aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorTeravus Ovares2008-03-03 16:52:25 +0000
committerTeravus Ovares2008-03-03 16:52:25 +0000
commitd01535690254a347939bc8946d8c10e78a8ea577 (patch)
tree638cae76c554d79425bcef4f64c1c96cfb2b4eb3 /OpenSim/Region/Physics
parent* More compiler warning nukage. (diff)
downloadopensim-SC_OLD-d01535690254a347939bc8946d8c10e78a8ea577.zip
opensim-SC_OLD-d01535690254a347939bc8946d8c10e78a8ea577.tar.gz
opensim-SC_OLD-d01535690254a347939bc8946d8c10e78a8ea577.tar.bz2
opensim-SC_OLD-d01535690254a347939bc8946d8c10e78a8ea577.tar.xz
* Applied patch 708 from devalnor. Thanks devalnor!
* ODE: Added support for larger box stacks. (they're slow, but they work) * ODEPlugin no longer tries to 'catch up' with the simulator frame rate if it gets behind. Catching up was causing a lot of problems with larger box stacks and other things that stall the simulator (like saving prim in the datastore)
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs25
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs149
2 files changed, 93 insertions, 81 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index eb90cf4..726f2e9 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -617,20 +617,23 @@ namespace OpenSim.Region.Physics.OdePlugin
617 public void disableBody() 617 public void disableBody()
618 { 618 {
619 //this kills the body so things like 'mesh' can re-create it. 619 //this kills the body so things like 'mesh' can re-create it.
620 if (Body != (IntPtr) 0) 620 lock (this)
621 { 621 {
622 m_collisionCategories &= ~CollisionCategories.Body; 622 if (Body != (IntPtr)0)
623 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
624
625 if (prim_geom != (IntPtr)0)
626 { 623 {
627 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); 624 m_collisionCategories &= ~CollisionCategories.Body;
628 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 625 m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land);
629 }
630 626
631 _parent_scene.remActivePrim(this); 627 if (prim_geom != (IntPtr)0)
632 d.BodyDestroy(Body); 628 {
633 Body = (IntPtr) 0; 629 d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories);
630 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
631 }
632
633 _parent_scene.remActivePrim(this);
634 d.BodyDestroy(Body);
635 Body = (IntPtr)0;
636 }
634 } 637 }
635 m_disabled = true; 638 m_disabled = true;
636 m_collisionscore = 0; 639 m_collisionscore = 0;
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 76bd3f2..563bf44 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -661,7 +661,9 @@ namespace OpenSim.Region.Physics.OdePlugin
661 { 661 {
662 try 662 try
663 { 663 {
664 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback); 664
665 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback);
666
665 } 667 }
666 catch (AccessViolationException) 668 catch (AccessViolationException)
667 { 669 {
@@ -685,7 +687,10 @@ namespace OpenSim.Region.Physics.OdePlugin
685 } 687 }
686 try 688 try
687 { 689 {
688 d.SpaceCollide2(LandGeom, chr.prim_geom, IntPtr.Zero, nearCallback); 690 lock (chr)
691 {
692 d.SpaceCollide2(LandGeom, chr.prim_geom, IntPtr.Zero, nearCallback);
693 }
689 } 694 }
690 catch (AccessViolationException) 695 catch (AccessViolationException)
691 { 696 {
@@ -759,90 +764,93 @@ namespace OpenSim.Region.Physics.OdePlugin
759 /// <param name="prim"></param> 764 /// <param name="prim"></param>
760 public void RemovePrimThreadLocked(OdePrim prim) 765 public void RemovePrimThreadLocked(OdePrim prim)
761 { 766 {
762 lock (ode) 767 lock (prim)
763 { 768 {
764 if (prim.prim_geom != (IntPtr)0) 769 lock (ode)
765 { 770 {
766 while (ode.lockquery()) 771 if (prim.prim_geom != (IntPtr)0)
767 { 772 {
768 } 773 while (ode.lockquery())
769 ode.dlock(world); 774 {
770 //System.Threading.Thread.Sleep(20); 775 }
771 prim.ResetTaints(); 776 ode.dlock(world);
772 777 //System.Threading.Thread.Sleep(20);
778 prim.ResetTaints();
773 779
774 if (prim.IsPhysical)
775 {
776 prim.disableBody();
777 }
778 // we don't want to remove the main space
779
780 // If the geometry is in the targetspace, remove it from the target space
781 //m_log.Warn(prim.m_targetSpace);
782 780
783 //if (prim.m_targetSpace != (IntPtr)0) 781 if (prim.IsPhysical)
784 //{
785 if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
786 { 782 {
783 prim.disableBody();
784 }
785 // we don't want to remove the main space
786
787 // If the geometry is in the targetspace, remove it from the target space
788 //m_log.Warn(prim.m_targetSpace);
789
790 //if (prim.m_targetSpace != (IntPtr)0)
791 //{
792 //if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
793 //{
794
795 //if (d.GeomIsSpace(prim.m_targetSpace))
796 //{
797 //waitForSpaceUnlock(prim.m_targetSpace);
798 //d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
799 prim.m_targetSpace = (IntPtr)0;
800 //}
801 //else
802 //{
803 // m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
804 //((OdePrim)prim).m_targetSpace.ToString());
805 //}
787 806
788 if (d.GeomIsSpace(prim.m_targetSpace)) 807 //}
808 //}
809 //m_log.Warn(prim.prim_geom);
810 try
811 {
812 if (prim.prim_geom != (IntPtr)0)
789 { 813 {
790 waitForSpaceUnlock(prim.m_targetSpace); 814 d.GeomDestroy(prim.prim_geom);
791 d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); 815 prim.prim_geom = (IntPtr)0;
792 prim.m_targetSpace = (IntPtr) 0;
793 } 816 }
794 else 817 else
795 { 818 {
796 m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + 819 m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene");
797 ((OdePrim)prim).m_targetSpace.ToString());
798 } 820 }
799 821
800 } 822 }
801 //} 823 catch (System.AccessViolationException)
802 //m_log.Warn(prim.prim_geom);
803 try
804 {
805 if (prim.prim_geom != (IntPtr)0)
806 { 824 {
807 d.GeomDestroy(prim.prim_geom); 825 m_log.Info("[PHYSICS]: Couldn't remove prim from physics scene, it was already be removed.");
808 prim.prim_geom = (IntPtr)0;
809 }
810 else
811 {
812 m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene");
813 } 826 }
827 _prims.Remove(prim);
814 828
829 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
830 //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
831 //{
832 //if (!(prim.m_targetSpace.Equals(null)))
833 //{
834 //if (d.GeomIsSpace(prim.m_targetSpace))
835 //{
836 //waitForSpaceUnlock(prim.m_targetSpace);
837 //d.SpaceRemove(space, prim.m_targetSpace);
838 // free up memory used by the space.
839 //d.SpaceDestroy(prim.m_targetSpace);
840 //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position);
841 //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]);
842 //}
843 //else
844 //{
845 //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
846 //((OdePrim) prim).m_targetSpace.ToString());
847 //}
848 //}
849 //}
815 } 850 }
816 catch (System.AccessViolationException)
817 {
818 m_log.Info("[PHYSICS]: Couldn't remove prim from physics scene, it was already be removed.");
819 }
820 _prims.Remove(prim);
821
822 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
823 //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
824 //{
825 //if (!(prim.m_targetSpace.Equals(null)))
826 //{
827 //if (d.GeomIsSpace(prim.m_targetSpace))
828 //{
829 //waitForSpaceUnlock(prim.m_targetSpace);
830 //d.SpaceRemove(space, prim.m_targetSpace);
831 // free up memory used by the space.
832 //d.SpaceDestroy(prim.m_targetSpace);
833 //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position);
834 //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]);
835 //}
836 //else
837 //{
838 //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
839 //((OdePrim) prim).m_targetSpace.ToString());
840 //}
841 //}
842 //}
843 }
844 851
845 ode.dunlock(world); 852 ode.dunlock(world);
853 }
846 } 854 }
847 } 855 }
848 856
@@ -934,7 +942,7 @@ namespace OpenSim.Region.Physics.OdePlugin
934 d.SpaceRemove(space, currentspace); 942 d.SpaceRemove(space, currentspace);
935 // free up memory used by the space. 943 // free up memory used by the space.
936 944
937 d.SpaceDestroy(currentspace); 945 //d.SpaceDestroy(currentspace);
938 resetSpaceArrayItemToZero(currentspace); 946 resetSpaceArrayItemToZero(currentspace);
939 } 947 }
940 else 948 else
@@ -1236,7 +1244,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1236 public override float Simulate(float timeStep) 1244 public override float Simulate(float timeStep)
1237 { 1245 {
1238 float fps = 0; 1246 float fps = 0;
1239 1247 //m_log.Info(timeStep.ToString());
1240 step_time += timeStep; 1248 step_time += timeStep;
1241 1249
1242 1250
@@ -1275,8 +1283,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1275 1283
1276 // Figure out the Frames Per Second we're going at. 1284 // Figure out the Frames Per Second we're going at.
1277 //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size 1285 //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size
1286 step_time = 0.09375f;
1278 fps = (step_time/ODE_STEPSIZE) * 1000; 1287 fps = (step_time/ODE_STEPSIZE) * 1000;
1279 1288
1280 while (step_time > 0.0f) 1289 while (step_time > 0.0f)
1281 { 1290 {
1282 lock (ode) 1291 lock (ode)