Skip to content

Commit

Permalink
clarify comments separate case logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtarsia committed Nov 2, 2024
1 parent b073250 commit 1aae194
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/terrain_3d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,31 +362,31 @@ void Terrain3DEditor::_operate_map(const Vector3 &p_global_position, const real_
}

// Overlay Spray
case ADD:
case SUBTRACT: {
case ADD: {
real_t spray_strength = CLAMP(strength * 0.05f, 0.004f, .25f);
real_t brush_value = CLAMP(brush_alpha * spray_strength, 0.f, 1.f);
if (enable_texture && brush_alpha * strength * 11.f > 0.1f) {
// Painted area, set overlay immediatley
if (base_id == overlay_id && blend < 0.004f) {
overlay_id = asset_id;
}
// If overlay and base texture are the same, reduce blend value
// Overlay and base texture are the same, reduce blend value
if (base_id == asset_id) {
blend = modifier_ctrl ? CLAMP(blend + brush_value, 0.f, 1.f) : CLAMP(blend - brush_value, 0.f, 1.f);
if (blend < 0.5f && brush_alpha > 0.5f && !modifier_ctrl) {
blend = CLAMP(blend - brush_value, 0.f, 1.f);
if (blend < 0.5f && brush_alpha > 0.5f) {
autoshader = false;
}
} else {
// Else overlay and base are separate, increase blend value
blend = modifier_ctrl ? CLAMP(blend - brush_value, 0.f, 1.f) : CLAMP(blend + brush_value, 0.f, 1.f);
// Overlay and base are separate, increase blend value
blend = CLAMP(blend + brush_value, 0.f, 1.f);
// Overlay already visibile, limit ID changes to high brush alpha
if (blend > 0.5f && brush_alpha > 0.5f && !modifier_ctrl) {
if (blend > 0.5f && brush_alpha > 0.5f) {
overlay_id = asset_id;
// Only remove auto shader when blend is past threshold.
autoshader = false;
}
// Overlay not visible at brush edge, write new ID ready for potential next pass
if (blend <= 0.5f && brush_alpha <= 0.5f && !modifier_ctrl) {
if (blend <= 0.5f && brush_alpha <= 0.5f) {
overlay_id = asset_id;
}
}
Expand All @@ -412,6 +412,18 @@ void Terrain3DEditor::_operate_map(const Vector3 &p_global_position, const real_
break;
}

// Overlay Spray reduce
case SUBTRACT: {
real_t spray_strength = CLAMP(strength * 0.05f, 0.004f, .25f);
real_t brush_value = CLAMP(brush_alpha * spray_strength, 0.f, 1.f);
blend = CLAMP(blend - brush_value, 0.f, 1.f);
// Reset to painted state
if (blend < 0.004f) {
overlay_id = base_id;
}
break;
}

default: {
break;
}
Expand Down

0 comments on commit 1aae194

Please sign in to comment.