Skip to content

Commit f3278b7

Browse files
committed
Change collision float to real_t
1 parent 8ff2db7 commit f3278b7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/terrain_3d_collision.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Dictionary Terrain3DCollision::_get_shape_data(const Vector2i &p_position, const
3636
const int region_size = _terrain->get_region_size();
3737
const real_t region_texel_size = 1.f / real_t(region_size);
3838

39-
auto check_region = [&](const Vector2 &uv2) -> float {
39+
auto check_region = [&](const Vector2 &uv2) -> real_t {
4040
Vector2i pos = Vector2i(Math::floor(uv2.x), Math::floor(uv2.y)) + Vector2i(region_map_size / 2, region_map_size / 2);
4141
int layer_index = 0;
4242
if ((uint32_t)(pos.x | pos.y) < (uint32_t)region_map_size) {
@@ -46,22 +46,22 @@ Dictionary Terrain3DCollision::_get_shape_data(const Vector2i &p_position, const
4646
return real_t(layer_index);
4747
};
4848

49-
auto get_region_blend = [&](Vector2 uv2) -> float {
49+
auto get_region_blend = [&](Vector2 uv2) -> real_t {
5050
// Floating point bias (must match shader)
5151
uv2 -= Vector2(0.5011f, 0.5011f);
5252

53-
float a = check_region(uv2 + Vector2(0.0f, 1.0f));
54-
float b = check_region(uv2 + Vector2(1.0f, 1.0f));
55-
float c = check_region(uv2 + Vector2(1.0f, 0.0f));
56-
float d = check_region(uv2 + Vector2(0.0f, 0.0f));
53+
real_t a = check_region(uv2 + Vector2(0.0f, 1.0f));
54+
real_t b = check_region(uv2 + Vector2(1.0f, 1.0f));
55+
real_t c = check_region(uv2 + Vector2(1.0f, 0.0f));
56+
real_t d = check_region(uv2 + Vector2(0.0f, 0.0f));
5757

5858
real_t blend_factor = 2.0f + 126.0f * (1.0f - region_blend);
5959
Vector2 f = Vector2(uv2.x - Math::floor(uv2.x), uv2.y - Math::floor(uv2.y));
6060
f.x = Math::clamp(f.x, 1e-8f, 1.f - 1e-8f);
6161
f.y = Math::clamp(f.y, 1e-8f, 1.f - 1e-8f);
6262
Vector2 w = Vector2(1.f / (1.f + Math::exp(blend_factor * Math::log((1.f - f.x) / f.x))),
6363
1.f / (1.f + Math::exp(blend_factor * Math::log((1.f - f.y) / f.y))));
64-
float blend = Math::lerp(Math::lerp(d, c, w.x), Math::lerp(a, b, w.x), w.y);
64+
real_t blend = Math::lerp(Math::lerp(d, c, w.x), Math::lerp(a, b, w.x), w.y);
6565

6666
return (1.f - blend) * 2.f;
6767
};
@@ -121,7 +121,7 @@ Dictionary Terrain3DCollision::_get_shape_data(const Vector2i &p_position, const
121121
// Set heights on local map, or adjacent maps if on the last row/col
122122
real_t height = NAN;
123123
if (!next_x && !next_z && map.is_valid()) {
124-
height = is_hole(cmap->get_pixel(img_x, img_y).r) ? NAN : map->get_pixel(img_x, img_y).r;
124+
height = is_hole(cmap->get_pixel(img_x, img_y).r) ? NAN : map->get_pixel(img_x, img_y).r;
125125
} else if (next_x && !next_z && map_x.is_valid()) {
126126
height = is_hole(cmap_x->get_pixel(img_x, img_y).r) ? NAN : map_x->get_pixel(img_x, img_y).r;
127127
} else if (!next_x && next_z && map_z.is_valid()) {

0 commit comments

Comments
 (0)