aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTeravus Ovares2007-11-30 16:29:23 +0000
committerTeravus Ovares2007-11-30 16:29:23 +0000
commit95c68a316af53368b6463caa1b7219c9f2ac9b65 (patch)
treef1321bcb41c8499a4542a99a3b02517a64688e9d /OpenSim/Region
parentreturn of the inv-lib-root patch from Justin Casey (IBM) (diff)
downloadopensim-SC_OLD-95c68a316af53368b6463caa1b7219c9f2ac9b65.zip
opensim-SC_OLD-95c68a316af53368b6463caa1b7219c9f2ac9b65.tar.gz
opensim-SC_OLD-95c68a316af53368b6463caa1b7219c9f2ac9b65.tar.bz2
opensim-SC_OLD-95c68a316af53368b6463caa1b7219c9f2ac9b65.tar.xz
*Refactored the initial raytracer so it doesn't use the Parent reference.
*Fixed a 'statement out of order' error in the setting of the permissions that are sent to the client.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs19
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs50
3 files changed, 48 insertions, 23 deletions
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 7c13b49..bdcd840 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -300,7 +300,7 @@ namespace OpenSim.Region.Environment.Scenes
300 if (ent is SceneObjectGroup) 300 if (ent is SceneObjectGroup)
301 { 301 {
302 SceneObjectGroup reportingG = (SceneObjectGroup)ent; 302 SceneObjectGroup reportingG = (SceneObjectGroup)ent;
303 EntityIntersection result = reportingG.testIntersection(hray); 303 EntityIntersection result = reportingG.TestIntersection(hray);
304 if (result.HitTF) 304 if (result.HitTF)
305 { 305 {
306 if (result.distance < closestDistance) 306 if (result.distance < closestDistance)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 8038a83..24fc484 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -358,17 +358,27 @@ namespace OpenSim.Region.Environment.Scenes
358 } 358 }
359 } 359 }
360 360
361 public EntityIntersection testIntersection(Ray hRay) 361 public EntityIntersection TestIntersection(Ray hRay)
362 { 362 {
363 // We got a request from the inner_scene to raytrace along the Ray hRay
364 // We're going to check all of the prim in this group for intersection with the ray
365 // If we get a result, we're going to find the closest result to the origin of the ray
366 // and send back the intersection information back to the innerscene.
367
363 EntityIntersection returnresult = new EntityIntersection(); 368 EntityIntersection returnresult = new EntityIntersection();
364 bool gothit = false; 369
365 foreach (SceneObjectPart part in m_parts.Values) 370 foreach (SceneObjectPart part in m_parts.Values)
366 { 371 {
367 SceneObjectPart returnThisPart = null; 372
368 Vector3 partPosition = new Vector3(part.AbsolutePosition.X,part.AbsolutePosition.Y,part.AbsolutePosition.Z); 373 Vector3 partPosition = new Vector3(part.AbsolutePosition.X,part.AbsolutePosition.Y,part.AbsolutePosition.Z);
369 Quaternion parentrotation = new Quaternion(GroupRotation.W,GroupRotation.X,GroupRotation.Y,GroupRotation.Z); 374 Quaternion parentrotation = new Quaternion(GroupRotation.W,GroupRotation.X,GroupRotation.Y,GroupRotation.Z);
370 EntityIntersection inter = part.testIntersection(hRay,parentrotation); 375
376 // Telling the prim to raytrace.
377 EntityIntersection inter = part.TestIntersection(hRay,parentrotation);
371 378
379 // This may need to be updated to the maximum draw distance possible..
380 // We might (and probably will) be checking for prim creation from other sims
381 // when the camera crosses the border.
372 float idist = 256f; 382 float idist = 256f;
373 383
374 384
@@ -384,7 +394,6 @@ namespace OpenSim.Region.Environment.Scenes
384 returnresult.obj = part; 394 returnresult.obj = part;
385 returnresult.normal = inter.normal; 395 returnresult.normal = inter.normal;
386 returnresult.distance = inter.distance; 396 returnresult.distance = inter.distance;
387 gothit = true;
388 } 397 }
389 } 398 }
390 399
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 6770812..99dafac 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -561,10 +561,12 @@ namespace OpenSim.Region.Environment.Scenes
561 serializer.Serialize(xmlWriter, this); 561 serializer.Serialize(xmlWriter, this);
562 } 562 }
563 563
564 public EntityIntersection testIntersection(Ray iray, Quaternion parentrot) 564 public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot)
565 { 565 {
566 566
567 //Sphere dummysphere = new Sphere(); 567 // In this case we're using a sphere with a radius of the largest dimention of the prim
568 // TODO: Change to take shape into account
569
568 570
569 EntityIntersection returnresult = new EntityIntersection(); 571 EntityIntersection returnresult = new EntityIntersection();
570 Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); 572 Vector3 vAbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
@@ -582,23 +584,25 @@ namespace OpenSim.Region.Environment.Scenes
582 Vector3 rDirection = iray.Direction; 584 Vector3 rDirection = iray.Direction;
583 585
584 586
585 587 // Buidling the first part of the Quadratic equation
586 Vector3 r2ndDirection = rDirection * rDirection; 588 Vector3 r2ndDirection = rDirection * rDirection;
587
588 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z; 589 float itestPart1 = r2ndDirection.x + r2ndDirection.y + r2ndDirection.z;
589 590
591 // Buidling the second part of the Quadratic equation
590 Vector3 tmVal2 = rOrigin - vAbsolutePosition; 592 Vector3 tmVal2 = rOrigin - vAbsolutePosition;
591
592 Vector3 r2Direction = rDirection * 2.0f; 593 Vector3 r2Direction = rDirection * 2.0f;
593 Vector3 tmVal3 = r2Direction * tmVal2; 594 Vector3 tmVal3 = r2Direction * tmVal2;
594 595
595 float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z; 596 float itestPart2 = tmVal3.x + tmVal3.y + tmVal3.z;
596 597
598 // Buidling the third part of the Quadratic equation
597 Vector3 tmVal4 = rOrigin * rOrigin; 599 Vector3 tmVal4 = rOrigin * rOrigin;
598 Vector3 tmVal5 = vAbsolutePosition * vAbsolutePosition; 600 Vector3 tmVal5 = vAbsolutePosition * vAbsolutePosition;
599 601
600 Vector3 tmVal6 = vAbsolutePosition * rOrigin; 602 Vector3 tmVal6 = vAbsolutePosition * rOrigin;
601 603
604
605 // Set Radius to the largest dimention of the prim
602 float radius = 0f; 606 float radius = 0f;
603 if (vScale.x > radius) 607 if (vScale.x > radius)
604 radius = vScale.x; 608 radius = vScale.x;
@@ -611,11 +615,11 @@ namespace OpenSim.Region.Environment.Scenes
611 615
612 float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z -(2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius))); 616 float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z -(2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius)));
613 617
614 // Yuk Quadradrics 618 // Yuk Quadradrics.. Solve first
615 float rootsqr = (itestPart2 * itestPart2) - (4.0f * itestPart1 * itestPart3); 619 float rootsqr = (itestPart2 * itestPart2) - (4.0f * itestPart1 * itestPart3);
616 if (rootsqr < 0.0f) 620 if (rootsqr < 0.0f)
617 { 621 {
618 622 // No intersection
619 return returnresult; 623 return returnresult;
620 } 624 }
621 float root = ((-itestPart2) - (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f); 625 float root = ((-itestPart2) - (float)Math.Sqrt((double)rootsqr)) / (itestPart1 * 2.0f);
@@ -628,18 +632,30 @@ namespace OpenSim.Region.Environment.Scenes
628 // is there any intersection? 632 // is there any intersection?
629 if (root < 0.0f) 633 if (root < 0.0f)
630 { 634 {
631 635 // nope, no intersection
632 return returnresult; 636 return returnresult;
633 } 637 }
634 } 638 }
635 639
640 // We got an intersection. putting together an EntityIntersection object with the
641 // intersection information
636 Vector3 ipoint = new Vector3(iray.Origin.x + (iray.Direction.x * root),iray.Origin.y + (iray.Direction.y * root),iray.Origin.z + (iray.Direction.z * root)); 642 Vector3 ipoint = new Vector3(iray.Origin.x + (iray.Direction.x * root),iray.Origin.y + (iray.Direction.y * root),iray.Origin.z + (iray.Direction.z * root));
637 643
638 returnresult.HitTF = true; 644 returnresult.HitTF = true;
639 returnresult.ipoint = ipoint; 645 returnresult.ipoint = ipoint;
646
647 // Normal is calculated by the difference and then normalizing the result
640 Vector3 normalpart = ipoint-vAbsolutePosition; 648 Vector3 normalpart = ipoint-vAbsolutePosition;
641 returnresult.normal = normalpart.Normalize(); 649 returnresult.normal = normalpart.Normalize();
642 returnresult.distance = ParentGroup.m_scene.m_innerScene.Vector3Distance(iray.Origin, ipoint); 650
651 // It's funny how the LLVector3 object has a Distance function, but the Axiom.Math object doesnt.
652 // I can write a function to do it.. but I like the fact that this one is Static.
653
654 LLVector3 distanceConvert1 = new LLVector3(iray.Origin.x,iray.Origin.y,iray.Origin.z);
655 LLVector3 distanceConvert2 = new LLVector3(ipoint.x, ipoint.y, ipoint.z);
656 float distance = (float)distanceConvert1.GetDistanceTo(distanceConvert2);
657
658 returnresult.distance = distance;
643 659
644 return returnresult; 660 return returnresult;
645 } 661 }
@@ -1235,15 +1251,15 @@ namespace OpenSim.Region.Environment.Scenes
1235 } 1251 }
1236 } 1252 }
1237 // If you can't edit it, send the base permissions minus the flag to edit 1253 // If you can't edit it, send the base permissions minus the flag to edit
1254
1255
1256 // We're going to be moving this into ScenePresence and the PermissionsManager itself.
1238 if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions) 1257 if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions)
1239 { 1258 {
1240 if (ParentGroup.m_scene.PermissionsMngr.CanEditObject(remoteClient.AgentId, this.ParentGroup.UUID)) 1259 if (ParentGroup.m_scene.PermissionsMngr.CanEditObject(remoteClient.AgentId, this.ParentGroup.UUID))
1241 { 1260 {
1242 //clientFlags = ObjectFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify; 1261 // we should be merging the objectflags with the ownermask here.
1243 //clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove; 1262 // TODO: Future refactoring here.
1244 //clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
1245 //clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
1246 // Send EveryoneMask
1247 clientFlags = ObjectFlags; 1263 clientFlags = ObjectFlags;
1248 1264
1249 } 1265 }
@@ -1259,13 +1275,13 @@ namespace OpenSim.Region.Environment.Scenes
1259 { 1275 {
1260 clientFlags = clientFlags &= ~(uint) LLObject.ObjectFlags.ObjectMove; 1276 clientFlags = clientFlags &= ~(uint) LLObject.ObjectFlags.ObjectMove;
1261 } 1277 }
1262 1278 clientFlags = EveryoneMask;
1263 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify; 1279 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
1264 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; 1280 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop;
1265 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; 1281 clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer;
1266 1282
1267 // TODO, FIXME, ERROR : This whole block amounts to moot because of this. 1283
1268 clientFlags = EveryoneMask; 1284
1269 } 1285 }
1270 } 1286 }
1271 1287