From 856d5f4375b34a48fbd7ae934152b588ed681237 Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 15 Jul 2009 18:55:28 +0000 Subject: Yet more work on fixing the boundingbox code. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 32 ++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index de77862..d0de5f2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -596,14 +596,23 @@ namespace OpenSim.Region.Framework.Scenes /// public Vector3 GetAxisAlignedBoundingBox() { - float maxX = 0f, maxY = 0f, maxZ = 0f, minX = 256f, minY = 256f, minZ = 256f; + float maxX = -256f, maxY = -256f, maxZ = -256f, minX = 256f, minY = 256f, minZ = 256f; lock (m_parts) { foreach (SceneObjectPart part in m_parts.Values) { + Vector3 worldPos = part.GetWorldPosition(); Vector3 offset = worldPos - AbsolutePosition; - Quaternion worldRot = part.GetWorldRotation(); + Quaternion worldRot; + if (part.ParentID == 0) + { + worldRot = part.RotationOffset; + } + else + { + worldRot = part.GetWorldRotation(); + } Vector3 frontTopLeft; Vector3 frontTopRight; @@ -621,35 +630,36 @@ namespace OpenSim.Region.Framework.Scenes frontTopLeft.Y = orig.Y - (part.Scale.Y / 2); frontTopLeft.Z = orig.Z + (part.Scale.Z / 2); - frontTopRight.X = orig.X + (part.Scale.X / 2); - frontTopRight.Y = orig.Y - (part.Scale.Y / 2); + frontTopRight.X = orig.X - (part.Scale.X / 2); + frontTopRight.Y = orig.Y + (part.Scale.Y / 2); frontTopRight.Z = orig.Z + (part.Scale.Z / 2); frontBottomLeft.X = orig.X - (part.Scale.X / 2); frontBottomLeft.Y = orig.Y - (part.Scale.Y / 2); frontBottomLeft.Z = orig.Z - (part.Scale.Z / 2); - frontBottomRight.X = orig.X + (part.Scale.X / 2); - frontBottomRight.Y = orig.Y - (part.Scale.Y / 2); + frontBottomRight.X = orig.X - (part.Scale.X / 2); + frontBottomRight.Y = orig.Y + (part.Scale.Y / 2); frontBottomRight.Z = orig.Z - (part.Scale.Z / 2); - backTopLeft.X = orig.X - (part.Scale.X / 2); - backTopLeft.Y = orig.Y + (part.Scale.Y / 2); + backTopLeft.X = orig.X + (part.Scale.X / 2); + backTopLeft.Y = orig.Y - (part.Scale.Y / 2); backTopLeft.Z = orig.Z + (part.Scale.Z / 2); backTopRight.X = orig.X + (part.Scale.X / 2); backTopRight.Y = orig.Y + (part.Scale.Y / 2); backTopRight.Z = orig.Z + (part.Scale.Z / 2); - backBottomLeft.X = orig.X - (part.Scale.X / 2); - backBottomLeft.Y = orig.Y + (part.Scale.Y / 2); + backBottomLeft.X = orig.X + (part.Scale.X / 2); + backBottomLeft.Y = orig.Y - (part.Scale.Y / 2); backBottomLeft.Z = orig.Z - (part.Scale.Z / 2); backBottomRight.X = orig.X + (part.Scale.X / 2); backBottomRight.Y = orig.Y + (part.Scale.Y / 2); backBottomRight.Z = orig.Z - (part.Scale.Z / 2); + frontTopLeft = frontTopLeft * worldRot; frontTopRight = frontTopRight * worldRot; frontBottomLeft = frontBottomLeft * worldRot; @@ -785,7 +795,7 @@ namespace OpenSim.Region.Framework.Scenes } Vector3 boundingBox = new Vector3(maxX - minX, maxY - minY, maxZ - minZ); - // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); + // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); return boundingBox; } -- cgit v1.1