Horde3D http://horde3d.org/forums/ |
|
big bounding box when mesh has zero vertices http://horde3d.org/forums/viewtopic.php?f=3&t=1680 |
Page 1 of 1 |
Author: | swx [ 11.06.2012, 22:35 ] |
Post subject: | big bounding box when mesh has zero vertices |
I imported a model that had a mesh that did not contain any vertices. This caused h3dGetNodeAABB to report a huge bounding box for the scene node. The problem is in ModelNode::updateLocalMeshAABBs(). If a mesh does not contain any vertices, bBMin and bBMax are assigned the value +- MaxFloat and never reassigned since there aren't any vertices. The solution could be to add a Code: if (mesh._vertRStart <= mesh._vertREnd) around the assignment and inner loop. |
Author: | Volker [ 12.06.2012, 10:20 ] |
Post subject: | Re: big bounding box when mesh has zero vertices |
Good spot! What is _vertRStart and _vertREnd in this case? Because normally the loop should be processed if both are equal for at least one vertex even if there are no vertices part of the mesh if the geometry resource has some vertices defined. I guess in this case _vertRStart and _vertREnd are zero and the first vertex position in the resource would be used. That's something that would be probably wrong too, but it shouldn't cause a huge bounding box but one around the first vertex in the geometry resource, should it? And if the resource does not contain any vertex I would think that mesh._vertRStart < _geometryRes->getVertCount() does not succeed and therefore would result in an empty AABB (else case). |
Author: | swx [ 12.06.2012, 10:39 ] |
Post subject: | Re: big bounding box when mesh has zero vertices |
The resource contained multiple meshes, so even though this mesh had no vertices, _geometryRes->getVertCount() was non-zero. I think _vertREnd was 71 and _vertRStart was 72 or something like that. |
Author: | Volker [ 12.06.2012, 10:58 ] |
Post subject: | Re: big bounding box when mesh has zero vertices |
Ah ok, so vertRStart was bigger than vertREnd. I guess the following patch should fix it (as you already suggested), shouldn't it? Code: Index: egModel.cpp
=================================================================== --- egModel.cpp (revision 340) +++ egModel.cpp (working copy) @@ -180,8 +180,9 @@ Vec3f &bBMin = mesh._localBBox.min; Vec3f &bBMax = mesh._localBBox.max; - - if( mesh._vertRStart < _geometryRes->getVertCount() && + + if( mesh._vertRStart <= mesh._vertREnd && + mesh._vertRStart < _geometryRes->getVertCount() && mesh._vertREnd < _geometryRes->getVertCount() ) { bBMin = Vec3f( Math::MaxFloat, Math::MaxFloat, Math::MaxFloat ); |
Author: | swx [ 12.06.2012, 11:49 ] |
Post subject: | Re: big bounding box when mesh has zero vertices |
I'm using the same fix locally and it appears to work. |
Author: | Volker [ 12.06.2012, 11:53 ] |
Post subject: | Re: big bounding box when mesh has zero vertices |
Thanks for the feedback, fixed it in the trunk |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |