Skip to content

Commit

Permalink
Update terrain_3d_editor.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtarsia committed Sep 16, 2024
1 parent 896d39d commit f302e0f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/terrain_3d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ void Terrain3DEditor::_operate_map(const Vector3 &p_global_position, const real_
bool navigation = is_nav(src.r);
bool autoshader = is_auto(src.r);

real_t alpha_clip = (brush_alpha > 0.1f) ? 1.f : 0.f;
uint32_t dest_id = uint32_t(Math::lerp(base_id, asset_id, alpha_clip));
real_t alpha_clip = (brush_alpha > 0.5f) ? 1.f : 0.f;
uint32_t dest_id = asset_id; //uint32_t(Math::lerp(base_id, asset_id, alpha_clip));
// Lookup to shift values saved to control map so that 0 (default) is the first entry
// Shader scale array is aligned to match this.
std::array<uint32_t, 8> scale_align = { 5, 6, 7, 0, 1, 2, 3, 4 };
Expand All @@ -320,7 +320,7 @@ void Terrain3DEditor::_operate_map(const Vector3 &p_global_position, const real_
switch (_operation) {
// Base Paint
case REPLACE: {
if (brush_alpha > 0.1f) {
if (brush_alpha > 0.5f) {
if (enable_texture) {
// Set base texture
base_id = dest_id;
Expand Down Expand Up @@ -352,7 +352,7 @@ void Terrain3DEditor::_operate_map(const Vector3 &p_global_position, const real_
case ADD: {
real_t spray_strength = CLAMP(strength * 0.05f, 0.003f, .25f);
real_t brush_value = CLAMP(brush_alpha * spray_strength, 0.f, 1.f);
if (enable_texture) {
if (enable_texture && brush_alpha * strength * 11.f > 0.5f) {
// If overlay and base texture are the same, reduce blend value
if (dest_id == base_id) {
blend = CLAMP(blend - brush_value, 0.f, 1.f);
Expand All @@ -361,9 +361,8 @@ void Terrain3DEditor::_operate_map(const Vector3 &p_global_position, const real_
overlay_id = dest_id;
blend = CLAMP(blend + brush_value, 0.f, 1.f);
}
autoshader = false;
}
if (brush_alpha * strength * 11.f > 0.1f) {
if (brush_alpha * strength * 11.f > 0.5f && ((dest_id == base_id) && blend < 0.5f || blend > 0.5f)) {
// Set angle & scale
if (enable_angle) {
if (dynamic_angle) {
Expand All @@ -380,6 +379,7 @@ void Terrain3DEditor::_operate_map(const Vector3 &p_global_position, const real_
// Maintain 0 = 0, remap negatives to end.
uvscale = scale_align[uint8_t(CLAMP(Math::round((scale + 60.f) / 20.f), 0.f, 7.f))];
}
autoshader = false;
}
break;
}
Expand All @@ -390,19 +390,19 @@ void Terrain3DEditor::_operate_map(const Vector3 &p_global_position, const real_
}
break;
case AUTOSHADER: {
if (brush_alpha > 0.1f) {
if (brush_alpha > 0.5f) {
autoshader = (_operation == ADD);
}
break;
}
case HOLES: {
if (brush_alpha > 0.1f) {
if (brush_alpha > 0.5f) {
hole = (_operation == ADD);
}
break;
}
case NAVIGATION: {
if (brush_alpha > 0.1f) {
if (brush_alpha > 0.5f) {
navigation = (_operation == ADD);
}
break;
Expand Down

0 comments on commit f302e0f

Please sign in to comment.