BulletSim: fix not moving physical objects below terrain to over terrain.
Add locking on register prestep action list preventing potential race conditions. Little comment and formatting changes.user_profiles
parent
8bf0a9f85d
commit
4e1ca890c2
|
@ -126,9 +126,9 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
DetailLog("{0},BSCharacter.Destroy", LocalID);
|
DetailLog("{0},BSCharacter.Destroy", LocalID);
|
||||||
PhysicsScene.TaintedObject("BSCharacter.destroy", delegate()
|
PhysicsScene.TaintedObject("BSCharacter.destroy", delegate()
|
||||||
{
|
{
|
||||||
PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null);
|
PhysicsScene.Shapes.DereferenceBody(PhysBody, true /* inTaintTime */, null /* bodyCallback */);
|
||||||
PhysBody.Clear();
|
PhysBody.Clear();
|
||||||
PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null);
|
PhysicsScene.Shapes.DereferenceShape(PhysShape, true /* inTaintTime */, null /* bodyCallback */);
|
||||||
PhysShape.Clear();
|
PhysShape.Clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,10 +382,13 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
{
|
{
|
||||||
string identifier = op + "-" + id.ToString();
|
string identifier = op + "-" + id.ToString();
|
||||||
|
|
||||||
|
lock (RegisteredActions)
|
||||||
|
{
|
||||||
// Clean out any existing action
|
// Clean out any existing action
|
||||||
UnRegisterPreStepAction(op, id);
|
UnRegisterPreStepAction(op, id);
|
||||||
|
|
||||||
RegisteredActions[identifier] = actn;
|
RegisteredActions[identifier] = actn;
|
||||||
|
}
|
||||||
PhysicsScene.BeforeStep += actn;
|
PhysicsScene.BeforeStep += actn;
|
||||||
DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
|
DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
|
||||||
}
|
}
|
||||||
|
@ -395,22 +398,28 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
{
|
{
|
||||||
string identifier = op + "-" + id.ToString();
|
string identifier = op + "-" + id.ToString();
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
|
lock (RegisteredActions)
|
||||||
|
{
|
||||||
if (RegisteredActions.ContainsKey(identifier))
|
if (RegisteredActions.ContainsKey(identifier))
|
||||||
{
|
{
|
||||||
PhysicsScene.BeforeStep -= RegisteredActions[identifier];
|
PhysicsScene.BeforeStep -= RegisteredActions[identifier];
|
||||||
RegisteredActions.Remove(identifier);
|
RegisteredActions.Remove(identifier);
|
||||||
removed = true;
|
removed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed);
|
DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UnRegisterAllPreStepActions()
|
protected void UnRegisterAllPreStepActions()
|
||||||
|
{
|
||||||
|
lock (RegisteredActions)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions)
|
foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions)
|
||||||
{
|
{
|
||||||
PhysicsScene.BeforeStep -= kvp.Value;
|
PhysicsScene.BeforeStep -= kvp.Value;
|
||||||
}
|
}
|
||||||
RegisteredActions.Clear();
|
RegisteredActions.Clear();
|
||||||
|
}
|
||||||
DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID);
|
DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -379,7 +379,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// If the object is below ground it just has to be moved up because pushing will
|
// If the object is below ground it just has to be moved up because pushing will
|
||||||
// not get it through the terrain
|
// not get it through the terrain
|
||||||
_position.Z = targetHeight;
|
_position.Z = targetHeight;
|
||||||
if (!inTaintTime)
|
if (inTaintTime)
|
||||||
ForcePosition = _position;
|
ForcePosition = _position;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,12 +387,14 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
if (!m_initialized) return null;
|
if (!m_initialized) return null;
|
||||||
|
|
||||||
BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying);
|
BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying);
|
||||||
lock (PhysObjects) PhysObjects.Add(localID, actor);
|
lock (PhysObjects)
|
||||||
|
PhysObjects.Add(localID, actor);
|
||||||
|
|
||||||
// TODO: Remove kludge someday.
|
// TODO: Remove kludge someday.
|
||||||
// We must generate a collision for avatars whether they collide or not.
|
// We must generate a collision for avatars whether they collide or not.
|
||||||
// This is required by OpenSim to update avatar animations, etc.
|
// This is required by OpenSim to update avatar animations, etc.
|
||||||
lock (m_avatars) m_avatars.Add(actor);
|
lock (m_avatars)
|
||||||
|
m_avatars.Add(actor);
|
||||||
|
|
||||||
return actor;
|
return actor;
|
||||||
}
|
}
|
||||||
|
@ -408,9 +410,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock (PhysObjects) PhysObjects.Remove(actor.LocalID);
|
lock (PhysObjects)
|
||||||
|
PhysObjects.Remove(bsactor.LocalID);
|
||||||
// Remove kludge someday
|
// Remove kludge someday
|
||||||
lock (m_avatars) m_avatars.Remove(bsactor);
|
lock (m_avatars)
|
||||||
|
m_avatars.Remove(bsactor);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -419,6 +423,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
bsactor.Destroy();
|
bsactor.Destroy();
|
||||||
// bsactor.dispose();
|
// bsactor.dispose();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("{0}: Requested to remove avatar that is not a BSCharacter. ID={1}, type={2}",
|
||||||
|
LogHeader, actor.LocalID, actor.GetType().Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RemovePrim(PhysicsActor prim)
|
public override void RemovePrim(PhysicsActor prim)
|
||||||
|
|
Loading…
Reference in New Issue