示例#1
0
 public bool Equals(EntityProperties other)
 {
     if (this.ID == other.ID && this.Position == other.Position && this.Rotation == other.Rotation && this.Velocity == other.Velocity && this.Acceleration == other.Acceleration)
         return this.AngularVelocity == other.AngularVelocity;
     else
         return false;
 }
示例#2
0
 public EntityProperties FromTransform(uint id, IndexedMatrix startTransform)
 {
     EntityProperties ret = new EntityProperties();
     ID = id;
     Position = startTransform._origin;
     Rotation = startTransform.GetRotation();
     return ret;
 }
示例#3
0
        public EntityProperties FromTransform(uint id, IndexedMatrix startTransform)
        {
            EntityProperties ret = new EntityProperties();

            ID       = id;
            Position = startTransform._origin;
            Rotation = startTransform.GetRotation();
            return(ret);
        }
示例#4
0
 public bool Equals(EntityProperties other)
 {
     if (this.ID == other.ID && this.Position == other.Position && this.Rotation == other.Rotation && this.Velocity == other.Velocity && this.Acceleration == other.Acceleration)
     {
         return(this.AngularVelocity == other.AngularVelocity);
     }
     else
     {
         return(false);
     }
 }
示例#5
0
 public SimMotionState(CollisionWorld pWorld, uint id, IndexedMatrix starTransform, object frameUpdates)
 {
     m_properties = new EntityProperties()
     {
         ID       = id,
         Position = starTransform._origin,
         Rotation = starTransform.GetRotation()
     };
     m_lastProperties = new EntityProperties()
     {
         ID       = id,
         Position = starTransform._origin,
         Rotation = starTransform.GetRotation()
     };
     m_world = pWorld;
     m_xform = starTransform;
 }
示例#6
0
        public void SetWorldTransform(ref IndexedMatrix worldTrans, bool force)
        {
            m_xform = worldTrans;
            // Put the new transform into m_properties
            m_properties.Position = m_xform._origin;
            m_properties.Rotation = m_xform.GetRotation();
            // A problem with stock Bullet is that we don't get an event when an object is deactivated.
            // This means that the last non-zero values for linear and angular velocity
            // are left in the viewer who does dead reconning and the objects look like
            // they float off.
            // BulletSim ships with a patch to Bullet which creates such an event.
            m_properties.Velocity        = Rigidbody.GetLinearVelocity();
            m_properties.AngularVelocity = Rigidbody.GetAngularVelocity();

            if (force

                || !AlmostEqual(ref m_lastProperties.Position, ref m_properties.Position, POSITION_TOLERANCE) ||
                !AlmostEqual(ref m_properties.Rotation, ref m_lastProperties.Rotation, ROTATION_TOLERANCE)
                // If the Velocity and AngularVelocity are zero, most likely the object has
                //    been deactivated. If they both are zero and they have become zero recently,
                //    make sure a property update is sent so the zeros make it to the viewer.
                || ((m_properties.Velocity == ZeroVect && m_properties.AngularVelocity == ZeroVect)
                    &&
                    (m_properties.Velocity != m_lastProperties.Velocity ||
                     m_properties.AngularVelocity != m_lastProperties.AngularVelocity))
                //	If Velocity and AngularVelocity are non-zero but have changed, send an update.
                || !AlmostEqual(ref m_properties.Velocity, ref m_lastProperties.Velocity, VELOCITY_TOLERANCE)
                ||
                !AlmostEqual(ref m_properties.AngularVelocity, ref m_lastProperties.AngularVelocity,
                             ANGULARVELOCITY_TOLERANCE)
                )


            {
                // Add this update to the list of updates for this frame.
                m_lastProperties = m_properties;
                if (m_world.LastEntityProperty < m_world.UpdatedObjects.Length)
                {
                    m_world.UpdatedObjects[m_world.LastEntityProperty++] = (m_properties);
                }

                //(*m_updatesThisFrame)[m_properties.ID] = &m_properties;
            }
        }
示例#7
0
 public SimMotionState(CollisionWorld pWorld, uint id, IndexedMatrix starTransform, object frameUpdates)
 {
     m_properties = new EntityProperties()
                        {
                            ID = id,
                            Position = starTransform._origin,
                            Rotation = starTransform.GetRotation()
                        };
     m_lastProperties = new EntityProperties()
     {
         ID = id,
         Position = starTransform._origin,
         Rotation = starTransform.GetRotation()
     };
     m_world = pWorld;
     m_xform = starTransform;
 }
示例#8
0
        public void SetWorldTransform(ref IndexedMatrix worldTrans, bool force)
        {
            m_xform = worldTrans;
            // Put the new transform into m_properties
            m_properties.Position = m_xform._origin;
            m_properties.Rotation = m_xform.GetRotation();
            // A problem with stock Bullet is that we don't get an event when an object is deactivated.
            // This means that the last non-zero values for linear and angular velocity
            // are left in the viewer who does dead reconning and the objects look like
            // they float off.
            // BulletSim ships with a patch to Bullet which creates such an event.
            m_properties.Velocity = Rigidbody.GetLinearVelocity();
            m_properties.AngularVelocity = Rigidbody.GetAngularVelocity();

            if (force

                || !AlmostEqual(ref m_lastProperties.Position, ref m_properties.Position, POSITION_TOLERANCE)
                || !AlmostEqual(ref m_properties.Rotation, ref m_lastProperties.Rotation, ROTATION_TOLERANCE)
                // If the Velocity and AngularVelocity are zero, most likely the object has
                //    been deactivated. If they both are zero and they have become zero recently,
                //    make sure a property update is sent so the zeros make it to the viewer.
                || ((m_properties.Velocity == ZeroVect && m_properties.AngularVelocity == ZeroVect)
                    &&
                    (m_properties.Velocity != m_lastProperties.Velocity ||
                     m_properties.AngularVelocity != m_lastProperties.AngularVelocity))
                //	If Velocity and AngularVelocity are non-zero but have changed, send an update.
                || !AlmostEqual(ref m_properties.Velocity, ref m_lastProperties.Velocity, VELOCITY_TOLERANCE)
                ||
                !AlmostEqual(ref m_properties.AngularVelocity, ref m_lastProperties.AngularVelocity,
                             ANGULARVELOCITY_TOLERANCE)
                )


            {
                // Add this update to the list of updates for this frame.
                m_lastProperties = m_properties;
                if (m_world.LastEntityProperty < m_world.UpdatedObjects.Length)
                    m_world.UpdatedObjects[m_world.LastEntityProperty++]=(m_properties);
                
                //(*m_updatesThisFrame)[m_properties.ID] = &m_properties;
            }
                
                
                

        }