Closed GoogleCodeExporter closed 8 years ago
I think the problem here is that the KinematicCharacterController gets disposed
when the method returns since DynamicsWorld won't keep a reference to it
(DynamicsWorld only deals with the unmanaged object).
This is probably an issue with the object lifetime management and cleanup in
BulletSharp. As a temporary fix, you could try to store the new
KinematicCharacterController in some static array to make it persist until the
program exits, although I'm not sure that will help. I'll try to look into it
soon.
Thanks for reporting this!
Original comment by andres.traks
on 4 Oct 2011 at 7:13
Thanks for your answer. I tried keeping a static reference as you suggested,
unfortunately the problem persists. I hope the issue can be resolved soon.
Thanks again anyway!
Original comment by ptour...@gmail.com
on 4 Oct 2011 at 7:26
I couldn't actually reproduce the error message with your configuration. Does
it run fine otherwise?
Original comment by andres.traks
on 4 Oct 2011 at 7:50
Yes it runs pretty OK. The problem appears on application exit only. If it
helps, I can post some source code tomorrow, or even send you the small test
project that produces the error on my machine.
Original comment by ptour...@gmail.com
on 4 Oct 2011 at 8:21
That would be good.
Original comment by andres.traks
on 4 Oct 2011 at 9:12
Hi again! I have attached a VS2010 solution with the test project I told you
about yesterday. I hope it makes some sense!
Original comment by ptour...@gmail.com
on 5 Oct 2011 at 11:41
Attachments:
I can see the error, but haven't found the cause yet.
Original comment by andres.traks
on 6 Oct 2011 at 6:06
Hi Andres. In the project I sent you, I created a separate "Player" class that
internally holds the KinematicCharacterController, the PairCachingGhostObject
and the ConvexShape and the problem was solved! It is strange though, because
other than the new class, the process I followed to add the character and
collision object to the dynamics world, as well as dispose them, was actually
the same. Anyway, since the problem's solved everything is fine. Thanks again
for your time!
Original comment by ptour...@gmail.com
on 7 Oct 2011 at 10:14
Well, it's been a while, but I traced it back to this line:
_dynamicsWorld.RemoveCollisionObject(_character.GhostObject);
The GhostObject getter property was creating a new wrapper object for the
btGhostObject instead of retrieving the existing one. Since the new object
immediately went out of scope, it also destroyed the btGhostObject, which
caused the crash. This is fixed in r383.
Thanks again!
Original comment by andres.traks
on 9 Jun 2012 at 9:44
Original issue reported on code.google.com by
ptour...@gmail.com
on 4 Oct 2011 at 5:23