From: <ma...@us...> - 2003-07-18 08:40:30
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1:/tmp/cvs-serv1247/src/org/jrman/render Modified Files: SimpleMicropolygon.java SamplePoint.java Sample.java Log Message: Another small optimization. Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SimpleMicropolygon.java 10 Jul 2003 17:01:39 -0000 1.6 --- SimpleMicropolygon.java 18 Jul 2003 08:40:24 -0000 1.7 *************** *** 81,85 **** private float minZ = Constants.INFINITY; ! public void write(DataOutputStream dos) throws IOException { dos.writeFloat(ax); --- 81,85 ---- private float minZ = Constants.INFINITY; ! public void write(DataOutputStream dos) throws IOException { dos.writeFloat(ax); *************** *** 105,111 **** dos.writeFloat(minZ); } ! public void read(DataInputStream dis) throws IOException { ! ax =dis.readFloat(); ay = dis.readFloat(); az = dis.readFloat(); --- 105,111 ---- dos.writeFloat(minZ); } ! public void read(DataInputStream dis) throws IOException { ! ax = dis.readFloat(); ay = dis.readFloat(); az = dis.readFloat(); *************** *** 194,206 **** Calc.clamp((int) (mpMinY / sampler.getSampleHeight()), 0, sampler.getHeight() - 1); int maxColumn = ! Calc.clamp( ! (int) (mpMaxX / sampler.getSampleWidth()), ! 0, ! sampler.getWidth() - 1); int maxRow = ! Calc.clamp( ! (int) (mpMaxY / sampler.getSampleHeight()), ! 0, ! sampler.getHeight() - 1); for (int row = minRow; row <= maxRow; row++) { for (int col = minColumn; col <= maxColumn; col++) { --- 194,200 ---- Calc.clamp((int) (mpMinY / sampler.getSampleHeight()), 0, sampler.getHeight() - 1); int maxColumn = ! Calc.clamp((int) (mpMaxX / sampler.getSampleWidth()), 0, sampler.getWidth() - 1); int maxRow = ! Calc.clamp((int) (mpMaxY / sampler.getSampleHeight()), 0, sampler.getHeight() - 1); for (int row = minRow; row <= maxRow; row++) { for (int col = minColumn; col <= maxColumn; col++) { *************** *** 228,239 **** float z = (nx * (ax - point.x) + ny * (ay - point.y)) * oneOverNz + az; sp.addSample( ! new Sample( ! colorRed, ! colorGreen, ! colorBlue, ! opacityRed, ! opacityGreen, ! opacityBlue, ! z)); return true; } --- 222,232 ---- float z = (nx * (ax - point.x) + ny * (ay - point.y)) * oneOverNz + az; sp.addSample( ! colorRed, ! colorGreen, ! colorBlue, ! opacityRed, ! opacityGreen, ! opacityBlue, ! z); return true; } Index: SamplePoint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SamplePoint.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SamplePoint.java 15 May 2003 03:15:31 -0000 1.11 --- SamplePoint.java 18 Jul 2003 08:40:24 -0000 1.12 *************** *** 61,69 **** } ! public void addSample(Sample sample) { int i = 0; while (i < samples.size()) { Sample s = (Sample) samples.get(i++); ! if (s.behind(sample)) { samples.add(--i, sample); if (sample.isOpaque()) --- 61,85 ---- } ! public void addSample( ! float colorRed, ! float colorGreen, ! float colorBlue, ! float opacityRed, ! float opacityGreen, ! float opacityBlue, ! float z) { int i = 0; while (i < samples.size()) { Sample s = (Sample) samples.get(i++); ! if (s.behind(z)) { ! Sample sample = ! new Sample( ! colorRed, ! colorGreen, ! colorBlue, ! opacityRed, ! opacityGreen, ! opacityBlue, ! z); samples.add(--i, sample); if (sample.isOpaque()) *************** *** 73,76 **** --- 89,101 ---- return; } + Sample sample = + new Sample( + colorRed, + colorGreen, + colorBlue, + opacityRed, + opacityGreen, + opacityBlue, + z); samples.add(sample); if (sample.isOpaque()) Index: Sample.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sample.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Sample.java 9 May 2003 00:05:13 -0000 1.3 --- Sample.java 18 Jul 2003 08:40:24 -0000 1.4 *************** *** 53,56 **** --- 53,60 ---- } + public boolean behind(float otherZ) { + return z > otherZ; + } + public boolean isOpaque() { return opacityRed== 1f && opacityGreen == 1f && opacityBlue == 1f; |