Updated sdf code to work in C++

This commit is contained in:
Segey Lapin
2021-10-14 13:42:21 +03:00
parent 2c7a6af437
commit 8c4432031e
5 changed files with 77 additions and 287 deletions

View File

@@ -614,10 +614,11 @@ float RoadsData::get_sdf(int x, int y, int z)
if (!curve.is_valid() || !noise.is_valid())
return (float)y;
float n = curve->interpolate_baked(0.5f + noise->get_noise_2d(x, z) * 0.5f);
Vector2 ifl = rg->get_influence(x, z);
n = CLAMP(n, -1000.0f, 1000.0f);
Vector2 ifl = rg->get_influence(x, z, 32.0f);
if (ifl.x > 0.0f) {
if (n <= ifl.y + 2.0f)
return (float)y - ifl.y;
if (n <= ifl.y - 0.5f)
return (float)y - ifl.y - 0.6f;
else
return (float)y - ifl.y;
}