diff options
author | John Hurliman | 2009-10-23 02:38:59 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-23 02:38:59 -0700 |
commit | 62f1a5e36d85b95e8f80bc073ba876873494963a (patch) | |
tree | 0afbdc903800f2afd127e45faf6879b49da412af /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |
parent | Uncommented the resend log line so the previous commit can be seen in action (diff) | |
download | opensim-SC_OLD-62f1a5e36d85b95e8f80bc073ba876873494963a.zip opensim-SC_OLD-62f1a5e36d85b95e8f80bc073ba876873494963a.tar.gz opensim-SC_OLD-62f1a5e36d85b95e8f80bc073ba876873494963a.tar.bz2 opensim-SC_OLD-62f1a5e36d85b95e8f80bc073ba876873494963a.tar.xz |
Implemented a "FrontBack" prioritizer, using distance plus the plane equation to give double weight to prims/avatars in front of you
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4f19761..dd8da20 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -493,8 +493,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
493 | 493 | ||
494 | public Vector3 GroupScale() | 494 | public Vector3 GroupScale() |
495 | { | 495 | { |
496 | Vector3 minScale = new Vector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize); | 496 | Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); |
497 | Vector3 maxScale = new Vector3(0f,0f,0f); | 497 | Vector3 maxScale = Vector3.Zero; |
498 | Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); | 498 | Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); |
499 | 499 | ||
500 | lock (m_parts) | 500 | lock (m_parts) |
@@ -577,7 +577,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
577 | { | 577 | { |
578 | foreach (SceneObjectPart part in m_parts.Values) | 578 | foreach (SceneObjectPart part in m_parts.Values) |
579 | { | 579 | { |
580 | |||
581 | Vector3 worldPos = part.GetWorldPosition(); | 580 | Vector3 worldPos = part.GetWorldPosition(); |
582 | Vector3 offset = worldPos - AbsolutePosition; | 581 | Vector3 offset = worldPos - AbsolutePosition; |
583 | Quaternion worldRot; | 582 | Quaternion worldRot; |
@@ -3366,6 +3365,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3366 | return GetPriorityByDistance(client); | 3365 | return GetPriorityByDistance(client); |
3367 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | 3366 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: |
3368 | return GetPriorityBySimpleAngularDistance(client); | 3367 | return GetPriorityBySimpleAngularDistance(client); |
3368 | case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: | ||
3369 | return GetPriorityByFrontBack(client); | ||
3369 | default: | 3370 | default: |
3370 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); | 3371 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); |
3371 | } | 3372 | } |
@@ -3398,6 +3399,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3398 | return double.NaN; | 3399 | return double.NaN; |
3399 | } | 3400 | } |
3400 | 3401 | ||
3402 | private double GetPriorityByFrontBack(IClientAPI client) | ||
3403 | { | ||
3404 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
3405 | if (presence != null) | ||
3406 | { | ||
3407 | return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis); | ||
3408 | } | ||
3409 | return double.NaN; | ||
3410 | } | ||
3411 | |||
3401 | public double GetPriorityByDistance(Vector3 position) | 3412 | public double GetPriorityByDistance(Vector3 position) |
3402 | { | 3413 | { |
3403 | return Vector3.Distance(AbsolutePosition, position); | 3414 | return Vector3.Distance(AbsolutePosition, position); |
@@ -3427,5 +3438,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3427 | else | 3438 | else |
3428 | return double.MinValue; | 3439 | return double.MinValue; |
3429 | } | 3440 | } |
3441 | |||
3442 | public double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis) | ||
3443 | { | ||
3444 | // Distance | ||
3445 | double priority = Vector3.Distance(camPosition, AbsolutePosition); | ||
3446 | |||
3447 | // Scale | ||
3448 | //priority -= GroupScale().Length(); | ||
3449 | |||
3450 | // Plane equation | ||
3451 | float d = -Vector3.Dot(camPosition, camAtAxis); | ||
3452 | float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d; | ||
3453 | if (p < 0.0f) priority *= 2.0f; | ||
3454 | |||
3455 | return priority; | ||
3456 | } | ||
3430 | } | 3457 | } |
3431 | } | 3458 | } |