BulletSim: fix corner case when rebuilding a compound linkset while
a mesh/hull while a mesh or hull is being rebuilt when its asset is fetched. This fixes a 'pure virtual function' crash when changing physical state of complex linksets that include many meshes.cpu-performance
parent
43d804b998
commit
0c971d148c
|
@ -389,9 +389,21 @@ public class BSShapeMesh : BSShape
|
||||||
}
|
}
|
||||||
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
|
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
|
||||||
{
|
{
|
||||||
// Another reference to this shape is just counted.
|
BSShape ret = null;
|
||||||
IncrementReference();
|
// If the underlying shape is native, the actual shape has not been build (waiting for asset)
|
||||||
return this;
|
// and we must create a copy of the native shape since they are never shared.
|
||||||
|
if (physShapeInfo.HasPhysicalShape && physShapeInfo.isNativeShape)
|
||||||
|
{
|
||||||
|
// TODO: decide when the native shapes should be freed. Check in Dereference?
|
||||||
|
ret = BSShapeNative.GetReference(pPhysicsScene, pPrim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Another reference to this shape is just counted.
|
||||||
|
IncrementReference();
|
||||||
|
ret = this;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
public override void Dereference(BSScene physicsScene)
|
public override void Dereference(BSScene physicsScene)
|
||||||
{
|
{
|
||||||
|
@ -560,9 +572,21 @@ public class BSShapeHull : BSShape
|
||||||
}
|
}
|
||||||
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
|
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
|
||||||
{
|
{
|
||||||
// Another reference to this shape is just counted.
|
BSShape ret = null;
|
||||||
IncrementReference();
|
// If the underlying shape is native, the actual shape has not been build (waiting for asset)
|
||||||
return this;
|
// and we must create a copy of the native shape since they are never shared.
|
||||||
|
if (physShapeInfo.HasPhysicalShape && physShapeInfo.isNativeShape)
|
||||||
|
{
|
||||||
|
// TODO: decide when the native shapes should be freed. Check in Dereference?
|
||||||
|
ret = BSShapeNative.GetReference(pPhysicsScene, pPrim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Another reference to this shape is just counted.
|
||||||
|
IncrementReference();
|
||||||
|
ret = this;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
public override void Dereference(BSScene physicsScene)
|
public override void Dereference(BSScene physicsScene)
|
||||||
{
|
{
|
||||||
|
@ -1075,12 +1099,23 @@ public class BSShapeGImpact : BSShape
|
||||||
(w, iC, i, vC, v) => physicsScene.PE.CreateGImpactShape(w, iC, i, vC, v) );
|
(w, iC, i, vC, v) => physicsScene.PE.CreateGImpactShape(w, iC, i, vC, v) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim)
|
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
|
||||||
{
|
{
|
||||||
// Calling this reference means we want another handle to an existing shape
|
BSShape ret = null;
|
||||||
// (usually linksets) so return this copy.
|
// If the underlying shape is native, the actual shape has not been build (waiting for asset)
|
||||||
IncrementReference();
|
// and we must create a copy of the native shape since they are never shared.
|
||||||
return this;
|
if (physShapeInfo.HasPhysicalShape && physShapeInfo.isNativeShape)
|
||||||
|
{
|
||||||
|
// TODO: decide when the native shapes should be freed. Check in Dereference?
|
||||||
|
ret = BSShapeNative.GetReference(pPhysicsScene, pPrim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Another reference to this shape is just counted.
|
||||||
|
IncrementReference();
|
||||||
|
ret = this;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
// Dereferencing a compound shape releases the hold on all the child shapes.
|
// Dereferencing a compound shape releases the hold on all the child shapes.
|
||||||
public override void Dereference(BSScene physicsScene)
|
public override void Dereference(BSScene physicsScene)
|
||||||
|
|
Loading…
Reference in New Issue