Server + Newton

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Server + Newton

Postby KingSnail » Thu Nov 18, 2010 2:34 pm

I am a running pretty cool experiment, running newton on a server and having a client just send inputs.
The collision detection is server side.
The server sends snapshots every 100ms of all people in a certain area around a player
the client interpolates the positions.

The question is how to handle the NewtonUpdate call on the server side?

I had this (from the demo) before and it was too laggy above 35 players

Code: Select all
                //unsigned int timeInMilisecunds = GetTimeInMicrosenconds();
      //deltaTime = timeInMilisecunds - g_currentTime;
      //g_currentTime = timeInMilisecunds;
      //g_timeAccumulator += deltaTime;

      //physicTime = 0;
      //int loops = 0;
      //physicLoopsTimeAcc = 0;

      //while ((loops < MAX_PHYSICS_LOOPS) && (g_timeAccumulator >= DEMO_FPS_IN_MICROSECUNDS))
      //{
      //   loops++;
      //   //Update(intepolationParam);
      //   g_physicTime = GetTimeInMicrosenconds ();

      //   std::vector<std::shared_ptr<Zone>>::iterator it = EverySingleZone.begin();
      //   while(it != EverySingleZone.end())
      //   {
      //      NewtonUpdate((*it)->World, (1.0f / DEMO_PHYSICS_FPS)); //Update physics
      //      ++it;
      //   }

      //   g_physicTime = GetTimeInMicrosenconds () - g_physicTime;
      //   g_timeAccumulator -= DEMO_FPS_IN_MICROSECUNDS;
      //   physicTime++;
      //   physicLoopsTimeAcc += g_physicTime;
      //}

      //if (loops > MAX_PHYSICS_LOOPS)
      //{
      //   g_physicTime = physicLoopsTimeAcc;
      //   g_timeAccumulator = DEMO_FPS_IN_MICROSECUNDS;
      //}

      //dFloat param = dFloat (g_timeAccumulator) / dFloat(DEMO_FPS_IN_MICROSECUNDS);
      //if(param > 1.0f)param = 1.0f;
      //intepolationParam = param;

      //deltaTime = 0;
      //physicLoopsTimeAcc = 0;
      //fps = 0.0f;
      //physicTime = 0.0f;
Working on an MMORPG powered by Newton Dynamics.
User avatar
KingSnail
 
Posts: 112
Joined: Sat Jan 02, 2010 9:55 pm

Re: Server + Newton

Postby Julio Jerez » Thu Nov 18, 2010 2:50 pm

Newton Update is too complex for a single core server side.
A way to do it would be do make a special version whne the serve use multicore to solve island in seperate cores but in a deterministic way.
basically it will break the work doen in teh world into separate independent sub world that can be solved in any order by separate cores, or even separate computers, then the result is put together.

I have not work on that but is is very possible.

you say you have the collision in the server but no the physics, are you using Netwon for collision only?
what are you dowing?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Server + Newton

Postby KingSnail » Thu Nov 18, 2010 6:08 pm

I have collision + character controllers on servers.
So how can I go about doing the multicore thing?
I would really like to implement it
Working on an MMORPG powered by Newton Dynamics.
User avatar
KingSnail
 
Posts: 112
Joined: Sat Jan 02, 2010 9:55 pm

Re: Server + Newton

Postby KingSnail » Sat Nov 20, 2010 1:43 pm

Can you please move this to requests?
Maybe some other people are interested in this too
Working on an MMORPG powered by Newton Dynamics.
User avatar
KingSnail
 
Posts: 112
Joined: Sat Jan 02, 2010 9:55 pm

Re: Server + Newton

Postby Julio Jerez » Sat Nov 20, 2010 3:23 pm

Just make the post again in the bug track.

I hav eot mae some change for that to happen, nothog hard but teh corrent version I thionk may no do it.

Has you try using the engine with multiple threads, It is jsu one line of code and it migh just work.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Server + Newton

Postby KingSnail » Sat Nov 20, 2010 9:10 pm

How do you mean with multiple threads?

NewtonUpdate on one thread? what do I pass in as the parameter
and the rest of the code on main thread or what?

please give an example maybe in pseudocode?
thanks
Working on an MMORPG powered by Newton Dynamics.
User avatar
KingSnail
 
Posts: 112
Joined: Sat Jan 02, 2010 9:55 pm

Re: Server + Newton

Postby Julio Jerez » Sun Nov 21, 2010 11:04 am

newton is one thread bu intenally it can use mutipel cores to do teh phtsics
just call NewtonSetThreadsCount (...) after you create the world

since you are doing a server based multiplepalyer, it should work fine for you.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Server + Newton

Postby KingSnail » Mon Nov 22, 2010 6:42 pm

Ok I did that but what do I pass in as the time step to NewtonUpdate?
Do I need any special loops to sync everything?
Please give a small example, I really * at 'time' in games
Working on an MMORPG powered by Newton Dynamics.
User avatar
KingSnail
 
Posts: 112
Joined: Sat Jan 02, 2010 9:55 pm

Re: Server + Newton

Postby ledahut » Tue Nov 23, 2010 3:48 am

You have nothing more to do.
Newton handle the sync for multi-threading.

ex: I have core i5 [2 core * 2 thread].
With NewtonSetThreadsCount=1 my application never go above 25% cpu time in task manager (with 5 thread counts for my processus).

NewtonSetThreadsCount=4 my application can up to 100% cpu when needed (and thread count is 8 in task manager).
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Server + Newton

Postby KingSnail » Tue Nov 23, 2010 12:48 pm

I mean the parameter for NewtonUpdate(world, parameter);
What goes in there?
Working on an MMORPG powered by Newton Dynamics.
User avatar
KingSnail
 
Posts: 112
Joined: Sat Jan 02, 2010 9:55 pm

Re: Server + Newton

Postby Julio Jerez » Tue Nov 23, 2010 2:30 pm

KingSnail wrote:I had this (from the demo) before and it was too laggy above 35 players
...


what I do no undestand si that you say it is too laggy with only 35 players, and that does not sound right.
there was a person doing an MMO using Ogre and also have performance propblem but he had 900+ players, and I add and special capule terrain collision to solved the problem
as aar as I know it was ok after that change

you only have 35 bodies, and you say is too slow....
are you doing lots of lock steps to cach up with client latency, or somethong like that?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Server + Newton

Postby KingSnail » Tue Nov 23, 2010 2:54 pm

I am not doing any locksteps
I think I am just calling NewtonUpdate wrong
Working on an MMORPG powered by Newton Dynamics.
User avatar
KingSnail
 
Posts: 112
Joined: Sat Jan 02, 2010 9:55 pm

Re: Server + Newton

Postby Julio Jerez » Tue Nov 23, 2010 6:48 pm

can you show me the fragment of code you use to call newton update
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Server + Newton

Postby KingSnail » Tue Nov 23, 2010 7:45 pm

I fixed the lag and it seems to work now. It turns out it was cal3d (3d skeletal animation library) causing my engine to be SUPER slow. so I am removing that lib.

NewtonUpdate(OurZone->World, (1.0f / 60.0f)); //Update physics

Thats what I am using. Is that ok? Or should there be some other value since this is running on a server in a neverending loop.
Working on an MMORPG powered by Newton Dynamics.
User avatar
KingSnail
 
Posts: 112
Joined: Sat Jan 02, 2010 9:55 pm

Re: Server + Newton

Postby Julio Jerez » Tue Nov 23, 2010 8:54 pm

KingSnail wrote:NewtonUpdate(OurZone->World, (1.0f / 60.0f)); //Update physics


That is OK, also is you server also doing graphics? or is a dedicated for physics only?
if it is one sytem in the network, then you may want to see 2.26 where there ia a class call dThread that you can use to run the physics asyncronust at a fix rate ina separate thread.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron