chore: adjusted line modifier

This commit is contained in:
Sara Gerretsen 2026-04-16 11:52:57 +02:00
parent cb44c4a2fc
commit cac2a1288f
2 changed files with 5 additions and 3 deletions

View file

@ -12,3 +12,4 @@
- [x] Stop processing terrain after generation is complete
- [x] Don't start generation threads if all meshes are cached
- [ ] Scaling modifiers
- [ ] Rewrite line modifier

View file

@ -287,12 +287,13 @@ float TerrainModifierPath::evaluate_line(Vector3 a, bool a_end, Vector3 b, bool
Vector2 const difference2{ b2 - a2 };
float w{ difference2.normalized().dot(relative_coordinate) / difference2.length() };
Vector3 const difference{ b - a };
Vector3 const closest_on_line{ a + difference * (w > 0 ? (w < 1 ? w : 1) : 0) };
float const w_clamped{ (w > 0 ? (w < 1 ? w : 1) : 0) };
Vector3 const closest_on_line{ a + difference * w_clamped };
Vector2 const right{ -difference.z, difference.x };
out_dot = right.normalized().dot(relative_coordinate);
out_distance = world_coordinate.distance_to({ closest_on_line.x, closest_on_line.z });
out_percentage = w;
return a.y + (b.y - a.y) * w;
out_percentage = w_clamped;
return a.y + (b.y - a.y) * w_clamped;
}
float TerrainModifierPath::evaluate_at(Vector2 world_coordinate, float before) {