diff options
author | Teravus Ovares | 2008-05-01 06:31:12 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-01 06:31:12 +0000 |
commit | 1c697ef0d206445c6819e338626169fc6ef56432 (patch) | |
tree | 88d6b26b5982eb73f75a5f051c2f068c1d8d8f27 /OpenSim/Region/Environment/Scenes/Scene.cs | |
parent | * Fix OBB raycaster to respond properly to rays cast from any direction. (diff) | |
download | opensim-SC-1c697ef0d206445c6819e338626169fc6ef56432.zip opensim-SC-1c697ef0d206445c6819e338626169fc6ef56432.tar.gz opensim-SC-1c697ef0d206445c6819e338626169fc6ef56432.tar.bz2 opensim-SC-1c697ef0d206445c6819e338626169fc6ef56432.tar.xz |
* You can now rez objects out of inventory at the correct offset from prim you rez it on. Including multi prim groups and prim that have different X/Y/Z scales.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index b5ead2a..203f6d3 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1172,7 +1172,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1172 | return myID; | 1172 | return myID; |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection) | 1175 | public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, LLVector3 scale) |
1176 | { | 1176 | { |
1177 | LLVector3 pos = LLVector3.Zero; | 1177 | LLVector3 pos = LLVector3.Zero; |
1178 | if (RayEndIsIntersection == (byte)1) | 1178 | if (RayEndIsIntersection == (byte)1) |
@@ -1199,18 +1199,24 @@ namespace OpenSim.Region.Environment.Scenes | |||
1199 | Ray NewRay = new Ray(AXOrigin, AXdirection); | 1199 | Ray NewRay = new Ray(AXOrigin, AXdirection); |
1200 | 1200 | ||
1201 | // Ray Trace against target here | 1201 | // Ray Trace against target here |
1202 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1,0,0,0)); | 1202 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1,0,0,0), frontFacesOnly); |
1203 | 1203 | ||
1204 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1204 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1205 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1205 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1206 | 1206 | float ScaleOffset = 0.5f; | |
1207 | |||
1207 | // If we hit something | 1208 | // If we hit something |
1208 | if (ei.HitTF) | 1209 | if (ei.HitTF) |
1209 | { | 1210 | { |
1211 | LLVector3 scaleComponent = new LLVector3(ei.AAfaceNormal.x, ei.AAfaceNormal.y, ei.AAfaceNormal.z); | ||
1212 | if (scaleComponent.X != 0) ScaleOffset = scale.X; | ||
1213 | if (scaleComponent.Y != 0) ScaleOffset = scale.Y; | ||
1214 | if (scaleComponent.Z != 0) ScaleOffset = scale.Z; | ||
1215 | ScaleOffset = Math.Abs(ScaleOffset); | ||
1210 | LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); | 1216 | LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); |
1211 | LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); | 1217 | LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); |
1212 | // Set the position to the intersection point | 1218 | // Set the position to the intersection point |
1213 | LLVector3 offset = (normal * (0.5f / 2f)); | 1219 | LLVector3 offset = (normal * (ScaleOffset / 2f)); |
1214 | pos = (intersectionpoint + offset); | 1220 | pos = (intersectionpoint + offset); |
1215 | 1221 | ||
1216 | // Un-offset the prim (it gets offset later by the consumer method) | 1222 | // Un-offset the prim (it gets offset later by the consumer method) |
@@ -1225,7 +1231,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1225 | { | 1231 | { |
1226 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1232 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1227 | 1233 | ||
1228 | EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); | 1234 | EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true); |
1229 | 1235 | ||
1230 | // Un-comment the following line to print the raytrace results to the console. | 1236 | // Un-comment the following line to print the raytrace results to the console. |
1231 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1237 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
@@ -1250,7 +1256,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1250 | byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID, | 1256 | byte bypassRaycast, LLVector3 RayStart, LLUUID RayTargetID, |
1251 | byte RayEndIsIntersection) | 1257 | byte RayEndIsIntersection) |
1252 | { | 1258 | { |
1253 | LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection); | 1259 | |
1260 | LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f,0.5f,0.5f)); | ||
1254 | 1261 | ||
1255 | if (PermissionsMngr.CanRezObject(ownerID, pos)) | 1262 | if (PermissionsMngr.CanRezObject(ownerID, pos)) |
1256 | { | 1263 | { |