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/Scene.cs | 42 ++++++++++++------------------ 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs') 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; -- cgit v1.1