diff options
author | Teravus Ovares | 2007-11-22 01:32:13 +0000 |
---|---|---|
committer | Teravus Ovares | 2007-11-22 01:32:13 +0000 |
commit | e69c810486e63e8b4398c7b67e84d73154d2dfcf (patch) | |
tree | 21423ba1dfad709e85a52e455d2c65840bad21d2 /OpenSim/Region/Environment/Scenes | |
parent | Fixed bug that can lead to infinitive loops (diff) | |
download | opensim-SC_OLD-e69c810486e63e8b4398c7b67e84d73154d2dfcf.zip opensim-SC_OLD-e69c810486e63e8b4398c7b67e84d73154d2dfcf.tar.gz opensim-SC_OLD-e69c810486e63e8b4398c7b67e84d73154d2dfcf.tar.bz2 opensim-SC_OLD-e69c810486e63e8b4398c7b67e84d73154d2dfcf.tar.xz |
* Added code to capture the draw distance setting from the client.
* Added a support function to InnerScene to calculate the distance between two vectors.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/InnerScene.cs | 36 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 82 |
2 files changed, 107 insertions, 11 deletions
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 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using Axiom.Math; | ||
4 | using libsecondlife; | 5 | using libsecondlife; |
5 | using libsecondlife.Packets; | 6 | using libsecondlife.Packets; |
6 | using OpenSim.Framework; | 7 | using OpenSim.Framework; |
@@ -325,7 +326,32 @@ namespace OpenSim.Region.Environment.Scenes | |||
325 | { | 326 | { |
326 | if (ent is SceneObjectGroup) | 327 | if (ent is SceneObjectGroup) |
327 | { | 328 | { |
328 | ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); | 329 | // Only send child agents stuff in their draw distance. |
330 | // This will need to be done for every agent once we figure out | ||
331 | // what we're going to use to store prim that agents already got | ||
332 | // the initial update for and what we'll use to limit the | ||
333 | // space we check for new objects on movement. | ||
334 | |||
335 | if (presence.IsChildAgent) | ||
336 | { | ||
337 | //Vector3 avPosition = new Vector3(presence.AbsolutePosition.X,presence.AbsolutePosition.Y,presence.AbsolutePosition.Z); | ||
338 | //LLVector3 oLoc = ((SceneObjectGroup)ent).AbsolutePosition; | ||
339 | //Vector3 objPosition = new Vector3(oLoc.X,oLoc.Y,oLoc.Z); | ||
340 | //float distResult = Vector3Distance(avPosition, objPosition); | ||
341 | //if (distResult > 512) | ||
342 | //{ | ||
343 | //int x = 0; | ||
344 | //} | ||
345 | //if (distResult < presence.DrawDistance) | ||
346 | //{ | ||
347 | ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); | ||
348 | //} | ||
349 | |||
350 | } | ||
351 | else | ||
352 | { | ||
353 | ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); | ||
354 | } | ||
329 | } | 355 | } |
330 | } | 356 | } |
331 | } | 357 | } |
@@ -642,7 +668,15 @@ namespace OpenSim.Region.Environment.Scenes | |||
642 | } | 668 | } |
643 | 669 | ||
644 | } | 670 | } |
671 | public float Vector3Distance(Vector3 v1, Vector3 v2) | ||
672 | { | ||
673 | // Calculates the distance between two Vector3s | ||
674 | // We don't really need the double floating point precision... | ||
675 | // so casting it to a single | ||
645 | 676 | ||
677 | 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)); | ||
678 | |||
679 | } | ||
646 | #endregion | 680 | #endregion |
647 | } | 681 | } |
648 | } | 682 | } |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index be21748..3929f0f 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -79,6 +79,19 @@ namespace OpenSim.Region.Environment.Scenes | |||
79 | private LLVector3 lastPhysPos = new LLVector3(); | 79 | private LLVector3 lastPhysPos = new LLVector3(); |
80 | private int m_wearablesSerial = 1; | 80 | private int m_wearablesSerial = 1; |
81 | 81 | ||
82 | |||
83 | // Position of agent's camera in world | ||
84 | protected Vector3 m_CameraCenter = new Vector3(0, 0, 0); | ||
85 | |||
86 | // Use these three vectors to figure out what the agent is looking at | ||
87 | // Convert it to a Matrix and/or Quaternion | ||
88 | protected Vector3 m_CameraAtAxis = new Vector3(0, 0, 0); | ||
89 | protected Vector3 m_CameraLeftAxis = new Vector3(0, 0, 0); | ||
90 | protected Vector3 m_CameraUpAxis = new Vector3(0, 0, 0); | ||
91 | |||
92 | // Agent's Draw distance. | ||
93 | protected float m_DrawDistance = 0f; | ||
94 | |||
82 | private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in | 95 | private readonly List<ulong> m_knownChildRegions = new List<ulong>(); //neighbouring regions we have enabled a child agent in |
83 | 96 | ||
84 | private enum Dir_ControlFlags | 97 | private enum Dir_ControlFlags |
@@ -148,6 +161,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
148 | get { return m_lastname; } | 161 | get { return m_lastname; } |
149 | } | 162 | } |
150 | 163 | ||
164 | public float DrawDistance | ||
165 | { | ||
166 | get { return m_DrawDistance; } | ||
167 | } | ||
168 | |||
151 | protected bool m_allowMovement = true; | 169 | protected bool m_allowMovement = true; |
152 | public bool AllowMovement | 170 | public bool AllowMovement |
153 | { | 171 | { |
@@ -408,11 +426,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
408 | AddToPhysicalScene(); | 426 | AddToPhysicalScene(); |
409 | m_physicsActor.Flying = isFlying; | 427 | m_physicsActor.Flying = isFlying; |
410 | 428 | ||
411 | if (!m_gotAllObjectsInScene) | 429 | //if (!m_gotAllObjectsInScene) |
412 | { | 430 | //{ |
413 | m_scene.SendAllSceneObjectsToClient(this); | 431 | //m_scene.SendAllSceneObjectsToClient(this); |
414 | m_gotAllObjectsInScene = true; | 432 | //m_gotAllObjectsInScene = true; |
415 | } | 433 | //} |
416 | 434 | ||
417 | } | 435 | } |
418 | 436 | ||
@@ -526,7 +544,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
526 | } | 544 | } |
527 | } | 545 | } |
528 | 546 | ||
529 | public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) | 547 | public void HandleAgentUpdate(IClientAPI remoteClient,AgentUpdatePacket agentData ) |
530 | { | 548 | { |
531 | //if (m_isChildAgent) | 549 | //if (m_isChildAgent) |
532 | //{ | 550 | //{ |
@@ -536,6 +554,54 @@ namespace OpenSim.Region.Environment.Scenes | |||
536 | 554 | ||
537 | // Must check for standing up even when PhysicsActor is null, | 555 | // Must check for standing up even when PhysicsActor is null, |
538 | // since sitting currently removes avatar from physical scene | 556 | // since sitting currently removes avatar from physical scene |
557 | |||
558 | uint flags = agentData.AgentData.ControlFlags; | ||
559 | LLQuaternion bodyRotation = agentData.AgentData.BodyRotation; | ||
560 | |||
561 | // Camera location in world. We'll need to raytrace | ||
562 | // from this location from time to time. | ||
563 | m_CameraCenter.x = agentData.AgentData.CameraCenter.X; | ||
564 | m_CameraCenter.y = agentData.AgentData.CameraCenter.Y; | ||
565 | m_CameraCenter.z = agentData.AgentData.CameraCenter.Z; | ||
566 | |||
567 | |||
568 | // Use these three vectors to figure out what the agent is looking at | ||
569 | // Convert it to a Matrix and/or Quaternion | ||
570 | m_CameraAtAxis.x = agentData.AgentData.CameraAtAxis.X; | ||
571 | m_CameraAtAxis.y = agentData.AgentData.CameraAtAxis.Y; | ||
572 | m_CameraAtAxis.z = agentData.AgentData.CameraAtAxis.Z; | ||
573 | |||
574 | m_CameraLeftAxis.x = agentData.AgentData.CameraLeftAxis.X; | ||
575 | m_CameraLeftAxis.y = agentData.AgentData.CameraLeftAxis.Y; | ||
576 | m_CameraLeftAxis.z = agentData.AgentData.CameraLeftAxis.Z; | ||
577 | |||
578 | m_CameraUpAxis.x = agentData.AgentData.CameraUpAxis.X; | ||
579 | m_CameraUpAxis.y = agentData.AgentData.CameraUpAxis.Y; | ||
580 | m_CameraUpAxis.z = agentData.AgentData.CameraUpAxis.Z; | ||
581 | |||
582 | // The Agent's Draw distance setting | ||
583 | m_DrawDistance = agentData.AgentData.Far; | ||
584 | |||
585 | // We don't know the agent's draw distance until the first agentUpdate packet | ||
586 | //if (m_DrawDistance > 0) | ||
587 | //{ | ||
588 | //if (!m_gotAllObjectsInScene && m_DrawDistance > 0) | ||
589 | //{ | ||
590 | // This will need to end up being a space based invalidator | ||
591 | // where we send object updates on spaces in 3d space (possibily a cube) | ||
592 | // that the avatar hasn't been surrounding it's draw distance. | ||
593 | // It would be better if the distance increased incrementally | ||
594 | // until there was no space to update because either the avatar's draw | ||
595 | // distance is smaller then the space they've been or the avatar has explored | ||
596 | // all the space in the sim. | ||
597 | |||
598 | //m_scene.SendAllSceneObjectsToClient(this); | ||
599 | //m_gotAllObjectsInScene = true; | ||
600 | //} | ||
601 | //} | ||
602 | //MainLog.Instance.Verbose("CAMERA", "AtAxis:" + m_CameraAtAxis.ToString() + " Center:" + m_CameraCenter.ToString() + " LeftAxis:" + m_CameraLeftAxis.ToString() + " UpAxis:" + m_CameraUpAxis.ToString() + " Far:" + m_CameraFar); | ||
603 | |||
604 | |||
539 | if ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) | 605 | if ((flags & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) |
540 | { | 606 | { |
541 | StandUp(); | 607 | StandUp(); |
@@ -999,10 +1065,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
999 | { | 1065 | { |
1000 | SendOwnWearables( ); | 1066 | SendOwnWearables( ); |
1001 | 1067 | ||
1002 | //Ugly hack x.x - Trap set appearence to send all objects in this scene! | ||
1003 | |||
1004 | m_scene.SendAllSceneObjectsToClient(this); | ||
1005 | m_gotAllObjectsInScene = true; | ||
1006 | // TODO: remove this once the SunModule is slightly more tested | 1068 | // TODO: remove this once the SunModule is slightly more tested |
1007 | // m_controllingClient.SendViewerTime(m_scene.TimePhase); | 1069 | // m_controllingClient.SendViewerTime(m_scene.TimePhase); |
1008 | } | 1070 | } |