Circular path prim meshes are now joined where the path ends meet if they match. This may have a minor improvement in memory and speed performance, but it's mainly for viewer applications and it also syncs the c# version of PrimMesher with my python sandbox version.

0.6.0-stable
Dahlia Trimble 2008-09-13 10:22:17 +00:00
parent 39902fef77
commit 8a8b01d1b8
2 changed files with 89 additions and 66 deletions

View File

@ -1909,8 +1909,8 @@ namespace OpenSim.Region.Physics.Meshing
PrimMesh primMesh = new PrimMesh(sides, profileBegin, profileEnd, profileHollow, hollowSides); PrimMesh primMesh = new PrimMesh(sides, profileBegin, profileEnd, profileHollow, hollowSides);
//PrimMesh primMesh = new PrimMesh(sides, profileBegin, profileEnd, 0.0f, 4); //PrimMesh primMesh = new PrimMesh(sides, profileBegin, profileEnd, 0.0f, 4);
Profile testProfile = new Profile(sides, profileBegin, profileEnd, profileHollow, hollowSides); //Profile testProfile = new Profile(sides, profileBegin, profileEnd, profileHollow, hollowSides, true);
testProfile.DumpRaw(baseDir, primName, "Profile"); //testProfile.DumpRaw(baseDir, primName, "Profile");
primMesh.topShearX = pathShearX; primMesh.topShearX = pathShearX;
primMesh.topShearY = pathShearY; primMesh.topShearY = pathShearY;

View File

@ -336,7 +336,7 @@ angles24 = [
this.faces = new List<Face>(); this.faces = new List<Face>();
} }
public Profile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides) public Profile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides, bool createFaces)
{ {
this.coords = new List<Coord>(); this.coords = new List<Coord>();
this.faces = new List<Face>(); this.faces = new List<Face>();
@ -422,7 +422,7 @@ angles24 = [
hollowCoords.Add(newVert); hollowCoords.Add(newVert);
} }
} }
else if (angle.angle > 0.0001f) else if (createFaces && angle.angle > 0.0001f)
{ {
Face newFace = new Face(); Face newFace = new Face();
newFace.v1 = 0; newFace.v1 = 0;
@ -437,77 +437,80 @@ angles24 = [
{ {
hollowCoords.Reverse(); hollowCoords.Reverse();
int numOuterVerts = this.coords.Count; if (createFaces)
int numHollowVerts = hollowCoords.Count;
int numTotalVerts = numOuterVerts + numHollowVerts;
if (numOuterVerts == numHollowVerts)
{ {
Face newFace = new Face(); int numOuterVerts = this.coords.Count;
int numHollowVerts = hollowCoords.Count;
int numTotalVerts = numOuterVerts + numHollowVerts;
for (int coordIndex = 0; coordIndex < numOuterVerts - 1; coordIndex++) if (numOuterVerts == numHollowVerts)
{
newFace.v1 = coordIndex;
newFace.v2 = coordIndex + 1;
newFace.v3 = numTotalVerts - coordIndex - 1;
this.faces.Add(newFace);
newFace.v1 = coordIndex + 1;
newFace.v2 = numTotalVerts - coordIndex - 2;
newFace.v3 = numTotalVerts - coordIndex - 1;
this.faces.Add(newFace);
}
}
else
{
if (numOuterVerts < numHollowVerts)
{ {
Face newFace = new Face(); Face newFace = new Face();
int j = 0; // j is the index for outer vertices
int maxJ = numOuterVerts - 1; for (int coordIndex = 0; coordIndex < numOuterVerts - 1; coordIndex++)
for (int i = 0; i < numHollowVerts; i++) // i is the index for inner vertices
{ {
if (j < maxJ) newFace.v1 = coordIndex;
if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle <= hollowAngles.angles[i].angle - angles.angles[j].angle) newFace.v2 = coordIndex + 1;
{ newFace.v3 = numTotalVerts - coordIndex - 1;
newFace.v1 = numTotalVerts - i - 1; this.faces.Add(newFace);
newFace.v2 = j;
newFace.v3 = j + 1;
this.faces.Add(newFace);
j += 1;
}
newFace.v1 = j;
newFace.v2 = numTotalVerts - i - 2;
newFace.v3 = numTotalVerts - i - 1;
newFace.v1 = coordIndex + 1;
newFace.v2 = numTotalVerts - coordIndex - 2;
newFace.v3 = numTotalVerts - coordIndex - 1;
this.faces.Add(newFace); this.faces.Add(newFace);
} }
} }
else // numHollowVerts < numOuterVerts else
{ {
Face newFace = new Face(); if (numOuterVerts < numHollowVerts)
int j = 0; // j is the index for inner vertices
int maxJ = numHollowVerts - 1;
for (int i = 0; i < numOuterVerts; i++)
{ {
if (j < maxJ) Face newFace = new Face();
if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle <= angles.angles[i].angle - hollowAngles.angles[j].angle) int j = 0; // j is the index for outer vertices
{ int maxJ = numOuterVerts - 1;
newFace.v1 = i; for (int i = 0; i < numHollowVerts; i++) // i is the index for inner vertices
newFace.v2 = numTotalVerts - j - 2; {
newFace.v3 = numTotalVerts - j - 1; if (j < maxJ)
if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle <= hollowAngles.angles[i].angle - angles.angles[j].angle)
{
newFace.v1 = numTotalVerts - i - 1;
newFace.v2 = j;
newFace.v3 = j + 1;
this.faces.Add(newFace); this.faces.Add(newFace);
j += 1; j += 1;
} }
newFace.v1 = numTotalVerts - j - 1; newFace.v1 = j;
newFace.v2 = i; newFace.v2 = numTotalVerts - i - 2;
newFace.v3 = i + 1; newFace.v3 = numTotalVerts - i - 1;
this.faces.Add(newFace); this.faces.Add(newFace);
}
}
else // numHollowVerts < numOuterVerts
{
Face newFace = new Face();
int j = 0; // j is the index for inner vertices
int maxJ = numHollowVerts - 1;
for (int i = 0; i < numOuterVerts; i++)
{
if (j < maxJ)
if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle <= angles.angles[i].angle - hollowAngles.angles[j].angle)
{
newFace.v1 = i;
newFace.v2 = numTotalVerts - j - 2;
newFace.v3 = numTotalVerts - j - 1;
this.faces.Add(newFace);
j += 1;
}
newFace.v1 = numTotalVerts - j - 1;
newFace.v2 = i;
newFace.v3 = i + 1;
this.faces.Add(newFace);
}
} }
} }
} }
@ -517,11 +520,17 @@ angles24 = [
} }
public Profile Clone() public Profile Clone()
{
return this.Clone(true);
}
public Profile Clone(bool needFaces)
{ {
Profile clone = new Profile(); Profile clone = new Profile();
clone.coords.AddRange(this.coords); clone.coords.AddRange(this.coords);
clone.faces.AddRange(this.faces); if (needFaces)
clone.faces.AddRange(this.faces);
return clone; return clone;
} }
@ -781,7 +790,7 @@ angles24 = [
hollow *= 0.707f; hollow *= 0.707f;
} }
Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides); Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true);
if (initialProfileRot != 0.0f) if (initialProfileRot != 0.0f)
profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot)); profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot));
@ -948,7 +957,17 @@ angles24 = [
} }
} }
Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides); bool needEndFaces = false;
if (this.pathCutBegin != 0.0 || this.pathCutEnd != 1.0)
needEndFaces = true;
else if (this.taperX != 0.0 || this.taperY != 0.0)
needEndFaces = true;
else if (this.skew != 0.0)
needEndFaces = true;
else if (twistTotal != 0.0)
needEndFaces = true;
Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, needEndFaces);
if (initialProfileRot != 0.0f) if (initialProfileRot != 0.0f)
profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot)); profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot));
@ -956,7 +975,11 @@ angles24 = [
bool done = false; bool done = false;
while (!done) // loop through the length of the path and add the layers while (!done) // loop through the length of the path and add the layers
{ {
Profile newLayer = profile.Clone(); bool isEndLayer = false;
if (angle == startAngle || angle >= endAngle)
isEndLayer = true;
Profile newLayer = profile.Clone(isEndLayer && needEndFaces);
float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX; float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX;
float yProfileScale = this.holeSizeY; float yProfileScale = this.holeSizeY;
@ -1012,7 +1035,7 @@ angles24 = [
this.coords.AddRange(newLayer.coords); this.coords.AddRange(newLayer.coords);
if (angle <= startAngle || angle >= endAngle) if (isEndLayer)
this.faces.AddRange(newLayer.faces); this.faces.AddRange(newLayer.faces);
// fill faces between layers // fill faces between layers