|
@@ -100098,6 +100098,10 @@ var BABYLON;
|
|
body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
|
|
body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
|
|
body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_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"));
|
|
body.setRestitution(impostor.getParam("restitution"));
|
|
this.world.addRigidBody(body);
|
|
this.world.addRigidBody(body);
|
|
impostor.physicsBody = body;
|
|
impostor.physicsBody = body;
|
|
@@ -100212,7 +100216,11 @@ var BABYLON;
|
|
var childImpostor = childMesh.getPhysicsImpostor();
|
|
var childImpostor = childMesh.getPhysicsImpostor();
|
|
if (childImpostor) {
|
|
if (childImpostor) {
|
|
var shape = _this._createShape(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._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
|
|
_this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
|
|
_this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
|
|
returnValue.addChildShape(_this._tmpAmmoTransform, shape);
|
|
returnValue.addChildShape(_this._tmpAmmoTransform, shape);
|
|
@@ -100223,7 +100231,6 @@ var BABYLON;
|
|
var shape = this._createShape(impostor, true);
|
|
var shape = this._createShape(impostor, true);
|
|
if (shape) {
|
|
if (shape) {
|
|
this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
|
|
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._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
|
|
this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
|
|
this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
|
|
returnValue.addChildShape(this._tmpAmmoTransform, shape);
|
|
returnValue.addChildShape(this._tmpAmmoTransform, shape);
|
|
@@ -100255,6 +100262,10 @@ var BABYLON;
|
|
returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
|
|
returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
|
|
}
|
|
}
|
|
break;
|
|
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;
|
|
return returnValue;
|
|
};
|
|
};
|
|
@@ -100505,6 +100516,7 @@ var BABYLON;
|
|
Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
|
|
Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
|
|
this.world = null;
|
|
this.world = null;
|
|
};
|
|
};
|
|
|
|
+ AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
|
|
AmmoJSPlugin.KINEMATIC_FLAG = 2;
|
|
AmmoJSPlugin.KINEMATIC_FLAG = 2;
|
|
AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
|
|
AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
|
|
return AmmoJSPlugin;
|
|
return AmmoJSPlugin;
|
|
@@ -103645,6 +103657,10 @@ var BABYLON;
|
|
*/
|
|
*/
|
|
this.zDragFactor = 3;
|
|
this.zDragFactor = 3;
|
|
/**
|
|
/**
|
|
|
|
+ * If the object should rotate to face the drag origin
|
|
|
|
+ */
|
|
|
|
+ this.rotateDraggedObject = true;
|
|
|
|
+ /**
|
|
* If the behavior is currently in a dragging state
|
|
* If the behavior is currently in a dragging state
|
|
*/
|
|
*/
|
|
this.dragging = false;
|
|
this.dragging = false;
|
|
@@ -103711,7 +103727,7 @@ var BABYLON;
|
|
if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
|
|
if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
|
|
if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
|
|
if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
|
|
- pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
|
|
|
|
|
|
+ pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
|
|
}
|
|
}
|
|
pickedMesh = _this._ownerNode;
|
|
pickedMesh = _this._ownerNode;
|
|
BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
|
|
BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
|
|
@@ -103767,7 +103783,7 @@ var BABYLON;
|
|
if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
|
|
if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
|
|
var zDragFactor = _this.zDragFactor;
|
|
var zDragFactor = _this.zDragFactor;
|
|
if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
|
|
if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == BABYLON.Camera.RIG_MODE_NONE) {
|
|
- pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.position);
|
|
|
|
|
|
+ pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
|
|
zDragFactor = 0;
|
|
zDragFactor = 0;
|
|
}
|
|
}
|
|
// Calculate controller drag distance in controller space
|
|
// Calculate controller drag distance in controller space
|
|
@@ -103803,21 +103819,23 @@ var BABYLON;
|
|
BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
|
|
BABYLON.BoundingBoxGizmo._RemoveAndStorePivotPoint(pickedMesh);
|
|
// Slowly move mesh to avoid jitter
|
|
// Slowly move mesh to avoid jitter
|
|
pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
|
|
pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
|
|
- // Get change in rotation
|
|
|
|
- tmpQuaternion.copyFrom(_this._startingOrientation);
|
|
|
|
- tmpQuaternion.x = -tmpQuaternion.x;
|
|
|
|
- tmpQuaternion.y = -tmpQuaternion.y;
|
|
|
|
- tmpQuaternion.z = -tmpQuaternion.z;
|
|
|
|
- _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
|
|
|
|
- // Convert change in rotation to only y axis rotation
|
|
|
|
- BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
|
|
|
|
- tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
|
|
|
|
- // Slowly move mesh to avoid jitter
|
|
|
|
- var oldParent = pickedMesh.parent;
|
|
|
|
- pickedMesh.setParent(null);
|
|
|
|
- BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
|
|
|
|
- pickedMesh.setParent(oldParent);
|
|
|
|
- BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
|
|
|
|
|
|
+ if (_this.rotateDraggedObject) {
|
|
|
|
+ // Get change in rotation
|
|
|
|
+ tmpQuaternion.copyFrom(_this._startingOrientation);
|
|
|
|
+ tmpQuaternion.x = -tmpQuaternion.x;
|
|
|
|
+ tmpQuaternion.y = -tmpQuaternion.y;
|
|
|
|
+ tmpQuaternion.z = -tmpQuaternion.z;
|
|
|
|
+ _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
|
|
|
|
+ // Convert change in rotation to only y axis rotation
|
|
|
|
+ BABYLON.Quaternion.RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
|
|
|
|
+ tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
|
|
|
|
+ // Slowly move mesh to avoid jitter
|
|
|
|
+ var oldParent = pickedMesh.parent;
|
|
|
|
+ pickedMesh.setParent(null);
|
|
|
|
+ BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
|
|
|
|
+ pickedMesh.setParent(oldParent);
|
|
|
|
+ BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
};
|