From e69c810486e63e8b4398c7b67e84d73154d2dfcf Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 22 Nov 2007 01:32:13 +0000 Subject: * Added code to capture the draw distance setting from the client. * Added a support function to InnerScene to calculate the distance between two vectors. --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 36 ++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Environment/Scenes/InnerScene.cs') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 1f3bc95..38a8a06 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using Axiom.Math; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; @@ -325,7 +326,32 @@ namespace OpenSim.Region.Environment.Scenes { 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 } } -- cgit v1.1