Exemplo n.º 1
0
        /// <summary>
        /// Simulation handlers can be registered here in order to receive simulation notifications
        /// </summary>
        public void RegisterSimulationHandler(MyPhysSimulationHandler simHandler)
        {
#if PHYSICS_CHECK
            for (int i = 0; i < m_SimulationHandlers.Count; i++)
            {
                MyPhysSimulationHandler simH = m_SimulationHandlers[i];
                if (simH == simHandler)
                {
                    // cannot add already existing item!
                    MyCommonDebugUtils.AssertDebug(false);
                }
            }
#endif
            m_SimulationHandlers.Add(simHandler);
        }
Exemplo n.º 2
0
        public void UnregisterSimulationHandler(MyPhysSimulationHandler simHandler)
        {
#if PHYSICS_CHECK
            bool found = false;
            for (int i = 0; i < m_SimulationHandlers.Count; i++)
            {
                MyPhysSimulationHandler simH = m_SimulationHandlers[i];
                if (simH == simHandler)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                // cannot remove item!
                MyCommonDebugUtils.AssertDebug(false);
            }
#endif
            m_SimulationHandlers.Remove(simHandler);
        }
Exemplo n.º 3
0
        /// <summary>
        /// main simulation function
        /// </summary>
        public void Simulate(float timeStep)
        {
            if (!PhysicsSimulation)
            {
                return;
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("fire before simulation callbacks");

            MyRBBoxElementTriangleMeshElementInteraction.TestsCount      = 0;
            MyRBBoxElementTriangleMeshElementInteraction.TrianglesTested = 0;

            // fire before simulation callbacks
            for (int i = 0; i < m_SimulationHandlers.Count; i++)
            {
                MyPhysSimulationHandler simH = m_SimulationHandlers[i];
                simH.BeforeSimulation(timeStep);
            }
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("simulate rigid bodies");

            // simulate rigid bodies
            m_RigidBodyModule.Simulate(timeStep);
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("fire after simulation callbacks");

            // fire after simulation callbacks
            for (int i = 0; i < m_SimulationHandlers.Count; i++)
            {
                MyPhysSimulationHandler simH = m_SimulationHandlers[i];
                simH.AfterSimulation(timeStep);
            }
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
Exemplo n.º 4
0
        public void UnregisterSimulationHandler(MyPhysSimulationHandler simHandler)
        {
#if PHYSICS_CHECK
            bool found = false;
            for (int i = 0; i < m_SimulationHandlers.Count; i++)
            {
                MyPhysSimulationHandler simH = m_SimulationHandlers[i];
                if (simH == simHandler)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                // cannot remove item!
                MyCommonDebugUtils.AssertDebug(false);
            }
#endif
            m_SimulationHandlers.Remove(simHandler);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Simulation handlers can be registered here in order to receive simulation notifications
        /// </summary>
        public void RegisterSimulationHandler(MyPhysSimulationHandler simHandler)
        {
#if PHYSICS_CHECK
            for (int i = 0; i < m_SimulationHandlers.Count; i++ )
            {
                MyPhysSimulationHandler simH = m_SimulationHandlers[i];
                if(simH == simHandler)
                {            
                    // cannot add already existing item!
                    MyCommonDebugUtils.AssertDebug(false);
                }
            }
#endif
            m_SimulationHandlers.Add(simHandler);
        }