MDX: Assigns a new mesh causes auto Dispose()

I'm going through the Software skinning method as a learning exercise & I'm at the GenerateSkinnedMesh step, when I had to do this:

meshContainer.MeshData.Mesh = newMesh

What I'm finding out is that MDX calls Dispose() for the Mesh that's there before assigning the newMesh to it.

1) This is a problem because that Mesh is being kept around in the OriginalMesh property for later use & SHOULD NOT be Dispose'd of, and

2) Is there a way to turn off this behavior If not, MDX is being pretty presumptuous here.


Answer this question

MDX: Assigns a new mesh causes auto Dispose()

  • tibear

    Known issue.... - I emailed it to Tom some time ago. read more here. Personally I think its a bug until someone explains otherwise.

    http://www.ircomm.net/forums/350/ShowPost.aspx

    Hard to exaplin in a short post but basically, when texture #1 gets disposed the autoevents cause a ripple up to the device which for some reason disposes all the other meshes created on it. Turn off the isUsingEventHandlers and the problem goes away.



  • Rick8728

    This was reported to me recently internally as well, and it's something I'm looking at for the next SDK release.  It shouldn't dispose objects in this manner.



  • Ricardo Tomé

    I would expect that this is occuring in the MeshData's set function for the Mesh property.  Instead of changing meshContainer.MeshData.Mesh, maybe you could create a new MeshData object and set meshContainer.MeshData.


  • Joel Miranda

    Thanks, ZMan

    I encountered the Texture issue a while back, and your post showed me the way. The problem is I do have IsUsingEventHandlers = false. Now, my Textures are behaving OK. What I'm having problem with is the MeshContainer.MeshData.Mesh property. If I assign it a new Mesh object, it does a Dispose() on the Mesh that's there first. Big problem if you have a reference to it elsewhere.

    Anyway, I'm coding around it. Just very unexpected behavior. Maybe it comes down to a C++ like behavior of disposing your own object or making it easy for newbies to play with MDX. I vote the former.

  • MDX: Assigns a new mesh causes auto Dispose()