yoshinoToylogic / bulletsharp

Automatically exported from code.google.com/p/bulletsharp
MIT License
0 stars 0 forks source link

OverlappingPairCache causes duplicate keys exception in ObjectTable #43

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I've implemented this example: 
http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Callbacks_and_T
riggers#btGhostObject

So it will mostly look like this:

AlignedManifoldArray manifoldArray = new AlignedManifoldArray();
OverlappingPairCache cache = ghostBody.OverlappingPairCache;
AlignedBroadphasePairArray pairArray = cache.OverlappingPairArray;

for (...)
{
...
}

What is the expected output? What do you see instead?

The second time it is called it will crash with a duplicate keys exception 
caused by a ObjectTable::Add call in OverlappingPairCallback.cpp (line 14).

I could fix it by just calling

pairArray.Dispose();
cache.Dispose();
manifoldArray.Dispose();

at the end of all. So I'm not sure if I should just dispose them evertime I'm 
finished or if OverlappingPairCallback should check if _unmanaged is already in 
ObjectTable.

Please provide any additional information below.

This looks simular to issue 38 and your fix in r362

Original issue reported on code.google.com by Hagn99@gmail.com on 30 Sep 2012 at 3:35

GoogleCodeExporter commented 8 years ago
Try r422. GhostObject should have kept the reference to the 
OverlappingPairCache, but instead created a new wrapper object the second time. 
There's no need to dispose now, because all the Dispose call did was remove the 
object from the object table, allowing another wrapper object to be created for 
that same unmanaged object.

Thanks again!

Original comment by andres.traks on 30 Sep 2012 at 6:49

GoogleCodeExporter commented 8 years ago
Works perfectly. Thank you!

Original comment by Hagn99@gmail.com on 30 Sep 2012 at 7:13

GoogleCodeExporter commented 8 years ago

Original comment by andres.traks on 30 Sep 2012 at 7:14