protected void Add(PhyBody phyBody) { _AddPhyBody(phyBody); AddBulletPhysicsTransform(phyBody); phyBody.SetWorldTransform(phyBody.matrix); if (phyBody.Constraint != null) { World.AddConstraint(phyBody.Constraint); } }
protected void Add(PhyBody phyBody, Matrix m) { _AddPhyBody(phyBody); AddBulletPhysicsTransform(phyBody); m = m * Matrix.Translation(-phyBody.offset); phyBody.SetWorldTransform(m); if (phyBody.Constraint != null) { World.AddConstraint(phyBody.Constraint); } }
protected void DeferredRegistration(PhyBody phyBody, GameObject go) { var drb = go.AddComponent <DeferredRegistrationBehaviour>(); drb.motionStateView = phyBody.ToView(); drb.localToWorld = phyBody.isLocalToWorldSet ? phyBody.localToWorld : LocalToWorld; drb.phyBody = phyBody; #if UNITY_EDITOR drb.rigidBodyView = phyBody.body.ToView(); #endif _HideGameObject(go); }
protected void AddBulletPhysicsTransform(PhyBody phyBody) { if (phyBody.entity != Entity.Null) { entityManager.AddComponent <BulletPhysicsTransformData>(phyBody.entity); entityManager.AddComponentData(phyBody.entity, new BulletPhysicsTransformData { motionStateView = phyBody.ToView(), localToWorld = LocalToWorld, lockPosition = phyBody.lockPosition, #if UNITY_EDITOR rigidBodyView = phyBody.body.ToView(), #endif }); #if UNITY_EDITOR entityManager.SetName(phyBody.entity, phyBody.name); #endif } }
protected void Add(PhyBody phyBody, UnityEngine.Vector3 pos) { Add(phyBody, pos, Quaternion.identity); }
protected void Add(PhyBody phyBody, UnityEngine.Vector3 pos, Quaternion rot) { Add(phyBody, Matrix4x4.TRS(pos, rot, UnityEngine.Vector3.one).ToBullet()); }
// ========================================================================== Add PhyBody to physics world === private void _AddPhyBody(PhyBody phyBody) { World.AddCollisionObject(phyBody.body, (CollisionFilterGroups)(1 << phyBody.phyType), (CollisionFilterGroups)_collisionsMap[phyBody.phyType]); }