ILightSceneNode::doLightRecalc

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

ILightSceneNode::doLightRecalc

Post by chronologicaldot »

It would be nice to have ILightSceneNode::doLightRecalc() or something like it. doLightRecalc() is in CLightSceneNode (but only ILightSceneNode is returned from the scene manager). Without an ugly hack, the only way to reset the light calculations is by a) doing it manually or b) lightNode->setRadius( lightNode->getRadius() );

I have to do light recalculations whenever I translate the light scene node (because for some reason no one planned for moving lights??).
Did I miss something????

For moving the light, here's what I'd like:

Code: Select all

 
ILightSceneNode* lightNode = sceneManager->addLightSceneNode(0, SColorf( SColor(0xffffffff) ), vector3df(), 100 );
// somewhere later, like in an animator...
lightNode->setTranslation( vector3df(4,0,10) ); // Should change light data too, but doesn't
// but this is required:
lightNode->setRadius( lightNode->getRadius() );
 
It would actually be nice if the light node itself simply called doLightRecalc() inside setTranslation(), and that way, native animators could be used and we wouldn't have doLightRecalc() exposed.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ILightSceneNode::doLightRecalc

Post by CuteAlien »

It calls doLightRecalc in OnRegisterSceneNode, but I guess that might be too early for animators.

Usually nothing much is done in setTranslation because the matrices are not updated there yet. That's done in updateAbsolutePosition() which is usually just called once (and that's an important enough speed optimization that it's not easy to remove despite all the troubles it causes). I wondered a few times already if the real solution might be using dirty-flags instead which ensure getAbsoluteTransformation always returns the updated matrix. But have to check what's going on exactly.

At least the light recalc should be done in updateAbsolutePosition() I think.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ILightSceneNode::doLightRecalc

Post by CuteAlien »

In svn r5111 do now a doLightRecalc in updateAbsolutePosition. This is already called after animators are run so it should now be possible to use native animators. I didn't know how to write a quick test-case for it which showed me the problems (hard to see if it's just stuff 1 frame wrong and about lights), so this is untested...
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
chronologicaldot
Competition winner
Posts: 688
Joined: Mon Sep 10, 2012 8:51 am

Re: ILightSceneNode::doLightRecalc

Post by chronologicaldot »

Thanks!
feelthat
Posts: 194
Joined: Sat Feb 02, 2013 5:27 am

Re: ILightSceneNode::doLightRecalc

Post by feelthat »

check keywords

spot light
chronologicaldot wrote:Thanks!
Last edited by feelthat on Tue Aug 18, 2015 4:57 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ILightSceneNode::doLightRecalc

Post by CuteAlien »

@feelthat: It doesn't help if you link it again,I've seen it back then. But I can't do anything with posts like that until you start explaining what your code is about. You have to describe the problem. You have to explain the solution. If you have a test even better. But describing and explaining is essential.

And in this case there seems also the problem that you copied code which was under GPL. That is incompatible with the zlib license of Irrlicht. Sorry, we can't use GPL code, please be careful with licenses.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
feelthat
Posts: 194
Joined: Sat Feb 02, 2013 5:27 am

Re: ILightSceneNode::doLightRecalc

Post by feelthat »

ok i will take care~~~

thanks
CuteAlien wrote:@feelthat: It doesn't help if you link it again,I've seen it back then. But I can't do anything with posts like that until you start explaining what your code is about. You have to describe the problem. You have to explain the solution. If you have a test even better. But describing and explaining is essential.

And in this case there seems also the problem that you copied code which was under GPL. That is incompatible with the zlib license of Irrlicht. Sorry, we can't use GPL code, please be careful with licenses.
Post Reply