As per mailing list last week, remove facility that would automatically move the avatar if prim with no sit target was out of sitting range.

Now, no movement occurs.
Note that you can still sit on a prim with an explicit sit target from any distance, as was the case before.
remove-scene-viewer
Justin Clark-Casey (justincc) 2011-11-11 21:42:58 +00:00
parent a658bddbcd
commit b1cb4f5b04
2 changed files with 197 additions and 227 deletions

View File

@ -188,20 +188,12 @@ namespace OpenSim.Region.Framework.Scenes
private readonly Vector3[] Dir_Vectors = new Vector3[11];
protected Timer m_reprioritization_timer;
protected bool m_reprioritizing;
protected bool m_reprioritization_called;
private Quaternion m_headrotation = Quaternion.Identity;
//Reuse the Vector3 instead of creating a new one on the UpdateMovement method
// private Vector3 movementvector;
private bool m_autopilotMoving;
private Vector3 m_autoPilotTarget;
private bool m_sitAtAutoTarget;
private string m_nextSitAnimation = String.Empty;
//PauPaw:Proper PID Controler for autopilot************
@ -1417,9 +1409,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
if (m_autopilotMoving)
CheckAtSitTarget();
if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
{
m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.
@ -1636,9 +1625,8 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}",
// allowUpdate, m_moveToPositionInProgress, m_autopilotMoving);
if (!m_autopilotMoving)
{
double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget);
// m_log.DebugFormat(
// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}",
// Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget);
@ -1742,7 +1730,6 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("Crash! {0}", e.ToString());
}
}
}
return updated;
}
@ -1842,47 +1829,6 @@ namespace OpenSim.Region.Framework.Scenes
AgentControlFlags = (uint)AgentManager.ControlFlags.NONE;
}
private void CheckAtSitTarget()
{
//m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString());
if (Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget) <= 1.5)
{
if (m_sitAtAutoTarget)
{
SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetUUID);
if (part != null)
{
AbsolutePosition = part.AbsolutePosition;
Velocity = Vector3.Zero;
SendAvatarDataToAllAgents();
//HandleAgentSit(ControllingClient, m_requestedSitTargetUUID);
}
//ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false);
m_requestedSitTargetUUID = UUID.Zero;
}
/*
else
{
//ControllingClient.SendAlertMessage("Autopilot cancelled");
//SendTerseUpdateToAllClients();
//PrimitiveBaseShape proxy = PrimitiveBaseShape.Default;
//proxy.PCode = (byte)PCode.ParticleSystem;
////uint nextUUID = m_scene.NextLocalId;
//proxyObjectGroup = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, UUID, nextUUID, m_autoPilotTarget, Quaternion.Identity, proxy);
//if (proxyObjectGroup != null)
//{
//proxyObjectGroup.SendGroupFullUpdate();
//ControllingClient.SendSitResponse(UUID.Zero, m_autoPilotTarget, Quaternion.Identity, true, Vector3.Zero, Vector3.Zero, false);
//m_scene.DeleteSceneObject(proxyObjectGroup);
//}
}
*/
m_autoPilotTarget = Vector3.Zero;
m_autopilotMoving = false;
}
}
/// <summary>
/// Perform the logic necessary to stand the avatar up. This method also executes
/// the stand animation.
@ -1893,7 +1839,7 @@ namespace OpenSim.Region.Framework.Scenes
if (ParentID != 0)
{
m_log.Debug("StandupCode Executed");
// m_log.Debug("StandupCode Executed");
SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID);
if (part != null)
{
@ -1983,7 +1929,6 @@ namespace OpenSim.Region.Framework.Scenes
private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation)
{
bool autopilot = true;
Vector3 pos = new Vector3();
Quaternion sitOrientation = pSitOrientation;
Vector3 cameraEyeOffset = Vector3.Zero;
@ -1991,8 +1936,9 @@ namespace OpenSim.Region.Framework.Scenes
bool forceMouselook = false;
SceneObjectPart part = FindNextAvailableSitTarget(targetID);
if (part != null)
{
if (part == null)
return;
// TODO: determine position to sit at based on scene geometry; don't trust offset from client
// see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it
@ -2013,64 +1959,62 @@ namespace OpenSim.Region.Framework.Scenes
// m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied);
if (SitTargetisSet && SitTargetUnOccupied)
if (PhysicsActor != null)
m_sitAvatarHeight = m_physicsActor.Size.Z;
bool canSit = false;
pos = part.AbsolutePosition + offset;
if (SitTargetisSet)
{
if (SitTargetUnOccupied)
{
m_log.DebugFormat(
"[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied",
Name, part.Name, part.LocalId);
part.SitTargetAvatar = UUID;
offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z);
sitOrientation = avSitOrientation;
autopilot = false;
}
pos = part.AbsolutePosition + offset;
//if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1)
//{
// offset = pos;
//autopilot = false;
//}
if (PhysicsActor != null)
{
// If we're not using the client autopilot, we're immediately warping the avatar to the location
// We can remove the physicsActor until they stand up.
m_sitAvatarHeight = PhysicsActor.Size.Z;
if (autopilot)
{
if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10)
{
autopilot = false;
RemoveFromPhysicalScene();
AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
canSit = true;
}
}
else
{
RemoveFromPhysicalScene();
if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10)
{
m_log.DebugFormat(
"[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m",
Name, part.Name, part.LocalId);
AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
canSit = true;
}
}
if (canSit)
{
if (PhysicsActor != null)
{
// We can remove the physicsActor until they stand up.
RemoveFromPhysicalScene();
}
cameraAtOffset = part.GetCameraAtOffset();
cameraEyeOffset = part.GetCameraEyeOffset();
forceMouselook = part.GetForceMouselook();
}
ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook);
ControllingClient.SendSitResponse(
targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook);
m_requestedSitTargetUUID = targetID;
// This calls HandleAgentSit twice, once from here, and the client calls
// HandleAgentSit itself after it gets to the location
// It doesn't get to the location until we've moved them there though
// which happens in HandleAgentSit :P
m_autopilotMoving = autopilot;
m_autoPilotTarget = pos;
m_sitAtAutoTarget = autopilot;
if (!autopilot)
HandleAgentSit(remoteClient, UUID);
// Moved here to avoid a race with default sit anim
// The script event needs to be raised after the default sit anim is set.
if (part != null)
part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
}
}
// public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset, string sitAnimation)
@ -2099,11 +2043,11 @@ namespace OpenSim.Region.Framework.Scenes
{
m_nextSitAnimation = part.SitAnimation;
}
m_requestedSitTargetID = part.LocalId;
//m_requestedSitOffset = offset;
m_requestedSitTargetUUID = targetID;
m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset);
// m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset);
if (m_scene.PhysicsScene.SupportsRayCast())
{
@ -2328,8 +2272,6 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
if (m_sitAtAutoTarget || !m_autopilotMoving)
{
if (part != null)
{
if (part.SitTargetAvatar == UUID)
@ -2364,7 +2306,6 @@ namespace OpenSim.Region.Framework.Scenes
{
return;
}
}
ParentID = m_requestedSitTargetID;

View File

@ -53,7 +53,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
}
[Test]
public void TestSitOutsideRange()
public void TestSitOutsideRangeNoTarget()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
}
[Test]
public void TestSitWithinRange()
public void TestSitWithinRangeNoTarget()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
@ -124,5 +124,34 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(sp.ParentID, Is.EqualTo(0));
}
[Test]
public void TestSitAndStandWithSitTarget()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
// If a prim has a sit target then we can sit from any distance away
Vector3 startPos = new Vector3(128, 128, 30);
sp.AbsolutePosition = startPos;
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene);
part.SitTargetPosition = new Vector3(0, 0, 1);
sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero);
Assert.That(part.SitTargetAvatar, Is.EqualTo(sp.UUID));
Assert.That(sp.ParentID, Is.EqualTo(part.LocalId));
Assert.That(
sp.AbsolutePosition,
Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
sp.StandUp();
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(sp.ParentID, Is.EqualTo(0));
}
}
}