aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMW2009-07-15 10:26:12 +0000
committerMW2009-07-15 10:26:12 +0000
commit08d4fffdfdf4f32d7aa9585bfd02e9aa02e04509 (patch)
tree203367d5e47c4adb17f55997bbd31e61cb96f47e /OpenSim
parentTest commit to see if commit is working for me, as another core developer is ... (diff)
downloadopensim-SC_OLD-08d4fffdfdf4f32d7aa9585bfd02e9aa02e04509.zip
opensim-SC_OLD-08d4fffdfdf4f32d7aa9585bfd02e9aa02e04509.tar.gz
opensim-SC_OLD-08d4fffdfdf4f32d7aa9585bfd02e9aa02e04509.tar.bz2
opensim-SC_OLD-08d4fffdfdf4f32d7aa9585bfd02e9aa02e04509.tar.xz
A attemp to fix the boundingBox code that I committed the other day.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs199
1 files changed, 174 insertions, 25 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index d65dbaf..dcc39cc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -596,7 +596,6 @@ namespace OpenSim.Region.Framework.Scenes
596 /// <returns></returns> 596 /// <returns></returns>
597 public Vector3 GetAxisAlignedBoundingBox() 597 public Vector3 GetAxisAlignedBoundingBox()
598 { 598 {
599 //int count = 0;
600 float maxX = 0f, maxY = 0f, maxZ = 0f, minX = 256f, minY = 256f, minZ = 256f; 599 float maxX = 0f, maxY = 0f, maxZ = 0f, minX = 256f, minY = 256f, minZ = 256f;
601 lock (m_parts) 600 lock (m_parts)
602 { 601 {
@@ -605,37 +604,187 @@ namespace OpenSim.Region.Framework.Scenes
605 Vector3 worldPos = part.GetWorldPosition(); 604 Vector3 worldPos = part.GetWorldPosition();
606 Quaternion worldRot = part.GetWorldRotation(); 605 Quaternion worldRot = part.GetWorldRotation();
607 606
608 Vector3 size = part.Scale * worldRot; 607 Vector3 frontTopLeft;
608 Vector3 frontTopRight;
609 Vector3 frontBottomLeft;
610 Vector3 frontBottomRight;
611
612 Vector3 backTopLeft;
613 Vector3 backTopRight;
614 Vector3 backBottomLeft;
615 Vector3 backBottomRight;
616
617 Vector3 orig = Vector3.Zero;
618
619 frontTopLeft.X = orig.X - (part.Scale.X / 2);
620 frontTopLeft.Y = orig.Y - (part.Scale.Y / 2);
621 frontTopLeft.Z = orig.Z + (part.Scale.Z / 2);
622
623 frontTopRight.X = orig.X + (part.Scale.X / 2);
624 frontTopRight.Y = orig.Y - (part.Scale.Y / 2);
625 frontTopRight.Z = orig.Z + (part.Scale.Z / 2);
626
627 frontBottomLeft.X = orig.X - (part.Scale.X / 2);
628 frontBottomLeft.Y = orig.Y - (part.Scale.Y / 2);
629 frontBottomLeft.Z = orig.Z - (part.Scale.Z / 2);
630
631 frontBottomRight.X = orig.X + (part.Scale.X / 2);
632 frontBottomRight.Y = orig.Y - (part.Scale.Y / 2);
633 frontBottomRight.Z = orig.Z - (part.Scale.Z / 2);
634
635
636 backTopLeft.X = orig.X - (part.Scale.X / 2);
637 backTopLeft.Y = orig.Y + (part.Scale.Y / 2);
638 backTopLeft.Z = orig.Z + (part.Scale.Z / 2);
639
640 backTopRight.X = orig.X + (part.Scale.X / 2);
641 backTopRight.Y = orig.Y + (part.Scale.Y / 2);
642 backTopRight.Z = orig.Z + (part.Scale.Z / 2);
643
644 backBottomLeft.X = orig.X - (part.Scale.X / 2);
645 backBottomLeft.Y = orig.Y + (part.Scale.Y / 2);
646 backBottomLeft.Z = orig.Z - (part.Scale.Z / 2);
647
648 backBottomRight.X = orig.X + (part.Scale.X / 2);
649 backBottomRight.Y = orig.Y + (part.Scale.Y / 2);
650 backBottomRight.Z = orig.Z - (part.Scale.Z / 2);
651
652 frontTopLeft = frontTopLeft * worldRot;
653 frontTopRight = frontTopRight * worldRot;
654 frontBottomLeft = frontBottomLeft * worldRot;
655 frontBottomRight = frontBottomRight * worldRot;
656
657 backBottomLeft = backBottomLeft * worldRot;
658 backBottomRight = backBottomRight * worldRot;
659 backTopLeft = backTopLeft * worldRot;
660 backTopRight = backTopRight * worldRot;
661
662
663 //frontTopLeft += worldPos;
664 //frontTopRight += worldPos;
665 //frontBottomLeft += worldPos;
666 //frontBottomRight += worldPos;
667
668 //backBottomLeft += worldPos;
669 //backBottomRight += worldPos;
670 //backTopLeft += worldPos;
671 //backTopRight += worldPos;
672
673 if (frontTopRight.X > maxX)
674 maxX = frontTopRight.X;
675 if (frontTopLeft.X > maxX)
676 maxX = frontTopLeft.X;
677 if (frontBottomRight.X > maxX)
678 maxX = frontBottomRight.X;
679 if (frontBottomLeft.X > maxX)
680 maxX = frontBottomLeft.X;
681
682 if (backTopRight.X > maxX)
683 maxX = backTopRight.X;
684 if (backTopLeft.X > maxX)
685 maxX = backTopLeft.X;
686 if (backBottomRight.X > maxX)
687 maxX = backBottomRight.X;
688 if (backBottomLeft.X > maxX)
689 maxX = backBottomLeft.X;
690
691 if (frontTopRight.X < minX)
692 minX = frontTopRight.X;
693 if (frontTopLeft.X < minX)
694 minX = frontTopLeft.X;
695 if (frontBottomRight.X < minX)
696 minX = frontBottomRight.X;
697 if (frontBottomLeft.X < minX)
698 minX = frontBottomLeft.X;
699
700 if (backTopRight.X < minX)
701 minX = backTopRight.X;
702 if (backTopLeft.X < minX)
703 minX = backTopLeft.X;
704 if (backBottomRight.X < minX)
705 minX = backBottomRight.X;
706 if (backBottomLeft.X < minX)
707 minX = backBottomLeft.X;
609 708
610 // m_log.InfoFormat("prim {0} , world pos is {1} , {2} , {3} , and size is {4} , {5} , {6}", count, worldPos.X, worldPos.Y, worldPos.Z, size.X, size.Y, size.Z); 709 //
611 // count++; 710 if (frontTopRight.Y > maxY)
612 711 maxY = frontTopRight.Y;
613 float tx= worldPos.X +( size.X/2); 712 if (frontTopLeft.Y > maxY)
614 float bx = worldPos.X - (size.X/2); 713 maxY = frontTopLeft.Y;
615 if (tx > maxX) 714 if (frontBottomRight.Y > maxY)
616 maxX = tx; 715 maxY = frontBottomRight.Y;
617 if (bx < minX) 716 if (frontBottomLeft.Y > maxY)
618 minX = bx; 717 maxY = frontBottomLeft.Y;
619 718
620 float ty = worldPos.Y + (size.Y / 2); 719 if (backTopRight.Y > maxY)
621 float by = worldPos.Y - (size.Y / 2); 720 maxY = backTopRight.Y;
622 if (ty > maxY) 721 if (backTopLeft.Y > maxY)
623 maxY = ty; 722 maxY = backTopLeft.Y;
624 if (by < minY) 723 if (backBottomRight.Y > maxY)
625 minY = by; 724 maxY = backBottomRight.Y;
725 if (backBottomLeft.Y > maxY)
726 maxY = backBottomLeft.Y;
727
728 if (frontTopRight.Y < minY)
729 minY = frontTopRight.Y;
730 if (frontTopLeft.Y < minY)
731 minY = frontTopLeft.Y;
732 if (frontBottomRight.Y < minY)
733 minY = frontBottomRight.Y;
734 if (frontBottomLeft.Y < minY)
735 minY = frontBottomLeft.Y;
736
737 if (backTopRight.Y < minY)
738 minY = backTopRight.Y;
739 if (backTopLeft.Y < minY)
740 minY = backTopLeft.Y;
741 if (backBottomRight.Y < minY)
742 minY = backBottomRight.Y;
743 if (backBottomLeft.Y < minY)
744 minY = backBottomLeft.Y;
626 745
627 float tz = worldPos.Z + (size.Z / 2); 746 //
628 float bz = worldPos.Z - (size.Z / 2); 747 if (frontTopRight.Z > maxZ)
629 if (tz > maxZ) 748 maxZ = frontTopRight.Z;
630 maxZ = tz; 749 if (frontTopLeft.Z > maxZ)
631 if (bz < minZ) 750 maxZ = frontTopLeft.Z;
632 minZ = bz; 751 if (frontBottomRight.Z > maxZ)
752 maxZ = frontBottomRight.Z;
753 if (frontBottomLeft.Z > maxZ)
754 maxZ = frontBottomLeft.Z;
755
756 if (backTopRight.Z > maxZ)
757 maxZ = backTopRight.Z;
758 if (backTopLeft.Z > maxZ)
759 maxZ = backTopLeft.Z;
760 if (backBottomRight.Z > maxZ)
761 maxZ = backBottomRight.Z;
762 if (backBottomLeft.Z > maxZ)
763 maxZ = backBottomLeft.Z;
764
765 if (frontTopRight.Z < minZ)
766 minZ = frontTopRight.Z;
767 if (frontTopLeft.Z < minZ)
768 minZ = frontTopLeft.Z;
769 if (frontBottomRight.Z < minZ)
770 minZ = frontBottomRight.Z;
771 if (frontBottomLeft.Z < minZ)
772 minZ = frontBottomLeft.Z;
773
774 if (backTopRight.Z < minZ)
775 minZ = backTopRight.Z;
776 if (backTopLeft.Z < minZ)
777 minZ = backTopLeft.Z;
778 if (backBottomRight.Z < minZ)
779 minZ = backBottomRight.Z;
780 if (backBottomLeft.Z < minZ)
781 minZ = backBottomLeft.Z;
633 } 782 }
634 783
635 } 784 }
636 785
637 Vector3 boundingBox = new Vector3(maxX - minX, maxY - minY, maxZ - minZ); 786 Vector3 boundingBox = new Vector3(maxX - minX, maxY - minY, maxZ - minZ);
638 //m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z); 787 // m_log.InfoFormat("BoundingBox is {0} , {1} , {2} ", boundingBox.X, boundingBox.Y, boundingBox.Z);
639 return boundingBox; 788 return boundingBox;
640 } 789 }
641 790