A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by aqnuep » Wed Nov 25, 2009 3:53 pm
Hi,
I would like to ask if somebody knows what are SceneCollision primitives good for?
Are they a collision type to handle world boundary contacts or it's for a different purpose?
What about the functions for manipulating it?
NewtonSceneCollisionCreateProxy
NewtonSceneCollisionDestroyProxy
NewtonSceneCollisionOptimize
NewtonSceneProxySetMatrix
-
aqnuep
-
- Posts: 97
- Joined: Sat Dec 22, 2007 4:14 pm
by Julio Jerez » Wed Nov 25, 2009 4:08 pm
say you wnat to make a game with a many terrains, cytes with many building, tousand ot trees, and whate else you want.
most those object will be static or quazy static objects,
using a rigid body for placing each of those objects in the scene is a very expensive solution in memory and performance.
-Rigid body are big in memory footprint (around 400 bytes or so)
-Rigid bodi are general therfore theyr use general algorithm for BroadPhase.
a Scene collision is a wraper that knows those those object are just will never be dynamics and can use a mus small struture to represent them.
(just a matrix and a cpupel fo printers)
it can use a much more effiecnt Mid phase collision prunning sicne it knwo that body do no move around.
a Scene collision can have 10 ot toundwea of object an dtehy will coudn as one body, if you make then all bodies they teh brraphace becoem very heavy.
since each time a dynamcic body move is alter the interation with any of those bodies in the mutigrid sytem that the braedphasee system used.
So far no one has paid attention to the Scene collision, but this is very much an object the reflect the way old games use to be made.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by aqnuep » Wed Nov 25, 2009 4:15 pm
Is it then somehow equivalent with making simply a huge TreeCollision for the scene and making a dummy body for it?
As I see it is a more flexible way of doing the above, because with scene collision you can create individual collisions that will make up the scene instead of making just a triangle soup with TreeCollision.
I've checked out the demo about SceneCollision and now I think I understand now how it works. I'll put then also this to the Wiki.
-
aqnuep
-
- Posts: 97
- Joined: Sat Dec 22, 2007 4:14 pm
by Julio Jerez » Wed Nov 25, 2009 4:25 pm
Yes you got it it is like a Tree colision or liek a Compound collision.
but teh scene make some compromises.
Compound collisions can be dynamics but you can no move indiviudal shapes, and tehy can only take closed shapes.
Collision tree are dynamics by teh are teh fasted shapes to handle per face collision an dteh have special infomation to prossest edge collision and stuff like that.
Scene collision allow to move shapes, but for that ther to sacricfy optimal Hierchical placement,
the MidPhase of a collision tree will report fower faces than the MidPhace of a Scene collision, bu you can add collision tree and oteh shapes to a scene collision and they will be up in the tree.
so the overal saving si significan.
Say you are making a game with alans scape and you want a forest with towsan fo trees, dodin tah with coliision tree will fill teh tree with many face ath will amost never be visited.
with a scene you can make each tree out of a convex conopee and a convex stem and that will be just two nodes in the trees.
Plus the convex collision will make for nicer and faster collision.
It is just a way to segragate shapes so that more optimal algorthm can be applied to the Braphase search.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by aqnuep » Wed Nov 25, 2009 5:00 pm
One more question:
What does actually NewtonSceneCollisionOptimize?
It is clear that it does some optimization. Can we know how it is done or how this affects performance?
-
aqnuep
-
- Posts: 97
- Joined: Sat Dec 22, 2007 4:14 pm
by Julio Jerez » Wed Nov 25, 2009 6:05 pm
Like I said a Scene collision have to make some compromises in orther to allow for moving objects.
say for example you have a array of M object tah you wan to orgioanize into a bounding Box Hiercahy.
you can run and algorithm that can place all the bodies into an array, and then select the N closest pairs using a priorityy queue.
the you can group each one of those pairs with in a Box and now you get an array of M - N element.
then you run the same algothm searching to the next N1 closest Pairs, and you group those new pais into a box getting and array of M - N - N1 boxes.
you keep doing that until you get an array of one Box, in wicth each child contain another Box, until you get down to the leaves objects
teh result is and amost 100% optimal BVH tree, very effiecnet but it is very rigid since each box is very tight tight.
let us now say you want be able to move a leave object, if you do that thee things can happens:
the Box can move in such way that the Parent Box become smaller,
the Box can move is such way that the Parent bacome bigerr but that the Parent Parent does not.
the Box can move is such way that the Parent bacomes bigger and the Grand Parent also becomes Bigger.
in the first case you do nothing,
in the secund case you enlarge the Parent Box but now you are adding Noice to the three beacose it may be that a a test of the Grand Parent may also resutl in false positve test on the grand child.
but this is not too bad either.
In the thied case in start to beacume dangeruos becacuse now a test of the Grand Grand Parent will cause lots of false positives.
what Optimzie does si that takes the liste of dirty Boxes and run a resorting pass, since the array is only two levers deep, the pass is is leanear.
In the future that function will be removed and placed into a garbage collection thread that will bo that automatically bahind the client applciation.
for now you only need to call it once after you create the tree, but it will be elimenated in futre Beta went I visite that shape again.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest