* This makes the non-physics llCastRay 'better'. It's not 'correctly working', and if you look deep enough, you see that the results are not really stable depending on the direction of the ray.

user_profiles
teravus 2013-01-23 21:58:51 -05:00
parent f7feed4d44
commit 878df52515
2 changed files with 18 additions and 4 deletions

View File

@ -3628,6 +3628,7 @@ namespace OpenSim.Region.Framework.Scenes
result.distance = distance2; result.distance = distance2;
result.HitTF = true; result.HitTF = true;
result.ipoint = q; result.ipoint = q;
result.face = i;
//m_log.Info("[FACE]:" + i.ToString()); //m_log.Info("[FACE]:" + i.ToString());
//m_log.Info("[POINT]: " + q.ToString()); //m_log.Info("[POINT]: " + q.ToString());
//m_log.Info("[DIST]: " + distance2.ToString()); //m_log.Info("[DIST]: " + distance2.ToString());

View File

@ -11152,7 +11152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
radius = Math.Abs(maxY); radius = Math.Abs(maxY);
if (Math.Abs(maxZ) > radius) if (Math.Abs(maxZ) > radius)
radius = Math.Abs(maxZ); radius = Math.Abs(maxZ);
radius = radius*1.413f;
Vector3 ac = group.AbsolutePosition - rayStart; Vector3 ac = group.AbsolutePosition - rayStart;
Vector3 bc = group.AbsolutePosition - rayEnd; Vector3 bc = group.AbsolutePosition - rayEnd;
@ -11167,11 +11167,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (d2 > 0) if (d2 > 0)
return; return;
ray = new Ray(rayStart, Vector3.Normalize(rayEnd - rayStart));
EntityIntersection intersection = group.TestIntersection(ray, true, false); EntityIntersection intersection = group.TestIntersection(ray, true, false);
// Miss. // Miss.
if (!intersection.HitTF) if (!intersection.HitTF)
return; return;
Vector3 b1 = group.AbsolutePosition + new Vector3(minX, minY, minZ);
Vector3 b2 = group.AbsolutePosition + new Vector3(maxX, maxY, maxZ);
//m_log.DebugFormat("[LLCASTRAY]: min<{0},{1},{2}>, max<{3},{4},{5}> = hitp<{6},{7},{8}>", b1.X,b1.Y,b1.Z,b2.X,b2.Y,b2.Z,intersection.ipoint.X,intersection.ipoint.Y,intersection.ipoint.Z);
if (!(intersection.ipoint.X >= b1.X && intersection.ipoint.X <= b2.X &&
intersection.ipoint.Y >= b1.Y && intersection.ipoint.Y <= b2.Y &&
intersection.ipoint.Z >= b1.Z && intersection.ipoint.Z <= b2.Z))
return;
ContactResult result = new ContactResult (); ContactResult result = new ContactResult ();
result.ConsumerID = group.LocalId; result.ConsumerID = group.LocalId;
result.Depth = intersection.distance; result.Depth = intersection.distance;
@ -11423,8 +11432,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (checkPhysical || checkNonPhysical || detectPhantom) if (checkPhysical || checkNonPhysical || detectPhantom)
{ {
ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom); ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, checkPhysical, checkNonPhysical, detectPhantom);
foreach (ContactResult r in objectHits) for (int iter = 0; iter < objectHits.Length; iter++)
results.Add(r); {
// Redistance the Depth because the Scene RayCaster returns distance from center to make the rezzing code simpler.
objectHits[iter].Depth = Vector3.Distance(objectHits[iter].Pos, rayStart);
results.Add(objectHits[iter]);
}
} }
} }