Incorrect bounding box of directional light

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
heda
Posts: 10
Joined: Mon Jul 16, 2012 3:28 pm
Location: The Netherlands

Incorrect bounding box of directional light

Post by heda »

Hi there,

I am using Irrlicht 1.8.0-alpha, SVN 4306. While playing with the bounding box of directional lights, which are actually lines from the position of the light in the direction of the light, I noticed that they were pointing in the wrong direction. This is caused by the fact that the direction is taken from the rotation of the LightSceneNode, and that rotation is also used to calculate the AbsoluteTransformation, so basically the rotation is applied twice. Below is the proposed fix to line 69 of CLightSceneNode.cpp:

Code: Select all

 
//! render
void CLightSceneNode::render()
{
    video::IVideoDriver* driver = SceneManager->getVideoDriver();
    if (!driver)
        return;
 
    if ( DebugDataVisible & scene::EDS_BBOX )
    {
        driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
        video::SMaterial m;
        m.Lighting = false;
        driver->setMaterial(m);
 
        switch ( LightData.Type )
        {
            case video::ELT_POINT:
            case video::ELT_SPOT:
                driver->draw3DBox(BBox, LightData.DiffuseColor.toSColor());
                break;
 
            case video::ELT_DIRECTIONAL:
                driver->draw3DLine(core::vector3df(0.f, 0.f, 0.f),
//                      LightData.Direction * LightData.Radius,  // this line should be removed
                        core::vector3df(0.f, 0.f, LightData.Radius),  // this line should be inserted
                        LightData.DiffuseColor.toSColor());
                break;
        }
    }
 
    DriverLightIndex = driver->addDynamicLight(LightData);
    setVisible(LightIsOn);
}
 
Hope this helps!

Cheers
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: Incorrect bounding box of directional light

Post by chronologicaldot »

Is this a carry over from Irrlicht 1.7 ?
heda
Posts: 10
Joined: Mon Jul 16, 2012 3:28 pm
Location: The Netherlands

Re: Incorrect bounding box of directional light

Post by heda »

Yeah, 1.7.3 contains exactly the same code.
Post Reply