aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/EntityBase.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs15
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs19
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs31
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs13
6 files changed, 69 insertions, 15 deletions
diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs
index 1faba9a..11bafb7 100644
--- a/OpenSim/Region/Environment/Scenes/EntityBase.cs
+++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs
@@ -222,6 +222,8 @@ namespace OpenSim.Region.Environment.Scenes
222 { 222 {
223 public Vector3 ipoint = new Vector3(0, 0, 0); 223 public Vector3 ipoint = new Vector3(0, 0, 0);
224 public Vector3 normal = new Vector3(0, 0, 0); 224 public Vector3 normal = new Vector3(0, 0, 0);
225 public Vector3 AAfaceNormal = new Vector3(0, 0, 0);
226 public int face = -1;
225 public bool HitTF = false; 227 public bool HitTF = false;
226 public SceneObjectPart obj; 228 public SceneObjectPart obj;
227 public float distance = 0; 229 public float distance = 0;
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 8a48f6e..5434a88 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -853,7 +853,7 @@ namespace OpenSim.Region.Environment.Scenes
853 return null; 853 return null;
854 } 854 }
855 855
856 public EntityIntersection GetClosestIntersectingPrim(Ray hray) 856 public EntityIntersection GetClosestIntersectingPrim(Ray hray, bool frontFacesOnly)
857 { 857 {
858 // Primitive Ray Tracing 858 // Primitive Ray Tracing
859 float closestDistance = 280f; 859 float closestDistance = 280f;
@@ -863,7 +863,7 @@ namespace OpenSim.Region.Environment.Scenes
863 if (ent is SceneObjectGroup) 863 if (ent is SceneObjectGroup)
864 { 864 {
865 SceneObjectGroup reportingG = (SceneObjectGroup)ent; 865 SceneObjectGroup reportingG = (SceneObjectGroup)ent;
866 EntityIntersection result = reportingG.TestIntersection(hray); 866 EntityIntersection result = reportingG.TestIntersection(hray, frontFacesOnly);
867 if (result.HitTF) 867 if (result.HitTF)
868 { 868 {
869 if (result.distance < closestDistance) 869 if (result.distance < closestDistance)
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 7e1b89f..7866b32 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -1235,10 +1235,12 @@ namespace OpenSim.Region.Environment.Scenes
1235 bRayEndIsIntersection = (byte)0; 1235 bRayEndIsIntersection = (byte)0;
1236 } 1236 }
1237 1237
1238 LLVector3 pos 1238 LLVector3 scale = new LLVector3(0.5f, 0.5f, 0.5f);
1239 = GetNewRezLocation( 1239
1240
1241 LLVector3 pos = GetNewRezLocation(
1240 RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), 1242 RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
1241 BypassRayCast, bRayEndIsIntersection); 1243 BypassRayCast, bRayEndIsIntersection,true,scale);
1242 1244
1243 if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos) && !attachment) 1245 if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos) && !attachment)
1244 { 1246 {
@@ -1266,9 +1268,16 @@ namespace OpenSim.Region.Environment.Scenes
1266 // if attachment we set it's asset id so object updates can reflect that 1268 // if attachment we set it's asset id so object updates can reflect that
1267 // if not, we set it's position in world. 1269 // if not, we set it's position in world.
1268 if (!attachment) 1270 if (!attachment)
1271 {
1272 pos = GetNewRezLocation(
1273 RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
1274 BypassRayCast, bRayEndIsIntersection, true, group.GroupScale());
1269 group.AbsolutePosition = pos; 1275 group.AbsolutePosition = pos;
1276 }
1270 else 1277 else
1278 {
1271 group.SetFromAssetID(itemID); 1279 group.SetFromAssetID(itemID);
1280 }
1272 1281
1273 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 1282 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1274 1283
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 {
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 863146c..5164d30 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -516,8 +516,35 @@ namespace OpenSim.Region.Environment.Scenes
516 m_scene.EventManager.OnBackup += ProcessBackup; 516 m_scene.EventManager.OnBackup += ProcessBackup;
517 } 517 }
518 } 518 }
519 public LLVector3 GroupScale()
520 {
521 LLVector3 minScale = new LLVector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize);
522 LLVector3 maxScale = new LLVector3(0f,0f,0f);
523 LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f);
524
525 lock (m_parts)
526 {
527 foreach (SceneObjectPart part in m_parts.Values)
528 {
529 LLVector3 partscale = part.Scale;
530 LLVector3 partoffset = part.OffsetPosition;
519 531
520 public EntityIntersection TestIntersection(Ray hRay) 532 minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X;
533 minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.X + partoffset.Y : minScale.Y;
534 minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.X + partoffset.Z : minScale.Z;
535
536 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
537 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
538 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
539 }
540 }
541 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
542 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
543 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
544 return finalScale;
545
546 }
547 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly)
521 { 548 {
522 // We got a request from the inner_scene to raytrace along the Ray hRay 549 // We got a request from the inner_scene to raytrace along the Ray hRay
523 // We're going to check all of the prim in this group for intersection with the ray 550 // We're going to check all of the prim in this group for intersection with the ray
@@ -539,7 +566,7 @@ namespace OpenSim.Region.Environment.Scenes
539 // Telling the prim to raytrace. 566 // Telling the prim to raytrace.
540 //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); 567 //EntityIntersection inter = part.TestIntersection(hRay, parentrotation);
541 568
542 EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation); 569 EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation,frontFacesOnly);
543 570
544 // This may need to be updated to the maximum draw distance possible.. 571 // This may need to be updated to the maximum draw distance possible..
545 // We might (and probably will) be checking for prim creation from other sims 572 // We might (and probably will) be checking for prim creation from other sims
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 8d05987..5f91176 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -1061,7 +1061,7 @@ namespace OpenSim.Region.Environment.Scenes
1061 return Math.Sqrt(dx * dx + dy * dy + dz * dz); 1061 return Math.Sqrt(dx * dx + dy * dy + dz * dz);
1062 } 1062 }
1063 1063
1064 public EntityIntersection TestIntersectionOBB(Ray iray, Quaternion parentrot) 1064 public EntityIntersection TestIntersectionOBB(Ray iray, Quaternion parentrot, bool FrontFacesOnly)
1065 { 1065 {
1066 // In this case we're using a rectangular prism, which has 6 faces and therefore 6 planes 1066 // In this case we're using a rectangular prism, which has 6 faces and therefore 6 planes
1067 // This breaks down into the ray---> plane equation. 1067 // This breaks down into the ray---> plane equation.
@@ -1075,6 +1075,14 @@ namespace OpenSim.Region.Environment.Scenes
1075 Vector3[] FaceD = new Vector3[6]; // vertex D for Facei 1075 Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
1076 1076
1077 Vector3[] normals = new Vector3[6]; // Normal for Facei 1077 Vector3[] normals = new Vector3[6]; // Normal for Facei
1078 Vector3[] AAfacenormals = new Vector3[6]; // Axis Aligned face normals
1079
1080 AAfacenormals[0] = new Vector3(1, 0, 0);
1081 AAfacenormals[1] = new Vector3(0, 1, 0);
1082 AAfacenormals[2] = new Vector3(-1, 0, 0);
1083 AAfacenormals[3] = new Vector3(0, -1, 0);
1084 AAfacenormals[4] = new Vector3(0, 0, 1);
1085 AAfacenormals[5] = new Vector3(0, 0, -1);
1078 1086
1079 Vector3 AmBa = new Vector3(0, 0, 0); // Vertex A - Vertex B 1087 Vector3 AmBa = new Vector3(0, 0, 0); // Vertex A - Vertex B
1080 Vector3 AmBb = new Vector3(0, 0, 0); // Vertex B - Vertex C 1088 Vector3 AmBb = new Vector3(0, 0, 0); // Vertex B - Vertex C
@@ -1332,7 +1340,7 @@ namespace OpenSim.Region.Environment.Scenes
1332 continue; 1340 continue;
1333 1341
1334 // If the normal is pointing outside the object 1342 // If the normal is pointing outside the object
1335 if (iray.Direction.Dot(normals[i]) < 0) 1343 if (iray.Direction.Dot(normals[i]) < 0 || !FrontFacesOnly)
1336 { 1344 {
1337 1345
1338 q = iray.Origin + a * iray.Direction; 1346 q = iray.Origin + a * iray.Direction;
@@ -1349,6 +1357,7 @@ namespace OpenSim.Region.Environment.Scenes
1349 //m_log.Info("[FACE]:" + i.ToString()); 1357 //m_log.Info("[FACE]:" + i.ToString());
1350 //m_log.Info("[POINT]: " + q.ToString()); 1358 //m_log.Info("[POINT]: " + q.ToString());
1351 returnresult.normal = normals[i]; 1359 returnresult.normal = normals[i];
1360 returnresult.AAfaceNormal = AAfacenormals[i];
1352 1361
1353 } 1362 }
1354 } 1363 }