diff options
author | Teravus Ovares | 2008-05-01 15:17:49 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-01 15:17:49 +0000 |
commit | 56b4f5a2ea582d347c69ce30405e078270090dfa (patch) | |
tree | 088745a3b4457b58c95c1eec1de5d5299d3493e9 | |
parent | * Assorted spring cleanings. (diff) | |
download | opensim-SC-56b4f5a2ea582d347c69ce30405e078270090dfa.zip opensim-SC-56b4f5a2ea582d347c69ce30405e078270090dfa.tar.gz opensim-SC-56b4f5a2ea582d347c69ce30405e078270090dfa.tar.bz2 opensim-SC-56b4f5a2ea582d347c69ce30405e078270090dfa.tar.xz |
* committing what I've got so far for DuplicateOnRay so I don't fight the conflict monster later. Not done yet, doesn't crash the server.
Diffstat (limited to '')
5 files changed, 114 insertions, 17 deletions
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 5434a88..da286ad 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, bool frontFacesOnly) | 856 | public EntityIntersection GetClosestIntersectingPrim(Ray hray, bool frontFacesOnly, bool faceCenters) |
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, frontFacesOnly); | 866 | EntityIntersection result = reportingG.TestIntersection(hray, frontFacesOnly, faceCenters); |
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 7866b32..6bd5d1a 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -1240,7 +1240,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1240 | 1240 | ||
1241 | LLVector3 pos = GetNewRezLocation( | 1241 | LLVector3 pos = GetNewRezLocation( |
1242 | RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), | 1242 | RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), |
1243 | BypassRayCast, bRayEndIsIntersection,true,scale); | 1243 | BypassRayCast, bRayEndIsIntersection,true,scale, false); |
1244 | 1244 | ||
1245 | if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos) && !attachment) | 1245 | if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos) && !attachment) |
1246 | { | 1246 | { |
@@ -1271,7 +1271,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1271 | { | 1271 | { |
1272 | pos = GetNewRezLocation( | 1272 | pos = GetNewRezLocation( |
1273 | RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), | 1273 | RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), |
1274 | BypassRayCast, bRayEndIsIntersection, true, group.GroupScale()); | 1274 | BypassRayCast, bRayEndIsIntersection, true, group.GroupScale(), false); |
1275 | group.AbsolutePosition = pos; | 1275 | group.AbsolutePosition = pos; |
1276 | } | 1276 | } |
1277 | else | 1277 | else |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 30e3815..60d6293 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1169,7 +1169,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1169 | return myID; | 1169 | return myID; |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, LLVector3 scale) | 1172 | public LLVector3 GetNewRezLocation(LLVector3 RayStart, LLVector3 RayEnd, LLUUID RayTargetID, LLQuaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, LLVector3 scale, bool FaceCenter) |
1173 | { | 1173 | { |
1174 | LLVector3 pos = LLVector3.Zero; | 1174 | LLVector3 pos = LLVector3.Zero; |
1175 | if (RayEndIsIntersection == (byte)1) | 1175 | if (RayEndIsIntersection == (byte)1) |
@@ -1196,7 +1196,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1196 | Ray NewRay = new Ray(AXOrigin, AXdirection); | 1196 | Ray NewRay = new Ray(AXOrigin, AXdirection); |
1197 | 1197 | ||
1198 | // Ray Trace against target here | 1198 | // Ray Trace against target here |
1199 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1,0,0,0), frontFacesOnly); | 1199 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1,0,0,0), frontFacesOnly, FaceCenter); |
1200 | 1200 | ||
1201 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1201 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1202 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1202 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
@@ -1228,7 +1228,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1228 | { | 1228 | { |
1229 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1229 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1230 | 1230 | ||
1231 | EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true); | 1231 | EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1232 | 1232 | ||
1233 | // Un-comment the following line to print the raytrace results to the console. | 1233 | // Un-comment the following line to print the raytrace results to the console. |
1234 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1234 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
@@ -1254,7 +1254,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1254 | byte RayEndIsIntersection) | 1254 | byte RayEndIsIntersection) |
1255 | { | 1255 | { |
1256 | 1256 | ||
1257 | LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f,0.5f,0.5f)); | 1257 | LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f,0.5f,0.5f), false); |
1258 | 1258 | ||
1259 | if (PermissionsMngr.CanRezObject(ownerID, pos)) | 1259 | if (PermissionsMngr.CanRezObject(ownerID, pos)) |
1260 | { | 1260 | { |
@@ -1560,6 +1560,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1560 | client.OnLinkObjects += m_innerScene.LinkObjects; | 1560 | client.OnLinkObjects += m_innerScene.LinkObjects; |
1561 | client.OnDelinkObjects += m_innerScene.DelinkObjects; | 1561 | client.OnDelinkObjects += m_innerScene.DelinkObjects; |
1562 | client.OnObjectDuplicate += m_innerScene.DuplicateObject; | 1562 | client.OnObjectDuplicate += m_innerScene.DuplicateObject; |
1563 | client.OnObjectDuplicateOnRay += doObjectDuplicateOnRay; | ||
1563 | client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags; | 1564 | client.OnUpdatePrimFlags += m_innerScene.UpdatePrimFlags; |
1564 | client.OnRequestObjectPropertiesFamily += m_innerScene.RequestObjectPropertiesFamily; | 1565 | client.OnRequestObjectPropertiesFamily += m_innerScene.RequestObjectPropertiesFamily; |
1565 | client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(LandChannel.handleParcelPropertiesRequest); | 1566 | client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(LandChannel.handleParcelPropertiesRequest); |
@@ -1632,7 +1633,92 @@ namespace OpenSim.Region.Environment.Scenes | |||
1632 | 1633 | ||
1633 | 1634 | ||
1634 | } | 1635 | } |
1635 | 1636 | public void doObjectDuplicateOnRay(uint localID, uint dupeFlags, LLUUID AgentID, LLUUID GroupID, | |
1637 | LLUUID RayTargetObj, LLVector3 RayEnd, LLVector3 RayStart, | ||
1638 | bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates) | ||
1639 | { | ||
1640 | |||
1641 | LLVector3 pos = LLVector3.Zero; | ||
1642 | bool frontFacesOnly = true; | ||
1643 | |||
1644 | SceneObjectPart target = GetSceneObjectPart(localID); | ||
1645 | |||
1646 | if (target != null) | ||
1647 | { | ||
1648 | |||
1649 | LLVector3 direction = LLVector3.Norm(RayEnd - RayStart); | ||
1650 | Vector3 AXOrigin = new Vector3(RayStart.X, RayStart.Y, RayStart.Z); | ||
1651 | Vector3 AXdirection = new Vector3(direction.X, direction.Y, direction.Z); | ||
1652 | |||
1653 | |||
1654 | if (target != null) | ||
1655 | { | ||
1656 | if (target.ParentGroup != null) | ||
1657 | { | ||
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 | |||
1661 | // TODO: Raytrace better here | ||
1662 | |||
1663 | //EntityIntersection ei = m_innerScene.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); | ||
1664 | Ray NewRay = new Ray(AXOrigin, AXdirection); | ||
1665 | |||
1666 | // Ray Trace against target here | ||
1667 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, false); | ||
1668 | |||
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()); | ||
1671 | float ScaleOffset = 0.5f; | ||
1672 | |||
1673 | // If we hit something | ||
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 | |||
1684 | |||
1685 | |||
1686 | if (CopyCenters) | ||
1687 | { | ||
1688 | // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal. | ||
1689 | LLVector3 direction2 = LLVector3.Norm(pos - target.AbsolutePosition); | ||
1690 | Vector3 AXOrigin2 = new Vector3(target.AbsolutePosition.X, target.AbsolutePosition.Y, target.AbsolutePosition.Z); | ||
1691 | Vector3 AXdirection2 = ei.AAfaceNormal; | ||
1692 | Ray NewRay2 = new Ray(AXOrigin2, AXdirection2); | ||
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 | } | ||
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 | } | ||
1709 | |||
1710 | |||
1711 | return; | ||
1712 | } | ||
1713 | return; | ||
1714 | } | ||
1715 | |||
1716 | } | ||
1717 | |||
1718 | |||
1719 | |||
1720 | |||
1721 | } | ||
1636 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) | 1722 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags) |
1637 | { | 1723 | { |
1638 | UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); | 1724 | UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index e53cfaa..5d39790 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -543,7 +543,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
543 | return finalScale; | 543 | return finalScale; |
544 | 544 | ||
545 | } | 545 | } |
546 | public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly) | 546 | public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) |
547 | { | 547 | { |
548 | // We got a request from the inner_scene to raytrace along the Ray hRay | 548 | // We got a request from the inner_scene to raytrace along the Ray hRay |
549 | // We're going to check all of the prim in this group for intersection with the ray | 549 | // We're going to check all of the prim in this group for intersection with the ray |
@@ -565,7 +565,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
565 | // Telling the prim to raytrace. | 565 | // Telling the prim to raytrace. |
566 | //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); | 566 | //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); |
567 | 567 | ||
568 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation,frontFacesOnly); | 568 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation,frontFacesOnly, faceCenters); |
569 | 569 | ||
570 | // This may need to be updated to the maximum draw distance possible.. | 570 | // This may need to be updated to the maximum draw distance possible.. |
571 | // We might (and probably will) be checking for prim creation from other sims | 571 | // 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 18cae48..3dbd809 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -1060,7 +1060,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1060 | return Math.Sqrt(dx * dx + dy * dy + dz * dz); | 1060 | return Math.Sqrt(dx * dx + dy * dy + dz * dz); |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | public EntityIntersection TestIntersectionOBB(Ray iray, Quaternion parentrot, bool FrontFacesOnly) | 1063 | public EntityIntersection TestIntersectionOBB(Ray iray, Quaternion parentrot, bool frontFacesOnly, bool faceCenters) |
1064 | { | 1064 | { |
1065 | // In this case we're using a rectangular prism, which has 6 faces and therefore 6 planes | 1065 | // In this case we're using a rectangular prism, which has 6 faces and therefore 6 planes |
1066 | // This breaks down into the ray---> plane equation. | 1066 | // This breaks down into the ray---> plane equation. |
@@ -1339,14 +1339,25 @@ namespace OpenSim.Region.Environment.Scenes | |||
1339 | continue; | 1339 | continue; |
1340 | 1340 | ||
1341 | // If the normal is pointing outside the object | 1341 | // If the normal is pointing outside the object |
1342 | if (iray.Direction.Dot(normals[i]) < 0 || !FrontFacesOnly) | 1342 | if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly) |
1343 | { | 1343 | { |
1344 | |||
1345 | q = iray.Origin + a * iray.Direction; | ||
1346 | 1344 | ||
1347 | // Is this the closest hit to the object's origin? | 1345 | if (faceCenters) |
1348 | //float distance2 = (float)GetDistanceTo(q, iray.Origin); | 1346 | { |
1347 | q = AXpos + a * AAfacenormals[i]; //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f; | ||
1348 | } | ||
1349 | else | ||
1350 | { | ||
1351 | q = iray.Origin + a * iray.Direction; | ||
1352 | } | ||
1353 | |||
1349 | float distance2 = (float)GetDistanceTo(q, AXpos); | 1354 | float distance2 = (float)GetDistanceTo(q, AXpos); |
1355 | // Is this the closest hit to the object's origin? | ||
1356 | if (faceCenters) | ||
1357 | { | ||
1358 | distance2 = (float)GetDistanceTo(q, iray.Origin); | ||
1359 | } | ||
1360 | |||
1350 | 1361 | ||
1351 | if (distance2 < returnresult.distance) | 1362 | if (distance2 < returnresult.distance) |
1352 | { | 1363 | { |