From 8a93358405ba97697ece87887d2a36fadfeaca4f Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Tue, 10 Jun 2008 00:18:00 +0000
Subject: * This completes ObjectDuplicateOnRay. * In English, that means that
Copy Selection works now, including Copy Centers and Copy Rotates.
---
OpenSim/Region/Environment/Scenes/InnerScene.cs | 22 +++++++-
OpenSim/Region/Environment/Scenes/Scene.cs | 42 ++++++---------
.../Region/Environment/Scenes/SceneObjectPart.cs | 62 ++++++++++++++--------
3 files changed, 76 insertions(+), 50 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index d7a6d5b..3cd32c6 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -1399,7 +1399,7 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- /// Duplicate the given object.
+ /// Duplicate the given object, Fire and Forget, No rotation, no return wrapper
///
///
///
@@ -1408,6 +1408,18 @@ namespace OpenSim.Region.Environment.Scenes
{
//m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID);
+ SceneObjectGroup dupe = DuplicateObject(originalPrim, offset, flags, AgentID, GroupID, Quaternion.Zero);
+ }
+ ///
+ /// Duplicate the given object.
+ ///
+ ///
+ ///
+ ///
+ protected internal SceneObjectGroup DuplicateObject(uint originalPrim, LLVector3 offset, uint flags, LLUUID AgentID, LLUUID GroupID, Quaternion rot)
+ {
+ //m_log.DebugFormat("[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", originalPrim, offset, AgentID);
+
List EntityList = GetEntities();
SceneObjectGroup originPrim = null;
@@ -1445,16 +1457,22 @@ namespace OpenSim.Region.Environment.Scenes
m_numPrim += copy.Children.Count;
+ if (rot != Quaternion.Zero)
+ {
+ copy.UpdateGroupRotation(new LLQuaternion(rot.x, rot.y, rot.z, rot.w));
+ }
+
copy.StartScripts();
copy.ScheduleGroupForFullUpdate();
+ return copy;
}
}
else
{
m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID);
}
+ return null;
}
-
///
/// Calculates the distance between two Vector3s
///
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 8094e4c..d5d8629 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1759,7 +1759,7 @@ namespace OpenSim.Region.Environment.Scenes
{
LLVector3 pos;
const bool frontFacesOnly = true;
-
+ //m_log.Info("HITTARGET: " + RayTargetObj.ToString() + ", COPYTARGET: " + localID.ToString());
SceneObjectPart target = GetSceneObjectPart(localID);
SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj);
@@ -1781,10 +1781,10 @@ namespace OpenSim.Region.Environment.Scenes
Ray NewRay = new Ray(AXOrigin, AXdirection);
// Ray Trace against target here
- EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, false);
+ EntityIntersection ei = target2.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, CopyCenters);
// Un-comment out the following line to Get Raytrace results printed to the console.
- // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
+ //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
float ScaleOffset = 0.5f;
// If we hit something
@@ -1801,31 +1801,21 @@ namespace OpenSim.Region.Environment.Scenes
LLVector3 offset = (normal * (ScaleOffset / 2f));
pos = (intersectionpoint + offset);
- if (CopyCenters)
+
+ // stick in offset format from the original prim
+ pos = pos - target.ParentGroup.AbsolutePosition;
+ if (CopyRotates)
{
- // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal.
- LLVector3 direction2 = LLVector3.Norm(pos - target2.AbsolutePosition);
- Vector3 AXOrigin2 = new Vector3(target2.AbsolutePosition.X, target2.AbsolutePosition.Y, target2.AbsolutePosition.Z);
- Vector3 AXdirection2 = new Vector3(direction2.X, direction2.Y, direction2.Z); //ei.AAfaceNormal;
- Ray NewRay2 = new Ray(AXOrigin2, AXdirection2);
- EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), false, CopyCenters);
- if (ei2.HitTF)
- {
- //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString());
- pos = new LLVector3(ei2.ipoint.x,ei2.ipoint.y,ei2.ipoint.z);
- normal.X = ei2.normal.x;
- normal.Y = ei2.normal.y;
- normal.Z = ei2.normal.z;
- }
- }
-
- // Set the position to the intersection point
- offset = (normal * (ScaleOffset / 2f));
- pos = (intersectionpoint + offset);
+ LLQuaternion worldRot = target2.GetWorldRotation();
- // stick in offset format from the original prim
- pos = pos - target2.ParentGroup.AbsolutePosition;
- m_innerScene.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID);
+ SceneObjectGroup obj = m_innerScene.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, new Quaternion(worldRot.W,worldRot.X,worldRot.Y,worldRot.Z));
+ //obj.Rotation = new Quaternion(worldRot.W, worldRot.X, worldRot.Y, worldRot.Z);
+ //obj.UpdateGroupRotation(worldRot);
+ }
+ else
+ {
+ m_innerScene.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID);
+ }
}
return;
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 614726e..2515122 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -1352,14 +1352,14 @@ namespace OpenSim.Region.Environment.Scenes
AmBb = FaceB[i] - FaceC[i];
d = normals[i].Dot(FaceB[i]);
- if (faceCenters)
- {
- c = normals[i].Dot(normals[i]);
- }
- else
- {
+ //if (faceCenters)
+ //{
+ // c = normals[i].Dot(normals[i]);
+ //}
+ //else
+ //{
c = iray.Direction.Dot(normals[i]);
- }
+ //}
if (c == 0)
continue;
@@ -1375,21 +1375,21 @@ namespace OpenSim.Region.Environment.Scenes
if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly)
{
- if (faceCenters)
- { //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f;
- q = iray.Origin + a * normals[i];
- }
- else
- {
+ //if (faceCenters)
+ //{ //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f;
+ // q = iray.Origin + a * normals[i];
+ //}
+ //else
+ //{
q = iray.Origin + a * iray.Direction;
- }
+ //}
float distance2 = (float)GetDistanceTo(q, AXpos);
// Is this the closest hit to the object's origin?
- if (faceCenters)
- {
- distance2 = (float)GetDistanceTo(q, iray.Origin);
- }
+ //if (faceCenters)
+ //{
+ // distance2 = (float)GetDistanceTo(q, iray.Origin);
+ //}
if (distance2 < returnresult.distance)
@@ -1397,10 +1397,28 @@ namespace OpenSim.Region.Environment.Scenes
returnresult.distance = distance2;
returnresult.HitTF = true;
returnresult.ipoint = q;
- m_log.Info("[FACE]:" + i.ToString());
- m_log.Info("[POINT]: " + q.ToString());
- m_log.Info("[DIST]: " + distance2.ToString());
- returnresult.normal = normals[i];
+ //m_log.Info("[FACE]:" + i.ToString());
+ //m_log.Info("[POINT]: " + q.ToString());
+ //m_log.Info("[DIST]: " + distance2.ToString());
+ if (faceCenters)
+ {
+ returnresult.normal = (AXrot * AAfacenormals[i]);
+
+ Vector3 scaleComponent = AAfacenormals[i];
+ float ScaleOffset = 0.5f;
+ if (scaleComponent.x != 0) ScaleOffset = AXscale.x;
+ if (scaleComponent.y != 0) ScaleOffset = AXscale.y;
+ if (scaleComponent.z != 0) ScaleOffset = AXscale.z;
+ ScaleOffset = Math.Abs(ScaleOffset);
+ Vector3 offset = (returnresult.normal * ScaleOffset);
+ returnresult.ipoint = (AXpos + offset );
+
+ ///pos = (intersectionpoint + offset);
+ }
+ else
+ {
+ returnresult.normal = normals[i];
+ }
returnresult.AAfaceNormal = AAfacenormals[i];
}
--
cgit v1.1