diff options
author | Teravus Ovares | 2008-05-02 02:31:22 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-02 02:31:22 +0000 |
commit | 412ca265659c7e4a18089de7da34bb44d1380338 (patch) | |
tree | 436d573c10e69c14407b102868e63583d390f7ac /OpenSim/Region/Environment/Scenes/Scene.cs | |
parent | revert changeset 4469 as this breaks the script engine. (diff) | |
download | opensim-SC-412ca265659c7e4a18089de7da34bb44d1380338.zip opensim-SC-412ca265659c7e4a18089de7da34bb44d1380338.tar.gz opensim-SC-412ca265659c7e4a18089de7da34bb44d1380338.tar.bz2 opensim-SC-412ca265659c7e4a18089de7da34bb44d1380338.tar.xz |
* DuplicateOnRay with copy center works in two directions... Still fighting with it.
* DuplicateOnRay without copy center works in all directions.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 99 |
1 files changed, 51 insertions, 48 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 3113831..532d646 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1642,8 +1642,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
1642 | bool frontFacesOnly = true; | 1642 | bool frontFacesOnly = true; |
1643 | 1643 | ||
1644 | SceneObjectPart target = GetSceneObjectPart(localID); | 1644 | SceneObjectPart target = GetSceneObjectPart(localID); |
1645 | SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj); | ||
1645 | 1646 | ||
1646 | if (target != null) | 1647 | if (target != null && target2 != null) |
1647 | { | 1648 | { |
1648 | 1649 | ||
1649 | LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); | 1650 | LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); |
@@ -1651,67 +1652,69 @@ namespace OpenSim.Region.Environment.Scenes | |||
1651 | Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); | 1652 | Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); |
1652 | 1653 | ||
1653 | 1654 | ||
1654 | if (target != null) | 1655 | |
1656 | if (target2.ParentGroup != null) | ||
1655 | { | 1657 | { |
1656 | if (target.ParentGroup != null) | 1658 | pos = target2.AbsolutePosition; |
1657 | { | 1659 | //m_log.Info("[OBJECT_REZ]: TargetPos: " + pos.ToString() + ", RayStart: " + RayStart.ToString() + ", RayEnd: " + RayEnd.ToString() + ", Volume: " + Util.GetDistanceTo(RayStart,RayEnd).ToString() + ", mag1: " + Util.GetMagnitude(RayStart).ToString() + ", mag2: " + Util.GetMagnitude(RayEnd).ToString()); |
1658 | pos = target.AbsolutePosition; | ||
1659 | //m_log.Info("[OBJECT_REZ]: TargetPos: " + pos.ToString() + ", RayStart: " + RayStart.ToString() + ", RayEnd: " + RayEnd.ToString() + ", Volume: " + Util.GetDistanceTo(RayStart,RayEnd).ToString() + ", mag1: " + Util.GetMagnitude(RayStart).ToString() + ", mag2: " + Util.GetMagnitude(RayEnd).ToString()); | ||
1660 | 1660 | ||
1661 | // TODO: Raytrace better here | 1661 | // TODO: Raytrace better here |
1662 | 1662 | ||
1663 | //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); | 1663 | //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); |
1664 | Ray NewRay = new Ray(AXOrigin, AXdirection); | 1664 | Ray NewRay = new Ray(AXOrigin, AXdirection); |
1665 | 1665 | ||
1666 | // Ray Trace against target here | 1666 | // Ray Trace against target here |
1667 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, false); | 1667 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, CopyCenters); |
1668 | 1668 | ||
1669 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1669 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1670 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1670 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1671 | float ScaleOffset = 0.5f; | 1671 | float ScaleOffset = 0.5f; |
1672 | 1672 | ||
1673 | // If we hit something | 1673 | // If we hit something |
1674 | if (ei.HitTF) | 1674 | if (ei.HitTF) |
1675 | { | ||
1676 | LLVector3 scale = target.Scale; | ||
1677 | LLVector3 scaleComponent = new LLVector3(ei.AAfaceNormal.x, ei.AAfaceNormal.y, ei.AAfaceNormal.z); | ||
1678 | if (scaleComponent.X != 0) ScaleOffset = scale.X; | ||
1679 | if (scaleComponent.Y != 0) ScaleOffset = scale.Y; | ||
1680 | if (scaleComponent.Z != 0) ScaleOffset = scale.Z; | ||
1681 | ScaleOffset = Math.Abs(ScaleOffset); | ||
1682 | LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); | ||
1683 | LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); | ||
1684 | |||
1685 | |||
1686 | if (CopyCenters) | ||
1675 | { | 1687 | { |
1676 | LLVector3 scale = target.Scale; | 1688 | // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal. |
1677 | LLVector3 scaleComponent = new LLVector3(ei.AAfaceNormal.x, ei.AAfaceNormal.y, ei.AAfaceNormal.z); | 1689 | LLVector3 direction2 = LLVector3.Norm(intersectionpoint - target2.AbsolutePosition); |
1678 | if (scaleComponent.X != 0) ScaleOffset = scale.X; | 1690 | Vector3 AXOrigin2 = new Vector3(target2.AbsolutePosition.X, target2.AbsolutePosition.Y, target2.AbsolutePosition.Z); |
1679 | if (scaleComponent.Y != 0) ScaleOffset = scale.Y; | 1691 | Vector3 AXdirection2 = ei.AAfaceNormal; |
1680 | if (scaleComponent.Z != 0) ScaleOffset = scale.Z; | 1692 | Ray NewRay2 = new Ray(AXOrigin2, AXdirection2); |
1681 | ScaleOffset = Math.Abs(ScaleOffset); | 1693 | EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), true, CopyCenters); |
1682 | LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); | 1694 | if (ei2.HitTF) |
1683 | |||
1684 | |||
1685 | |||
1686 | if (CopyCenters) | ||
1687 | { | 1695 | { |
1688 | // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal. | 1696 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString()); |
1689 | LLVector3 direction2 = LLVector3.Norm(pos - target.AbsolutePosition); | 1697 | pos = new LLVector3(ei2.ipoint.x,ei2.ipoint.y,ei2.ipoint.z); |
1690 | Vector3 AXOrigin2 = new Vector3(target.AbsolutePosition.X, target.AbsolutePosition.Y, target.AbsolutePosition.Z); | 1698 | normal.X = ei2.normal.x; |
1691 | Vector3 AXdirection2 = ei.AAfaceNormal; | 1699 | normal.Y = ei2.normal.y; |
1692 | Ray NewRay2 = new Ray(AXOrigin2, AXdirection2); | 1700 | normal.Z = ei2.normal.z; |
1693 | EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), false, CopyCenters); | ||
1694 | if (ei2.HitTF) | ||
1695 | { | ||
1696 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString()); | ||
1697 | pos = new LLVector3(ei2.ipoint.x,ei2.ipoint.y,ei2.ipoint.z); | ||
1698 | } | ||
1699 | } | 1701 | } |
1700 | LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); | ||
1701 | // Set the position to the intersection point | ||
1702 | LLVector3 offset = (normal * (ScaleOffset / 2f)); | ||
1703 | pos = (intersectionpoint + offset); | ||
1704 | |||
1705 | // stick in offset format from the original prim | ||
1706 | pos = pos - target.ParentGroup.AbsolutePosition; | ||
1707 | m_innerScene.DuplicateObject(target.ParentGroup.LocalId, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID); | ||
1708 | } | 1702 | } |
1703 | |||
1704 | // Set the position to the intersection point | ||
1705 | LLVector3 offset = (normal * (ScaleOffset / 2f)); | ||
1706 | pos = (intersectionpoint + offset); | ||
1709 | 1707 | ||
1710 | 1708 | // stick in offset format from the original prim | |
1711 | return; | 1709 | pos = pos - target2.ParentGroup.AbsolutePosition; |
1710 | m_innerScene.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID); | ||
1712 | } | 1711 | } |
1712 | |||
1713 | |||
1713 | return; | 1714 | return; |
1714 | } | 1715 | } |
1716 | return; | ||
1717 | |||
1715 | 1718 | ||
1716 | } | 1719 | } |
1717 | 1720 | ||