summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2019-04-25 13:03:48 +1000
committerBastiaan Olij <mux213@gmail.com>2019-05-07 22:43:10 +1000
commite4dea0595aae76de254502bca714b9e54e46b74a (patch)
treef8fecbce5e87dd83b0d24c8599a03e9b76b0d1bb /scene/resources
parent4bb0df7060329390890d74ede7ec848eef552b16 (diff)
Add transform support to deal with Bullets centering of shapes
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/height_map_shape.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/scene/resources/height_map_shape.cpp b/scene/resources/height_map_shape.cpp
index 98b597ac0a..8cd271dab0 100644
--- a/scene/resources/height_map_shape.cpp
+++ b/scene/resources/height_map_shape.cpp
@@ -44,16 +44,6 @@ Vector<Vector3> HeightMapShape::_gen_debug_mesh_lines() {
PoolRealArray::Read r = map_data.read();
- // Bullet centers our heightmap, this is really counter intuitive but for now we'll adjust our debug shape accordingly:
- // https://github.com/bulletphysics/bullet3/blob/master/src/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h#L33
- float min = r[0];
- float max = r[0];
- for (int i = 0; i < map_data.size(); i++) {
- if (min > r[i]) min = r[i];
- if (max < r[i]) max = r[i];
- };
- float center = min + ((max - min) * 0.5);
-
// reserve some memory for our points..
points.resize(((map_width - 1) * map_depth * 2) + (map_width * (map_depth - 1) * 2));
@@ -64,16 +54,16 @@ Vector<Vector3> HeightMapShape::_gen_debug_mesh_lines() {
Vector3 height(start.x, 0.0, start.y);
for (int w = 0; w < map_width; w++) {
- height.y = r[r_offset++] - center;
+ height.y = r[r_offset++];
if (w != map_width - 1) {
points.write[w_offset++] = height;
- points.write[w_offset++] = Vector3(height.x + 1.0, r[r_offset] - center, height.z);
+ points.write[w_offset++] = Vector3(height.x + 1.0, r[r_offset], height.z);
}
if (d != map_depth - 1) {
points.write[w_offset++] = height;
- points.write[w_offset++] = Vector3(height.x, r[r_offset + map_width - 1] - center, height.z + 1.0);
+ points.write[w_offset++] = Vector3(height.x, r[r_offset + map_width - 1], height.z + 1.0);
}
height.x += 1.0;