From 07167c9a3f6d93fddf66e6f252f4a9b3a4fde8de Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 3 May 2008 04:33:17 +0000 Subject: * Committing some collision stuffs that I'm working on. * Nothing user facing yet. --- OpenSim/Region/Environment/Scenes/Scene.cs | 13 ++--- .../Region/Environment/Scenes/SceneObjectPart.cs | 55 ++++++++++++++++++++-- 2 files changed, 57 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') 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 Ray NewRay = new Ray(AXOrigin, AXdirection); // Ray Trace against target here - EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, CopyCenters); + EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, false); // Un-comment out the following line to Get Raytrace results printed to the console. // 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 ScaleOffset = Math.Abs(ScaleOffset); LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z); LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z); - + LLVector3 offset = (normal * (ScaleOffset / 2f)); + pos = (intersectionpoint + offset); if (CopyCenters) { // now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal. - LLVector3 direction2 = LLVector3.Norm(intersectionpoint - target2.AbsolutePosition); + LLVector3 direction2 = LLVector3.Norm(pos - target2.AbsolutePosition); Vector3 AXOrigin2 = new Vector3(target2.AbsolutePosition.X, target2.AbsolutePosition.Y, target2.AbsolutePosition.Z); - Vector3 AXdirection2 = ei.AAfaceNormal; + Vector3 AXdirection2 = new Vector3(direction2.X, direction2.Y, direction2.Z); //ei.AAfaceNormal; Ray NewRay2 = new Ray(AXOrigin2, AXdirection2); - EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), true, CopyCenters); + EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), false, CopyCenters); if (ei2.HitTF) { //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 } // Set the position to the intersection point - LLVector3 offset = (normal * (ScaleOffset / 2f)); + offset = (normal * (ScaleOffset / 2f)); pos = (intersectionpoint + offset); // 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 AmBa = FaceA[i] - FaceB[i]; AmBb = FaceB[i] - FaceC[i]; d = normals[i].Dot(FaceB[i]); - c = iray.Direction.Dot(normals[i]); + + if (faceCenters) + { + c = normals[i].Dot(normals[i]); + } + else + { + c = iray.Direction.Dot(normals[i]); + } if (c == 0) continue; @@ -1339,12 +1347,15 @@ namespace OpenSim.Region.Environment.Scenes continue; // If the normal is pointing outside the object + + + if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly) { if (faceCenters) - { - q = (FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f; //iray.Origin + a * normals[i]; + { //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f; + q = iray.Origin + a * normals[i]; } else { @@ -1364,8 +1375,9 @@ namespace OpenSim.Region.Environment.Scenes returnresult.distance = distance2; returnresult.HitTF = true; returnresult.ipoint = q; - //m_log.Info("[FACE]:" + i.ToString()); - //m_log.Info("[POINT]: " + q.ToString()); + m_log.Info("[FACE]:" + i.ToString()); + m_log.Info("[POINT]: " + q.ToString()); + m_log.Info("[DIST]: " + distance2.ToString()); returnresult.normal = normals[i]; returnresult.AAfaceNormal = AAfacenormals[i]; @@ -2680,6 +2692,20 @@ namespace OpenSim.Region.Environment.Scenes ) { // subscribe to physics updates. + if (PhysActor != null) + { + PhysActor.OnCollisionUpdate += PhysicsCollision; + PhysActor.SubscribeEvents(1000); + + } + } + else + { + if (PhysActor != null) + { + PhysActor.UnSubscribeEvents(); + PhysActor.OnCollisionUpdate -= PhysicsCollision; + } } LocalFlags=(LLObject.ObjectFlags)objectflagupdate; @@ -2689,5 +2715,24 @@ namespace OpenSim.Region.Environment.Scenes else ScheduleFullUpdate(); } + public void PhysicsCollision(EventArgs e) + { + + return; + + // + //if (e == null) + //{ + // return; + //} + //CollisionEventUpdate a = (CollisionEventUpdate)e; + //Dictionary collissionswith = a.m_objCollisionList; + //foreach (uint localid in collissionswith.Keys) + //{ + // m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); + //} + + } } + } -- cgit v1.1