diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 8f3495c..9c0b33c 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1067,46 +1067,51 @@ namespace OpenSim.Region.Environment.Scenes | |||
1067 | if (RayTargetID != LLUUID.Zero) | 1067 | if (RayTargetID != LLUUID.Zero) |
1068 | { | 1068 | { |
1069 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1069 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1070 | |||
1071 | LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); | ||
1072 | Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); | ||
1073 | Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); | ||
1074 | |||
1070 | if (target != null) | 1075 | if (target != null) |
1071 | { | 1076 | { |
1072 | pos = target.AbsolutePosition; | 1077 | pos = target.AbsolutePosition; |
1073 | //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()); | 1078 | //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()); |
1074 | //target.Scale.X | 1079 | |
1075 | if (Math.Abs(target.Scale.X - target.Scale.Y) > 4.5f | 1080 | // TODO: Raytrace better here |
1076 | || Math.Abs(target.Scale.Y - target.Scale.Z) > 4.5f | 1081 | |
1077 | || Math.Abs(target.Scale.Z - target.Scale.X) > 4.5f) | 1082 | //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); |
1078 | { | 1083 | Ray NewRay = new Ray(AXOrigin, AXdirection); |
1079 | 1084 | ||
1080 | // for now lets use the old method here as the new method works by using the largest scale vector | 1085 | // Ray Trace against target here |
1081 | // component as the radius of a sphere and produces wide results if there's a huge difference | 1086 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1,0,0,0)); |
1082 | // between the x/y/z vector components | 1087 | |
1083 | 1088 | // Un-comment out the following line to Get Raytrace results printed to the console. | |
1084 | // If one scale component is less then .21m, it's likely being used as a thin block and therefore | 1089 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1085 | // the raytracing would produce a wide result. | 1090 | |
1086 | 1091 | // If we hit something | |
1087 | 1092 | if (ei.HitTF) | |
1088 | } | ||
1089 | else | ||
1090 | { | 1093 | { |
1091 | // TODO: Raytrace better here | 1094 | // Set the position to the intersection point |
1092 | LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); | 1095 | pos = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); |
1093 | Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); | 1096 | } |
1094 | Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); | ||
1095 | EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); | ||
1096 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | ||
1097 | |||
1098 | if (ei.HitTF) | ||
1099 | { | ||
1100 | pos = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); | ||
1101 | } | ||
1102 | 1097 | ||
1103 | } | 1098 | |
1104 | return pos; | 1099 | return pos; |
1105 | } | 1100 | } |
1106 | else | 1101 | else |
1107 | { | 1102 | { |
1108 | // fall back to our stupid functionality | 1103 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1109 | pos = RayEnd; | 1104 | |
1105 | EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); | ||
1106 | |||
1107 | // Un-comment the following line to print the raytrace results to the console. | ||
1108 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | ||
1109 | |||
1110 | if (ei.HitTF) | ||
1111 | { | ||
1112 | pos = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); | ||
1113 | } | ||
1114 | |||
1110 | return pos; | 1115 | return pos; |
1111 | } | 1116 | } |
1112 | } | 1117 | } |