refactor: Move another chunk of ninja code out of the OdeScene.Simulate() loop for consistency and readability.
parent
3f0d8f3cbf
commit
2a39d0cdb0
|
@ -2738,7 +2738,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SupportsNINJAJoints)
|
if (SupportsNINJAJoints)
|
||||||
SimulateNINJAJoints();
|
SimulatePendingNINJAJoints();
|
||||||
|
|
||||||
if (processedtaints)
|
if (processedtaints)
|
||||||
//Console.WriteLine("Simulate calls Clear of _taintedPrim list");
|
//Console.WriteLine("Simulate calls Clear of _taintedPrim list");
|
||||||
|
@ -2839,6 +2839,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
||||||
{
|
{
|
||||||
if (actor.bad)
|
if (actor.bad)
|
||||||
m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
|
m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
|
||||||
|
|
||||||
actor.UpdatePositionAndVelocity();
|
actor.UpdatePositionAndVelocity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2852,6 +2853,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
||||||
{
|
{
|
||||||
RemoveCharacter(chr);
|
RemoveCharacter(chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
_badCharacter.Clear();
|
_badCharacter.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2867,30 +2869,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
||||||
actor.UpdatePositionAndVelocity();
|
actor.UpdatePositionAndVelocity();
|
||||||
|
|
||||||
if (SupportsNINJAJoints)
|
if (SupportsNINJAJoints)
|
||||||
{
|
SimulateActorPendingJoints(actor);
|
||||||
// If an actor moved, move its joint proxy objects as well.
|
|
||||||
// There seems to be an event PhysicsActor.OnPositionUpdate that could be used
|
|
||||||
// for this purpose but it is never called! So we just do the joint
|
|
||||||
// movement code here.
|
|
||||||
|
|
||||||
if (actor.SOPName != null &&
|
|
||||||
joints_connecting_actor.ContainsKey(actor.SOPName) &&
|
|
||||||
joints_connecting_actor[actor.SOPName] != null &&
|
|
||||||
joints_connecting_actor[actor.SOPName].Count > 0)
|
|
||||||
{
|
|
||||||
foreach (PhysicsJoint affectedJoint in joints_connecting_actor[actor.SOPName])
|
|
||||||
{
|
|
||||||
if (affectedJoint.IsInPhysicsEngine)
|
|
||||||
{
|
|
||||||
DoJointMoved(affectedJoint);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DoJointErrorMessage(affectedJoint, "a body connected to a joint was moved, but the joint doesn't exist yet! this will lead to joint error. joint was: " + affectedJoint.ObjectNameInScene + " parms:" + affectedJoint.RawParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2925,7 +2904,9 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
||||||
// If Physics stalls, it takes longer which makes the tick count ms larger.
|
// If Physics stalls, it takes longer which makes the tick count ms larger.
|
||||||
|
|
||||||
if (latertickcount < 100)
|
if (latertickcount < 100)
|
||||||
|
{
|
||||||
m_timeDilation = 1.0f;
|
m_timeDilation = 1.0f;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_timeDilation = 100f / latertickcount;
|
m_timeDilation = 100f / latertickcount;
|
||||||
|
@ -2939,12 +2920,12 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Simulate NINJA joints.
|
/// Simulate pending NINJA joints.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Called by the main Simulate() loop if NINJA joints are active. Should not be called from anywhere else.
|
/// Called by the main Simulate() loop if NINJA joints are active. Should not be called from anywhere else.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected void SimulateNINJAJoints()
|
protected void SimulatePendingNINJAJoints()
|
||||||
{
|
{
|
||||||
// Create pending joints, if possible
|
// Create pending joints, if possible
|
||||||
|
|
||||||
|
@ -3007,6 +2988,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allJointBodiesAreReady)
|
if (allJointBodiesAreReady)
|
||||||
{
|
{
|
||||||
//DoJointErrorMessage(joint, "allJointBodiesAreReady for " + joint.ObjectNameInScene + " with parms " + joint.RawParams);
|
//DoJointErrorMessage(joint, "allJointBodiesAreReady for " + joint.ObjectNameInScene + " with parms " + joint.RawParams);
|
||||||
|
@ -3126,6 +3108,32 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void SimulateActorPendingJoints(OdePrim actor)
|
||||||
|
{
|
||||||
|
// If an actor moved, move its joint proxy objects as well.
|
||||||
|
// There seems to be an event PhysicsActor.OnPositionUpdate that could be used
|
||||||
|
// for this purpose but it is never called! So we just do the joint
|
||||||
|
// movement code here.
|
||||||
|
|
||||||
|
if (actor.SOPName != null &&
|
||||||
|
joints_connecting_actor.ContainsKey(actor.SOPName) &&
|
||||||
|
joints_connecting_actor[actor.SOPName] != null &&
|
||||||
|
joints_connecting_actor[actor.SOPName].Count > 0)
|
||||||
|
{
|
||||||
|
foreach (PhysicsJoint affectedJoint in joints_connecting_actor[actor.SOPName])
|
||||||
|
{
|
||||||
|
if (affectedJoint.IsInPhysicsEngine)
|
||||||
|
{
|
||||||
|
DoJointMoved(affectedJoint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DoJointErrorMessage(affectedJoint, "a body connected to a joint was moved, but the joint doesn't exist yet! this will lead to joint error. joint was: " + affectedJoint.ObjectNameInScene + " parms:" + affectedJoint.RawParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void GetResults()
|
public override void GetResults()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue