summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2014-03-07 14:55:15 -0800
committerHarvey Harrison <[email protected]>2014-03-07 14:55:15 -0800
commita5f67b5d4003732cf5fbbea7157220be46999939 (patch)
tree914d5161198c56a233a1812737b42f7db637c091 /src
parent56f0144d731a71870272c6a8e8089e7589088a16 (diff)
j3dutils: pass the facetNormals as an argument to calculations
Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/classes/share/com/sun/j3d/utils/geometry/NormalGenerator.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/geometry/NormalGenerator.java b/src/classes/share/com/sun/j3d/utils/geometry/NormalGenerator.java
index 9d675da..5168a89 100644
--- a/src/classes/share/com/sun/j3d/utils/geometry/NormalGenerator.java
+++ b/src/classes/share/com/sun/j3d/utils/geometry/NormalGenerator.java
@@ -68,7 +68,6 @@ import javax.vecmath.Vector3f;
public class NormalGenerator {
private double creaseAngle;
- private Vector3f facetNorms[];
private ArrayList<ArrayList<Integer>> tally;
private int coordInds[];
private int normalInds[];
@@ -95,10 +94,10 @@ public class NormalGenerator {
// Calculate the normal of each triangle in the list by finding
// the cross product
- private void calculatefacetNorms(GeometryInfo gi)
+ private Vector3f[] calculatefacetNorms(GeometryInfo gi)
{
Point3f coordinates[] = gi.getCoordinates();
- facetNorms = new Vector3f[coordInds.length / 3];
+ Vector3f[] facetNorms = new Vector3f[coordInds.length / 3];
Vector3f a = new Vector3f();
Vector3f b = new Vector3f();
if ((DEBUG & 1) != 0) System.out.println("Facet normals:");
@@ -145,6 +144,7 @@ public class NormalGenerator {
}
}
}
+ return facetNorms;
} // End of calculatefacetNorms
@@ -169,7 +169,7 @@ public class NormalGenerator {
//
// Returns the largest number of triangles that share a single normal.
//
- private int createHardEdges()
+ private int createHardEdges(Vector3f[] facetNorms)
{
EdgeTable et = new EdgeTable(coordInds);
tally = new ArrayList<ArrayList<Integer>>();
@@ -333,7 +333,7 @@ public class NormalGenerator {
// indexed, table. That way, to tell if two triangles have the
// same normal, we just need to compare indexes. This would speed up
// the process of checking for duplicates.
- private void calculateVertexNormals(GeometryInfo gi, int maxShare)
+ private void calculateVertexNormals(GeometryInfo gi, Vector3f[] facetNorms, int maxShare)
{
Vector3f normals[];
ArrayList<Integer> sharers;
@@ -806,21 +806,21 @@ public class NormalGenerator {
time = System.currentTimeMillis();
}
- calculatefacetNorms(gi);
+ Vector3f[] facetNorms = calculatefacetNorms(gi);
if ((DEBUG & 16) != 0) {
t2 += System.currentTimeMillis() - time;
System.out.println("Calculate Facet Normals: " + t2 + " ms");
time = System.currentTimeMillis();
}
- int maxShare = createHardEdges();
+ int maxShare = createHardEdges(facetNorms);
if ((DEBUG & 16) != 0) {
t3 += System.currentTimeMillis() - time;
System.out.println("Hard Edges: " + t3 + " ms");
time = System.currentTimeMillis();
}
- calculateVertexNormals(gi, maxShare);
+ calculateVertexNormals(gi, facetNorms, maxShare);
if ((DEBUG & 16) != 0) {
t5 += System.currentTimeMillis() - time;
System.out.println("Vertex Normals: " + t5 + " ms");