Cleaned up ScenePresence parameters for Flying, WasFlying, FlyingOld and IsColliding
parent
3c55d2e776
commit
c34ab0ee66
|
@ -5083,7 +5083,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
presence.AbsolutePosition = presence.MoveToPositionTarget;
|
presence.AbsolutePosition = presence.MoveToPositionTarget;
|
||||||
presence.ResetMoveToTarget();
|
presence.ResetMoveToTarget();
|
||||||
|
|
||||||
if (presence.PhysicsActor.Flying)
|
if (presence.Flying)
|
||||||
{
|
{
|
||||||
// A horrible hack to stop the avatar dead in its tracks rather than having them overshoot
|
// A horrible hack to stop the avatar dead in its tracks rather than having them overshoot
|
||||||
// the target if flying.
|
// the target if flying.
|
||||||
|
@ -5091,16 +5091,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// least be able to set collision status once, rather than 5 times to give it enough
|
// least be able to set collision status once, rather than 5 times to give it enough
|
||||||
// weighting so that that PhysicsActor thinks it really is colliding.
|
// weighting so that that PhysicsActor thinks it really is colliding.
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
presence.PhysicsActor.IsColliding = true;
|
presence.IsColliding = true;
|
||||||
|
|
||||||
if (presence.LandAtTarget)
|
if (presence.LandAtTarget)
|
||||||
presence.PhysicsActor.Flying = false;
|
presence.Flying = false;
|
||||||
|
|
||||||
// Vector3 targetPos = presence.MoveToPositionTarget;
|
// Vector3 targetPos = presence.MoveToPositionTarget;
|
||||||
// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
|
// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
|
||||||
// if (targetPos.Z - terrainHeight < 0.2)
|
// if (targetPos.Z - terrainHeight < 0.2)
|
||||||
// {
|
// {
|
||||||
// presence.PhysicsActor.Flying = false;
|
// presence.Flying = false;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,12 +142,27 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
get { return m_userFlags; }
|
get { return m_userFlags; }
|
||||||
}
|
}
|
||||||
private bool m_flyingOld; // add for fly velocity control
|
|
||||||
|
// Flying
|
||||||
|
public bool Flying
|
||||||
|
{
|
||||||
|
get { return PhysicsActor != null && PhysicsActor.Flying; }
|
||||||
|
set { PhysicsActor.Flying = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// add for fly velocity control
|
||||||
|
private bool FlyingOld {get; set;}
|
||||||
public bool WasFlying
|
public bool WasFlying
|
||||||
{
|
{
|
||||||
get { return m_wasFlying; }
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsColliding
|
||||||
|
{
|
||||||
|
get { return PhysicsActor != null && PhysicsActor.IsColliding; }
|
||||||
|
// We would expect setting IsColliding to be private but it's used by a hack in Scene
|
||||||
|
set { PhysicsActor.IsColliding = value; }
|
||||||
}
|
}
|
||||||
private bool m_wasFlying; // add for fly velocity control
|
|
||||||
|
|
||||||
// private int m_lastColCount = -1; //KF: Look for Collision chnages
|
// private int m_lastColCount = -1; //KF: Look for Collision chnages
|
||||||
// private int m_updateCount = 0; //KF: Update Anims for a while
|
// private int m_updateCount = 0; //KF: Update Anims for a while
|
||||||
|
@ -682,9 +697,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
set {
|
set {
|
||||||
if(value)
|
if(value)
|
||||||
{
|
{
|
||||||
if ((PhysicsActor != null) && PhysicsActor.Flying)
|
if (Flying)
|
||||||
m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY;
|
m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY;
|
||||||
else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0)
|
else
|
||||||
m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY;
|
m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY;
|
||||||
}
|
}
|
||||||
m_inTransit = value;
|
m_inTransit = value;
|
||||||
|
@ -908,11 +923,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
if (ForceFly)
|
if (ForceFly)
|
||||||
{
|
{
|
||||||
PhysicsActor.Flying = true;
|
Flying = true;
|
||||||
}
|
}
|
||||||
else if (FlyDisabled)
|
else if (FlyDisabled)
|
||||||
{
|
{
|
||||||
PhysicsActor.Flying = false;
|
Flying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
|
// Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
|
||||||
|
@ -1037,10 +1052,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="pos"></param>
|
/// <param name="pos"></param>
|
||||||
public void Teleport(Vector3 pos)
|
public void Teleport(Vector3 pos)
|
||||||
{
|
{
|
||||||
bool isFlying = false;
|
bool isFlying = Flying;
|
||||||
if (PhysicsActor != null)
|
|
||||||
isFlying = PhysicsActor.Flying;
|
|
||||||
|
|
||||||
RemoveFromPhysicalScene();
|
RemoveFromPhysicalScene();
|
||||||
Velocity = Vector3.Zero;
|
Velocity = Vector3.Zero;
|
||||||
AbsolutePosition = pos;
|
AbsolutePosition = pos;
|
||||||
|
@ -1051,10 +1063,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public void TeleportWithMomentum(Vector3 pos)
|
public void TeleportWithMomentum(Vector3 pos)
|
||||||
{
|
{
|
||||||
bool isFlying = false;
|
bool isFlying = Flying;
|
||||||
if (PhysicsActor != null)
|
|
||||||
isFlying = PhysicsActor.Flying;
|
|
||||||
|
|
||||||
RemoveFromPhysicalScene();
|
RemoveFromPhysicalScene();
|
||||||
AbsolutePosition = pos;
|
AbsolutePosition = pos;
|
||||||
AddToPhysicalScene(isFlying);
|
AddToPhysicalScene(isFlying);
|
||||||
|
@ -1188,8 +1197,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
AbsolutePosition = pos;
|
AbsolutePosition = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
|
bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
|
||||||
MakeRootAgent(AbsolutePosition, m_flying);
|
MakeRootAgent(AbsolutePosition, flying);
|
||||||
|
|
||||||
if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
|
if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
|
||||||
{
|
{
|
||||||
|
@ -1414,7 +1423,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
bool DCFlagKeyPressed = false;
|
bool DCFlagKeyPressed = false;
|
||||||
Vector3 agent_control_v3 = Vector3.Zero;
|
Vector3 agent_control_v3 = Vector3.Zero;
|
||||||
|
|
||||||
bool oldflying = PhysicsActor.Flying;
|
bool oldflying = Flying;
|
||||||
|
|
||||||
if (ForceFly)
|
if (ForceFly)
|
||||||
actor.Flying = true;
|
actor.Flying = true;
|
||||||
|
@ -1434,7 +1443,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
// use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
|
// use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
|
||||||
// this prevents 'jumping' in inappropriate situations.
|
// this prevents 'jumping' in inappropriate situations.
|
||||||
if ((m_mouseLook && !PhysicsActor.Flying) || (m_leftButtonDown && !PhysicsActor.Flying))
|
if (!Flying && (m_mouseLook || m_leftButtonDown))
|
||||||
dirVectors = GetWalkDirectionVectors();
|
dirVectors = GetWalkDirectionVectors();
|
||||||
else
|
else
|
||||||
dirVectors = Dir_Vectors;
|
dirVectors = Dir_Vectors;
|
||||||
|
@ -1521,7 +1530,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// with something with the down arrow pressed.
|
// with something with the down arrow pressed.
|
||||||
|
|
||||||
// Only do this if we're flying
|
// Only do this if we're flying
|
||||||
if (PhysicsActor != null && PhysicsActor.Flying && !ForceFly)
|
if (Flying && !ForceFly)
|
||||||
{
|
{
|
||||||
// Landing detection code
|
// Landing detection code
|
||||||
|
|
||||||
|
@ -1529,7 +1538,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
|
bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
|
||||||
((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
|
((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
|
||||||
|
|
||||||
if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland)
|
if (Flying && IsColliding && controlland)
|
||||||
{
|
{
|
||||||
// nesting this check because LengthSquared() is expensive and we don't
|
// nesting this check because LengthSquared() is expensive and we don't
|
||||||
// want to do it every step when flying.
|
// want to do it every step when flying.
|
||||||
|
@ -1742,9 +1751,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
|
Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
if (noFly)
|
if (noFly)
|
||||||
PhysicsActor.Flying = false;
|
Flying = false;
|
||||||
else if (pos.Z > terrainHeight)
|
else if (pos.Z > terrainHeight)
|
||||||
PhysicsActor.Flying = true;
|
Flying = true;
|
||||||
|
|
||||||
LandAtTarget = landAtTarget;
|
LandAtTarget = landAtTarget;
|
||||||
MovingToTarget = true;
|
MovingToTarget = true;
|
||||||
|
@ -2307,42 +2316,42 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
Vector3 direc = vec * Rotation;
|
Vector3 direc = vec * Rotation;
|
||||||
direc.Normalize();
|
direc.Normalize();
|
||||||
|
|
||||||
if (PhysicsActor.Flying != m_flyingOld) // add for fly velocity control
|
if (Flying != FlyingOld) // add for fly velocity control
|
||||||
{
|
{
|
||||||
m_flyingOld = PhysicsActor.Flying; // add for fly velocity control
|
FlyingOld = Flying; // add for fly velocity control
|
||||||
if (!PhysicsActor.Flying)
|
if (!Flying)
|
||||||
m_wasFlying = true; // add for fly velocity control
|
WasFlying = true; // add for fly velocity control
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PhysicsActor.IsColliding == true)
|
if (IsColliding)
|
||||||
m_wasFlying = false; // add for fly velocity control
|
WasFlying = false; // add for fly velocity control
|
||||||
|
|
||||||
if ((vec.Z == 0f) && !PhysicsActor.Flying)
|
if ((vec.Z == 0f) && !Flying)
|
||||||
direc.Z = 0f; // Prevent camera WASD up.
|
direc.Z = 0f; // Prevent camera WASD up.
|
||||||
|
|
||||||
direc *= 0.03f * 128f * SpeedModifier;
|
direc *= 0.03f * 128f * SpeedModifier;
|
||||||
|
|
||||||
if (PhysicsActor != null)
|
if (PhysicsActor != null)
|
||||||
{
|
{
|
||||||
if (PhysicsActor.Flying)
|
if (Flying)
|
||||||
{
|
{
|
||||||
direc *= 4.0f;
|
direc *= 4.0f;
|
||||||
//bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
|
//bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
|
||||||
//if (controlland)
|
//if (controlland)
|
||||||
// m_log.Info("[AGENT]: landCommand");
|
// m_log.Info("[AGENT]: landCommand");
|
||||||
//if (PhysicsActor.IsColliding)
|
//if (IsColliding)
|
||||||
// m_log.Info("[AGENT]: colliding");
|
// m_log.Info("[AGENT]: colliding");
|
||||||
//if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland)
|
//if (Flying && IsColliding && controlland)
|
||||||
//{
|
//{
|
||||||
// StopFlying();
|
// StopFlying();
|
||||||
// m_log.Info("[AGENT]: Stop Flying");
|
// m_log.Info("[AGENT]: Stop Flying");
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
if (Animator.Falling && m_wasFlying) // if falling from flying, disable motion add
|
if (Animator.Falling && WasFlying) // if falling from flying, disable motion add
|
||||||
{
|
{
|
||||||
direc *= 0.0f;
|
direc *= 0.0f;
|
||||||
}
|
}
|
||||||
else if (!PhysicsActor.Flying && PhysicsActor.IsColliding)
|
else if (!Flying && IsColliding)
|
||||||
{
|
{
|
||||||
if (direc.Z > 2.0f)
|
if (direc.Z > 2.0f)
|
||||||
{
|
{
|
||||||
|
@ -2809,7 +2818,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
if (m_requestedSitTargetUUID == UUID.Zero)
|
if (m_requestedSitTargetUUID == UUID.Zero)
|
||||||
{
|
{
|
||||||
bool isFlying = PhysicsActor.Flying;
|
bool isFlying = Flying;
|
||||||
RemoveFromPhysicalScene();
|
RemoveFromPhysicalScene();
|
||||||
|
|
||||||
Vector3 pos = AbsolutePosition;
|
Vector3 pos = AbsolutePosition;
|
||||||
|
@ -2836,7 +2845,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
if (m_requestedSitTargetUUID == UUID.Zero)
|
if (m_requestedSitTargetUUID == UUID.Zero)
|
||||||
{
|
{
|
||||||
bool isFlying = PhysicsActor.Flying;
|
bool isFlying = Flying;
|
||||||
RemoveFromPhysicalScene();
|
RemoveFromPhysicalScene();
|
||||||
|
|
||||||
Vector3 pos = AbsolutePosition;
|
Vector3 pos = AbsolutePosition;
|
||||||
|
@ -2886,7 +2895,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return m_scene.CrossAgentToNewRegion(this, PhysicsActor.Flying);
|
return m_scene.CrossAgentToNewRegion(this, Flying);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -3162,7 +3171,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
Appearance = new AvatarAppearance(cAgent.Appearance);
|
Appearance = new AvatarAppearance(cAgent.Appearance);
|
||||||
if (PhysicsActor != null)
|
if (PhysicsActor != null)
|
||||||
{
|
{
|
||||||
bool isFlying = PhysicsActor.Flying;
|
bool isFlying = Flying;
|
||||||
RemoveFromPhysicalScene();
|
RemoveFromPhysicalScene();
|
||||||
AddToPhysicalScene(isFlying);
|
AddToPhysicalScene(isFlying);
|
||||||
}
|
}
|
||||||
|
@ -3265,7 +3274,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
private void OutOfBoundsCall(Vector3 pos)
|
private void OutOfBoundsCall(Vector3 pos)
|
||||||
{
|
{
|
||||||
//bool flying = PhysicsActor.Flying;
|
//bool flying = Flying;
|
||||||
//RemoveFromPhysicalScene();
|
//RemoveFromPhysicalScene();
|
||||||
|
|
||||||
//AddToPhysicalScene(flying);
|
//AddToPhysicalScene(flying);
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
|
|
||||||
TestScene scene = SceneHelpers.SetupScene();
|
TestScene scene = SceneHelpers.SetupScene();
|
||||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
|
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
|
||||||
sp.PhysicsActor.Flying = true;
|
sp.Flying = true;
|
||||||
sp.PhysicsCollisionUpdate(new CollisionEventUpdate());
|
sp.PhysicsCollisionUpdate(new CollisionEventUpdate());
|
||||||
|
|
||||||
Assert.That(sp.Animator.CurrentMovementAnimation, Is.EqualTo("HOVER"));
|
Assert.That(sp.Animator.CurrentMovementAnimation, Is.EqualTo("HOVER"));
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
// Vector3 startPos = new Vector3(128, 128, 30);
|
// Vector3 startPos = new Vector3(128, 128, 30);
|
||||||
|
|
||||||
// For now, we'll make the scene presence fly to simplify this test, but this needs to change.
|
// For now, we'll make the scene presence fly to simplify this test, but this needs to change.
|
||||||
sp.PhysicsActor.Flying = true;
|
sp.Flying = true;
|
||||||
|
|
||||||
m_scene.Update();
|
m_scene.Update();
|
||||||
Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
|
Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
|
||||||
|
|
|
@ -175,7 +175,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
|
||||||
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
|
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
|
||||||
|
|
||||||
// For now, we'll make the scene presence fly to simplify this test, but this needs to change.
|
// For now, we'll make the scene presence fly to simplify this test, but this needs to change.
|
||||||
npc.PhysicsActor.Flying = true;
|
npc.Flying = true;
|
||||||
|
|
||||||
scene.Update();
|
scene.Update();
|
||||||
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
|
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
|
||||||
|
|
|
@ -5573,9 +5573,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
// note: this may need some tweaking when walking downhill. you "fall down" for a brief instant
|
// note: this may need some tweaking when walking downhill. you "fall down" for a brief instant
|
||||||
// and don't collide when walking downhill, which instantly registers as in-air, briefly. should
|
// and don't collide when walking downhill, which instantly registers as in-air, briefly. should
|
||||||
// there be some minimum non-collision threshold time before claiming the avatar is in-air?
|
// there be some minimum non-collision threshold time before claiming the avatar is in-air?
|
||||||
if ((flags & ScriptBaseClass.AGENT_WALKING) == 0 &&
|
if ((flags & ScriptBaseClass.AGENT_WALKING) == 0 && !agent.IsColliding )
|
||||||
agent.PhysicsActor != null &&
|
|
||||||
!agent.PhysicsActor.IsColliding)
|
|
||||||
{
|
{
|
||||||
flags |= ScriptBaseClass.AGENT_IN_AIR;
|
flags |= ScriptBaseClass.AGENT_IN_AIR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue