I have 2.26 and I found the class dThread
but how do I use it?
Do you have a small example?
Moderators: Sascha Willems, walaber
class dSimulationThread: public dThread
{
public:
dSimulationThread();
~dSimulationThread();
virtual unsigned RunMyTask ();
bool m_asycronousUpdate;
dFloat m_physicsTime;
};
unsigned dSimulationThread::RunMyTask ()
{
if (m_asycronousUpdate) {
DemoEntityManager& me = *((DemoEntityManager*)this);
me.UpdatePhysics();
}
return 1;
}
// in your world class call asycronous from the physic thread
void DemoEntityManager::UpdatePhysics()
{
if (m_world) {
dFloat timestepInSecunds = 1.0f / MAX_PHYSICS_FPS;
unsigned64 timestepMicrosecunds = unsigned64 (timestepInSecunds * 1000000.0f);
unsigned64 currentTime = m_timer.GetTimeInMicrosenconds ();
unsigned64 nextTime = currentTime - m_microsecunds;
int loops = 0;
while ((nextTime >= timestepMicrosecunds) && (loops < MAX_PHYSICS_LOOPS)) {
loops ++;
// run the newton update function
if (!m_reEntrantUpdate) {
m_reEntrantUpdate = true;
if (m_physicsUpdate && m_world) {
NewtonUpdate (m_world, timestepInSecunds);
}
m_reEntrantUpdate = false;
}
nextTime -= timestepMicrosecunds;
m_microsecunds += timestepMicrosecunds;
}
if (loops) {
m_physicsTime = dFloat (m_timer.GetTimeInMicrosenconds () - currentTime) / 1000000.0f;
}
if (loops >= MAX_PHYSICS_LOOPS) {
m_microsecunds = currentTime;
}
}
}
KingSnail wrote:The server sends snapshots every 100ms of all people in a certain area around a player
the client interpolates the positions.
[...]
I had this (from the demo) before and it was too laggy above 35 players
Users browsing this forum: No registered users and 2 guests