[bleeding] Bug in RenderableSources

luis

01-06-2008 16:55:21

The bug is in 1.0-18 but i beleive it is in the lastest version also.

If you create bodies, then delete just some of them and create more bodies again the link between the visual representation (source renderable) and the physics is lost in the new bodies and in the old ones.
So you see you objects floating in the scene or you dont see them at all (but there are ! in the VRD you can see them).

The bug is here:

void SceneRenderer::registerSource(NxOgre::RenderableSource *source) {
NxRenderableSourceID id = mSources.count() + 1; // <---- THIS LINE
NxRenderableSourceID id = ++mLastRenderableSourceID;
source->mRenderableSourceID = id;
mSources.insert(id, source);
}



My solution was:

void SceneRenderer::registerSource(NxOgre::RenderableSource *source) {
NxRenderableSourceID id = ++mLastRenderableSourceID;
source->mRenderableSourceID = id;
mSources.insert(id, source);
}


mLastRenderableSourceID type is NxRenderableSourceID and it is intialized in SceneRenderer's ctor to zero ;)

luis

01-06-2008 19:11:57

I forget to say the reason... since mSources is an associative container the source will not be inserted if it is already registered with the same ID.
And erasing objects implies changing the size of mSources so:
mSources.count() + 1
Will not generate unique IDs.....

Betajaen do you want me to submit a patch or this problem will not exist in 1.0-24?

betajaen

01-06-2008 19:35:37

Yep, '21/'22 has this problem too.

void SceneRenderer::registerSource(NxOgre::RenderableSource *source) {
source->mRenderableSourceID = mSources.Size() + 1;
mSources.Insert(source);
}


It uses a SharedList instead of a Container now; so the bug is different, name collisions are less likely to occur.

But I'm on it.

[Edit]

There.

void SceneRenderer::registerSource(NxOgre::RenderableSource *source) {
source->mRenderableSourceID = mNextRenderableSourceID++;
mSources.Insert(source);
}