* Makes forward and backward key reactions faster by responding to the NUDGE type movements.

mysql-performance
Teravus Ovares (Dan Olivares) 2009-12-30 15:01:14 -05:00
parent 2205d1c486
commit 16a64c400b
2 changed files with 35 additions and 9 deletions

View File

@ -156,7 +156,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix);
// Check control flags
bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
bool heldForward =
(((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) || ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS));
bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG;
bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;

View File

@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes
protected RegionInfo m_regionInfo;
protected ulong crossingFromRegion;
private readonly Vector3[] Dir_Vectors = new Vector3[6];
private readonly Vector3[] Dir_Vectors = new Vector3[9];
// Position of agent's camera in world (region cordinates)
protected Vector3 m_CameraCenter;
@ -233,6 +233,8 @@ namespace OpenSim.Region.Framework.Scenes
DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG,
DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS,
DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS,
DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
}
@ -717,19 +719,23 @@ namespace OpenSim.Region.Framework.Scenes
Dir_Vectors[3] = -Vector3.UnitY; //RIGHT
Dir_Vectors[4] = Vector3.UnitZ; //UP
Dir_Vectors[5] = -Vector3.UnitZ; //DOWN
Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
Dir_Vectors[6] = Vector3.UnitX*2; //FORWARD
Dir_Vectors[7] = -Vector3.UnitX; //BACK
}
private Vector3[] GetWalkDirectionVectors()
{
Vector3[] vector = new Vector3[6];
Vector3[] vector = new Vector3[9];
vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD
vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK
vector[2] = Vector3.UnitY; //LEFT
vector[3] = -Vector3.UnitY; //RIGHT
vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP
vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN
vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
vector[6] = (new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z) * 2); //FORWARD Nudge
vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK Nudge
return vector;
}
@ -1306,6 +1312,9 @@ namespace OpenSim.Region.Framework.Scenes
else
dirVectors = Dir_Vectors;
// The fact that m_movementflag is a byte needs to be fixed
// it really should be a uint
uint nudgehack = 250;
foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
{
if (((uint)flags & (uint)DCF) != 0)
@ -1315,24 +1324,40 @@ namespace OpenSim.Region.Framework.Scenes
try
{
agent_control_v3 += dirVectors[i];
//m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]);
}
catch (IndexOutOfRangeException)
{
// Why did I get this?
}
if ((m_movementflag & (uint)DCF) == 0)
if ((m_movementflag & (byte)(uint)DCF) == 0)
{
if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
{
m_movementflag |= (byte)nudgehack;
}
m_movementflag += (byte)(uint)DCF;
update_movementflag = true;
}
}
else
{
if ((m_movementflag & (uint)DCF) != 0)
if ((m_movementflag & (byte)(uint)DCF) != 0 ||
((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
&& ((m_movementflag & (byte)nudgehack) == nudgehack))
) // This or is for Nudge forward
{
m_movementflag -= (byte)(uint)DCF;
m_movementflag -= ((byte)(uint)DCF);
update_movementflag = true;
/*
if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
&& ((m_movementflag & (byte)nudgehack) == nudgehack))
{
m_log.Debug("Removed Hack flag");
}
*/
}
else
{
@ -1470,7 +1495,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
if (update_movementflag)
if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0))
Animator.UpdateMovementAnimations();
m_scene.EventManager.TriggerOnClientMovement(this);