aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Physics/Manager/IMesher.cs11
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs36
2 files changed, 42 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs
index 1181b8d..3a9ca1b 100644
--- a/OpenSim/Region/Physics/Manager/IMesher.cs
+++ b/OpenSim/Region/Physics/Manager/IMesher.cs
@@ -38,6 +38,17 @@ namespace OpenSim.Region.Physics.Manager
38 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical); 38 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical);
39 } 39 }
40 40
41 // Values for level of detail to be passed to the mesher.
42 // Values origionally chosen for the LOD of sculpties (the sqrt(width*heigth) of sculpt texture)
43 // Lower level of detail reduces the number of vertices used to represent the meshed shape.
44 public enum LevelOfDetail
45 {
46 High = 32,
47 Medium = 16,
48 Low = 8,
49 VeryLow = 4
50 }
51
41 public interface IVertex 52 public interface IVertex
42 { 53 {
43 } 54 }
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index e81b982..faecce4 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -336,7 +336,7 @@ namespace OpenSim.Region.Physics.Meshing
336 } 336 }
337 else 337 else
338 { 338 {
339 if (!GenerateCoordsAndFacesFromPrimShapeData(primName, primShape, size, out coords, out faces)) 339 if (!GenerateCoordsAndFacesFromPrimShapeData(primName, primShape, size, lod, out coords, out faces))
340 return null; 340 return null;
341 } 341 }
342 342
@@ -616,7 +616,7 @@ namespace OpenSim.Region.Physics.Meshing
616 /// <param name="faces">Faces are added to this list by the method.</param> 616 /// <param name="faces">Faces are added to this list by the method.</param>
617 /// <returns>true if coords and faces were successfully generated, false if not</returns> 617 /// <returns>true if coords and faces were successfully generated, false if not</returns>
618 private bool GenerateCoordsAndFacesFromPrimShapeData( 618 private bool GenerateCoordsAndFacesFromPrimShapeData(
619 string primName, PrimitiveBaseShape primShape, Vector3 size, out List<Coord> coords, out List<Face> faces) 619 string primName, PrimitiveBaseShape primShape, Vector3 size, float lod, out List<Coord> coords, out List<Face> faces)
620 { 620 {
621 PrimMesh primMesh; 621 PrimMesh primMesh;
622 coords = new List<Coord>(); 622 coords = new List<Coord>();
@@ -636,13 +636,30 @@ namespace OpenSim.Region.Physics.Meshing
636 profileHollow = 0.95f; 636 profileHollow = 0.95f;
637 637
638 int sides = 4; 638 int sides = 4;
639 LevelOfDetail iLOD = (LevelOfDetail)lod;
639 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) 640 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
640 sides = 3; 641 sides = 3;
641 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) 642 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
642 sides = 24; 643 {
644 switch (iLOD)
645 {
646 case LevelOfDetail.High: sides = 24; break;
647 case LevelOfDetail.Medium: sides = 12; break;
648 case LevelOfDetail.Low: sides = 6; break;
649 case LevelOfDetail.VeryLow: sides = 3; break;
650 default: sides = 24; break;
651 }
652 }
643 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle) 653 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
644 { // half circle, prim is a sphere 654 { // half circle, prim is a sphere
645 sides = 24; 655 switch (iLOD)
656 {
657 case LevelOfDetail.High: sides = 24; break;
658 case LevelOfDetail.Medium: sides = 12; break;
659 case LevelOfDetail.Low: sides = 6; break;
660 case LevelOfDetail.VeryLow: sides = 3; break;
661 default: sides = 24; break;
662 }
646 663
647 profileBegin = 0.5f * profileBegin + 0.5f; 664 profileBegin = 0.5f * profileBegin + 0.5f;
648 profileEnd = 0.5f * profileEnd + 0.5f; 665 profileEnd = 0.5f * profileEnd + 0.5f;
@@ -650,7 +667,16 @@ namespace OpenSim.Region.Physics.Meshing
650 667
651 int hollowSides = sides; 668 int hollowSides = sides;
652 if (primShape.HollowShape == HollowShape.Circle) 669 if (primShape.HollowShape == HollowShape.Circle)
653 hollowSides = 24; 670 {
671 switch (iLOD)
672 {
673 case LevelOfDetail.High: hollowSides = 24; break;
674 case LevelOfDetail.Medium: hollowSides = 12; break;
675 case LevelOfDetail.Low: hollowSides = 6; break;
676 case LevelOfDetail.VeryLow: hollowSides = 3; break;
677 default: hollowSides = 24; break;
678 }
679 }
654 else if (primShape.HollowShape == HollowShape.Square) 680 else if (primShape.HollowShape == HollowShape.Square)
655 hollowSides = 4; 681 hollowSides = 4;
656 else if (primShape.HollowShape == HollowShape.Triangle) 682 else if (primShape.HollowShape == HollowShape.Triangle)