Ver código fonte

Fixes heightfield for non-square grids. Tested on rectangular heightmaps.

Ken Whatmough 13 anos atrás
pai
commit
ba23eea169
1 arquivos alterados com 3 adições e 3 exclusões
  1. 3 3
      gameplay/src/PhysicsController.cpp

+ 3 - 3
gameplay/src/PhysicsController.cpp

@@ -1038,9 +1038,9 @@ PhysicsCollisionShape* PhysicsController::createHeightfield(Node* node, Image* i
             // which is just under 0.4%.
             // which is just under 0.4%.
             //
             //
             heights[x + y * w] = normalizedHeightPacked(
             heights[x + y * w] = normalizedHeightPacked(
-                data[(x + y * h) * pixelSize + 0],
-                data[(x + y * h) * pixelSize + 1],
-                data[(x + y * h) * pixelSize + 2]) * (maxHeight - minHeight) + minHeight;
+                data[(x + y * w) * pixelSize + 0],
+                data[(x + y * w) * pixelSize + 1],
+                data[(x + y * w) * pixelSize + 2]) * (maxHeight - minHeight) + minHeight;
         }
         }
     }
     }