diff options
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 189 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 123 |
2 files changed, 199 insertions, 113 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 0ccdbc0..17f38e8 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | |||
@@ -155,6 +155,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
155 | public float m_collisionscore; | 155 | public float m_collisionscore; |
156 | int m_colliderfilter = 0; | 156 | int m_colliderfilter = 0; |
157 | 157 | ||
158 | public IntPtr collide_geom; // for objects: geom if single prim space it linkset | ||
159 | |||
158 | private float m_density = 10.000006836f; // Aluminum g/cm3; | 160 | private float m_density = 10.000006836f; // Aluminum g/cm3; |
159 | 161 | ||
160 | public bool _zeroFlag; | 162 | public bool _zeroFlag; |
@@ -453,8 +455,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
453 | { | 455 | { |
454 | get | 456 | get |
455 | { | 457 | { |
456 | // Averate previous velocity with the new one so | ||
457 | // client object interpolation works a 'little' better | ||
458 | if (_zeroFlag) | 458 | if (_zeroFlag) |
459 | return Vector3.Zero; | 459 | return Vector3.Zero; |
460 | return _velocity; | 460 | return _velocity; |
@@ -833,6 +833,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
833 | body_autodisable_frames = parent_scene.bodyFramesAutoDisable; | 833 | body_autodisable_frames = parent_scene.bodyFramesAutoDisable; |
834 | 834 | ||
835 | prim_geom = IntPtr.Zero; | 835 | prim_geom = IntPtr.Zero; |
836 | collide_geom = IntPtr.Zero; | ||
836 | Body = IntPtr.Zero; | 837 | Body = IntPtr.Zero; |
837 | 838 | ||
838 | if (!size.IsFinite()) | 839 | if (!size.IsFinite()) |
@@ -1367,7 +1368,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1367 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | 1368 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
1368 | m_collisionscore = 0; | 1369 | m_collisionscore = 0; |
1369 | 1370 | ||
1370 | if (m_targetSpace != _parent_scene.ActiveSpace) | 1371 | // if (m_targetSpace != _parent_scene.ActiveSpace) |
1371 | { | 1372 | { |
1372 | if (m_targetSpace != IntPtr.Zero) | 1373 | if (m_targetSpace != IntPtr.Zero) |
1373 | { | 1374 | { |
@@ -1376,9 +1377,26 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1376 | d.SpaceRemove(m_targetSpace, prim_geom); | 1377 | d.SpaceRemove(m_targetSpace, prim_geom); |
1377 | } | 1378 | } |
1378 | 1379 | ||
1380 | // m_targetSpace = _parent_scene.ActiveSpace; | ||
1381 | // d.SpaceAdd(m_targetSpace, prim_geom); | ||
1382 | } | ||
1383 | |||
1384 | |||
1385 | if (childrenPrim.Count == 0) | ||
1386 | { | ||
1387 | collide_geom = prim_geom; | ||
1379 | m_targetSpace = _parent_scene.ActiveSpace; | 1388 | m_targetSpace = _parent_scene.ActiveSpace; |
1380 | d.SpaceAdd(m_targetSpace, prim_geom); | 1389 | d.SpaceAdd(m_targetSpace, prim_geom); |
1381 | } | 1390 | } |
1391 | else | ||
1392 | { | ||
1393 | m_targetSpace = d.HashSpaceCreate(_parent_scene.ActiveSpace); | ||
1394 | d.HashSpaceSetLevels(m_targetSpace, -2, 8); | ||
1395 | d.SpaceSetSublevel(m_targetSpace, 3); | ||
1396 | d.SpaceSetCleanup(m_targetSpace, false); | ||
1397 | d.SpaceAdd(m_targetSpace, prim_geom); | ||
1398 | collide_geom = m_targetSpace; | ||
1399 | } | ||
1382 | 1400 | ||
1383 | lock (childrenPrim) | 1401 | lock (childrenPrim) |
1384 | { | 1402 | { |
@@ -1396,15 +1414,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1396 | d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); | 1414 | d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); |
1397 | prm.m_collisionscore = 0; | 1415 | prm.m_collisionscore = 0; |
1398 | 1416 | ||
1399 | if (prm.m_targetSpace != _parent_scene.ActiveSpace) | 1417 | if (prm.m_targetSpace != m_targetSpace) |
1400 | { | 1418 | { |
1401 | if (prm.m_targetSpace != IntPtr.Zero) | 1419 | if (prm.m_targetSpace != IntPtr.Zero) |
1402 | { | 1420 | { |
1403 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1421 | _parent_scene.waitForSpaceUnlock(prm.m_targetSpace); |
1404 | if (d.SpaceQuery(prm.m_targetSpace, prm.prim_geom)) | 1422 | if (d.SpaceQuery(prm.m_targetSpace, prm.prim_geom)) |
1405 | d.SpaceRemove(prm.m_targetSpace, prm.prim_geom); | 1423 | d.SpaceRemove(prm.m_targetSpace, prm.prim_geom); |
1406 | } | 1424 | } |
1407 | prm.m_targetSpace = _parent_scene.ActiveSpace; | 1425 | prm.m_targetSpace = m_targetSpace; |
1408 | d.SpaceAdd(m_targetSpace, prm.prim_geom); | 1426 | d.SpaceAdd(m_targetSpace, prm.prim_geom); |
1409 | } | 1427 | } |
1410 | 1428 | ||
@@ -1427,8 +1445,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1427 | d.GeomDisable(prim_geom); | 1445 | d.GeomDisable(prim_geom); |
1428 | d.BodyDisable(Body); | 1446 | d.BodyDisable(Body); |
1429 | } | 1447 | } |
1448 | else | ||
1449 | { | ||
1450 | d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); | ||
1451 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); | ||
1452 | } | ||
1430 | 1453 | ||
1431 | _parent_scene.addActivePrim(this); | 1454 | _parent_scene.addActivePrim(this); |
1455 | _parent_scene.addActiveGroups(this); | ||
1432 | } | 1456 | } |
1433 | 1457 | ||
1434 | private void DestroyBody() | 1458 | private void DestroyBody() |
@@ -1473,6 +1497,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1473 | d.JointDestroy(Amotor); | 1497 | d.JointDestroy(Amotor); |
1474 | Amotor = IntPtr.Zero; | 1498 | Amotor = IntPtr.Zero; |
1475 | } | 1499 | } |
1500 | _parent_scene.remActiveGroup(this); | ||
1476 | d.BodyDestroy(Body); | 1501 | d.BodyDestroy(Body); |
1477 | } | 1502 | } |
1478 | Body = IntPtr.Zero; | 1503 | Body = IntPtr.Zero; |
@@ -2390,8 +2415,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2390 | else | 2415 | else |
2391 | */ | 2416 | */ |
2392 | DestroyBody(); | 2417 | DestroyBody(); |
2393 | Stop(); | ||
2394 | } | 2418 | } |
2419 | Stop(); | ||
2395 | } | 2420 | } |
2396 | } | 2421 | } |
2397 | 2422 | ||
@@ -2576,7 +2601,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2576 | if ((bool)newbuilding) | 2601 | if ((bool)newbuilding) |
2577 | { | 2602 | { |
2578 | m_building = true; | 2603 | m_building = true; |
2579 | DestroyBody(); | 2604 | if (!childPrim) |
2605 | DestroyBody(); | ||
2580 | } | 2606 | } |
2581 | else | 2607 | else |
2582 | { | 2608 | { |
@@ -2648,12 +2674,95 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2648 | public void Move() | 2674 | public void Move() |
2649 | { | 2675 | { |
2650 | if (!childPrim && m_isphysical && Body != IntPtr.Zero && | 2676 | if (!childPrim && m_isphysical && Body != IntPtr.Zero && |
2651 | !m_disabled && !m_isSelected && d.BodyIsEnabled(Body) && !m_building) // KF: Only move root prims. | 2677 | !m_disabled && !m_isSelected && d.BodyIsEnabled(Body) && !m_building && !m_outbounds) |
2678 | // !m_disabled && !m_isSelected && !m_building && !m_outbounds) | ||
2652 | { | 2679 | { |
2653 | // if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009 | 2680 | // if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009 |
2654 | 2681 | ||
2655 | float timestep = _parent_scene.ODE_STEPSIZE; | 2682 | float timestep = _parent_scene.ODE_STEPSIZE; |
2656 | 2683 | ||
2684 | // check outside region | ||
2685 | d.Vector3 lpos; | ||
2686 | d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator | ||
2687 | |||
2688 | if (lpos.Z < -100 || lpos.Z > 100000f) | ||
2689 | { | ||
2690 | m_outbounds = true; | ||
2691 | |||
2692 | lpos.Z = Util.Clip(lpos.Z, -100f, 100000f); | ||
2693 | _acceleration.X = 0; | ||
2694 | _acceleration.Y = 0; | ||
2695 | _acceleration.Z = 0; | ||
2696 | |||
2697 | _velocity.X = 0; | ||
2698 | _velocity.Y = 0; | ||
2699 | _velocity.Z = 0; | ||
2700 | m_rotationalVelocity.X = 0; | ||
2701 | m_rotationalVelocity.Y = 0; | ||
2702 | m_rotationalVelocity.Z = 0; | ||
2703 | |||
2704 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
2705 | d.BodySetAngularVel(Body, 0, 0, 0); // stop it | ||
2706 | d.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere | ||
2707 | m_lastposition = _position; | ||
2708 | m_lastorientation = _orientation; | ||
2709 | |||
2710 | base.RequestPhysicsterseUpdate(); | ||
2711 | |||
2712 | m_throttleUpdates = false; | ||
2713 | throttleCounter = 0; | ||
2714 | _zeroFlag = true; | ||
2715 | |||
2716 | disableBodySoft(); // disable it and colisions | ||
2717 | base.RaiseOutOfBounds(_position); | ||
2718 | return; | ||
2719 | } | ||
2720 | |||
2721 | if (lpos.X < 0f) | ||
2722 | { | ||
2723 | _position.X = Util.Clip(lpos.X, -2f, -0.1f); | ||
2724 | m_outbounds = true; | ||
2725 | } | ||
2726 | else if(lpos.X > _parent_scene.WorldExtents.X) | ||
2727 | { | ||
2728 | _position.X = Util.Clip(lpos.X, _parent_scene.WorldExtents.X + 0.1f, _parent_scene.WorldExtents.X + 2f); | ||
2729 | m_outbounds = true; | ||
2730 | } | ||
2731 | if (lpos.Y < 0f) | ||
2732 | { | ||
2733 | _position.Y = Util.Clip(lpos.Y, -2f, -0.1f); | ||
2734 | m_outbounds = true; | ||
2735 | } | ||
2736 | else if(lpos.Y > _parent_scene.WorldExtents.Y) | ||
2737 | { | ||
2738 | _position.Y = Util.Clip(lpos.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f); | ||
2739 | m_outbounds = true; | ||
2740 | } | ||
2741 | |||
2742 | if(m_outbounds) | ||
2743 | { | ||
2744 | m_lastposition = _position; | ||
2745 | m_lastorientation = _orientation; | ||
2746 | |||
2747 | d.Vector3 dtmp = d.BodyGetAngularVel(Body); | ||
2748 | m_rotationalVelocity.X = dtmp.X; | ||
2749 | m_rotationalVelocity.Y = dtmp.Y; | ||
2750 | m_rotationalVelocity.Z = dtmp.Z; | ||
2751 | |||
2752 | dtmp = d.BodyGetLinearVel(Body); | ||
2753 | _velocity.X = dtmp.X; | ||
2754 | _velocity.Y = dtmp.Y; | ||
2755 | _velocity.Z = dtmp.Z; | ||
2756 | |||
2757 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
2758 | d.BodySetAngularVel(Body, 0, 0, 0); | ||
2759 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
2760 | disableBodySoft(); // stop collisions | ||
2761 | base.RequestPhysicsterseUpdate(); | ||
2762 | return; | ||
2763 | } | ||
2764 | |||
2765 | |||
2657 | float fx = 0; | 2766 | float fx = 0; |
2658 | float fy = 0; | 2767 | float fy = 0; |
2659 | float fz = 0; | 2768 | float fz = 0; |
@@ -2862,7 +2971,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2862 | public void UpdatePositionAndVelocity(float simulatedtime) | 2971 | public void UpdatePositionAndVelocity(float simulatedtime) |
2863 | { | 2972 | { |
2864 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! | 2973 | // 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) | 2974 | if (_parent == null && !m_disabled && !m_building && !m_outbounds) |
2866 | { | 2975 | { |
2867 | if (Body != IntPtr.Zero) | 2976 | if (Body != IntPtr.Zero) |
2868 | { | 2977 | { |
@@ -2872,64 +2981,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2872 | d.Vector3 lpos; | 2981 | d.Vector3 lpos; |
2873 | d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator | 2982 | d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator |
2874 | 2983 | ||
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 | 2984 | ||
2934 | d.Quaternion ori; | 2985 | d.Quaternion ori; |
2935 | d.GeomCopyQuaternion(prim_geom, out ori); | 2986 | d.GeomCopyQuaternion(prim_geom, out ori); |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 6e4c373..ccb4c23 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -224,6 +224,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
224 | private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); | 224 | private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); |
225 | private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); | 225 | private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); |
226 | private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); | 226 | private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); |
227 | private readonly HashSet<OdePrim> _activegroups = new HashSet<OdePrim>(); | ||
227 | 228 | ||
228 | public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); | 229 | public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); |
229 | 230 | ||
@@ -1013,15 +1014,24 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1013 | 1014 | ||
1014 | } | 1015 | } |
1015 | 1016 | ||
1016 | // collide active prims with static enviroment | ||
1017 | lock (_activeprims) | 1017 | lock (_activeprims) |
1018 | { | 1018 | { |
1019 | foreach (OdePrim aprim in _activeprims) | ||
1020 | { | ||
1021 | aprim.CollisionScore = 0; | ||
1022 | aprim.IsColliding = false; | ||
1023 | } | ||
1024 | } | ||
1025 | |||
1026 | // collide active prims with static enviroment | ||
1027 | lock (_activegroups) | ||
1028 | { | ||
1019 | try | 1029 | try |
1020 | { | 1030 | { |
1021 | foreach (OdePrim prm in _activeprims) | 1031 | foreach (OdePrim prm in _activegroups) |
1022 | { | 1032 | { |
1023 | if (d.BodyIsEnabled(prm.Body)) | 1033 | if (d.BodyIsEnabled(prm.Body) && !prm.m_outbounds) |
1024 | d.SpaceCollide2(StaticSpace, prm.prim_geom, IntPtr.Zero, nearCallback); | 1034 | d.SpaceCollide2(StaticSpace, prm.collide_geom, IntPtr.Zero, nearCallback); |
1025 | } | 1035 | } |
1026 | } | 1036 | } |
1027 | catch (AccessViolationException) | 1037 | catch (AccessViolationException) |
@@ -1029,7 +1039,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1029 | m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); | 1039 | m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); |
1030 | } | 1040 | } |
1031 | } | 1041 | } |
1032 | |||
1033 | // finally colide active things amoung them | 1042 | // finally colide active things amoung them |
1034 | try | 1043 | try |
1035 | { | 1044 | { |
@@ -1039,7 +1048,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1039 | { | 1048 | { |
1040 | m_log.Warn("[PHYSICS]: Unable to collide in Active space"); | 1049 | m_log.Warn("[PHYSICS]: Unable to collide in Active space"); |
1041 | } | 1050 | } |
1042 | |||
1043 | // _perloopContact.Clear(); | 1051 | // _perloopContact.Clear(); |
1044 | } | 1052 | } |
1045 | 1053 | ||
@@ -1148,13 +1156,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1148 | 1156 | ||
1149 | public void addActivePrim(OdePrim activatePrim) | 1157 | public void addActivePrim(OdePrim activatePrim) |
1150 | { | 1158 | { |
1151 | // adds active prim.. (ones that should be iterated over in collisions_optimized | 1159 | // adds active prim.. |
1152 | lock (_activeprims) | 1160 | lock (_activeprims) |
1153 | { | 1161 | { |
1154 | if (!_activeprims.Contains(activatePrim)) | 1162 | if (!_activeprims.Contains(activatePrim)) |
1155 | _activeprims.Add(activatePrim); | 1163 | _activeprims.Add(activatePrim); |
1156 | //else | 1164 | } |
1157 | // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent"); | 1165 | } |
1166 | |||
1167 | public void addActiveGroups(OdePrim activatePrim) | ||
1168 | { | ||
1169 | lock (_activegroups) | ||
1170 | { | ||
1171 | if (!_activegroups.Contains(activatePrim)) | ||
1172 | _activegroups.Add(activatePrim); | ||
1158 | } | 1173 | } |
1159 | } | 1174 | } |
1160 | 1175 | ||
@@ -1186,6 +1201,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1186 | _activeprims.Remove(deactivatePrim); | 1201 | _activeprims.Remove(deactivatePrim); |
1187 | } | 1202 | } |
1188 | } | 1203 | } |
1204 | public void remActiveGroup(OdePrim deactivatePrim) | ||
1205 | { | ||
1206 | lock (_activegroups) | ||
1207 | { | ||
1208 | _activegroups.Remove(deactivatePrim); | ||
1209 | } | ||
1210 | } | ||
1189 | 1211 | ||
1190 | public override void RemovePrim(PhysicsActor prim) | 1212 | public override void RemovePrim(PhysicsActor prim) |
1191 | { | 1213 | { |
@@ -1258,6 +1280,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1258 | { | 1280 | { |
1259 | waitForSpaceUnlock(currentspace); | 1281 | waitForSpaceUnlock(currentspace); |
1260 | d.SpaceRemove(currentspace, geom); | 1282 | d.SpaceRemove(currentspace, geom); |
1283 | |||
1284 | if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0) | ||
1285 | { | ||
1286 | d.SpaceDestroy(currentspace); | ||
1287 | } | ||
1261 | } | 1288 | } |
1262 | else | 1289 | else |
1263 | { | 1290 | { |
@@ -1274,6 +1301,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1274 | { | 1301 | { |
1275 | waitForSpaceUnlock(currentspace); | 1302 | waitForSpaceUnlock(currentspace); |
1276 | d.SpaceRemove(currentspace, geom); | 1303 | d.SpaceRemove(currentspace, geom); |
1304 | |||
1305 | if (d.SpaceGetSublevel(currentspace) > 1 && d.SpaceGetNumGeoms(currentspace) == 0) | ||
1306 | { | ||
1307 | d.SpaceDestroy(currentspace); | ||
1308 | } | ||
1309 | |||
1277 | } | 1310 | } |
1278 | } | 1311 | } |
1279 | } | 1312 | } |
@@ -1577,42 +1610,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1577 | 1610 | ||
1578 | statchanges += Util.EnvironmentTickCountSubtract(statstart); | 1611 | statchanges += Util.EnvironmentTickCountSubtract(statstart); |
1579 | 1612 | ||
1580 | // Move characters | ||
1581 | lock (_characters) | ||
1582 | { | ||
1583 | List<OdeCharacter> defects = new List<OdeCharacter>(); | ||
1584 | foreach (OdeCharacter actor in _characters) | ||
1585 | { | ||
1586 | if (actor != null) | ||
1587 | actor.Move(ODE_STEPSIZE, defects); | ||
1588 | } | ||
1589 | if (defects.Count != 0) | ||
1590 | { | ||
1591 | foreach (OdeCharacter defect in defects) | ||
1592 | { | ||
1593 | RemoveCharacter(defect); | ||
1594 | } | ||
1595 | } | ||
1596 | } | ||
1597 | statchmove += Util.EnvironmentTickCountSubtract(statstart); | ||
1598 | |||
1599 | // Move other active objects | ||
1600 | lock (_activeprims) | ||
1601 | { | ||
1602 | foreach (OdePrim aprim in _activeprims) | ||
1603 | { | ||
1604 | aprim.CollisionScore = 0; | ||
1605 | aprim.IsColliding = false; | ||
1606 | aprim.Move(); | ||
1607 | } | ||
1608 | } | ||
1609 | |||
1610 | statactmove += Util.EnvironmentTickCountSubtract(statstart); | 1613 | statactmove += Util.EnvironmentTickCountSubtract(statstart); |
1611 | //if ((framecount % m_randomizeWater) == 0) | 1614 | //if ((framecount % m_randomizeWater) == 0) |
1612 | // randomizeWater(waterlevel); | 1615 | // randomizeWater(waterlevel); |
1613 | 1616 | ||
1614 | m_rayCastManager.ProcessQueuedRequests(); | 1617 | m_rayCastManager.ProcessQueuedRequests(); |
1615 | 1618 | ||
1619 | |||
1620 | |||
1616 | statray += Util.EnvironmentTickCountSubtract(statstart); | 1621 | statray += Util.EnvironmentTickCountSubtract(statstart); |
1617 | collision_optimized(); | 1622 | collision_optimized(); |
1618 | statcol += Util.EnvironmentTickCountSubtract(statstart); | 1623 | statcol += Util.EnvironmentTickCountSubtract(statstart); |
@@ -1642,8 +1647,35 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1642 | 1647 | ||
1643 | d.WorldQuickStep(world, ODE_STEPSIZE); | 1648 | d.WorldQuickStep(world, ODE_STEPSIZE); |
1644 | statstep += Util.EnvironmentTickCountSubtract(statstart); | 1649 | statstep += Util.EnvironmentTickCountSubtract(statstart); |
1645 | d.JointGroupEmpty(contactgroup); | 1650 | |
1646 | totjcontact += m_global_contactcount; | 1651 | // Move characters |
1652 | lock (_characters) | ||
1653 | { | ||
1654 | List<OdeCharacter> defects = new List<OdeCharacter>(); | ||
1655 | foreach (OdeCharacter actor in _characters) | ||
1656 | { | ||
1657 | if (actor != null) | ||
1658 | actor.Move(ODE_STEPSIZE, defects); | ||
1659 | } | ||
1660 | if (defects.Count != 0) | ||
1661 | { | ||
1662 | foreach (OdeCharacter defect in defects) | ||
1663 | { | ||
1664 | RemoveCharacter(defect); | ||
1665 | } | ||
1666 | } | ||
1667 | } | ||
1668 | statchmove += Util.EnvironmentTickCountSubtract(statstart); | ||
1669 | |||
1670 | // Move other active objects | ||
1671 | lock (_activegroups) | ||
1672 | { | ||
1673 | foreach (OdePrim aprim in _activegroups) | ||
1674 | { | ||
1675 | aprim.Move(); | ||
1676 | } | ||
1677 | } | ||
1678 | |||
1647 | //ode.dunlock(world); | 1679 | //ode.dunlock(world); |
1648 | } | 1680 | } |
1649 | catch (Exception e) | 1681 | catch (Exception e) |
@@ -1652,6 +1684,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1652 | // ode.dunlock(world); | 1684 | // ode.dunlock(world); |
1653 | } | 1685 | } |
1654 | 1686 | ||
1687 | d.JointGroupEmpty(contactgroup); | ||
1688 | totjcontact += m_global_contactcount; | ||
1689 | |||
1655 | step_time -= ODE_STEPSIZE; | 1690 | step_time -= ODE_STEPSIZE; |
1656 | nodeframes++; | 1691 | nodeframes++; |
1657 | } | 1692 | } |
@@ -1686,10 +1721,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1686 | } | 1721 | } |
1687 | statmovchar = Util.EnvironmentTickCountSubtract(statstart); | 1722 | statmovchar = Util.EnvironmentTickCountSubtract(statstart); |
1688 | 1723 | ||
1689 | lock (_activeprims) | 1724 | lock (_activegroups) |
1690 | { | 1725 | { |
1691 | { | 1726 | { |
1692 | foreach (OdePrim actor in _activeprims) | 1727 | foreach (OdePrim actor in _activegroups) |
1693 | { | 1728 | { |
1694 | if (actor.IsPhysical) | 1729 | if (actor.IsPhysical) |
1695 | { | 1730 | { |
@@ -1966,7 +2001,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1966 | 2001 | ||
1967 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 2002 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
1968 | d.GeomSetRotation(GroundGeom, ref R); | 2003 | d.GeomSetRotation(GroundGeom, ref R); |
1969 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f - 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f - 0.5f, 0); | 2004 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); |
1970 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); | 2005 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); |
1971 | // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); | 2006 | // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); |
1972 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | 2007 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); |