diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index c6190dd368..2f5d3c84fb 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -4115,12 +4115,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP if(!inview) { - Vector3 partpos = grp.AbsolutePosition; + float bradius = grp.GetBoundsRadius(); // needs to be called before getBoundsCenter + Vector3 partpos = grp.AbsolutePosition + grp.getBoundsCenter(); // float dcam = (partpos - mycamera).LengthSquared(); float dpos = (partpos - mypos).LengthSquared(); // if(dcam < dpos) // dpos = dcam; - dpos = (float)Math.Sqrt(dpos) - grp.GetBoundsRadius(); + dpos = (float)Math.Sqrt(dpos) - bradius; if(dpos > cullingrange) continue; @@ -4418,13 +4419,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP if(grp.IsDeleted || grp.IsAttachment) continue; - Vector3 grppos = grp.AbsolutePosition; + float bradius = grp.GetBoundsRadius(); // needs to be called before getBoundsCenter + Vector3 grppos = grp.AbsolutePosition + grp.getBoundsCenter(); // float dcam = (grppos - mycamera).LengthSquared(); float dpos = (grppos - mypos).LengthSquared(); // if(dcam < dpos) // dpos = dcam; - dpos = (float)Math.Sqrt(dpos) - grp.GetBoundsRadius(); + dpos = (float)Math.Sqrt(dpos) - bradius; bool inview; lock(GroupsInView) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1a40ed9fae..722905f23f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1573,6 +1573,12 @@ namespace OpenSim.Region.Framework.Scenes m_boundsRadius = null; } + private Vector3 m_boundsCenter; + public Vector3 getBoundsCenter() + { + // this needs to be called after GetBoundsRadius() so its updated + return m_boundsCenter; + } public float GetBoundsRadius() { // this may need more threading work @@ -1582,6 +1588,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart p; SceneObjectPart[] parts; float partR; + Vector3 offset = Vector3.Zero; lock (m_parts) { parts = m_parts.GetArray(); @@ -1593,10 +1600,19 @@ namespace OpenSim.Region.Framework.Scenes p = parts[i]; partR = 0.5f * p.Scale.Length(); if(p != RootPart) + { partR += p.OffsetPosition.Length(); + offset += p.OffsetPosition; + } if(partR > res) res = partR; } + if(parts.Length > 1) + { + offset /= parts.Length; // basicly geometric center + offset = offset * RootPart.RotationOffset; + } + m_boundsCenter = offset; m_boundsRadius = res; return res; } @@ -4646,26 +4662,16 @@ namespace OpenSim.Region.Framework.Scenes Vector3 gc = Vector3.Zero; - int nparts = m_parts.Count; - if (nparts <= 1) - return gc; - SceneObjectPart[] parts = m_parts.GetArray(); - nparts = parts.Length; // just in case it changed - if (nparts <= 1) + int nparts = parts.Length; + if (nparts < 2) return gc; - Vector3 pPos; - // average all parts positions for (int i = 0; i < nparts; i++) { if (parts[i] != RootPart) - { - pPos = parts[i].OffsetPosition; - gc += pPos; - } - + gc += parts[i].OffsetPosition; } gc /= nparts;