aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
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/Environment/Scenes/SceneObjectPart.cs
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/Environment/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs50
1 files changed, 33 insertions, 17 deletions
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