Re: [Ardor3D] CollisionTreeManager
Posted by Stefan on Feb 27, 2015; 5:45pm
URL: https://forum.jogamp.org/Ardor3D-CollisionTreeManager-tp4034063p4034078.html
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