diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 398 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 150 |
2 files changed, 235 insertions, 313 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 5d9b169..a2c0c6b 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -161,22 +161,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
161 | m_density = parent_scene.geomDefaultDensity; | 161 | m_density = parent_scene.geomDefaultDensity; |
162 | m_tensor = parent_scene.bodyMotorJointMaxforceTensor; | 162 | m_tensor = parent_scene.bodyMotorJointMaxforceTensor; |
163 | body_autodisable_frames = parent_scene.bodyFramesAutoDisable; | 163 | body_autodisable_frames = parent_scene.bodyFramesAutoDisable; |
164 | //if (_position.X > 257) | 164 | |
165 | //{ | ||
166 | //_position.X = 257; | ||
167 | //} | ||
168 | //if (_position.X < 0) | ||
169 | //{ | ||
170 | //_position.X = 0; | ||
171 | //} | ||
172 | //if (_position.Y > 257) | ||
173 | //{ | ||
174 | //_position.Y = 257; | ||
175 | //} | ||
176 | //if (_position.Y < 0) | ||
177 | //{ | ||
178 | // _position.Y = 0; | ||
179 | //} | ||
180 | 165 | ||
181 | prim_geom = (IntPtr)0; | 166 | prim_geom = (IntPtr)0; |
182 | prev_geom = (IntPtr)0; | 167 | prev_geom = (IntPtr)0; |
@@ -715,14 +700,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
715 | oldMesh = null; | 700 | oldMesh = null; |
716 | } | 701 | } |
717 | 702 | ||
718 | if (IsPhysical && Body == (IntPtr) 0) | 703 | // if (IsPhysical && Body == (IntPtr) 0) |
719 | { | 704 | // { |
720 | // Recreate the body | 705 | // Recreate the body |
721 | m_interpenetrationcount = 0; | 706 | // m_interpenetrationcount = 0; |
722 | m_collisionscore = 0; | 707 | // m_collisionscore = 0; |
723 | 708 | ||
724 | enableBody(); | 709 | // enableBody(); |
725 | } | 710 | // } |
726 | } | 711 | } |
727 | 712 | ||
728 | public void ProcessTaints(float timestep) | 713 | public void ProcessTaints(float timestep) |
@@ -775,7 +760,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
775 | } | 760 | } |
776 | else | 761 | else |
777 | { | 762 | { |
778 | m_log.Error("[PHYSICS]: The scene reused a disposed PhysActor! *waves finger*, Don't be evil."); | 763 | m_log.Error("[PHYSICS]: The scene reused a disposed PhysActor! *waves finger*, Don't be evil. A couple of things can cause this. An improper prim breakdown(be sure to set prim_geom to zero after d.GeomDestroy! An improper buildup (creating the geom failed). Or, the Scene Reused a physics actor after disposing it.)"); |
779 | } | 764 | } |
780 | } | 765 | } |
781 | 766 | ||
@@ -910,69 +895,30 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
910 | m_taintVelocity = PhysicsVector.Zero; | 895 | m_taintVelocity = PhysicsVector.Zero; |
911 | } | 896 | } |
912 | 897 | ||
913 | public void changeadd(float timestep) | 898 | public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) |
914 | { | 899 | { |
915 | int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position); | 900 | if (_mesh != null) |
916 | IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position); | ||
917 | |||
918 | if (targetspace == IntPtr.Zero) | ||
919 | targetspace = _parent_scene.createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]); | ||
920 | |||
921 | m_targetSpace = targetspace; | ||
922 | |||
923 | if (_mesh == null) | ||
924 | { | 901 | { |
925 | if (_parent_scene.needsMeshing(_pbs)) | 902 | setMesh(_parent_scene, _mesh); |
926 | { | ||
927 | // Don't need to re-enable body.. it's done in SetMesh | ||
928 | _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical); | ||
929 | // createmesh returns null when it's a shape that isn't a cube. | ||
930 | } | ||
931 | } | 903 | } |
932 | 904 | else | |
933 | //if (_mesh == null ) | ||
934 | // _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical); | ||
935 | |||
936 | |||
937 | lock (OdeScene.OdeLock) | ||
938 | { | 905 | { |
939 | if (_mesh != null) | 906 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) |
940 | { | ||
941 | setMesh(_parent_scene, _mesh); | ||
942 | } | ||
943 | else | ||
944 | { | 907 | { |
945 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) | 908 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) |
946 | { | 909 | { |
947 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | 910 | if (((_size.X / 2f) > 0f)) |
948 | { | 911 | { |
949 | if (((_size.X / 2f) > 0f)) | 912 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
913 | try | ||
950 | { | 914 | { |
951 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 915 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); |
952 | try | ||
953 | { | ||
954 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); | ||
955 | } | ||
956 | catch (AccessViolationException) | ||
957 | { | ||
958 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); | ||
959 | ode.dunlock(_parent_scene.world); | ||
960 | return; | ||
961 | } | ||
962 | } | 916 | } |
963 | else | 917 | catch (AccessViolationException) |
964 | { | 918 | { |
965 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 919 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); |
966 | try | 920 | ode.dunlock(_parent_scene.world); |
967 | { | 921 | return; |
968 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
969 | } | ||
970 | catch (AccessViolationException) | ||
971 | { | ||
972 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); | ||
973 | ode.dunlock(_parent_scene.world); | ||
974 | return; | ||
975 | } | ||
976 | } | 922 | } |
977 | } | 923 | } |
978 | else | 924 | else |
@@ -980,7 +926,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
980 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 926 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
981 | try | 927 | try |
982 | { | 928 | { |
983 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | 929 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
984 | } | 930 | } |
985 | catch (AccessViolationException) | 931 | catch (AccessViolationException) |
986 | { | 932 | { |
@@ -990,18 +936,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
990 | } | 936 | } |
991 | } | 937 | } |
992 | } | 938 | } |
993 | //else if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight) | ||
994 | //{ | ||
995 | //Cyllinder | ||
996 | //if (_size.X == _size.Y) | ||
997 | //{ | ||
998 | //prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z); | ||
999 | //} | ||
1000 | //else | ||
1001 | //{ | ||
1002 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
1003 | //} | ||
1004 | //} | ||
1005 | else | 939 | else |
1006 | { | 940 | { |
1007 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 941 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
@@ -1017,6 +951,49 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1017 | } | 951 | } |
1018 | } | 952 | } |
1019 | } | 953 | } |
954 | |||
955 | else | ||
956 | { | ||
957 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
958 | try | ||
959 | { | ||
960 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
961 | } | ||
962 | catch (AccessViolationException) | ||
963 | { | ||
964 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); | ||
965 | ode.dunlock(_parent_scene.world); | ||
966 | return; | ||
967 | } | ||
968 | } | ||
969 | } | ||
970 | } | ||
971 | |||
972 | public void changeadd(float timestep) | ||
973 | { | ||
974 | int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position); | ||
975 | IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position); | ||
976 | |||
977 | if (targetspace == IntPtr.Zero) | ||
978 | targetspace = _parent_scene.createprimspace(iprimspaceArrItem[0], iprimspaceArrItem[1]); | ||
979 | |||
980 | m_targetSpace = targetspace; | ||
981 | |||
982 | if (_mesh == null) | ||
983 | { | ||
984 | if (_parent_scene.needsMeshing(_pbs)) | ||
985 | { | ||
986 | // Don't need to re-enable body.. it's done in SetMesh | ||
987 | _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical); | ||
988 | // createmesh returns null when it's a shape that isn't a cube. | ||
989 | } | ||
990 | } | ||
991 | |||
992 | |||
993 | lock (OdeScene.OdeLock) | ||
994 | { | ||
995 | CreateGeom(m_targetSpace, _mesh); | ||
996 | |||
1020 | if (prim_geom != (IntPtr) 0) | 997 | if (prim_geom != (IntPtr) 0) |
1021 | { | 998 | { |
1022 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 999 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
@@ -1277,8 +1254,22 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1277 | { | 1254 | { |
1278 | if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim) | 1255 | if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim) |
1279 | { | 1256 | { |
1257 | |||
1258 | |||
1280 | if (prim_geom != IntPtr.Zero) | 1259 | if (prim_geom != IntPtr.Zero) |
1281 | d.GeomDestroy(prim_geom); | 1260 | { |
1261 | try | ||
1262 | { | ||
1263 | d.GeomDestroy(prim_geom); | ||
1264 | prim_geom = IntPtr.Zero; | ||
1265 | _mesh = null; | ||
1266 | } | ||
1267 | catch (System.AccessViolationException) | ||
1268 | { | ||
1269 | prim_geom = IntPtr.Zero; | ||
1270 | m_log.Error("[PHYSICS]: PrimGeom dead"); | ||
1271 | } | ||
1272 | } | ||
1282 | 1273 | ||
1283 | changeadd(2f); | 1274 | changeadd(2f); |
1284 | } | 1275 | } |
@@ -1340,66 +1331,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1340 | 1331 | ||
1341 | //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); | 1332 | //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); |
1342 | 1333 | ||
1343 | if (mesh != null) | 1334 | CreateGeom(m_targetSpace, mesh); |
1344 | { | ||
1345 | setMesh(_parent_scene, mesh); | ||
1346 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
1347 | d.Quaternion myrot = new d.Quaternion(); | ||
1348 | myrot.X = _orientation.X; | ||
1349 | myrot.Y = _orientation.Y; | ||
1350 | myrot.Z = _orientation.Z; | ||
1351 | myrot.W = _orientation.W; | ||
1352 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
1353 | 1335 | ||
1354 | //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | 1336 | |
1355 | if (IsPhysical && Body == (IntPtr)0) | 1337 | } |
1356 | { | 1338 | else |
1357 | // Re creates body on size. | 1339 | { |
1358 | // EnableBody also does setMass() | 1340 | _mesh = null; |
1359 | enableBody(); | 1341 | CreateGeom(m_targetSpace, _mesh); |
1360 | d.BodyEnable(Body); | 1342 | } |
1361 | } | ||
1362 | } | ||
1363 | else | ||
1364 | { | ||
1365 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) | ||
1366 | { | ||
1367 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | ||
1368 | { | ||
1369 | if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000)) | ||
1370 | { | ||
1371 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1372 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); | ||
1373 | } | ||
1374 | else | ||
1375 | { | ||
1376 | m_log.Info("[PHYSICS]: Failed to load a sphere bad size"); | ||
1377 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1378 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
1379 | } | ||
1380 | 1343 | ||
1381 | } | 1344 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
1382 | else | 1345 | d.Quaternion myrot = new d.Quaternion(); |
1383 | { | 1346 | myrot.X = _orientation.X; |
1384 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1347 | myrot.Y = _orientation.Y; |
1385 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | 1348 | myrot.Z = _orientation.Z; |
1386 | } | 1349 | myrot.W = _orientation.W; |
1387 | } | 1350 | d.GeomSetQuaternion(prim_geom, ref myrot); |
1388 | 1351 | ||
1389 | else | 1352 | //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); |
1390 | { | 1353 | if (IsPhysical && Body == (IntPtr)0) |
1391 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1354 | { |
1392 | SetGeom(prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | 1355 | // Re creates body on size. |
1393 | } | 1356 | // EnableBody also does setMass() |
1394 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 1357 | enableBody(); |
1395 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 1358 | d.BodyEnable(Body); |
1396 | d.Quaternion myrot = new d.Quaternion(); | ||
1397 | myrot.X = _orientation.X; | ||
1398 | myrot.Y = _orientation.Y; | ||
1399 | myrot.Z = _orientation.Z; | ||
1400 | myrot.W = _orientation.W; | ||
1401 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
1402 | } | ||
1403 | } | 1359 | } |
1404 | 1360 | ||
1405 | _parent_scene.geom_name_map[prim_geom] = oldname; | 1361 | _parent_scene.geom_name_map[prim_geom] = oldname; |
@@ -1609,7 +1565,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1609 | { | 1565 | { |
1610 | disableBody(); | 1566 | disableBody(); |
1611 | } | 1567 | } |
1612 | d.GeomDestroy(prim_geom); | 1568 | try |
1569 | { | ||
1570 | d.GeomDestroy(prim_geom); | ||
1571 | } | ||
1572 | catch (System.AccessViolationException) | ||
1573 | { | ||
1574 | prim_geom = IntPtr.Zero; | ||
1575 | m_log.Error("[PHYSICS]: PrimGeom dead"); | ||
1576 | } | ||
1613 | prim_geom = (IntPtr) 0; | 1577 | prim_geom = (IntPtr) 0; |
1614 | // we don't need to do space calculation because the client sends a position update also. | 1578 | // we don't need to do space calculation because the client sends a position update also. |
1615 | if (_size.X <= 0) _size.X = 0.01f; | 1579 | if (_size.X <= 0) _size.X = 0.01f; |
@@ -1626,128 +1590,32 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1626 | meshlod = _parent_scene.MeshSculptphysicalLOD; | 1590 | meshlod = _parent_scene.MeshSculptphysicalLOD; |
1627 | 1591 | ||
1628 | IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); | 1592 | IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); |
1629 | // createmesh returns null when it's a shape that isn't a cube. | 1593 | // createmesh returns null when it doesn't mesh. |
1630 | if (mesh != null) | 1594 | CreateGeom(m_targetSpace, mesh); |
1631 | { | ||
1632 | setMesh(_parent_scene, mesh); | ||
1633 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
1634 | d.Quaternion myrot = new d.Quaternion(); | ||
1635 | myrot.X = _orientation.X; | ||
1636 | myrot.Y = _orientation.Y; | ||
1637 | myrot.Z = _orientation.Z; | ||
1638 | myrot.W = _orientation.W; | ||
1639 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
1640 | |||
1641 | //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | ||
1642 | if (IsPhysical && Body == (IntPtr)0) | ||
1643 | { | ||
1644 | // Re creates body on size. | ||
1645 | // EnableBody also does setMass() | ||
1646 | enableBody(); | ||
1647 | } | ||
1648 | } | ||
1649 | else | ||
1650 | { | ||
1651 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) | ||
1652 | { | ||
1653 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | ||
1654 | { | ||
1655 | if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000)) | ||
1656 | { | ||
1657 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1658 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); | ||
1659 | } | ||
1660 | else | ||
1661 | { | ||
1662 | m_log.Info("[PHYSICS]: Failed to load a sphere bad size"); | ||
1663 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1664 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
1665 | } | ||
1666 | } | ||
1667 | else | ||
1668 | { | ||
1669 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1670 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
1671 | } | ||
1672 | } | ||
1673 | //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) | ||
1674 | //{ | ||
1675 | //Cyllinder | ||
1676 | //if (_size.X == _size.Y) | ||
1677 | //{ | ||
1678 | // prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z); | ||
1679 | //} | ||
1680 | //else | ||
1681 | //{ | ||
1682 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
1683 | //} | ||
1684 | //} | ||
1685 | else | ||
1686 | { | ||
1687 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1688 | SetGeom(prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
1689 | } | ||
1690 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
1691 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
1692 | d.Quaternion myrot = new d.Quaternion(); | ||
1693 | myrot.X = _orientation.X; | ||
1694 | myrot.Y = _orientation.Y; | ||
1695 | myrot.Z = _orientation.Z; | ||
1696 | myrot.W = _orientation.W; | ||
1697 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
1698 | } | ||
1699 | } | 1595 | } |
1700 | else | 1596 | else |
1701 | { | 1597 | { |
1702 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) | 1598 | _mesh = null; |
1703 | { | 1599 | CreateGeom(m_targetSpace, null); |
1704 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | ||
1705 | { | ||
1706 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1707 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); | ||
1708 | } | ||
1709 | else | ||
1710 | { | ||
1711 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1712 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
1713 | } | ||
1714 | } | ||
1715 | //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) | ||
1716 | //{ | ||
1717 | //Cyllinder | ||
1718 | //if (_size.X == _size.Y) | ||
1719 | //{ | ||
1720 | //prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z); | ||
1721 | //} | ||
1722 | //else | ||
1723 | //{ | ||
1724 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | ||
1725 | //} | ||
1726 | //} | ||
1727 | else | ||
1728 | { | ||
1729 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
1730 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); | ||
1731 | } | ||
1732 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
1733 | d.Quaternion myrot = new d.Quaternion(); | ||
1734 | //myrot.W = _orientation.w; | ||
1735 | myrot.W = _orientation.W; | ||
1736 | myrot.X = _orientation.X; | ||
1737 | myrot.Y = _orientation.Y; | ||
1738 | myrot.Z = _orientation.Z; | ||
1739 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
1740 | |||
1741 | //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | ||
1742 | if (IsPhysical && Body == (IntPtr)0) | ||
1743 | { | ||
1744 | // Re creates body on size. | ||
1745 | // EnableBody also does setMass() | ||
1746 | enableBody(); | ||
1747 | d.BodyEnable(Body); | ||
1748 | } | ||
1749 | } | 1600 | } |
1750 | 1601 | ||
1602 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
1603 | d.Quaternion myrot = new d.Quaternion(); | ||
1604 | //myrot.W = _orientation.w; | ||
1605 | myrot.W = _orientation.W; | ||
1606 | myrot.X = _orientation.X; | ||
1607 | myrot.Y = _orientation.Y; | ||
1608 | myrot.Z = _orientation.Z; | ||
1609 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
1610 | |||
1611 | //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | ||
1612 | if (IsPhysical && Body == (IntPtr)0) | ||
1613 | { | ||
1614 | // Re creates body on size. | ||
1615 | // EnableBody also does setMass() | ||
1616 | enableBody(); | ||
1617 | d.BodyEnable(Body); | ||
1618 | } | ||
1751 | _parent_scene.geom_name_map[prim_geom] = oldname; | 1619 | _parent_scene.geom_name_map[prim_geom] = oldname; |
1752 | 1620 | ||
1753 | changeSelectedStatus(timestamp); | 1621 | changeSelectedStatus(timestamp); |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 9d6b773..2676def 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -1042,6 +1042,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1042 | 1042 | ||
1043 | lock (_activeprims) | 1043 | lock (_activeprims) |
1044 | { | 1044 | { |
1045 | List<OdePrim> removeprims = null; | ||
1045 | foreach (OdePrim chr in _activeprims) | 1046 | foreach (OdePrim chr in _activeprims) |
1046 | { | 1047 | { |
1047 | if (d.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) | 1048 | if (d.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) |
@@ -1056,7 +1057,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1056 | } | 1057 | } |
1057 | else | 1058 | else |
1058 | { | 1059 | { |
1059 | m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed"); | 1060 | if (removeprims == null) |
1061 | { | ||
1062 | removeprims = new List<OdePrim>(); | ||
1063 | } | ||
1064 | removeprims.Add(chr); | ||
1065 | m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed. Removed it from the active prim list. This needs to be fixed!"); | ||
1060 | } | 1066 | } |
1061 | } | 1067 | } |
1062 | } | 1068 | } |
@@ -1066,6 +1072,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1066 | } | 1072 | } |
1067 | } | 1073 | } |
1068 | } | 1074 | } |
1075 | if (removeprims != null) | ||
1076 | { | ||
1077 | foreach (OdePrim chr in removeprims) | ||
1078 | { | ||
1079 | _activeprims.Remove(chr); | ||
1080 | } | ||
1081 | } | ||
1069 | } | 1082 | } |
1070 | } | 1083 | } |
1071 | 1084 | ||
@@ -1466,6 +1479,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1466 | staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero); | 1479 | staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY] = d.HashSpaceCreate(IntPtr.Zero); |
1467 | d.GeomSetCategoryBits(staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY], (int)CollisionCategories.Space); | 1480 | d.GeomSetCategoryBits(staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY], (int)CollisionCategories.Space); |
1468 | waitForSpaceUnlock(space); | 1481 | waitForSpaceUnlock(space); |
1482 | d.SpaceSetSublevel(space, 1); | ||
1469 | d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]); | 1483 | d.SpaceAdd(space, staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]); |
1470 | return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]; | 1484 | return staticPrimspace[iprimspaceArrItemX, iprimspaceArrItemY]; |
1471 | } | 1485 | } |
@@ -1522,72 +1536,112 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1522 | 1536 | ||
1523 | // //if (pbs.PathCurve == (byte)Primitive.PathCurve.Circle && pbs.ProfileCurve == (byte)Primitive.ProfileCurve.Circle && pbs.PathScaleY <= 0.75f) | 1537 | // //if (pbs.PathCurve == (byte)Primitive.PathCurve.Circle && pbs.ProfileCurve == (byte)Primitive.ProfileCurve.Circle && pbs.PathScaleY <= 0.75f) |
1524 | // //Console.WriteLine("needsMeshing: " + " pathCurve: " + pbs.PathCurve.ToString() + " profileCurve: " + pbs.ProfileCurve.ToString() + " pathScaleY: " + Primitive.UnpackPathScale(pbs.PathScaleY).ToString()); | 1538 | // //Console.WriteLine("needsMeshing: " + " pathCurve: " + pbs.PathCurve.ToString() + " profileCurve: " + pbs.ProfileCurve.ToString() + " pathScaleY: " + Primitive.UnpackPathScale(pbs.PathScaleY).ToString()); |
1539 | int iPropertiesNotSupportedDefault = 0; | ||
1540 | |||
1525 | if (pbs.SculptEntry && !meshSculptedPrim) | 1541 | if (pbs.SculptEntry && !meshSculptedPrim) |
1526 | { | 1542 | { |
1543 | #if SPAM | ||
1544 | m_log.Warn("NonMesh"); | ||
1545 | #endif | ||
1527 | return false; | 1546 | return false; |
1528 | } | 1547 | } |
1529 | 1548 | ||
1530 | // if it's a standard box or sphere with no cuts or hollows or twist, return false since ODE can use an internal representation for the prim | 1549 | // if it's a standard box or sphere with no cuts or hollows or twist, return false since ODE can use an internal representation for the prim |
1531 | //if ((pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight) | 1550 | if ((pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight) |
1532 | // || (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 | 1551 | || (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 |
1533 | // && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z)) | 1552 | && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z)) |
1534 | //{ | 1553 | { |
1535 | // if (pbs.ProfileBegin == 0 && pbs.ProfileEnd == 0 | ||
1536 | // && pbs.ProfileHollow == 0 | ||
1537 | // && pbs.PathTwist == 0 && pbs.PathTwistBegin == 0 | ||
1538 | // && pbs.PathBegin == 0 && pbs.PathEnd == 0 | ||
1539 | // //&& pbs.PathTaperX == 0 && pbs.PathTaperY == 0 | ||
1540 | // && pbs.PathScaleX == 100 && pbs.PathScaleY == 100) | ||
1541 | // return false; | ||
1542 | //} | ||
1543 | |||
1544 | // if (pbs.ProfileHollow != 0) | ||
1545 | // return true; | ||
1546 | |||
1547 | // if (((Int16)pbs.PathTwistBegin != 0) || ((Int16)pbs.PathTwist != 0)) | ||
1548 | // return true; | ||
1549 | 1554 | ||
1550 | // if ((pbs.ProfileBegin != 0) || pbs.ProfileEnd != 0) | 1555 | if (pbs.ProfileBegin == 0 && pbs.ProfileEnd == 0 |
1551 | // return true; | 1556 | && pbs.ProfileHollow == 0 |
1557 | && pbs.PathTwist == 0 && pbs.PathTwistBegin == 0 | ||
1558 | && pbs.PathBegin == 0 && pbs.PathEnd == 0 | ||
1559 | && pbs.PathTaperX == 0 && pbs.PathTaperY == 0 | ||
1560 | && pbs.PathScaleX == 100 && pbs.PathScaleY == 100) | ||
1561 | { | ||
1562 | #if SPAM | ||
1563 | m_log.Warn("NonMesh"); | ||
1564 | #endif | ||
1565 | return false; | ||
1566 | } | ||
1567 | } | ||
1552 | 1568 | ||
1553 | // if ((pbs.PathScaleX != 100) || (pbs.PathScaleY != 100)) | 1569 | if (pbs.ProfileHollow != 0) |
1554 | // return true; | 1570 | iPropertiesNotSupportedDefault++; |
1555 | 1571 | ||
1556 | // if ((pbs.PathShearX != 0) || (pbs.PathShearY != 0)) | 1572 | if (((Int16)pbs.PathTwistBegin != 0) || ((Int16)pbs.PathTwist != 0)) |
1557 | // return true; | 1573 | iPropertiesNotSupportedDefault++; |
1558 | 1574 | ||
1559 | // if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight) | 1575 | if ((pbs.ProfileBegin != 0) || pbs.ProfileEnd != 0) |
1560 | // return true; | 1576 | iPropertiesNotSupportedDefault++; |
1561 | // //if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 && (pbs.Scale.X != pbs.Scale.Y || pbs.Scale.Y != pbs.Scale.Z || pbs.Scale.Z != pbs.Scale.X)) | ||
1562 | // // return true; | ||
1563 | 1577 | ||
1564 | // if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte) Extrusion.Curve1) | 1578 | if ((pbs.PathScaleX != 100) || (pbs.PathScaleY != 100)) |
1565 | // return true; | 1579 | iPropertiesNotSupportedDefault++; |
1566 | 1580 | ||
1567 | // // test for torus | 1581 | if ((pbs.PathShearX != 0) || (pbs.PathShearY != 0)) |
1568 | // if (pbs.PathCurve == (byte)Primitive.PathCurve.Circle | 1582 | iPropertiesNotSupportedDefault++; |
1569 | // && (pbs.ProfileCurve & 0x07) == (byte)Primitive.ProfileCurve.Circle | ||
1570 | // && Primitive.UnpackPathScale(pbs.PathScaleY) <= 0.75f) | ||
1571 | // return true; | ||
1572 | 1583 | ||
1573 | // // test for tube | 1584 | if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight) |
1574 | // if (pbs.PathCurve == (byte)Primitive.PathCurve.Circle | 1585 | iPropertiesNotSupportedDefault++; |
1575 | // && (pbs.ProfileCurve & 0x07) == (byte)Primitive.ProfileCurve.EqualTriangle) | ||
1576 | // return true; | ||
1577 | 1586 | ||
1578 | // // test for ring | 1587 | if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 && (pbs.Scale.X != pbs.Scale.Y || pbs.Scale.Y != pbs.Scale.Z || pbs.Scale.Z != pbs.Scale.X)) |
1579 | // if (pbs.PathCurve == (byte)Primitive.PathCurve.Circle | 1588 | iPropertiesNotSupportedDefault++; |
1580 | // && (pbs.ProfileCurve & 0x07) == (byte)Primitive.ProfileCurve.EqualTriangle) | ||
1581 | // return true; | ||
1582 | 1589 | ||
1583 | // if (pbs.ProfileShape == ProfileShape.EquilateralTriangle) | 1590 | if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte) Extrusion.Curve1) |
1584 | // return true; | 1591 | iPropertiesNotSupportedDefault++; |
1585 | 1592 | ||
1593 | // test for torus | ||
1594 | if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.Square) | ||
1595 | { | ||
1596 | if (pbs.PathCurve == (byte)Extrusion.Curve1) | ||
1597 | { | ||
1598 | iPropertiesNotSupportedDefault++; | ||
1599 | } | ||
1600 | } | ||
1601 | else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) | ||
1602 | { | ||
1603 | if (pbs.PathCurve == (byte)Extrusion.Straight) | ||
1604 | { | ||
1605 | iPropertiesNotSupportedDefault++; | ||
1606 | } | ||
1586 | 1607 | ||
1608 | // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits | ||
1609 | else if (pbs.PathCurve == (byte)Extrusion.Curve1) | ||
1610 | { | ||
1611 | iPropertiesNotSupportedDefault++; | ||
1612 | } | ||
1613 | } | ||
1614 | else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle) | ||
1615 | { | ||
1616 | if (pbs.PathCurve == (byte)Extrusion.Curve1 || pbs.PathCurve == (byte)Extrusion.Curve2) | ||
1617 | { | ||
1618 | iPropertiesNotSupportedDefault++; | ||
1619 | } | ||
1620 | } | ||
1621 | else if ((pbs.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) | ||
1622 | { | ||
1623 | if (pbs.PathCurve == (byte)Extrusion.Straight) | ||
1624 | { | ||
1625 | iPropertiesNotSupportedDefault++; | ||
1626 | } | ||
1627 | else if (pbs.PathCurve == (byte)Extrusion.Curve1) | ||
1628 | { | ||
1629 | iPropertiesNotSupportedDefault++; | ||
1630 | } | ||
1631 | } | ||
1587 | 1632 | ||
1588 | // return false; | ||
1589 | 1633 | ||
1590 | return true; // assume the mesher will return a default shape or null and later code can deal with this | 1634 | if (iPropertiesNotSupportedDefault == 0) |
1635 | { | ||
1636 | #if SPAM | ||
1637 | m_log.Warn("NonMesh"); | ||
1638 | #endif | ||
1639 | return false; | ||
1640 | } | ||
1641 | #if SPAM | ||
1642 | m_log.Debug("Mesh"); | ||
1643 | #endif | ||
1644 | return true; | ||
1591 | } | 1645 | } |
1592 | 1646 | ||
1593 | /// <summary> | 1647 | /// <summary> |