sebavan 6 年之前
父節點
當前提交
1b75b24ef5

File diff suppressed because it is too large
+ 5172 - 5171
Playground/babylon.d.txt


File diff suppressed because it is too large
+ 5180 - 5179
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.js


+ 14 - 2
dist/preview release/babylon.max.js

@@ -100098,6 +100098,10 @@ var BABYLON;
                     body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
                     body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
                 }
+                // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
+                if (impostor.type == BABYLON.PhysicsImpostor.NoImpostor && !colShape.getChildShape) {
+                    body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
+                }
                 body.setRestitution(impostor.getParam("restitution"));
                 this.world.addRigidBody(body);
                 impostor.physicsBody = body;
@@ -100212,7 +100216,11 @@ var BABYLON;
                         var childImpostor = childMesh.getPhysicsImpostor();
                         if (childImpostor) {
                             var shape = _this._createShape(childImpostor);
-                            _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x, childMesh.position.y, childMesh.position.z);
+                            // Position needs to be scaled based on parent's scaling
+                            var parentMat = childMesh.parent.getWorldMatrix().clone();
+                            var s = new BABYLON.Vector3();
+                            parentMat.decompose(s);
+                            _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
                             _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
                             _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
                             returnValue.addChildShape(_this._tmpAmmoTransform, shape);
@@ -100223,7 +100231,6 @@ var BABYLON;
                     var shape = this._createShape(impostor, true);
                     if (shape) {
                         this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
-                        //this._tmpAmmoQuaternion = new this.BJSAMMO.btQuaternion(0,0,0,1);
                         this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
                         this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
                         returnValue.addChildShape(this._tmpAmmoTransform, shape);
@@ -100255,6 +100262,10 @@ var BABYLON;
                         returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
                     }
                     break;
+                case BABYLON.PhysicsImpostor.NoImpostor:
+                    // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
+                    returnValue = new Ammo.btSphereShape(extendSize.x / 2);
+                    break;
             }
             return returnValue;
         };
@@ -100505,6 +100516,7 @@ var BABYLON;
             Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
             this.world = null;
         };
+        AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
         AmmoJSPlugin.KINEMATIC_FLAG = 2;
         AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
         return AmmoJSPlugin;

+ 14 - 2
dist/preview release/babylon.no-module.max.js

@@ -100065,6 +100065,10 @@ var BABYLON;
                     body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
                     body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
                 }
+                // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
+                if (impostor.type == BABYLON.PhysicsImpostor.NoImpostor && !colShape.getChildShape) {
+                    body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
+                }
                 body.setRestitution(impostor.getParam("restitution"));
                 this.world.addRigidBody(body);
                 impostor.physicsBody = body;
@@ -100179,7 +100183,11 @@ var BABYLON;
                         var childImpostor = childMesh.getPhysicsImpostor();
                         if (childImpostor) {
                             var shape = _this._createShape(childImpostor);
-                            _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x, childMesh.position.y, childMesh.position.z);
+                            // Position needs to be scaled based on parent's scaling
+                            var parentMat = childMesh.parent.getWorldMatrix().clone();
+                            var s = new BABYLON.Vector3();
+                            parentMat.decompose(s);
+                            _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
                             _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
                             _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
                             returnValue.addChildShape(_this._tmpAmmoTransform, shape);
@@ -100190,7 +100198,6 @@ var BABYLON;
                     var shape = this._createShape(impostor, true);
                     if (shape) {
                         this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
-                        //this._tmpAmmoQuaternion = new this.BJSAMMO.btQuaternion(0,0,0,1);
                         this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
                         this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
                         returnValue.addChildShape(this._tmpAmmoTransform, shape);
@@ -100222,6 +100229,10 @@ var BABYLON;
                         returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
                     }
                     break;
+                case BABYLON.PhysicsImpostor.NoImpostor:
+                    // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
+                    returnValue = new Ammo.btSphereShape(extendSize.x / 2);
+                    break;
             }
             return returnValue;
         };
@@ -100472,6 +100483,7 @@ var BABYLON;
             Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
             this.world = null;
         };
+        AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
         AmmoJSPlugin.KINEMATIC_FLAG = 2;
         AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
         return AmmoJSPlugin;

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.worker.js


+ 14 - 2
dist/preview release/es6.js

@@ -100065,6 +100065,10 @@ var BABYLON;
                     body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
                     body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
                 }
+                // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
+                if (impostor.type == BABYLON.PhysicsImpostor.NoImpostor && !colShape.getChildShape) {
+                    body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
+                }
                 body.setRestitution(impostor.getParam("restitution"));
                 this.world.addRigidBody(body);
                 impostor.physicsBody = body;
@@ -100179,7 +100183,11 @@ var BABYLON;
                         var childImpostor = childMesh.getPhysicsImpostor();
                         if (childImpostor) {
                             var shape = _this._createShape(childImpostor);
-                            _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x, childMesh.position.y, childMesh.position.z);
+                            // Position needs to be scaled based on parent's scaling
+                            var parentMat = childMesh.parent.getWorldMatrix().clone();
+                            var s = new BABYLON.Vector3();
+                            parentMat.decompose(s);
+                            _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
                             _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
                             _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
                             returnValue.addChildShape(_this._tmpAmmoTransform, shape);
@@ -100190,7 +100198,6 @@ var BABYLON;
                     var shape = this._createShape(impostor, true);
                     if (shape) {
                         this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
-                        //this._tmpAmmoQuaternion = new this.BJSAMMO.btQuaternion(0,0,0,1);
                         this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
                         this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
                         returnValue.addChildShape(this._tmpAmmoTransform, shape);
@@ -100222,6 +100229,10 @@ var BABYLON;
                         returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
                     }
                     break;
+                case BABYLON.PhysicsImpostor.NoImpostor:
+                    // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
+                    returnValue = new Ammo.btSphereShape(extendSize.x / 2);
+                    break;
             }
             return returnValue;
         };
@@ -100472,6 +100483,7 @@ var BABYLON;
             Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
             this.world = null;
         };
+        AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
         AmmoJSPlugin.KINEMATIC_FLAG = 2;
         AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
         return AmmoJSPlugin;

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js