|
@@ -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;
|