Using multiple TreeCollision objects (?)

gzmzhen

17-08-2006 20:22:03

Is it possible to use multiple TreeCollision objects? Or is it made to only handle so many (one, or two)?

I currently am making treeCollision objects for some automatically made objects in my scene and it crashes after creating ten of them (not including the base world which is a tree collision as well).

I can put them all together as well, but just want to make sure that's my problem before I make that kind of modification.

walaber

17-08-2006 20:47:45

you can make as many, or as few as you want. several Stunt Playground scenes have 10+ tree collision objects, so I think the problem is in your code, or one of your meshes...

gzmzhen

17-08-2006 21:33:01

I'm looking for it ... I was really hoping that was the problem, cause I extended the TreeCollision class and added a function called addPolys which basically does what the constructor does with the vertex and index data but requires you to call start and finish.

Maybe you have a better idea of where I should look for it. On the 9th or 10th call it causes a pointer exception error to occur in:

void TreeCollision::finish( bool optimize)
{
NewtonTreeCollisionEndBuild( m_col, optimize );
}


So I'm not really sure how or why that occurs.

With my extended class there is one point in time that it overwrites memory (past the original problem) on the stack (so the numVertices goes from 230 to -1 and everything else goes whacko as well).

gzmzhen

17-08-2006 21:37:04

Is it more efficient to have one treeCollision object for all of them?

Or does it not really matter? (i.e. it's only more efficient if I decide to serialize them?)

gzmzhen

17-08-2006 21:39:20

Ok so I'm a real fool. The problem was that I was sending it the number of vertices and not the number of vectors in the float buffer... which was my assumption (for some dumb reason) when I created the function.

So, I guess just my last question remains: is it more efficient to have one, or no?

walaber

18-08-2006 08:25:21

I'm not sure to be honest. I think 1 large TreeCollision is probably more efficient, but I can't say for sure.

you could as on the Newton forum...

gzmzhen

18-08-2006 20:03:32

Here's the link to the newton post. You will need to Register to view it.

http://newtondynamics.com/forum/viewtop ... 73154f60a7

Basically one big one can be a problem (time consuming) in optimize mode. (At least, some guy says so from experience)