本文整理汇总了C#中OpenSim.Framework.AgentUpdateArgs类的典型用法代码示例。如果您正苦于以下问题:C# AgentUpdateArgs类的具体用法?C# AgentUpdateArgs怎么用?C# AgentUpdateArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AgentUpdateArgs类属于OpenSim.Framework命名空间,在下文中一共展示了AgentUpdateArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCrossOnSameSimulator
public void TestCrossOnSameSimulator()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID userId = TestHelpers.ParseTail(0x1);
// TestEventQueueGetModule eqmA = new TestEventQueueGetModule();
EntityTransferModule etmA = new EntityTransferModule();
EntityTransferModule etmB = new EntityTransferModule();
LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
IConfigSource config = new IniConfigSource();
IConfig modulesConfig = config.AddConfig("Modules");
modulesConfig.Set("EntityTransferModule", etmA.Name);
modulesConfig.Set("SimulationServices", lscm.Name);
// IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
// In order to run a single threaded regression test we do not want the entity transfer module waiting
// for a callback from the destination scene before removing its avatar data.
// entityTransferConfig.Set("wait_for_callback", false);
SceneHelpers sh = new SceneHelpers();
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
// SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA);
SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
TestClient tc = new TestClient(acd, sceneA);
List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
originalSp.AbsolutePosition = new Vector3(128, 32, 10);
// originalSp.Flying = true;
// Console.WriteLine("First pos {0}", originalSp.AbsolutePosition);
// eqmA.ClearEvents();
AgentUpdateArgs moveArgs = new AgentUpdateArgs();
//moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
moveArgs.SessionID = acd.SessionID;
originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
sceneA.Update(1);
// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);
// FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
// But really we want to do this in a more robust way.
for (int i = 0; i < 100; i++)
{
sceneA.Update(1);
// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
}
// Need to sort processing of EnableSimulator message on adding scene presences before we can test eqm
// messages
// Dictionary<UUID, List<TestEventQueueGetModule.Event>> eqmEvents = eqmA.Events;
//
// Assert.That(eqmEvents.Count, Is.EqualTo(1));
// Assert.That(eqmEvents.ContainsKey(originalSp.UUID), Is.True);
//
// List<TestEventQueueGetModule.Event> spEqmEvents = eqmEvents[originalSp.UUID];
//
// Assert.That(spEqmEvents.Count, Is.EqualTo(1));
// Assert.That(spEqmEvents[0].Name, Is.EqualTo("CrossRegion"));
// sceneA should now only have a child agent
ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True);
ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);
// Agent remains a child until the client triggers complete movement
Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
int agentMovementCompleteReceived = 0;
sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
sceneBTc.CompleteMovement();
Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
}
示例2: HandleAgentUpdate
/// <summary>
/// This is the event handler for client movement. If a client is moving, this event is triggering.
/// </summary>
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
bool recoverPhysActor = false;
if (m_isChildAgent)
{
//m_log.Warn("[CROSSING]: HandleAgentUpdate from child agent ignored "+agentData.AgentID.ToString());
return;
}
if (IsInTransit)
{
// m_log.Error("[CROSSING]: AgentUpdate called during transit! Ignored.");
return;
}
SceneObjectPart part = m_posInfo.Parent;
EntityBase.PositionInfo posInfo = GetPosInfo();
if (part != null)
{ // sitting on a prim
if (part.ParentGroup.InTransit)
{
// m_log.Warn("[CROSSING]: AgentUpdate called during prim transit! Ignored.");
return;
}
}
if (!posInfo.Position.IsFinite())
{
RemoveFromPhysicalScene();
m_log.Error("[SCENE PRESENCE]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999902");
if (m_LastFinitePos.IsFinite())
{
SetAgentPositionInfo(false, m_LastFinitePos, posInfo.Parent, Vector3.Zero, Vector3.Zero);
}
else
{
Vector3 emergencyPos = new Vector3(127.0f, 127.0f, 127.0f);
SetAgentPositionInfo(false, emergencyPos, posInfo.Parent, Vector3.Zero, Vector3.Zero);
m_log.Error("[SCENE PRESENCE]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999903");
}
AddToPhysicalScene(false);
}
else
{
m_LastFinitePos = m_posInfo.Position;
}
m_perfMonMS = Environment.TickCount;
uint flags = agentData.ControlFlags;
Quaternion bodyRotation = agentData.BodyRotation;
// Camera location in world. We'll need to raytrace
// from this location from time to time.
bool doCullingCheck = false;
bool update_rotation = false;
if (m_sceneView != null && m_sceneView.UseCulling)
{
if (!m_sceneView.NeedsFullSceneUpdate && (Environment.TickCount - m_lastCullCheckMS) > 0 &&
Vector3.DistanceSquared(agentData.CameraCenter, m_lastCameraCenter) > m_sceneView.DistanceBeforeCullingRequired * m_sceneView.DistanceBeforeCullingRequired)
{
//Check for new entities that we may now be able to see with this camera movement
m_lastCameraCenter = agentData.CameraCenter;
doCullingCheck = true;
}
else if (!m_sceneView.NeedsFullSceneUpdate && agentData.Far > m_DrawDistance)
{
//Check to see if the draw distance has gone up
doCullingCheck = true;
}
//Do a culling check, if required
if (doCullingCheck)
{
m_sceneView.CheckForDistantEntitiesToShow();
//Also tell all child regions about the change
SendChildAgentUpdate();
m_lastCullCheckMS = Environment.TickCount + 1000;//Only do the camera check at the most once a sec
}
}
m_CameraCenter = agentData.CameraCenter;
// Use these three vectors to figure out what the agent is looking at
// Convert it to a Matrix and/or Quaternion
m_CameraAtAxis = agentData.CameraAtAxis;
m_CameraLeftAxis = agentData.CameraLeftAxis;
m_CameraUpAxis = agentData.CameraUpAxis;
// check if the Agent's Draw distance setting has changed
if (m_DrawDistance != agentData.Far)
{
m_DrawDistance = agentData.Far;
//.........这里部分代码省略.........
示例3: HandleAgentUpdate
/// <summary>
/// This is the event handler for client movement. If a client is moving, this event is triggering.
/// </summary>
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
//if (m_isChildAgent)
//{
// // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
// return;
//}
m_perfMonMS = Util.EnvironmentTickCount();
++m_movementUpdateCount;
if (m_movementUpdateCount < 1)
m_movementUpdateCount = 1;
#region Sanity Checking
// This is irritating. Really.
if (!AbsolutePosition.IsFinite())
{
RemoveFromPhysicalScene();
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902");
m_pos = m_LastFinitePos;
if (!m_pos.IsFinite())
{
m_pos.X = 127f;
m_pos.Y = 127f;
m_pos.Z = 127f;
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903");
}
AddToPhysicalScene(false);
}
else
{
m_LastFinitePos = m_pos;
}
#endregion Sanity Checking
#region Inputs
AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags;
Quaternion bodyRotation = agentData.BodyRotation;
// Camera location in world. We'll need to raytrace
// from this location from time to time.
m_CameraCenter = agentData.CameraCenter;
if (Vector3.Distance(m_lastCameraCenter, m_CameraCenter) >= Scene.RootReprioritizationDistance)
{
ReprioritizeUpdates();
m_lastCameraCenter = m_CameraCenter;
}
// Use these three vectors to figure out what the agent is looking at
// Convert it to a Matrix and/or Quaternion
m_CameraAtAxis = agentData.CameraAtAxis;
m_CameraLeftAxis = agentData.CameraLeftAxis;
m_CameraUpAxis = agentData.CameraUpAxis;
// The Agent's Draw distance setting
m_DrawDistance = agentData.Far;
// Check if Client has camera in 'follow cam' or 'build' mode.
Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation);
m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f)
&& (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
#endregion Inputs
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
{
StandUp();
}
//m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto);
// Raycast from the avatar's head to the camera to see if there's anything blocking the view
if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast())
{
if (m_followCamAuto)
{
Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT;
m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback);
}
}
lock (scriptedcontrols)
{
if (scriptedcontrols.Count > 0)
{
SendControlToScripts((uint)flags);
flags = RemoveIgnoredControls(flags, IgnoredControls);
}
//.........这里部分代码省略.........
示例4: ClientOnPreAgentUpdate
void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
//If we are forcing a position for them to go
if (forcedPosition.ContainsKey(remoteClient.AgentId))
{
ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
//Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
//When the avatar walks into a ban line on the ground, it prevents getting stuck
agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
//Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2)
{
// m_log.DebugFormat(
// "[LAND MANAGEMENT MODULE]: Stopping force position of {0} because {1} is close enough to {2}",
// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
forcedPosition.Remove(remoteClient.AgentId);
}
//if we are far away, teleport
else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3)
{
Vector3 forcePosition = forcedPosition[remoteClient.AgentId];
// m_log.DebugFormat(
// "[LAND MANAGEMENT MODULE]: Teleporting out {0} because {1} is too far from avatar position {2}",
// clientAvatar.Name, clientAvatar.AbsolutePosition, forcePosition);
m_scene.RequestTeleportLocation(remoteClient, m_scene.RegionInfo.RegionHandle,
forcePosition, clientAvatar.Lookat, (uint)Constants.TeleportFlags.ForceRedirect);
forcedPosition.Remove(remoteClient.AgentId);
}
else
{
// m_log.DebugFormat(
// "[LAND MANAGEMENT MODULE]: Forcing {0} from {1} to {2}",
// clientAvatar.Name, clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]);
//Forces them toward the forced position we want if they aren't there yet
agentData.UseClientAgentPosition = true;
agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId];
}
}
}
示例5: FilterAgentUpdate
public void FilterAgentUpdate(IClientAPI remoteClient, OpenMetaverse.Packets.AgentUpdatePacket.AgentDataBlock x)
{
bool update;
if (m_lastAgentUpdate != null)
{
// These should be ordered from most-likely to
// least likely to change. I've made an initial
// guess at that.
update =
(
(m_moveToPositionInProgress) ||
(Util.NotEquals(x.BodyRotation, m_lastAgentUpdate.BodyRotation, Util.DefaultComparePrecision)) ||
(Util.NotEquals(x.CameraAtAxis, m_lastAgentUpdate.CameraAtAxis, Util.DefaultComparePrecision)) ||
(Util.NotEquals(x.CameraCenter, m_lastAgentUpdate.CameraCenter, Util.DefaultComparePrecision)) ||
(Util.NotEquals(x.CameraLeftAxis, m_lastAgentUpdate.CameraLeftAxis, Util.DefaultComparePrecision)) ||
(Util.NotEquals(x.CameraUpAxis, m_lastAgentUpdate.CameraUpAxis, Util.DefaultComparePrecision)) ||
(x.ControlFlags != m_lastAgentUpdate.ControlFlags) ||
(Util.NotEquals(x.Far, m_lastAgentUpdate.Far, Util.DefaultComparePrecision)) ||
(x.Flags != m_lastAgentUpdate.Flags) ||
(x.State != m_lastAgentUpdate.State) ||
(Util.NotEquals(x.HeadRotation, m_lastAgentUpdate.HeadRotation, Util.DefaultComparePrecision)) ||
(x.SessionID != m_lastAgentUpdate.SessionID) ||
(x.AgentID != m_lastAgentUpdate.AgentID)
);
}
else
{
update = true;
}
if (update)
{
// m_log.WarnFormat("[SCENE PRESENCE]: AgentUpdate: {0} {1} {2} {3} {4}", this.Name, x.Flags.ToString("X2"), x.ControlFlags.ToString("X8"), x.State.ToString(), this.Velocity.ToString());
AgentUpdateArgs arg = new AgentUpdateArgs();
arg.AgentID = x.AgentID;
arg.BodyRotation = x.BodyRotation;
arg.CameraAtAxis = x.CameraAtAxis;
arg.CameraCenter = x.CameraCenter;
arg.CameraLeftAxis = x.CameraLeftAxis;
arg.CameraUpAxis = x.CameraUpAxis;
arg.ControlFlags = x.ControlFlags;
arg.Far = x.Far;
arg.Flags = x.Flags;
arg.HeadRotation = x.HeadRotation;
arg.SessionID = x.SessionID;
arg.State = x.State;
m_lastAgentUpdate = arg; // save this set of arguments for nexttime
HandleAgentUpdate(remoteClient, arg);
}
}
示例6: HandleAgentUpdate
/// <summary>
/// This is the event handler for client movement. If a client is moving, this event is triggering.
/// </summary>
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
// m_log.DebugFormat(
// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
// Scene.Name, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
if (IsChildAgent)
{
// m_log.DebugFormat("DEBUG: HandleAgentUpdate: child agent in {0}", Scene.Name);
return;
}
if (IsInTransit)
return;
#region Sanity Checking
// This is irritating. Really.
if (!AbsolutePosition.IsFinite())
{
RemoveFromPhysicalScene();
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902");
m_pos = m_LastFinitePos;
if (!m_pos.IsFinite())
{
m_pos.X = 127f;
m_pos.Y = 127f;
m_pos.Z = 127f;
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903");
}
AddToPhysicalScene(false);
}
else
{
m_LastFinitePos = m_pos;
}
#endregion Sanity Checking
#region Inputs
AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags;
// The Agent's Draw distance setting
// When we get to the point of re-computing neighbors everytime this
// changes, then start using the agent's drawdistance rather than the
// region's draw distance.
DrawDistance = agentData.Far;
m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
// FIXME: This does not work as intended because the viewer only sends the lbutton down when the button
// is first pressed, not whilst it is held down. If this is required in the future then need to look
// for an AGENT_CONTROL_LBUTTON_UP event and make sure to handle cases where an initial DOWN is not
// received (e.g. on holding LMB down on the avatar in a viewer).
m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
#endregion Inputs
// // Make anims work for client side autopilot
// if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
// m_updateCount = UPDATE_COUNT;
//
// // Make turning in place work
// if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0 ||
// (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
// m_updateCount = UPDATE_COUNT;
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
{
StandUp();
}
// Raycast from the avatar's head to the camera to see if there's anything blocking the view
// this exclude checks may not be complete
if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast())
{
if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0)
{
Vector3 posAdjusted = AbsolutePosition;
// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f;
posAdjusted.Z += 1.0f; // viewer current camera focus point
Vector3 tocam = CameraPosition - posAdjusted;
tocam.X = (float)Math.Round(tocam.X, 1);
tocam.Y = (float)Math.Round(tocam.Y, 1);
tocam.Z = (float)Math.Round(tocam.Z, 1);
float distTocamlen = tocam.Length();
if (distTocamlen > 0.3f)
{
tocam *= (1.0f / distTocamlen);
posAdjusted.X = (float)Math.Round(posAdjusted.X, 1);
//.........这里部分代码省略.........
示例7: OnBotAgentUpdate
public void OnBotAgentUpdate(ScenePresence presence, Vector3 toward, uint controlFlag, Quaternion bodyRotation, bool isMoving)
{
if (m_controller.Bot.Frozen && isMoving)
{
var pa = presence.PhysicsActor;
bool fly = pa != null && pa.Flying;
StopMoving(presence, fly, false);
return;
}
if (isMoving)
m_hasStoppedMoving = false;
AgentUpdateArgs pack = new AgentUpdateArgs { ControlFlags = controlFlag, BodyRotation = bodyRotation };
presence.HandleAgentUpdate(presence.ControllingClient, pack);
}
示例8: RealHandleAgentUpdate
private void RealHandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
//if (m_isChildAgent)
//{
// // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
// return;
//}
m_movementUpdateCount++;
if (m_movementUpdateCount >= int.MaxValue)
m_movementUpdateCount = 1;
// Must check for standing up even when PhysicsActor is null,
// since sitting currently removes avatar from physical scene
//m_log.Debug("agentPos:" + AbsolutePosition.ToString());
// This is irritating. Really.
if (!AbsolutePosition.IsFinite())
{
RemoveFromPhysicalScene();
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999902");
m_pos = m_LastFinitePos;
if (!m_pos.IsFinite())
{
m_pos.X = 127f;
m_pos.Y = 127f;
m_pos.Z = 127f;
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999903");
}
AddToPhysicalScene(false);
}
else
{
m_LastFinitePos = m_pos;
}
//m_physicsActor.AddForce(new PhysicsVector(999999999, 99999999, 999999999999999), true);
//ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
//if (land != null)
//{
//if (land.landData.landingType == (byte)1 && land.landData.userLocation != Vector3.Zero)
//{
// agent.startpos = land.landData.userLocation;
//}
//}
m_perfMonMS = Environment.TickCount;
uint flags = agentData.ControlFlags;
Quaternion bodyRotation = agentData.BodyRotation;
// Camera location in world. We'll need to raytrace
// from this location from time to time.
m_CameraCenter = agentData.CameraCenter;
// Use these three vectors to figure out what the agent is looking at
// Convert it to a Matrix and/or Quaternion
m_CameraAtAxis = agentData.CameraAtAxis;
m_CameraLeftAxis = agentData.CameraLeftAxis;
m_CameraUpAxis = agentData.CameraUpAxis;
// The Agent's Draw distance setting
m_DrawDistance = agentData.Far;
if ((flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
{
StandUp();
}
// Check if Client has camera in 'follow cam' or 'build' mode.
Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation);
m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f)
&& (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
//m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto);
// Raycast from the avatar's head to the camera to see if there's anything blocking the view
if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast())
{
if (m_followCamAuto)
{
Vector3 headadjustment = new Vector3(0, 0, 0.3f);
m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - (m_pos + headadjustment)), Vector3.Distance(m_CameraCenter, (m_pos + headadjustment)) + 0.3f, RayCastCameraCallback);
}
}
m_mouseLook = (flags & (uint) AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
m_leftButtonDown = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
//.........这里部分代码省略.........
示例9: HandleAgentUpdate
/// <summary>
/// This is the event handler for client movement. If a client is moving, this event is triggering.
/// </summary>
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
//m_log.DebugFormat(
// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
if (IsChildAgent)
{
// // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
return;
}
#region Sanity Checking
// This is irritating. Really.
if (!AbsolutePosition.IsFinite())
{
RemoveFromPhysicalScene();
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902");
m_pos = m_LastFinitePos;
if (!m_pos.IsFinite())
{
m_pos.X = 127f;
m_pos.Y = 127f;
m_pos.Z = 127f;
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903");
}
AddToPhysicalScene(false);
}
else
{
m_LastFinitePos = m_pos;
}
#endregion Sanity Checking
#region Inputs
AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags;
// The Agent's Draw distance setting
// When we get to the point of re-computing neighbors everytime this
// changes, then start using the agent's drawdistance rather than the
// region's draw distance.
// DrawDistance = agentData.Far;
DrawDistance = Scene.DefaultDrawDistance;
m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
#endregion Inputs
// // Make anims work for client side autopilot
// if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
// m_updateCount = UPDATE_COUNT;
//
// // Make turning in place work
// if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0 ||
// (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
// m_updateCount = UPDATE_COUNT;
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
{
StandUp();
}
uint flagsForScripts = (uint)flags;
flags = RemoveIgnoredControls(flags, IgnoredControls);
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
HandleAgentSitOnGround();
// In the future, these values might need to go global.
// Here's where you get them.
m_AgentControlFlags = flags;
m_headrotation = agentData.HeadRotation;
byte oldState = State;
State = agentData.State;
// We need to send this back to the client in order to stop the edit beams
if ((oldState & (uint)AgentState.Editing) != 0 && State == (uint)AgentState.None)
ControllingClient.SendAgentTerseUpdate(this);
PhysicsActor actor = PhysicsActor;
if (actor == null)
{
SendControlsToScripts(flagsForScripts);
return;
}
if (AllowMovement && !SitGround)
{
Quaternion bodyRotation = agentData.BodyRotation;
bool update_rotation = false;
//.........这里部分代码省略.........
示例10: TestCrossOnSameSimulatorNoRootDestPerm
public void TestCrossOnSameSimulatorNoRootDestPerm()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID userId = TestHelpers.ParseTail(0x1);
EntityTransferModule etmA = new EntityTransferModule();
EntityTransferModule etmB = new EntityTransferModule();
LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
IConfigSource config = new IniConfigSource();
IConfig modulesConfig = config.AddConfig("Modules");
modulesConfig.Set("EntityTransferModule", etmA.Name);
modulesConfig.Set("SimulationServices", lscm.Name);
SceneHelpers sh = new SceneHelpers();
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
// We need to set up the permisions module on scene B so that our later use of agent limit to deny
// QueryAccess won't succeed anyway because administrators are always allowed in and the default
// IsAdministrator if no permissions module is present is true.
SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new DefaultPermissionsModule(), etmB);
AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
TestClient tc = new TestClient(acd, sceneA);
List<TestClient> destinationTestClients = new List<TestClient>();
EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
// Make sure sceneB will not accept this avatar.
sceneB.RegionInfo.EstateSettings.PublicAccess = false;
ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
originalSp.AbsolutePosition = new Vector3(128, 32, 10);
AgentUpdateArgs moveArgs = new AgentUpdateArgs();
//moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
moveArgs.SessionID = acd.SessionID;
originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
sceneA.Update(1);
// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);
// FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
// But really we want to do this in a more robust way.
for (int i = 0; i < 100; i++)
{
sceneA.Update(1);
// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
}
// sceneA agent should still be root
ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
Assert.That(spAfterCrossSceneA.IsChildAgent, Is.False);
ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);
// sceneB agent should still be child
Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
// sceneB should ignore unauthorized attempt to upgrade agent to root
TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
int agentMovementCompleteReceived = 0;
sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
sceneBTc.CompleteMovement();
Assert.That(agentMovementCompleteReceived, Is.EqualTo(0));
Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
}
示例11: HandleAgentUpdate
/// <summary>
/// This is the event handler for client movement. If a client is moving, this event is triggering.
/// </summary>
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
lock (m_agentUpdates)
{
if (m_updatesAllowed)
{
RealHandleAgentUpdate(remoteClient, agentData);
return;
}
m_agentUpdates.Add(agentData);
}
}
示例12: ClientOnPreAgentUpdate
void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
//If we are forcing a position for them to go
if (forcedPosition != null)
{
ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
//Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
//When the avatar walks into a ban line on the ground, it prevents getting stuck
agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
//Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition.Value) < .2)
{
Debug.WriteLine(string.Format("Stopping force position because {0} is close enough to position {1}", forcedPosition.Value, clientAvatar.AbsolutePosition));
forcedPosition = null;
}
//if we are far away, teleport
else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition.Value) > 3)
{
Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}", forcedPosition.Value, clientAvatar.AbsolutePosition));
clientAvatar.Teleport(forcedPosition.Value);
forcedPosition = null;
}
else
{
//Forces them toward the forced position we want if they aren't there yet
agentData.UseClientAgentPosition = true;
agentData.ClientAgentPosition = forcedPosition.Value;
}
}
}
示例13: ClientOnPreAgentUpdate
void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
}
示例14: GenerateAgentUpdated
// Some presence property has changed. Generate a call into the scene presence
// so the new values are evaluated (like AgentControlFlags).
// The ScenePresence will trigger OnScenePresenceUpdated and we rely on the
// fact that the values will all be equal to supress the generation of a
// new outgoing property update message.
private void GenerateAgentUpdated(ScenePresence sp)
{
// The call for the change of these values comes out of the client view
// which has an OnAgentUpdate event that the scene presence connects to.
// We can't use the OnAgentUpdate event subscription (we're not derived
// from client view) so we fake the reception of a presenece changing
// message by building up the parameter block and directly calling the
// ScenePresence's handling routine.
AgentUpdateArgs aua = new AgentUpdateArgs();
aua.AgentID = sp.UUID;
aua.BodyRotation = sp.Rotation;
aua.CameraAtAxis = sp.CameraAtAxis;
aua.CameraCenter = sp.CameraPosition;
aua.CameraLeftAxis = sp.CameraLeftAxis;
aua.CameraUpAxis = sp.CameraUpAxis;
aua.ClientAgentPosition = sp.AbsolutePosition;
aua.ControlFlags = sp.AgentControlFlags;
aua.Far = sp.DrawDistance;
aua.Flags = 0;
aua.HeadRotation = sp.Rotation; // this is wrong but the only thing we can do
aua.State = sp.State;
aua.UseClientAgentPosition = true;
sp.HandleAgentUpdate(null, aua);
}
示例15: HandleAgentUpdate
/// <summary>
/// This is the event handler for client movement. If a client is moving, this event is triggering.
/// </summary>
public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
// m_log.DebugFormat(
// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
if (IsChildAgent)
{
// // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
return;
}
++m_movementUpdateCount;
if (m_movementUpdateCount < 1)
m_movementUpdateCount = 1;
#region Sanity Checking
// This is irritating. Really.
if (!AbsolutePosition.IsFinite())
{
RemoveFromPhysicalScene();
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902");
m_pos = m_LastFinitePos;
if (!m_pos.IsFinite())
{
m_pos.X = 127f;
m_pos.Y = 127f;
m_pos.Z = 127f;
m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903");
}
AddToPhysicalScene(false);
}
else
{
m_LastFinitePos = m_pos;
}
#endregion Sanity Checking
#region Inputs
AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags;
// Camera location in world. We'll need to raytrace
// from this location from time to time.
CameraPosition = agentData.CameraCenter;
if (Vector3.Distance(m_lastCameraPosition, CameraPosition) >= Scene.RootReprioritizationDistance)
{
ReprioritizeUpdates();
m_lastCameraPosition = CameraPosition;
}
// Use these three vectors to figure out what the agent is looking at
// Convert it to a Matrix and/or Quaternion
CameraAtAxis = agentData.CameraAtAxis;
CameraLeftAxis = agentData.CameraLeftAxis;
CameraUpAxis = agentData.CameraUpAxis;
// The Agent's Draw distance setting
// When we get to the point of re-computing neighbors everytime this
// changes, then start using the agent's drawdistance rather than the
// region's draw distance.
// DrawDistance = agentData.Far;
DrawDistance = Scene.DefaultDrawDistance;
// Check if Client has camera in 'follow cam' or 'build' mode.
Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f)
&& (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
#endregion Inputs
// // Make anims work for client side autopilot
// if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
// m_updateCount = UPDATE_COUNT;
//
// // Make turning in place work
// if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0 ||
// (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
// m_updateCount = UPDATE_COUNT;
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
{
StandUp();
}
//m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto);
// Raycast from the avatar's head to the camera to see if there's anything blocking the view
if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast())
{
//.........这里部分代码省略.........