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=");
|
||||||
|
@ -807,6 +807,13 @@ public class BSShapeCompound : BSShape
|
||||||
hullDesc.Dereference(physicsScene);
|
hullDesc.Dereference(physicsScene);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
BSShapeConvexHull chullDesc;
|
||||||
|
if (BSShapeConvexHull.TryGetHullByPtr(pShape, out chullDesc))
|
||||||
|
{
|
||||||
|
chullDesc.Dereference(physicsScene);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (physicsScene.PE.IsCompound(pShape))
|
if (physicsScene.PE.IsCompound(pShape))
|
||||||
{
|
{
|
||||||
|
@ -824,6 +831,7 @@ public class BSShapeCompound : BSShape
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================================================
|
// ============================================================================================================
|
||||||
|
@ -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