[0] Cannon物理设置了ColliderShape的localOffset属性 并 isKinematic=true时模型会匀速移动

现象是 当使用  Cannon物理引擎时,设置了 ColliderShape的localOffset属性后,即使 isKinematic=true ,模型会匀速移动。
 已经附上 专门制作的能工重现的项目代码,
 
目测bug原因是 laya.cannonPhysics.js 内的_innerDerivePhysicsTransformation 方法中,错误的将 colliderShape.localOffset 的世界坐标,设置成了 transform.position 。导致物体会一直匀速移动。
 _innerDerivePhysicsTransformation(physicTransformOut, force) {
var transform = this.owner._transform;
if (force || this._getTransformFlag(Laya.Transform3D.TRANSFORM_WORLDPOSITION)) {
var shapeOffset = this._colliderShape.localOffset;
var position = transform.position;
var btPosition = CannonPhysicsComponent._btVector30;
if (shapeOffset.x !== 0 || shapeOffset.y !== 0 || shapeOffset.z !== 0) {
var physicPosition = CannonPhysicsComponent._tempVector30;
var worldMat = transform.worldMatrix;
Laya.Vector3.transformCoordinate(shapeOffset, worldMat, physicPosition);
btPosition.set(physicPosition.x, physicPosition.y, physicPosition.z);
}
else {
btPosition.set(position.x, position.y, position.z);
}
physicTransformOut.position.set(btPosition.x, btPosition.y, btPosition.z);
this._setTransformFlag(Laya.Transform3D.TRANSFORM_WORLDPOSITION, false);
}
if (force || this._getTransformFlag(Laya.Transform3D.TRANSFORM_WORLDQUATERNION)) {
var shapeRotation = this._colliderShape.localRotation;
var btRotation = CannonPhysicsComponent._btQuaternion0;
var rotation = transform.rotation;
if (shapeRotation.x !== 0 || shapeRotation.y !== 0 || shapeRotation.z !== 0 || shapeRotation.w !== 1) {
var physicRotation = CannonPhysicsComponent._tempQuaternion0;
CannonPhysicsComponent.physicQuaternionMultiply(rotation.x, rotation.y, rotation.z, rotation.w, shapeRotation, physicRotation);
btRotation.set(physicRotation.x, physicRotation.y, physicRotation.z, physicRotation.w);
}
else {
btRotation.set(rotation.x, rotation.y, rotation.z, rotation.w);
}
physicTransformOut.quaternion.set(btRotation.x, btRotation.y, btRotation.z, btRotation.w);
this._setTransformFlag(Laya.Transform3D.TRANSFORM_WORLDQUATERNION, false);
}
if (force || this._getTransformFlag(Laya.Transform3D.TRANSFORM_WORLDSCALE)) {
this._onScaleChange(transform.getWorldLossyScale());
this._setTransformFlag(Laya.Transform3D.TRANSFORM_WORLDSCALE, false);
}
}

 
已邀请:

Laya_Fred

赞同来自:

感谢反馈,我们复现下问题,有最新消息会回复您。

要回复问题请先

商务合作
商务合作