diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 154 |
1 files changed, 41 insertions, 113 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index ff17a6e..6d322e2 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | |||
@@ -101,7 +101,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
101 | private float m_invTimeStep = 50.0f; | 101 | private float m_invTimeStep = 50.0f; |
102 | private float m_timeStep = .02f; | 102 | private float m_timeStep = .02f; |
103 | 103 | ||
104 | |||
105 | private Vector3 m_PIDTarget; | 104 | private Vector3 m_PIDTarget; |
106 | private float m_PIDTau; | 105 | private float m_PIDTau; |
107 | private bool m_usePID; | 106 | private bool m_usePID; |
@@ -119,7 +118,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
119 | private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. | 118 | private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. |
120 | 119 | ||
121 | private int body_autodisable_frames = 5; | 120 | private int body_autodisable_frames = 5; |
122 | private int bodydisablecontrol = 0; | 121 | public int bodydisablecontrol = 0; |
123 | 122 | ||
124 | 123 | ||
125 | // Default we're a Geometry | 124 | // Default we're a Geometry |
@@ -134,7 +133,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
134 | 133 | ||
135 | // private bool m_collidesLand = true; | 134 | // private bool m_collidesLand = true; |
136 | private bool m_collidesWater; | 135 | private bool m_collidesWater; |
137 | public bool m_returnCollisions; | 136 | // public bool m_returnCollisions; |
138 | 137 | ||
139 | private bool m_NoColide; // for now only for internal use for bad meshs | 138 | private bool m_NoColide; // for now only for internal use for bad meshs |
140 | 139 | ||
@@ -144,7 +143,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
144 | 143 | ||
145 | public bool m_disabled; | 144 | public bool m_disabled; |
146 | 145 | ||
147 | public uint m_localID; | 146 | private uint m_localID; |
148 | 147 | ||
149 | private IMesh m_mesh; | 148 | private IMesh m_mesh; |
150 | private object m_meshlock = new object(); | 149 | private object m_meshlock = new object(); |
@@ -164,10 +163,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
164 | private List<OdePrim> childrenPrim = new List<OdePrim>(); | 163 | private List<OdePrim> childrenPrim = new List<OdePrim>(); |
165 | 164 | ||
166 | 165 | ||
167 | private bool m_throttleUpdates; | 166 | // private bool m_throttleUpdates; |
168 | private int throttleCounter; | 167 | // private int throttleCounter; |
169 | public float m_collisionscore; | 168 | public float m_collisionscore; |
170 | int m_colliderfilter = 0; | 169 | private int m_colliderfilter = 0; |
171 | 170 | ||
172 | public IntPtr collide_geom; // for objects: geom if single prim space it linkset | 171 | public IntPtr collide_geom; // for objects: geom if single prim space it linkset |
173 | 172 | ||
@@ -235,7 +234,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
235 | } | 234 | } |
236 | } | 235 | } |
237 | 236 | ||
238 | |||
239 | public override bool Phantom // this is not reliable for internal use | 237 | public override bool Phantom // this is not reliable for internal use |
240 | { | 238 | { |
241 | get { return m_fakeisphantom; } | 239 | get { return m_fakeisphantom; } |
@@ -293,14 +291,18 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
293 | 291 | ||
294 | public override uint LocalID | 292 | public override uint LocalID |
295 | { | 293 | { |
294 | get { return m_localID; } | ||
295 | set { m_localID = value; } | ||
296 | } | ||
297 | |||
298 | public OdePrim Parent | ||
299 | { | ||
296 | get | 300 | get |
297 | { | 301 | { |
298 | return m_localID; | 302 | if (childPrim) |
299 | } | 303 | return (OdePrim)_parent; |
300 | set | 304 | else |
301 | { | 305 | return this; |
302 | //m_log.Info("[PHYSICS]: Setting TrackerID: " + value); | ||
303 | m_localID = value; | ||
304 | } | 306 | } |
305 | } | 307 | } |
306 | 308 | ||
@@ -363,12 +365,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
363 | set { return; } | 365 | set { return; } |
364 | } | 366 | } |
365 | 367 | ||
366 | public override bool ThrottleUpdates | 368 | |
369 | public override bool ThrottleUpdates {get;set;} | ||
370 | /* | ||
367 | { | 371 | { |
368 | get { return m_throttleUpdates; } | 372 | get { return m_throttleUpdates; } |
369 | set { m_throttleUpdates = value; } | 373 | set { m_throttleUpdates = value; } |
370 | } | 374 | } |
371 | 375 | */ | |
372 | public override bool Stopped | 376 | public override bool Stopped |
373 | { | 377 | { |
374 | get { return _zeroFlag; } | 378 | get { return _zeroFlag; } |
@@ -943,15 +947,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
943 | CollisionEventsThisFrame = null; | 947 | CollisionEventsThisFrame = null; |
944 | } | 948 | } |
945 | m_eventsubscription = 0; | 949 | m_eventsubscription = 0; |
946 | // for now still done on odescene | 950 | _parent_scene.RemoveCollisionEventReporting(this); |
947 | // _parent_scene.RemoveCollisionEventReporting(this); | ||
948 | } | 951 | } |
949 | 952 | ||
950 | public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) | 953 | public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) |
951 | { | 954 | { |
952 | if (CollisionEventsThisFrame == null) | 955 | if (CollisionEventsThisFrame == null) |
953 | CollisionEventsThisFrame = new CollisionEventUpdate(); | 956 | CollisionEventsThisFrame = new CollisionEventUpdate(); |
954 | CollisionEventsThisFrame.AddCollider(CollidedWith, contact); | 957 | // if(CollisionEventsThisFrame.Count < 32) |
958 | CollisionEventsThisFrame.AddCollider(CollidedWith, contact); | ||
955 | } | 959 | } |
956 | 960 | ||
957 | public void SendCollisions() | 961 | public void SendCollisions() |
@@ -1746,8 +1750,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1746 | if (childrenPrim.Count == 0) | 1750 | if (childrenPrim.Count == 0) |
1747 | { | 1751 | { |
1748 | collide_geom = prim_geom; | 1752 | collide_geom = prim_geom; |
1749 | m_targetSpace = _parent_scene.ActiveSpace; | 1753 | m_targetSpace = _parent_scene.ActiveSpace; |
1750 | d.SpaceAdd(m_targetSpace, prim_geom); | ||
1751 | } | 1754 | } |
1752 | else | 1755 | else |
1753 | { | 1756 | { |
@@ -1755,7 +1758,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1755 | d.HashSpaceSetLevels(m_targetSpace, -2, 8); | 1758 | d.HashSpaceSetLevels(m_targetSpace, -2, 8); |
1756 | d.SpaceSetSublevel(m_targetSpace, 3); | 1759 | d.SpaceSetSublevel(m_targetSpace, 3); |
1757 | d.SpaceSetCleanup(m_targetSpace, false); | 1760 | d.SpaceSetCleanup(m_targetSpace, false); |
1758 | d.SpaceAdd(m_targetSpace, prim_geom); | ||
1759 | 1761 | ||
1760 | d.GeomSetCategoryBits(m_targetSpace, (uint)(CollisionCategories.Space | | 1762 | d.GeomSetCategoryBits(m_targetSpace, (uint)(CollisionCategories.Space | |
1761 | CollisionCategories.Geom | | 1763 | CollisionCategories.Geom | |
@@ -1766,12 +1768,21 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1766 | collide_geom = m_targetSpace; | 1768 | collide_geom = m_targetSpace; |
1767 | } | 1769 | } |
1768 | 1770 | ||
1771 | d.SpaceAdd(m_targetSpace, prim_geom); | ||
1772 | |||
1769 | if (m_delaySelect) | 1773 | if (m_delaySelect) |
1770 | { | 1774 | { |
1771 | m_isSelected = true; | 1775 | m_isSelected = true; |
1772 | m_delaySelect = false; | 1776 | m_delaySelect = false; |
1773 | } | 1777 | } |
1774 | 1778 | ||
1779 | m_collisionscore = 0; | ||
1780 | |||
1781 | UpdateCollisionCatFlags(); | ||
1782 | ApplyCollisionCatFlags(); | ||
1783 | |||
1784 | _parent_scene.addActivePrim(this); | ||
1785 | |||
1775 | lock (childrenPrim) | 1786 | lock (childrenPrim) |
1776 | { | 1787 | { |
1777 | foreach (OdePrim prm in childrenPrim) | 1788 | foreach (OdePrim prm in childrenPrim) |
@@ -1809,10 +1820,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1809 | createAMotor(m_angularlock); | 1820 | createAMotor(m_angularlock); |
1810 | } | 1821 | } |
1811 | 1822 | ||
1812 | m_collisionscore = 0; | ||
1813 | |||
1814 | UpdateCollisionCatFlags(); | ||
1815 | ApplyCollisionCatFlags(); | ||
1816 | 1823 | ||
1817 | if (m_isSelected || m_disabled) | 1824 | if (m_isSelected || m_disabled) |
1818 | { | 1825 | { |
@@ -1822,9 +1829,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1822 | { | 1829 | { |
1823 | d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); | 1830 | d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); |
1824 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); | 1831 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); |
1825 | } | 1832 | } |
1826 | |||
1827 | _parent_scene.addActivePrim(this); | ||
1828 | _parent_scene.addActiveGroups(this); | 1833 | _parent_scene.addActiveGroups(this); |
1829 | } | 1834 | } |
1830 | 1835 | ||
@@ -3441,92 +3446,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3441 | if (++bodydisablecontrol < 20) | 3446 | if (++bodydisablecontrol < 20) |
3442 | return; | 3447 | return; |
3443 | 3448 | ||
3444 | bodydisablecontrol = 0; | 3449 | |
3445 | d.BodyEnable(Body); | 3450 | d.BodyEnable(Body); |
3446 | } | 3451 | } |
3447 | 3452 | ||
3448 | d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator | 3453 | bodydisablecontrol = 0; |
3449 | |||
3450 | /* moved down to UpdateMove... where it belongs again | ||
3451 | |||
3452 | // check outside region | ||
3453 | |||
3454 | if (lpos.Z < -100 || lpos.Z > 100000f) | ||
3455 | { | ||
3456 | m_outbounds = true; | ||
3457 | |||
3458 | lpos.Z = Util.Clip(lpos.Z, -100f, 100000f); | ||
3459 | _acceleration.X = 0; | ||
3460 | _acceleration.Y = 0; | ||
3461 | _acceleration.Z = 0; | ||
3462 | |||
3463 | _velocity.X = 0; | ||
3464 | _velocity.Y = 0; | ||
3465 | _velocity.Z = 0; | ||
3466 | m_rotationalVelocity.X = 0; | ||
3467 | m_rotationalVelocity.Y = 0; | ||
3468 | m_rotationalVelocity.Z = 0; | ||
3469 | |||
3470 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
3471 | d.BodySetAngularVel(Body, 0, 0, 0); // stop it | ||
3472 | d.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere | ||
3473 | m_lastposition = _position; | ||
3474 | m_lastorientation = _orientation; | ||
3475 | |||
3476 | base.RequestPhysicsterseUpdate(); | ||
3477 | |||
3478 | throttleCounter = 0; | ||
3479 | _zeroFlag = true; | ||
3480 | |||
3481 | disableBodySoft(); // disable it and colisions | ||
3482 | base.RaiseOutOfBounds(_position); | ||
3483 | return; | ||
3484 | } | ||
3485 | |||
3486 | if (lpos.X < 0f) | ||
3487 | { | ||
3488 | _position.X = Util.Clip(lpos.X, -2f, -0.1f); | ||
3489 | m_outbounds = true; | ||
3490 | } | ||
3491 | else if (lpos.X > _parent_scene.WorldExtents.X) | ||
3492 | { | ||
3493 | _position.X = Util.Clip(lpos.X, _parent_scene.WorldExtents.X + 0.1f, _parent_scene.WorldExtents.X + 2f); | ||
3494 | m_outbounds = true; | ||
3495 | } | ||
3496 | if (lpos.Y < 0f) | ||
3497 | { | ||
3498 | _position.Y = Util.Clip(lpos.Y, -2f, -0.1f); | ||
3499 | m_outbounds = true; | ||
3500 | } | ||
3501 | else if (lpos.Y > _parent_scene.WorldExtents.Y) | ||
3502 | { | ||
3503 | _position.Y = Util.Clip(lpos.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f); | ||
3504 | m_outbounds = true; | ||
3505 | } | ||
3506 | |||
3507 | if (m_outbounds) | ||
3508 | { | ||
3509 | m_lastposition = _position; | ||
3510 | m_lastorientation = _orientation; | ||
3511 | |||
3512 | d.Vector3 dtmp = d.BodyGetAngularVel(Body); | ||
3513 | m_rotationalVelocity.X = dtmp.X; | ||
3514 | m_rotationalVelocity.Y = dtmp.Y; | ||
3515 | m_rotationalVelocity.Z = dtmp.Z; | ||
3516 | 3454 | ||
3517 | dtmp = d.BodyGetLinearVel(Body); | 3455 | d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator |
3518 | _velocity.X = dtmp.X; | ||
3519 | _velocity.Y = dtmp.Y; | ||
3520 | _velocity.Z = dtmp.Z; | ||
3521 | 3456 | ||
3522 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it | ||
3523 | d.BodySetAngularVel(Body, 0, 0, 0); | ||
3524 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
3525 | disableBodySoft(); // stop collisions | ||
3526 | base.RequestPhysicsterseUpdate(); | ||
3527 | return; | ||
3528 | } | ||
3529 | */ | ||
3530 | if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) | 3457 | if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) |
3531 | { | 3458 | { |
3532 | // 'VEHICLES' are dealt with in ODEDynamics.cs | 3459 | // 'VEHICLES' are dealt with in ODEDynamics.cs |
@@ -3721,7 +3648,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3721 | 3648 | ||
3722 | base.RequestPhysicsterseUpdate(); | 3649 | base.RequestPhysicsterseUpdate(); |
3723 | 3650 | ||
3724 | throttleCounter = 0; | 3651 | // throttleCounter = 0; |
3725 | _zeroFlag = true; | 3652 | _zeroFlag = true; |
3726 | 3653 | ||
3727 | disableBodySoft(); // disable it and colisions | 3654 | disableBodySoft(); // disable it and colisions |
@@ -3769,6 +3696,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3769 | d.BodySetAngularVel(Body, 0, 0, 0); | 3696 | d.BodySetAngularVel(Body, 0, 0, 0); |
3770 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 3697 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
3771 | disableBodySoft(); // stop collisions | 3698 | disableBodySoft(); // stop collisions |
3699 | UnSubscribeEvents(); | ||
3700 | |||
3772 | base.RequestPhysicsterseUpdate(); | 3701 | base.RequestPhysicsterseUpdate(); |
3773 | return; | 3702 | return; |
3774 | } | 3703 | } |
@@ -3940,8 +3869,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3940 | m_vehicle = null; | 3869 | m_vehicle = null; |
3941 | RemoveGeom(); | 3870 | RemoveGeom(); |
3942 | m_targetSpace = IntPtr.Zero; | 3871 | m_targetSpace = IntPtr.Zero; |
3943 | if (m_eventsubscription > 0) | 3872 | UnSubscribeEvents(); |
3944 | UnSubscribeEvents(); | ||
3945 | return true; | 3873 | return true; |
3946 | 3874 | ||
3947 | case changes.Link: | 3875 | case changes.Link: |