does this count as a bug?

Alik

28-01-2010 09:44:44

Hello,

Just getting up to speed with Mogre; liking it so far, though it took a long time to figure out debugging and getting the right call stacks and all that. Anyway, I am writing an extension of the MeshBuilderHelper class from the wiki to make it support multiple submeshes and materials. I ran into an issue that flummoxed me for a while, and it was this: I was creating one VertexDeclaration, and then setting mSubMesh.vertexData.vertexDeclaration = commonVertexDeclaration for each submesh. From .NET, this would seem to work, as queries to mSubMesh.vertexData.vertexDeclaration would return all the expected values. However, it would *sometimes* crash upon rendering or upon finishing the mesh, especially if shadows were enabled. Turns out I needed to leave mSubMesh.vertexData.vertexDeclaration as it was and re-add the elements to the declaration for each submesh. So, I think maybe vertexData.vertexDeclaration should be made a get-only accessor, to prevent this mistake in future.

BTW, one more thing that almost certainly is a bug: when I add a watch to mSubMesh.vertexData.vertexBufferBinding.NextIndex, every time the watch refreshes (e.g. if I add more watches of the same variable) the number increments, or goes to some wild number. (I assume that these weird numbers are also being returned if you use them in the code.) This should not be happening.

Also, is this the right forum for a post like this? Thanks,

Alec

smiley80

28-01-2010 16:51:26

Did you create commonVertexDeclaration with the public constructor of VertexDeclaration or HardwareBufferManager.Singleton.CreateVertexDeclaration?

If you look at the Ogre source, you'll see that 'getNextIndex' increments its return value everytime it's called. In context: everytime the watch looks for the value, it also increments it. That's not a bug, but it's bad behaviour for a property getter. Should be changed to a method.

Alik

29-01-2010 04:57:04

Good point re GetNextIndex; I should have looked that up. Though it seems to me like a bug in Ogre, then -- the documentation says "getNextIndex(): Gets the highest index which has already been set, plus 1", which, if it increments after just a call, is not true.

In answer to your question, I looked closer at my code and found that commonVertexDeclaration was declared with the public constructor. *slaps own wrist* Whoops! Thanks for pointing that out. Though, when I switched it to CreateVertexDeclaration, it now built and rendered OK, but did the whole crash-on-dispose thing, which may be because multiple submeshes are trying to destroy the same vertex declaration (maybe?) so I just left it the way I had it, with re-adding the elements to each submesh's vertex declaration.

Thanks!

smiley80

29-01-2010 10:35:24

Though it seems to me like a bug in Ogre, then -- the documentation says "getNextIndex(): Gets the highest index which has already been set, plus 1", which, if it increments after just a call, is not true.
Judging from the SVN logs, the behaviour of 'getNextIndex' seems to be intentional, but the docu is outdated (since early 2004).


which may be because multiple submeshes are trying to destroy the same vertex declaration (maybe?)

Right, the submesh destructor destroys the vertexdata, and the vertexdata destructor destroys the vertexdeclaration.