Improve construction of VisibleObjectsBoundsInfo

What it says on the tin: a place to discuss proposed new features.
Post Reply
yeahRIGHT
Halfling
Posts: 74
Joined: Sun Sep 07, 2008 5:09 pm

Improve construction of VisibleObjectsBoundsInfo

Post by yeahRIGHT »

Currently the VisibleObjectsBoundsInfo::receiverAabb is expanded like that:

Code: Select all

void OctreeNode::_addToRenderQueue( Camera* cam, RenderQueue *queue, bool onlyShadowCasters, VisibleObjectsBoundsInfo* visibleBounds )
{
    ObjectMap::iterator mit = mObjectsByName.begin();

    while ( mit != mObjectsByName.end() )
    {
        MovableObject * mo = mit->second;

        mo->_notifyCurrentCamera(cam);
        if ( mo->isVisible() && (!onlyShadowCasters || mo->getCastShadows()))
        {
            mo -> _updateRenderQueue( queue );

			if (visibleBounds)
			{
// HERE
				visibleBounds->merge(mo->getWorldBoundingBox(true), 
					mo->getWorldBoundingSphere(true), cam, 
					queue->getQueueGroup(mo->getRenderQueueGroup())->getShadowsEnabled());
			}
        }

        ++mit;
    }

}
However, this does not consider the individual objects and their materials but the render queue group as a whole, for which shadows are generally enabled in most cases. This means, basically every visible object is treated as a shadow receiver when it comes to the construction of the receiverAabb, which results in a non-optimal shadow camera setup (resolution is wasted).

I propose there should be a method like the MovableObject::_updateRenderQueue(RenderQueue), for example MovableObject::_updateVisibleBounds(VisibleObjectsBoundsInfo), which expands the bounds as needed, checking whether the materials receive shadows. This approach can even consider that not all sub entities need to receive shadows.
Post Reply