aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs17
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs41
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs5
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs9
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs160
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs178
6 files changed, 280 insertions, 130 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 708da15..d8cb11c 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -737,12 +737,27 @@ namespace OpenSim.Region.Environment.Scenes
737 m_statsReporter.addOtherMS(otherMS); 737 m_statsReporter.addOtherMS(otherMS);
738 m_statsReporter.SetActiveScripts(m_innerScene.GetActiveScripts()); 738 m_statsReporter.SetActiveScripts(m_innerScene.GetActiveScripts());
739 m_statsReporter.addScriptLines(m_innerScene.GetScriptLPS()); 739 m_statsReporter.addScriptLines(m_innerScene.GetScriptLPS());
740 740
741 } 741 }
742 catch (NotImplementedException) 742 catch (NotImplementedException)
743 { 743 {
744 throw; 744 throw;
745 } 745 }
746 catch (System.AccessViolationException e)
747 {
748 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
749
750 }
751 catch (System.NullReferenceException e)
752 {
753 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
754
755 }
756 catch (System.InvalidOperationException e)
757 {
758 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
759
760 }
746 catch (Exception e) 761 catch (Exception e)
747 { 762 {
748 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); 763 m_log.Error("[Scene]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName);
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index e8d4766..519858b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -1265,23 +1265,11 @@ namespace OpenSim.Region.Environment.Scenes
1265 if (part != null) 1265 if (part != null)
1266 { 1266 {
1267 part.UpdateShape(shapeBlock); 1267 part.UpdateShape(shapeBlock);
1268 }
1269 if (m_rootPart.PhysActor != null)
1270 {
1271 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor);
1272 m_rootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape(
1273 m_rootPart.Name,
1274 m_rootPart.Shape,
1275 new PhysicsVector(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y,
1276 m_rootPart.AbsolutePosition.Z),
1277 new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z),
1278 new Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X,
1279 m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z),
1280 m_rootPart.PhysActor.IsPhysical);
1281 bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0);
1282 m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
1283 1268
1269 if (part.PhysActor != null)
1270 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
1284 } 1271 }
1272
1285 } 1273 }
1286 1274
1287 #endregion 1275 #endregion
@@ -1299,15 +1287,24 @@ namespace OpenSim.Region.Environment.Scenes
1299 if (part != null) 1287 if (part != null)
1300 { 1288 {
1301 part.Resize(scale); 1289 part.Resize(scale);
1302 if (part.UUID == m_rootPart.UUID) 1290 if (part.PhysActor != null)
1303 { 1291 {
1304 if (m_rootPart.PhysActor != null) 1292 part.PhysActor.Size =
1305 { 1293 new PhysicsVector(scale.X, scale.Y, scale.Z);
1306 m_rootPart.PhysActor.Size = 1294 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
1307 new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z);
1308 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
1309 }
1310 } 1295 }
1296 if (part.UUID != m_rootPart.UUID)
1297 ScheduleGroupForFullUpdate();
1298
1299 //if (part.UUID == m_rootPart.UUID)
1300 //{
1301 //if (m_rootPart.PhysActor != null)
1302 //{
1303 //m_rootPart.PhysActor.Size =
1304 //new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z);
1305 //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
1306 //}
1307 //}
1311 } 1308 }
1312 } 1309 }
1313 1310
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 1d5dd5b..5756a0b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -1182,6 +1182,10 @@ namespace OpenSim.Region.Environment.Scenes
1182 m_shape.PathTaperY = shapeBlock.PathTaperY; 1182 m_shape.PathTaperY = shapeBlock.PathTaperY;
1183 m_shape.PathTwist = shapeBlock.PathTwist; 1183 m_shape.PathTwist = shapeBlock.PathTwist;
1184 m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; 1184 m_shape.PathTwistBegin = shapeBlock.PathTwistBegin;
1185 if (PhysActor != null)
1186 {
1187 PhysActor.Shape = m_shape;
1188 }
1185 ScheduleFullUpdate(); 1189 ScheduleFullUpdate();
1186 } 1190 }
1187 1191
@@ -1583,6 +1587,7 @@ namespace OpenSim.Region.Environment.Scenes
1583 public void Resize(LLVector3 scale) 1587 public void Resize(LLVector3 scale)
1584 { 1588 {
1585 m_shape.Scale = scale; 1589 m_shape.Scale = scale;
1590
1586 ScheduleFullUpdate(); 1591 ScheduleFullUpdate();
1587 } 1592 }
1588 1593
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index a6acdeb..6b8d0e2 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -508,7 +508,12 @@ namespace OpenSim.Region.Physics.OdePlugin
508 508
509 public override PhysicsVector Velocity 509 public override PhysicsVector Velocity
510 { 510 {
511 get { return _velocity; } 511 get {
512 if (_zeroFlag)
513 return PhysicsVector.Zero;
514 m_lastUpdateSent = false;
515 return _velocity;
516 }
512 set 517 set
513 { 518 {
514 m_pidControllerActive = true; 519 m_pidControllerActive = true;
@@ -612,7 +617,7 @@ namespace OpenSim.Region.Physics.OdePlugin
612 _zeroPosition = d.BodyGetPosition(Body); 617 _zeroPosition = d.BodyGetPosition(Body);
613 } 618 }
614 //PidStatus = true; 619 //PidStatus = true;
615 620
616 PhysicsVector vec = new PhysicsVector(); 621 PhysicsVector vec = new PhysicsVector();
617 d.Vector3 vel = d.BodyGetLinearVel(Body); 622 d.Vector3 vel = d.BodyGetLinearVel(Body);
618 float movementdivisor = 1f; 623 float movementdivisor = 1f;
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 59c1f87..fae5316 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -682,6 +682,11 @@ namespace OpenSim.Region.Physics.OdePlugin
682 682
683 public void changePhysicsStatus(float timestap) 683 public void changePhysicsStatus(float timestap)
684 { 684 {
685 while (ode.lockquery())
686 {
687 }
688 ode.dlock(_parent_scene.world);
689
685 if (m_isphysical == true) 690 if (m_isphysical == true)
686 { 691 {
687 if (Body == (IntPtr) 0) 692 if (Body == (IntPtr) 0)
@@ -696,6 +701,9 @@ namespace OpenSim.Region.Physics.OdePlugin
696 disableBody(); 701 disableBody();
697 } 702 }
698 } 703 }
704
705 ode.dunlock(_parent_scene.world);
706
699 resetCollisionAccounting(); 707 resetCollisionAccounting();
700 m_taintPhysics = m_isphysical; 708 m_taintPhysics = m_isphysical;
701 } 709 }
@@ -730,7 +738,7 @@ namespace OpenSim.Region.Physics.OdePlugin
730 d.SpaceRemove(m_targetSpace, prim_geom); 738 d.SpaceRemove(m_targetSpace, prim_geom);
731 } 739 }
732 d.GeomDestroy(prim_geom); 740 d.GeomDestroy(prim_geom);
733 741 prim_geom = (IntPtr)0;
734 // we don't need to do space calculation because the client sends a position update also. 742 // we don't need to do space calculation because the client sends a position update also.
735 743
736 // Construction of new prim 744 // Construction of new prim
@@ -742,6 +750,23 @@ namespace OpenSim.Region.Physics.OdePlugin
742 if (mesh != null) 750 if (mesh != null)
743 { 751 {
744 setMesh(_parent_scene, mesh); 752 setMesh(_parent_scene, mesh);
753 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
754 d.Quaternion myrot = new d.Quaternion();
755 myrot.W = _orientation.w;
756 myrot.X = _orientation.x;
757 myrot.Y = _orientation.y;
758 myrot.Z = _orientation.z;
759 d.GeomSetQuaternion(prim_geom, ref myrot);
760
761
762 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
763 if (IsPhysical && Body == (IntPtr)0)
764 {
765 // Re creates body on size.
766 // EnableBody also does setMass()
767 enableBody();
768 d.BodyEnable(Body);
769 }
745 } 770 }
746 else 771 else
747 { 772 {
@@ -870,37 +895,120 @@ namespace OpenSim.Region.Physics.OdePlugin
870 disableBody(); 895 disableBody();
871 } 896 }
872 d.GeomDestroy(prim_geom); 897 d.GeomDestroy(prim_geom);
873 if (_mesh != null) 898 prim_geom = (IntPtr) 0;
874 { 899 // we don't need to do space calculation because the client sends a position update also.
875 d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
876 }
877 900
878 // Construction of new prim 901 // Construction of new prim
879 if (_parent_scene.needsMeshing(_pbs)) 902 if (_parent_scene.needsMeshing(_pbs))
880 { 903 {
904 // Don't need to re-enable body.. it's done in SetMesh
881 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); 905 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size);
906 // createmesh returns null when it's a shape that isn't a cube.
882 if (mesh != null) 907 if (mesh != null)
883 { 908 {
884 setMesh(_parent_scene, mesh); 909 setMesh(_parent_scene, mesh);
910 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
911 d.Quaternion myrot = new d.Quaternion();
912 myrot.W = _orientation.w;
913 myrot.X = _orientation.x;
914 myrot.Y = _orientation.y;
915 myrot.Z = _orientation.z;
916 d.GeomSetQuaternion(prim_geom, ref myrot);
917
918
919 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
920 if (IsPhysical && Body == (IntPtr)0)
921 {
922 // Re creates body on size.
923 // EnableBody also does setMass()
924 enableBody();
925 d.BodyEnable(Body);
926 }
885 } 927 }
886 else 928 else
887 { 929 {
888 _parent_scene.waitForSpaceUnlock(m_targetSpace); 930 if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1)
889 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 931 {
932 if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z)
933 {
934 if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000))
935 {
936 _parent_scene.waitForSpaceUnlock(m_targetSpace);
937 SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2));
938 }
939 else
940 {
941 m_log.Info("[PHYSICS]: Failed to load a sphere bad size");
942 _parent_scene.waitForSpaceUnlock(m_targetSpace);
943 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
944 }
945
946 }
947 else
948 {
949 _parent_scene.waitForSpaceUnlock(m_targetSpace);
950 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
951 }
952 }
953 //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight)
954 //{
955 //Cyllinder
956 //if (_size.X == _size.Y)
957 //{
958 // prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z);
959 //}
960 //else
961 //{
962 //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
963 //}
964 //}
965 else
966 {
967 _parent_scene.waitForSpaceUnlock(m_targetSpace);
968 SetGeom(prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
969 }
970 //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
971 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
972 d.Quaternion myrot = new d.Quaternion();
973 myrot.W = _orientation.w;
974 myrot.X = _orientation.x;
975 myrot.Y = _orientation.y;
976 myrot.Z = _orientation.z;
977 d.GeomSetQuaternion(prim_geom, ref myrot);
890 } 978 }
891 } 979 }
892 else 980 else
893 { 981 {
894 _parent_scene.waitForSpaceUnlock(m_targetSpace); 982 if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1)
895 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); 983 {
896 } 984 if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z)
897 if (IsPhysical && Body == (IntPtr) 0) 985 {
898 { 986 _parent_scene.waitForSpaceUnlock(m_targetSpace);
899 //re-create new body 987 SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2));
900 enableBody(); 988 }
901 } 989 else
902 else 990 {
903 { 991 _parent_scene.waitForSpaceUnlock(m_targetSpace);
992 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
993 }
994 }
995 //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight)
996 //{
997 //Cyllinder
998 //if (_size.X == _size.Y)
999 //{
1000 //prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z);
1001 //}
1002 //else
1003 //{
1004 //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
1005 //}
1006 //}
1007 else
1008 {
1009 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1010 SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
1011 }
904 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 1012 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
905 d.Quaternion myrot = new d.Quaternion(); 1013 d.Quaternion myrot = new d.Quaternion();
906 myrot.W = _orientation.w; 1014 myrot.W = _orientation.w;
@@ -908,6 +1016,16 @@ namespace OpenSim.Region.Physics.OdePlugin
908 myrot.Y = _orientation.y; 1016 myrot.Y = _orientation.y;
909 myrot.Z = _orientation.z; 1017 myrot.Z = _orientation.z;
910 d.GeomSetQuaternion(prim_geom, ref myrot); 1018 d.GeomSetQuaternion(prim_geom, ref myrot);
1019
1020
1021 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
1022 if (IsPhysical && Body == (IntPtr)0)
1023 {
1024 // Re creates body on size.
1025 // EnableBody also does setMass()
1026 enableBody();
1027 d.BodyEnable(Body);
1028 }
911 } 1029 }
912 _parent_scene.geom_name_map[prim_geom] = oldname; 1030 _parent_scene.geom_name_map[prim_geom] = oldname;
913 1031
@@ -924,7 +1042,7 @@ namespace OpenSim.Region.Physics.OdePlugin
924 } 1042 }
925 ode.dlock(_parent_scene.world); 1043 ode.dlock(_parent_scene.world);
926 1044
927 System.Threading.Thread.Sleep(2); 1045
928 lock (m_forcelist) 1046 lock (m_forcelist)
929 { 1047 {
930 //m_log.Info("[PHYSICS]: dequeing forcelist"); 1048 //m_log.Info("[PHYSICS]: dequeing forcelist");
@@ -1048,7 +1166,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1048 1166
1049 public override PrimitiveBaseShape Shape 1167 public override PrimitiveBaseShape Shape
1050 { 1168 {
1051 set { _pbs = value; } 1169 set {
1170
1171 _pbs = value;
1172 m_taintshape = true;
1173 }
1052 } 1174 }
1053 1175
1054 public override PhysicsVector Velocity 1176 public override PhysicsVector Velocity
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 3d70a3d..d7d9ab1 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -330,6 +330,7 @@ namespace OpenSim.Region.Physics.OdePlugin
330 catch (SEHException) 330 catch (SEHException)
331 { 331 {
332 m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); 332 m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim.");
333 ode.drelease(world);
333 base.TriggerPhysicsBasedRestart(); 334 base.TriggerPhysicsBasedRestart();
334 } 335 }
335 catch (System.AccessViolationException) 336 catch (System.AccessViolationException)
@@ -737,87 +738,92 @@ namespace OpenSim.Region.Physics.OdePlugin
737 /// <param name="prim"></param> 738 /// <param name="prim"></param>
738 public void RemovePrimThreadLocked(OdePrim prim) 739 public void RemovePrimThreadLocked(OdePrim prim)
739 { 740 {
740 while (ode.lockquery()) 741 lock (ode)
741 { 742 {
742 } 743 if (prim.prim_geom != (IntPtr)0)
743 ode.dlock(world);
744 //System.Threading.Thread.Sleep(20);
745 prim.ResetTaints();
746
747
748 if (prim.IsPhysical)
749 {
750 prim.disableBody();
751 }
752 // we don't want to remove the main space
753 if (prim.m_targetSpace != space && prim.IsPhysical == false)
754 { 744 {
755 // If the geometry is in the targetspace, remove it from the target space 745 while (ode.lockquery())
756 //m_log.Warn(prim.m_targetSpace); 746 {
757 if (prim.prim_geom == (IntPtr)0) 747 }
758 prim.prim_geom = prim.prev_geom; 748 ode.dlock(world);
749 //System.Threading.Thread.Sleep(20);
750 prim.ResetTaints();
751
759 752
760 if (prim.m_targetSpace != (IntPtr)0) 753 if (prim.IsPhysical)
761 { 754 {
762 if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom)) 755 prim.disableBody();
756 }
757 // we don't want to remove the main space
758 if (prim.m_targetSpace != space && prim.IsPhysical == false)
759 {
760 // If the geometry is in the targetspace, remove it from the target space
761 //m_log.Warn(prim.m_targetSpace);
762
763
764 if (prim.m_targetSpace != (IntPtr)0)
763 { 765 {
764 766 if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom))
765 if (d.GeomIsSpace(prim.m_targetSpace))
766 { 767 {
767 waitForSpaceUnlock(prim.m_targetSpace); 768
768 d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); 769 if (d.GeomIsSpace(prim.m_targetSpace))
769 prim.m_targetSpace = space; 770 {
771 waitForSpaceUnlock(prim.m_targetSpace);
772 d.SpaceRemove(prim.m_targetSpace, prim.prim_geom);
773 prim.m_targetSpace = space;
774 }
775 else
776 {
777 m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
778 ((OdePrim)prim).m_targetSpace.ToString());
779 }
780
770 } 781 }
771 else 782 }
783 //m_log.Warn(prim.prim_geom);
784 try
785 {
786 if (prim.prim_geom != (IntPtr)0)
772 { 787 {
773 m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + 788 d.GeomDestroy(prim.prim_geom);
774 ((OdePrim)prim).m_targetSpace.ToString()); 789 prim.prim_geom = (IntPtr)0;
775 } 790 }
776 791
777 } 792 }
778 } 793 catch (System.AccessViolationException)
779 //m_log.Warn(prim.prim_geom);
780 try
781 {
782 if (prim.prim_geom != (IntPtr)0)
783 { 794 {
784 d.GeomDestroy(prim.prim_geom); 795 m_log.Info("[PHYSICS]: Couldn't remove prim from physics scene, it was already be removed.");
785 prim.prim_geom = (IntPtr) 0;
786 } 796 }
787 797 _prims.Remove(prim);
788 }
789 catch (System.AccessViolationException)
790 {
791 m_log.Info("[PHYSICS]: Couldn't remove prim from physics scene, it was already be removed.");
792 }
793 _prims.Remove(prim);
794 798
795 //If there are no more geometries in the sub-space, we don't need it in the main space anymore 799 //If there are no more geometries in the sub-space, we don't need it in the main space anymore
796 //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0) 800 //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0)
797 //{ 801 //{
798 //if (!(prim.m_targetSpace.Equals(null))) 802 //if (!(prim.m_targetSpace.Equals(null)))
799 //{ 803 //{
800 //if (d.GeomIsSpace(prim.m_targetSpace)) 804 //if (d.GeomIsSpace(prim.m_targetSpace))
801 //{ 805 //{
802 //waitForSpaceUnlock(prim.m_targetSpace); 806 //waitForSpaceUnlock(prim.m_targetSpace);
803 //d.SpaceRemove(space, prim.m_targetSpace); 807 //d.SpaceRemove(space, prim.m_targetSpace);
804 // free up memory used by the space. 808 // free up memory used by the space.
805 //d.SpaceDestroy(prim.m_targetSpace); 809 //d.SpaceDestroy(prim.m_targetSpace);
806 //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position); 810 //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position);
807 //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]); 811 //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]);
808 //}
809 //else
810 //{
811 //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
812 //((OdePrim) prim).m_targetSpace.ToString());
813 //}
814 //} 812 //}
815 //} 813 //else
816 } 814 //{
815 //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" +
816 //((OdePrim) prim).m_targetSpace.ToString());
817 //}
818 //}
819 //}
820 }
821
822
817 823
818 824 ode.dunlock(world);
819 825 }
820 ode.dunlock(world); 826 }
821 } 827 }
822 /// <summary> 828 /// <summary>
823 /// Takes a space pointer and zeros out the array we're using to hold the spaces 829 /// Takes a space pointer and zeros out the array we're using to hold the spaces
@@ -1238,6 +1244,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1238 catch (StackOverflowException) 1244 catch (StackOverflowException)
1239 { 1245 {
1240 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); 1246 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
1247 ode.drelease(world);
1241 base.TriggerPhysicsBasedRestart(); 1248 base.TriggerPhysicsBasedRestart();
1242 } 1249 }
1243 1250
@@ -1249,33 +1256,32 @@ namespace OpenSim.Region.Physics.OdePlugin
1249 1256
1250 while (step_time > 0.0f) 1257 while (step_time > 0.0f)
1251 { 1258 {
1252 foreach (OdeCharacter actor in _characters) 1259 lock (ode)
1253 { 1260 {
1254 actor.Move(timeStep); 1261 if (!ode.lockquery())
1255 actor.collidelock = true; 1262 {
1256 } 1263 ode.dlock(world);
1257 if (!ode.lockquery()) 1264 foreach (OdeCharacter actor in _characters)
1258 { 1265 {
1259 ode.dlock(world); 1266 actor.Move(timeStep);
1267
1268 }
1269
1260 1270
1261 collision_optimized(timeStep); 1271 collision_optimized(timeStep);
1262 1272
1263 d.WorldQuickStep(world, ODE_STEPSIZE); 1273 d.WorldQuickStep(world, ODE_STEPSIZE);
1264
1265 d.JointGroupEmpty(contactgroup);
1266 ode.dunlock(world);
1267 1274
1268 step_time -= ODE_STEPSIZE; 1275 d.JointGroupEmpty(contactgroup);
1269 i++; 1276 ode.dunlock(world);
1270 }
1271 else
1272 {
1273 fps = 0;
1274 }
1275 1277
1276 foreach (OdeCharacter actor in _characters) 1278 step_time -= ODE_STEPSIZE;
1277 { 1279 i++;
1278 actor.collidelock = false; 1280 }
1281 else
1282 {
1283 fps = 0;
1284 }
1279 } 1285 }
1280 } 1286 }
1281 1287