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

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

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