diff options
Diffstat (limited to 'OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs')
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs | 83 |
1 files changed, 78 insertions, 5 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs index 89baf94..d9544db 100644 --- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs +++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs | |||
@@ -619,7 +619,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
619 | vs.Clear(); | 619 | vs.Clear(); |
620 | continue; | 620 | continue; |
621 | } | 621 | } |
622 | 622 | /* | |
623 | if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f)) | 623 | if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f)) |
624 | { | 624 | { |
625 | vs.Clear(); | 625 | vs.Clear(); |
@@ -657,6 +657,45 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
657 | f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); | 657 | f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); |
658 | faces.Add(f); | 658 | faces.Add(f); |
659 | } | 659 | } |
660 | */ | ||
661 | List<int> indices; | ||
662 | if (!HullUtils.ComputeHull(vs, out indices)) | ||
663 | { | ||
664 | vs.Clear(); | ||
665 | continue; | ||
666 | } | ||
667 | |||
668 | nverts = vs.Count; | ||
669 | nindexs = indices.Count; | ||
670 | |||
671 | if (nindexs % 3 != 0) | ||
672 | { | ||
673 | vs.Clear(); | ||
674 | continue; | ||
675 | } | ||
676 | |||
677 | for (i = 0; i < nverts; i++) | ||
678 | { | ||
679 | c.X = vs[i].x; | ||
680 | c.Y = vs[i].y; | ||
681 | c.Z = vs[i].z; | ||
682 | coords.Add(c); | ||
683 | } | ||
684 | |||
685 | for (i = 0; i < nindexs; i += 3) | ||
686 | { | ||
687 | t1 = indices[i]; | ||
688 | if (t1 > nverts) | ||
689 | break; | ||
690 | t2 = indices[i + 1]; | ||
691 | if (t2 > nverts) | ||
692 | break; | ||
693 | t3 = indices[i + 2]; | ||
694 | if (t3 > nverts) | ||
695 | break; | ||
696 | f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); | ||
697 | faces.Add(f); | ||
698 | } | ||
660 | vertsoffset += nverts; | 699 | vertsoffset += nverts; |
661 | vs.Clear(); | 700 | vs.Clear(); |
662 | } | 701 | } |
@@ -686,13 +725,15 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
686 | vs.Add(f3); | 725 | vs.Add(f3); |
687 | } | 726 | } |
688 | 727 | ||
689 | if (vs.Count < 3) | 728 | nverts = vs.Count; |
729 | |||
730 | if (nverts < 3) | ||
690 | { | 731 | { |
691 | vs.Clear(); | 732 | vs.Clear(); |
692 | return false; | 733 | return false; |
693 | } | 734 | } |
694 | 735 | ||
695 | if (vs.Count < 5) | 736 | if (nverts < 5) |
696 | { | 737 | { |
697 | foreach (float3 point in vs) | 738 | foreach (float3 point in vs) |
698 | { | 739 | { |
@@ -701,10 +742,11 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
701 | c.Z = point.z; | 742 | c.Z = point.z; |
702 | coords.Add(c); | 743 | coords.Add(c); |
703 | } | 744 | } |
745 | |||
704 | f = new Face(0, 1, 2); | 746 | f = new Face(0, 1, 2); |
705 | faces.Add(f); | 747 | faces.Add(f); |
706 | 748 | ||
707 | if (vs.Count == 4) | 749 | if (nverts == 4) |
708 | { | 750 | { |
709 | f = new Face(0, 2, 3); | 751 | f = new Face(0, 2, 3); |
710 | faces.Add(f); | 752 | faces.Add(f); |
@@ -716,7 +758,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
716 | vs.Clear(); | 758 | vs.Clear(); |
717 | return true; | 759 | return true; |
718 | } | 760 | } |
719 | 761 | /* | |
720 | if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f)) | 762 | if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f)) |
721 | return false; | 763 | return false; |
722 | 764 | ||
@@ -747,7 +789,38 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
747 | f = new Face(t1, t2, t3); | 789 | f = new Face(t1, t2, t3); |
748 | faces.Add(f); | 790 | faces.Add(f); |
749 | } | 791 | } |
792 | */ | ||
793 | List<int> indices; | ||
794 | if (!HullUtils.ComputeHull(vs, out indices)) | ||
795 | return false; | ||
796 | |||
797 | nindexs = indices.Count; | ||
750 | 798 | ||
799 | if (nindexs % 3 != 0) | ||
800 | return false; | ||
801 | |||
802 | for (i = 0; i < nverts; i++) | ||
803 | { | ||
804 | c.X = vs[i].x; | ||
805 | c.Y = vs[i].y; | ||
806 | c.Z = vs[i].z; | ||
807 | coords.Add(c); | ||
808 | } | ||
809 | for (i = 0; i < nindexs; i += 3) | ||
810 | { | ||
811 | t1 = indices[i]; | ||
812 | if (t1 > nverts) | ||
813 | break; | ||
814 | t2 = indices[i + 1]; | ||
815 | if (t2 > nverts) | ||
816 | break; | ||
817 | t3 = indices[i + 2]; | ||
818 | if (t3 > nverts) | ||
819 | break; | ||
820 | f = new Face(t1, t2, t3); | ||
821 | faces.Add(f); | ||
822 | } | ||
823 | vs.Clear(); | ||
751 | if (coords.Count > 0 && faces.Count > 0) | 824 | if (coords.Count > 0 && faces.Count > 0) |
752 | return true; | 825 | return true; |
753 | } | 826 | } |