diff options
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs | 71 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 201 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 191 |
3 files changed, 299 insertions, 164 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs index c9d0909..0fabb56 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs | |||
@@ -38,7 +38,7 @@ | |||
38 | * settings use. | 38 | * settings use. |
39 | */ | 39 | */ |
40 | 40 | ||
41 | // Ubit 2012 | 41 | // Extensive change Ubit 2012 |
42 | 42 | ||
43 | using System; | 43 | using System; |
44 | using System.Collections.Generic; | 44 | using System.Collections.Generic; |
@@ -120,6 +120,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
120 | private float m_lmEfect = 0; // current linear motor eficiency | 120 | private float m_lmEfect = 0; // current linear motor eficiency |
121 | private float m_amEfect = 0; // current angular motor eficiency | 121 | private float m_amEfect = 0; // current angular motor eficiency |
122 | 122 | ||
123 | public bool EngineActive | ||
124 | { | ||
125 | get | ||
126 | { | ||
127 | if (m_lmEfect > 0.01) | ||
128 | return true; | ||
129 | return false; | ||
130 | } | ||
131 | } | ||
132 | |||
123 | 133 | ||
124 | public ODEDynamics(OdePrim rootp) | 134 | public ODEDynamics(OdePrim rootp) |
125 | { | 135 | { |
@@ -152,6 +162,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
152 | m_linearMotorTimescale = vd.m_linearMotorTimescale; | 162 | m_linearMotorTimescale = vd.m_linearMotorTimescale; |
153 | if (m_linearMotorTimescale < timestep) m_linearMotorTimescale = timestep; | 163 | if (m_linearMotorTimescale < timestep) m_linearMotorTimescale = timestep; |
154 | 164 | ||
165 | |||
155 | m_linearMotorOffset = vd.m_linearMotorOffset; | 166 | m_linearMotorOffset = vd.m_linearMotorOffset; |
156 | 167 | ||
157 | //Angular properties | 168 | //Angular properties |
@@ -614,6 +625,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
614 | return vec; | 625 | return vec; |
615 | } | 626 | } |
616 | 627 | ||
628 | private const float pi = (float)Math.PI; | ||
617 | private const float halfpi = 0.5f * (float)Math.PI; | 629 | private const float halfpi = 0.5f * (float)Math.PI; |
618 | 630 | ||
619 | public static Vector3 ubitRot2Euler(Quaternion rot) | 631 | public static Vector3 ubitRot2Euler(Quaternion rot) |
@@ -884,35 +896,64 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
884 | float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale / _pParentScene.ODE_STEPSIZE; | 896 | float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale / _pParentScene.ODE_STEPSIZE; |
885 | float ftmp2 = m_verticalAttractionEfficiency / _pParentScene.ODE_STEPSIZE; | 897 | float ftmp2 = m_verticalAttractionEfficiency / _pParentScene.ODE_STEPSIZE; |
886 | 898 | ||
887 | if (Math.Abs(roll) > 0.01) // roll | 899 | if (roll > halfpi) |
900 | roll = pi - roll; | ||
901 | else if (roll < -halfpi) | ||
902 | roll = -pi - roll; | ||
903 | |||
904 | float effroll = pitch / halfpi; | ||
905 | effroll *= effroll; | ||
906 | effroll = 1 - effroll; | ||
907 | effroll *= roll; | ||
908 | |||
909 | if (Math.Abs(effroll) > 0.01) // roll | ||
888 | { | 910 | { |
889 | torque.X -= -roll * ftmp + curLocalAngVel.X * ftmp2; | 911 | torque.X -= -effroll * ftmp + curLocalAngVel.X * ftmp2; |
890 | } | 912 | } |
891 | 913 | ||
892 | if (Math.Abs(pitch) > 0.01 && ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0)) // pitch | 914 | if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0) |
893 | { | 915 | { |
894 | torque.Y -= -pitch * ftmp + curLocalAngVel.Y * ftmp2; | 916 | float effpitch = roll / halfpi; |
917 | effpitch *= effpitch; | ||
918 | effpitch = 1 - effpitch; | ||
919 | effpitch *= pitch; | ||
920 | |||
921 | if (Math.Abs(effpitch) > 0.01) // pitch | ||
922 | { | ||
923 | torque.Y -= -effpitch * ftmp + curLocalAngVel.Y * ftmp2; | ||
924 | } | ||
895 | } | 925 | } |
896 | 926 | ||
897 | if (m_bankingEfficiency != 0 && Math.Abs(roll) > 0.01) | 927 | if (m_bankingEfficiency != 0 && Math.Abs(effroll) > 0.01) |
898 | { | 928 | { |
899 | float broll = roll * m_bankingEfficiency; ; | 929 | |
930 | float broll = effroll; | ||
931 | /* | ||
932 | if (broll > halfpi) | ||
933 | broll = pi - broll; | ||
934 | else if (broll < -halfpi) | ||
935 | broll = -pi - broll; | ||
936 | */ | ||
937 | broll *= m_bankingEfficiency; | ||
900 | if (m_bankingMix != 0) | 938 | if (m_bankingMix != 0) |
901 | { | 939 | { |
902 | float vfact = Math.Abs(curLocalVel.X) / 10.0f; | 940 | float vfact = Math.Abs(curLocalVel.X) / 10.0f; |
903 | if (vfact > 1.0f) vfact = 1.0f; | 941 | if (vfact > 1.0f) vfact = 1.0f; |
942 | |||
904 | if (curLocalVel.X >= 0) | 943 | if (curLocalVel.X >= 0) |
905 | broll *= ((1 - m_bankingMix) + vfact); | 944 | broll *= (1 + (vfact - 1) * m_bankingMix); |
906 | else | 945 | else |
907 | broll *= -((1 - m_bankingMix) + vfact); | 946 | broll *= -(1 + (vfact - 1) * m_bankingMix); |
908 | } | 947 | } |
909 | broll = (broll - curLocalAngVel.Z) / m_bankingTimescale; | ||
910 | // torque.Z += broll; | ||
911 | |||
912 | // make z rot be in world Z not local as seems to be in sl | 948 | // make z rot be in world Z not local as seems to be in sl |
913 | tmpV.X = 0; | 949 | |
914 | tmpV.Y = 0; | 950 | broll = broll / m_bankingTimescale; |
915 | tmpV.Z = broll; | 951 | |
952 | ftmp = -Math.Abs(m_bankingEfficiency) / m_bankingTimescale; | ||
953 | |||
954 | tmpV.X = ftmp * curAngVel.X; | ||
955 | tmpV.Y = ftmp * curAngVel.Y; | ||
956 | tmpV.Z = broll + ftmp * curAngVel.Z; | ||
916 | tmpV *= irotq; | 957 | tmpV *= irotq; |
917 | 958 | ||
918 | torque.X += tmpV.X; | 959 | torque.X += tmpV.X; |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 0ccdbc0..e5fa1d7 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; |
@@ -220,6 +222,18 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
220 | { | 222 | { |
221 | get | 223 | get |
222 | { | 224 | { |
225 | if (m_isphysical) | ||
226 | { | ||
227 | ODEDynamics veh; | ||
228 | if (_parent != null) | ||
229 | veh = ((OdePrim)_parent).m_vehicle; | ||
230 | else | ||
231 | veh = m_vehicle; | ||
232 | |||
233 | if (veh != null) | ||
234 | if (veh.Type != Vehicle.TYPE_NONE && veh.EngineActive) | ||
235 | return new ContactData(0, 0); | ||
236 | } | ||
223 | return primContactData; | 237 | return primContactData; |
224 | } | 238 | } |
225 | } | 239 | } |
@@ -453,8 +467,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
453 | { | 467 | { |
454 | get | 468 | get |
455 | { | 469 | { |
456 | // Averate previous velocity with the new one so | ||
457 | // client object interpolation works a 'little' better | ||
458 | if (_zeroFlag) | 470 | if (_zeroFlag) |
459 | return Vector3.Zero; | 471 | return Vector3.Zero; |
460 | return _velocity; | 472 | return _velocity; |
@@ -833,6 +845,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
833 | body_autodisable_frames = parent_scene.bodyFramesAutoDisable; | 845 | body_autodisable_frames = parent_scene.bodyFramesAutoDisable; |
834 | 846 | ||
835 | prim_geom = IntPtr.Zero; | 847 | prim_geom = IntPtr.Zero; |
848 | collide_geom = IntPtr.Zero; | ||
836 | Body = IntPtr.Zero; | 849 | Body = IntPtr.Zero; |
837 | 850 | ||
838 | if (!size.IsFinite()) | 851 | if (!size.IsFinite()) |
@@ -1367,7 +1380,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1367 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); | 1380 | d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); |
1368 | m_collisionscore = 0; | 1381 | m_collisionscore = 0; |
1369 | 1382 | ||
1370 | if (m_targetSpace != _parent_scene.ActiveSpace) | 1383 | // if (m_targetSpace != _parent_scene.ActiveSpace) |
1371 | { | 1384 | { |
1372 | if (m_targetSpace != IntPtr.Zero) | 1385 | if (m_targetSpace != IntPtr.Zero) |
1373 | { | 1386 | { |
@@ -1376,9 +1389,26 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1376 | d.SpaceRemove(m_targetSpace, prim_geom); | 1389 | d.SpaceRemove(m_targetSpace, prim_geom); |
1377 | } | 1390 | } |
1378 | 1391 | ||
1392 | // m_targetSpace = _parent_scene.ActiveSpace; | ||
1393 | // d.SpaceAdd(m_targetSpace, prim_geom); | ||
1394 | } | ||
1395 | |||
1396 | |||
1397 | if (childrenPrim.Count == 0) | ||
1398 | { | ||
1399 | collide_geom = prim_geom; | ||
1379 | m_targetSpace = _parent_scene.ActiveSpace; | 1400 | m_targetSpace = _parent_scene.ActiveSpace; |
1380 | d.SpaceAdd(m_targetSpace, prim_geom); | 1401 | d.SpaceAdd(m_targetSpace, prim_geom); |
1381 | } | 1402 | } |
1403 | else | ||
1404 | { | ||
1405 | m_targetSpace = d.HashSpaceCreate(_parent_scene.ActiveSpace); | ||
1406 | d.HashSpaceSetLevels(m_targetSpace, -2, 8); | ||
1407 | d.SpaceSetSublevel(m_targetSpace, 3); | ||
1408 | d.SpaceSetCleanup(m_targetSpace, false); | ||
1409 | d.SpaceAdd(m_targetSpace, prim_geom); | ||
1410 | collide_geom = m_targetSpace; | ||
1411 | } | ||
1382 | 1412 | ||
1383 | lock (childrenPrim) | 1413 | lock (childrenPrim) |
1384 | { | 1414 | { |
@@ -1396,15 +1426,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1396 | d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); | 1426 | d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); |
1397 | prm.m_collisionscore = 0; | 1427 | prm.m_collisionscore = 0; |
1398 | 1428 | ||
1399 | if (prm.m_targetSpace != _parent_scene.ActiveSpace) | 1429 | if (prm.m_targetSpace != m_targetSpace) |
1400 | { | 1430 | { |
1401 | if (prm.m_targetSpace != IntPtr.Zero) | 1431 | if (prm.m_targetSpace != IntPtr.Zero) |
1402 | { | 1432 | { |
1403 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 1433 | _parent_scene.waitForSpaceUnlock(prm.m_targetSpace); |
1404 | if (d.SpaceQuery(prm.m_targetSpace, prm.prim_geom)) | 1434 | if (d.SpaceQuery(prm.m_targetSpace, prm.prim_geom)) |
1405 | d.SpaceRemove(prm.m_targetSpace, prm.prim_geom); | 1435 | d.SpaceRemove(prm.m_targetSpace, prm.prim_geom); |
1406 | } | 1436 | } |
1407 | prm.m_targetSpace = _parent_scene.ActiveSpace; | 1437 | prm.m_targetSpace = m_targetSpace; |
1408 | d.SpaceAdd(m_targetSpace, prm.prim_geom); | 1438 | d.SpaceAdd(m_targetSpace, prm.prim_geom); |
1409 | } | 1439 | } |
1410 | 1440 | ||
@@ -1427,8 +1457,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1427 | d.GeomDisable(prim_geom); | 1457 | d.GeomDisable(prim_geom); |
1428 | d.BodyDisable(Body); | 1458 | d.BodyDisable(Body); |
1429 | } | 1459 | } |
1460 | else | ||
1461 | { | ||
1462 | d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); | ||
1463 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); | ||
1464 | } | ||
1430 | 1465 | ||
1431 | _parent_scene.addActivePrim(this); | 1466 | _parent_scene.addActivePrim(this); |
1467 | _parent_scene.addActiveGroups(this); | ||
1432 | } | 1468 | } |
1433 | 1469 | ||
1434 | private void DestroyBody() | 1470 | private void DestroyBody() |
@@ -1473,6 +1509,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1473 | d.JointDestroy(Amotor); | 1509 | d.JointDestroy(Amotor); |
1474 | Amotor = IntPtr.Zero; | 1510 | Amotor = IntPtr.Zero; |
1475 | } | 1511 | } |
1512 | _parent_scene.remActiveGroup(this); | ||
1476 | d.BodyDestroy(Body); | 1513 | d.BodyDestroy(Body); |
1477 | } | 1514 | } |
1478 | Body = IntPtr.Zero; | 1515 | Body = IntPtr.Zero; |
@@ -2390,8 +2427,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2390 | else | 2427 | else |
2391 | */ | 2428 | */ |
2392 | DestroyBody(); | 2429 | DestroyBody(); |
2393 | Stop(); | ||
2394 | } | 2430 | } |
2431 | Stop(); | ||
2395 | } | 2432 | } |
2396 | } | 2433 | } |
2397 | 2434 | ||
@@ -2576,7 +2613,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2576 | if ((bool)newbuilding) | 2613 | if ((bool)newbuilding) |
2577 | { | 2614 | { |
2578 | m_building = true; | 2615 | m_building = true; |
2579 | DestroyBody(); | 2616 | if (!childPrim) |
2617 | DestroyBody(); | ||
2580 | } | 2618 | } |
2581 | else | 2619 | else |
2582 | { | 2620 | { |
@@ -2648,12 +2686,95 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2648 | public void Move() | 2686 | public void Move() |
2649 | { | 2687 | { |
2650 | if (!childPrim && m_isphysical && Body != IntPtr.Zero && | 2688 | if (!childPrim && m_isphysical && Body != IntPtr.Zero && |
2651 | !m_disabled && !m_isSelected && d.BodyIsEnabled(Body) && !m_building) // KF: Only move root prims. | 2689 | !m_disabled && !m_isSelected && d.BodyIsEnabled(Body) && !m_building && !m_outbounds) |
2690 | // !m_disabled && !m_isSelected && !m_building && !m_outbounds) | ||
2652 | { | 2691 | { |
2653 | // if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009 | 2692 | // if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009 |
2654 | 2693 | ||
2655 | float timestep = _parent_scene.ODE_STEPSIZE; | 2694 | float timestep = _parent_scene.ODE_STEPSIZE; |
2656 | 2695 | ||
2696 | // check outside region | ||
2697 | d.Vector3 lpos; | ||
2698 | d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator | ||
2699 | |||
2700 | if (lpos.Z < -100 || lpos.Z > 100000f) | ||
2701 | { | ||
2702 | m_outbounds = true; | ||
2703 | |||
2704 | lpos.Z = Util.Clip(lpos.Z, -100f, 100000f); | ||
2705 | _acceleration.X = 0; | ||
2706 | _acceleration.Y = 0; | ||
2707 | _acceleration.Z = 0; | ||
2708 | |||
2709 | _velocity.X = 0; | ||
2710 | _velocity.Y = 0; | ||
2711 | _velocity.Z = 0; | ||
2712 | m_rotationalVelocity.X = 0; | ||
2713 | m_rotationalVelocity.Y = 0; | ||
2714 | m_rotationalVelocity.Z = 0; | ||
2715 | |||
2716 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
2717 | d.BodySetAngularVel(Body, 0, 0, 0); // stop it | ||
2718 | d.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere | ||
2719 | m_lastposition = _position; | ||
2720 | m_lastorientation = _orientation; | ||
2721 | |||
2722 | base.RequestPhysicsterseUpdate(); | ||
2723 | |||
2724 | m_throttleUpdates = false; | ||
2725 | throttleCounter = 0; | ||
2726 | _zeroFlag = true; | ||
2727 | |||
2728 | disableBodySoft(); // disable it and colisions | ||
2729 | base.RaiseOutOfBounds(_position); | ||
2730 | return; | ||
2731 | } | ||
2732 | |||
2733 | if (lpos.X < 0f) | ||
2734 | { | ||
2735 | _position.X = Util.Clip(lpos.X, -2f, -0.1f); | ||
2736 | m_outbounds = true; | ||
2737 | } | ||
2738 | else if(lpos.X > _parent_scene.WorldExtents.X) | ||
2739 | { | ||
2740 | _position.X = Util.Clip(lpos.X, _parent_scene.WorldExtents.X + 0.1f, _parent_scene.WorldExtents.X + 2f); | ||
2741 | m_outbounds = true; | ||
2742 | } | ||
2743 | if (lpos.Y < 0f) | ||
2744 | { | ||
2745 | _position.Y = Util.Clip(lpos.Y, -2f, -0.1f); | ||
2746 | m_outbounds = true; | ||
2747 | } | ||
2748 | else if(lpos.Y > _parent_scene.WorldExtents.Y) | ||
2749 | { | ||
2750 | _position.Y = Util.Clip(lpos.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f); | ||
2751 | m_outbounds = true; | ||
2752 | } | ||
2753 | |||
2754 | if(m_outbounds) | ||
2755 | { | ||
2756 | m_lastposition = _position; | ||
2757 | m_lastorientation = _orientation; | ||
2758 | |||
2759 | d.Vector3 dtmp = d.BodyGetAngularVel(Body); | ||
2760 | m_rotationalVelocity.X = dtmp.X; | ||
2761 | m_rotationalVelocity.Y = dtmp.Y; | ||
2762 | m_rotationalVelocity.Z = dtmp.Z; | ||
2763 | |||
2764 | dtmp = d.BodyGetLinearVel(Body); | ||
2765 | _velocity.X = dtmp.X; | ||
2766 | _velocity.Y = dtmp.Y; | ||
2767 | _velocity.Z = dtmp.Z; | ||
2768 | |||
2769 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
2770 | d.BodySetAngularVel(Body, 0, 0, 0); | ||
2771 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
2772 | disableBodySoft(); // stop collisions | ||
2773 | base.RequestPhysicsterseUpdate(); | ||
2774 | return; | ||
2775 | } | ||
2776 | |||
2777 | |||
2657 | float fx = 0; | 2778 | float fx = 0; |
2658 | float fy = 0; | 2779 | float fy = 0; |
2659 | float fz = 0; | 2780 | float fz = 0; |
@@ -2862,7 +2983,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2862 | public void UpdatePositionAndVelocity(float simulatedtime) | 2983 | public void UpdatePositionAndVelocity(float simulatedtime) |
2863 | { | 2984 | { |
2864 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! | 2985 | // 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) | 2986 | if (_parent == null && !m_disabled && !m_building && !m_outbounds) |
2866 | { | 2987 | { |
2867 | if (Body != IntPtr.Zero) | 2988 | if (Body != IntPtr.Zero) |
2868 | { | 2989 | { |
@@ -2872,64 +2993,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2872 | d.Vector3 lpos; | 2993 | d.Vector3 lpos; |
2873 | d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator | 2994 | d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator |
2874 | 2995 | ||
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 | 2996 | ||
2934 | d.Quaternion ori; | 2997 | d.Quaternion ori; |
2935 | d.GeomCopyQuaternion(prim_geom, out ori); | 2998 | d.GeomCopyQuaternion(prim_geom, out ori); |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 6e4c373..129db5d 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -155,7 +155,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
155 | private readonly ILog m_log; | 155 | private readonly ILog m_log; |
156 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); | 156 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); |
157 | 157 | ||
158 | private int threadid = 0; | 158 | // private int threadid = 0; |
159 | private Random fluidRandomizer = new Random(Environment.TickCount); | 159 | private Random fluidRandomizer = new Random(Environment.TickCount); |
160 | 160 | ||
161 | const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce; | 161 | const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce; |
@@ -168,7 +168,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
168 | float frictionMovementMult = 0.3f; | 168 | float frictionMovementMult = 0.3f; |
169 | 169 | ||
170 | float TerrainBounce = 0.1f; | 170 | float TerrainBounce = 0.1f; |
171 | float TerrainFriction = 0.1f; | 171 | float TerrainFriction = 0.3f; |
172 | 172 | ||
173 | public float AvatarBounce = 0.3f; | 173 | public float AvatarBounce = 0.3f; |
174 | public float AvatarFriction = 0;// 0.9f * 0.5f; | 174 | public float AvatarFriction = 0;// 0.9f * 0.5f; |
@@ -189,8 +189,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
189 | 189 | ||
190 | internal IntPtr WaterGeom; | 190 | internal IntPtr WaterGeom; |
191 | 191 | ||
192 | public float avPIDD = 3200f; // make it visible | 192 | public float avPIDD = 2200f; // make it visible |
193 | public float avPIDP = 1400f; // make it visible | 193 | public float avPIDP = 900f; // make it visible |
194 | private float avCapRadius = 0.37f; | 194 | private float avCapRadius = 0.37f; |
195 | private float avDensity = 3f; | 195 | private float avDensity = 3f; |
196 | private float avMovementDivisorWalk = 1.3f; | 196 | private float avMovementDivisorWalk = 1.3f; |
@@ -202,7 +202,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
202 | public bool forceSimplePrimMeshing = false; | 202 | public bool forceSimplePrimMeshing = false; |
203 | 203 | ||
204 | public float meshSculptLOD = 32; | 204 | public float meshSculptLOD = 32; |
205 | public float MeshSculptphysicalLOD = 16; | 205 | public float MeshSculptphysicalLOD = 32; |
206 | 206 | ||
207 | public float geomDefaultDensity = 10.000006836f; | 207 | public float geomDefaultDensity = 10.000006836f; |
208 | 208 | ||
@@ -212,18 +212,18 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
212 | public float bodyPIDD = 35f; | 212 | public float bodyPIDD = 35f; |
213 | public float bodyPIDG = 25; | 213 | public float bodyPIDG = 25; |
214 | 214 | ||
215 | public int geomCrossingFailuresBeforeOutofbounds = 6; | 215 | // public int geomCrossingFailuresBeforeOutofbounds = 6; |
216 | 216 | ||
217 | public int bodyFramesAutoDisable = 20; | 217 | public int bodyFramesAutoDisable = 20; |
218 | 218 | ||
219 | private float[] _watermap; | 219 | private float[] _watermap; |
220 | private bool m_filterCollisions = true; | ||
221 | 220 | ||
222 | private d.NearCallback nearCallback; | 221 | private d.NearCallback nearCallback; |
223 | 222 | ||
224 | private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); | 223 | private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); |
225 | private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); | 224 | private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); |
226 | private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); | 225 | private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); |
226 | private readonly HashSet<OdePrim> _activegroups = new HashSet<OdePrim>(); | ||
227 | 227 | ||
228 | public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); | 228 | public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); |
229 | 229 | ||
@@ -387,9 +387,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
387 | 387 | ||
388 | // Defaults | 388 | // Defaults |
389 | 389 | ||
390 | avPIDD = 2200.0f; | ||
391 | avPIDP = 900.0f; | ||
392 | |||
393 | int contactsPerCollision = 80; | 390 | int contactsPerCollision = 80; |
394 | 391 | ||
395 | if (m_config != null) | 392 | if (m_config != null) |
@@ -397,57 +394,56 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
397 | IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; | 394 | IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; |
398 | if (physicsconfig != null) | 395 | if (physicsconfig != null) |
399 | { | 396 | { |
400 | gravityx = physicsconfig.GetFloat("world_gravityx", 0f); | 397 | gravityx = physicsconfig.GetFloat("world_gravityx", gravityx); |
401 | gravityy = physicsconfig.GetFloat("world_gravityy", 0f); | 398 | gravityy = physicsconfig.GetFloat("world_gravityy", gravityy); |
402 | gravityz = physicsconfig.GetFloat("world_gravityz", -9.8f); | 399 | gravityz = physicsconfig.GetFloat("world_gravityz", gravityz); |
403 | 400 | ||
404 | metersInSpace = physicsconfig.GetFloat("meters_in_small_space", 29.9f); | 401 | metersInSpace = physicsconfig.GetFloat("meters_in_small_space", metersInSpace); |
405 | 402 | ||
406 | contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer); | 403 | contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer); |
407 | 404 | ||
408 | ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", 0.020f); | 405 | ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", ODE_STEPSIZE); |
409 | m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", 10); | 406 | m_physicsiterations = physicsconfig.GetInt("world_internal_steps_without_collisions", m_physicsiterations); |
410 | 407 | ||
411 | avDensity = physicsconfig.GetFloat("av_density", avDensity); | 408 | avDensity = physicsconfig.GetFloat("av_density", avDensity); |
412 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f); | 409 | avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk); |
413 | avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); | 410 | avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", avMovementDivisorRun); |
414 | avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); | 411 | avCapRadius = physicsconfig.GetFloat("av_capsule_radius", avCapRadius); |
415 | 412 | ||
416 | contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80); | 413 | contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); |
417 | 414 | ||
418 | geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); | 415 | geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); |
419 | geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); | 416 | geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); |
420 | geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); | 417 | // geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); |
421 | 418 | ||
422 | geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f); | 419 | geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", geomDefaultDensity); |
423 | bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20); | 420 | bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", bodyFramesAutoDisable); |
424 | 421 | ||
425 | bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", 35f); | 422 | bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", bodyPIDD); |
426 | bodyPIDG = physicsconfig.GetFloat("body_pid_gain", 25f); | 423 | bodyPIDG = physicsconfig.GetFloat("body_pid_gain", bodyPIDG); |
427 | 424 | ||
428 | forceSimplePrimMeshing = physicsconfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing); | 425 | forceSimplePrimMeshing = physicsconfig.GetBoolean("force_simple_prim_meshing", forceSimplePrimMeshing); |
429 | meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", true); | 426 | meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", meshSculptedPrim); |
430 | meshSculptLOD = physicsconfig.GetFloat("mesh_lod", 32f); | 427 | meshSculptLOD = physicsconfig.GetFloat("mesh_lod", meshSculptLOD); |
431 | MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", 16f); | 428 | MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", MeshSculptphysicalLOD); |
432 | m_filterCollisions = physicsconfig.GetBoolean("filter_collisions", false); | ||
433 | 429 | ||
434 | if (Environment.OSVersion.Platform == PlatformID.Unix) | 430 | if (Environment.OSVersion.Platform == PlatformID.Unix) |
435 | { | 431 | { |
436 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 2200.0f); | 432 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", avPIDD); |
437 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 900.0f); | 433 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", avPIDP); |
438 | } | 434 | } |
439 | else | 435 | else |
440 | { | 436 | { |
441 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f); | 437 | avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", avPIDD); |
442 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); | 438 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", avPIDP); |
443 | } | 439 | } |
444 | 440 | ||
445 | physics_logging = physicsconfig.GetBoolean("physics_logging", false); | 441 | physics_logging = physicsconfig.GetBoolean("physics_logging", false); |
446 | physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0); | 442 | physics_logging_interval = physicsconfig.GetInt("physics_logging_interval", 0); |
447 | physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false); | 443 | physics_logging_append_existing_logfile = physicsconfig.GetBoolean("physics_logging_append_existing_logfile", false); |
448 | 444 | ||
449 | minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); | 445 | minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", minimumGroundFlightOffset); |
450 | maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", 10000.01f); | 446 | maximumMassObject = physicsconfig.GetFloat("maximum_mass_object", maximumMassObject); |
451 | } | 447 | } |
452 | } | 448 | } |
453 | 449 | ||
@@ -1013,15 +1009,24 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1013 | 1009 | ||
1014 | } | 1010 | } |
1015 | 1011 | ||
1016 | // collide active prims with static enviroment | ||
1017 | lock (_activeprims) | 1012 | lock (_activeprims) |
1018 | { | 1013 | { |
1014 | foreach (OdePrim aprim in _activeprims) | ||
1015 | { | ||
1016 | aprim.CollisionScore = 0; | ||
1017 | aprim.IsColliding = false; | ||
1018 | } | ||
1019 | } | ||
1020 | |||
1021 | // collide active prims with static enviroment | ||
1022 | lock (_activegroups) | ||
1023 | { | ||
1019 | try | 1024 | try |
1020 | { | 1025 | { |
1021 | foreach (OdePrim prm in _activeprims) | 1026 | foreach (OdePrim prm in _activegroups) |
1022 | { | 1027 | { |
1023 | if (d.BodyIsEnabled(prm.Body)) | 1028 | if (d.BodyIsEnabled(prm.Body) && !prm.m_outbounds) |
1024 | d.SpaceCollide2(StaticSpace, prm.prim_geom, IntPtr.Zero, nearCallback); | 1029 | d.SpaceCollide2(StaticSpace, prm.collide_geom, IntPtr.Zero, nearCallback); |
1025 | } | 1030 | } |
1026 | } | 1031 | } |
1027 | catch (AccessViolationException) | 1032 | catch (AccessViolationException) |
@@ -1029,7 +1034,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1029 | m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); | 1034 | m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); |
1030 | } | 1035 | } |
1031 | } | 1036 | } |
1032 | |||
1033 | // finally colide active things amoung them | 1037 | // finally colide active things amoung them |
1034 | try | 1038 | try |
1035 | { | 1039 | { |
@@ -1039,7 +1043,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1039 | { | 1043 | { |
1040 | m_log.Warn("[PHYSICS]: Unable to collide in Active space"); | 1044 | m_log.Warn("[PHYSICS]: Unable to collide in Active space"); |
1041 | } | 1045 | } |
1042 | |||
1043 | // _perloopContact.Clear(); | 1046 | // _perloopContact.Clear(); |
1044 | } | 1047 | } |
1045 | 1048 | ||
@@ -1148,13 +1151,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1148 | 1151 | ||
1149 | public void addActivePrim(OdePrim activatePrim) | 1152 | public void addActivePrim(OdePrim activatePrim) |
1150 | { | 1153 | { |
1151 | // adds active prim.. (ones that should be iterated over in collisions_optimized | 1154 | // adds active prim.. |
1152 | lock (_activeprims) | 1155 | lock (_activeprims) |
1153 | { | 1156 | { |
1154 | if (!_activeprims.Contains(activatePrim)) | 1157 | if (!_activeprims.Contains(activatePrim)) |
1155 | _activeprims.Add(activatePrim); | 1158 | _activeprims.Add(activatePrim); |
1156 | //else | 1159 | } |
1157 | // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent"); | 1160 | } |
1161 | |||
1162 | public void addActiveGroups(OdePrim activatePrim) | ||
1163 | { | ||
1164 | lock (_activegroups) | ||
1165 | { | ||
1166 | if (!_activegroups.Contains(activatePrim)) | ||
1167 | _activegroups.Add(activatePrim); | ||
1158 | } | 1168 | } |
1159 | } | 1169 | } |
1160 | 1170 | ||
@@ -1186,6 +1196,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1186 | _activeprims.Remove(deactivatePrim); | 1196 | _activeprims.Remove(deactivatePrim); |
1187 | } | 1197 | } |
1188 | } | 1198 | } |
1199 | public void remActiveGroup(OdePrim deactivatePrim) | ||
1200 | { | ||
1201 | lock (_activegroups) | ||
1202 | { | ||
1203 | _activegroups.Remove(deactivatePrim); | ||
1204 | } | ||
1205 | } | ||
1189 | 1206 | ||
1190 | public override void RemovePrim(PhysicsActor prim) | 1207 | public override void RemovePrim(PhysicsActor prim) |
1191 | { | 1208 | { |
@@ -1258,6 +1275,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1258 | { | 1275 | { |
1259 | waitForSpaceUnlock(currentspace); | 1276 | waitForSpaceUnlock(currentspace); |
1260 | d.SpaceRemove(currentspace, geom); | 1277 | d.SpaceRemove(currentspace, geom); |
1278 | |||
1279 | if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0) | ||
1280 | { | ||
1281 | d.SpaceDestroy(currentspace); | ||
1282 | } | ||
1261 | } | 1283 | } |
1262 | else | 1284 | else |
1263 | { | 1285 | { |
@@ -1274,6 +1296,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1274 | { | 1296 | { |
1275 | waitForSpaceUnlock(currentspace); | 1297 | waitForSpaceUnlock(currentspace); |
1276 | d.SpaceRemove(currentspace, geom); | 1298 | d.SpaceRemove(currentspace, geom); |
1299 | |||
1300 | if (d.SpaceGetSublevel(currentspace) > 2 && d.SpaceGetNumGeoms(currentspace) == 0) | ||
1301 | { | ||
1302 | d.SpaceDestroy(currentspace); | ||
1303 | } | ||
1304 | |||
1277 | } | 1305 | } |
1278 | } | 1306 | } |
1279 | } | 1307 | } |
@@ -1577,42 +1605,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1577 | 1605 | ||
1578 | statchanges += Util.EnvironmentTickCountSubtract(statstart); | 1606 | statchanges += Util.EnvironmentTickCountSubtract(statstart); |
1579 | 1607 | ||
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); | 1608 | statactmove += Util.EnvironmentTickCountSubtract(statstart); |
1611 | //if ((framecount % m_randomizeWater) == 0) | 1609 | //if ((framecount % m_randomizeWater) == 0) |
1612 | // randomizeWater(waterlevel); | 1610 | // randomizeWater(waterlevel); |
1613 | 1611 | ||
1614 | m_rayCastManager.ProcessQueuedRequests(); | 1612 | m_rayCastManager.ProcessQueuedRequests(); |
1615 | 1613 | ||
1614 | |||
1615 | |||
1616 | statray += Util.EnvironmentTickCountSubtract(statstart); | 1616 | statray += Util.EnvironmentTickCountSubtract(statstart); |
1617 | collision_optimized(); | 1617 | collision_optimized(); |
1618 | statcol += Util.EnvironmentTickCountSubtract(statstart); | 1618 | statcol += Util.EnvironmentTickCountSubtract(statstart); |
@@ -1642,8 +1642,35 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1642 | 1642 | ||
1643 | d.WorldQuickStep(world, ODE_STEPSIZE); | 1643 | d.WorldQuickStep(world, ODE_STEPSIZE); |
1644 | statstep += Util.EnvironmentTickCountSubtract(statstart); | 1644 | statstep += Util.EnvironmentTickCountSubtract(statstart); |
1645 | d.JointGroupEmpty(contactgroup); | 1645 | |
1646 | totjcontact += m_global_contactcount; | 1646 | // Move characters |
1647 | lock (_characters) | ||
1648 | { | ||
1649 | List<OdeCharacter> defects = new List<OdeCharacter>(); | ||
1650 | foreach (OdeCharacter actor in _characters) | ||
1651 | { | ||
1652 | if (actor != null) | ||
1653 | actor.Move(ODE_STEPSIZE, defects); | ||
1654 | } | ||
1655 | if (defects.Count != 0) | ||
1656 | { | ||
1657 | foreach (OdeCharacter defect in defects) | ||
1658 | { | ||
1659 | RemoveCharacter(defect); | ||
1660 | } | ||
1661 | } | ||
1662 | } | ||
1663 | statchmove += Util.EnvironmentTickCountSubtract(statstart); | ||
1664 | |||
1665 | // Move other active objects | ||
1666 | lock (_activegroups) | ||
1667 | { | ||
1668 | foreach (OdePrim aprim in _activegroups) | ||
1669 | { | ||
1670 | aprim.Move(); | ||
1671 | } | ||
1672 | } | ||
1673 | |||
1647 | //ode.dunlock(world); | 1674 | //ode.dunlock(world); |
1648 | } | 1675 | } |
1649 | catch (Exception e) | 1676 | catch (Exception e) |
@@ -1652,6 +1679,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1652 | // ode.dunlock(world); | 1679 | // ode.dunlock(world); |
1653 | } | 1680 | } |
1654 | 1681 | ||
1682 | d.JointGroupEmpty(contactgroup); | ||
1683 | totjcontact += m_global_contactcount; | ||
1684 | |||
1655 | step_time -= ODE_STEPSIZE; | 1685 | step_time -= ODE_STEPSIZE; |
1656 | nodeframes++; | 1686 | nodeframes++; |
1657 | } | 1687 | } |
@@ -1686,10 +1716,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1686 | } | 1716 | } |
1687 | statmovchar = Util.EnvironmentTickCountSubtract(statstart); | 1717 | statmovchar = Util.EnvironmentTickCountSubtract(statstart); |
1688 | 1718 | ||
1689 | lock (_activeprims) | 1719 | lock (_activegroups) |
1690 | { | 1720 | { |
1691 | { | 1721 | { |
1692 | foreach (OdePrim actor in _activeprims) | 1722 | foreach (OdePrim actor in _activegroups) |
1693 | { | 1723 | { |
1694 | if (actor.IsPhysical) | 1724 | if (actor.IsPhysical) |
1695 | { | 1725 | { |
@@ -1906,13 +1936,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1906 | yy += regionsize; | 1936 | yy += regionsize; |
1907 | 1937 | ||
1908 | val = heightMap[yy + xx]; | 1938 | val = heightMap[yy + xx]; |
1939 | if (val < 0.0f) | ||
1940 | val = 0.0f; // no neg terrain as in chode | ||
1909 | _heightmap[xt + y] = val; | 1941 | _heightmap[xt + y] = val; |
1910 | 1942 | ||
1911 | if (hfmin > val) | 1943 | if (hfmin > val) |
1912 | hfmin = val; | 1944 | hfmin = val; |
1913 | if (hfmax < val) | 1945 | if (hfmax < val) |
1914 | hfmax = val; | 1946 | hfmax = val; |
1915 | |||
1916 | } | 1947 | } |
1917 | xt += heightmapHeightSamples; | 1948 | xt += heightmapHeightSamples; |
1918 | } | 1949 | } |
@@ -1966,7 +1997,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1966 | 1997 | ||
1967 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 1998 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
1968 | d.GeomSetRotation(GroundGeom, ref R); | 1999 | 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); | 2000 | d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); |
1970 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); | 2001 | RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); |
1971 | // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); | 2002 | // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap); |
1972 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); | 2003 | TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); |