[2.2+] Billboard broken

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Lax
Gnoll
Posts: 659
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 63

[2.2+] Billboard broken

Post by Lax »

Hi dark_sylinc,

I'm making some Ogre components tests and with Ogre 2.2+ version Billboards do no longer work.

I debugged and when setting the datablock, (e.g. "Star", which is an unlit datablock) for a BillboardSet:

Code: Select all

this->billboardSet->setDatablock(Ogre::Root::getSingleton().getHlmsManager()->getDatablock("Star"));
Its internally not really set, because in "OgreBillboardSet.cpp":

Code: Select all

void BillboardSet::setDatablock( HlmsDatablock *datablock )
    {
        mMaterialName.clear();
        mMaterialGroup.clear();

        const String *fullDatablockName = datablock->getNameStr();
        if( fullDatablockName )
        {
            mMaterialName = *fullDatablockName;
        }
        else
        {
            LogManager::getSingleton().logMessage(
                        "Couldn't retrieve full material name of datablock '" +
                        datablock->getName().getFriendlyText() +
                        "' Billboard may not render as expected. "
                        "May be the datablock is scheduled for deletion?" );
        }

        if( mBuffersCreated )
            Renderable::setDatablock( datablock );
    }
--> Renderable::setDatablock( datablock ); is not called, because the mBuffersCreated is not true.
I get a crash in the next Ogre update:

Image

Because in the render queue the datablock is null, but there is access on that datablock.

Could you look into that issue?

Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5446
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1348

Re: [2.2+] Billboard broken

Post by dark_sylinc »

I'm currently into something else.

When mBuffersCreated == false, we save the mMaterialName; and later in _createBuffers() we create the buffers and set the material we kept from its name.

_createBuffers is called by beginBillboards.
beginBillboards is called by BillboardParticleRenderer::_updateRenderQueue
_updateRenderQueue is supposed to be called in SceneManager::_renderPhase02

Research why beginBillboards / _updateRenderQueue is not getting called timely enough and you'll find the problem.
Lax
Gnoll
Posts: 659
Joined: Mon Aug 06, 2007 12:53 pm
Location: Saarland, Germany
x 63

Re: [2.2+] Billboard broken

Post by Lax »

ok thanks. You pointed me in the right direction. I had the billboard in a wrong render queue.

Now, when I destroy a billboard I get a crash, because in:

Code: Select all

void BillboardSet::_destroyBuffers(void)
    {
        if (mVertexData)
        {
            OGRE_DELETE mVertexData;
            mVertexData = 0;
        }
        if (mIndexData)
        {
            OGRE_DELETE mIndexData;
            mIndexData = 0;
        }

        mMainBuf.setNull();
        mMainBuffers.clear();

        if( mHlmsDatablock && getMaterial().isNull() )
        {
            mHlmsDatablock->_unlinkRenderable( this );
            mHlmsDatablock = 0;
            _setHlmsHashes( 0u, 0u );
        }

        mBuffersCreated = false;
    }
-> "_setHlmsHashes(0u, 0u)" is called and inside:

Code: Select all

void Renderable::_setHlmsHashes( uint32 hash, uint32 casterHash )
    {
        mHlmsHash       = hash;
        mHlmsCasterHash = casterHash;

        assert( (mHlmsDatablock->getAlphaTest() == CMPF_ALWAYS_PASS ||
                mVaoPerLod[0].empty() || mVaoPerLod[0][0] == mVaoPerLod[1][0])
                && "v2 objects must overload _setHlmsHashes to disable special "
                "shadow mapping buffers on objects with alpha testing materials" );
    }
the assert causes a crash, because the mHlmsDatablock is already null. I thing, there is just a nullptr condition missing.

Best Regards
Lax

http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62