diff --git a/libsecondlife/Helpers.cs b/libsecondlife/Helpers.cs index e48e309a..08cd3889 100644 --- a/libsecondlife/Helpers.cs +++ b/libsecondlife/Helpers.cs @@ -714,6 +714,17 @@ namespace libsecondlife return (float)Math.Sqrt(xd * xd + yd * yd + zd * zd); } + /// + /// Calculates the distance between two vectors + /// + public static double VecDist(LLVector3d pointA, LLVector3d pointB) + { + double xd = pointB.X - pointA.X; + double yd = pointB.Y - pointA.Y; + double zd = pointB.Z - pointA.Z; + return Math.Sqrt(xd * xd + yd * yd + zd * zd); + } + /// /// Calculate the magnitude of the supplied vector /// diff --git a/libsecondlife/MainAvatar.cs b/libsecondlife/MainAvatar.cs index 2963de02..4d5614f3 100644 --- a/libsecondlife/MainAvatar.cs +++ b/libsecondlife/MainAvatar.cs @@ -657,6 +657,24 @@ namespace libsecondlife public LLUUID ActiveGroup { get { return activeGroup; } } /// Current status message for teleporting public string TeleportMessage { get { return teleportMessage; } } + /// Returns the global grid position of the avatar + public LLVector3d GlobalPosition + { + get + { + if (Client.Network.CurrentSim != null) + { + uint globalX, globalY; + Helpers.LongToUInts(Client.Network.CurrentSim.Handle, out globalX, out globalY); + return new LLVector3d( + (double)globalX + (double)Position.X, + (double)globalY + (double)Position.Y, + (double)Position.Z); + } + else + return LLVector3d.Zero; + } + } #endregion Public Members diff --git a/libsecondlife/ObjectManager.cs b/libsecondlife/ObjectManager.cs index 1c95caa9..eafff864 100644 --- a/libsecondlife/ObjectManager.cs +++ b/libsecondlife/ObjectManager.cs @@ -2260,37 +2260,51 @@ namespace libsecondlife protected Primitive GetPrimitive(Simulator simulator, uint localID, LLUUID fullID) { - if (simulator.Objects.Prims.ContainsKey(localID)) + if (Client.Settings.OBJECT_TRACKING) { - return simulator.Objects.Prims[localID]; + if (simulator.Objects.Prims.ContainsKey(localID)) + { + return simulator.Objects.Prims[localID]; + } + else + { + Primitive prim = new Primitive(); + prim.LocalID = localID; + prim.ID = fullID; + lock (simulator.Objects.Prims) + simulator.Objects.Prims[localID] = prim; + + return prim; + } } else { - Primitive prim = new Primitive(); - prim.LocalID = localID; - prim.ID = fullID; - lock (simulator.Objects.Prims) - simulator.Objects.Prims[localID] = prim; - - return prim; + return new Primitive(); } } protected Avatar GetAvatar(Simulator simulator, uint localID, LLUUID fullID) { - if (simulator.Objects.Avatars.ContainsKey(localID)) + if (Client.Settings.OBJECT_TRACKING) { - return simulator.Objects.Avatars[localID]; + if (simulator.Objects.Avatars.ContainsKey(localID)) + { + return simulator.Objects.Avatars[localID]; + } + else + { + Avatar avatar = new Avatar(); + avatar.LocalID = localID; + avatar.ID = fullID; + lock (simulator.Objects.Avatars) + simulator.Objects.Avatars[localID] = avatar; + + return avatar; + } } else { - Avatar avatar = new Avatar(); - avatar.LocalID = localID; - avatar.ID = fullID; - lock (simulator.Objects.Avatars) - simulator.Objects.Avatars[localID] = avatar; - - return avatar; + return new Avatar(); } } diff --git a/libsecondlife/Settings.cs b/libsecondlife/Settings.cs index 473eae83..d89c9b84 100644 --- a/libsecondlife/Settings.cs +++ b/libsecondlife/Settings.cs @@ -161,6 +161,11 @@ namespace libsecondlife /// AgentUpdate packets will continuously be sent out to give the bot /// smoother movement and autopiloting public bool CONTINUOUS_AGENT_UPDATES = true; + /// If true, currently visible primitives and avatars will be + /// stored in dictionaries inside Simulator.Objects. If + /// false, a new Avatar or Primitive object will be created each time + /// an object update packet is received + public bool OBJECT_TRACKING = true; /// Cost of uploading an asset /// Read-only since this value is dynamically fetched at login diff --git a/libslupdater/Properties/AssemblyInfo.cs b/libslupdater/Properties/AssemblyInfo.cs deleted file mode 100644 index 8eb8b3f7..00000000 --- a/libslupdater/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("libslupdater")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("libslupdater")] -[assembly: AssemblyCopyright("Copyright © 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e9866226-78cb-4804-b7f1-92fac9915b7d")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/libslupdater/libslupdater.cs b/libslupdater/libslupdater.cs deleted file mode 100644 index afa6ae7b..00000000 --- a/libslupdater/libslupdater.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net; - -namespace libslupdater -{ - public class Updater - { - public const string CheckURI = "http://www.libsecondlife.org/ccnet/update/"; - - private bool busy = false; - public bool Busy - { - get { return busy; } - } - - public Updater() - { - } - - public void UpdateProcessBegin() - { - busy = true; - - // Start a thread that: - /////////////////////// - - // Connects to the check URI and see if we're running the latest - - // If not, download from the latest update link given by the check server - - // Confirm the download checksum, start the waiting thread, and return a kill - // signal to the calling app - - // Wait for the app to die and replace the target file - - // Re-launch the app and kill this process - } - - public int UpdateProcess() - { - // Call UpdateProcessBegin and wait for a response, return the response - return 0; - } - } - - public class Program - { - static int Main(string[] args) - { - return 0; - } - } -} diff --git a/libslupdater/libslupdater.csproj b/libslupdater/libslupdater.csproj deleted file mode 100644 index ad15c195..00000000 --- a/libslupdater/libslupdater.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {9707686C-61AB-4DDB-8437-A11A36B61A81} - WinExe - Properties - libslupdater - libslupdater - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - \ No newline at end of file diff --git a/libslupdater/libslupdater.sln b/libslupdater/libslupdater.sln deleted file mode 100644 index 77050ab8..00000000 --- a/libslupdater/libslupdater.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libslupdater", "libslupdater.csproj", "{9707686C-61AB-4DDB-8437-A11A36B61A81}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9707686C-61AB-4DDB-8437-A11A36B61A81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9707686C-61AB-4DDB-8437-A11A36B61A81}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9707686C-61AB-4DDB-8437-A11A36B61A81}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9707686C-61AB-4DDB-8437-A11A36B61A81}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal