From 116a08f42e791ed5190c8e042e480715ce0f2d75 Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Sun, 12 Oct 2008 08:52:42 +0000 Subject: Fixed a missing face on a profile cut --- OpenSim/Region/Physics/Meshing/PrimMesher.cs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Physics/Meshing/PrimMesher.cs') diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index 537d652..e96985d 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs @@ -458,6 +458,10 @@ namespace PrimMesher return; } + bool simpleFace = false; // flag to create as few triangles as possible for 3 or 4 side profile + if (sides < 5 && hollow == 0.0f && profileStart == 0.0f && profileEnd == 1.0f) + simpleFace = true; + if (this.calcVertexNormals) { if (sides > 4) @@ -501,7 +505,7 @@ namespace PrimMesher } } } - else + else if (!simpleFace) { this.coords.Add(center); if (this.calcVertexNormals && sides > 4) @@ -546,7 +550,7 @@ namespace PrimMesher hollowCoords.Add(newVert); } } - else if (createFaces && angle.angle > 0.0001f) + else if (!simpleFace && createFaces && angle.angle > 0.0001f) { Face newFace = new Face(); newFace.v1 = 0; @@ -641,6 +645,18 @@ namespace PrimMesher this.coords.AddRange(hollowCoords); } + + if (simpleFace && createFaces) + { + if (sides == 3) + this.faces.Add(new Face(0, 1, 2)); + else if (sides == 4) + { + this.faces.Add(new Face(0, 1, 2)); + this.faces.Add(new Face(0, 2, 3)); + } + } + } public Profile Clone() @@ -966,7 +982,7 @@ namespace PrimMesher hollow *= 1.414f; bool hasProfileCut = false; - if (profileStart < 0.0 || profileEnd < 1.0) + if (profileStart > 0.0f || profileEnd < 1.0f) hasProfileCut = true; Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true, calcVertexNormals); @@ -1023,7 +1039,7 @@ namespace PrimMesher int startVert = coordsLen + 1; int endVert = this.coords.Count - 1; - if (hasProfileCut || hollow > 0.0f) + if (sides < 5 || hasProfileCut || hollow > 0.0f) startVert--; for (int i = startVert; i < endVert; i++) @@ -1067,6 +1083,9 @@ namespace PrimMesher } else done = true; } + + if (calcVertexNormals && sides < 5 && twistBegin == 0.0f && twistEnd == 0.0f) + this.CalcNormals(); } public void ExtrudeCircular() -- cgit v1.1