Quantcast

[Ardor3D] CollisionTreeManager

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Ardor3D] CollisionTreeManager

Stefan
This post was updated on .
Hello,

I realized that the CollisionTreeManager initially requires about 5-6 seconds to compute a CollisionTree for my geometry (about 18 million vertices and 6 million triangles). Moreover, when I use makeCopy() to clone a Mesh, the already computed CollisionTree of the source Mesh does not get registered for the cloned Mesh in the CollisionTreeManager. So, the CollisionTree has to be recomputed. Is there a way to prevent this and reuse the existing CollisionTree? Are there other possibilities?

Thanks for your help!

Regards,

Stefan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Ardor3D] CollisionTreeManager

gouessej
Administrator
Hi

Do you put all your children into the same node?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Ardor3D] CollisionTreeManager

Stefan
Hello Gouessej,

no, the meshes do not share a common parent node (except of root).

Regards,

Stefan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Ardor3D] CollisionTreeManager

gouessej
Administrator
In my humble opinion, your meshes should be stored in a hierarchical way matching with their location so that the collision test can skip lots of meshes. A single common parent node is the worst case. It's not specific to JogAmp's Ardor3D Continuation. There is no interest in using a scenegraph API if the meshes aren't cleverly distributed. Each parent node has a bounding box, the objective consists in minimizing the number of meshes requiring very accurate triangle-triangle collision tests. If you have a very few meshes, maybe you should split the largest one into several ones. If you have a very few intermediary parent nodes, you should create new parent nodes.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Ardor3D] CollisionTreeManager

Stefan
Hello Gouessej,

thanks for your quick reply! Perhaps I should provide some more information about my setting: My scene consists of primitives (e.g. boxs and spheres) and meshes. Primitives and meshes can be grouped together (for this purpose I use Nodes). Groups can be hierarchical (nested Nodes). There can be multiple trees with this structure below the root Node.

Since the same mesh/geometry can appear several times in this structure and the meshes can be big, I thought it would be a good idea to clone/instantiate the geometry (to save memory). For this purpose I used makeCopy(true). However, when I use makeCopy(true), the returned Mesh does not have a CollisionTree registed at CollisionTreeManager. In my opinion it should be the same as the source Mesh's one? If the Mesh gets picked for the first time, the computation takes 5-6 seconds.

I thought your question was aiming on whether all "instances" of a Mesh are contained by the same parent Node. This is not the case. But some instances might share a common ancestor Node, but not necesarily.

Thanks for your help!

Regards,

Stefan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Ardor3D] CollisionTreeManager

gouessej
Administrator
Hi

Maybe there is a limitation in the collision tree manager but I wonder how you could shorten the computation time even when you don't use any cloned mesh. In my humble opinion, this potential limitation has an impact if most of your scene is composed of cloned meshes. I have found no way to "fix" it. The only hacky way to work around it consists in using the reflection API to put the original collision tree into the cache for each cloned mesh that shares the geometry data with the original mesh. It could have some side effects.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Ardor3D] CollisionTreeManager

Stefan
Hello Julien,

makeCopy(true) assigns the _meshData of the parent mesh to the child mesh. This could be used to identify a mesh copy. One could do the following:

- the Mesh class could provide a method like isCopy(Mesh):boolean that compares the _meshData of the two meshes
- the CollisionTreeManager class could provide a new private method getCollisionTreeForMeshCopy(Mesh):CollisionTree that iterates over the registered meshes and returns the CollisionTree if Mesh.isChild(Mesh) returns true
- the CollisionTreeManager.getCollisionTree(Mesh) method could invoke the getCollisionTreeForMeshCopy(Mesh) in case it does not find a CollisionTree for the passed Mesh

Iterating over all meshes would cost some time, but it would only happen for copies and for the initial computation of the CollisionTree. To reduce the number of iterations, one could also store the found relations between parent meshes and copies in a look-up data structure. Of course, one has to check after every look-up whether the original mesh and the copy still share the same _meshData.

Could this work out in your opinion?

Regards,

Stefan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Ardor3D] CollisionTreeManager

gouessej
Administrator
Hi

I would rather say that Mesh.makeCopy(true) puts the mesh data of the caller into the newly created mesh and it doesn't mean that both meshes are absolutely identical. They just share the geometric data but the rest can diverge.

In my humble opinion, your suggestion could work in a particular case. Maybe you should try to override the CollisionTreeManager class. Let me know whether something prevents you from doing what you want. I know that lots of classes used in the engine still use numerous static methods and are difficult to subclass :s
Loading...