Reduce complexity of OdeScene.Simulate() by fully removing bad characters at point of detection rather than later on.
parent
5bd27b7b22
commit
4a99619bc0
|
@ -172,7 +172,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
|
||||
m_taintPosition = _position;
|
||||
|
||||
m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
|
||||
m_log.WarnFormat("[ODE CHARACTER]: Got NaN Position on Character Create for {0}", avName);
|
||||
}
|
||||
|
||||
_parent_scene = parent_scene;
|
||||
|
@ -195,7 +195,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
m_colliderarr[i] = false;
|
||||
}
|
||||
CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
|
||||
//m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
|
||||
//m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH.ToString());
|
||||
m_tainted_CAPSULE_LENGTH = CAPSULE_LENGTH;
|
||||
|
||||
m_isPhysical = false; // current status: no ODE information exists
|
||||
|
@ -265,7 +265,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
set
|
||||
{
|
||||
flying = value;
|
||||
// m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying);
|
||||
// m_log.DebugFormat("[ODE CHARACTER]: Set OdeCharacter Flying to {0}", flying);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("[PHYSICS]: Got a NaN Position from Scene on a Character");
|
||||
m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Position from Scene on character {0}", Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
Vector3 SetSize = value;
|
||||
m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
|
||||
// m_log.Info("[SIZE]: " + CAPSULE_LENGTH);
|
||||
// m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH);
|
||||
|
||||
// If we reset velocity here, then an avatar stalls when it crosses a border for the first time
|
||||
// (as the height of the new root agent is set).
|
||||
|
@ -473,7 +473,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("[PHYSICS]: Got a NaN Size from Scene on a Character");
|
||||
m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size from Scene on {0}", Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -532,7 +532,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
float xTiltComponent = -movementVector.X * m_tiltMagnitudeWhenProjectedOnXYPlane;
|
||||
float yTiltComponent = -movementVector.Y * m_tiltMagnitudeWhenProjectedOnXYPlane;
|
||||
|
||||
//m_log.Debug("[PHYSICS] changing avatar tilt");
|
||||
//m_log.Debug("[ODE CHARACTER]: changing avatar tilt");
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, xTiltComponent);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, xTiltComponent); // must be same as lowstop, else a different, spurious tilt is introduced
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, yTiltComponent);
|
||||
|
@ -559,17 +559,16 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
_parent_scene.waitForSpaceUnlock(_parent_scene.space);
|
||||
if (CAPSULE_LENGTH <= 0)
|
||||
{
|
||||
m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
|
||||
m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
|
||||
CAPSULE_LENGTH = 0.01f;
|
||||
|
||||
}
|
||||
|
||||
if (CAPSULE_RADIUS <= 0)
|
||||
{
|
||||
m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
|
||||
m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
|
||||
CAPSULE_RADIUS = 0.01f;
|
||||
|
||||
}
|
||||
|
||||
Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
|
||||
|
||||
d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
|
||||
|
@ -769,7 +768,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character");
|
||||
m_log.WarnFormat("[ODE CHARACTER]: Got a NaN velocity from Scene for {0}", Name);
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[PHYSICS]: Set target velocity of {0}", m_taintTargetVelocity);
|
||||
|
@ -844,7 +843,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("[PHYSICS]: Got a NaN force applied to a Character");
|
||||
m_log.WarnFormat("[ODE CHARACTER]: Got a NaN force applied to {0}", Name);
|
||||
}
|
||||
//m_lastUpdateSent = false;
|
||||
}
|
||||
|
@ -870,11 +869,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
/// Called from Simulate
|
||||
/// This is the avatar's movement control + PID Controller
|
||||
/// </summary>
|
||||
/// <param name="defects">
|
||||
/// If there is something wrong with the character (e.g. its position is non-finite)
|
||||
/// then it is added to this list. The ODE structures associated with it are also destroyed.
|
||||
/// </param>
|
||||
internal void Move(List<OdeCharacter> defects)
|
||||
/// <remarks>
|
||||
/// This routine will remove the character from the physics scene if it detects something wrong (non-finite
|
||||
/// position or velocity).
|
||||
/// </remarks>
|
||||
internal void Move()
|
||||
{
|
||||
// no lock; for now it's only called from within Simulate()
|
||||
|
||||
|
@ -895,11 +894,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
if (!localPos.IsFinite())
|
||||
{
|
||||
m_log.WarnFormat("[PHYSICS]: Avatar Position of {0} is non-finite!", Name);
|
||||
|
||||
defects.Add(this);
|
||||
// _parent_scene.RemoveCharacter(this);
|
||||
m_log.WarnFormat(
|
||||
"[ODE CHARACTER]: Avatar position of {0} for {1} is non-finite! Removing from physics scene.",
|
||||
localPos, Name);
|
||||
|
||||
_parent_scene.RemoveCharacter(this);
|
||||
DestroyOdeStructures();
|
||||
|
||||
return;
|
||||
|
@ -1034,11 +1033,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("[PHYSICS]: Got a NaN force vector in Move()");
|
||||
m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
|
||||
defects.Add(this);
|
||||
// _parent_scene.RemoveCharacter(this);
|
||||
m_log.WarnFormat(
|
||||
"[ODE CHARACTER]: Got a NaN force vector {0} in Move() for {1}. Removing character from physics scene.",
|
||||
vec, Name);
|
||||
|
||||
_parent_scene.RemoveCharacter(this);
|
||||
DestroyOdeStructures();
|
||||
}
|
||||
}
|
||||
|
@ -1057,7 +1056,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
catch (NullReferenceException)
|
||||
{
|
||||
bad = true;
|
||||
_parent_scene.BadCharacter(this);
|
||||
_parent_scene.RemoveCharacter(this);
|
||||
DestroyOdeStructures();
|
||||
newPos = new d.Vector3(_position.X, _position.Y, _position.Z);
|
||||
base.RaiseOutOfBounds(_position); // Tells ScenePresence that there's a problem!
|
||||
|
@ -1258,7 +1257,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
// Create avatar capsule and related ODE data
|
||||
if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero))
|
||||
{
|
||||
m_log.Warn("[PHYSICS]: re-creating the following avatar ODE data, even though it already exists - "
|
||||
m_log.Warn("[ODE CHARACTER]: re-creating the following avatar ODE data for " + Name + ", even though it already exists - "
|
||||
+ (Shell!=IntPtr.Zero ? "Shell ":"")
|
||||
+ (Body!=IntPtr.Zero ? "Body ":"")
|
||||
+ (Amotor!=IntPtr.Zero ? "Amotor ":""));
|
||||
|
@ -1303,7 +1302,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("[ODE CHARACTER]: trying to change capsule size, but the following ODE data is missing - "
|
||||
m_log.Warn("[ODE CHARACTER]: trying to change capsule size for " + Name + ", but the following ODE data is missing - "
|
||||
+ (Shell==IntPtr.Zero ? "Shell ":"")
|
||||
+ (Body==IntPtr.Zero ? "Body ":"")
|
||||
+ (Amotor==IntPtr.Zero ? "Amotor ":""));
|
||||
|
|
|
@ -193,14 +193,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
|
||||
private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
|
||||
|
||||
/// <summary>
|
||||
/// Defects list to remove characters that no longer have finite positions due to some other bug.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used repeatedly in Simulate() but initialized once here.
|
||||
/// </remarks>
|
||||
private readonly List<OdeCharacter> defects = new List<OdeCharacter>();
|
||||
|
||||
/// <summary>
|
||||
/// Used to lock on manipulation of _taintedPrimL and _taintedPrimH
|
||||
/// </summary>
|
||||
|
@ -1734,15 +1726,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
}
|
||||
|
||||
internal void BadCharacter(OdeCharacter chr)
|
||||
{
|
||||
lock (_badCharacter)
|
||||
{
|
||||
if (!_badCharacter.Contains(chr))
|
||||
_badCharacter.Add(chr);
|
||||
}
|
||||
}
|
||||
|
||||
private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
|
||||
PrimitiveBaseShape pbs, bool isphysical, uint localID)
|
||||
{
|
||||
|
@ -2789,15 +2772,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
|||
foreach (OdeCharacter actor in _characters)
|
||||
{
|
||||
if (actor != null)
|
||||
actor.Move(defects);
|
||||
}
|
||||
|
||||
if (0 != defects.Count)
|
||||
{
|
||||
foreach (OdeCharacter defect in defects)
|
||||
RemoveCharacter(defect);
|
||||
|
||||
defects.Clear();
|
||||
actor.Move();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2872,19 +2847,6 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
|||
}
|
||||
}
|
||||
|
||||
lock (_badCharacter)
|
||||
{
|
||||
if (_badCharacter.Count > 0)
|
||||
{
|
||||
foreach (OdeCharacter chr in _badCharacter)
|
||||
{
|
||||
RemoveCharacter(chr);
|
||||
}
|
||||
|
||||
_badCharacter.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
lock (_activeprims)
|
||||
{
|
||||
//if (timeStep < 0.2f)
|
||||
|
|
Loading…
Reference in New Issue