Horde3D

Next-Generation Graphics Engine
It is currently 10.11.2024, 20:48

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 11.06.2012, 22:35 
Offline

Joined: 09.06.2012, 14:21
Posts: 12
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.


Top
 Profile  
Reply with quote  
PostPosted: 12.06.2012, 10:20 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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).


Top
 Profile  
Reply with quote  
PostPosted: 12.06.2012, 10:39 
Offline

Joined: 09.06.2012, 14:21
Posts: 12
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.


Top
 Profile  
Reply with quote  
PostPosted: 12.06.2012, 10:58 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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 );


Top
 Profile  
Reply with quote  
PostPosted: 12.06.2012, 11:49 
Offline

Joined: 09.06.2012, 14:21
Posts: 12
I'm using the same fix locally and it appears to work.


Top
 Profile  
Reply with quote  
PostPosted: 12.06.2012, 11:53 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Thanks for the feedback, fixed it in the trunk


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group