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
|
@ -388,10 +388,22 @@ public class BSShapeMesh : BSShape
|
||||||
return retMesh;
|
return retMesh;
|
||||||
}
|
}
|
||||||
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
|
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
|
||||||
|
{
|
||||||
|
BSShape ret = null;
|
||||||
|
// If the underlying shape is native, the actual shape has not been build (waiting for asset)
|
||||||
|
// 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.
|
// Another reference to this shape is just counted.
|
||||||
IncrementReference();
|
IncrementReference();
|
||||||
return this;
|
ret = this;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
public override void Dereference(BSScene physicsScene)
|
public override void Dereference(BSScene physicsScene)
|
||||||
{
|
{
|
||||||
|
@ -559,10 +571,22 @@ public class BSShapeHull : BSShape
|
||||||
return retHull;
|
return retHull;
|
||||||
}
|
}
|
||||||
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
|
public override BSShape GetReference(BSScene pPhysicsScene, BSPhysObject pPrim)
|
||||||
|
{
|
||||||
|
BSShape ret = null;
|
||||||
|
// If the underlying shape is native, the actual shape has not been build (waiting for asset)
|
||||||
|
// 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.
|
// Another reference to this shape is just counted.
|
||||||
IncrementReference();
|
IncrementReference();
|
||||||
return this;
|
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)
|
||||||
|
// 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();
|
IncrementReference();
|
||||||
return this;
|
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