Fix wrong heights data used to compute min and max heights

This commit is contained in:
Marc Gilleron 2019-04-04 21:22:18 +01:00
parent 6d27226134
commit cdcdba704b
1 changed files with 5 additions and 4 deletions

View File

@ -510,18 +510,19 @@ void HeightMapShapeBullet::set_data(const Variant &p_data) {
// Compute min and max heights if not specified. // Compute min and max heights if not specified.
if (!d.has("min_height") && !d.has("max_height")) { if (!d.has("min_height") && !d.has("max_height")) {
PoolVector<real_t>::Read r = heights.read(); PoolVector<real_t>::Read r = l_heights.read();
int heights_size = heights.size(); int heights_size = l_heights.size();
for (int i = 0; i < heights_size; ++i) { for (int i = 0; i < heights_size; ++i) {
real_t h = r[i]; real_t h = r[i];
if (h < l_min_height) if (h < l_min_height) {
l_min_height = h; l_min_height = h;
else if (h > l_max_height) } else if (h > l_max_height) {
l_max_height = h; l_max_height = h;
} }
} }
}
setup(l_heights, l_width, l_depth, l_min_height, l_max_height); setup(l_heights, l_width, l_depth, l_min_height, l_max_height);
} }