Page 1 of 1

::ConstIterator and ::Iterator access

Posted: Sat Oct 11, 2008 8:36 am
by aheymann
I am restarting a thread that is currently embedded within another thread to see if I can get some answers to my problem. I have a ILightSceneNode, which has attached with it a IBillboardSceneNode (as a child node). I am using the SVN trunk. In 1.4.2 it all works fine, but due to changes in 1.5 with the declaration of ISceneNode as a virtual class problems happen.

This is what I am trying to do :

Code: Select all

   core::list<ISceneNode *>::ConstIterator it;

:
:
      pLight = Light->pIRRLight;
      
      it = pLight->getChildren().begin();
      if (*it)
			((IBillboardSceneNode *) *it)->setSize(Size * pLight->getPosition().getDistanceFrom(pos) * A1_SIZE);
pLight is a ILightSceneNode

my compiler gives the following errors :

1>c:\msdev\onyx\src\commonstuff\Drawing3D.cpp(355) : error C2635: cannot convert a 'irr::scene::ISceneNode*' to a 'irr::scene::IBillboardSceneNode*'; conversion from a virtual base class is implied
1> c:\msdev\onyx\src\trunk\include\ISceneNode.h(35) : see declaration of 'irr::scene::ISceneNode'
1> c:\msdev\onyx\src\trunk\include\IBillboardSceneNode.h(20) : see declaration of 'irr::scene::IBillboardSceneNode'
1>c:\msdev\onyx\src\commonstuff\Drawing3D.cpp(355) : error C2039: 'setSize' : is not a member of 'irr::scene::ISceneNode'
1> c:\msdev\onyx\src\trunk\include\ISceneNode.h(35) : see declaration of 'irr::scene::ISceneNode'


I have tried <dynamic_cast> - runtime error.

Please, please I need to get this resolved.

Thanks

Anton

Posted: Sat Oct 11, 2008 9:32 am
by rogerborg
Oops. I hope I'm wrong, but I'm not sure that there is a solution to that, other than turning on RTTI and using dynamic_cast<>. You can't even brute force (void*) your way around it.

You might want to take this up directly with hybrid, since he virtualised IBillboardSceneNode back in February.

Posted: Sat Oct 11, 2008 10:10 am
by hybrid
I already concluded the other thread with reverting these changes, because of the cast problems we would face wiht the current solution. Since we don't want RTTI and dynamic_cast in Irrlicht we will go for the duplication solution.

Posted: Sat Oct 11, 2008 12:15 pm
by aheymann
Hybrid

Are there not other classes that are derived from ISceneNode that are virtual as well e.g. ITextSceneNode etc. e.g. this might resolve this particular issue with billboards, but is this going to be a robust general solution. Anyway thanks for the efforts:)

Anton

Posted: Sat Oct 11, 2008 4:12 pm
by hybrid
No, these are the only two/three: The ITextSceneNode and IBillboardSceneNode, which are both inherited by CBillboardTextSceneNode...