aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-11-22 21:51:00 +0000
committerJustin Clark-Casey (justincc)2011-11-22 21:51:00 +0000
commitdaf99f8c0ac874971c829b18a2372be1c4ee9541 (patch)
tree71268ae25d4ef8ad59612eeacb6db105addfe28f /OpenSim/Region/Physics/OdePlugin
parentImprove the error messages returned if the HelloNeighbour call fails. (diff)
downloadopensim-SC_OLD-daf99f8c0ac874971c829b18a2372be1c4ee9541.zip
opensim-SC_OLD-daf99f8c0ac874971c829b18a2372be1c4ee9541.tar.gz
opensim-SC_OLD-daf99f8c0ac874971c829b18a2372be1c4ee9541.tar.bz2
opensim-SC_OLD-daf99f8c0ac874971c829b18a2372be1c4ee9541.tar.xz
slightly simplify OdeScene.Simulate() by removing bool processtaints, since we can inspect count of taint lists instead.
also groups OdeCharacter.CreateOdeStructures() and DestroyOdeStructures() together
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs234
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs1
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdeScene.cs34
3 files changed, 128 insertions, 141 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index cfe64f2..489a23a 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -542,123 +542,6 @@ namespace OpenSim.Region.Physics.OdePlugin
542 } 542 }
543 543
544 /// <summary> 544 /// <summary>
545 /// This creates the Avatar's physical Surrogate in ODE at the position supplied
546 /// </summary>
547 /// <remarks>
548 /// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
549 /// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
550 /// place that is safe to call this routine AvatarGeomAndBodyCreation.
551 /// </remarks>
552 /// <param name="npositionX"></param>
553 /// <param name="npositionY"></param>
554 /// <param name="npositionZ"></param>
555 /// <param name="tensor"></param>
556 private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor)
557 {
558 int dAMotorEuler = 1;
559// _parent_scene.waitForSpaceUnlock(_parent_scene.space);
560 if (CAPSULE_LENGTH <= 0)
561 {
562 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
563 CAPSULE_LENGTH = 0.01f;
564 }
565
566 if (CAPSULE_RADIUS <= 0)
567 {
568 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
569 CAPSULE_RADIUS = 0.01f;
570 }
571
572 Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
573
574 d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
575 d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
576
577 d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
578 Body = d.BodyCreate(_parent_scene.world);
579 d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
580
581 _position.X = npositionX;
582 _position.Y = npositionY;
583 _position.Z = npositionZ;
584
585 m_taintPosition = _position;
586
587 d.BodySetMass(Body, ref ShellMass);
588 d.Matrix3 m_caprot;
589 // 90 Stand up on the cap of the capped cyllinder
590 if (_parent_scene.IsAvCapsuleTilted)
591 {
592 d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2));
593 }
594 else
595 {
596 d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
597 }
598
599 d.GeomSetRotation(Shell, ref m_caprot);
600 d.BodySetRotation(Body, ref m_caprot);
601
602 d.GeomSetBody(Shell, Body);
603
604 // The purpose of the AMotor here is to keep the avatar's physical
605 // surrogate from rotating while moving
606 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
607 d.JointAttach(Amotor, Body, IntPtr.Zero);
608 d.JointSetAMotorMode(Amotor, dAMotorEuler);
609 d.JointSetAMotorNumAxes(Amotor, 3);
610 d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0);
611 d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
612 d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
613 d.JointSetAMotorAngle(Amotor, 0, 0);
614 d.JointSetAMotorAngle(Amotor, 1, 0);
615 d.JointSetAMotorAngle(Amotor, 2, 0);
616
617 // These lowstops and high stops are effectively (no wiggle room)
618 if (_parent_scene.IsAvCapsuleTilted)
619 {
620 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f);
621 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f);
622 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f);
623 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f);
624 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
625 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
626 }
627 else
628 {
629 #region Documentation of capsule motor LowStop and HighStop parameters
630 // Intentionally introduce some tilt into the capsule by setting
631 // the motor stops to small epsilon values. This small tilt prevents
632 // the capsule from falling into the terrain; a straight-up capsule
633 // (with -0..0 motor stops) falls into the terrain for reasons yet
634 // to be comprehended in their entirety.
635 #endregion
636 AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
637 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
638 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
639 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
640 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.08f); // must be same as lowstop, else a different, spurious tilt is introduced
641 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop
642 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop
643 }
644
645 // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the
646 // capped cyllinder will fall over
647 d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
648 d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor);
649
650 //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
651 //d.QfromR(
652 //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068,
653 //
654 //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
655 //standupStraight();
656
657 _parent_scene.geom_name_map[Shell] = Name;
658 _parent_scene.actor_name_map[Shell] = this;
659 }
660
661 /// <summary>
662 /// Uses the capped cyllinder volume formula to calculate the avatar's mass. 545 /// Uses the capped cyllinder volume formula to calculate the avatar's mass.
663 /// This may be used in calculations in the scene/scenepresence 546 /// This may be used in calculations in the scene/scenepresence
664 /// </summary> 547 /// </summary>
@@ -1126,6 +1009,123 @@ namespace OpenSim.Region.Physics.OdePlugin
1126 } 1009 }
1127 1010
1128 /// <summary> 1011 /// <summary>
1012 /// This creates the Avatar's physical Surrogate in ODE at the position supplied
1013 /// </summary>
1014 /// <remarks>
1015 /// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
1016 /// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only
1017 /// place that is safe to call this routine AvatarGeomAndBodyCreation.
1018 /// </remarks>
1019 /// <param name="npositionX"></param>
1020 /// <param name="npositionY"></param>
1021 /// <param name="npositionZ"></param>
1022 /// <param name="tensor"></param>
1023 private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor)
1024 {
1025 int dAMotorEuler = 1;
1026// _parent_scene.waitForSpaceUnlock(_parent_scene.space);
1027 if (CAPSULE_LENGTH <= 0)
1028 {
1029 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
1030 CAPSULE_LENGTH = 0.01f;
1031 }
1032
1033 if (CAPSULE_RADIUS <= 0)
1034 {
1035 m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!");
1036 CAPSULE_RADIUS = 0.01f;
1037 }
1038
1039 Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
1040
1041 d.GeomSetCategoryBits(Shell, (int)m_collisionCategories);
1042 d.GeomSetCollideBits(Shell, (int)m_collisionFlags);
1043
1044 d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH);
1045 Body = d.BodyCreate(_parent_scene.world);
1046 d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
1047
1048 _position.X = npositionX;
1049 _position.Y = npositionY;
1050 _position.Z = npositionZ;
1051
1052 m_taintPosition = _position;
1053
1054 d.BodySetMass(Body, ref ShellMass);
1055 d.Matrix3 m_caprot;
1056 // 90 Stand up on the cap of the capped cyllinder
1057 if (_parent_scene.IsAvCapsuleTilted)
1058 {
1059 d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2));
1060 }
1061 else
1062 {
1063 d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2));
1064 }
1065
1066 d.GeomSetRotation(Shell, ref m_caprot);
1067 d.BodySetRotation(Body, ref m_caprot);
1068
1069 d.GeomSetBody(Shell, Body);
1070
1071 // The purpose of the AMotor here is to keep the avatar's physical
1072 // surrogate from rotating while moving
1073 Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero);
1074 d.JointAttach(Amotor, Body, IntPtr.Zero);
1075 d.JointSetAMotorMode(Amotor, dAMotorEuler);
1076 d.JointSetAMotorNumAxes(Amotor, 3);
1077 d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0);
1078 d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0);
1079 d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1);
1080 d.JointSetAMotorAngle(Amotor, 0, 0);
1081 d.JointSetAMotorAngle(Amotor, 1, 0);
1082 d.JointSetAMotorAngle(Amotor, 2, 0);
1083
1084 // These lowstops and high stops are effectively (no wiggle room)
1085 if (_parent_scene.IsAvCapsuleTilted)
1086 {
1087 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f);
1088 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f);
1089 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f);
1090 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f);
1091 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f);
1092 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f);
1093 }
1094 else
1095 {
1096 #region Documentation of capsule motor LowStop and HighStop parameters
1097 // Intentionally introduce some tilt into the capsule by setting
1098 // the motor stops to small epsilon values. This small tilt prevents
1099 // the capsule from falling into the terrain; a straight-up capsule
1100 // (with -0..0 motor stops) falls into the terrain for reasons yet
1101 // to be comprehended in their entirety.
1102 #endregion
1103 AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
1104 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
1105 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
1106 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
1107 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.08f); // must be same as lowstop, else a different, spurious tilt is introduced
1108 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop
1109 d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop
1110 }
1111
1112 // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the
1113 // capped cyllinder will fall over
1114 d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
1115 d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor);
1116
1117 //d.Matrix3 bodyrotation = d.BodyGetRotation(Body);
1118 //d.QfromR(
1119 //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068,
1120 //
1121 //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
1122 //standupStraight();
1123
1124 _parent_scene.geom_name_map[Shell] = Name;
1125 _parent_scene.actor_name_map[Shell] = this;
1126 }
1127
1128 /// <summary>
1129 /// Cleanup the things we use in the scene. 1129 /// Cleanup the things we use in the scene.
1130 /// </summary> 1130 /// </summary>
1131 internal void Destroy() 1131 internal void Destroy()
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index fec4693..94e6185 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -272,7 +272,6 @@ namespace OpenSim.Region.Physics.OdePlugin
272 272
273 m_taintadd = true; 273 m_taintadd = true;
274 _parent_scene.AddPhysicsActorTaint(this); 274 _parent_scene.AddPhysicsActorTaint(this);
275 // don't do .add() here; old geoms get recycled with the same hash
276 } 275 }
277 276
278 public override int PhysicsActorType 277 public override int PhysicsActorType
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
index e219535..72e9ca0 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs
@@ -2160,7 +2160,6 @@ namespace OpenSim.Region.Physics.OdePlugin
2160 2160
2161 p.setPrimForRemoval(); 2161 p.setPrimForRemoval();
2162 AddPhysicsActorTaint(prim); 2162 AddPhysicsActorTaint(prim);
2163 //RemovePrimThreadLocked(p);
2164 } 2163 }
2165 } 2164 }
2166 } 2165 }
@@ -2607,15 +2606,17 @@ namespace OpenSim.Region.Physics.OdePlugin
2607 2606
2608 /// <summary> 2607 /// <summary>
2609 /// Called after our prim properties are set Scale, position etc. 2608 /// Called after our prim properties are set Scale, position etc.
2609 /// </summary>
2610 /// <remarks>
2610 /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex 2611 /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex
2611 /// This assures us that we have no race conditions 2612 /// This assures us that we have no race conditions
2612 /// </summary> 2613 /// </remarks>
2613 /// <param name="prim"></param> 2614 /// <param name="actor"></param>
2614 public override void AddPhysicsActorTaint(PhysicsActor prim) 2615 public override void AddPhysicsActorTaint(PhysicsActor actor)
2615 { 2616 {
2616 if (prim is OdePrim) 2617 if (actor is OdePrim)
2617 { 2618 {
2618 OdePrim taintedprim = ((OdePrim) prim); 2619 OdePrim taintedprim = ((OdePrim)actor);
2619 lock (_taintedPrimLock) 2620 lock (_taintedPrimLock)
2620 { 2621 {
2621 if (!(_taintedPrimH.Contains(taintedprim))) 2622 if (!(_taintedPrimH.Contains(taintedprim)))
@@ -2627,11 +2628,10 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2627 _taintedPrimL.Add(taintedprim); // List for ordered readout 2628 _taintedPrimL.Add(taintedprim); // List for ordered readout
2628 } 2629 }
2629 } 2630 }
2630 return;
2631 } 2631 }
2632 else if (prim is OdeCharacter) 2632 else if (actor is OdeCharacter)
2633 { 2633 {
2634 OdeCharacter taintedchar = ((OdeCharacter)prim); 2634 OdeCharacter taintedchar = ((OdeCharacter)actor);
2635 lock (_taintedActors) 2635 lock (_taintedActors)
2636 { 2636 {
2637 if (!(_taintedActors.Contains(taintedchar))) 2637 if (!(_taintedActors.Contains(taintedchar)))
@@ -2734,29 +2734,18 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2734 { 2734 {
2735 try 2735 try
2736 { 2736 {
2737 // Insert, remove Characters
2738 bool processedtaints = false;
2739
2740 lock (_taintedActors) 2737 lock (_taintedActors)
2741 { 2738 {
2742 if (_taintedActors.Count > 0) 2739 if (_taintedActors.Count > 0)
2743 { 2740 {
2744 foreach (OdeCharacter character in _taintedActors) 2741 foreach (OdeCharacter character in _taintedActors)
2745 {
2746 character.ProcessTaints(); 2742 character.ProcessTaints();
2747 2743
2748 processedtaints = true; 2744 if (_taintedActors.Count > 0)
2749 //character.m_collisionscore = 0;
2750 }
2751
2752 if (processedtaints)
2753 _taintedActors.Clear(); 2745 _taintedActors.Clear();
2754 } 2746 }
2755 } 2747 }
2756 2748
2757 // Modify other objects in the scene.
2758 processedtaints = false;
2759
2760 lock (_taintedPrimLock) 2749 lock (_taintedPrimLock)
2761 { 2750 {
2762 foreach (OdePrim prim in _taintedPrimL) 2751 foreach (OdePrim prim in _taintedPrimL)
@@ -2772,7 +2761,6 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2772 prim.ProcessTaints(); 2761 prim.ProcessTaints();
2773 } 2762 }
2774 2763
2775 processedtaints = true;
2776 prim.m_collisionscore = 0; 2764 prim.m_collisionscore = 0;
2777 2765
2778 // This loop can block up the Heartbeat for a very long time on large regions. 2766 // This loop can block up the Heartbeat for a very long time on large regions.
@@ -2785,7 +2773,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
2785 if (SupportsNINJAJoints) 2773 if (SupportsNINJAJoints)
2786 SimulatePendingNINJAJoints(); 2774 SimulatePendingNINJAJoints();
2787 2775
2788 if (processedtaints) 2776 if (_taintedPrimL.Count > 0)
2789 { 2777 {
2790//Console.WriteLine("Simulate calls Clear of _taintedPrim list"); 2778//Console.WriteLine("Simulate calls Clear of _taintedPrim list");
2791 _taintedPrimH.Clear(); 2779 _taintedPrimH.Clear();