aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-02-14 09:31:22 +0000
committerTeravus Ovares2008-02-14 09:31:22 +0000
commitbd880f917812280eb90af51b3f1e74e3a6ba457b (patch)
tree2794440d87cf6edfb6dbb53aa9a50156e185d15b /OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
parentUpdate svn properties from a bar ftw. Kanpai! (diff)
downloadopensim-SC_OLD-bd880f917812280eb90af51b3f1e74e3a6ba457b.zip
opensim-SC_OLD-bd880f917812280eb90af51b3f1e74e3a6ba457b.tar.gz
opensim-SC_OLD-bd880f917812280eb90af51b3f1e74e3a6ba457b.tar.bz2
opensim-SC_OLD-bd880f917812280eb90af51b3f1e74e3a6ba457b.tar.xz
* Another ODE Stability update. This might fix the recent Linux issues with the ODEPlugin.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs129
1 files changed, 75 insertions, 54 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index f934341..9392192 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -596,7 +596,7 @@ namespace OpenSim.Region.Physics.OdePlugin
596 /// <param name="timeStep"></param> 596 /// <param name="timeStep"></param>
597 private void collision_optimized(float timeStep) 597 private void collision_optimized(float timeStep)
598 { 598 {
599 starttiming(); 599
600 foreach (OdeCharacter chr in _characters) 600 foreach (OdeCharacter chr in _characters)
601 { 601 {
602 // Reset the collision values to false 602 // Reset the collision values to false
@@ -626,7 +626,7 @@ namespace OpenSim.Region.Physics.OdePlugin
626 //forcedZ = true; 626 //forcedZ = true;
627 //} 627 //}
628 } 628 }
629 int avms = stoptiming(); 629
630 630
631 // If the sim is running slow this frame, 631 // If the sim is running slow this frame,
632 // don't process collision for prim! 632 // don't process collision for prim!
@@ -719,8 +719,9 @@ namespace OpenSim.Region.Physics.OdePlugin
719 { 719 {
720 OdePrim p = (OdePrim) prim; 720 OdePrim p = (OdePrim) prim;
721 721
722 p.setPrimForRemoval(); 722 //p.setPrimForRemoval();
723 AddPhysicsActorTaint(prim); 723 //AddPhysicsActorTaint(prim);
724 RemovePrimThreadLocked(p);
724 } 725 }
725 } 726 }
726 } 727 }
@@ -736,10 +737,14 @@ namespace OpenSim.Region.Physics.OdePlugin
736 /// <param name="prim"></param> 737 /// <param name="prim"></param>
737 public void RemovePrimThreadLocked(OdePrim prim) 738 public void RemovePrimThreadLocked(OdePrim prim)
738 { 739 {
739 prim.ResetTaints(); 740 while (ode.lockquery())
740 lock (OdeLock)
741 { 741 {
742 System.Threading.Thread.Sleep(20); 742 }
743 ode.dlock(world);
744 //System.Threading.Thread.Sleep(20);
745 prim.ResetTaints();
746
747
743 if (prim.IsPhysical) 748 if (prim.IsPhysical)
744 { 749 {
745 prim.disableBody(); 750 prim.disableBody();
@@ -748,27 +753,38 @@ namespace OpenSim.Region.Physics.OdePlugin
748 if (prim.m_targetSpace != space && prim.IsPhysical == false) 753 if (prim.m_targetSpace != space && prim.IsPhysical == false)
749 { 754 {
750 // If the geometry is in the targetspace, remove it from the target space 755 // If the geometry is in the targetspace, remove it from the target space
751 if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom)) 756 //m_log.Warn(prim.m_targetSpace);
757 if (prim.prim_geom == (IntPtr)0)
758 prim.prim_geom = prim.prev_geom;
759
760 if (prim.m_targetSpace != (IntPtr)0)
752 { 761 {
753 if (!(prim.m_targetSpace.Equals(null))) 762 if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
754 { 763 {
755 764
756 if (d.GeomIsSpace(prim.m_targetSpace)) 765 if (d.GeomIsSpace(prim.m_targetSpace))
757 { 766 {
758 waitForSpaceUnlock(prim.m_targetSpace); 767 waitForSpaceUnlock(prim.m_targetSpace);
759 d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); 768 d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
769 prim.m_targetSpace = space;
760 } 770 }
761 else 771 else
762 { 772 {
763 m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + 773 m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
764 ((OdePrim) prim).m_targetSpace.ToString()); 774 ((OdePrim)prim).m_targetSpace.ToString());
765 } 775 }
776
766 } 777 }
767 } 778 }
779 m_log.Warn(prim.prim_geom);
768 try 780 try
769 { 781 {
770 782 if (prim.prim_geom != (IntPtr)0)
771 d.GeomDestroy(prim.prim_geom); 783 {
784 d.GeomDestroy(prim.prim_geom);
785 prim.prim_geom = (IntPtr) 0;
786 }
787
772 } 788 }
773 catch (System.AccessViolationException) 789 catch (System.AccessViolationException)
774 { 790 {
@@ -777,30 +793,31 @@ namespace OpenSim.Region.Physics.OdePlugin
777 _prims.Remove(prim); 793 _prims.Remove(prim);
778 794
779 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 795 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
780 if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0) 796 //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
781 { 797 //{
782 if (!(prim.m_targetSpace.Equals(null))) 798 //if (!(prim.m_targetSpace.Equals(null)))
783 { 799 //{
784 if (d.GeomIsSpace(prim.m_targetSpace)) 800 //if (d.GeomIsSpace(prim.m_targetSpace))
785 { 801 //{
786 waitForSpaceUnlock(prim.m_targetSpace); 802 //waitForSpaceUnlock(prim.m_targetSpace);
787 d.SpaceRemove(space, prim.m_targetSpace); 803 //d.SpaceRemove(space, prim.m_targetSpace);
788 // free up memory used by the space. 804 // free up memory used by the space.
789 d.SpaceDestroy(prim.m_targetSpace); 805 //d.SpaceDestroy(prim.m_targetSpace);
790 int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position); 806 //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position);
791 resetSpaceArrayItemToZero(xyspace[0], xyspace[1]); 807 //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]);
792 } 808 //}
793 else 809 //else
794 { 810 //{
795 m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + 811 //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
796 ((OdePrim) prim).m_targetSpace.ToString()); 812 //((OdePrim) prim).m_targetSpace.ToString());
797 } 813 //}
798 } 814 //}
799 } 815 //}
800 } 816 }
801 817
802 818
803 } 819
820 ode.dunlock(world);
804 } 821 }
805 /// <summary> 822 /// <summary>
806 /// Takes a space pointer and zeros out the array we're using to hold the spaces 823 /// Takes a space pointer and zeros out the array we're using to hold the spaces
@@ -905,9 +922,11 @@ namespace OpenSim.Region.Physics.OdePlugin
905 else 922 else
906 { 923 {
907 // this is a physical object that got disabled. ;.; 924 // this is a physical object that got disabled. ;.;
908 if (d.SpaceQuery(currentspace, geom)) 925 if (currentspace != (IntPtr)0 && geom != (IntPtr)0)
909 { 926 {
910 if (currentspace != (IntPtr) 0) 927 if (d.SpaceQuery(currentspace, geom))
928 {
929
911 if (d.GeomIsSpace(currentspace)) 930 if (d.GeomIsSpace(currentspace))
912 { 931 {
913 waitForSpaceUnlock(currentspace); 932 waitForSpaceUnlock(currentspace);
@@ -918,23 +937,24 @@ namespace OpenSim.Region.Physics.OdePlugin
918 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + 937 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
919 currentspace.ToString() + " Geom:" + geom.ToString()); 938 currentspace.ToString() + " Geom:" + geom.ToString());
920 } 939 }
921 } 940 }
922 else 941 else
923 {
924 IntPtr sGeomIsIn = d.GeomGetSpace(geom);
925 if (!(sGeomIsIn.Equals(null)))
926 { 942 {
927 if (sGeomIsIn != (IntPtr) 0) 943 IntPtr sGeomIsIn = d.GeomGetSpace(geom);
944 if (!(sGeomIsIn.Equals(null)))
928 { 945 {
929 if (d.GeomIsSpace(sGeomIsIn)) 946 if (sGeomIsIn != (IntPtr)0)
930 { 947 {
931 waitForSpaceUnlock(sGeomIsIn); 948 if (d.GeomIsSpace(sGeomIsIn))
932 d.SpaceRemove(sGeomIsIn, geom); 949 {
933 } 950 waitForSpaceUnlock(sGeomIsIn);
934 else 951 d.SpaceRemove(sGeomIsIn, geom);
935 { 952 }
936 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + 953 else
937 sGeomIsIn.ToString() + " Geom:" + geom.ToString()); 954 {
955 m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" +
956 sGeomIsIn.ToString() + " Geom:" + geom.ToString());
957 }
938 } 958 }
939 } 959 }
940 } 960 }
@@ -1041,6 +1061,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1041 1061
1042 _prims.Add(newPrim); 1062 _prims.Add(newPrim);
1043 } 1063 }
1064
1044 1065
1045 return newPrim; 1066 return newPrim;
1046 } 1067 }
@@ -1268,10 +1289,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1268 bool processedtaints = false; 1289 bool processedtaints = false;
1269 foreach (OdePrim prim in _taintedPrim) 1290 foreach (OdePrim prim in _taintedPrim)
1270 { 1291 {
1271 if (prim.m_taintremove) 1292 //if (prim.m_taintremove)
1272 { 1293 //{
1273 RemovePrimThreadLocked(prim); 1294 //RemovePrimThreadLocked(prim);
1274 } 1295 //}
1275 1296
1276 prim.ProcessTaints(timeStep); 1297 prim.ProcessTaints(timeStep);
1277 1298