diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 563 |
1 files changed, 418 insertions, 145 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 0ccdbc0..b105f77 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | |||
@@ -114,6 +114,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
114 | // private bool m_collidesLand = true; | 114 | // private bool m_collidesLand = true; |
115 | private bool m_collidesWater; | 115 | private bool m_collidesWater; |
116 | public bool m_returnCollisions; | 116 | public bool m_returnCollisions; |
117 | private bool m_softcolide; | ||
118 | |||
119 | private bool m_NoColide; // for now only for internal use for bad meshs | ||
117 | 120 | ||
118 | // Default we're a Geometry | 121 | // Default we're a Geometry |
119 | private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); | 122 | private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); |
@@ -155,6 +158,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
155 | public float m_collisionscore; | 158 | public float m_collisionscore; |
156 | int m_colliderfilter = 0; | 159 | int m_colliderfilter = 0; |
157 | 160 | ||
161 | public IntPtr collide_geom; // for objects: geom if single prim space it linkset | ||
162 | |||
158 | private float m_density = 10.000006836f; // Aluminum g/cm3; | 163 | private float m_density = 10.000006836f; // Aluminum g/cm3; |
159 | 164 | ||
160 | public bool _zeroFlag; | 165 | public bool _zeroFlag; |
@@ -185,7 +190,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
185 | public ODEDynamics m_vehicle; | 190 | public ODEDynamics m_vehicle; |
186 | 191 | ||
187 | internal int m_material = (int)Material.Wood; | 192 | internal int m_material = (int)Material.Wood; |
188 | protected ContactData primContactData = new ContactData { mu = 0f, bounce = 0.1f }; | 193 | private float mu; |
194 | private float bounce; | ||
189 | 195 | ||
190 | /// <summary> | 196 | /// <summary> |
191 | /// Is this prim subject to physics? Even if not, it's still solid for collision purposes. | 197 | /// Is this prim subject to physics? Even if not, it's still solid for collision purposes. |
@@ -216,13 +222,26 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
216 | } | 222 | } |
217 | } | 223 | } |
218 | 224 | ||
219 | public override ContactData ContactData | 225 | public override void getContactData(ref ContactData cdata) |
220 | { | 226 | { |
221 | get | 227 | cdata.mu = mu; |
228 | cdata.bounce = bounce; | ||
229 | |||
230 | // cdata.softcolide = m_softcolide; | ||
231 | cdata.softcolide = false; | ||
232 | |||
233 | if (m_isphysical) | ||
222 | { | 234 | { |
223 | return primContactData; | 235 | ODEDynamics veh; |
236 | if (_parent != null) | ||
237 | veh = ((OdePrim)_parent).m_vehicle; | ||
238 | else | ||
239 | veh = m_vehicle; | ||
240 | |||
241 | if (veh != null && veh.Type != Vehicle.TYPE_NONE) | ||
242 | cdata.mu *= veh.FrictionFactor; | ||
224 | } | 243 | } |
225 | } | 244 | } |
226 | 245 | ||
227 | public override int PhysicsActorType | 246 | public override int PhysicsActorType |
228 | { | 247 | { |
@@ -290,7 +309,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
290 | } | 309 | } |
291 | 310 | ||
292 | if (m_colliderfilter == 0) | 311 | if (m_colliderfilter == 0) |
312 | { | ||
313 | m_softcolide = false; | ||
293 | m_iscolliding = false; | 314 | m_iscolliding = false; |
315 | } | ||
294 | else | 316 | else |
295 | m_iscolliding = true; | 317 | m_iscolliding = true; |
296 | } | 318 | } |
@@ -453,8 +475,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
453 | { | 475 | { |
454 | get | 476 | get |
455 | { | 477 | { |
456 | // Averate previous velocity with the new one so | ||
457 | // client object interpolation works a 'little' better | ||
458 | if (_zeroFlag) | 478 | if (_zeroFlag) |
459 | return Vector3.Zero; | 479 | return Vector3.Zero; |
460 | return _velocity; | 480 | return _velocity; |
@@ -733,8 +753,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
733 | public override void SetMaterial(int pMaterial) | 753 | public override void SetMaterial(int pMaterial) |
734 | { | 754 | { |
735 | m_material = pMaterial; | 755 | m_material = pMaterial; |
736 | primContactData.mu = _parent_scene.m_materialContactsData[pMaterial].mu; | 756 | mu = _parent_scene.m_materialContactsData[pMaterial].mu; |
737 | primContactData.bounce = _parent_scene.m_materialContactsData[pMaterial].bounce; | 757 | bounce = _parent_scene.m_materialContactsData[pMaterial].bounce; |
738 | } | 758 | } |
739 | 759 | ||
740 | public void setPrimForRemoval() | 760 | public void setPrimForRemoval() |
@@ -833,6 +853,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
833 | body_autodisable_frames = parent_scene.bodyFramesAutoDisable; | 853 | body_autodisable_frames = parent_scene.bodyFramesAutoDisable; |
834 | 854 | ||
835 | prim_geom = IntPtr.Zero; | 855 | prim_geom = IntPtr.Zero; |
856 | collide_geom = IntPtr.Zero; | ||
836 | Body = IntPtr.Zero; | 857 | Body = IntPtr.Zero; |
837 | 858 | ||
838 | if (!size.IsFinite()) | 859 | if (!size.IsFinite()) |
@@ -847,7 +868,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
847 | 868 | ||
848 | _size = size; | 869 | _size = size; |
849 | 870 | ||
850 | |||
851 | if (!QuaternionIsFinite(rotation)) | 871 | if (!QuaternionIsFinite(rotation)) |
852 | { | 872 | { |
853 | rotation = Quaternion.Identity; | 873 | rotation = Quaternion.Identity; |
@@ -878,6 +898,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
878 | 898 | ||
879 | m_iscolliding = false; | 899 | m_iscolliding = false; |
880 | m_colliderfilter = 0; | 900 | m_colliderfilter = 0; |
901 | m_softcolide = true; | ||
902 | m_NoColide = false; | ||
881 | 903 | ||
882 | hasOOBoffsetFromMesh = false; | 904 | hasOOBoffsetFromMesh = false; |
883 | _triMeshData = IntPtr.Zero; | 905 | _triMeshData = IntPtr.Zero; |
@@ -886,8 +908,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
886 | m_isSelected = false; | 908 | m_isSelected = false; |
887 | m_delaySelect = false; | 909 | m_delaySelect = false; |
888 | 910 | ||
889 | primContactData.mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu; | 911 | mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu; |
890 | primContactData.bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce; | 912 | bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce; |
891 | 913 | ||
892 | CalcPrimBodyData(); | 914 | CalcPrimBodyData(); |
893 | 915 | ||
@@ -1025,34 +1047,42 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1025 | 1047 | ||
1026 | if (vertexCount == 0 || indexCount == 0) | 1048 | if (vertexCount == 0 || indexCount == 0) |
1027 | { | 1049 | { |
1028 | m_log.WarnFormat("[PHYSICS]: Got invalid mesh on prim {0} at <{1},{2},{3}>. It can be a sculp with alpha channel in map. Replacing it by a small box.", Name, _position.X, _position.Y, _position.Z); | 1050 | m_log.WarnFormat("[PHYSICS]: Got invalid mesh on prim {0} at <{1},{2},{3}>. mesh UUID {4}", |
1029 | _size.X = 0.01f; | 1051 | Name, _position.X, _position.Y, _position.Z, _pbs.SculptTexture.ToString()); |
1030 | _size.Y = 0.01f; | 1052 | mesh.releaseSourceMeshData(); |
1031 | _size.Z = 0.01f; | ||
1032 | return false; | 1053 | return false; |
1033 | } | 1054 | } |
1034 | 1055 | ||
1035 | primOOBoffset = mesh.GetCentroid(); | 1056 | primOOBoffset = mesh.GetCentroid(); |
1036 | hasOOBoffsetFromMesh = true; | 1057 | hasOOBoffsetFromMesh = true; |
1037 | 1058 | ||
1038 | _triMeshData = d.GeomTriMeshDataCreate(); | ||
1039 | |||
1040 | d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); | ||
1041 | d.GeomTriMeshDataPreprocess(_triMeshData); | ||
1042 | |||
1043 | mesh.releaseSourceMeshData(); | 1059 | mesh.releaseSourceMeshData(); |
1044 | 1060 | ||
1045 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1061 | IntPtr geo = IntPtr.Zero; |
1062 | |||
1046 | try | 1063 | try |
1047 | { | 1064 | { |
1048 | SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null)); | 1065 | _triMeshData = d.GeomTriMeshDataCreate(); |
1066 | |||
1067 | d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); | ||
1068 | d.GeomTriMeshDataPreprocess(_triMeshData); | ||
1069 | |||
1070 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1071 | geo = d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null); | ||
1049 | } | 1072 | } |
1050 | 1073 | ||
1051 | catch (Exception e) | 1074 | catch (Exception e) |
1052 | { | 1075 | { |
1053 | m_log.ErrorFormat("[PHYSICS]: SetGeom Mesh failed for {0} exception: {1}", Name, e); | 1076 | m_log.ErrorFormat("[PHYSICS]: SetGeom Mesh failed for {0} exception: {1}", Name, e); |
1077 | if (_triMeshData != IntPtr.Zero) | ||
1078 | { | ||
1079 | d.GeomTriMeshDataDestroy(_triMeshData); | ||
1080 | _triMeshData = IntPtr.Zero; | ||
1081 | } | ||
1054 | return false; | 1082 | return false; |
1055 | } | 1083 | } |
1084 | |||
1085 | SetGeom(geo); | ||
1056 | return true; | 1086 | return true; |
1057 | } | 1087 | } |
1058 | 1088 | ||
@@ -1062,25 +1092,30 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1062 | //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name); | 1092 | //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name); |
1063 | if (prim_geom != IntPtr.Zero) | 1093 | if (prim_geom != IntPtr.Zero) |
1064 | { | 1094 | { |
1065 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | 1095 | if (m_NoColide) |
1066 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | 1096 | { |
1097 | d.GeomSetCategoryBits(prim_geom, 0); | ||
1098 | if (m_isphysical) | ||
1099 | { | ||
1100 | d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land); | ||
1101 | } | ||
1102 | else | ||
1103 | { | ||
1104 | d.GeomSetCollideBits(prim_geom, 0); | ||
1105 | d.GeomDisable(prim_geom); | ||
1106 | } | ||
1107 | } | ||
1108 | else | ||
1109 | { | ||
1110 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
1111 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
1112 | } | ||
1067 | 1113 | ||
1068 | CalcPrimBodyData(); | 1114 | CalcPrimBodyData(); |
1069 | 1115 | ||
1070 | _parent_scene.geom_name_map[prim_geom] = Name; | 1116 | _parent_scene.geom_name_map[prim_geom] = Name; |
1071 | _parent_scene.actor_name_map[prim_geom] = this; | 1117 | _parent_scene.actor_name_map[prim_geom] = this; |
1072 | 1118 | ||
1073 | /* | ||
1074 | if (childPrim) | ||
1075 | { | ||
1076 | if (_parent != null && _parent is OdePrim) | ||
1077 | { | ||
1078 | OdePrim parent = (OdePrim)_parent; | ||
1079 | //Console.WriteLine("SetGeom calls ChildSetGeom"); | ||
1080 | parent.ChildSetGeom(this); | ||
1081 | } | ||
1082 | } | ||
1083 | */ | ||
1084 | } | 1119 | } |
1085 | else | 1120 | else |
1086 | m_log.Warn("Setting bad Geom"); | 1121 | m_log.Warn("Setting bad Geom"); |
@@ -1102,10 +1137,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1102 | 1137 | ||
1103 | bool haveMesh = false; | 1138 | bool haveMesh = false; |
1104 | hasOOBoffsetFromMesh = false; | 1139 | hasOOBoffsetFromMesh = false; |
1140 | m_NoColide = false; | ||
1105 | 1141 | ||
1106 | if (_parent_scene.needsMeshing(_pbs)) | 1142 | if (_parent_scene.needsMeshing(_pbs)) |
1107 | { | 1143 | { |
1108 | haveMesh = setMesh(_parent_scene); // this will give a mesh to non trivial known prims | 1144 | haveMesh = setMesh(_parent_scene); // this will give a mesh to non trivial known prims |
1145 | if (!haveMesh) | ||
1146 | m_NoColide = true; | ||
1109 | } | 1147 | } |
1110 | 1148 | ||
1111 | if (!haveMesh) | 1149 | if (!haveMesh) |
@@ -1197,12 +1235,46 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1197 | { | 1235 | { |
1198 | if (!childPrim && !m_isSelected) | 1236 | if (!childPrim && !m_isSelected) |
1199 | { | 1237 | { |
1200 | if (m_isphysical && Body != IntPtr.Zero && prim_geom != IntPtr.Zero) | 1238 | if (m_isphysical && Body != IntPtr.Zero) |
1201 | { | 1239 | { |
1202 | d.GeomEnable(prim_geom); | 1240 | m_collisionCategories |= CollisionCategories.Body; |
1241 | m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | ||
1242 | |||
1203 | foreach (OdePrim prm in childrenPrim) | 1243 | foreach (OdePrim prm in childrenPrim) |
1204 | d.GeomEnable(prm.prim_geom); | 1244 | { |
1245 | prm.m_collisionCategories = m_collisionCategories; | ||
1246 | prm.m_collisionFlags = m_collisionFlags; | ||
1205 | 1247 | ||
1248 | if (prm.prim_geom != IntPtr.Zero) | ||
1249 | { | ||
1250 | if (prm.m_NoColide) | ||
1251 | { | ||
1252 | d.GeomSetCategoryBits(prm.prim_geom, 0); | ||
1253 | d.GeomSetCollideBits(prm.prim_geom, (int)CollisionCategories.Land); | ||
1254 | } | ||
1255 | else | ||
1256 | { | ||
1257 | d.GeomSetCategoryBits(prm.prim_geom, (int)m_collisionCategories); | ||
1258 | d.GeomSetCollideBits(prm.prim_geom, (int)m_collisionFlags); | ||
1259 | } | ||
1260 | d.GeomEnable(prm.prim_geom); | ||
1261 | } | ||
1262 | } | ||
1263 | |||
1264 | if (prim_geom != IntPtr.Zero) | ||
1265 | { | ||
1266 | if (m_NoColide) | ||
1267 | { | ||
1268 | d.GeomSetCategoryBits(prim_geom, 0); | ||
1269 | d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land); | ||
1270 | } | ||
1271 | else | ||
1272 | { | ||
1273 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
1274 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
1275 | } | ||
1276 | d.GeomEnable(prim_geom); | ||
1277 | } | ||
1206 | d.BodyEnable(Body); | 1278 | d.BodyEnable(Body); |
1207 | } | 1279 | } |
1208 | } | 1280 | } |
@@ -1215,11 +1287,47 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1215 | m_disabled = true; | 1287 | m_disabled = true; |
1216 | if (!childPrim) | 1288 | if (!childPrim) |
1217 | { | 1289 | { |
1218 | if (m_isphysical && Body != IntPtr.Zero && prim_geom != IntPtr.Zero) | 1290 | if (m_isphysical && Body != IntPtr.Zero) |
1219 | { | 1291 | { |
1220 | d.GeomDisable(prim_geom); | 1292 | m_collisionCategories &= ~CollisionCategories.Body; |
1293 | m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); | ||
1294 | |||
1221 | foreach (OdePrim prm in childrenPrim) | 1295 | foreach (OdePrim prm in childrenPrim) |
1222 | d.GeomDisable(prm.prim_geom); | 1296 | { |
1297 | prm.m_collisionCategories = m_collisionCategories; | ||
1298 | prm.m_collisionFlags = m_collisionFlags; | ||
1299 | |||
1300 | if (prm.prim_geom != IntPtr.Zero) | ||
1301 | { | ||
1302 | if (prm.m_NoColide) | ||
1303 | { | ||
1304 | d.GeomSetCategoryBits(prm.prim_geom, 0); | ||
1305 | d.GeomSetCollideBits(prm.prim_geom, 0); | ||
1306 | } | ||
1307 | else | ||
1308 | { | ||
1309 | d.GeomSetCategoryBits(prm.prim_geom, (int)m_collisionCategories); | ||
1310 | d.GeomSetCollideBits(prm.prim_geom, (int)m_collisionFlags); | ||
1311 | } | ||
1312 | d.GeomDisable(prm.prim_geom); | ||
1313 | } | ||
1314 | } | ||
1315 | |||
1316 | if (prim_geom != IntPtr.Zero) | ||
1317 | { | ||
1318 | if (m_NoColide) | ||
1319 | { | ||
1320 | d.GeomSetCategoryBits(prim_geom, 0); | ||
1321 | d.GeomSetCollideBits(prim_geom, 0); | ||
1322 | } | ||
1323 | else | ||
1324 | { | ||
1325 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
1326 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
1327 | } | ||
1328 | d.GeomDisable(prim_geom); | ||
1329 | } | ||
1330 | |||
1223 | d.BodyDisable(Body); | 1331 | d.BodyDisable(Body); |
1224 | } | 1332 | } |
1225 | } | 1333 | } |
@@ -1298,8 +1406,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1298 | continue; | 1406 | continue; |
1299 | } | 1407 | } |
1300 | 1408 | ||
1301 | |||
1302 | |||
1303 | DMassCopy(ref prm.primdMass, ref tmpdmass); | 1409 | DMassCopy(ref prm.primdMass, ref tmpdmass); |
1304 | 1410 | ||
1305 | // apply prim current rotation to inertia | 1411 | // apply prim current rotation to inertia |
@@ -1361,14 +1467,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1361 | // d.BodySetAngularDampingThreshold(Body, 0.001f); | 1467 | // d.BodySetAngularDampingThreshold(Body, 0.001f); |
1362 | d.BodySetDamping(Body, .002f, .002f); | 1468 | d.BodySetDamping(Body, .002f, .002f); |
1363 | 1469 | ||
1364 | m_collisionCategories |= CollisionCategories.Body; | ||
1365 | m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | ||
1366 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
1367 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
1368 | m_collisionscore = 0; | ||
1369 | 1470 | ||
1370 | if (m_targetSpace != _parent_scene.ActiveSpace) | ||
1371 | { | ||
1372 | if (m_targetSpace != IntPtr.Zero) | 1471 | if (m_targetSpace != IntPtr.Zero) |
1373 | { | 1472 | { |
1374 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1473 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
@@ -1376,9 +1475,22 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1376 | d.SpaceRemove(m_targetSpace, prim_geom); | 1475 | d.SpaceRemove(m_targetSpace, prim_geom); |
1377 | } | 1476 | } |
1378 | 1477 | ||
1478 | |||
1479 | if (childrenPrim.Count == 0) | ||
1480 | { | ||
1481 | collide_geom = prim_geom; | ||
1379 | m_targetSpace = _parent_scene.ActiveSpace; | 1482 | m_targetSpace = _parent_scene.ActiveSpace; |
1380 | d.SpaceAdd(m_targetSpace, prim_geom); | 1483 | d.SpaceAdd(m_targetSpace, prim_geom); |
1381 | } | 1484 | } |
1485 | else | ||
1486 | { | ||
1487 | m_targetSpace = d.HashSpaceCreate(_parent_scene.ActiveSpace); | ||
1488 | d.HashSpaceSetLevels(m_targetSpace, -2, 8); | ||
1489 | d.SpaceSetSublevel(m_targetSpace, 3); | ||
1490 | d.SpaceSetCleanup(m_targetSpace, false); | ||
1491 | d.SpaceAdd(m_targetSpace, prim_geom); | ||
1492 | collide_geom = m_targetSpace; | ||
1493 | } | ||
1382 | 1494 | ||
1383 | lock (childrenPrim) | 1495 | lock (childrenPrim) |
1384 | { | 1496 | { |
@@ -1390,28 +1502,45 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1390 | Vector3 ppos = prm._position; | 1502 | Vector3 ppos = prm._position; |
1391 | d.GeomSetOffsetWorldPosition(prm.prim_geom, ppos.X, ppos.Y, ppos.Z); // set relative position | 1503 | d.GeomSetOffsetWorldPosition(prm.prim_geom, ppos.X, ppos.Y, ppos.Z); // set relative position |
1392 | 1504 | ||
1393 | prm.m_collisionCategories |= CollisionCategories.Body; | 1505 | if (prm.m_targetSpace != m_targetSpace) |
1394 | prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | ||
1395 | d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); | ||
1396 | d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); | ||
1397 | prm.m_collisionscore = 0; | ||
1398 | |||
1399 | if (prm.m_targetSpace != _parent_scene.ActiveSpace) | ||
1400 | { | 1506 | { |
1401 | if (prm.m_targetSpace != IntPtr.Zero) | 1507 | if (prm.m_targetSpace != IntPtr.Zero) |
1402 | { | 1508 | { |
1403 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1509 | _parent_scene.waitForSpaceUnlock(prm.m_targetSpace); |
1404 | if (d.SpaceQuery(prm.m_targetSpace, prm.prim_geom)) | 1510 | if (d.SpaceQuery(prm.m_targetSpace, prm.prim_geom)) |
1405 | d.SpaceRemove(prm.m_targetSpace, prm.prim_geom); | 1511 | d.SpaceRemove(prm.m_targetSpace, prm.prim_geom); |
1406 | } | 1512 | } |
1407 | prm.m_targetSpace = _parent_scene.ActiveSpace; | 1513 | prm.m_targetSpace = m_targetSpace; |
1408 | d.SpaceAdd(m_targetSpace, prm.prim_geom); | 1514 | d.SpaceAdd(m_targetSpace, prm.prim_geom); |
1409 | } | 1515 | } |
1410 | 1516 | ||
1411 | if (m_isSelected || m_disabled) | 1517 | if (m_isSelected || m_disabled) |
1518 | { | ||
1519 | prm.m_collisionCategories &= ~CollisionCategories.Body; | ||
1520 | prm.m_collisionFlags &= ~(CollisionCategories.Land | CollisionCategories.Wind); | ||
1412 | d.GeomDisable(prm.prim_geom); | 1521 | d.GeomDisable(prm.prim_geom); |
1522 | } | ||
1523 | else | ||
1524 | { | ||
1525 | prm.m_collisionCategories |= CollisionCategories.Body; | ||
1526 | prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | ||
1527 | } | ||
1528 | |||
1529 | if (prm.m_NoColide) | ||
1530 | { | ||
1531 | d.GeomSetCategoryBits(prm.prim_geom, 0); | ||
1532 | d.GeomSetCollideBits(prm.prim_geom, (int)CollisionCategories.Land); | ||
1533 | } | ||
1534 | else | ||
1535 | { | ||
1536 | d.GeomSetCategoryBits(prm.prim_geom, (int)m_collisionCategories); | ||
1537 | d.GeomSetCollideBits(prm.prim_geom, (int)m_collisionFlags); | ||
1538 | } | ||
1539 | prm.m_collisionscore = 0; | ||
1540 | |||
1541 | if(!m_disabled) | ||
1542 | prm.m_disabled = false; | ||
1413 | 1543 | ||
1414 | prm.m_disabled = false; | ||
1415 | _parent_scene.addActivePrim(prm); | 1544 | _parent_scene.addActivePrim(prm); |
1416 | } | 1545 | } |
1417 | } | 1546 | } |
@@ -1424,11 +1553,37 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1424 | 1553 | ||
1425 | if (m_isSelected || m_disabled) | 1554 | if (m_isSelected || m_disabled) |
1426 | { | 1555 | { |
1556 | m_collisionCategories &= ~CollisionCategories.Body; | ||
1557 | m_collisionFlags &= ~(CollisionCategories.Land | CollisionCategories.Wind); | ||
1558 | |||
1427 | d.GeomDisable(prim_geom); | 1559 | d.GeomDisable(prim_geom); |
1428 | d.BodyDisable(Body); | 1560 | d.BodyDisable(Body); |
1429 | } | 1561 | } |
1562 | else | ||
1563 | { | ||
1564 | m_collisionCategories |= CollisionCategories.Body; | ||
1565 | m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); | ||
1566 | |||
1567 | d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); | ||
1568 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); | ||
1569 | } | ||
1430 | 1570 | ||
1571 | if (m_NoColide) | ||
1572 | { | ||
1573 | d.GeomSetCategoryBits(prim_geom, 0); | ||
1574 | d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land); | ||
1575 | } | ||
1576 | else | ||
1577 | { | ||
1578 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
1579 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
1580 | } | ||
1581 | |||
1582 | m_collisionscore = 0; | ||
1583 | |||
1584 | m_softcolide = true; | ||
1431 | _parent_scene.addActivePrim(this); | 1585 | _parent_scene.addActivePrim(this); |
1586 | _parent_scene.addActiveGroups(this); | ||
1432 | } | 1587 | } |
1433 | 1588 | ||
1434 | private void DestroyBody() | 1589 | private void DestroyBody() |
@@ -1440,8 +1595,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1440 | m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); | 1595 | m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); |
1441 | if (prim_geom != IntPtr.Zero) | 1596 | if (prim_geom != IntPtr.Zero) |
1442 | { | 1597 | { |
1443 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | 1598 | if (m_NoColide) |
1444 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | 1599 | { |
1600 | d.GeomSetCategoryBits(prim_geom, 0); | ||
1601 | d.GeomSetCollideBits(prim_geom, 0); | ||
1602 | } | ||
1603 | else | ||
1604 | { | ||
1605 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
1606 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
1607 | } | ||
1445 | UpdateDataFromGeom(); | 1608 | UpdateDataFromGeom(); |
1446 | d.GeomSetBody(prim_geom, IntPtr.Zero); | 1609 | d.GeomSetBody(prim_geom, IntPtr.Zero); |
1447 | SetInStaticSpace(this); | 1610 | SetInStaticSpace(this); |
@@ -1454,12 +1617,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1454 | foreach (OdePrim prm in childrenPrim) | 1617 | foreach (OdePrim prm in childrenPrim) |
1455 | { | 1618 | { |
1456 | _parent_scene.remActivePrim(prm); | 1619 | _parent_scene.remActivePrim(prm); |
1457 | prm.m_collisionCategories &= ~CollisionCategories.Body; | 1620 | prm.m_collisionCategories = m_collisionCategories; |
1458 | prm.m_collisionFlags &= ~(CollisionCategories.Wind | CollisionCategories.Land); | 1621 | prm.m_collisionFlags = m_collisionFlags; |
1459 | if (prm.prim_geom != IntPtr.Zero) | 1622 | if (prm.prim_geom != IntPtr.Zero) |
1460 | { | 1623 | { |
1461 | d.GeomSetCategoryBits(prm.prim_geom, (int)m_collisionCategories); | 1624 | if (prm.m_NoColide) |
1462 | d.GeomSetCollideBits(prm.prim_geom, (int)m_collisionFlags); | 1625 | { |
1626 | d.GeomSetCategoryBits(prm.prim_geom, 0); | ||
1627 | d.GeomSetCollideBits(prm.prim_geom, 0); | ||
1628 | } | ||
1629 | else | ||
1630 | { | ||
1631 | d.GeomSetCategoryBits(prm.prim_geom, (int)m_collisionCategories); | ||
1632 | d.GeomSetCollideBits(prm.prim_geom, (int)m_collisionFlags); | ||
1633 | } | ||
1463 | prm.UpdateDataFromGeom(); | 1634 | prm.UpdateDataFromGeom(); |
1464 | SetInStaticSpace(prm); | 1635 | SetInStaticSpace(prm); |
1465 | } | 1636 | } |
@@ -1473,6 +1644,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1473 | d.JointDestroy(Amotor); | 1644 | d.JointDestroy(Amotor); |
1474 | Amotor = IntPtr.Zero; | 1645 | Amotor = IntPtr.Zero; |
1475 | } | 1646 | } |
1647 | _parent_scene.remActiveGroup(this); | ||
1476 | d.BodyDestroy(Body); | 1648 | d.BodyDestroy(Body); |
1477 | } | 1649 | } |
1478 | Body = IntPtr.Zero; | 1650 | Body = IntPtr.Zero; |
@@ -2008,23 +2180,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2008 | myrot.Z = _orientation.Z; | 2180 | myrot.Z = _orientation.Z; |
2009 | myrot.W = _orientation.W; | 2181 | myrot.W = _orientation.W; |
2010 | d.GeomSetQuaternion(prim_geom, ref myrot); | 2182 | d.GeomSetQuaternion(prim_geom, ref myrot); |
2011 | // _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; | 2183 | |
2012 | if (!m_isphysical) | 2184 | if (!m_isphysical) |
2013 | SetInStaticSpace(this); | 2185 | SetInStaticSpace(this); |
2014 | } | 2186 | } |
2015 | 2187 | ||
2016 | if (m_isphysical && Body == IntPtr.Zero) | 2188 | if (m_isphysical && Body == IntPtr.Zero) |
2017 | { | 2189 | { |
2018 | /* | ||
2019 | if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim) | ||
2020 | { | ||
2021 | changeShape(_pbs); | ||
2022 | } | ||
2023 | else | ||
2024 | { | ||
2025 | */ | ||
2026 | MakeBody(); | 2190 | MakeBody(); |
2027 | // } | ||
2028 | } | 2191 | } |
2029 | } | 2192 | } |
2030 | 2193 | ||
@@ -2133,17 +2296,52 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2133 | if (!childPrim && Body != IntPtr.Zero) | 2296 | if (!childPrim && Body != IntPtr.Zero) |
2134 | d.BodyDisable(Body); | 2297 | d.BodyDisable(Body); |
2135 | 2298 | ||
2136 | if (m_delaySelect) | 2299 | if (m_delaySelect || m_isphysical) |
2137 | { | 2300 | { |
2301 | m_collisionCategories = CollisionCategories.Selected; | ||
2302 | m_collisionFlags = (CollisionCategories.Sensor | CollisionCategories.Space); | ||
2303 | |||
2138 | if (!childPrim) | 2304 | if (!childPrim) |
2139 | { | 2305 | { |
2140 | foreach (OdePrim prm in childrenPrim) | 2306 | foreach (OdePrim prm in childrenPrim) |
2141 | { | 2307 | { |
2142 | d.GeomDisable(prm.prim_geom); | 2308 | prm.m_collisionCategories = m_collisionCategories; |
2309 | prm.m_collisionFlags = m_collisionFlags; | ||
2310 | |||
2311 | if (prm.prim_geom != null) | ||
2312 | { | ||
2313 | |||
2314 | if (prm.m_NoColide) | ||
2315 | { | ||
2316 | d.GeomSetCategoryBits(prm.prim_geom, 0); | ||
2317 | d.GeomSetCollideBits(prm.prim_geom, 0); | ||
2318 | } | ||
2319 | else | ||
2320 | { | ||
2321 | d.GeomSetCategoryBits(prm.prim_geom, (int)m_collisionCategories); | ||
2322 | d.GeomSetCollideBits(prm.prim_geom, (int)m_collisionFlags); | ||
2323 | } | ||
2324 | d.GeomDisable(prm.prim_geom); | ||
2325 | } | ||
2143 | prm.m_delaySelect = false; | 2326 | prm.m_delaySelect = false; |
2144 | } | 2327 | } |
2145 | } | 2328 | } |
2146 | d.GeomDisable(prim_geom); | 2329 | |
2330 | if (prim_geom != null) | ||
2331 | { | ||
2332 | if (m_NoColide) | ||
2333 | { | ||
2334 | d.GeomSetCategoryBits(prim_geom, 0); | ||
2335 | d.GeomSetCollideBits(prim_geom, 0); | ||
2336 | } | ||
2337 | else | ||
2338 | { | ||
2339 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
2340 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
2341 | } | ||
2342 | d.GeomDisable(prim_geom); | ||
2343 | } | ||
2344 | |||
2147 | m_delaySelect = false; | 2345 | m_delaySelect = false; |
2148 | } | 2346 | } |
2149 | else | 2347 | else |
@@ -2156,19 +2354,64 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2156 | if (!childPrim && Body != IntPtr.Zero && !m_disabled) | 2354 | if (!childPrim && Body != IntPtr.Zero && !m_disabled) |
2157 | d.BodyEnable(Body); | 2355 | d.BodyEnable(Body); |
2158 | 2356 | ||
2357 | m_collisionCategories = CollisionCategories.Geom; | ||
2358 | if (m_isphysical) | ||
2359 | m_collisionCategories |= CollisionCategories.Body; | ||
2360 | |||
2361 | m_collisionFlags = m_default_collisionFlags | CollisionCategories.Land; | ||
2362 | |||
2363 | if (m_collidesWater) | ||
2364 | m_collisionFlags |= CollisionCategories.Water; | ||
2365 | |||
2159 | if (!childPrim) | 2366 | if (!childPrim) |
2160 | { | 2367 | { |
2161 | foreach (OdePrim prm in childrenPrim) | 2368 | foreach (OdePrim prm in childrenPrim) |
2162 | { | 2369 | { |
2163 | if(!prm.m_disabled) | 2370 | prm.m_collisionCategories = m_collisionCategories; |
2371 | prm.m_collisionFlags = m_collisionFlags; | ||
2372 | |||
2373 | if (!prm.m_disabled && prm.prim_geom != IntPtr.Zero) | ||
2374 | { | ||
2375 | if (prm.m_NoColide) | ||
2376 | { | ||
2377 | d.GeomSetCategoryBits(prm.prim_geom, 0); | ||
2378 | if (m_isphysical) | ||
2379 | d.GeomSetCollideBits(prm.prim_geom, (int)CollisionCategories.Land); | ||
2380 | else | ||
2381 | d.GeomSetCollideBits(prm.prim_geom, 0); | ||
2382 | } | ||
2383 | else | ||
2384 | { | ||
2385 | d.GeomSetCategoryBits(prm.prim_geom, (int)m_collisionCategories); | ||
2386 | d.GeomSetCollideBits(prm.prim_geom, (int)m_collisionFlags); | ||
2387 | } | ||
2164 | d.GeomEnable(prm.prim_geom); | 2388 | d.GeomEnable(prm.prim_geom); |
2389 | } | ||
2165 | prm.m_delaySelect = false; | 2390 | prm.m_delaySelect = false; |
2391 | prm.m_softcolide = true; | ||
2166 | } | 2392 | } |
2167 | } | 2393 | } |
2168 | if(!m_disabled) | 2394 | |
2395 | if (!m_disabled && prim_geom != IntPtr.Zero) | ||
2396 | { | ||
2397 | if (m_NoColide) | ||
2398 | { | ||
2399 | d.GeomSetCategoryBits(prim_geom, 0); | ||
2400 | if (m_isphysical) | ||
2401 | d.GeomSetCollideBits(prim_geom, (int)CollisionCategories.Land); | ||
2402 | else | ||
2403 | d.GeomSetCollideBits(prim_geom, 0); | ||
2404 | } | ||
2405 | else | ||
2406 | { | ||
2407 | d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); | ||
2408 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | ||
2409 | } | ||
2169 | d.GeomEnable(prim_geom); | 2410 | d.GeomEnable(prim_geom); |
2411 | } | ||
2170 | 2412 | ||
2171 | m_delaySelect = false; | 2413 | m_delaySelect = false; |
2414 | m_softcolide = true; | ||
2172 | } | 2415 | } |
2173 | 2416 | ||
2174 | resetCollisionAccounting(); | 2417 | resetCollisionAccounting(); |
@@ -2214,6 +2457,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2214 | if (givefakepos < 0) | 2457 | if (givefakepos < 0) |
2215 | givefakepos = 0; | 2458 | givefakepos = 0; |
2216 | // changeSelectedStatus(); | 2459 | // changeSelectedStatus(); |
2460 | m_softcolide = true; | ||
2217 | resetCollisionAccounting(); | 2461 | resetCollisionAccounting(); |
2218 | } | 2462 | } |
2219 | 2463 | ||
@@ -2266,6 +2510,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2266 | givefakeori--; | 2510 | givefakeori--; |
2267 | if (givefakeori < 0) | 2511 | if (givefakeori < 0) |
2268 | givefakeori = 0; | 2512 | givefakeori = 0; |
2513 | m_softcolide = true; | ||
2269 | resetCollisionAccounting(); | 2514 | resetCollisionAccounting(); |
2270 | } | 2515 | } |
2271 | 2516 | ||
@@ -2336,6 +2581,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2336 | if (givefakeori < 0) | 2581 | if (givefakeori < 0) |
2337 | givefakeori = 0; | 2582 | givefakeori = 0; |
2338 | 2583 | ||
2584 | m_softcolide = true; | ||
2339 | resetCollisionAccounting(); | 2585 | resetCollisionAccounting(); |
2340 | } | 2586 | } |
2341 | 2587 | ||
@@ -2390,8 +2636,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2390 | else | 2636 | else |
2391 | */ | 2637 | */ |
2392 | DestroyBody(); | 2638 | DestroyBody(); |
2393 | Stop(); | ||
2394 | } | 2639 | } |
2640 | Stop(); | ||
2395 | } | 2641 | } |
2396 | } | 2642 | } |
2397 | 2643 | ||
@@ -2452,6 +2698,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2452 | else | 2698 | else |
2453 | MakeBody(); | 2699 | MakeBody(); |
2454 | 2700 | ||
2701 | m_softcolide = true; | ||
2455 | resetCollisionAccounting(); | 2702 | resetCollisionAccounting(); |
2456 | } | 2703 | } |
2457 | 2704 | ||
@@ -2576,7 +2823,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2576 | if ((bool)newbuilding) | 2823 | if ((bool)newbuilding) |
2577 | { | 2824 | { |
2578 | m_building = true; | 2825 | m_building = true; |
2579 | DestroyBody(); | 2826 | if (!childPrim) |
2827 | DestroyBody(); | ||
2580 | } | 2828 | } |
2581 | else | 2829 | else |
2582 | { | 2830 | { |
@@ -2648,12 +2896,95 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2648 | public void Move() | 2896 | public void Move() |
2649 | { | 2897 | { |
2650 | if (!childPrim && m_isphysical && Body != IntPtr.Zero && | 2898 | if (!childPrim && m_isphysical && Body != IntPtr.Zero && |
2651 | !m_disabled && !m_isSelected && d.BodyIsEnabled(Body) && !m_building) // KF: Only move root prims. | 2899 | !m_disabled && !m_isSelected && d.BodyIsEnabled(Body) && !m_building && !m_outbounds) |
2900 | // !m_disabled && !m_isSelected && !m_building && !m_outbounds) | ||
2652 | { | 2901 | { |
2653 | // if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009 | 2902 | // if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009 |
2654 | 2903 | ||
2655 | float timestep = _parent_scene.ODE_STEPSIZE; | 2904 | float timestep = _parent_scene.ODE_STEPSIZE; |
2656 | 2905 | ||
2906 | // check outside region | ||
2907 | d.Vector3 lpos; | ||
2908 | d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator | ||
2909 | |||
2910 | if (lpos.Z < -100 || lpos.Z > 100000f) | ||
2911 | { | ||
2912 | m_outbounds = true; | ||
2913 | |||
2914 | lpos.Z = Util.Clip(lpos.Z, -100f, 100000f); | ||
2915 | _acceleration.X = 0; | ||
2916 | _acceleration.Y = 0; | ||
2917 | _acceleration.Z = 0; | ||
2918 | |||
2919 | _velocity.X = 0; | ||
2920 | _velocity.Y = 0; | ||
2921 | _velocity.Z = 0; | ||
2922 | m_rotationalVelocity.X = 0; | ||
2923 | m_rotationalVelocity.Y = 0; | ||
2924 | m_rotationalVelocity.Z = 0; | ||
2925 | |||
2926 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
2927 | d.BodySetAngularVel(Body, 0, 0, 0); // stop it | ||
2928 | d.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere | ||
2929 | m_lastposition = _position; | ||
2930 | m_lastorientation = _orientation; | ||
2931 | |||
2932 | base.RequestPhysicsterseUpdate(); | ||
2933 | |||
2934 | m_throttleUpdates = false; | ||
2935 | throttleCounter = 0; | ||
2936 | _zeroFlag = true; | ||
2937 | |||
2938 | disableBodySoft(); // disable it and colisions | ||
2939 | base.RaiseOutOfBounds(_position); | ||
2940 | return; | ||
2941 | } | ||
2942 | |||
2943 | if (lpos.X < 0f) | ||
2944 | { | ||
2945 | _position.X = Util.Clip(lpos.X, -2f, -0.1f); | ||
2946 | m_outbounds = true; | ||
2947 | } | ||
2948 | else if(lpos.X > _parent_scene.WorldExtents.X) | ||
2949 | { | ||
2950 | _position.X = Util.Clip(lpos.X, _parent_scene.WorldExtents.X + 0.1f, _parent_scene.WorldExtents.X + 2f); | ||
2951 | m_outbounds = true; | ||
2952 | } | ||
2953 | if (lpos.Y < 0f) | ||
2954 | { | ||
2955 | _position.Y = Util.Clip(lpos.Y, -2f, -0.1f); | ||
2956 | m_outbounds = true; | ||
2957 | } | ||
2958 | else if(lpos.Y > _parent_scene.WorldExtents.Y) | ||
2959 | { | ||
2960 | _position.Y = Util.Clip(lpos.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f); | ||
2961 | m_outbounds = true; | ||
2962 | } | ||
2963 | |||
2964 | if(m_outbounds) | ||
2965 | { | ||
2966 | m_lastposition = _position; | ||
2967 | m_lastorientation = _orientation; | ||
2968 | |||
2969 | d.Vector3 dtmp = d.BodyGetAngularVel(Body); | ||
2970 | m_rotationalVelocity.X = dtmp.X; | ||
2971 | m_rotationalVelocity.Y = dtmp.Y; | ||
2972 | m_rotationalVelocity.Z = dtmp.Z; | ||
2973 | |||
2974 | dtmp = d.BodyGetLinearVel(Body); | ||
2975 | _velocity.X = dtmp.X; | ||
2976 | _velocity.Y = dtmp.Y; | ||
2977 | _velocity.Z = dtmp.Z; | ||
2978 | |||
2979 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
2980 | d.BodySetAngularVel(Body, 0, 0, 0); | ||
2981 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
2982 | disableBodySoft(); // stop collisions | ||
2983 | base.RequestPhysicsterseUpdate(); | ||
2984 | return; | ||
2985 | } | ||
2986 | |||
2987 | |||
2657 | float fx = 0; | 2988 | float fx = 0; |
2658 | float fy = 0; | 2989 | float fy = 0; |
2659 | float fz = 0; | 2990 | float fz = 0; |
@@ -2862,7 +3193,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2862 | public void UpdatePositionAndVelocity(float simulatedtime) | 3193 | public void UpdatePositionAndVelocity(float simulatedtime) |
2863 | { | 3194 | { |
2864 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! | 3195 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! |
2865 | if (_parent == null && !m_disabled && !m_building) | 3196 | if (_parent == null && !m_disabled && !m_building && !m_outbounds) |
2866 | { | 3197 | { |
2867 | if (Body != IntPtr.Zero) | 3198 | if (Body != IntPtr.Zero) |
2868 | { | 3199 | { |
@@ -2872,64 +3203,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2872 | d.Vector3 lpos; | 3203 | d.Vector3 lpos; |
2873 | d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator | 3204 | d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator |
2874 | 3205 | ||
2875 | // we need to use root position since that's all the rest of scene uses | ||
2876 | if (lpos.X < 0f || lpos.X > _parent_scene.WorldExtents.X | ||
2877 | || lpos.Y < 0f || lpos.Y > _parent_scene.WorldExtents.Y | ||
2878 | ) | ||
2879 | { | ||
2880 | // we are outside current region | ||
2881 | // we can't let it keeping moving and having colisions | ||
2882 | // since it can be stucked between something like terrain and edge | ||
2883 | // so lets stop and disable it until something else kicks it | ||
2884 | |||
2885 | _position.X = Util.Clip(lpos.X, -0.2f, _parent_scene.WorldExtents.X + 0.2f); | ||
2886 | _position.Y = Util.Clip(lpos.Y, -0.2f, _parent_scene.WorldExtents.Y + 0.2f); | ||
2887 | _position.Z = Util.Clip(lpos.Z, -100f, 50000f); | ||
2888 | |||
2889 | m_lastposition = _position; | ||
2890 | // m_lastorientation = _orientation; | ||
2891 | |||
2892 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
2893 | // d.BodySetAngularVel(Body, 0, 0, 0); | ||
2894 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
2895 | disableBodySoft(); // stop collisions | ||
2896 | m_outbounds = true; | ||
2897 | base.RequestPhysicsterseUpdate(); | ||
2898 | return; | ||
2899 | } | ||
2900 | |||
2901 | if (lpos.Z < -100 || lpos.Z > 100000f) | ||
2902 | { | ||
2903 | lpos.Z = Util.Clip(lpos.Z, -100f, 50000f); | ||
2904 | |||
2905 | _acceleration.X = 0; | ||
2906 | _acceleration.Y = 0; | ||
2907 | _acceleration.Z = 0; | ||
2908 | |||
2909 | _velocity.X = 0; | ||
2910 | _velocity.Y = 0; | ||
2911 | _velocity.Z = 0; | ||
2912 | m_rotationalVelocity.X = 0; | ||
2913 | m_rotationalVelocity.Y = 0; | ||
2914 | m_rotationalVelocity.Z = 0; | ||
2915 | |||
2916 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
2917 | d.BodySetAngularVel(Body, 0, 0, 0); // stop it | ||
2918 | d.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere | ||
2919 | m_lastposition = _position; | ||
2920 | m_lastorientation = _orientation; | ||
2921 | |||
2922 | base.RequestPhysicsterseUpdate(); | ||
2923 | |||
2924 | m_throttleUpdates = false; | ||
2925 | throttleCounter = 0; | ||
2926 | _zeroFlag = true; | ||
2927 | |||
2928 | disableBodySoft(); // disable it and colisions | ||
2929 | base.RaiseOutOfBounds(_position); | ||
2930 | |||
2931 | return; | ||
2932 | } | ||
2933 | 3206 | ||
2934 | d.Quaternion ori; | 3207 | d.Quaternion ori; |
2935 | d.GeomCopyQuaternion(prim_geom, out ori); | 3208 | d.GeomCopyQuaternion(prim_geom, out ori); |