BulletSim: properly free references to simple convex hull shapes. Didn't
loose memory since shapes are shared but did mess up usage accounting.user_profiles
parent
1c6b8293d7
commit
84118c5735
|
@ -117,11 +117,11 @@ public abstract class BSShape
|
||||||
StringBuilder buff = new StringBuilder();
|
StringBuilder buff = new StringBuilder();
|
||||||
if (physShapeInfo == null)
|
if (physShapeInfo == null)
|
||||||
{
|
{
|
||||||
buff.Append(",noPhys");
|
buff.Append("<noPhys");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buff.Append(",phy=");
|
buff.Append("<phy=");
|
||||||
buff.Append(physShapeInfo.ToString());
|
buff.Append(physShapeInfo.ToString());
|
||||||
}
|
}
|
||||||
buff.Append(",c=");
|
buff.Append(",c=");
|
||||||
|
@ -808,17 +808,25 @@ public class BSShapeCompound : BSShape
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (physicsScene.PE.IsCompound(pShape))
|
BSShapeConvexHull chullDesc;
|
||||||
|
if (BSShapeConvexHull.TryGetHullByPtr(pShape, out chullDesc))
|
||||||
{
|
{
|
||||||
BSShapeCompound recursiveCompound = new BSShapeCompound(pShape);
|
chullDesc.Dereference(physicsScene);
|
||||||
recursiveCompound.Dereference(physicsScene);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (physicsScene.PE.IsNativeShape(pShape))
|
if (physicsScene.PE.IsCompound(pShape))
|
||||||
{
|
{
|
||||||
BSShapeNative nativeShape = new BSShapeNative(pShape);
|
BSShapeCompound recursiveCompound = new BSShapeCompound(pShape);
|
||||||
nativeShape.Dereference(physicsScene);
|
recursiveCompound.Dereference(physicsScene);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (physicsScene.PE.IsNativeShape(pShape))
|
||||||
|
{
|
||||||
|
BSShapeNative nativeShape = new BSShapeNative(pShape);
|
||||||
|
nativeShape.Dereference(physicsScene);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -898,6 +906,27 @@ public class BSShapeConvexHull : BSShape
|
||||||
// TODO: schedule aging and destruction of unused meshes.
|
// TODO: schedule aging and destruction of unused meshes.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Loop through all the known hulls and return the description based on the physical address.
|
||||||
|
public static bool TryGetHullByPtr(BulletShape pShape, out BSShapeConvexHull outHull)
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
BSShapeConvexHull foundDesc = null;
|
||||||
|
lock (ConvexHulls)
|
||||||
|
{
|
||||||
|
foreach (BSShapeConvexHull sh in ConvexHulls.Values)
|
||||||
|
{
|
||||||
|
if (sh.physShapeInfo.ReferenceSame(pShape))
|
||||||
|
{
|
||||||
|
foundDesc = sh;
|
||||||
|
ret = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outHull = foundDesc;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================================================
|
// ============================================================================================================
|
||||||
|
|
Loading…
Reference in New Issue