aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorKitto Flora2010-06-17 13:04:18 -0400
committerKitto Flora2010-06-17 13:04:18 -0400
commit958c6c6fde45e41433452f44bf8e2e925153a24d (patch)
treef1ee3709033d024cfb33227fda1ae04a0a6e8742 /OpenSim/Region
parentD.U.H. #2. Inverted test. Again. Argh! (diff)
downloadopensim-SC_OLD-958c6c6fde45e41433452f44bf8e2e925153a24d.zip
opensim-SC_OLD-958c6c6fde45e41433452f44bf8e2e925153a24d.tar.gz
opensim-SC_OLD-958c6c6fde45e41433452f44bf8e2e925153a24d.tar.bz2
opensim-SC_OLD-958c6c6fde45e41433452f44bf8e2e925153a24d.tar.xz
Add rez on water surface.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs32
1 files changed, 21 insertions, 11 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index b58bfb8..a88b87f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1967,14 +1967,24 @@ namespace OpenSim.Region.Framework.Scenes
1967 /// <returns></returns> 1967 /// <returns></returns>
1968 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1968 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1969 { 1969 {
1970
1971 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1972 Vector3 wpos = Vector3.Zero;
1973 // Check for water surface intersection from above
1974 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1975 {
1976 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1977 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1978 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1979 wpos.Z = wheight;
1980 }
1981
1970 Vector3 pos = Vector3.Zero; 1982 Vector3 pos = Vector3.Zero;
1971 if (RayEndIsIntersection == (byte)1) 1983 if (RayEndIsIntersection == (byte)1)
1972 { 1984 {
1973 pos = RayEnd; 1985 pos = RayEnd;
1974 return pos;
1975 } 1986 }
1976 1987 else if (RayTargetID != UUID.Zero)
1977 if (RayTargetID != UUID.Zero)
1978 { 1988 {
1979 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1989 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1980 1990
@@ -1996,7 +2006,7 @@ namespace OpenSim.Region.Framework.Scenes
1996 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 2006 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1997 2007
1998 // Un-comment out the following line to Get Raytrace results printed to the console. 2008 // Un-comment out the following line to Get Raytrace results printed to the console.
1999 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 2009 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
2000 float ScaleOffset = 0.5f; 2010 float ScaleOffset = 0.5f;
2001 2011
2002 // If we hit something 2012 // If we hit something
@@ -2019,13 +2029,10 @@ namespace OpenSim.Region.Framework.Scenes
2019 //pos.Z -= 0.25F; 2029 //pos.Z -= 0.25F;
2020 2030
2021 } 2031 }
2022
2023 return pos;
2024 } 2032 }
2025 else 2033 else
2026 { 2034 {
2027 // We don't have a target here, so we're going to raytrace all the objects in the scene. 2035 // We don't have a target here, so we're going to raytrace all the objects in the scene.
2028
2029 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 2036 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
2030 2037
2031 // Un-comment the following line to print the raytrace results to the console. 2038 // Un-comment the following line to print the raytrace results to the console.
@@ -2034,13 +2041,12 @@ namespace OpenSim.Region.Framework.Scenes
2034 if (ei.HitTF) 2041 if (ei.HitTF)
2035 { 2042 {
2036 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 2043 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
2037 } else 2044 }
2045 else
2038 { 2046 {
2039 // fall back to our stupid functionality 2047 // fall back to our stupid functionality
2040 pos = RayEnd; 2048 pos = RayEnd;
2041 } 2049 }
2042
2043 return pos;
2044 } 2050 }
2045 } 2051 }
2046 else 2052 else
@@ -2051,8 +2057,12 @@ namespace OpenSim.Region.Framework.Scenes
2051 //increase height so its above the ground. 2057 //increase height so its above the ground.
2052 //should be getting the normal of the ground at the rez point and using that? 2058 //should be getting the normal of the ground at the rez point and using that?
2053 pos.Z += scale.Z / 2f; 2059 pos.Z += scale.Z / 2f;
2054 return pos; 2060// return pos;
2055 } 2061 }
2062
2063 // check against posible water intercept
2064 if (wpos.Z > pos.Z) pos = wpos;
2065 return pos;
2056 } 2066 }
2057 2067
2058 2068