aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2016-09-02 11:55:59 +0100
committerUbitUmarov2016-09-02 11:55:59 +0100
commitd9572bdf4e97a82ef570b1153e422b66ea5085f7 (patch)
treec0640cad6a0fecfb65afcf8c89d2f09d7d5c7f5c
parentConvexDecomposition fix some incorrect convexhull mesh generation for ubOde (diff)
downloadopensim-SC-d9572bdf4e97a82ef570b1153e422b66ea5085f7.zip
opensim-SC-d9572bdf4e97a82ef570b1153e422b66ea5085f7.tar.gz
opensim-SC-d9572bdf4e97a82ef570b1153e422b66ea5085f7.tar.bz2
opensim-SC-d9572bdf4e97a82ef570b1153e422b66ea5085f7.tar.xz
ConvexDecomposition remove a copy of vertices not needed for ubOde
-rw-r--r--OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs15
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs83
2 files changed, 92 insertions, 6 deletions
diff --git a/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs
index 22691e6..72f2d6d 100644
--- a/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs
+++ b/OpenSim/Region/PhysicsModules/ConvexDecompositionDotNet/HullUtils.cs
@@ -1094,7 +1094,7 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
1094 return m; 1094 return m;
1095 } 1095 }
1096 1096
1097 for (int i = m; i < count; i++) 1097 for (int i = m + 1; i < count; i++)
1098 { 1098 {
1099 if (allow[i] != 0) 1099 if (allow[i] != 0)
1100 { 1100 {
@@ -1540,6 +1540,19 @@ namespace OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet
1540 } 1540 }
1541 } 1541 }
1542 1542
1543 public static bool ComputeHull(List<float3> vertices, out List<int> indices)
1544 {
1545 List<HullTriangle> tris = new List<HullTriangle>();
1546
1547 bool ret = calchull(vertices, out indices, 0, tris);
1548 if (ret == false)
1549 {
1550 indices = new List<int>();
1551 return false;
1552 }
1553 return true;
1554 }
1555
1543 private static bool CleanupVertices(List<float3> svertices, out List<float3> vertices, float normalepsilon, out float3 scale) 1556 private static bool CleanupVertices(List<float3> svertices, out List<float3> vertices, float normalepsilon, out float3 scale)
1544 { 1557 {
1545 const float EPSILON = 0.000001f; 1558 const float EPSILON = 0.000001f;
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 }