示例#1
0
        protected void Add(PhyBody phyBody)
        {
            _AddPhyBody(phyBody);
            AddBulletPhysicsTransform(phyBody);
            phyBody.SetWorldTransform(phyBody.matrix);

            if (phyBody.Constraint != null)
            {
                World.AddConstraint(phyBody.Constraint);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
        }
示例#4
0
        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
            }
        }
示例#5
0
 protected void Add(PhyBody phyBody, UnityEngine.Vector3 pos)
 {
     Add(phyBody, pos, Quaternion.identity);
 }
示例#6
0
 protected void Add(PhyBody phyBody, UnityEngine.Vector3 pos, Quaternion rot)
 {
     Add(phyBody, Matrix4x4.TRS(pos, rot, UnityEngine.Vector3.one).ToBullet());
 }
示例#7
0
        // ========================================================================== Add PhyBody to physics world ===

        private void _AddPhyBody(PhyBody phyBody)
        {
            World.AddCollisionObject(phyBody.body, (CollisionFilterGroups)(1 << phyBody.phyType), (CollisionFilterGroups)_collisionsMap[phyBody.phyType]);
        }