From c4318136ba356a1766d57479ae1814a2606c5c8d Mon Sep 17 00:00:00 2001
From: MW
Date: Mon, 13 Jul 2009 14:42:46 +0000
Subject: Changed it so that when rezzing prims from inventory, a bounding box
containing all the prims in the group is used for working out the rezzing
point. So that none of the child prims are underground. Or at least thats
what it is meant to do, still needs more testing and there are still some
issues with link sets getting rezzed too high above the ground/target prim.
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +-
OpenSim/Region/Framework/Scenes/Scene.cs | 3 +-
.../Region/Framework/Scenes/SceneObjectGroup.cs | 53 ++++++++++++++++++++++
3 files changed, 55 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 3fe879a..3a5107d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -2318,7 +2318,7 @@ namespace OpenSim.Region.Framework.Scenes
{
pos = GetNewRezLocation(
RayStart, RayEnd, RayTargetID, Quaternion.Identity,
- BypassRayCast, bRayEndIsIntersection, true, group.GroupScale(), false);
+ BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(), false);
group.AbsolutePosition = pos;
}
else
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ac2d02e..660ee8d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1386,8 +1386,7 @@ namespace OpenSim.Region.Framework.Scenes
//increase height so its above the ground.
//should be getting the normal of the ground at the rez point and using that?
- float ScaleOffset = Math.Abs(scale.Z);
- pos.Z += ScaleOffset / 2f;
+ pos.Z += scale.Z / 2f;
return pos;
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 55ee460..a403030 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -581,6 +581,59 @@ namespace OpenSim.Region.Framework.Scenes
return returnresult;
}
+
+
+ ///
+ /// Gets a vector representing the size of the bounding box containing all the prims in the group
+ /// Treats all prims as rectangular, so no shape (cut etc) is taken into account
+ ///
+ ///
+ public Vector3 GetAxisAlignedBoundingBox()
+ {
+ //int count = 0;
+ float maxX = 0f, maxY = 0f, maxZ = 0f, minX = 256f, minY = 256f, minZ = 256f;
+ lock (m_parts)
+ {
+ foreach (SceneObjectPart part in m_parts.Values)
+ {
+ Vector3 worldPos = part.GetWorldPosition();
+ Quaternion worldRot = part.GetWorldRotation();
+
+ Vector3 size = part.Scale * worldRot;
+
+ // m_log.InfoFormat("prim {0} , world pos is {1} , {2} , {3} , and size is {4} , {5} , {6}", count, worldPos.X, worldPos.Y, worldPos.Z, size.X, size.Y, size.Z);
+ // count++;
+
+ float tx= worldPos.X +( size.X/2);
+ float bx = worldPos.X - (size.X/2);
+ if (tx > maxX)
+ maxX = tx;
+ if (bx < minX)
+ minX = bx;
+
+ float ty = worldPos.Y + (size.Y / 2);
+ float by = worldPos.Y - (size.Y / 2);
+ if (ty > maxY)
+ maxY = ty;
+ if (by < minY)
+ minY = by;
+
+ float tz = worldPos.Z + (size.Z / 2);
+ float bz = worldPos.Z - (size.Z / 2);
+ if (tz > maxZ)
+ maxZ = tz;
+ if (bz < minZ)
+ minZ = bz;
+
+ }
+
+ }
+
+ Vector3 boundingBox = new Vector3(maxX - minX, maxY - minY, maxZ - minZ);
+ //m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z);
+ return boundingBox;
+ }
+
#endregion
public void SaveScriptedState(XmlTextWriter writer)
--
cgit v1.1