Commented out the float array "normals" in the Mesh object and all references to save memory as it was unused

0.6.0-stable
Dahlia Trimble 2008-08-22 07:06:33 +00:00
parent d433567178
commit 261876fd47
3 changed files with 56 additions and 56 deletions

View File

@ -39,7 +39,7 @@ namespace OpenSim.Region.Physics.Meshing
public List<Triangle> triangles; public List<Triangle> triangles;
GCHandle pinnedVirtexes; GCHandle pinnedVirtexes;
GCHandle pinnedIndex; GCHandle pinnedIndex;
public float[] normals; //public float[] normals;
public Mesh() public Mesh()
{ {

View File

@ -1760,66 +1760,66 @@ namespace OpenSim.Region.Physics.Meshing
return result; return result;
} }
public static void CalcNormals(Mesh mesh) //public static void CalcNormals(Mesh mesh)
{ //{
int iTriangles = mesh.triangles.Count; // int iTriangles = mesh.triangles.Count;
mesh.normals = new float[iTriangles*3]; // mesh.normals = new float[iTriangles*3];
int i = 0; // int i = 0;
foreach (Triangle t in mesh.triangles) // foreach (Triangle t in mesh.triangles)
{ // {
float ux, uy, uz; // float ux, uy, uz;
float vx, vy, vz; // float vx, vy, vz;
float wx, wy, wz; // float wx, wy, wz;
ux = t.v1.X; // ux = t.v1.X;
uy = t.v1.Y; // uy = t.v1.Y;
uz = t.v1.Z; // uz = t.v1.Z;
vx = t.v2.X; // vx = t.v2.X;
vy = t.v2.Y; // vy = t.v2.Y;
vz = t.v2.Z; // vz = t.v2.Z;
wx = t.v3.X; // wx = t.v3.X;
wy = t.v3.Y; // wy = t.v3.Y;
wz = t.v3.Z; // wz = t.v3.Z;
// Vectors for edges // // Vectors for edges
float e1x, e1y, e1z; // float e1x, e1y, e1z;
float e2x, e2y, e2z; // float e2x, e2y, e2z;
e1x = ux - vx; // e1x = ux - vx;
e1y = uy - vy; // e1y = uy - vy;
e1z = uz - vz; // e1z = uz - vz;
e2x = ux - wx; // e2x = ux - wx;
e2y = uy - wy; // e2y = uy - wy;
e2z = uz - wz; // e2z = uz - wz;
// Cross product for normal // // Cross product for normal
float nx, ny, nz; // float nx, ny, nz;
nx = e1y*e2z - e1z*e2y; // nx = e1y*e2z - e1z*e2y;
ny = e1z*e2x - e1x*e2z; // ny = e1z*e2x - e1x*e2z;
nz = e1x*e2y - e1y*e2x; // nz = e1x*e2y - e1y*e2x;
// Length // // Length
float l = (float) Math.Sqrt(nx*nx + ny*ny + nz*nz); // float l = (float) Math.Sqrt(nx*nx + ny*ny + nz*nz);
// Normalized "normal" // // Normalized "normal"
nx /= l; // nx /= l;
ny /= l; // ny /= l;
nz /= l; // nz /= l;
mesh.normals[i] = nx; // //mesh.normals[i] = nx;
mesh.normals[i + 1] = ny; // //mesh.normals[i + 1] = ny;
mesh.normals[i + 2] = nz; // //mesh.normals[i + 2] = nz;
i += 3; // i += 3;
} // }
} //}
public static Vertex midUnitRadialPoint(Vertex a, Vertex b, float radius) public static Vertex midUnitRadialPoint(Vertex a, Vertex b, float radius)
{ {
@ -1878,21 +1878,21 @@ namespace OpenSim.Region.Physics.Meshing
SculptMesh smesh = CreateSculptMesh(primName, primShape, size, lod); SculptMesh smesh = CreateSculptMesh(primName, primShape, size, lod);
mesh = (Mesh)smesh; mesh = (Mesh)smesh;
CalcNormals(mesh); //CalcNormals(mesh);
} }
else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
{ {
if (primShape.PathCurve == (byte)Extrusion.Straight) if (primShape.PathCurve == (byte)Extrusion.Straight)
{ // its a box { // its a box
mesh = CreateBoxMesh(primName, primShape, size); mesh = CreateBoxMesh(primName, primShape, size);
CalcNormals(mesh); //CalcNormals(mesh);
} }
else if (primShape.PathCurve == (byte)Extrusion.Curve1) else if (primShape.PathCurve == (byte)Extrusion.Curve1)
{ // tube { // tube
// do a cylinder for now // do a cylinder for now
//mesh = CreateCylinderMesh(primName, primShape, size); //mesh = CreateCylinderMesh(primName, primShape, size);
mesh = CreateCircularPathMesh(primName, primShape, size); mesh = CreateCircularPathMesh(primName, primShape, size);
CalcNormals(mesh); //CalcNormals(mesh);
} }
} }
else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
@ -1900,14 +1900,14 @@ namespace OpenSim.Region.Physics.Meshing
if (primShape.PathCurve == (byte)Extrusion.Straight) if (primShape.PathCurve == (byte)Extrusion.Straight)
{ {
mesh = CreateCylinderMesh(primName, primShape, size); mesh = CreateCylinderMesh(primName, primShape, size);
CalcNormals(mesh); //CalcNormals(mesh);
} }
// ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
else if (primShape.PathCurve == (byte) Extrusion.Curve1) else if (primShape.PathCurve == (byte) Extrusion.Curve1)
{ // dahlia's favorite, a torus :) { // dahlia's favorite, a torus :)
mesh = CreateCircularPathMesh(primName, primShape, size); mesh = CreateCircularPathMesh(primName, primShape, size);
CalcNormals(mesh); //CalcNormals(mesh);
} }
} }
else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle) else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
@ -1916,7 +1916,7 @@ namespace OpenSim.Region.Physics.Meshing
{ {
//mesh = CreateSphereMesh(primName, primShape, size); //mesh = CreateSphereMesh(primName, primShape, size);
mesh = CreateCircularPathMesh(primName, primShape, size); mesh = CreateCircularPathMesh(primName, primShape, size);
CalcNormals(mesh); //CalcNormals(mesh);
} }
} }
else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
@ -1924,19 +1924,19 @@ namespace OpenSim.Region.Physics.Meshing
if (primShape.PathCurve == (byte)Extrusion.Straight) if (primShape.PathCurve == (byte)Extrusion.Straight)
{ {
mesh = CreatePrismMesh(primName, primShape, size); mesh = CreatePrismMesh(primName, primShape, size);
CalcNormals(mesh); //CalcNormals(mesh);
} }
else if (primShape.PathCurve == (byte) Extrusion.Curve1) else if (primShape.PathCurve == (byte) Extrusion.Curve1)
{ // a ring - do a cylinder for now { // a ring - do a cylinder for now
//mesh = CreateCylinderMesh(primName, primShape, size); //mesh = CreateCylinderMesh(primName, primShape, size);
mesh = CreateCircularPathMesh(primName, primShape, size); mesh = CreateCircularPathMesh(primName, primShape, size);
CalcNormals(mesh); //CalcNormals(mesh);
} }
} }
else // just do a box else // just do a box
{ {
mesh = CreateBoxMesh(primName, primShape, size); mesh = CreateBoxMesh(primName, primShape, size);
CalcNormals(mesh); //CalcNormals(mesh);
} }
if (mesh != null) if (mesh != null)

View File

@ -202,7 +202,7 @@ namespace OpenSim.Region.Physics.Meshing
{ {
this.triangles.Clear(); this.triangles.Clear();
this.vertices.Clear(); this.vertices.Clear();
normals = new float[0]; //normals = new float[0];
} }
public void processSculptTexture() public void processSculptTexture()