diff options
author | John Hurliman | 2010-05-21 13:55:36 -0700 |
---|---|---|
committer | John Hurliman | 2010-05-21 13:55:36 -0700 |
commit | 93ef65c69055157e0b7d51e544abe5a1035f40f0 (patch) | |
tree | 0afcfd50591e34f0a5d7efa474f300cf09083f69 /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |
parent | minor: remove LongRunning test designator from TestAddSceneObject() since it ... (diff) | |
download | opensim-SC-93ef65c69055157e0b7d51e544abe5a1035f40f0.zip opensim-SC-93ef65c69055157e0b7d51e544abe5a1035f40f0.tar.gz opensim-SC-93ef65c69055157e0b7d51e544abe5a1035f40f0.tar.bz2 opensim-SC-93ef65c69055157e0b7d51e544abe5a1035f40f0.tar.xz |
* Moving all of the prioritization/reprioritization code into a new file Prioritizer.cs
* Simplified the interest management code to make it easier to add new policies. Prioritization and reprioritization share code paths now
* Improved the distance and front back policies to always give your avatar the highest priority
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 101 |
1 files changed, 1 insertions, 100 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8aefd50..4453beb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -3602,106 +3602,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3602 | 3602 | ||
3603 | SetFromItemID(uuid); | 3603 | SetFromItemID(uuid); |
3604 | } | 3604 | } |
3605 | #endregion | ||
3606 | 3605 | ||
3607 | public double GetUpdatePriority(IClientAPI client) | 3606 | #endregion |
3608 | { | ||
3609 | switch (Scene.UpdatePrioritizationScheme) | ||
3610 | { | ||
3611 | case Scene.UpdatePrioritizationSchemes.Time: | ||
3612 | return GetPriorityByTime(); | ||
3613 | case Scene.UpdatePrioritizationSchemes.Distance: | ||
3614 | return GetPriorityByDistance(client); | ||
3615 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | ||
3616 | return GetPriorityBySimpleAngularDistance(client); | ||
3617 | case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: | ||
3618 | return GetPriorityByFrontBack(client); | ||
3619 | default: | ||
3620 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); | ||
3621 | } | ||
3622 | } | ||
3623 | |||
3624 | private double GetPriorityByTime() | ||
3625 | { | ||
3626 | return DateTime.Now.ToOADate(); | ||
3627 | } | ||
3628 | |||
3629 | private double GetPriorityByDistance(IClientAPI client) | ||
3630 | { | ||
3631 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
3632 | if (presence != null) | ||
3633 | { | ||
3634 | return GetPriorityByDistance((presence.IsChildAgent) ? | ||
3635 | presence.AbsolutePosition : presence.CameraPosition); | ||
3636 | } | ||
3637 | return double.NaN; | ||
3638 | } | ||
3639 | |||
3640 | private double GetPriorityBySimpleAngularDistance(IClientAPI client) | ||
3641 | { | ||
3642 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
3643 | if (presence != null) | ||
3644 | { | ||
3645 | return GetPriorityBySimpleAngularDistance((presence.IsChildAgent) ? | ||
3646 | presence.AbsolutePosition : presence.CameraPosition); | ||
3647 | } | ||
3648 | return double.NaN; | ||
3649 | } | ||
3650 | |||
3651 | private double GetPriorityByFrontBack(IClientAPI client) | ||
3652 | { | ||
3653 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
3654 | if (presence != null) | ||
3655 | { | ||
3656 | return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis); | ||
3657 | } | ||
3658 | return double.NaN; | ||
3659 | } | ||
3660 | |||
3661 | public double GetPriorityByDistance(Vector3 position) | ||
3662 | { | ||
3663 | return Vector3.Distance(AbsolutePosition, position); | ||
3664 | } | ||
3665 | |||
3666 | public double GetPriorityBySimpleAngularDistance(Vector3 position) | ||
3667 | { | ||
3668 | double distance = Vector3.Distance(position, AbsolutePosition); | ||
3669 | if (distance >= double.Epsilon) | ||
3670 | { | ||
3671 | float height; | ||
3672 | Vector3 box = GetAxisAlignedBoundingBox(out height); | ||
3673 | |||
3674 | double angle = box.X / distance; | ||
3675 | double max = angle; | ||
3676 | |||
3677 | angle = box.Y / distance; | ||
3678 | if (max < angle) | ||
3679 | max = angle; | ||
3680 | |||
3681 | angle = box.Z / distance; | ||
3682 | if (max < angle) | ||
3683 | max = angle; | ||
3684 | |||
3685 | return -max; | ||
3686 | } | ||
3687 | else | ||
3688 | return double.MinValue; | ||
3689 | } | ||
3690 | |||
3691 | public double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis) | ||
3692 | { | ||
3693 | // Distance | ||
3694 | double priority = Vector3.Distance(camPosition, AbsolutePosition); | ||
3695 | |||
3696 | // Scale | ||
3697 | //priority -= GroupScale().Length(); | ||
3698 | |||
3699 | // Plane equation | ||
3700 | float d = -Vector3.Dot(camPosition, camAtAxis); | ||
3701 | float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d; | ||
3702 | if (p < 0.0f) priority *= 2.0f; | ||
3703 | |||
3704 | return priority; | ||
3705 | } | ||
3706 | } | 3607 | } |
3707 | } | 3608 | } |