public void SetPhysicsFPS(float value)
 {
     m_average.Add(value);
     //Now fix time dilation
     m_scene.TimeDilation = m_average.GetAverage() / m_scene.BaseSimPhysFPS;
     if (m_scene.TimeDilation < 0.1) //Limit so that the client (and physics engine) don't go crazy
     {
         m_scene.TimeDilation = 0.1f;
     }
     else if (m_scene.TimeDilation > 1.0) //No going over!
     {
         m_scene.TimeDilation = 1.0f;
     }
 }
示例#2
0
        private int GetHeartbeatSleepTime(int timeBeatTook)
        {
            //Add it to the list of the last 50 heartbeats

            m_heartbeatList.Add(timeBeatTook);
            int avgHeartBeat = (int)m_heartbeatList.GetAverage();

            //The heartbeat sleep time if time dilation is 1
            int normalHeartBeatSleepTime = (int)m_updatetimespan;

            if (avgHeartBeat + (m_physicstimespan / m_updatetimespan) > normalHeartBeatSleepTime) //Fudge a bit
            {
                return(0);                                                                        //It doesn't get any sleep
            }
            int newAvgSleepTime = normalHeartBeatSleepTime - avgHeartBeat;

            return(newAvgSleepTime - (int)(m_physicstimespan / m_updatetimespan)); //Fudge a bit
        }
示例#3
0
        private int GetHeartbeatSleepTime(int timeBeatTook, bool phys)
        {
            if (phys)
            {
                //Add it to the list of the last 50 heartbeats
                if (timeBeatTook != 0)
                {
                    m_physheartbeatList.Add(timeBeatTook);
                }
                int avgHeartBeat = (int)m_physheartbeatList.GetAverage();

                //The heartbeat sleep time if time dilation is 1
                float normalHeartBeatSleepTime = m_physicstimespan;
                if (avgHeartBeat > normalHeartBeatSleepTime) //Fudge a bit
                {
                    return(0);                               //It doesn't get any sleep
                }
                int newAvgSleepTime = (int)(normalHeartBeatSleepTime - avgHeartBeat);
                return(newAvgSleepTime);//Fudge a bit
            }
            else
            {
                //Add it to the list of the last 50 heartbeats
                m_heartbeatList.Add(timeBeatTook);
                int avgHeartBeat = (int)m_heartbeatList.GetAverage();

                //The heartbeat sleep time if time dilation is 1
                int normalHeartBeatSleepTime = (int)m_updatetimespan;
                if (avgHeartBeat > normalHeartBeatSleepTime) //Fudge a bit
                {
                    return(0);                               //It doesn't get any sleep
                }
                int newAvgSleepTime = normalHeartBeatSleepTime - avgHeartBeat;
                //Console.WriteLine (newAvgSleepTime);
                return(newAvgSleepTime);
            }
        }