Skip to content

Commit

Permalink
Remove expand/reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
TokisanGames committed Aug 4, 2024
1 parent e64f598 commit 4087e3b
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 42 deletions.
6 changes: 0 additions & 6 deletions project/addons/terrain_3d/src/toolbar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const ICON_REGION_ADD: String = "res://addons/terrain_3d/icons/region_add.svg"
const ICON_REGION_REMOVE: String = "res://addons/terrain_3d/icons/region_remove.svg"
const ICON_HEIGHT_ADD: String = "res://addons/terrain_3d/icons/height_add.svg"
const ICON_HEIGHT_SUB: String = "res://addons/terrain_3d/icons/height_sub.svg"
const ICON_HEIGHT_MUL: String = "res://addons/terrain_3d/icons/height_mul.svg"
const ICON_HEIGHT_DIV: String = "res://addons/terrain_3d/icons/height_div.svg"
const ICON_HEIGHT_FLAT: String = "res://addons/terrain_3d/icons/height_flat.svg"
const ICON_HEIGHT_SLOPE: String = "res://addons/terrain_3d/icons/height_slope.svg"
const ICON_HEIGHT_SMOOTH: String = "res://addons/terrain_3d/icons/height_smooth.svg"
Expand Down Expand Up @@ -42,10 +40,6 @@ func _ready() -> void:
"add_text":"Raise", "add_op":Terrain3DEditor.ADD, "add_icon":ICON_HEIGHT_ADD,
"sub_text":"Lower", "sub_op":Terrain3DEditor.SUBTRACT, "sub_icon":ICON_HEIGHT_SUB })

add_tool_button({ "tool":Terrain3DEditor.HEIGHT,
"add_text":"Expand", "add_op":Terrain3DEditor.MULTIPLY, "add_icon":ICON_HEIGHT_MUL,
"sub_text":"Reduce", "sub_op":Terrain3DEditor.DIVIDE, "sub_icon":ICON_HEIGHT_DIV })

add_tool_button({ "tool":Terrain3DEditor.HEIGHT,
"add_text":"Smooth", "add_op":Terrain3DEditor.AVERAGE, "add_icon":ICON_HEIGHT_SMOOTH })

Expand Down
13 changes: 1 addition & 12 deletions project/addons/terrain_3d/src/ui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ func _on_tool_changed(p_tool: Terrain3DEditor.Tool, p_operation: Terrain3DEditor
to_show.push_back("brush")
to_show.push_back("size")
to_show.push_back("strength")
if p_operation in [Terrain3DEditor.ADD, Terrain3DEditor.SUBTRACT, \
Terrain3DEditor.MULTIPLY, Terrain3DEditor.DIVIDE]:
if p_operation in [Terrain3DEditor.ADD, Terrain3DEditor.SUBTRACT]:
to_show.push_back("remove")
elif p_operation == Terrain3DEditor.REPLACE:
to_show.push_back("height")
Expand Down Expand Up @@ -303,12 +302,6 @@ func update_decal() -> void:
else:
decal.modulate = COLOR_LOWER
decal.modulate.a = clamp(brush_data["strength"], .2, .5) + .5
Terrain3DEditor.MULTIPLY:
decal.modulate = COLOR_EXPAND
decal.modulate.a = clamp(brush_data["strength"], .2, .5)
Terrain3DEditor.DIVIDE:
decal.modulate = COLOR_REDUCE
decal.modulate.a = clamp(brush_data["strength"], .2, .5)
Terrain3DEditor.REPLACE:
decal.modulate = COLOR_HEIGHT
decal.modulate.a = clamp(brush_data["strength"], .2, .5)
Expand Down Expand Up @@ -474,10 +467,6 @@ func _invert_operation(p_operation: Terrain3DEditor.Operation, flags: int = OP_N
return Terrain3DEditor.SUBTRACT
elif p_operation == Terrain3DEditor.SUBTRACT and ! (flags & OP_NEGATIVE_ONLY):
return Terrain3DEditor.ADD
elif p_operation == Terrain3DEditor.MULTIPLY and ! (flags & OP_POSITIVE_ONLY):
return Terrain3DEditor.DIVIDE
elif p_operation == Terrain3DEditor.DIVIDE and ! (flags & OP_NEGATIVE_ONLY):
return Terrain3DEditor.MULTIPLY
return p_operation


Expand Down
20 changes: 0 additions & 20 deletions src/terrain_3d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,6 @@ void Terrain3DEditor::_operate_map(const Vector3 &p_global_position, const real_
}
break;
}
case MULTIPLY: {
brush_alpha *= (srcf > 0) ? 1 : -1;
destf = srcf * (brush_alpha * strength * .01f + 1.0f);
if (lift_floor && !std::isnan(p_global_position.y)) {
real_t brush_center_y = p_global_position.y * (brush_alpha * strength * .01f + 1.0f);
destf = Math::clamp(brush_center_y, srcf, destf);
}
break;
}
case DIVIDE: {
brush_alpha *= (srcf < 0) ? 1 : -1;
destf = srcf * (brush_alpha * strength * .01f + 1.0f);
if (flatten_peaks && !std::isnan(p_global_position.y)) {
real_t brush_center_y = p_global_position.y * (brush_alpha * strength * .01f + 1.0f);
destf = Math::clamp(brush_center_y, destf, srcf);
}
break;
}
case REPLACE: {
destf = Math::lerp(srcf, height, brush_alpha * strength * .5f);
break;
Expand Down Expand Up @@ -720,8 +702,6 @@ void Terrain3DEditor::stop_operation() {
void Terrain3DEditor::_bind_methods() {
BIND_ENUM_CONSTANT(ADD);
BIND_ENUM_CONSTANT(SUBTRACT);
BIND_ENUM_CONSTANT(MULTIPLY);
BIND_ENUM_CONSTANT(DIVIDE);
BIND_ENUM_CONSTANT(REPLACE);
BIND_ENUM_CONSTANT(AVERAGE);
BIND_ENUM_CONSTANT(GRADIENT);
Expand Down
4 changes: 0 additions & 4 deletions src/terrain_3d_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class Terrain3DEditor : public Object {
enum Operation {
ADD,
SUBTRACT,
MULTIPLY,
DIVIDE,
REPLACE,
AVERAGE,
GRADIENT,
Expand All @@ -29,8 +27,6 @@ class Terrain3DEditor : public Object {
static inline const char *OPNAME[] = {
"Add",
"Subtract",
"Multiply",
"Divide",
"Replace",
"Average",
"Gradient",
Expand Down

0 comments on commit 4087e3b

Please sign in to comment.