Browse Source

use pivot position for center calculation

Raanan Weber 7 years ago
parent
commit
7b093d3c8b

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

@@ -363,7 +363,7 @@
             if (!bInfo) return;
             var center = impostor.getObjectCenter();
             //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
-            this._tmpDeltaPosition.copyFrom(object.getAbsolutePosition().subtract(center));
+            this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
             this._tmpPosition.copyFrom(center);
             var quaternion = object.rotationQuaternion;
 

+ 1 - 1
src/Physics/babylon.physicsImpostor.ts

@@ -387,7 +387,7 @@ module BABYLON {
 
             if (!this._options.disableBidirectionalTransformation) {
                 let bInfo = this.object.getBoundingInfo();
-                bInfo && this.object.rotationQuaternion && this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(this, /*bInfo.boundingBox.centerWorld*/ this.object.getAbsolutePosition(), this.object.rotationQuaternion);
+                bInfo && this.object.rotationQuaternion && this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(this, /*bInfo.boundingBox.centerWorld*/ this.object.getAbsolutePivotPoint(), this.object.rotationQuaternion);
             }
 
             this._onBeforePhysicsStepCallbacks.forEach((func) => {