BillBoards + Lights = Crash in OgreMain.dll?

Problems building or running the engine, queries about how to use features etc.
Van
Hobgoblin
Posts: 512
Joined: Fri Nov 19, 2004 3:56 am

BillBoards + Lights = Crash in OgreMain.dll?

Post by Van »

We added "Nav Lights" to our ships (Port and Starboard).
We use a BILLBOARD and a LIGHT (SpotLight) in the same location.

Now, during my development and testing, the nav lights worked. However, other people could NOT run the client because it would crash with a "Send to microsoft" window. I thought it was just their PC, old video drivers, etc. Well, if it didn't happent to me. Now, i can't even run my own code. It is definitly crashing in OgreMain.DLL.

If I disable the Nav Light function, everyone can run the client just fine.

The video cards: Nvdia FX 5700, ATI Radeon 9600, Nvidia 6300.

Is anyone else having a similar problem?
Van
Hobgoblin
Posts: 512
Joined: Fri Nov 19, 2004 3:56 am

Post by Van »

I debugged the problem.....

I am using Ogre 0.15.2 with Newton (physics engine) 1.31.

The problem:
Ogre considers BillboardSets attached to an OgreNode to be a mesh (or submesh in this case).

Consider the following code:

Code: Select all


 //get the mesh!
 Ogre::MovableObject* obj = node->getAttachedObject(0);
 Ogre::Mesh* mesh = ((Ogre::Entity*)obj)->getMesh();

 //get scale
 scale = node->getScale();

 //find number of submeshes
 unsigned short sub = mesh->getNumSubMeshes();

The value in mesh will include the Billboards!!!

So, while trying to build my collision object for the Newton physics engine, Ogre was considering the Billboards as submeshes and causing the code to attempt to calculate verticies for the billboards. This is what generates the error. The error was in OgreMain.DLL and would get the 0x000005 (NULL pointer) error in the Vector.cpp.

Visuall representation

What did NOT work:
(Billboardset being attached to the Ogre ShipNode)

+OgreControlNode
+--ShipNode (used to form the Newton collision object)
+----ShipEntity
+----Billboardset
+--(more nodes attached)

What DOES work:
(Attaching the Billboardset to our Ogre Control node)

+OgreControlNode
+--ShipNode (used to form the Newton collision object)
+----ShipEntity
+--Billboardset
+--(more nodes attached)


Why???!
...is (and should?) a billboard, which is only a 2D representation, being considered as a mesh?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

Ogre considers BillboardSets attached to an OgreNode to be a mesh (or submesh in this case).
No, it doesn't. You've chosen to cast a pointer to one object to a pointer to another type without doing any safety checks.

Code: Select all

//get the mesh!
 Ogre::MovableObject* obj = node->getAttachedObject(0);
 Ogre::Mesh* mesh = ((Ogre::Entity*)obj)->getMesh(); 
If you blindly cast a MovableObject to Entity, if that MovableObject is not an Entity the results are completely undefined. That's not safe C++, and you shouldn't be writing code like that. Check the type of the MovableObject before you do it using getMovableType().

Please don't blame us for coding errors that are not ours, it's not polite.
Van
Hobgoblin
Posts: 512
Joined: Fri Nov 19, 2004 3:56 am

Post by Van »

sinbad wrote:
Please don't blame us for coding errors that are not ours, it's not polite.
DOH! Thank you Sinbad for the heads up. Sometimes you can't see the forest through the tree's...

BTW, I was not blaming anyone. If that is how it was read, my appologies. I was just trying to figure out my issue by posting what I found.

Again, thanks for the heads up!