diff options
author | Teravus Ovares | 2008-05-03 04:33:17 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-03 04:33:17 +0000 |
commit | 07167c9a3f6d93fddf66e6f252f4a9b3a4fde8de (patch) | |
tree | 7b19dfcf5db2afcd1bbacbf55298f14669b0f615 /OpenSim/Region/Environment/Scenes | |
parent | Thank you kindly, Melanie for a patch to solve (diff) | |
download | opensim-SC-07167c9a3f6d93fddf66e6f252f4a9b3a4fde8de.zip opensim-SC-07167c9a3f6d93fddf66e6f252f4a9b3a4fde8de.tar.gz opensim-SC-07167c9a3f6d93fddf66e6f252f4a9b3a4fde8de.tar.bz2 opensim-SC-07167c9a3f6d93fddf66e6f252f4a9b3a4fde8de.tar.xz |
* Committing some collision stuffs that I'm working on.
* Nothing user facing yet.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 55 |
2 files changed, 57 insertions, 11 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 378199c..edce960 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -1659,7 +1659,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1659 | Ray NewRay = new Ray(AXOrigin, AXdirection); | 1659 | Ray NewRay = new Ray(AXOrigin, AXdirection); |
1660 | 1660 | ||
1661 | // Ray Trace against target here | 1661 | // Ray Trace against target here |
1662 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, CopyCenters); | 1662 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, false); |
1663 | 1663 | ||
1664 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1664 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1665 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1665 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
@@ -1676,16 +1676,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
1676 | ScaleOffset = Math.Abs(ScaleOffset); | 1676 | ScaleOffset = Math.Abs(ScaleOffset); |
1677 | LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); | 1677 | LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); |
1678 | LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); | 1678 | LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); |
1679 | 1679 | LLVector3 offset = (normal * (ScaleOffset / 2f)); | |
1680 | pos = (intersectionpoint + offset); | ||
1680 | 1681 | ||
1681 | if (CopyCenters) | 1682 | if (CopyCenters) |
1682 | { | 1683 | { |
1683 | // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal. | 1684 | // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal. |
1684 | LLVector3 direction2 = LLVector3.Norm(intersectionpoint - target2.AbsolutePosition); | 1685 | LLVector3 direction2 = LLVector3.Norm(pos - target2.AbsolutePosition); |
1685 | Vector3 AXOrigin2 = new Vector3(target2.AbsolutePosition.X, target2.AbsolutePosition.Y, target2.AbsolutePosition.Z); | 1686 | Vector3 AXOrigin2 = new Vector3(target2.AbsolutePosition.X, target2.AbsolutePosition.Y, target2.AbsolutePosition.Z); |
1686 | Vector3 AXdirection2 = ei.AAfaceNormal; | 1687 | Vector3 AXdirection2 = new Vector3(direction2.X, direction2.Y, direction2.Z); //ei.AAfaceNormal; |
1687 | Ray NewRay2 = new Ray(AXOrigin2, AXdirection2); | 1688 | Ray NewRay2 = new Ray(AXOrigin2, AXdirection2); |
1688 | EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), true, CopyCenters); | 1689 | EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), false, CopyCenters); |
1689 | if (ei2.HitTF) | 1690 | if (ei2.HitTF) |
1690 | { | 1691 | { |
1691 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString()); | 1692 | //m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString()); |
@@ -1697,7 +1698,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1697 | } | 1698 | } |
1698 | 1699 | ||
1699 | // Set the position to the intersection point | 1700 | // Set the position to the intersection point |
1700 | LLVector3 offset = (normal * (ScaleOffset / 2f)); | 1701 | offset = (normal * (ScaleOffset / 2f)); |
1701 | pos = (intersectionpoint + offset); | 1702 | pos = (intersectionpoint + offset); |
1702 | 1703 | ||
1703 | // stick in offset format from the original prim | 1704 | // stick in offset format from the original prim |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 35eabbd..9b4f9af 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -1329,7 +1329,15 @@ namespace OpenSim.Region.Environment.Scenes | |||
1329 | AmBa = FaceA[i] - FaceB[i]; | 1329 | AmBa = FaceA[i] - FaceB[i]; |
1330 | AmBb = FaceB[i] - FaceC[i]; | 1330 | AmBb = FaceB[i] - FaceC[i]; |
1331 | d = normals[i].Dot(FaceB[i]); | 1331 | d = normals[i].Dot(FaceB[i]); |
1332 | c = iray.Direction.Dot(normals[i]); | 1332 | |
1333 | if (faceCenters) | ||
1334 | { | ||
1335 | c = normals[i].Dot(normals[i]); | ||
1336 | } | ||
1337 | else | ||
1338 | { | ||
1339 | c = iray.Direction.Dot(normals[i]); | ||
1340 | } | ||
1333 | if (c == 0) | 1341 | if (c == 0) |
1334 | continue; | 1342 | continue; |
1335 | 1343 | ||
@@ -1339,12 +1347,15 @@ namespace OpenSim.Region.Environment.Scenes | |||
1339 | continue; | 1347 | continue; |
1340 | 1348 | ||
1341 | // If the normal is pointing outside the object | 1349 | // If the normal is pointing outside the object |
1350 | |||
1351 | |||
1352 | |||
1342 | if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly) | 1353 | if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly) |
1343 | { | 1354 | { |
1344 | 1355 | ||
1345 | if (faceCenters) | 1356 | if (faceCenters) |
1346 | { | 1357 | { //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f; |
1347 | q = (FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f; //iray.Origin + a * normals[i]; | 1358 | q = iray.Origin + a * normals[i]; |
1348 | } | 1359 | } |
1349 | else | 1360 | else |
1350 | { | 1361 | { |
@@ -1364,8 +1375,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
1364 | returnresult.distance = distance2; | 1375 | returnresult.distance = distance2; |
1365 | returnresult.HitTF = true; | 1376 | returnresult.HitTF = true; |
1366 | returnresult.ipoint = q; | 1377 | returnresult.ipoint = q; |
1367 | //m_log.Info("[FACE]:" + i.ToString()); | 1378 | m_log.Info("[FACE]:" + i.ToString()); |
1368 | //m_log.Info("[POINT]: " + q.ToString()); | 1379 | m_log.Info("[POINT]: " + q.ToString()); |
1380 | m_log.Info("[DIST]: " + distance2.ToString()); | ||
1369 | returnresult.normal = normals[i]; | 1381 | returnresult.normal = normals[i]; |
1370 | returnresult.AAfaceNormal = AAfacenormals[i]; | 1382 | returnresult.AAfaceNormal = AAfacenormals[i]; |
1371 | 1383 | ||
@@ -2680,6 +2692,20 @@ namespace OpenSim.Region.Environment.Scenes | |||
2680 | ) | 2692 | ) |
2681 | { | 2693 | { |
2682 | // subscribe to physics updates. | 2694 | // subscribe to physics updates. |
2695 | if (PhysActor != null) | ||
2696 | { | ||
2697 | PhysActor.OnCollisionUpdate += PhysicsCollision; | ||
2698 | PhysActor.SubscribeEvents(1000); | ||
2699 | |||
2700 | } | ||
2701 | } | ||
2702 | else | ||
2703 | { | ||
2704 | if (PhysActor != null) | ||
2705 | { | ||
2706 | PhysActor.UnSubscribeEvents(); | ||
2707 | PhysActor.OnCollisionUpdate -= PhysicsCollision; | ||
2708 | } | ||
2683 | } | 2709 | } |
2684 | 2710 | ||
2685 | LocalFlags=(LLObject.ObjectFlags)objectflagupdate; | 2711 | LocalFlags=(LLObject.ObjectFlags)objectflagupdate; |
@@ -2689,5 +2715,24 @@ namespace OpenSim.Region.Environment.Scenes | |||
2689 | else | 2715 | else |
2690 | ScheduleFullUpdate(); | 2716 | ScheduleFullUpdate(); |
2691 | } | 2717 | } |
2718 | public void PhysicsCollision(EventArgs e) | ||
2719 | { | ||
2720 | |||
2721 | return; | ||
2722 | |||
2723 | // | ||
2724 | //if (e == null) | ||
2725 | //{ | ||
2726 | // return; | ||
2727 | //} | ||
2728 | //CollisionEventUpdate a = (CollisionEventUpdate)e; | ||
2729 | //Dictionary<uint, float> collissionswith = a.m_objCollisionList; | ||
2730 | //foreach (uint localid in collissionswith.Keys) | ||
2731 | //{ | ||
2732 | // m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
2733 | //} | ||
2734 | |||
2735 | } | ||
2692 | } | 2736 | } |
2737 | |||
2693 | } | 2738 | } |