ubitODE: - don't try to hover underground unless volumedetector (that doesn't colide with it)

avinationmerge
UbitUmarov 2012-04-21 05:16:54 +01:00
parent 3b56c44453
commit 190e7a4334
1 changed files with 94 additions and 48 deletions

View File

@ -68,9 +68,17 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_fakeisphysical; private bool m_fakeisphysical;
private bool m_isphantom; private bool m_isphantom;
private bool m_fakeisphantom; private bool m_fakeisphantom;
internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
private bool m_fakeisVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
protected bool m_building; protected bool m_building;
protected bool m_forcePosOrRotation; protected bool m_forcePosOrRotation;
private bool m_iscolliding;
internal bool m_isSelected;
private bool m_delaySelect;
private bool m_lastdoneSelected;
internal bool m_outbounds;
private Quaternion m_lastorientation = new Quaternion(); private Quaternion m_lastorientation = new Quaternion();
private Quaternion _orientation; private Quaternion _orientation;
@ -153,14 +161,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private List<OdePrim> childrenPrim = new List<OdePrim>(); private List<OdePrim> childrenPrim = new List<OdePrim>();
private bool m_iscolliding;
public bool m_isSelected;
private bool m_delaySelect;
private bool m_lastdoneSelected;
public bool m_outbounds;
internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
private bool m_throttleUpdates; private bool m_throttleUpdates;
private int throttleCounter; private int throttleCounter;
@ -223,9 +223,12 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool IsVolumeDtc public override bool IsVolumeDtc
{ {
set { return; } get { return m_fakeisVolumeDetect; }
get { return m_isVolumeDetect; } set
{
m_fakeisVolumeDetect = value;
AddChange(changes.VolumeDtc, value);
}
} }
@ -234,10 +237,7 @@ namespace OpenSim.Region.Physics.OdePlugin
get { return m_fakeisphantom; } get { return m_fakeisphantom; }
set set
{ {
m_fakeisphantom = value; // we show imediatly to outside that we changed physical m_fakeisphantom = value;
// and also to stop imediatly some updates
// but real change will only happen in taintprocessing
AddChange(changes.Phantom, value); AddChange(changes.Phantom, value);
} }
} }
@ -427,7 +427,8 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void SetVolumeDetect(int param) public override void SetVolumeDetect(int param)
{ {
AddChange(changes.VolumeDtc, (param != 0)); m_fakeisVolumeDetect = (param != 0);
AddChange(changes.VolumeDtc, m_fakeisVolumeDetect);
} }
public override Vector3 GeometricCenter public override Vector3 GeometricCenter
@ -958,6 +959,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_fakeisphysical = m_isphysical; m_fakeisphysical = m_isphysical;
m_isVolumeDetect = false; m_isVolumeDetect = false;
m_fakeisVolumeDetect = false;
m_force = Vector3.Zero; m_force = Vector3.Zero;
@ -1066,7 +1068,7 @@ namespace OpenSim.Region.Physics.OdePlugin
prm.m_collisionCategories = CollisionCategories.Selected; prm.m_collisionCategories = CollisionCategories.Selected;
prm.m_collisionFlags = 0; prm.m_collisionFlags = 0;
} }
else if (prm.IsVolumeDtc) else if (prm.m_isVolumeDetect)
{ {
prm.m_collisionCategories = CollisionCategories.VolumeDtc; prm.m_collisionCategories = CollisionCategories.VolumeDtc;
if (m_isphysical) if (m_isphysical)
@ -1445,14 +1447,14 @@ namespace OpenSim.Region.Physics.OdePlugin
hasOOBoffsetFromMesh = false; hasOOBoffsetFromMesh = false;
CalcPrimBodyData(); CalcPrimBodyData();
} }
/*
private void ChildSetGeom(OdePrim odePrim) private void ChildSetGeom(OdePrim odePrim)
{ {
// well.. // well..
DestroyBody(); DestroyBody();
MakeBody(); MakeBody();
} }
*/
//sets non physical prim m_targetSpace to right space in spaces grid for static prims //sets non physical prim m_targetSpace to right space in spaces grid for static prims
// should only be called for non physical prims unless they are becoming non physical // should only be called for non physical prims unless they are becoming non physical
private void SetInStaticSpace(OdePrim prim) private void SetInStaticSpace(OdePrim prim)
@ -2650,6 +2652,31 @@ namespace OpenSim.Region.Physics.OdePlugin
ApplyCollisionCatFlags(); ApplyCollisionCatFlags();
} }
/* not in use
internal void ChildSelectedChange(bool childSelect)
{
if(childPrim)
return;
if (childSelect == m_isSelected)
return;
if (childSelect)
{
DoSelectedStatus(true);
}
else
{
foreach (OdePrim prm in childrenPrim)
{
if (prm.m_isSelected)
return;
}
DoSelectedStatus(false);
}
}
*/
private void changeSelectedStatus(bool newval) private void changeSelectedStatus(bool newval)
{ {
if (m_lastdoneSelected == newval) if (m_lastdoneSelected == newval)
@ -2669,6 +2696,12 @@ namespace OpenSim.Region.Physics.OdePlugin
private void DoSelectedStatus(bool newval) private void DoSelectedStatus(bool newval)
{ {
if (m_isSelected == newval)
{
resetCollisionAccounting();
return;
}
m_isSelected = newval; m_isSelected = newval;
Stop(); Stop();
@ -2706,6 +2739,9 @@ namespace OpenSim.Region.Physics.OdePlugin
prm.m_delaySelect = false; prm.m_delaySelect = false;
} }
} }
// else if (_parent != null)
// ((OdePrim)_parent).ChildSelectedChange(true);
if (prim_geom != null) if (prim_geom != null)
{ {
@ -2741,8 +2777,13 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
if (!childPrim && Body != IntPtr.Zero && !m_disabled) if (!childPrim)
d.BodyEnable(Body); {
if (Body != IntPtr.Zero && !m_disabled)
d.BodyEnable(Body);
}
// else if (_parent != null)
// ((OdePrim)_parent).ChildSelectedChange(false);
UpdateCollisionCatFlags(); UpdateCollisionCatFlags();
ApplyCollisionCatFlags(); ApplyCollisionCatFlags();
@ -3145,6 +3186,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changeVolumedetetion(bool newVolDtc) private void changeVolumedetetion(bool newVolDtc)
{ {
m_isVolumeDetect = newVolDtc; m_isVolumeDetect = newVolDtc;
m_fakeisVolumeDetect = newVolDtc;
UpdateCollisionCatFlags(); UpdateCollisionCatFlags();
ApplyCollisionCatFlags(); ApplyCollisionCatFlags();
} }
@ -3370,7 +3412,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P; //fz = fz + (_target_velocity.Z - vel.Z) * (PID_D) + (_zeroPosition.Z - pos.Z) * PID_P;
d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z); d.BodySetPosition(Body, m_PIDTarget.X, m_PIDTarget.Y, m_PIDTarget.Z);
d.BodySetLinearVel(Body, 0, 0, 0); d.BodySetLinearVel(Body, 0, 0, 0);
d.BodyAddForce(Body, 0, 0, fz); // d.BodyAddForce(Body, 0, 0, fz);
return; return;
} }
else else
@ -3419,14 +3461,17 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
case PIDHoverType.Ground: case PIDHoverType.Ground:
m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y); m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
break; break;
case PIDHoverType.GroundAndWater: case PIDHoverType.GroundAndWater:
m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y); m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
m_waterHeight = _parent_scene.GetWaterLevel(); m_waterHeight = _parent_scene.GetWaterLevel();
if (m_groundHeight > m_waterHeight) if (m_groundHeight > m_waterHeight)
{ {
m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight; if (m_PIDHoverHeight > 0 || m_isVolumeDetect)
m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
else
m_targetHoverHeight = m_groundHeight;
} }
else else
{ {
@ -3436,34 +3481,35 @@ namespace OpenSim.Region.Physics.OdePlugin
} // end switch (m_PIDHoverType) } // end switch (m_PIDHoverType)
// don't go underground unless volumedetector
_target_velocity =
new Vector3(0.0f, 0.0f, if (m_targetHoverHeight > m_groundHeight || m_isVolumeDetect)
(m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
);
// if velocity is zero, use position control; otherwise, velocity control
if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
{ {
// keep track of where we stopped. No more slippin' & slidin' fz = (m_targetHoverHeight - pos.Z) * (PID_G - m_PIDHoverTau) * timestep;
// We only want to deactivate the PID Controller if we think we want to have our surrogate // if velocity is zero, use position control; otherwise, velocity control
// react to the physics scene by moving it's position.
// Avatar to Avatar collisions
// Prim to avatar collisions
d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight); if (Math.Abs(fz) < 0.1f)
d.BodySetLinearVel(Body, vel.X, vel.Y, 0); {
// ? d.BodyAddForce(Body, 0, 0, fz); // keep track of where we stopped. No more slippin' & slidin'
return;
}
else
{
_zeroFlag = false;
// We're flying and colliding with something // We only want to deactivate the PID Controller if we think we want to have our surrogate
fz = ((_target_velocity.Z - vel.Z) * (PID_D)); // react to the physics scene by moving it's position.
// Avatar to Avatar collisions
// Prim to avatar collisions
d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
// ? d.BodyAddForce(Body, 0, 0, fz);
return;
}
else
{
_zeroFlag = false;
// We're flying and colliding with something
fz = ((fz - vel.Z) * (PID_D));
}
} }
} }
else else