aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-07-29 00:51:07 +0100
committerJustin Clark-Casey (justincc)2011-07-29 00:51:07 +0100
commit2a39d0cdb01dfbcc8d8838a80380dabfd9e468e1 (patch)
tree3805c641a4ee25f90c7d41350e8df00a7a8d7e75
parentrefactor: Simplify reading OdeScene.Simulate() loop by shunting all the NINJA... (diff)
downloadopensim-SC_OLD-2a39d0cdb01dfbcc8d8838a80380dabfd9e468e1.zip
opensim-SC_OLD-2a39d0cdb01dfbcc8d8838a80380dabfd9e468e1.tar.gz
opensim-SC_OLD-2a39d0cdb01dfbcc8d8838a80380dabfd9e468e1.tar.bz2
opensim-SC_OLD-2a39d0cdb01dfbcc8d8838a80380dabfd9e468e1.tar.xz
refactor: Move another chunk of ninja code out of the OdeScene.Simulate() loop for consistency and readability.
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs64
1 files changed, 36 insertions, 28 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index 9d41b15..c436fca 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -2738,7 +2738,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2738 } 2738 }
2739 2739
2740 if (SupportsNINJAJoints) 2740 if (SupportsNINJAJoints)
2741 SimulateNINJAJoints(); 2741 SimulatePendingNINJAJoints();
2742 2742
2743 if (processedtaints) 2743 if (processedtaints)
2744//Console.WriteLine("Simulate calls Clear of _taintedPrim list"); 2744//Console.WriteLine("Simulate calls Clear of _taintedPrim list");
@@ -2839,6 +2839,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2839 { 2839 {
2840 if (actor.bad) 2840 if (actor.bad)
2841 m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); 2841 m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
2842
2842 actor.UpdatePositionAndVelocity(); 2843 actor.UpdatePositionAndVelocity();
2843 } 2844 }
2844 } 2845 }
@@ -2852,6 +2853,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2852 { 2853 {
2853 RemoveCharacter(chr); 2854 RemoveCharacter(chr);
2854 } 2855 }
2856
2855 _badCharacter.Clear(); 2857 _badCharacter.Clear();
2856 } 2858 }
2857 } 2859 }
@@ -2867,30 +2869,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2867 actor.UpdatePositionAndVelocity(); 2869 actor.UpdatePositionAndVelocity();
2868 2870
2869 if (SupportsNINJAJoints) 2871 if (SupportsNINJAJoints)
2870 { 2872 SimulateActorPendingJoints(actor);
2871 // If an actor moved, move its joint proxy objects as well.
2872 // There seems to be an event PhysicsActor.OnPositionUpdate that could be used
2873 // for this purpose but it is never called! So we just do the joint
2874 // movement code here.
2875
2876 if (actor.SOPName != null &&
2877 joints_connecting_actor.ContainsKey(actor.SOPName) &&
2878 joints_connecting_actor[actor.SOPName] != null &&
2879 joints_connecting_actor[actor.SOPName].Count > 0)
2880 {
2881 foreach (PhysicsJoint affectedJoint in joints_connecting_actor[actor.SOPName])
2882 {
2883 if (affectedJoint.IsInPhysicsEngine)
2884 {
2885 DoJointMoved(affectedJoint);
2886 }
2887 else
2888 {
2889 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);
2890 }
2891 }
2892 }
2893 }
2894 } 2873 }
2895 } 2874 }
2896 } 2875 }
@@ -2901,7 +2880,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2901 // Finished with all sim stepping. If requested, dump world state to file for debugging. 2880 // Finished with all sim stepping. If requested, dump world state to file for debugging.
2902 // TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed? 2881 // TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed?
2903 // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots? 2882 // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots?
2904 if (physics_logging && (physics_logging_interval>0) && (framecount % physics_logging_interval == 0)) 2883 if (physics_logging && (physics_logging_interval > 0) && (framecount % physics_logging_interval == 0))
2905 { 2884 {
2906 string fname = "state-" + world.ToString() + ".DIF"; // give each physics world a separate filename 2885 string fname = "state-" + world.ToString() + ".DIF"; // give each physics world a separate filename
2907 string prefix = "world" + world.ToString(); // prefix for variable names in exported .DIF file 2886 string prefix = "world" + world.ToString(); // prefix for variable names in exported .DIF file
@@ -2925,7 +2904,9 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2925 // If Physics stalls, it takes longer which makes the tick count ms larger. 2904 // If Physics stalls, it takes longer which makes the tick count ms larger.
2926 2905
2927 if (latertickcount < 100) 2906 if (latertickcount < 100)
2907 {
2928 m_timeDilation = 1.0f; 2908 m_timeDilation = 1.0f;
2909 }
2929 else 2910 else
2930 { 2911 {
2931 m_timeDilation = 100f / latertickcount; 2912 m_timeDilation = 100f / latertickcount;
@@ -2939,12 +2920,12 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2939 } 2920 }
2940 2921
2941 /// <summary> 2922 /// <summary>
2942 /// Simulate NINJA joints. 2923 /// Simulate pending NINJA joints.
2943 /// </summary> 2924 /// </summary>
2944 /// <remarks> 2925 /// <remarks>
2945 /// Called by the main Simulate() loop if NINJA joints are active. Should not be called from anywhere else. 2926 /// Called by the main Simulate() loop if NINJA joints are active. Should not be called from anywhere else.
2946 /// </remarks> 2927 /// </remarks>
2947 protected void SimulateNINJAJoints() 2928 protected void SimulatePendingNINJAJoints()
2948 { 2929 {
2949 // Create pending joints, if possible 2930 // Create pending joints, if possible
2950 2931
@@ -3007,6 +2988,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
3007 } 2988 }
3008 } 2989 }
3009 } 2990 }
2991
3010 if (allJointBodiesAreReady) 2992 if (allJointBodiesAreReady)
3011 { 2993 {
3012 //DoJointErrorMessage(joint, "allJointBodiesAreReady for " + joint.ObjectNameInScene + " with parms " + joint.RawParams); 2994 //DoJointErrorMessage(joint, "allJointBodiesAreReady for " + joint.ObjectNameInScene + " with parms " + joint.RawParams);
@@ -3126,6 +3108,32 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
3126 } 3108 }
3127 } 3109 }
3128 3110
3111 protected void SimulateActorPendingJoints(OdePrim actor)
3112 {
3113 // If an actor moved, move its joint proxy objects as well.
3114 // There seems to be an event PhysicsActor.OnPositionUpdate that could be used
3115 // for this purpose but it is never called! So we just do the joint
3116 // movement code here.
3117
3118 if (actor.SOPName != null &&
3119 joints_connecting_actor.ContainsKey(actor.SOPName) &&
3120 joints_connecting_actor[actor.SOPName] != null &&
3121 joints_connecting_actor[actor.SOPName].Count > 0)
3122 {
3123 foreach (PhysicsJoint affectedJoint in joints_connecting_actor[actor.SOPName])
3124 {
3125 if (affectedJoint.IsInPhysicsEngine)
3126 {
3127 DoJointMoved(affectedJoint);
3128 }
3129 else
3130 {
3131 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);
3132 }
3133 }
3134 }
3135 }
3136
3129 public override void GetResults() 3137 public override void GetResults()
3130 { 3138 {
3131 } 3139 }