* Added code to capture the draw distance setting from the client.

* Added a support function to InnerScene to calculate the distance between two vectors.
afrisby
Teravus Ovares 2007-11-22 01:32:13 +00:00
parent e5a0049c16
commit e69c810486
5 changed files with 114 additions and 14 deletions

View File

@ -237,7 +237,7 @@ namespace OpenSim.Framework
public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status); public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status);
public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); public delegate void UpdateAgent(IClientAPI remoteClient, AgentUpdatePacket agentData);
public delegate void AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset); public delegate void AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID, LLVector3 offset);

View File

@ -186,7 +186,8 @@ namespace OpenSim.Region.ClientStack
if (OnAgentUpdate != null) if (OnAgentUpdate != null)
{ {
AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack; AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack;
OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation);
OnAgentUpdate(this, agenUpdate); //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa);
} }
break; break;
case PacketType.AgentAnimation: case PacketType.AgentAnimation:

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using Axiom.Math;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
@ -325,7 +326,32 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (ent is SceneObjectGroup) if (ent is SceneObjectGroup)
{ {
((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); // Only send child agents stuff in their draw distance.
// This will need to be done for every agent once we figure out
// what we're going to use to store prim that agents already got
// the initial update for and what we'll use to limit the
// space we check for new objects on movement.
if (presence.IsChildAgent)
{
//Vector3 avPosition = new Vector3(presence.AbsolutePosition.X,presence.AbsolutePosition.Y,presence.AbsolutePosition.Z);
//LLVector3 oLoc = ((SceneObjectGroup)ent).AbsolutePosition;
//Vector3 objPosition = new Vector3(oLoc.X,oLoc.Y,oLoc.Z);
//float distResult = Vector3Distance(avPosition, objPosition);
//if (distResult > 512)
//{
//int x = 0;
//}
//if (distResult < presence.DrawDistance)
//{
((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence);
//}
}
else
{
((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence);
}
} }
} }
} }
@ -642,7 +668,15 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public float Vector3Distance(Vector3 v1, Vector3 v2)
{
// Calculates the distance between two Vector3s
// We don't really need the double floating point precision...
// so casting it to a single
return (float)Math.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.y - v2.y) * (v1.y - v2.y) + (v1.z - v2.z) * (v1.z - v2.z));
}
#endregion #endregion
} }
} }

View File

@ -79,6 +79,19 @@ namespace OpenSim.Region.Environment.Scenes
private LLVector3 lastPhysPos = new LLVector3(); private LLVector3 lastPhysPos = new LLVector3();
private int m_wearablesSerial = 1; private int m_wearablesSerial = 1;
// Position of agent's camera in world
protected Vector3 m_CameraCenter = new Vector3(0, 0, 0);
// Use these three vectors to figure out what the agent is looking at
// Convert it to a Matrix and/or Quaternion
protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0);
protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0);
protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0);
// Agent's Draw distance.
protected float m_DrawDistance = 0f;
private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in
private enum Dir_ControlFlags private enum Dir_ControlFlags
@ -148,6 +161,11 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_lastname; } get { return m_lastname; }
} }
public float DrawDistance
{
get { return m_DrawDistance; }
}
protected bool m_allowMovement = true; protected bool m_allowMovement = true;
public bool AllowMovement public bool AllowMovement
{ {
@ -408,11 +426,11 @@ namespace OpenSim.Region.Environment.Scenes
AddToPhysicalScene(); AddToPhysicalScene();
m_physicsActor.Flying = isFlying; m_physicsActor.Flying = isFlying;
if (!m_gotAllObjectsInScene) //if (!m_gotAllObjectsInScene)
{ //{
m_scene.SendAllSceneObjectsToClient(this); //m_scene.SendAllSceneObjectsToClient(this);
m_gotAllObjectsInScene = true; //m_gotAllObjectsInScene = true;
} //}
} }
@ -526,7 +544,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) public void HandleAgentUpdate(IClientAPI remoteClient,AgentUpdatePacket agentData )
{ {
//if (m_isChildAgent) //if (m_isChildAgent)
//{ //{
@ -536,6 +554,54 @@ namespace OpenSim.Region.Environment.Scenes
// Must check for standing up even when PhysicsActor is null, // Must check for standing up even when PhysicsActor is null,
// since sitting currently removes avatar from physical scene // since sitting currently removes avatar from physical scene
uint flags = agentData.AgentData.ControlFlags;
LLQuaternion bodyRotation = agentData.AgentData.BodyRotation;
// Camera location in world. We'll need to raytrace
// from this location from time to time.
m_CameraCenter.x = agentData.AgentData.CameraCenter.X;
m_CameraCenter.y = agentData.AgentData.CameraCenter.Y;
m_CameraCenter.z = agentData.AgentData.CameraCenter.Z;
// Use these three vectors to figure out what the agent is looking at
// Convert it to a Matrix and/or Quaternion
m_CameraAtAxis.x = agentData.AgentData.CameraAtAxis.X;
m_CameraAtAxis.y = agentData.AgentData.CameraAtAxis.Y;
m_CameraAtAxis.z = agentData.AgentData.CameraAtAxis.Z;
m_CameraLeftAxis.x = agentData.AgentData.CameraLeftAxis.X;
m_CameraLeftAxis.y = agentData.AgentData.CameraLeftAxis.Y;
m_CameraLeftAxis.z = agentData.AgentData.CameraLeftAxis.Z;
m_CameraUpAxis.x = agentData.AgentData.CameraUpAxis.X;
m_CameraUpAxis.y = agentData.AgentData.CameraUpAxis.Y;
m_CameraUpAxis.z = agentData.AgentData.CameraUpAxis.Z;
// The Agent's Draw distance setting
m_DrawDistance = agentData.AgentData.Far;
// We don't know the agent's draw distance until the first agentUpdate packet
//if (m_DrawDistance > 0)
//{
//if (!m_gotAllObjectsInScene && m_DrawDistance > 0)
//{
// This will need to end up being a space based invalidator
// where we send object updates on spaces in 3d space (possibily a cube)
// that the avatar hasn't been surrounding it's draw distance.
// It would be better if the distance increased incrementally
// until there was no space to update because either the avatar's draw
// distance is smaller then the space they've been or the avatar has explored
// all the space in the sim.
//m_scene.SendAllSceneObjectsToClient(this);
//m_gotAllObjectsInScene = true;
//}
//}
//MainLog.Instance.Verbose("CAMERA", "AtAxis:" + m_CameraAtAxis.ToString() + " Center:" + m_CameraCenter.ToString() + " LeftAxis:" + m_CameraLeftAxis.ToString() + " UpAxis:" + m_CameraUpAxis.ToString() + " Far:" + m_CameraFar);
if ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) if ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0)
{ {
StandUp(); StandUp();
@ -999,10 +1065,6 @@ namespace OpenSim.Region.Environment.Scenes
{ {
SendOwnWearables( ); SendOwnWearables( );
//Ugly hack x.x - Trap set appearence to send all objects in this scene!
m_scene.SendAllSceneObjectsToClient(this);
m_gotAllObjectsInScene = true;
// TODO: remove this once the SunModule is slightly more tested // TODO: remove this once the SunModule is slightly more tested
// m_controllingClient.SendViewerTime(m_scene.TimePhase); // m_controllingClient.SendViewerTime(m_scene.TimePhase);
} }

View File

@ -364,7 +364,10 @@ namespace SimpleApp
if (OnAgentUpdate != null) if (OnAgentUpdate != null)
{ {
OnAgentUpdate(this, movementFlag, bodyDirection); AgentUpdatePacket pack = new AgentUpdatePacket();
pack.AgentData.ControlFlags = movementFlag;
pack.AgentData.BodyRotation = bodyDirection;
OnAgentUpdate(this, pack);
} }
if (flyState == 0) if (flyState == 0)
{ {