Beispiel #1
0
        public override void CreateVolume(MyElement element)
        {
            MyCommonDebugUtils.AssertDebug(element.ProxyData == MyElement.PROXY_UNASSIGNED);
            BoundingBox aabb = element.GetWorldSpaceAABB();

            element.ProxyData = m_DAABBTree.AddProxy(ref aabb, element, (uint)element.Flags);
        }
Beispiel #2
0
        public override void DestroyVolume(MyElement element)
        {
            if (element.ProxyData == MyElement.PROXY_UNASSIGNED)
            {
                return;
            }
            m_DAABBTree.RemoveProxy(element.ProxyData);
            element.ProxyData = MyElement.PROXY_UNASSIGNED;

            if ((element.Flags & MyElementFlag.EF_SENSOR_ELEMENT) > 0)
            {
                MySensorElement se = (MySensorElement)element;
            }

            if ((element.Flags & MyElementFlag.EF_RB_ELEMENT) > 0)
            {
                MyRBElement elm = (MyRBElement)element;


                //clear all iterations from me and from objects i iterate with
                while (elm.GetRBElementInteractions().Count > 0)
                {
                    MyRBElementInteraction intr = elm.GetRBElementInteractions()[0];
                    MyPhysics.physicsSystem.GetRBInteractionModule().RemoveRBElementInteraction(intr.RBElement1, intr.RBElement2);
                }


                elm.GetRBElementInteractions().Clear();
            }
        }
Beispiel #3
0
        public override void DestroyVolume(MyElement element)
        {
            if (element.ProxyData == MyElement.PROXY_UNASSIGNED)
            {
                return;
            }
            m_DAABBTree.RemoveProxy(element.ProxyData);
            element.ProxyData = MyElement.PROXY_UNASSIGNED;

            if ((element.Flags & MyElementFlag.EF_SENSOR_ELEMENT) > 0)
            {
                MySensorElement se = (MySensorElement)element;
            }

            if ((element.Flags & MyElementFlag.EF_RB_ELEMENT) > 0)
            {
                MyRBElement elm = (MyRBElement)element;
                
                
                //clear all iterations from me and from objects i iterate with
                while(elm.GetRBElementInteractions().Count > 0){
                    MyRBElementInteraction intr = elm.GetRBElementInteractions()[0];
                    MyPhysics.physicsSystem.GetRBInteractionModule().RemoveRBElementInteraction(intr.RBElement1, intr.RBElement2);
                }
                
                
                elm.GetRBElementInteractions().Clear();
            }
        }
        public override void DestroyVolume(MyElement element)
        {
            if ((element.Flags & MyElementFlag.EF_SENSOR_ELEMENT) > 0)
            {
                return;
            }
            MyRBElement elm = (MyRBElement)element;

            elm.GetRBElementInteractions().Clear();
            m_Elements.Remove(elm);
        }
Beispiel #5
0
        public override void DestroyVolume(MyElement element)
        {
            if ((element.Flags & MyElementFlag.EF_SENSOR_ELEMENT) > 0)
            {
                return;
            }
            MyRBElement elm = (MyRBElement)element;

            elm.GetRBElementInteractions().Clear();
            m_Elements.Remove(elm);
        }
Beispiel #6
0
        /// <summary>
        /// when a volume moves we have to update the AABB and then update the tree
        /// </summary>
        public override void MoveVolume(MyElement element)
        {
            if (element.ProxyData == MyElement.PROXY_UNASSIGNED)
            {
                return;
            }

            element.UpdateAABB();
            BoundingBox aabb = element.GetWorldSpaceAABB();

            m_DAABBTree.MoveProxy(element.ProxyData, ref aabb, Vector3.Zero);
        }
        public override void CreateVolume(MyElement element)
        { 
#if PHYSICS_CHECK
            for (int i = 0; i < m_Elements.Count; i++)
            {
                MyRBElement el = m_Elements[i];
                if (el == element)
                {
                    // inserting twice!!!
                    CommonDebugUtils.AssertRelease(false);
                    return;
                }
            }
#endif
            if ((element.Flags & MyElementFlag.EF_SENSOR_ELEMENT) > 0)
            {
                return;
            }
            MyRBElement elm = (MyRBElement)element;
            m_Elements.Add(elm);
        }
Beispiel #8
0
        public override void CreateVolume(MyElement element)
        {
#if PHYSICS_CHECK
            for (int i = 0; i < m_Elements.Count; i++)
            {
                MyRBElement el = m_Elements[i];
                if (el == element)
                {
                    // inserting twice!!!
                    CommonDebugUtils.AssertRelease(false);
                    return;
                }
            }
#endif
            if ((element.Flags & MyElementFlag.EF_SENSOR_ELEMENT) > 0)
            {
                return;
            }
            MyRBElement elm = (MyRBElement)element;
            m_Elements.Add(elm);
        }
Beispiel #9
0
        /// <summary>
        /// we have the aabb updated and just update the tree using the info from velocity as a hint
        /// </summary>
        public override void MoveVolumeFast(MyElement element)
        {
            if (element.ProxyData == MyElement.PROXY_UNASSIGNED)
            {
                return;
            }

            if ((element.Flags & MyElementFlag.EF_RB_ELEMENT) > 0)
            {
                MyRBElement rel = (MyRBElement)element;

                float dt = MyPhysics.physicsSystem.GetRigidBodyModule().CurrentTimeStep;

                Vector3     movement = rel.GetRigidBody().LinearVelocity *dt;
                BoundingBox aabb     = element.GetWorldSpaceAABB();
                m_DAABBTree.MoveProxy(element.ProxyData, ref aabb, movement);
            }
            else
            {
                BoundingBox aabb = element.GetWorldSpaceAABB();
                m_DAABBTree.MoveProxy(element.ProxyData, ref aabb, Vector3.Zero);
            }
        }
Beispiel #10
0
 public virtual void MoveVolumeFast(MyElement element)
 {
 }
Beispiel #11
0
 public virtual void DestroyVolume(MyElement element)
 {
 }
Beispiel #12
0
 public override void CreateVolume(MyElement element)
 {
     MyCommonDebugUtils.AssertDebug(element.ProxyData == MyElement.PROXY_UNASSIGNED);
     BoundingBox aabb = element.GetWorldSpaceAABB();
     element.ProxyData = m_DAABBTree.AddProxy(ref aabb, element, (uint)element.Flags);
 }
Beispiel #13
0
 public virtual void MoveVolumeFast(MyElement element) { }        
Beispiel #14
0
 public virtual void DestroyVolume(MyElement element) { }
Beispiel #15
0
 public virtual void CreateVolume(MyElement element) { }
Beispiel #16
0
        /// <summary>
        /// when a volume moves we have to update the AABB and then update the tree
        /// </summary>
        public override void MoveVolume(MyElement element)
        {
            if (element.ProxyData == MyElement.PROXY_UNASSIGNED)
            {
                return;
            }

            element.UpdateAABB();
            BoundingBox aabb = element.GetWorldSpaceAABB();
            m_DAABBTree.MoveProxy(element.ProxyData,ref aabb, Vector3.Zero);
        }
Beispiel #17
0
 public virtual void CreateVolume(MyElement element)
 {
 }
Beispiel #18
0
        /// <summary>
        /// we have the aabb updated and just update the tree using the info from velocity as a hint
        /// </summary>
        public override void MoveVolumeFast(MyElement element)
        {
            if (element.ProxyData == MyElement.PROXY_UNASSIGNED)
            {
                return;
            }

            if ((element.Flags & MyElementFlag.EF_RB_ELEMENT) > 0)
            {
                MyRBElement rel = (MyRBElement) element;

                float dt = MyPhysics.physicsSystem.GetRigidBodyModule().CurrentTimeStep;

                Vector3 movement = rel.GetRigidBody().LinearVelocity * dt;
                BoundingBox aabb = element.GetWorldSpaceAABB();
                m_DAABBTree.MoveProxy(element.ProxyData, ref aabb, movement);
            }
            else
            {
                BoundingBox aabb = element.GetWorldSpaceAABB();
                m_DAABBTree.MoveProxy(element.ProxyData, ref aabb, Vector3.Zero);
            }
        }