瀏覽代碼

Merge pull request #5397 from barroij/BboxFix

fix bug in PhysicsImpostor.HeightmapImpostor
David Catuhe 6 年之前
父節點
當前提交
5720b2ec7c
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      src/Physics/Plugins/babylon.cannonJSPlugin.ts

+ 8 - 1
src/Physics/Plugins/babylon.cannonJSPlugin.ts

@@ -435,7 +435,14 @@ module BABYLON {
                 //get original center with no rotation
                 var c = center.clone();
 
-                var oldPivot = mesh.getPivotMatrix() || Matrix.Translation(0, 0, 0);
+                var oldPivot = mesh.getPivotMatrix();
+                if (oldPivot) {
+                    // create a copy the pivot Matrix as it is modified in place
+                    oldPivot = oldPivot.clone();
+                }
+                else {
+                    oldPivot = Matrix.Identity();
+                }
 
                 //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
                 var p = Matrix.Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);