BulletSim: delay adding a scene presence to the list of presences

until it is fully configured. Another addition to fixing the
collisions stopping problem.
This commit is contained in:
Robert Adams
2015-08-23 21:15:04 -07:00
parent 11209c72f5
commit 062ec0efbd
3 changed files with 33 additions and 19 deletions

View File

@@ -71,6 +71,11 @@ public abstract class BSPhysObject : PhysicsActor
{
}
protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName)
{
InitializePhysObject(parentScene, localID, name, typeName);
}
protected void InitializePhysObject(BSScene parentScene, uint localID, string name, string typeName)
{
IsInitialized = false;
@@ -119,6 +124,8 @@ public abstract class BSPhysObject : PhysicsActor
// Tell the object to clean up.
public virtual void Destroy()
{
SubscribedEventsMs = 0;
PhysicalActors.Enable(false);
PhysScene.TaintedObject(LocalID, "BSPhysObject.Destroy", delegate()
{
@@ -455,6 +462,7 @@ public abstract class BSPhysObject : PhysicsActor
// Return 'true' if a collision was processed and should be sent up.
// Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision.
// Called at taint time from within the Step() function
// Both 'CollisionLock' and 'PhysObjects' are locked when this is called by 'SendCollisions'.
public delegate bool CollideCall(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth);
public virtual bool Collide(uint collidingWith, BSPhysObject collidee,
OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
@@ -512,7 +520,7 @@ public abstract class BSPhysObject : PhysicsActor
// If no collisions this call but there were collisions last call, force the collision
// event to be happen right now so quick collision_end.
bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0);
bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0);
// throttle the collisions to the number of milliseconds specified in the subscription
if (force || (PhysScene.SimulationNowTime >= NextCollisionOkTime))
@@ -545,7 +553,7 @@ public abstract class BSPhysObject : PhysicsActor
// Subscribe for collision events.
// Parameter is the millisecond rate the caller wishes collision events to occur.
public override void SubscribeEvents(int ms) {
// DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms);
DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms);
SubscribedEventsMs = ms;
if (ms > 0)
{