Optimizing physics

Those are objects I have, they are randomly generated, so specific amount will always vary.

Trees: 315
Rocks: 9
Weeds: 350

Plus I have 512x512 terrain.

All of those, excluding weeds, have collission shape of their mesh. FPS already starts to drop.
How could I optimize it?

One thing I could do is replacing collission meshes with collission shapes, but it is important to me, to have precise collissions.
Even if, how would I fit these shapes to a model?

Oh dude. Of course such large quantities of Mesh-Shapes are going to hurt performance.
I would go for Compound collision shapes for the stones etc, Trees in particular can be wrapped into a cylinder with ease. You wont lose that much of precision here and it’s going to be a lot faster.

Don’t put them all in one collision shape so more of the collision code can be offloaded to the broadphase.

@KuroSei said: Trees in particular can be wrapped into a cylinder with ease.
But how do I do that? Is there editor or do I have to guess the values in code?

You can also batch your objects. But Normem is right, you should make it based on areas, so that whole groups could be discarded quickly.

@Neomex said: But how do I do that? Is there editor or do I have to guess the values in code?

Don’;t guess. Look in the model editor at the size and position of your tree. Create a cylinder to match…

@zarch said: Don';t guess. Look in the model editor at the size and position of your tree. Create a cylinder to match...
I'm not sure if I don't know something, but for me it still is very hard to fit it in-code.

You can also try a HullCollisionShape, which will find the simplest Collision Shape to fit to your model. It may not give you the results you want near the top (but then again you probably shouldn’t have it on leaves anyways ^^), but the trunk will be pretty near. You won’t have to do any “guessing” this way at least

I think it didn’t work out too well…

how high are those going :O, looks like its using a scaled version of the tree mesh or something