Optimizing a/my strategy game scene

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Optimizing a/my strategy game scene

Postby Marc » Wed Jan 13, 2010 11:00 am

Hi !

Whiel this is a continuation of this thread http://newtondynamics.com/forum/viewtopic.php?f=9&t=5338&p=40723#p40723, I start a new thread for this because the title other title referred to an old issue that got solved some time ago already.

Sorry it took a few days, but finally, I colored the graph and show the number of units as well as upgraded to newton 2.16. :)
I also set up a copy of the live system for debugging purposes. You can get find it here: [url]wwwdev.confrontation-unlimited.net[/url]. Don't use the live system, it's still running on 2.12.

I created an admin account for you with credentials I send to you via pm. When you are connected to a region, you can press 5 and the debug window will appear you can see a few lines down. You can toggle the 8 graphs with the check boxes. They correspond to the 8 graphs newton offers.

I simulate the scene with 60Hz and every 8 frames, I flush the scene for determinism. That explains the spikes every 8 frames.

There is one region showing the current speed problem:

Image

It's the region 15/16, you can connect to it in the dev system with your account. As you can see, it has >800 units and the physics take quite some time. Also note that they are just standing around and have nothing to do - but that's an abservation from the gamelogic point of view. If they are actually asleep or not I don't know. But compared to region 15/15:

Image

There are less units but a lot more trees, which are static ellipsoids, the physics take a lot less time while the total amount of objects is only 200 less than in 15/16. So I assume, the units, the dynamic ellipsoids slow it down.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Optimizing a/my strategy game scene

Postby Julio Jerez » Wed Jan 13, 2010 11:48 am

what is the meaning of the colors in the graph?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Optimizing a/my strategy game scene

Postby Marc » Wed Jan 13, 2010 1:27 pm

ok, I added a legend :)
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Optimizing a/my strategy game scene

Postby Julio Jerez » Wed Jan 13, 2010 2:49 pm

I have not tested yet, I am busy this week I will try the weekend.
But we can do the first thing that will give some performance for very little work.
I see you have many static bodies that at made of convex collision like the tree.

In Newton the performance of the collision shape is like this, from fastest to slower

-collision trees and high field, the fastest but the more limited since it can only be static, you can move the object but by setting the matrix explicitly
-compound collision, can be dynamics or static but pieces cannot move relative to each other
-Scene collision is make the body static by you can move the pieces by setting a matrix of a shape.
-convex shapes, and close form convex collision
-convex collision controlled by a convex modifier

You are using lot of ellipsoid collision which are some kind of special case of convex modifier, when you add then to eth world the use
a full body so the add lot of overhead in memory and performance, the engine internally do no have the notion of static of dynamics body
so representing tress a static ellipsoid does not make any difference.

However in Newton 2.16 you can take all those ellipsoid and place then is a collision compound collision and the will all could as one body.
And you still get feedback information when on the specific colliding shape.

can you take the trees and place them all by convex collision (spheres, boxes, ellipsoid, of convex hulls) one single compound collision?

Also since I do not have time this week to check the application, can you just tell me what the colors of eth top line in the graph represent?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Optimizing a/my strategy game scene

Postby Marc » Wed Jan 13, 2010 3:54 pm

I can try putting all trees in a compound collision. But unless they have sideeffects on the single units as well (like creation of smaller islands maybe?) I guess that wouldn't help that much. From the graphs above I guess the trees aren't the problem.

Theere are 8 colored lines in the graph. Each color corresponds to a number you can read from the legend - maybe you have to refresh your browser cache. Each number corresponds to the values read from NewtonReadPerformanceTicks() with the number being the 2nd parameter.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Optimizing a/my strategy game scene

Postby JernejL » Thu Jan 14, 2010 5:48 am

Julio Jerez wrote:can you take the trees and place them all by convex collision (spheres, boxes, ellipsoid, of convex hulls) one single compound collision?


Is that a good idea? i was thinking of doing similar stuff, but such a compound would extend along all the world and it's AABB would always be included in any raycast or collision check.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Optimizing a/my strategy game scene

Postby Marc » Thu Jan 14, 2010 6:50 am

Julio Jerez wrote:You are using lot of ellipsoid collision which are some kind of special case of convex modifier, when you add then to eth world the use
a full body so the add lot of overhead in memory and performance, the engine internally do no have the notion of static of dynamics body
so representing tress a static ellipsoid does not make any difference.

Maybe I should replace the ellipsoids with some other primitive then? Maybe a capsule or a cylinder? Or maybe the playercontroller can help?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Optimizing a/my strategy game scene

Postby Julio Jerez » Thu Jan 14, 2010 8:17 am

no do not do that, let us see what it is first.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Optimizing a/my strategy game scene

Postby Marc » Thu Jan 14, 2010 8:33 am

ok.

btw. did anything change from 2.12 to 2.16 with respect to NewtonCollisionMakeUnique() ? I have several collision I use in multiple newtonworlds, so what I do at the beginning of my programm is for each of these collision:

nWorld = NewtonCreate()
CreateCollisionSomehow(nWorld)
NewtonCollisionMakeUnique(nWorld)
NewtonDestroy(nWorld)

And at the end of my program I do

nWorld = NewtonCreate()
NewtonReleaseCollision()
NewtonDestroy()

So for every collision that gets reused in multiple worlds, I create a temp world at the beginning in which the collision gets created, then I make it unique and then I destroy that temp world. For destruction I do the same thing. This worked for 2.12 but for 2.16, I get a crash in NewtonReleaseCollision from time to time at the end of my program. It doesn't always happen, but about 50% of the time it does. I see you changed something with the allocator parameters of NewtonCreate and put them in a seperate function. Maybe that's related somehow?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Optimizing a/my strategy game scene

Postby Julio Jerez » Thu Jan 14, 2010 12:55 pm

that will definitly crash, when I made the memory manager local to the world now everything created in one world must be detroyed by that world,
so releasing a collision and using it in a different world is a guaratee for a crash later.

what you could do is to make oen world to be the manage of all collision
that si you craete collision ios teh collsion world and you use then for what ever you want.
you can just use create collision at will and forget abput caching Newton is very good a caching the collison shapes.


basically you do

collision = NetwonCraete collision (collsionworld ....)



// use teh collsion in any oeteh world

NetwonCraeteBody (someworld, collision)

NetwonCraeteBody (someOtherWorld, collision)
...


DerstoryBody(body)
...



this should be simple and sloud work without problems.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Optimizing a/my strategy game scene

Postby Marc » Thu Jan 14, 2010 1:00 pm

Hmm, but can I still use a collision in a different world? I could instead of the above create one newtonworld at the bewinning of my program where I create all those collision in and keep it until the end of the program and release the collision in that world and destroy that world.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Optimizing a/my strategy game scene

Postby Julio Jerez » Thu Jan 14, 2010 1:07 pm

You posted before I finish my answer.

yes you can you can,
you can have one world as the Database manager of collisiion shapes, you create then there and then you make bodies from any world you want with that shape
basically you make the collision from the world and you do not release then when you make bodies.
then when the bodies are disposes you can queres the collision Reference count and if it is one then you can call

void NewtonReleaseCollision (const NewtonWorld* newtonWorld, const NewtonCollision* collision);
on the collision world.

you are right MakeUnique could create big problem now tha the world onl the pool memory manager, if teh application destroy a body with a collision created on another world and reference is remove from that world.
I will have to revisit that funtion or remove it altogether
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Optimizing a/my strategy game scene

Postby Marc » Thu Jan 14, 2010 2:05 pm

oh, I seems like I was really fast heh :D

Ok, I just made those changes with one Newtonworld containing all the reused collisions and not calling MakeUnique() anymore - and it seems to work :)
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Optimizing a/my strategy game scene

Postby Julio Jerez » Thu Jan 14, 2010 2:14 pm

Ok that's one problem less.

It si possibel to make a test level wit the map an dteh dynamics bodies, leaing ot teh trees and building.
this is just to see if what si teh effect of the dynamics bodies alone.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Optimizing a/my strategy game scene

Postby Marc » Thu Jan 14, 2010 2:17 pm

Ok, I'll try that.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron