aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs140
1 files changed, 93 insertions, 47 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 5467b9f..49766f8 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -68,9 +68,17 @@ namespace OpenSim.Region.Physics.OdePlugin
68 private bool m_fakeisphysical; 68 private bool m_fakeisphysical;
69 private bool m_isphantom; 69 private bool m_isphantom;
70 private bool m_fakeisphantom; 70 private bool m_fakeisphantom;
71 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
72 private bool m_fakeisVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
71 73
72 protected bool m_building; 74 protected bool m_building;
73 protected bool m_forcePosOrRotation; 75 protected bool m_forcePosOrRotation;
76 private bool m_iscolliding;
77
78 internal bool m_isSelected;
79 private bool m_delaySelect;
80 private bool m_lastdoneSelected;
81 internal bool m_outbounds;
74 82
75 private Quaternion m_lastorientation = new Quaternion(); 83 private Quaternion m_lastorientation = new Quaternion();
76 private Quaternion _orientation; 84 private Quaternion _orientation;
@@ -153,14 +161,6 @@ namespace OpenSim.Region.Physics.OdePlugin
153 161
154 private List<OdePrim> childrenPrim = new List<OdePrim>(); 162 private List<OdePrim> childrenPrim = new List<OdePrim>();
155 163
156 private bool m_iscolliding;
157
158 public bool m_isSelected;
159 private bool m_delaySelect;
160 private bool m_lastdoneSelected;
161 public bool m_outbounds;
162
163 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
164 164
165 private bool m_throttleUpdates; 165 private bool m_throttleUpdates;
166 private int throttleCounter; 166 private int throttleCounter;
@@ -223,9 +223,12 @@ namespace OpenSim.Region.Physics.OdePlugin
223 223
224 public override bool IsVolumeDtc 224 public override bool IsVolumeDtc
225 { 225 {
226 set { return; } 226 get { return m_fakeisVolumeDetect; }
227 get { return m_isVolumeDetect; } 227 set
228 228 {
229 m_fakeisVolumeDetect = value;
230 AddChange(changes.VolumeDtc, value);
231 }
229 } 232 }
230 233
231 234
@@ -234,10 +237,7 @@ namespace OpenSim.Region.Physics.OdePlugin
234 get { return m_fakeisphantom; } 237 get { return m_fakeisphantom; }
235 set 238 set
236 { 239 {
237 m_fakeisphantom = value; // we show imediatly to outside that we changed physical 240 m_fakeisphantom = value;
238 // and also to stop imediatly some updates
239 // but real change will only happen in taintprocessing
240
241 AddChange(changes.Phantom, value); 241 AddChange(changes.Phantom, value);
242 } 242 }
243 } 243 }
@@ -427,7 +427,8 @@ namespace OpenSim.Region.Physics.OdePlugin
427 427
428 public override void SetVolumeDetect(int param) 428 public override void SetVolumeDetect(int param)
429 { 429 {
430 AddChange(changes.VolumeDtc, (param != 0)); 430 m_fakeisVolumeDetect = (param != 0);
431 AddChange(changes.VolumeDtc, m_fakeisVolumeDetect);
431 } 432 }
432 433
433 public override Vector3 GeometricCenter 434 public override Vector3 GeometricCenter
@@ -958,6 +959,7 @@ namespace OpenSim.Region.Physics.OdePlugin
958 m_fakeisphysical = m_isphysical; 959 m_fakeisphysical = m_isphysical;
959 960
960 m_isVolumeDetect = false; 961 m_isVolumeDetect = false;
962 m_fakeisVolumeDetect = false;
961 963
962 m_force = Vector3.Zero; 964 m_force = Vector3.Zero;
963 965
@@ -1066,7 +1068,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1066 prm.m_collisionCategories = CollisionCategories.Selected; 1068 prm.m_collisionCategories = CollisionCategories.Selected;
1067 prm.m_collisionFlags = 0; 1069 prm.m_collisionFlags = 0;
1068 } 1070 }
1069 else if (prm.IsVolumeDtc) 1071 else if (prm.m_isVolumeDetect)
1070 { 1072 {
1071 prm.m_collisionCategories = CollisionCategories.VolumeDtc; 1073 prm.m_collisionCategories = CollisionCategories.VolumeDtc;
1072 if (m_isphysical) 1074 if (m_isphysical)
@@ -1445,14 +1447,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1445 hasOOBoffsetFromMesh = false; 1447 hasOOBoffsetFromMesh = false;
1446 CalcPrimBodyData(); 1448 CalcPrimBodyData();
1447 } 1449 }
1448 1450/*
1449 private void ChildSetGeom(OdePrim odePrim) 1451 private void ChildSetGeom(OdePrim odePrim)
1450 { 1452 {
1451 // well.. 1453 // well..
1452 DestroyBody(); 1454 DestroyBody();
1453 MakeBody(); 1455 MakeBody();
1454 } 1456 }
1455 1457*/
1456 //sets non physical prim m_targetSpace to right space in spaces grid for static prims 1458 //sets non physical prim m_targetSpace to right space in spaces grid for static prims
1457 // should only be called for non physical prims unless they are becoming non physical 1459 // should only be called for non physical prims unless they are becoming non physical
1458 private void SetInStaticSpace(OdePrim prim) 1460 private void SetInStaticSpace(OdePrim prim)
@@ -2650,6 +2652,31 @@ namespace OpenSim.Region.Physics.OdePlugin
2650 ApplyCollisionCatFlags(); 2652 ApplyCollisionCatFlags();
2651 } 2653 }
2652 2654
2655/* not in use
2656 internal void ChildSelectedChange(bool childSelect)
2657 {
2658 if(childPrim)
2659 return;
2660
2661 if (childSelect == m_isSelected)
2662 return;
2663
2664 if (childSelect)
2665 {
2666 DoSelectedStatus(true);
2667 }
2668
2669 else
2670 {
2671 foreach (OdePrim prm in childrenPrim)
2672 {
2673 if (prm.m_isSelected)
2674 return;
2675 }
2676 DoSelectedStatus(false);
2677 }
2678 }
2679*/
2653 private void changeSelectedStatus(bool newval) 2680 private void changeSelectedStatus(bool newval)
2654 { 2681 {
2655 if (m_lastdoneSelected == newval) 2682 if (m_lastdoneSelected == newval)
@@ -2669,6 +2696,12 @@ namespace OpenSim.Region.Physics.OdePlugin
2669 2696
2670 private void DoSelectedStatus(bool newval) 2697 private void DoSelectedStatus(bool newval)
2671 { 2698 {
2699 if (m_isSelected == newval)
2700 {
2701 resetCollisionAccounting();
2702 return;
2703 }
2704
2672 m_isSelected = newval; 2705 m_isSelected = newval;
2673 Stop(); 2706 Stop();
2674 2707
@@ -2706,6 +2739,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2706 prm.m_delaySelect = false; 2739 prm.m_delaySelect = false;
2707 } 2740 }
2708 } 2741 }
2742// else if (_parent != null)
2743// ((OdePrim)_parent).ChildSelectedChange(true);
2744
2709 2745
2710 if (prim_geom != null) 2746 if (prim_geom != null)
2711 { 2747 {
@@ -2741,8 +2777,13 @@ namespace OpenSim.Region.Physics.OdePlugin
2741 } 2777 }
2742 else 2778 else
2743 { 2779 {
2744 if (!childPrim && Body != IntPtr.Zero && !m_disabled) 2780 if (!childPrim)
2745 d.BodyEnable(Body); 2781 {
2782 if (Body != IntPtr.Zero && !m_disabled)
2783 d.BodyEnable(Body);
2784 }
2785// else if (_parent != null)
2786// ((OdePrim)_parent).ChildSelectedChange(false);
2746 2787
2747 UpdateCollisionCatFlags(); 2788 UpdateCollisionCatFlags();
2748 ApplyCollisionCatFlags(); 2789 ApplyCollisionCatFlags();
@@ -3145,6 +3186,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3145 private void changeVolumedetetion(bool newVolDtc) 3186 private void changeVolumedetetion(bool newVolDtc)
3146 { 3187 {
3147 m_isVolumeDetect = newVolDtc; 3188 m_isVolumeDetect = newVolDtc;
3189 m_fakeisVolumeDetect = newVolDtc;
3148 UpdateCollisionCatFlags(); 3190 UpdateCollisionCatFlags();
3149 ApplyCollisionCatFlags(); 3191 ApplyCollisionCatFlags();
3150 } 3192 }
@@ -3370,7 +3412,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3370 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P; 3412 //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
3371 d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z); 3413 d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
3372 d.BodySetLinearVel(Body, 0, 0, 0); 3414 d.BodySetLinearVel(Body, 0, 0, 0);
3373 d.BodyAddForce(Body, 0, 0, fz); 3415 // d.BodyAddForce(Body, 0, 0, fz);
3374 return; 3416 return;
3375 } 3417 }
3376 else 3418 else
@@ -3419,14 +3461,17 @@ namespace OpenSim.Region.Physics.OdePlugin
3419 { 3461 {
3420 case PIDHoverType.Ground: 3462 case PIDHoverType.Ground:
3421 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y); 3463 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
3422 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight; 3464
3423 break; 3465 break;
3424 case PIDHoverType.GroundAndWater: 3466 case PIDHoverType.GroundAndWater:
3425 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y); 3467 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
3426 m_waterHeight = _parent_scene.GetWaterLevel(); 3468 m_waterHeight = _parent_scene.GetWaterLevel();
3427 if (m_groundHeight > m_waterHeight) 3469 if (m_groundHeight > m_waterHeight)
3428 { 3470 {
3429 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight; 3471 if (m_PIDHoverHeight > 0 || m_isVolumeDetect)
3472 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
3473 else
3474 m_targetHoverHeight = m_groundHeight;
3430 } 3475 }
3431 else 3476 else
3432 { 3477 {
@@ -3436,34 +3481,35 @@ namespace OpenSim.Region.Physics.OdePlugin
3436 3481
3437 } // end switch (m_PIDHoverType) 3482 } // end switch (m_PIDHoverType)
3438 3483
3484 // don't go underground unless volumedetector
3485
3486 if (m_targetHoverHeight > m_groundHeight || m_isVolumeDetect)
3487 {
3488 fz = (m_targetHoverHeight - pos.Z) * (PID_G - m_PIDHoverTau) * timestep;
3439 3489
3440 _target_velocity = 3490 // if velocity is zero, use position control; otherwise, velocity control
3441 new Vector3(0.0f, 0.0f,
3442 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
3443 );
3444
3445 // if velocity is zero, use position control; otherwise, velocity control
3446 3491
3447 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f)) 3492 if (Math.Abs(fz) < 0.1f)
3448 { 3493 {
3449 // keep track of where we stopped. No more slippin' & slidin' 3494 // keep track of where we stopped. No more slippin' & slidin'
3450 3495
3451 // We only want to deactivate the PID Controller if we think we want to have our surrogate 3496 // We only want to deactivate the PID Controller if we think we want to have our surrogate
3452 // react to the physics scene by moving it's position. 3497 // react to the physics scene by moving it's position.
3453 // Avatar to Avatar collisions 3498 // Avatar to Avatar collisions
3454 // Prim to avatar collisions 3499 // Prim to avatar collisions
3455 3500
3456 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight); 3501 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
3457 d.BodySetLinearVel(Body, vel.X, vel.Y, 0); 3502 d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
3458 // ? d.BodyAddForce(Body, 0, 0, fz); 3503 // ? d.BodyAddForce(Body, 0, 0, fz);
3459 return; 3504 return;
3460 } 3505 }
3461 else 3506 else
3462 { 3507 {
3463 _zeroFlag = false; 3508 _zeroFlag = false;
3464 3509
3465 // We're flying and colliding with something 3510 // We're flying and colliding with something
3466 fz = ((_target_velocity.Z - vel.Z) * (PID_D)); 3511 fz = ((fz - vel.Z) * (PID_D));
3512 }
3467 } 3513 }
3468 } 3514 }
3469 else 3515 else