Horde3D

Next-Generation Graphics Engine
It is currently 26.05.2018, 07:26

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 31.01.2010, 22:23 
Offline

Joined: 19.11.2007, 19:35
Posts: 218
May be useful to others, GroupNodes don't update their bounds (which is sensible) so I made a quick change to have them determine their bounds when it's asked for through the API.

In egMain.cpp
Code:
DLLEXP void h3dGetNodeAABB( NodeHandle node, float *minX, float *minY, float *minZ,
                            float *maxX, float *maxY, float *maxZ )
{
   SceneNode *sn = Modules::sceneMan().resolveNodeHandle( node );
   VALIDATE_NODE( sn, "h3dGetNodeAABB", EMPTY );

    Modules::sceneMan().updateNodes();
    if (sn->getType() == SceneNodeTypes::Group)
        ((GroupNode*)sn)->calculateBBox();
    if( minX != 0x0 ) *minX = sn->getBBox().min.x;
    if( minY != 0x0 ) *minY = sn->getBBox().min.y;
    if( minZ != 0x0 ) *minZ = sn->getBBox().min.z;
    if( maxX != 0x0 ) *maxX = sn->getBBox().max.x;
    if( maxY != 0x0 ) *maxY = sn->getBBox().max.y;
    if( maxZ != 0x0 ) *maxZ = sn->getBBox().max.z;
   
    if (sn->getType() == SceneNodeTypes::Group) //a little gross, but it's grosser if we don't clear it
        ((GroupNode*)sn)->clearBBox();
}


In egScene.h - GroupNode class declaration
Code:
void calculateBBox();


In egScene.cpp
Code:
void GroupNode::calculateBBox()
{
    for (std::vector<SceneNode*>::iterator it = _children.begin(); it != _children.end(); ++it) {
        if (*it) {
            if ((*it)->getType() == SceneNodeTypes::Group)
                ((GroupNode*)*it)->calculateBBox();
            _bBox.makeUnion((*it)->getBBox());
            if ((*it)->getType() == SceneNodeTypes::Group) //gross
                ((GroupNode*)*it)->clearBBox();
        }
    }
}


Top
 Profile  
Reply with quote  
PostPosted: 02.02.2010, 23:17 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Thanks. We used to have an AABB tree for culling but updating it has a considerable performance overhead (a lot of cache misses), that's why it was removed. Some different spatial structure will be used instead in the future.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 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