diff options
author | Teravus Ovares | 2008-03-09 15:43:01 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-03-09 15:43:01 +0000 |
commit | 081b2ac34ec57fe0f67f0e63c9179e3a141f0ea5 (patch) | |
tree | f2d5e9658368e1479e780e5b077b99ef2616b2e5 /OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |
parent | Update svn properties. (diff) | |
download | opensim-SC_OLD-081b2ac34ec57fe0f67f0e63c9179e3a141f0ea5.zip opensim-SC_OLD-081b2ac34ec57fe0f67f0e63c9179e3a141f0ea5.tar.gz opensim-SC_OLD-081b2ac34ec57fe0f67f0e63c9179e3a141f0ea5.tar.bz2 opensim-SC_OLD-081b2ac34ec57fe0f67f0e63c9179e3a141f0ea5.tar.xz |
* Cleaned up some locking on the ODEPlugin to make it more developer friendly
* Expect the occasional deadlock?
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODEPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 137 |
1 files changed, 47 insertions, 90 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 36b3828..8a8a5fb 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -293,6 +293,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
293 | _parent_scene.addActivePrim(this); | 293 | _parent_scene.addActivePrim(this); |
294 | } | 294 | } |
295 | 295 | ||
296 | #region Mass Calculation | ||
297 | |||
296 | private float CalculateMass() | 298 | private float CalculateMass() |
297 | { | 299 | { |
298 | float volume = 0; | 300 | float volume = 0; |
@@ -598,6 +600,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
598 | return returnMass; | 600 | return returnMass; |
599 | } | 601 | } |
600 | 602 | ||
603 | #endregion | ||
604 | |||
605 | |||
601 | public void setMass() | 606 | public void setMass() |
602 | { | 607 | { |
603 | if (Body != (IntPtr) 0) | 608 | if (Body != (IntPtr) 0) |
@@ -734,11 +739,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
734 | 739 | ||
735 | private void changelink(float timestep) | 740 | private void changelink(float timestep) |
736 | { | 741 | { |
737 | while (ode.lockquery()) | 742 | |
738 | { | ||
739 | } | ||
740 | ode.dlock(_parent_scene.world); | ||
741 | |||
742 | if (_parent == null && m_taintparent != null) | 743 | if (_parent == null && m_taintparent != null) |
743 | { | 744 | { |
744 | if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim) | 745 | if (m_taintparent.PhysicsActorType == (int)ActorTypes.Prim) |
@@ -763,18 +764,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
763 | m_linkJoint = (IntPtr)0; | 764 | m_linkJoint = (IntPtr)0; |
764 | 765 | ||
765 | } | 766 | } |
766 | ode.dunlock(_parent_scene.world); | 767 | |
767 | 768 | ||
768 | _parent = m_taintparent; | 769 | _parent = m_taintparent; |
769 | } | 770 | } |
770 | 771 | ||
771 | private void changeSelectedStatus(float timestep) | 772 | private void changeSelectedStatus(float timestep) |
772 | { | 773 | { |
773 | while (ode.lockquery()) | 774 | |
774 | { | ||
775 | } | ||
776 | ode.dlock(_parent_scene.world); | ||
777 | |||
778 | if (m_taintselected) | 775 | if (m_taintselected) |
779 | { | 776 | { |
780 | 777 | ||
@@ -831,7 +828,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
831 | 828 | ||
832 | } | 829 | } |
833 | 830 | ||
834 | ode.dunlock(_parent_scene.world); | 831 | |
835 | resetCollisionAccounting(); | 832 | resetCollisionAccounting(); |
836 | m_isSelected = m_taintselected; | 833 | m_isSelected = m_taintselected; |
837 | } | 834 | } |
@@ -860,10 +857,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
860 | } | 857 | } |
861 | public void changeadd(float timestep) | 858 | public void changeadd(float timestep) |
862 | { | 859 | { |
863 | while (ode.lockquery()) | 860 | |
864 | { | 861 | |
865 | } | ||
866 | ode.dlock(_parent_scene.world); | ||
867 | 862 | ||
868 | int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position); | 863 | int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position); |
869 | IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position); | 864 | IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position); |
@@ -992,7 +987,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
992 | 987 | ||
993 | 988 | ||
994 | } | 989 | } |
995 | ode.dunlock(_parent_scene.world); | 990 | |
996 | _parent_scene.geom_name_map[prim_geom] = this.m_primName; | 991 | _parent_scene.geom_name_map[prim_geom] = this.m_primName; |
997 | _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; | 992 | _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; |
998 | 993 | ||
@@ -1004,10 +999,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1004 | } | 999 | } |
1005 | public void Move(float timestep) | 1000 | public void Move(float timestep) |
1006 | { | 1001 | { |
1007 | while (ode.lockquery()) | 1002 | |
1008 | { | ||
1009 | } | ||
1010 | ode.dlock(_parent_scene.world); | ||
1011 | 1003 | ||
1012 | 1004 | ||
1013 | if (m_isphysical) | 1005 | if (m_isphysical) |
@@ -1057,7 +1049,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1057 | d.SpaceAdd(m_targetSpace, prim_geom); | 1049 | d.SpaceAdd(m_targetSpace, prim_geom); |
1058 | } | 1050 | } |
1059 | } | 1051 | } |
1060 | ode.dunlock(_parent_scene.world); | 1052 | |
1061 | 1053 | ||
1062 | changeSelectedStatus(timestep); | 1054 | changeSelectedStatus(timestep); |
1063 | 1055 | ||
@@ -1067,10 +1059,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1067 | 1059 | ||
1068 | public void rotate(float timestep) | 1060 | public void rotate(float timestep) |
1069 | { | 1061 | { |
1070 | while (ode.lockquery()) | 1062 | |
1071 | { | ||
1072 | } | ||
1073 | ode.dlock(_parent_scene.world); | ||
1074 | 1063 | ||
1075 | d.Quaternion myrot = new d.Quaternion(); | 1064 | d.Quaternion myrot = new d.Quaternion(); |
1076 | myrot.W = _orientation.w; | 1065 | myrot.W = _orientation.w; |
@@ -1082,8 +1071,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1082 | { | 1071 | { |
1083 | d.BodySetQuaternion(Body, ref myrot); | 1072 | d.BodySetQuaternion(Body, ref myrot); |
1084 | } | 1073 | } |
1085 | |||
1086 | ode.dunlock(_parent_scene.world); | ||
1087 | 1074 | ||
1088 | resetCollisionAccounting(); | 1075 | resetCollisionAccounting(); |
1089 | m_taintrot = _orientation; | 1076 | m_taintrot = _orientation; |
@@ -1098,46 +1085,35 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1098 | 1085 | ||
1099 | public void changedisable(float timestep) | 1086 | public void changedisable(float timestep) |
1100 | { | 1087 | { |
1101 | while (ode.lockquery()) | 1088 | |
1102 | { | ||
1103 | } | ||
1104 | ode.dlock(_parent_scene.world); | ||
1105 | m_disabled = true; | 1089 | m_disabled = true; |
1106 | if (Body != (IntPtr)0) | 1090 | if (Body != (IntPtr)0) |
1107 | { | 1091 | { |
1108 | d.BodyDisable(Body); | 1092 | d.BodyDisable(Body); |
1109 | Body = (IntPtr)0; | 1093 | Body = (IntPtr)0; |
1110 | } | 1094 | } |
1111 | ode.dunlock(_parent_scene.world); | 1095 | |
1112 | 1096 | ||
1113 | m_taintdisable = false; | 1097 | m_taintdisable = false; |
1114 | } | 1098 | } |
1115 | 1099 | ||
1116 | public void changePhysicsStatus(float timestep) | 1100 | public void changePhysicsStatus(float timestep) |
1117 | { | 1101 | { |
1118 | lock (ode) | 1102 | |
1119 | { | ||
1120 | while (ode.lockquery()) | ||
1121 | { | ||
1122 | } | ||
1123 | ode.dlock(_parent_scene.world); | ||
1124 | 1103 | ||
1125 | if (m_isphysical == true) | 1104 | if (m_isphysical == true) |
1105 | { | ||
1106 | if (Body == (IntPtr)0) | ||
1126 | { | 1107 | { |
1127 | if (Body == (IntPtr)0) | 1108 | enableBody(); |
1128 | { | ||
1129 | enableBody(); | ||
1130 | } | ||
1131 | } | 1109 | } |
1132 | else | 1110 | } |
1111 | else | ||
1112 | { | ||
1113 | if (Body != (IntPtr)0) | ||
1133 | { | 1114 | { |
1134 | if (Body != (IntPtr)0) | 1115 | disableBody(); |
1135 | { | ||
1136 | disableBody(); | ||
1137 | } | ||
1138 | } | 1116 | } |
1139 | |||
1140 | ode.dunlock(_parent_scene.world); | ||
1141 | } | 1117 | } |
1142 | 1118 | ||
1143 | changeSelectedStatus(timestep); | 1119 | changeSelectedStatus(timestep); |
@@ -1148,10 +1124,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1148 | 1124 | ||
1149 | public void changesize(float timestamp) | 1125 | public void changesize(float timestamp) |
1150 | { | 1126 | { |
1151 | while (ode.lockquery()) | 1127 | |
1152 | { | ||
1153 | } | ||
1154 | ode.dlock(_parent_scene.world); | ||
1155 | //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom)) | 1128 | //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom)) |
1156 | //{ | 1129 | //{ |
1157 | // m_taintsize = _size; | 1130 | // m_taintsize = _size; |
@@ -1311,8 +1284,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1311 | 1284 | ||
1312 | _parent_scene.geom_name_map[prim_geom] = oldname; | 1285 | _parent_scene.geom_name_map[prim_geom] = oldname; |
1313 | 1286 | ||
1314 | ode.dunlock(_parent_scene.world); | ||
1315 | |||
1316 | changeSelectedStatus(timestamp); | 1287 | changeSelectedStatus(timestamp); |
1317 | 1288 | ||
1318 | resetCollisionAccounting(); | 1289 | resetCollisionAccounting(); |
@@ -1321,12 +1292,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1321 | 1292 | ||
1322 | public void changeshape(float timestamp) | 1293 | public void changeshape(float timestamp) |
1323 | { | 1294 | { |
1324 | while (ode.lockquery()) | 1295 | |
1325 | { | ||
1326 | } | ||
1327 | ode.dlock(_parent_scene.world); | ||
1328 | |||
1329 | |||
1330 | string oldname = _parent_scene.geom_name_map[prim_geom]; | 1296 | string oldname = _parent_scene.geom_name_map[prim_geom]; |
1331 | 1297 | ||
1332 | // Cleanup of old prim geometry and Bodies | 1298 | // Cleanup of old prim geometry and Bodies |
@@ -1471,8 +1437,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1471 | 1437 | ||
1472 | _parent_scene.geom_name_map[prim_geom] = oldname; | 1438 | _parent_scene.geom_name_map[prim_geom] = oldname; |
1473 | 1439 | ||
1474 | ode.dunlock(_parent_scene.world); | ||
1475 | |||
1476 | changeSelectedStatus(timestamp); | 1440 | changeSelectedStatus(timestamp); |
1477 | 1441 | ||
1478 | resetCollisionAccounting(); | 1442 | resetCollisionAccounting(); |
@@ -1483,10 +1447,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1483 | { | 1447 | { |
1484 | if (!m_isSelected) | 1448 | if (!m_isSelected) |
1485 | { | 1449 | { |
1486 | while (ode.lockquery()) | 1450 | |
1487 | { | ||
1488 | } | ||
1489 | ode.dlock(_parent_scene.world); | ||
1490 | 1451 | ||
1491 | 1452 | ||
1492 | lock (m_forcelist) | 1453 | lock (m_forcelist) |
@@ -1505,7 +1466,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1505 | m_forcelist.Clear(); | 1466 | m_forcelist.Clear(); |
1506 | } | 1467 | } |
1507 | 1468 | ||
1508 | ode.dunlock(_parent_scene.world); | ||
1509 | 1469 | ||
1510 | m_collisionscore = 0; | 1470 | m_collisionscore = 0; |
1511 | m_interpenetrationcount = 0; | 1471 | m_interpenetrationcount = 0; |
@@ -1517,24 +1477,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1517 | { | 1477 | { |
1518 | if (!m_isSelected) | 1478 | if (!m_isSelected) |
1519 | { | 1479 | { |
1520 | lock (ode) | 1480 | |
1521 | { | ||
1522 | while (ode.lockquery()) | ||
1523 | { | ||
1524 | } | ||
1525 | ode.dlock(_parent_scene.world); | ||
1526 | 1481 | ||
1527 | System.Threading.Thread.Sleep(20); | 1482 | System.Threading.Thread.Sleep(20); |
1528 | if (IsPhysical) | 1483 | if (IsPhysical) |
1484 | { | ||
1485 | if (Body != (IntPtr)0) | ||
1529 | { | 1486 | { |
1530 | if (Body != (IntPtr)0) | 1487 | d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); |
1531 | { | ||
1532 | d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); | ||
1533 | } | ||
1534 | } | 1488 | } |
1535 | 1489 | } | |
1536 | ode.dunlock(_parent_scene.world); | 1490 | |
1537 | } | ||
1538 | //resetCollisionAccounting(); | 1491 | //resetCollisionAccounting(); |
1539 | } | 1492 | } |
1540 | m_taintVelocity = PhysicsVector.Zero; | 1493 | m_taintVelocity = PhysicsVector.Zero; |
@@ -1763,12 +1716,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1763 | if (l_position.X > 255.95f || l_position.X < 0f || l_position.Y > 255.95f || l_position.Y < 0f) | 1716 | if (l_position.X > 255.95f || l_position.X < 0f || l_position.Y > 255.95f || l_position.Y < 0f) |
1764 | { | 1717 | { |
1765 | base.RaiseOutOfBounds(_position); | 1718 | base.RaiseOutOfBounds(_position); |
1719 | |||
1720 | //if (m_crossingfailures < 5) | ||
1721 | //{ | ||
1722 | //base.RequestPhysicsterseUpdate(); | ||
1723 | //} | ||
1724 | //else | ||
1725 | //{ | ||
1726 | //base.RaiseOutOfBounds(_position); | ||
1727 | //} | ||
1766 | } | 1728 | } |
1767 | //if (m_crossingfailures < 5) | ||
1768 | //{ | ||
1769 | //base.RequestPhysicsterseUpdate(); | ||
1770 | //} | ||
1771 | //} | ||
1772 | 1729 | ||
1773 | if (l_position.Z < 0) | 1730 | if (l_position.Z < 0) |
1774 | { | 1731 | { |