You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(116) |
May
(220) |
Jun
(52) |
Jul
(30) |
Aug
(35) |
Sep
(24) |
Oct
(49) |
Nov
(44) |
Dec
(70) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(21) |
Feb
(30) |
Mar
(9) |
Apr
(44) |
May
(2) |
Jun
|
Jul
(10) |
Aug
(20) |
Sep
(25) |
Oct
(12) |
Nov
(16) |
Dec
(4) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(25) |
Aug
|
Sep
|
Oct
|
Nov
(26) |
Dec
(10) |
2006 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(33) |
2007 |
Jan
(4) |
Feb
(57) |
Mar
(17) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Elmer G. <ega...@us...> - 2005-11-07 01:04:59
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29812/src/org/jrman/primitive Modified Files: Nurbs.java Added Files: NurbsRI.java Log Message: Working NURBS!!! --- NEW FILE: NurbsRI.java --- /* Nurbs.java Copyright (C) 2004-2005 Gerardo Horvilleur Martinez, Elmer Garduno Hernandez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.primitive; import javax.vecmath.Point3f; import javax.vecmath.Point4f; import javax.vecmath.Tuple3f; import javax.vecmath.Tuple4f; import javax.vecmath.Vector3f; import java.util.Arrays; import org.jrman.util.Calc; import org.jrman.geom.BoundingVolume; import org.jrman.geom.ConvexHull3f; import org.jrman.attributes.Attributes; import org.jrman.parameters.Declaration; import org.jrman.parameters.ParameterList; import org.jrman.parameters.VaryingScalarHPoint; import org.jrman.parameters.VaryingScalarTuple3f; import org.jrman.grid.Grid; import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; import org.jrman.render.ShaderVariables; public class NurbsRI extends Primitive { private final int upc; private final int uorder; private final float[] uknot; private final float umin; private final float umax; private final int vpc; private final int vorder; private final float[] vknot; private final float vmin; private final float vmax; private final boolean dirflag; private final Point4f[][] points; private final static Declaration DECL_PW = new Declaration("Pw", Declaration.StorageClass.VERTEX, Declaration.Type.HPOINT, 1); public NurbsRI(int upc, int uorder, float[] uknot, float umin, float umax, int vpc, int vorder, float[] vknot, float vmin, float vmax, boolean dirflag, ParameterList parameters, Attributes attributes) { super(parameters, attributes); this.upc = upc; this.uorder = uorder; this.uknot = uknot; this.umin = umin; this.umax = umax; this.vpc = vpc; this.vorder = vorder; this.vknot = vknot; this.vmin = vmin; this.vmax = vmax; this.dirflag = dirflag; this.points = extractPoints(parameters); } private Point4f[][] extractPoints(ParameterList parameters) { VaryingScalarTuple3f param3f = (VaryingScalarTuple3f) parameters.getParameter("P"); if (param3f != null) { parameters.removeParameter("P"); parameters.addParameter(new VaryingScalarHPoint (new Declaration("Pw", "vertex hpoint"), param3f)); } VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); //parameters.removeParameter("Pw"); Point4f[][] points = new Point4f[vpc][upc]; for (int i = 0; i < vpc; i++) { for (int j = 0; j < upc; j++) { Point4f p = new Point4f(); paramHp.getValue((i * upc) + j, p); points[i][j] = p; } } return points; } public BoundingVolume getBoundingVolume() { ConvexHull3f ch = new ConvexHull3f(); for (int i = 0; i < vpc; i++) { for (int j = 0; j < upc; j++) { ch.addHpoint(points[i][j]); } } return ch; } public String toString() { return print(points, vpc) + print(uknot) + print(vknot); } private String print(Point4f[][] points, int vpc) { StringBuffer sb = new StringBuffer(); sb.append("["); for (int i = 0; i < vpc; i++) { sb.append(Arrays.asList(points[i])); sb.append(" "); } sb.append("]"); return sb.toString(); } private String print(float[] a) { StringBuffer sb = new StringBuffer(); sb.append("["); for (int i = 0; i < a.length; i++) { sb.append(a[i]); sb.append(" "); } sb.append("]"); return sb.toString(); } public Primitive[] split() { NurbsRI[] result = new NurbsRI[2]; float[] knot = dirflag ? uknot : vknot; int order = dirflag ? uorder : vorder; SplitArgs sa = getKnotVector(knot); Point4f[][] npoints = dirflag ? getPointsU(sa.kv, uorder, knot, points) : getPointsV(sa.kv, vorder, knot, points) ; float[] kv0 = new float[sa.pos + order]; System.arraycopy(sa.kv, 0, kv0, 0, kv0.length); float[] kv1 = new float[sa.kv.length - sa.pos]; System.arraycopy(sa.kv, sa.pos, kv1, 0, kv1.length); if (dirflag) { float mid = (umax + umin) /2; int p0c = kv0.length - uorder; Point4f[][] points0 = new Point4f[vpc][p0c]; for (int i = 0; i < vpc; i++) { for (int j = 0; j < p0c; j++) { points0[i][j] = npoints[i][j]; } } result[0] = new NurbsRI(p0c, uorder, kv0, umin, umax, vpc, vorder, vknot, vmin, vmax, !dirflag, nuInterpolateParameters (umin, mid, vmin, vmax, points0), attributes); int p1c = kv1.length - uorder; Point4f[][] points1 = new Point4f[vpc][p1c]; for (int i = 0; i < vpc; i++) { for (int j = 0; j < p1c; j++) { points1[i][j] = npoints[i][j + p0c]; } } result[1] = new NurbsRI(p1c, uorder, kv1, umin, umax, vpc, vorder, vknot, vmin, vmax, !dirflag, nuInterpolateParameters (mid, umax, vmin, vmax, points1), attributes); } else { float mid = (vmax + vmin) /2; int p0c = kv0.length - vorder; Point4f[][] points0 = new Point4f[p0c][upc]; for (int i = 0; i < upc; i++) { for (int j = 0; j < p0c; j++) { points0[j][i] = npoints[j][i]; } } result[0] = new NurbsRI(upc, uorder, uknot, umin, umax, p0c, vorder, kv0, vmin, vmax, !dirflag, nuInterpolateParameters (umin, umax, vmin, mid, points0), attributes); int p1c = kv1.length - vorder; Point4f[][] points1 = new Point4f[p1c][upc]; for (int i = 0; i < upc; i++) { for (int j = 0; j < p1c; j++) { points1[j][i] = npoints[j + p0c][i]; } } result[1] = new NurbsRI(upc, uorder, uknot, umin, umax, p1c, vorder, kv1, vmin, vmax, !dirflag, nuInterpolateParameters (umin, umax, mid, vmax, points1), attributes); } //System.out.println(this); //System.out.println(result[0]); //System.out.println(result[1]); result[0].setObjectToCamera(objectToCamera); result[1].setObjectToCamera(objectToCamera); return result; } private ParameterList nuInterpolateParameters(float umin, float umax, float vmin, float vmax, Point4f[][] points) { VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); ParameterList result = linearInterpolateParameters(umin, umax, vmin, vmax); int vpc = points.length; int upc = points[0].length; VaryingScalarHPoint sparam = new VaryingScalarHPoint(DECL_PW, new float[vpc * upc * 4]); for (int i = 0; i < vpc; i++) { for (int j = 0; j < upc; j++) { sparam.setValue((i * upc) + j, points[i][j]); } } result.addParameter(sparam); return result; } private SplitArgs getKnotVector(float[] v) { float mid = (v[v.length - 1] + v[0]) / 2; int count = 0; int pos = 0; for (int i =0; i < v.length; i++) { if (v[i] == mid) { count ++; } else if (v[i] > mid){ pos = i; break; } } int add = uorder - count; float[] kv = new float[v.length + add]; for(int i = 0; i < pos; i++) { kv[i] = v[i]; } for(int i = 0; i < add; i++) { kv[i + pos] = mid; } for(int i = 0; i < v.length - pos; i++) { kv[i + pos + add] = v[i + pos]; } return new SplitArgs(kv, pos - count); } private final static class SplitArgs { final float[] kv; final int pos; public SplitArgs(float[] kv, int pos) { this.kv = kv; this.pos = pos; } } private Point4f[][] getPointsU(float[] nv, int k, float[] v, Point4f[][] points) { Point4f[][] result = new Point4f[vpc][nv.length - k]; for (int pos = 0; pos < vpc; pos++) { for (int j = 0; j < nv.length - k; j++) { Point4f point = new Point4f(); for (int i = 0; i < v.length - k; i++) { float alpha = getAlpha(nv, k, i, j, v); point.x += alpha * points[pos][i].x; point.y += alpha * points[pos][i].y; point.z += alpha * points[pos][i].z; point.w += alpha * points[pos][i].w; } result[pos][j] = point; } } return result; } private Point4f[][] getPointsV(float[] nv, int k, float[] v, Point4f[][] points) { Point4f[][] result = new Point4f[nv.length - k][upc]; for (int pos = 0; pos < upc; pos++) { for (int j = 0; j < nv.length - k; j++) { Point4f point = new Point4f(); for (int i = 0; i < v.length - k; i++) { float alpha = getAlpha(nv, k, i, j, v); point.x += alpha * points[i][pos].x; point.y += alpha * points[i][pos].y; point.z += alpha * points[i][pos].z; point.w += alpha * points[i][pos].w; } result[j][pos] = point; } } return result; } private float getAlpha(float[] nv, int k, int i, int j, float[] v) { if (k == 1) { return (nv[j] >= v[i] && nv[j] < v[i + 1]) ? 1 : 0; } else { float aa = ratio(nv[j + k - 1] - v[i], v[i + k -1] - v[i]) * getAlpha(nv, k - 1, i, j, v) + ratio(v[i + k] - nv[j + k - 1], v[i + k] - v[i + 1]) * getAlpha(nv, k - 1, i + 1, j, v); return aa; } } protected void dice_P(ShaderVariables sv) { Point3fGrid P = sv.P; Vector3fGrid Ng = sv.Ng; int uSize = Grid.getUSize(); int vSize = Grid.getVSize(); for (int v = 0; v < vSize; v++) { float vPos = (v / (float) (vSize - 1)) * (vknot[vpc] - vknot[vorder - 1]) + vknot[vorder - 1]; float fu = 0f; for (int u = 0; u < uSize; u++) { float uPos = ( u /(float) (uSize - 1)) * (uknot[upc] - uknot[uorder - 1]) + uknot[uorder - 1]; Point3f p = new Point3f(); Vector3f utan = new Vector3f(); Vector3f vtan = new Vector3f(); eval(uPos, vPos, p, utan, vtan); P.set(u, v, p); Vector3f n = new Vector3f(); n.cross(utan, vtan); float d = n.length(); if (d != 0.0) { n.x /= d; n.y /= d; n.z /= d; } else { n.x = 0; n.y = 0; n.z = 0; } Ng.set(u, v, n); } } } /* * Compute Bi,k(u), for i = 0..k. * u is the parameter of the spline to find the basis * functions for * brkPoint is the start of the knot interval ("segment") * kv is the knot vector * k is the order of the curve * bvals is the array of returned basis values. * * (From Bartels, Beatty & Barsky, p.387) */ private float[] basisFunctions(float u, int brkPoint, float[] kv, int k, int order) { float[] bvals = new float[order]; bvals[0] = 1.0f; for (int r = 2; r <= k; r++) { int i = brkPoint - r + 1; bvals[r - 1] = 0.0f; for (int s = r - 2; s >= 0; s--) { i++; float omega; if (i < 0) omega = 0; else omega = (u - kv[i]) / (kv[i + r - 1] - kv[i]); bvals[s + 1] = bvals[s + 1] + (1 - omega) * bvals[s]; bvals[s] = omega * bvals[s]; } } return bvals; } /* * Compute derivatives of the basis functions Bi,k(u)' */ private float[] basisDerivatives(float u, int brkPoint, float[] kv, int k) { float[] dvals = basisFunctions(u, brkPoint, kv, k - 1, k); dvals[k - 1] = 0.0F; // BasisFunctions misses this float knotScale = kv[brkPoint + 1] - kv[brkPoint]; int i = brkPoint - k + 1; for (int s = k - 2; s >= 0; s--) { i++; int ik1 = Calc.clamp(i + k - 1, 0, kv.length); int ic = Calc.clamp(i, 0, kv.length); float omega = knotScale * (k - 1.0F) / (kv[ik1] - kv[ic]); dvals[s + 1] += -omega * dvals[s]; dvals[s] *= omega; } return dvals; } /* * Return the current knot the parameter u is less than or equal to. Find * this "breakpoint" allows the evaluation routines to concentrate on only * those control points actually effecting the curve around u.] * * m is the number of points on the curve (or surface direction) k is the * order of the curve (or surface direction) kv is the knot vector * ([0..m+k-1]) to find the break point in. */ private int findBreakPoint(float u, float[] kv, int m, int k) { if (u == kv[m + 1]) /* Special case for closed interval */ return m; int i = m + k; while ((u < kv[i]) && (i > 0)) i--; return i; } private void eval(float u, float v, Point3f p, Vector3f utan, Vector3f vtan) { int ubrkPoint = findBreakPoint(u, uknot, upc - 1, uorder); int ufirst = ubrkPoint - uorder + 1; float[] bu = basisFunctions(u, ubrkPoint, uknot, uorder, uorder); float[] buprime = basisDerivatives(u, ubrkPoint, uknot, uorder); int vbrkPoint = findBreakPoint(v, vknot, vpc - 1, vorder); int vfirst = vbrkPoint - vorder + 1; float[] bv = basisFunctions(v, vbrkPoint, vknot, vorder, vorder); float[] bvprime = basisDerivatives(v, vbrkPoint, vknot, vorder); Point4f rutan = new Point4f(); Point4f rvtan = new Point4f(); Point4f result = new Point4f(); for (int i = 0; i < vorder; i++) { for (int j = 0; j < uorder; j++) { int ri = vorder - 1 - i; int rj = uorder - 1 - j; float tmp = bu[rj] * bv[ri]; int ivfirst = Calc.clamp(i + vfirst, 0, points.length); int jufirst = Calc.clamp(j + ufirst, 0, points[0].length); Point4f cp = points[ivfirst][jufirst]; result.x += cp.x * tmp; result.y += cp.y * tmp; result.z += cp.z * tmp; result.w += cp.w * tmp; tmp = buprime[rj] * bv[ri]; rutan.x += cp.x * tmp; rutan.y += cp.y * tmp; rutan.z += cp.z * tmp; rutan.w += cp.w * tmp; tmp = bu[rj] * bvprime[ri]; rvtan.x += cp.x * tmp; rvtan.y += cp.y * tmp; rvtan.z += cp.z * tmp; rvtan.w += cp.w * tmp; } } float wsqrdiv = 1.0f / (result.w * result.w); utan.x = (result.w * rutan.x - rutan.w * result.x) * wsqrdiv; utan.y = (result.w * rutan.y - rutan.w * result.y) * wsqrdiv; utan.z = (result.w * rutan.z - rutan.w * result.z) * wsqrdiv; vtan.x = (result.w * rvtan.x - rvtan.w * result.x) * wsqrdiv; vtan.y = (result.w * rvtan.y - rvtan.w * result.y) * wsqrdiv; vtan.z = (result.w * rvtan.z - rvtan.w * result.z) * wsqrdiv; p.x = result.x / result.w; p.y = result.y / result.w; p.z = result.z / result.w; } private static float ratio(float a, float b) { return b != 0f ? a / b : 0f; } } Index: Nurbs.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Nurbs.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Nurbs.java 3 Jul 2005 04:37:36 -0000 1.12 --- Nurbs.java 7 Nov 2005 01:04:47 -0000 1.13 *************** *** 25,28 **** --- 25,29 ---- import javax.vecmath.Tuple4f; import javax.vecmath.Vector3f; + import java.util.Arrays; import org.jrman.attributes.Attributes; *************** *** 67,74 **** private boolean dirflag = true; - - private float[] newkv; - - private int splitPt; /* Control points, indexed as points[0..numV-1][0..numU-1] */ --- 68,71 ---- *************** *** 103,130 **** private static Point4f rvtan = new Point4f(); public Nurbs(int nu, int uorder, float[] uknot, float umin, float umax, ! int nv, int vorder, float[] vknot, float vmin, float vmax, boolean dirflag, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); this.nu = nu; ! this.uorder = uorder; ! this.uknot = uknot; this.umin = umin; this.umax = umax; this.nv = nv; this.vorder = vorder; ! this.vknot = vknot; this.vmin = vmin; this.vmax = vmax; this.dirflag = !dirflag; extractPoints(parameters); ! } ! public Nurbs(int nu, int uorder, float[] uknot, float umin, float umax, ! int nv, int vorder, float[] vknot, float vmin, float vmax, ! ParameterList parameters, Attributes attributes) { ! this(nu, uorder, uknot, umin, umax, nv, vorder, vknot, vmin, vmax, ! true, parameters, attributes); } --- 100,139 ---- private static Point4f rvtan = new Point4f(); + private String asList(float[] f) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < f.length; i++) { + sb.append(f[i]); + sb.append(' '); + } + return sb.toString(); + } + public Nurbs(int nu, int uorder, float[] uknot, float umin, float umax, ! int nv, int vorder, float[] vknot, float vmin, float vmax, ! boolean dirflag, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); this.nu = nu; ! this.uorder = uorder; ! this.uknot = new float[nu + uorder]; ! System.arraycopy(uknot, 0, this.uknot, 0, nu + uorder); this.umin = umin; this.umax = umax; this.nv = nv; this.vorder = vorder; ! this.vknot = new float[nv + vorder]; ! System.arraycopy(vknot, 0, this.vknot, 0, nv + vorder); this.vmin = vmin; this.vmax = vmax; this.dirflag = !dirflag; extractPoints(parameters); ! } public Nurbs(int nu, int uorder, float[] uknot, float umin, float umax, ! int nv, int vorder, float[] vknot, float vmin, float vmax, ! ParameterList parameters, Attributes attributes) { ! this(nu, uorder, uknot, umin, umax, nv, vorder, ! vknot, vmin, vmax, ! true, parameters, attributes); } *************** *** 144,149 **** if (param3f != null) { parameters.removeParameter("P"); ! parameters.addParameter( ! new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), param3f)); } VaryingScalarHPoint paramHp = --- 153,159 ---- if (param3f != null) { parameters.removeParameter("P"); ! parameters.addParameter(new VaryingScalarHPoint ! (new Declaration("Pw", "vertex hpoint"), ! param3f)); } VaryingScalarHPoint paramHp = *************** *** 181,185 **** public void copy(Nurbs parent) { - nu = parent.nu; nv = parent.nv; --- 191,194 ---- *************** *** 190,194 **** uknot = new float[nu + uorder]; vknot = new float[nv + vorder]; ! points = new Point4f[nv][nu]; for (int i = 0; i < nv; i++) { --- 199,203 ---- uknot = new float[nu + uorder]; vknot = new float[nv + vorder]; ! points = new Point4f[nv][nu]; for (int i = 0; i < nv; i++) { *************** *** 208,212 **** //cn0 = new SurfSample(parent.cn0); //cnn = new SurfSample(parent.cnn); - } --- 217,220 ---- *************** *** 233,237 **** private void getNormal(int indV, int indU) { Vector3f tmpL = new Vector3f(); ! Vector3f tmpR = new Vector3f(); /* "Left" and "Right" of the base point */ SurfSample crnr; --- 241,246 ---- private void getNormal(int indV, int indU) { Vector3f tmpL = new Vector3f(); ! Vector3f tmpR = new Vector3f(); ! /* "Left" and "Right" of the base point */ SurfSample crnr; *************** *** 272,277 **** samp.normal.scale(samp.normLen); } ! ! /* * Split a surface into two halves. First inserts multiplicity k knots in --- 281,285 ---- samp.normal.scale(samp.normLen); } ! /* * Split a surface into two halves. First inserts multiplicity k knots in *************** *** 293,310 **** */ ! Nurbs tmp = new Nurbs(this); ! if (dirflag) { ! tmp.nu = nu ! + splitKV(uknot, (nu - 1), uorder); ! tmp.uknot = newkv; ! for (int i = 0; i < nv + tmp.vorder; i++) ! tmp.vknot[i] = vknot[i]; } else { ! tmp.nv = nv ! + splitKV(vknot, (nv - 1), vorder); ! tmp.vknot = newkv; ! for (int i = 0; i < tmp.nu + tmp.uorder; i++) ! tmp.uknot[i] = uknot[i]; } tmp.updatePointsSize(); --- 301,310 ---- */ ! Nurbs tmp = new Nurbs(this); ! int splitPt; if (dirflag) { ! splitPt = tmp.splitKv(this, dirflag); } else { ! splitPt = tmp.splitKv(this, dirflag); } tmp.updatePointsSize(); *************** *** 319,351 **** kid0.copy(this); /* copy various edge flags and orders */ ! kid0.nu = dirflag ? splitPt + 1 : nu; ! kid0.nv = dirflag ? nv : splitPt + 1; ! for (int i = 0; i < kid0.nv; i++) ! /* Copy the point and kv data */ ! for (int j = 0; j < kid0.nu; j++) kid0.points[i][j] = tmp.points[i][j]; ! for (int i = 0; i < kid0.uorder + kid0.nu; i++) kid0.uknot[i] = tmp.uknot[i]; ! for (int i = 0; i < kid0.vorder + kid0.nv; i++) kid0.vknot[i] = tmp.vknot[i]; /* Second half */ splitPt++; kid1.copy(this); ! kid1.nu = dirflag ? tmp.nu - splitPt : nu; kid1.nv = dirflag ? nv : tmp.nv - splitPt; ! ! for (int i = 0; i < kid1.nv; i++) /* Copy the point and kv data */ ! for (int j = 0; j < kid1.nu; j++) kid1.points[i][j] = tmp.points[dirflag ? i : (i + splitPt)] ! [dirflag ? (j + splitPt) : j]; ! for (int i = 0; i < kid1.uorder + kid1.nu; i++) kid1.uknot[i] = tmp.uknot[dirflag ? (i + splitPt) : i]; ! for (int i = 0; i < kid1.vorder + kid1.nv; i++) kid1.vknot[i] = tmp.vknot[dirflag ? i : (i + splitPt)]; /* Construct new corners on the boundry between the two kids */ --- 319,363 ---- kid0.copy(this); /* copy various edge flags and orders */ ! kid0.nu = dirflag ? splitPt + 1 : nu; ! kid0.nv = dirflag ? nv : splitPt + 1; ! kid0.updatePointsSize(); ! ! /* Copy the point and kv data */ ! ! for (int i = 0; i < kid0.nv; i++) { ! for (int j = 0; j < kid0.nu; j++) { kid0.points[i][j] = tmp.points[i][j]; ! } ! } ! for (int i = 0; i < kid0.uorder + kid0.nu; i++) { kid0.uknot[i] = tmp.uknot[i]; ! } ! for (int i = 0; i < kid0.vorder + kid0.nv; i++) { kid0.vknot[i] = tmp.vknot[i]; + } /* Second half */ splitPt++; kid1.copy(this); ! kid1.nu = dirflag ? tmp.nu - splitPt : nu; kid1.nv = dirflag ? nv : tmp.nv - splitPt; ! kid1.updatePointsSize(); ! ! for (int i = 0; i < kid1.nv; i++) { /* Copy the point and kv data */ ! for (int j = 0; j < kid1.nu; j++) { kid1.points[i][j] = tmp.points[dirflag ? i : (i + splitPt)] ! [dirflag ? (j + splitPt) : j]; ! } ! } ! for (int i = 0; i < kid1.uorder + kid1.nu; i++) { kid1.uknot[i] = tmp.uknot[dirflag ? (i + splitPt) : i]; ! } ! for (int i = 0; i < kid1.vorder + kid1.nv; i++) { kid1.vknot[i] = tmp.vknot[dirflag ? i : (i + splitPt)]; + } /* Construct new corners on the boundry between the two kids */ *************** *** 358,362 **** */ private void makeNewCorners(Nurbs kid0, Nurbs kid1, ! boolean dirflag) { divW(kid0.points[(kid0.nv - 1)][(kid0.nu - 1)], kid0.cnn.point); getNormal((kid0.nv - 1), (kid0.nu - 1)); --- 370,374 ---- */ private void makeNewCorners(Nurbs kid0, Nurbs kid1, ! boolean dirflag) { divW(kid0.points[(kid0.nv - 1)][(kid0.nu - 1)], kid0.cnn.point); getNormal((kid0.nv - 1), (kid0.nu - 1)); *************** *** 401,408 **** if (strU0) projectToLine(c00.point, cn0.point, ! kid0.cn0.point); if (strUn) projectToLine(c0n.point, cnn.point, ! kid0.cnn.point); kid1.c00.point = kid0.cn0.point; --- 413,420 ---- if (strU0) projectToLine(c00.point, cn0.point, ! kid0.cn0.point); if (strUn) projectToLine(c0n.point, cnn.point, ! kid0.cnn.point); kid1.c00.point = kid0.cn0.point; *************** *** 439,450 **** * Bezier curve). */ ! private int splitKV(float[] srckv, int m, int k) { ! int extra = 0; ! int last = (m + k); int middex = last / 2; float midVal = srckv[middex]; ! /* Search forward and backward to see if multiple knot is already there */ int i = middex + 1; --- 451,476 ---- * Bezier curve). */ ! private int splitKv(Nurbs src, boolean dirflag) { ! float[] srckv; ! int m; ! int k; ! ! if (dirflag) { ! srckv = src.uknot; ! m = nu - 1; ! k = uorder; ! } else { ! srckv = src.vknot; ! m = nv - 1; ! k = vorder; ! } ! ! int last = m + k; int middex = last / 2; float midVal = srckv[middex]; ! /* Search forward and backward to see if multiple ! knot is already there */ int i = middex + 1; *************** *** 464,468 **** if (i <= 0) /* No knot in middle, must create it */ { ! midVal = (srckv[0] + srckv[last]) / 2.0F; middex = last / 2; while (srckv[middex + 1] < midVal) --- 490,494 ---- if (i <= 0) /* No knot in middle, must create it */ { ! midVal = (srckv[0] + srckv[last]) / 2.0f; middex = last / 2; while (srckv[middex + 1] < midVal) *************** *** 471,495 **** } ! extra = k - same; ! newkv = new float[m + k + extra + 1]; ! if (same < k) /* Must add knots */ ! { ! for (i = 0; i <= middex; i++) newkv[i] = srckv[i]; ! for (i = middex + 1; i <= middex + extra; i++) newkv[i] = midVal; ! for (i = middex + k - same + 1; i <= m + k + extra; i++) newkv[i] = srckv[i - extra]; } else { for (i = 0; i <= m + k; i++) newkv[i] = srckv[i]; } ! ! splitPt = (extra < k) ? middex - 1 : middex; ! return extra; } --- 497,532 ---- } ! int extra = k - same; ! float[] newkv = new float[m + k + extra + 1]; ! if (same < k) { /* Must add knots */ ! for (i = 0; i <= middex; i++) { newkv[i] = srckv[i]; + } ! for (i = middex + 1; i <= middex + extra; i++) { newkv[i] = midVal; + } ! for (i = middex + k - same + 1; i <= m + k + extra; i++) { newkv[i] = srckv[i - extra]; + } } else { for (i = 0; i <= m + k; i++) newkv[i] = srckv[i]; } ! ! if (dirflag) { ! nu = src.nu + extra; ! uknot = newkv; ! System.arraycopy(src.vknot, 0, vknot, 0, nv + vorder); ! } else { ! nv = src.nv + extra; ! vknot = newkv; ! System.arraycopy(src.uknot, 0, uknot, 0, nu + uorder); ! } ! ! return (extra < k) ? middex - 1 : middex; } *************** *** 524,532 **** int j = (i + 1) % 3; norm.x += (V[i].point.y - V[j].point.y) ! * (V[i].point.z + V[j].point.z); norm.y += (V[i].point.z - V[j].point.z) ! * (V[i].point.x + V[j].point.x); norm.z += (V[i].point.x - V[j].point.x) ! * (V[i].point.y + V[j].point.y); } float dist = norm.length(); --- 561,569 ---- int j = (i + 1) % 3; norm.x += (V[i].point.y - V[j].point.y) ! * (V[i].point.z + V[j].point.z); norm.y += (V[i].point.z - V[j].point.z) ! * (V[i].point.x + V[j].point.x); norm.z += (V[i].point.x - V[j].point.x) ! * (V[i].point.y + V[j].point.y); } float dist = norm.length(); *************** *** 540,545 **** V[i].normLen = dist; } ! } else /* Replace a sick normal with a healthy one nearby */ ! { for (int i = 0; i < 3; i++) if ((i != ok) && (V[i].normLen == 0.0)) --- 577,582 ---- V[i].normLen = dist; } ! } else { ! /* Replace a sick normal with a healthy one nearby */ for (int i = 0; i < 3; i++) if ((i != ok) && (V[i].normLen == 0.0)) *************** *** 556,564 **** * This is from Bartels, Beatty & Barsky, p. 407 */ ! private float[][] calcAlpha(float[] ukv, float[] wkv, int m, int n, int k) { ! float[] aval = new float[k]; float[][] alpha = new float[k + 1][m + n + 1]; for (int j = 0; j <= m + n; j++) { ! int brkPoint = findBreakPoint(wkv[j], ukv, m, k); aval[0] = 1.0F; for (int r = 2; r <= k; r++) { --- 593,602 ---- * This is from Bartels, Beatty & Barsky, p. 407 */ ! private float[][] calcAlpha(float[] orig, float[] dest, ! int m, int n, int k) { float[][] alpha = new float[k + 1][m + n + 1]; for (int j = 0; j <= m + n; j++) { ! int brkPoint = findBreakPoint(dest[j], orig, m, k); ! float[] aval = new float[k]; aval[0] = 1.0F; for (int r = 2; r <= k; r++) { *************** *** 567,579 **** int i = brkPoint - last; if (last < rm1) ! aval[last] = aval[last] * (wkv[j + r - 1] - ukv[i]) ! / (ukv[i + r - 1] - ukv[i]); else aval[last] = 0.0F; ! for (int s = last - 1; s >= 0; s--) { i++; ! float omega = (wkv[j + r - 1] - ukv[i]) ! / (ukv[i + r - 1] - ukv[i]); aval[s + 1] = aval[s + 1] + (1 - omega) * aval[s]; aval[s] = omega * aval[s]; --- 605,628 ---- int i = brkPoint - last; if (last < rm1) ! aval[last] = aval[last] * (dest[j + r - 1] - orig[i]) ! / (orig[i + r - 1] - orig[i]); else aval[last] = 0.0F; ! for (int s = last - 1; s >= 0; s--) { i++; ! /*if (i + r > orig.length) { ! System.out.println("dest:" + dest.length + " orig:" + ! orig.length); ! System.out.println("m:" + m + " n:" + n + " k:" + k); ! System.out.println("j:" + j + " r:" + r + " i:" + i); ! System.out.println("last:" + last + " s:" + s + ! " brkPoint:" + brkPoint); ! System.out.println("aval:" + asList(aval)); ! System.out.println("orig:" + asList(orig)); ! System.out.println("dest:" + asList(dest)); ! }*/ ! float omega = (dest[j + r - 1] - orig[i]) ! / (orig[i + r - 1] - orig[i]); aval[s + 1] = aval[s + 1] + (1 - omega) * aval[s]; aval[s] = omega * aval[s]; *************** *** 585,592 **** for (int s = 0; s <= last; s++) alpha[last - s][j] = aval[s]; ! } return alpha; } /* --- 634,733 ---- for (int s = 0; s <= last; s++) alpha[last - s][j] = aval[s]; ! }/* ! for (int i = 0; i < alpha.length; i++) { ! System.out.println(asList(alpha[i])); ! }*/ ! return alpha; ! } + /* + * Apply the alpha matrix to the original control points, generating new + * ones + */ + private void generatePointsU(float[][] alpha, Nurbs dest) { + for (int out = 0; out < dest.nv; out++) { + for (int j = 0; j < dest.nu; j++) { + Point4f dp = dest.points[out][j]; + dp.x = 0.0f; + dp.y = 0.0f; + dp.z = 0.0f; + dp.w = 0.0f; + for (int i = 0; i < nu; i++) { + double a = alpha[i][j]; + Point4f sp = points[out][i]; + dp.x += a * sp.x; + dp.y += a * sp.y; + dp.z += a * sp.z; + dp.w += a * sp.w; + } + } + } + } + + private void generatePointsV(float[][] alpha, Nurbs dest) { + for (int out = 0; out < dest.nu; out++) { + for (int j = 0; j < dest.nv; j++) { + Point4f dp = dest.points[j][out]; + dp.x = 0.0f; + dp.y = 0.0f; + dp.z = 0.0f; + dp.w = 0.0f; + for (int i = 0; i < nv; i++) { + double a = alpha[i][j]; + Point4f sp = points[i][out]; + dp.x += a * sp.x; + dp.y += a * sp.y; + dp.z += a * sp.z; + dp.w += a * sp.w; + } + } + } + } + + private float evaluate(float[] x, float[] y, int i, int j, int k) { + if (k == 1) + if (x[i] <= y[j] && y[j] < x[i + 1]) + return 1; + else + return 0; + float a1 = evaluate(x, y, i, j, k - 1); + float a2 = evaluate(x, y, i + 1, j, k - 1); + return (a1 != 0 ? ((y[j + k - 1] - x[i]) / (x[i + k - 1] - x[i])) : 0) + + (a2 != 0 ? ((x[i + k] - y[j + k - 1]) / (x[i + k] - x[i + 1])) : 0); + } + + private float[][] calcAlpha2(float[] x, float[] y, int n, int m, int k) { + float[][] alpha = new float[n][m]; + for (int l = 0; l < k; l++) { + for (int j = 0; j < m; j++) { + for (int i = 0; i < n; i++) { + alpha[i][j] = evaluate(x, y, i, j, k); + } + } + } return alpha; } + + /* + * Apply the alpha matrix computed above to the rows (or columns) of the + * surface. If dirflag is true do the U's (row), else do V's (col). + */ + private void refineSurface2(Nurbs dest, boolean dirflag) { + /* + * Compute the alpha matrix and indexing variables for the requested + * direction + */ + + if (dirflag) { + float[][] alpha = calcAlpha2(uknot, dest.uknot, nu, dest.nu, + uorder); + generatePointsU(alpha, dest); + } else { + float[][] alpha = calcAlpha2(vknot, dest.vknot, nv, dest.nv, + vorder); + generatePointsV(alpha, dest); + } + } + /* *************** *** 628,637 **** if (dirflag) { dp = dest.points[out][j]; ! brkPoint = findBreakPoint(dest.uknot[j], uknot, nu - 1, uorder); i1 = Math.max(brkPoint - uorder + 1, 0); sp = points[out][i1]; } else { dp = dest.points[j][out]; ! brkPoint = findBreakPoint(dest.vknot[j], vknot, nv - 1, vorder); i1 = Math.max(brkPoint - vorder + 1, 0); sp = points[i1][out]; --- 769,780 ---- if (dirflag) { dp = dest.points[out][j]; ! brkPoint = findBreakPoint(dest.uknot[j], uknot, nu - 1, ! uorder); i1 = Math.max(brkPoint - uorder + 1, 0); sp = points[out][i1]; } else { dp = dest.points[j][out]; ! brkPoint = findBreakPoint(dest.vknot[j], vknot, nv - 1, ! vorder); i1 = Math.max(brkPoint - vorder + 1, 0); sp = points[i1][out]; *************** *** 663,666 **** --- 806,810 ---- private int findBreakPoint(float u, float[] kv, int m, int k) { + //System.out.println("m:" + m + " k:" + k + " m+k-1:" + (m+k-1) + " kv.length:" + kv.length); if (u == kv[m + 1]) /* Special case for closed interval */ return m; *************** *** 698,717 **** public Primitive[] split() { Nurbs[] result = new Nurbs[2]; if (dirflag) { float mid = (umax + umin) /2; ! result[0] = new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, dirflag, ! nuInterpolateParameters(umin, mid, vmin, vmax), attributes); ! result[1] = new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, dirflag, ! nuInterpolateParameters(mid, umax, vmin, vmax), attributes); } else { float mid = (vmax + vmin) /2; ! result[0] = new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, dirflag, ! nuInterpolateParameters(umin, umax, vmin, mid), attributes); ! result[1] = new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, dirflag, ! nuInterpolateParameters(umin, umax, mid, vmax), attributes); } splitSurface(result[0], result[1]); --- 842,870 ---- public Primitive[] split() { Nurbs[] result = new Nurbs[2]; + if (dirflag) { float mid = (umax + umin) /2; ! result[0] = ! new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, dirflag, ! nuInterpolateParameters(umin, mid, vmin, vmax), ! attributes); ! result[1] = ! new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, dirflag, ! nuInterpolateParameters(mid, umax, vmin, vmax), ! attributes); } else { float mid = (vmax + vmin) /2; ! result[0] = ! new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, dirflag, ! nuInterpolateParameters(umin, umax, vmin, mid), ! attributes); ! result[1] = ! new Nurbs(nu, uorder, uknot, umin, umax, ! nv, vorder, vknot, vmin, vmax, dirflag, ! nuInterpolateParameters(umin, umax, mid, vmax), ! attributes); } splitSurface(result[0], result[1]); *************** *** 721,734 **** } ! private ParameterList nuInterpolateParameters( ! float umin, ! float umax, ! float vmin, ! float vmax) { ! VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter("Pw"); ! ParameterList result = linearInterpolateParameters(umin, umax, vmin, vmax); ! result.addParameter(paramHp); ! return result; } --- 874,887 ---- } ! private ParameterList nuInterpolateParameters(float umin, ! float umax, ! float vmin, ! float vmax) { ! VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter("Pw"); ! ParameterList result = ! linearInterpolateParameters(umin, umax, vmin, vmax); ! result.addParameter(paramHp); ! return result; } *************** *** 737,742 **** * If any normals are sick, fix them now. */ ! if ((c00.normLen == 0.0) || (cnn.normLen == 0.0) ! || (cn0.normLen == 0.0)) fixNormals(c00, cnn, cn0); if (c0n.normLen == 0.0) --- 890,894 ---- * If any normals are sick, fix them now. */ ! if ((c00.normLen == 0.0) || (cnn.normLen == 0.0) || (cn0.normLen == 0.0)) fixNormals(c00, cnn, cn0); if (c0n.normLen == 0.0) *************** *** 759,763 **** + vknot[vorder - 1]; ! calcPoint( uPos, vPos, p, utan, vtan ); P.set(u, v, p); --- 911,915 ---- + vknot[vorder - 1]; ! calcPoint(uPos, vPos, p, utan, vtan); P.set(u, v, p); *************** *** 794,798 **** /* * Compute Bi,k(u), for i = 0..k. ! * u is the parameter of the spline to find the basis functions for * brkPoint is the start of the knot interval ("segment") * kv is the knot vector --- 946,951 ---- /* * Compute Bi,k(u), for i = 0..k. ! * u is the parameter of the spline to find the basis ! * functions for * brkPoint is the start of the knot interval ("segment") * kv is the knot vector *************** *** 803,812 **** */ ! private void basisFunctions( float u, int brkPoint, float[] kv, ! int k, float[] bvals ) { ! bvals[0] = 1.0F; for (int r = 2; r <= k; r++) { int i = brkPoint - r + 1; ! bvals[r - 1] = 0.0F; for (int s = r - 2; s >= 0; s--) { i++; --- 956,965 ---- */ ! private void basisFunctions(float u, int brkPoint, float[] kv, ! int k, float[] bvals ) { ! bvals[0] = 1.0f; for (int r = 2; r <= k; r++) { int i = brkPoint - r + 1; ! bvals[r - 1] = 0.0f; for (int s = r - 2; s >= 0; s--) { i++; *************** *** 826,830 **** */ private void basisDerivatives( float u, int brkPoint, ! float[] kv, int k, float[] dvals ) { basisFunctions( u, brkPoint, kv, k - 1, dvals ); --- 979,983 ---- */ private void basisDerivatives( float u, int brkPoint, ! float[] kv, int k, float[] dvals ) { basisFunctions( u, brkPoint, kv, k - 1, dvals ); |
From: Elmer G. <ega...@us...> - 2005-11-07 01:04:59
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29812/src/org/jrman/parser Modified Files: Parser.java Log Message: Working NURBS!!! Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** Parser.java 4 Jul 2005 06:32:04 -0000 1.105 --- Parser.java 7 Nov 2005 01:04:47 -0000 1.106 *************** *** 79,83 **** import org.jrman.primitive.Disk; import org.jrman.primitive.Hyperboloid; ! import org.jrman.primitive.Nurbs; import org.jrman.primitive.ObjectInstance; import org.jrman.primitive.Paraboloid; --- 79,83 ---- import org.jrman.primitive.Disk; import org.jrman.primitive.Hyperboloid; ! import org.jrman.primitive.NurbsRI; import org.jrman.primitive.ObjectInstance; import org.jrman.primitive.Paraboloid; *************** *** 1275,1279 **** if (!inObject) { renderer.addPrimitive( ! new Nurbs( nu, uorder, --- 1275,1279 ---- if (!inObject) { renderer.addPrimitive( ! new NurbsRI( nu, uorder, *************** *** 1286,1289 **** --- 1286,1290 ---- vmin, vmax, + true, parameters, getAttributes())); *************** *** 1295,1299 **** public Primitive create(Attributes attributes) { nurbsCount++; ! return new Nurbs( nu, uorder, --- 1296,1300 ---- public Primitive create(Attributes attributes) { nurbsCount++; ! return new NurbsRI( nu, uorder, *************** *** 1306,1309 **** --- 1307,1311 ---- vmin, vmax, + true, parameters, createAttributes(transform, attributes)); |
From: Gerardo H. <ma...@us...> - 2005-07-18 06:19:19
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20106/src/org/jrman/render Modified Files: Sample.java Sampler.java Log Message: Fixed opacity/grid bug! Index: Sampler.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sampler.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Sampler.java 13 Jul 2005 04:13:40 -0000 1.25 --- Sampler.java 18 Jul 2005 06:18:55 -0000 1.26 *************** *** 257,291 **** } - public boolean isVisible(Micropolygon mp) { - if (rootVisibility.opaque && rootVisibility.z < mp.getMinZ()) { - mpRootCount++; - return false; - } - boolean visible = false; - float minX = mp.getMinX() - min.x; - float minY = mp.getMinY() - min.y; - float maxX = mp.getMaxX() - min.x; - float maxY = mp.getMaxY() - min.y; - int minCol = (int) Calc.clamp(minX, 0f, bucketWidth - 1); - int minRow = (int) Calc.clamp(minY, 0f, bucketHeight - 1); - int maxCol = (int) Calc.clamp((float) Calc.ceil(maxX), 0f, - bucketWidth - 1); - int maxRow = (int) Calc.clamp((float) Calc.ceil(maxY), 0f, - bucketHeight - 1); - PixelsLoop: for (int row = minRow; row <= maxRow; row++) - for (int column = minCol; column <= maxCol; column++) { - MaskElement me = pixelsVisibility[row * bucketWidth + column]; - if (!me.opaque || me.z > mp.getMinZ()) { - visible = true; - break PixelsLoop; - } - } - if (!visible) { - mpPixelCount++; - return false; - } - return true; - } - public void sample(Micropolygon mp) { if (rootVisibility.opaque && rootVisibility.z < mp.getMinZ()) { --- 257,260 ---- *************** *** 314,318 **** for (int row = minRow; row <= maxRow; row++) { int minR = Calc.max(rowOffset, sMinRow); ! int maxR = Calc.min(rowOffset + pixelHeight, sMaxRow); int colOffset = minCol * pixelWidth; for (int column = minCol; column <= maxCol; column++) { --- 283,287 ---- for (int row = minRow; row <= maxRow; row++) { int minR = Calc.max(rowOffset, sMinRow); ! int maxR = Calc.min(rowOffset + pixelHeight - 1, sMaxRow); int colOffset = minCol * pixelWidth; for (int column = minCol; column <= maxCol; column++) { *************** *** 320,324 **** if (!me.opaque || me.z > mp.getMinZ()) { int minC = Calc.max(colOffset, sMinCol); ! int maxC = Calc.min(colOffset + pixelWidth, sMaxCol); for (int r = minR; r <= maxR; r++) for (int c = minC; c <= maxC; c++) { --- 289,293 ---- if (!me.opaque || me.z > mp.getMinZ()) { int minC = Calc.max(colOffset, sMinCol); ! int maxC = Calc.min(colOffset + pixelWidth - 1, sMaxCol); for (int r = minR; r <= maxR; r++) for (int c = minC; c <= maxC; c++) { Index: Sample.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sample.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Sample.java 14 Jan 2004 03:06:35 -0000 1.10 --- Sample.java 18 Jul 2005 06:18:55 -0000 1.11 *************** *** 81,92 **** } - /* - public void overlayOver(float[] dst, int offset) { - dst[offset] = dst[offset] * (1f - opacityRed) + colorRed; - dst[offset + 1] = dst[offset + 1] * (1f - opacityGreen) + colorGreen; - dst[offset + 2] = dst[offset + 2] * (1f - opacityBlue) + colorBlue; - } - */ - public float getZ() { return z; --- 81,84 ---- |
From: Gerardo H. <ma...@us...> - 2005-07-18 06:19:19
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20106/src/org/jrman/shaders Modified Files: SurfaceShader.java Log Message: Fixed opacity/grid bug! Index: SurfaceShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceShader.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** SurfaceShader.java 4 Jul 2005 06:32:03 -0000 1.21 --- SurfaceShader.java 18 Jul 2005 06:18:55 -0000 1.22 *************** *** 49,53 **** private static boolean betterHighlights = false; ! static FloatGrid _fg1 = new FloatGrid(); --- 49,53 ---- private static boolean betterHighlights = false; ! static FloatGrid _fg1 = new FloatGrid(); |
From: Gerardo H. <ma...@us...> - 2005-07-18 06:19:19
|
Update of /cvsroot/jrman/drafts/src/org/jrman/attributes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20106/src/org/jrman/attributes Modified Files: Attributes.java Log Message: Fixed opacity/grid bug! Index: Attributes.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/attributes/Attributes.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Attributes.java 16 Sep 2004 04:16:42 -0000 1.5 --- Attributes.java 18 Jul 2005 06:18:56 -0000 1.6 *************** *** 93,97 **** protected Space space; ! protected Attributes() { } --- 93,97 ---- protected Space space; ! protected Attributes() { } |
From: Gerardo H. <ma...@us...> - 2005-07-13 04:14:06
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10654/src/org/jrman/render Modified Files: SimpleMicropolygon.java SamplePoint.java SmoothMicropolygon.java Micropolygon.java Sampler.java Log Message: More optimizations. Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** SimpleMicropolygon.java 6 Jul 2005 22:53:24 -0000 1.23 --- SimpleMicropolygon.java 13 Jul 2005 04:13:40 -0000 1.24 *************** *** 23,28 **** import javax.vecmath.Point3f; - import org.jrman.util.Calc; - public class SimpleMicropolygon extends Micropolygon { --- 23,26 ---- *************** *** 101,148 **** } - private void addPointToBounds(float x, float y, float z) { - minX = Calc.min(minX, x); - maxX = Calc.max(maxX, x); - minY = Calc.min(minY, y); - maxY = Calc.max(maxY, y); - minZ = Calc.min(minZ, z); - } - - public void sample(Sampler sampler) { - if (!sampler.isVisible(this)) - return; - Point2f smin = sampler.getMin(); - float mpMinX = minX - smin.x; - float mpMaxX = maxX - smin.x; - float mpMinY = minY - smin.y; - float mpMaxY = maxY - smin.y; - int minColumn = - Calc.clamp( - (int) (mpMinX * sampler.getOneOverSampleWidth()), - 0, - sampler.getWidth() - 1); - int minRow = - Calc.clamp( - (int) (mpMinY * sampler.getOneOverSampleHeight()), - 0, - sampler.getHeight() - 1); - int maxColumn = - Calc.clamp( - (int) (mpMaxX * sampler.getOneOverSampleWidth()), - 0, - sampler.getWidth() - 1); - int maxRow = - Calc.clamp( - (int) (mpMaxY * sampler.getOneOverSampleHeight()), - 0, - sampler.getHeight() - 1); - for (int row = minRow; row <= maxRow; row++) { - for (int col = minColumn; col <= maxColumn; col++) { - SamplePoint sp = sampler.getSamplePoint(col, row); - sampleAtPoint(sp); - } - } - } - public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); --- 99,102 ---- Index: Sampler.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sampler.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Sampler.java 6 Jul 2005 22:53:24 -0000 1.24 --- Sampler.java 13 Jul 2005 04:13:40 -0000 1.25 *************** *** 213,233 **** } - /* - public void updateDepth(int offset, float z, boolean firstTime) { - MaskElement me = pixelsVisibility[offset]; - me.z = Calc.max(me.z, z); - if (firstTime) { - me.count++; - if (me.count == samplesPerPixel) { - me.opaque = true; - rootVisibility.count++; - rootVisibility.z = Calc.max(rootVisibility.z, z); - if (rootVisibility.count == pixelsPerBucket) - rootVisibility.opaque = true; - } - } - } - */ - public void updateDepth(int offset, float z) { MaskElement me = pixelsVisibility[offset]; --- 213,216 ---- Index: SmoothMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SmoothMicropolygon.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SmoothMicropolygon.java 6 Jul 2005 22:53:24 -0000 1.4 --- SmoothMicropolygon.java 13 Jul 2005 04:13:40 -0000 1.5 *************** *** 23,28 **** import javax.vecmath.Point3f; - import org.jrman.util.Calc; - public class SmoothMicropolygon extends Micropolygon { --- 23,26 ---- *************** *** 149,194 **** } - private void addPointToBounds(float x, float y, float z) { - minX = Calc.min(minX, x); - maxX = Calc.max(maxX, x); - minY = Calc.min(minY, y); - maxY = Calc.max(maxY, y); - minZ = Calc.min(minZ, z); - } - - public void sample(Sampler sampler) { - Point2f smin = sampler.getMin(); - float mpMinX = minX - smin.x; - float mpMaxX = maxX - smin.x; - float mpMinY = minY - smin.y; - float mpMaxY = maxY - smin.y; - int minColumn = - Calc.clamp( - (int) (mpMinX * sampler.getOneOverSampleWidth()), - 0, - sampler.getWidth() - 1); - int minRow = - Calc.clamp( - (int) (mpMinY * sampler.getOneOverSampleHeight()), - 0, - sampler.getHeight() - 1); - int maxColumn = - Calc.clamp( - (int) (mpMaxX * sampler.getOneOverSampleWidth()), - 0, - sampler.getWidth() - 1); - int maxRow = - Calc.clamp( - (int) (mpMaxY * sampler.getOneOverSampleHeight()), - 0, - sampler.getHeight() - 1); - for (int row = minRow; row <= maxRow; row++) { - for (int col = minColumn; col <= maxColumn; col++) { - SamplePoint sp = sampler.getSamplePoint(col, row); - sampleAtPoint(sp); - } - } - } - public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); --- 147,150 ---- Index: Micropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Micropolygon.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Micropolygon.java 6 Jul 2005 22:53:24 -0000 1.21 --- Micropolygon.java 13 Jul 2005 04:13:40 -0000 1.22 *************** *** 20,23 **** --- 20,24 ---- package org.jrman.render; + import org.jrman.util.Calc; import org.jrman.util.Constants; *************** *** 36,41 **** protected float minZ = Constants.INFINITY; - public abstract void sample(Sampler sampler); - public abstract void sampleAtPoint(SamplePoint sp); --- 37,40 ---- *************** *** 69,71 **** --- 68,78 ---- } + protected void addPointToBounds(float x, float y, float z) { + minX = Calc.min(minX, x); + maxX = Calc.max(maxX, x); + minY = Calc.min(minY, y); + maxY = Calc.max(maxY, y); + minZ = Calc.min(minZ, z); + } + } Index: SamplePoint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SamplePoint.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** SamplePoint.java 6 Jul 2005 22:53:24 -0000 1.26 --- SamplePoint.java 13 Jul 2005 04:13:40 -0000 1.27 *************** *** 32,37 **** private int sampleCount = 0; - // private Micropolygon micropolygons; - private Sampler sampler; --- 32,35 ---- *************** *** 54,58 **** sampleCount = 0; z = Constants.INFINITY; - // micropolygons = null; } --- 52,55 ---- *************** *** 96,109 **** } - /* - private void update(float nz) { - if (nz < z || !opaque) { - z = nz; - sampler.updateDepth(offset, z, !opaque); - opaque = true; - } - } - */ - private void update(float nz) { if (nz < z) --- 93,96 ---- *************** *** 151,163 **** } - /* - * public void addMicropolygon(Micropolygon mp) { mp.next = micropolygons; - * micropolygons = mp; } - * - * public boolean hasMoreMicropolygons() { return micropolygons != null; } - * - * public Micropolygon getNextMicropolygon() { Micropolygon result = - * micropolygons; micropolygons = result.next; return result; } - */ - } \ No newline at end of file --- 138,140 ---- |
From: Gerardo H. <ma...@us...> - 2005-07-06 22:53:34
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2402/src/org/jrman/render Modified Files: MemoryBucket.java RendererHidden.java ShaderVariables.java Sampler.java SimpleMicropolygon.java SamplePoint.java SmoothMicropolygon.java Micropolygon.java Log Message: Some performance optimization attempts. Some of this stuff will stay, some might go away... Index: Sampler.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sampler.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Sampler.java 20 Sep 2004 21:09:06 -0000 1.23 --- Sampler.java 6 Jul 2005 22:53:24 -0000 1.24 *************** *** 1,20 **** /* ! Sampler.java ! Copyright (C) 2003 Gerardo Horvilleur Martinez ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package org.jrman.render; --- 1,19 ---- /* ! * Sampler.java Copyright (C) 2003 Gerardo Horvilleur Martinez ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ! * details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package org.jrman.render; *************** *** 61,65 **** private int samplesPerPixel; ! private int pixelsPerBucket; --- 60,64 ---- private int samplesPerPixel; ! private int pixelsPerBucket; *************** *** 70,77 **** private int pixelCount; public static class MaskElement { ! float z; ! boolean opaque; --- 69,80 ---- private int pixelCount; + private int mpRootCount; + + private int mpPixelCount; + public static class MaskElement { ! float z; ! boolean opaque; *************** *** 86,90 **** } ! public Sampler(int bucketWidth, int bucketHeight, float hSamples, float vSamples) { this.bucketWidth = bucketWidth; this.bucketHeight = bucketHeight; --- 89,94 ---- } ! public Sampler(int bucketWidth, int bucketHeight, float hSamples, ! float vSamples) { this.bucketWidth = bucketWidth; this.bucketHeight = bucketHeight; *************** *** 102,108 **** for (int row = 0; row < height; row++) for (int column = 0; column < width; column++) ! samplePoints[row * width + column] = ! new SamplePoint(this, ! column / pixelWidth + (row / pixelHeight) * bucketWidth); pixelsVisibility = new MaskElement[bucketWidth * bucketHeight]; for (int i = 0; i < pixelsVisibility.length; i++) --- 106,111 ---- for (int row = 0; row < height; row++) for (int column = 0; column < width; column++) ! samplePoints[row * width + column] = new SamplePoint(this, ! column / pixelWidth + (row / pixelHeight) * bucketWidth); pixelsVisibility = new MaskElement[bucketWidth * bucketHeight]; for (int i = 0; i < pixelsVisibility.length; i++) *************** *** 117,122 **** float x = minX; for (int column = 0; column < width; column++) { ! float jx = x + Rand.uniform() * sampleWidth; ! float jy = y + Rand.uniform() * sampleHeight; samplePoints[offset + column].init(jx, jy); x += sampleWidth; --- 120,125 ---- float x = minX; for (int column = 0; column < width; column++) { ! float jx = x + Rand.uniform() * sampleWidth; ! float jy = y + Rand.uniform() * sampleHeight; samplePoints[offset + column].init(jx, jy); x += sampleWidth; *************** *** 134,148 **** while (bucket.hasMoreMicropolygons()) { Micropolygon mp = bucket.getNextMicropolygon(); ! mp.sample(this); hasSamples = true; } } ! public void getColors( ! float[] dst, ! int dstOffset, ! int rowLength, ! int bands, ! int bandOffset) { int destOffset = dstOffset + bandOffset; rowLength *= bands; --- 137,147 ---- while (bucket.hasMoreMicropolygons()) { Micropolygon mp = bucket.getNextMicropolygon(); ! sample(mp); hasSamples = true; } } ! public void getColors(float[] dst, int dstOffset, int rowLength, int bands, ! int bandOffset) { int destOffset = dstOffset + bandOffset; rowLength *= bands; *************** *** 214,217 **** --- 213,217 ---- } + /* public void updateDepth(int offset, float z, boolean firstTime) { MaskElement me = pixelsVisibility[offset]; *************** *** 228,231 **** --- 228,245 ---- } } + */ + + public void updateDepth(int offset, float z) { + MaskElement me = pixelsVisibility[offset]; + me.z = Calc.max(me.z, z); + me.count++; + if (me.count == samplesPerPixel) { + me.opaque = true; + rootVisibility.count++; + rootVisibility.z = Calc.max(rootVisibility.z, z); + if (rootVisibility.count == pixelsPerBucket) + rootVisibility.opaque = true; + } + } public boolean isVisible(Bounds2f bounds, float z) { *************** *** 241,247 **** int minCol = (int) Calc.clamp(minX, 0f, bucketWidth - 1); int minRow = (int) Calc.clamp(minY, 0f, bucketHeight - 1); ! int maxCol = (int) Calc.clamp((float) Calc.ceil(maxX), 0f, bucketWidth - 1); ! int maxRow = (int) Calc.clamp((float) Calc.ceil(maxY), 0f, bucketHeight - 1); ! PixelsLoop : for (int row = minRow; row <= maxRow; row++) for (int column = minCol; column <= maxCol; column++) { MaskElement me = pixelsVisibility[row * bucketWidth + column]; --- 255,263 ---- int minCol = (int) Calc.clamp(minX, 0f, bucketWidth - 1); int minRow = (int) Calc.clamp(minY, 0f, bucketHeight - 1); ! int maxCol = (int) Calc.clamp((float) Calc.ceil(maxX), 0f, ! bucketWidth - 1); ! int maxRow = (int) Calc.clamp((float) Calc.ceil(maxY), 0f, ! bucketHeight - 1); ! PixelsLoop: for (int row = minRow; row <= maxRow; row++) for (int column = minCol; column <= maxCol; column++) { MaskElement me = pixelsVisibility[row * bucketWidth + column]; *************** *** 258,261 **** --- 274,354 ---- } + public boolean isVisible(Micropolygon mp) { + if (rootVisibility.opaque && rootVisibility.z < mp.getMinZ()) { + mpRootCount++; + return false; + } + boolean visible = false; + float minX = mp.getMinX() - min.x; + float minY = mp.getMinY() - min.y; + float maxX = mp.getMaxX() - min.x; + float maxY = mp.getMaxY() - min.y; + int minCol = (int) Calc.clamp(minX, 0f, bucketWidth - 1); + int minRow = (int) Calc.clamp(minY, 0f, bucketHeight - 1); + int maxCol = (int) Calc.clamp((float) Calc.ceil(maxX), 0f, + bucketWidth - 1); + int maxRow = (int) Calc.clamp((float) Calc.ceil(maxY), 0f, + bucketHeight - 1); + PixelsLoop: for (int row = minRow; row <= maxRow; row++) + for (int column = minCol; column <= maxCol; column++) { + MaskElement me = pixelsVisibility[row * bucketWidth + column]; + if (!me.opaque || me.z > mp.getMinZ()) { + visible = true; + break PixelsLoop; + } + } + if (!visible) { + mpPixelCount++; + return false; + } + return true; + } + + public void sample(Micropolygon mp) { + if (rootVisibility.opaque && rootVisibility.z < mp.getMinZ()) { + mpRootCount++; + return; + } + float minX = mp.getMinX() - min.x; + float minY = mp.getMinY() - min.y; + float maxX = mp.getMaxX() - min.x; + float maxY = mp.getMaxY() - min.y; + int minCol = (int) Calc.clamp(minX, 0f, bucketWidth - 1); + int minRow = (int) Calc.clamp(minY, 0f, bucketHeight - 1); + int maxCol = (int) Calc.clamp((float) Calc.ceil(maxX), 0f, + bucketWidth - 1); + int maxRow = (int) Calc.clamp((float) Calc.ceil(maxY), 0f, + bucketHeight - 1); + int sMinCol = Calc.clamp((int) (minX * oneOverSampleWidth), 0, + width - 1); + int sMinRow = Calc.clamp((int) (minY * oneOverSampleHeight), 0, + height - 1); + int sMaxCol = Calc.clamp((int) (maxX * oneOverSampleWidth), 0, + width - 1); + int sMaxRow = Calc.clamp((int) (maxY * oneOverSampleHeight), 0, + height - 1); + int rowOffset = minRow * pixelHeight; + for (int row = minRow; row <= maxRow; row++) { + int minR = Calc.max(rowOffset, sMinRow); + int maxR = Calc.min(rowOffset + pixelHeight, sMaxRow); + int colOffset = minCol * pixelWidth; + for (int column = minCol; column <= maxCol; column++) { + MaskElement me = pixelsVisibility[row * bucketWidth + column]; + if (!me.opaque || me.z > mp.getMinZ()) { + int minC = Calc.max(colOffset, sMinCol); + int maxC = Calc.min(colOffset + pixelWidth, sMaxCol); + for (int r = minR; r <= maxR; r++) + for (int c = minC; c <= maxC; c++) { + SamplePoint sp = getSamplePoint(c, r); + mp.sampleAtPoint(sp); + } + } + colOffset += pixelWidth; + } + rowOffset += pixelHeight; + } + return; + } + public int getBucketHeight() { return bucketHeight; *************** *** 282,290 **** } ! public int getPixelCount() { ! return pixelCount; ! } ! public int getRootCount() { ! return rootCount; ! } ! } --- 375,392 ---- } ! public int getPixelCount() { ! return pixelCount; ! } ! ! public int getRootCount() { ! return rootCount; ! } ! ! public int getMPRootCount() { ! return mpRootCount; ! } ! ! public int getMPPixelCount() { ! return mpPixelCount; ! } ! } \ No newline at end of file Index: ShaderVariables.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/ShaderVariables.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ShaderVariables.java 8 Feb 2004 08:54:55 -0000 1.13 --- ShaderVariables.java 6 Jul 2005 22:53:24 -0000 1.14 *************** *** 100,103 **** --- 100,107 ---- public void transform(Transform transform) { P.transform(P, transform); + } + + public void primitiveTransform(Transform transform) { + P.transform(P, transform); N.ntransform(N, transform); Ng.ntransform(Ng, transform); Index: Micropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Micropolygon.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Micropolygon.java 20 Sep 2004 21:09:06 -0000 1.20 --- Micropolygon.java 6 Jul 2005 22:53:24 -0000 1.21 *************** *** 37,40 **** --- 37,42 ---- public abstract void sample(Sampler sampler); + + public abstract void sampleAtPoint(SamplePoint sp); public final float getMaxX() { Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** RendererHidden.java 20 Dec 2004 03:22:52 -0000 1.69 --- RendererHidden.java 6 Jul 2005 22:53:24 -0000 1.70 *************** *** 529,532 **** --- 529,534 ---- System.out.println("Root count: " + sampler.getRootCount()); System.out.println("Pixel count: " + sampler.getPixelCount()); + System.out.println("MP Root count: " + sampler.getMPRootCount()); + System.out.println("MP Pixel count: " + sampler.getMPPixelCount()); System.out.println( "gridCount = " Index: SamplePoint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SamplePoint.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** SamplePoint.java 4 Jul 2005 07:11:01 -0000 1.25 --- SamplePoint.java 6 Jul 2005 22:53:24 -0000 1.26 *************** *** 89,92 **** --- 89,93 ---- Sample[] tmp = new Sample[sampleCount * 2]; System.arraycopy(samples, 0, tmp, 0, sampleCount); + samples = tmp; } samples[sampleCount++] = sample; *************** *** 95,98 **** --- 96,100 ---- } + /* private void update(float nz) { if (nz < z || !opaque) { *************** *** 102,105 **** --- 104,117 ---- } } + */ + + private void update(float nz) { + if (nz < z) + z = nz; + if (!opaque) { + sampler.updateDepth(offset, nz); + opaque = true; + } + } public void getColor(Color4f ocolor) { Index: MemoryBucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/MemoryBucket.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MemoryBucket.java 4 Jul 2005 06:32:02 -0000 1.9 --- MemoryBucket.java 6 Jul 2005 22:53:23 -0000 1.10 *************** *** 26,34 **** public class MemoryBucket implements Bucket { ! private Primitive[] primitives = new Primitive[50]; private int primitiveCount = 0; ! private Micropolygon[] micropolygons = new Micropolygon[200]; private int micropolygonCount = 0; --- 26,34 ---- public class MemoryBucket implements Bucket { ! private Primitive[] primitives = new Primitive[0]; private int primitiveCount = 0; ! private Micropolygon[] micropolygons = new Micropolygon[0]; private int micropolygonCount = 0; *************** *** 44,49 **** public void addPrimitive(Primitive primitive) { ! if (primitiveCount == primitives.length) { ! Primitive[] tmp = new Primitive[primitiveCount * 2]; System.arraycopy(primitives, 0, tmp, 0, primitiveCount); primitives = tmp; --- 44,53 ---- public void addPrimitive(Primitive primitive) { ! if (primitiveCount == primitives.length) { ! Primitive[] tmp; ! if (primitiveCount == 0) ! tmp = new Primitive[50]; ! else ! tmp = new Primitive[primitiveCount * 4]; System.arraycopy(primitives, 0, tmp, 0, primitiveCount); primitives = tmp; *************** *** 81,85 **** return; if (micropolygonCount == micropolygons.length) { ! Micropolygon[] tmp = new Micropolygon[micropolygonCount * 2]; System.arraycopy(micropolygons, 0, tmp, 0, micropolygonCount); micropolygons = tmp; --- 85,93 ---- return; if (micropolygonCount == micropolygons.length) { ! Micropolygon[] tmp; ! if (micropolygonCount == 0) ! tmp = new Micropolygon[1024]; ! else ! tmp = new Micropolygon[micropolygonCount * 4]; System.arraycopy(micropolygons, 0, tmp, 0, micropolygonCount); micropolygons = tmp; *************** *** 106,109 **** --- 114,118 ---- for (int i = 0; i < micropolygonCount; i++) micropolygons[i] = null; + micropolygons = null; micropolygonCount = 0; } Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SimpleMicropolygon.java 2 Jul 2005 08:00:35 -0000 1.22 --- SimpleMicropolygon.java 6 Jul 2005 22:53:24 -0000 1.23 *************** *** 110,113 **** --- 110,115 ---- public void sample(Sampler sampler) { + if (!sampler.isVisible(this)) + return; Point2f smin = sampler.getMin(); float mpMinX = minX - smin.x; *************** *** 159,162 **** --- 161,166 ---- return; float z = w * az + u * bz + v * cz; + if (sp.isOpaque() && sp.getZ() < z) + return; sp.addSample( colorRed, Index: SmoothMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SmoothMicropolygon.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SmoothMicropolygon.java 2 Jul 2005 08:00:35 -0000 1.3 --- SmoothMicropolygon.java 6 Jul 2005 22:53:24 -0000 1.4 *************** *** 207,210 **** --- 207,212 ---- return; float z = w * az + u * bz + v * cz; + if (sp.isOpaque() && sp.getZ() < z) + return; float colorRed = w * aColorRed + u * bColorRed + v * cColorRed; float colorGreen = w * aColorGreen + u * bColorGreen + v * cColorGreen; |
From: Gerardo H. <ma...@us...> - 2005-07-06 22:53:33
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2402/src/org/jrman/parser Modified Files: Tokenizer.java Log Message: Some performance optimization attempts. Some of this stuff will stay, some might go away... Index: Tokenizer.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Tokenizer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Tokenizer.java 4 Jul 2005 06:32:03 -0000 1.3 --- Tokenizer.java 6 Jul 2005 22:53:25 -0000 1.4 *************** *** 1,20 **** /* ! Tokenizer.java ! Copyright (C) 2004 Gerardo Horvilleur Martinez ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package org.jrman.parser; --- 1,19 ---- /* ! * Tokenizer.java Copyright (C) 2004 Gerardo Horvilleur Martinez ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ! * details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package org.jrman.parser; *************** *** 23,64 **** import java.io.Reader; import java.io.StreamTokenizer; ! import java.util.ArrayList; ! import java.util.List; public class Tokenizer { ! ! private static List strings = new ArrayList(); ! private static char[] buffer = new char[2000]; ! public String sval; ! public float nval; ! private Reader reader; ! private char ch; ! private int pos; ! private int lineno = 1; ! private int token; ! private boolean pushedBack; ! public Tokenizer(Reader reader) throws IOException { this.reader = reader; nextChar(); } ! private void nextChar() throws IOException { ch = (char) reader.read(); } ! private void bufferReset() { pos = 0; } ! private void bufferAdd() throws IOException { if (pos == buffer.length) { --- 22,65 ---- import java.io.Reader; import java.io.StreamTokenizer; ! import java.util.Arrays; ! import java.util.Comparator; ! ! import org.jrman.util.Calc; public class Tokenizer { ! ! private static String[] strings = new String[0]; ! private static char[] buffer = new char[2000]; ! public String sval; ! public float nval; ! private Reader reader; ! private char ch; ! private int pos; ! private int lineno = 1; ! private int token; ! private boolean pushedBack; ! public Tokenizer(Reader reader) throws IOException { this.reader = reader; nextChar(); } ! private void nextChar() throws IOException { ch = (char) reader.read(); } ! private void bufferReset() { pos = 0; } ! private void bufferAdd() throws IOException { if (pos == buffer.length) { *************** *** 70,91 **** nextChar(); } ! ! private static boolean matches(char[] buffer, int pos, String s) { ! if (s.length() != pos) ! return false; ! for (int i = 0; i < pos; i++) ! if (buffer[i] != s.charAt(i)) ! return false; ! return true; ! } ! ! private String bufferToString() { ! for (int i = 0; i < strings.size(); i++) { ! String s = (String) strings.get(i); ! if (matches(buffer, pos, s)) ! return s; } String s = new String(buffer, 0, pos); ! strings.add(s); return s; } --- 71,127 ---- nextChar(); } ! ! /* ! * ! * private static boolean matches(char[] buffer, int pos, String s) { if ! * (s.length() != pos) return false; for (int i = 0; i < pos; i++) if ! * (buffer[i] != s.charAt(i)) return false; return true; } ! * ! * private String bufferToString() { for (int i = 0; i < strings.size(); ! * i++) { String s = (String) strings.get(i); if (matches(buffer, pos, s)) ! * return s; } String s = new String(buffer, 0, pos); strings.add(s); return ! * s; } ! * ! */ ! ! private Comparator comparator = new Comparator() { ! public int compare(Object o1, Object o2) { ! String s = (String) o1; ! if (s.length() == pos) { ! for (int i = 0; i < pos; i++) { ! char chs = s.charAt(i); ! char chb = buffer[i]; ! if (chs < chb) ! return -1; ! if (chs > chb) ! return 1; ! } ! return 0; ! } else { ! int l = Calc.min(s.length(), pos); ! for (int i = 0; i < l; i++) { ! char chs = s.charAt(i); ! char chb = buffer[i]; ! if (chs < chb) ! return -1; ! if (chs > chb) ! return 1; ! } ! return s.length() < pos ? -1 : 1; ! } } + }; + + private String bufferToString() { + int index = Arrays.binarySearch(strings, buffer, comparator); + if (index >= 0) + return strings[index]; + index = -(index + 1); + String[] tmp = new String[strings.length + 1]; + System.arraycopy(strings, 0, tmp, 0, index); + System.arraycopy(strings, index, tmp, index + 1, strings.length - index); + strings = tmp; String s = new String(buffer, 0, pos); ! strings[index] = s; return s; } *************** *** 105,110 **** while (ch != '\n') nextChar(); ! } ! else break; } --- 141,145 ---- while (ch != '\n') nextChar(); ! } else break; } *************** *** 113,135 **** return token; } - if (Character.isJavaIdentifierStart(ch)) { - bufferReset(); - bufferAdd(); - while (Character.isJavaIdentifierPart(ch)) - bufferAdd(); - sval = bufferToString(); - token = StreamTokenizer.TT_WORD; - return token; - } - if (ch == '"') { - bufferReset(); - nextChar(); - while (ch != '"') - bufferAdd(); - sval = bufferToString(); - nextChar(); - token = '"'; - return token; - } if (Character.isDigit(ch) || ch == '.' || ch == '-' || ch == '+') { float negative = 1f; --- 148,151 ---- *************** *** 145,156 **** nextChar(); while (Character.isDigit(ch) || ch == '.') { ! if (ch == '.') ! afterPoint = true; ! else { ! nval = nval * 10f + ch - '0'; ! if (afterPoint) exp *= 0.1f; } - nextChar(); } if (ch == 'e' || ch == 'E') { --- 161,176 ---- nextChar(); while (Character.isDigit(ch) || ch == '.') { ! if (afterPoint || ch == '.') { ! if (!afterPoint) ! nextChar(); ! while (Character.isDigit(ch)) { ! nval = nval * 10f + (ch - '0'); exp *= 0.1f; + nextChar(); + } + } else { + nval = nval * 10f + (ch - '0'); + nextChar(); } } if (ch == 'e' || ch == 'E') { *************** *** 174,182 **** return token; } token = ch; nextChar(); return token; } ! public void pushBack() { pushedBack = true; --- 194,221 ---- return token; } + if (Character.isJavaIdentifierStart(ch)) { + bufferReset(); + bufferAdd(); + while (Character.isJavaIdentifierPart(ch)) + bufferAdd(); + sval = bufferToString(); + token = StreamTokenizer.TT_WORD; + return token; + } + if (ch == '"') { + bufferReset(); + nextChar(); + while (ch != '"') + bufferAdd(); + sval = bufferToString(); + nextChar(); + token = '"'; + return token; + } token = ch; nextChar(); return token; } ! public void pushBack() { pushedBack = true; *************** *** 186,189 **** return lineno; } ! ! } --- 225,228 ---- return lineno; } ! ! } \ No newline at end of file |
From: Gerardo H. <ma...@us...> - 2005-07-06 22:53:33
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2402/src/org/jrman/primitive Modified Files: Primitive.java BicubicPatch.java Log Message: Some performance optimization attempts. Some of this stuff will stay, some might go away... Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Primitive.java 3 Jul 2005 04:37:36 -0000 1.35 --- Primitive.java 6 Jul 2005 22:53:23 -0000 1.36 *************** *** 113,117 **** return distance; } ! public int compareTo(Object other) { Primitive op = (Primitive) other; --- 113,117 ---- return distance; } ! public int compareTo(Object other) { Primitive op = (Primitive) other; *************** *** 148,152 **** dice_t(shaderVariables); dice_others(shaderVariables); ! shaderVariables.transform(objectToCamera); } --- 148,152 ---- dice_t(shaderVariables); dice_others(shaderVariables); ! shaderVariables.primitiveTransform(objectToCamera); } Index: BicubicPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BicubicPatch.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** BicubicPatch.java 3 Jul 2005 04:37:36 -0000 1.16 --- BicubicPatch.java 6 Jul 2005 22:53:23 -0000 1.17 *************** *** 38,41 **** --- 38,45 ---- public class BicubicPatch extends Primitive { + private final static Declaration DECL_PW = new Declaration("Pw", + Declaration.StorageClass.VERTEX, + Declaration.Type.HPOINT, 1); + private static Point4f P00 = new Point4f(); *************** *** 127,133 **** parameters.removeParameter("P"); parameters.addParameter( ! new VaryingScalarHPoint(new Declaration("Pw", ! Declaration.StorageClass.VERTEX, ! Declaration.Type.HPOINT, 1), param3f)); } VaryingScalarHPoint paramHp = --- 131,135 ---- parameters.removeParameter("P"); parameters.addParameter( ! new VaryingScalarHPoint(DECL_PW, param3f)); } VaryingScalarHPoint paramHp = *************** *** 286,292 **** extractPoints(); VaryingScalarHPoint sparam = ! new VaryingScalarHPoint( ! new Declaration("Pw", Declaration.StorageClass.VERTEX, ! Declaration.Type.HPOINT, 1), new float[16 * 4]); if (uv00 == .5f) { splitUpper(P00, P10, P20, P30, PS00, PS10, PS20, PS30); --- 288,292 ---- extractPoints(); VaryingScalarHPoint sparam = ! new VaryingScalarHPoint(DECL_PW, new float[16 * 4]); if (uv00 == .5f) { splitUpper(P00, P10, P20, P30, PS00, PS10, PS20, PS30); |
From: Gerardo H. <ma...@us...> - 2005-07-06 22:53:31
|
Update of /cvsroot/jrman/drafts/src/org/jrman/geom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2402/src/org/jrman/geom Modified Files: PerspectiveTransform.java Bounds3f.java Log Message: Some performance optimization attempts. Some of this stuff will stay, some might go away... Index: Bounds3f.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/Bounds3f.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Bounds3f.java 14 Dec 2003 22:28:29 -0000 1.15 --- Bounds3f.java 6 Jul 2005 22:53:23 -0000 1.16 *************** *** 76,79 **** --- 76,83 ---- return minZ; } + + public float getMaxZ() { + return maxZ; + } public Bounds2f toBounds2f() { Index: PerspectiveTransform.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/geom/PerspectiveTransform.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PerspectiveTransform.java 20 Sep 2004 21:09:05 -0000 1.11 --- PerspectiveTransform.java 6 Jul 2005 22:53:23 -0000 1.12 *************** *** 112,115 **** --- 112,116 ---- transformHPoint(hpoint); point.project(hpoint); + point.z = hpoint.w; // point.z = (hpoint. w - near) / (far - near); } *************** *** 119,122 **** --- 120,124 ---- transformHPoint(hpoint); out.project(hpoint); + out.z = hpoint.w; // out.z = (hpoint.w - near) / (far -near); } |
From: Gerardo H. <ma...@us...> - 2005-07-04 07:11:10
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30872/src/org/jrman/render Modified Files: SamplePoint.java Log Message: More optimization. Index: SamplePoint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SamplePoint.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** SamplePoint.java 4 Jul 2005 06:32:02 -0000 1.24 --- SamplePoint.java 4 Jul 2005 07:11:01 -0000 1.25 *************** *** 77,84 **** } sampleCount++; ! } ! samples[i - 1] = sample; ! if (sample.isOpaque()) update(z); return; } else if (s.isOpaque()) --- 77,83 ---- } sampleCount++; ! } else update(z); + samples[i - 1] = sample; return; } else if (s.isOpaque()) |
From: Gerardo H. <ma...@us...> - 2005-07-04 06:32:44
|
Update of /cvsroot/jrman/drafts/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14683/src Modified Files: SurfaceRandomcolors.java Log Message: More optimizations Index: SurfaceRandomcolors.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/SurfaceRandomcolors.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SurfaceRandomcolors.java 9 Dec 2003 04:51:52 -0000 1.5 --- SurfaceRandomcolors.java 4 Jul 2005 06:32:02 -0000 1.6 *************** *** 34,43 **** private static Color3fGrid cg3 = new Color3fGrid(); ! protected void initDefaults() { defaultParameters.addParameter( ! new UniformScalarFloat(new Declaration("Ka", "uniform float"), 1f)); defaultParameters.addParameter( ! new UniformScalarFloat(new Declaration("Kd", "uniform float"), 1f)); } --- 34,47 ---- private static Color3fGrid cg3 = new Color3fGrid(); ! ! private static Declaration KA_DECL = new Declaration("Ka", "uniform float"); ! ! private static Declaration KD_DECL = new Declaration("Kd", "uniform float"); ! protected void initDefaults() { defaultParameters.addParameter( ! new UniformScalarFloat(KA_DECL, 1f)); defaultParameters.addParameter( ! new UniformScalarFloat(KD_DECL, 1f)); } |
From: Gerardo H. <ma...@us...> - 2005-07-04 06:32:44
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14683/src/org/jrman/shaders Modified Files: SurfaceShader.java SurfaceMatte.java Log Message: More optimizations Index: SurfaceShader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceShader.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SurfaceShader.java 16 Sep 2004 05:07:09 -0000 1.20 --- SurfaceShader.java 4 Jul 2005 06:32:03 -0000 1.21 *************** *** 1,20 **** /* ! SurfaceShader.java ! Copyright (C) 2003 Gerardo Horvilleur Martinez ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package org.jrman.shaders; --- 1,19 ---- /* ! * SurfaceShader.java Copyright (C) 2003 Gerardo Horvilleur Martinez ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ! * details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package org.jrman.shaders; *************** *** 22,26 **** --- 21,27 ---- import java.util.ArrayList; import java.util.Arrays; + import java.util.HashMap; import java.util.List; + import java.util.Map; import java.util.Set; import java.util.TreeSet; *************** *** 59,83 **** static Color3fGrid _cg1 = new Color3fGrid(); protected static abstract class Statement { public abstract void execute(ShaderVariables sv, LightShader ls); } ! private DiffuseStatement diffuseStatement = new DiffuseStatement(); ! private SpecularStatement specularStatement = new SpecularStatement(); ! private static class DiffuseStatement extends Statement { ! private Vector3fGrid Nn; ! private Color3fGrid out; ! public void setNn(Vector3fGrid nn) { Nn = nn; } public void setOut(Color3fGrid out) { this.out = out; } ! public void execute(ShaderVariables sv, LightShader ls) { FloatGrid nondiff = _fg1; --- 60,87 ---- static Color3fGrid _cg1 = new Color3fGrid(); + static Map shaderClassCache = new HashMap(); + protected static abstract class Statement { public abstract void execute(ShaderVariables sv, LightShader ls); } ! private DiffuseStatement diffuseStatement = new DiffuseStatement(); ! private SpecularStatement specularStatement = new SpecularStatement(); ! private static class DiffuseStatement extends Statement { ! private Vector3fGrid Nn; ! private Color3fGrid out; ! public void setNn(Vector3fGrid nn) { Nn = nn; } + public void setOut(Color3fGrid out) { this.out = out; } ! public void execute(ShaderVariables sv, LightShader ls) { FloatGrid nondiff = _fg1; *************** *** 92,124 **** out.add(out, sv.Cl); } ! } ! private static class SpecularStatement extends Statement { private Vector3fGrid Nn; ! private Vector3fGrid V; ! private float roughness; ! private Color3fGrid out; ! public void setNn(Vector3fGrid nn) { Nn = nn; } ! private void setV(Vector3fGrid V) { this.V = V; } ! private void setRoughness(float roughness) { this.roughness = roughness; } ! public void setOut(Color3fGrid out) { this.out = out; } ! public void execute(ShaderVariables sv, LightShader ls) { FloatGrid nonspec = _fg1; --- 96,128 ---- out.add(out, sv.Cl); } ! } ! private static class SpecularStatement extends Statement { private Vector3fGrid Nn; ! private Vector3fGrid V; ! private float roughness; ! private Color3fGrid out; ! public void setNn(Vector3fGrid nn) { Nn = nn; } ! private void setV(Vector3fGrid V) { this.V = V; } ! private void setRoughness(float roughness) { this.roughness = roughness; } ! public void setOut(Color3fGrid out) { this.out = out; } ! public void execute(ShaderVariables sv, LightShader ls) { FloatGrid nonspec = _fg1; *************** *** 143,177 **** } ! public static SurfaceShader createShader( ! String name, ! ParameterList parameters, ! Attributes attributes) { ! SurfaceShader result; ! String className = ! "Surface" + name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase(); ! if (className.equals("SurfaceConstant")) ! result = new SurfaceConstant(); ! else if (className.equals("SurfaceMatte")) ! result = new SurfaceMatte(); ! else if (className.equals("SurfaceMetal") || className.equals("SurfaceShinymetal")) ! result = new SurfaceMetal(); ! else if (className.equals("SurfacePlastic")) ! result = new SurfacePlastic(); else if (className.equals("SurfacePaintedplastic")) ! result = new SurfacePaintedplastic(); else if (className.equals("SurfaceReflectivepaintedplastic")) ! result = new SurfaceReflectivepaintedplastic(); ! else if (className.equals("SurfaceFakedlight")) ! result = new SurfaceFakedlight(); ! else ! try { ! result = (SurfaceShader) Class.forName(className).newInstance(); ! } catch (Exception e) { ! System.out.println( ! "Unknown surface shader: " ! + name ! + ", replacing with fakedlight surface shader"); ! result = new SurfaceFakedlight(); ! } result.init(name, parameters, attributes); return result; --- 147,189 ---- } ! public static SurfaceShader createShader(String name, ! ParameterList parameters, Attributes attributes) { ! Class clazz = (Class) shaderClassCache.get(name); ! if (clazz == null) { ! String className = "Surface" + name.substring(0, 1).toUpperCase() ! + name.substring(1).toLowerCase(); ! if (className.equals("SurfaceConstant")) ! clazz = SurfaceConstant.class; ! else if (className.equals("SurfaceMatte")) ! clazz = SurfaceMatte.class; ! else if (className.equals("SurfaceMetal") ! || className.equals("SurfaceShinymetal")) ! clazz = SurfaceMetal.class; ! else if (className.equals("SurfacePlastic")) ! clazz = SurfacePlastic.class; else if (className.equals("SurfacePaintedplastic")) ! clazz = SurfacePaintedplastic.class; else if (className.equals("SurfaceReflectivepaintedplastic")) ! clazz = SurfaceReflectivepaintedplastic.class; ! else if (className.equals("SurfaceFakedlight")) ! clazz = SurfaceFakedlight.class; ! else ! try { ! clazz = Class.forName(className); ! } catch (Exception e) { ! System.out.println("Unknown surface shader: " + name ! + ", replacing with fakedlight surface shader"); ! clazz = SurfaceFakedlight.class; ! } ! shaderClassCache.put(name, clazz); ! } ! SurfaceShader result; ! try { ! result = (SurfaceShader) clazz.newInstance(); ! ! } catch (Exception e) { ! throw new RuntimeException("Couldn't create instance of shader: " ! + name); ! } result.init(name, parameters, attributes); return result; *************** *** 200,210 **** illuminance(sv, null, sv.P, Nn, (float) Math.PI / 2, diffuseStatement); } ! ! protected void specular( ! ShaderVariables sv, ! Vector3fGrid Nn, ! Vector3fGrid V, ! float roughness, ! Color3fGrid out) { out.set(BLACK); specularStatement.setNn(Nn); --- 212,218 ---- illuminance(sv, null, sv.P, Nn, (float) Math.PI / 2, diffuseStatement); } ! ! protected void specular(ShaderVariables sv, Vector3fGrid Nn, ! Vector3fGrid V, float roughness, Color3fGrid out) { out.set(BLACK); specularStatement.setNn(Nn); *************** *** 215,225 **** } ! protected void doIlluminance( ! ShaderVariables sv, ! LightShader[] lights, ! Point3fGrid P, ! Vector3fGrid N, ! float angle, ! Statement statement) { for (int i = 0; i < lights.length; i++) { LightShader ls = lights[i]; --- 223,228 ---- } ! protected void doIlluminance(ShaderVariables sv, LightShader[] lights, ! Point3fGrid P, Vector3fGrid N, float angle, Statement statement) { for (int i = 0; i < lights.length; i++) { LightShader ls = lights[i]; *************** *** 231,241 **** } ! protected void illuminance( ! ShaderVariables sv, ! String categoryList, ! Point3fGrid P, ! Vector3fGrid N, ! float angle, ! Statement statement) { LightShader[] selectedLights; if (categoryList == null) --- 234,239 ---- } ! protected void illuminance(ShaderVariables sv, String categoryList, ! Point3fGrid P, Vector3fGrid N, float angle, Statement statement) { LightShader[] selectedLights; if (categoryList == null) *************** *** 246,250 **** } ! protected LightShader[] getLightsByCategory(ShaderVariables sv, String categoryList) { boolean inverse = false; if (categoryList.startsWith("-")) { --- 244,249 ---- } ! protected LightShader[] getLightsByCategory(ShaderVariables sv, ! String categoryList) { boolean inverse = false; if (categoryList.startsWith("-")) { *************** *** 260,274 **** if (ls.isAmbient()) continue; ! /* MUST FIX THIS!!!! ! Map param = ls.getParameters(); ! String __category = (String) param.get("__category"); ! if (inverse) { ! if (__category == null || !categories.contains(__category)) ! result.add(ls); ! } else { ! if (__category != null && categories.contains(__category)) ! result.add(ls); ! } ! */ } return (LightShader[]) result.toArray(new LightShader[result.size()]); --- 259,269 ---- if (ls.isAmbient()) continue; ! /* ! * MUST FIX THIS!!!! Map param = ls.getParameters(); String ! * __category = (String) param.get("__category"); if (inverse) { ! * if (__category == null || !categories.contains(__category)) ! * result.add(ls); } else { if (__category != null && ! * categories.contains(__category)) result.add(ls); } ! */ } return (LightShader[]) result.toArray(new LightShader[result.size()]); *************** *** 280,282 **** } ! } --- 275,277 ---- } ! } \ No newline at end of file Index: SurfaceMatte.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/SurfaceMatte.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SurfaceMatte.java 25 Nov 2003 16:34:08 -0000 1.3 --- SurfaceMatte.java 4 Jul 2005 06:32:03 -0000 1.4 *************** *** 36,44 **** private static Color3fGrid cg3 = new Color3fGrid(); protected void initDefaults() { defaultParameters.addParameter( ! new UniformScalarFloat(new Declaration("Ka", "uniform float"), 1f)); defaultParameters.addParameter( ! new UniformScalarFloat(new Declaration("Kd", "uniform float"), 1f)); } --- 36,48 ---- private static Color3fGrid cg3 = new Color3fGrid(); + private static Declaration KA_DECL = new Declaration("Ka", "uniform float"); + + private static Declaration KD_DECL = new Declaration("Kd", "uniform float"); + protected void initDefaults() { defaultParameters.addParameter( ! new UniformScalarFloat(KA_DECL, 1f)); defaultParameters.addParameter( ! new UniformScalarFloat(KD_DECL, 1f)); } |
From: Gerardo H. <ma...@us...> - 2005-07-04 06:32:44
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14683/src/org/jrman/render Modified Files: SamplePoint.java MemoryBucket.java Log Message: More optimizations Index: SamplePoint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SamplePoint.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** SamplePoint.java 2 Feb 2004 19:30:05 -0000 1.23 --- SamplePoint.java 4 Jul 2005 06:32:02 -0000 1.24 *************** *** 1,26 **** /* ! SamplePoint.java ! Copyright (C) 2003 Gerardo Horvilleur Martinez ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package org.jrman.render; - import java.util.ArrayList; - import java.util.List; - import javax.vecmath.Color4f; import javax.vecmath.Point2f; --- 1,22 ---- /* ! * SamplePoint.java Copyright (C) 2003 Gerardo Horvilleur Martinez ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ! * details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! */ package org.jrman.render; import javax.vecmath.Color4f; import javax.vecmath.Point2f; *************** *** 32,36 **** private Point2f point = new Point2f(); ! private List samples = new ArrayList(); // private Micropolygon micropolygons; --- 28,34 ---- private Point2f point = new Point2f(); ! private Sample[] samples = new Sample[10]; ! ! private int sampleCount = 0; // private Micropolygon micropolygons; *************** *** 51,83 **** public void init(float x, float y) { point.set(x, y); - samples.clear(); opaque = false; z = Constants.INFINITY; // micropolygons = null; } ! public void addSample( ! float colorRed, ! float colorGreen, ! float colorBlue, ! float opacityRed, ! float opacityGreen, ! float opacityBlue, ! float z) { int i = 0; ! int size = samples.size(); ! while (i < 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()) update(z); --- 49,82 ---- public void init(float x, float y) { point.set(x, y); opaque = false; + for (int i = 0; i < sampleCount; i++) + samples[i] = null; + sampleCount = 0; z = Constants.INFINITY; // micropolygons = null; } ! public void addSample(float colorRed, float colorGreen, float colorBlue, ! float opacityRed, float opacityGreen, float opacityBlue, float z) { int i = 0; ! while (i < sampleCount) { ! Sample s = samples[i++]; if (s.behind(z)) { ! Sample sample = new Sample(colorRed, colorGreen, colorBlue, ! opacityRed, opacityGreen, opacityBlue, z); ! if (!sample.isOpaque()) { ! if (sampleCount < samples.length) { ! System.arraycopy(samples, i - 1, samples, i, ! sampleCount - i + 1); ! } else { ! Sample[] tmp = new Sample[sampleCount * 2]; ! System.arraycopy(samples, 0, tmp, 0, i - 1); ! System.arraycopy(samples, i - 1, tmp, i, sampleCount ! - i + 1); ! samples = tmp; ! } ! sampleCount++; ! } ! samples[i - 1] = sample; if (sample.isOpaque()) update(z); *************** *** 86,99 **** return; } ! Sample sample = ! new Sample( ! colorRed, ! colorGreen, ! colorBlue, ! opacityRed, ! opacityGreen, ! opacityBlue, ! z); ! samples.add(sample); if (sample.isOpaque()) update(z); --- 85,95 ---- return; } ! Sample sample = new Sample(colorRed, colorGreen, colorBlue, opacityRed, ! opacityGreen, opacityBlue, z); ! if (sampleCount == samples.length) { ! Sample[] tmp = new Sample[sampleCount * 2]; ! System.arraycopy(samples, 0, tmp, 0, sampleCount); ! } ! samples[sampleCount++] = sample; if (sample.isOpaque()) update(z); *************** *** 111,122 **** ocolor.set(0f, 0f, 0f, 0f); int i = 0; ! int size = samples.size(); ! while (i < size) { ! Sample sample = (Sample) samples.get(i++); if (sample.isOpaque()) break; } while (i > 0) { ! Sample sample = (Sample) samples.get(--i); sample.overlayOver(ocolor); } --- 107,117 ---- ocolor.set(0f, 0f, 0f, 0f); int i = 0; ! while (i < sampleCount) { ! Sample sample = samples[i++]; if (sample.isOpaque()) break; } while (i > 0) { ! Sample sample = samples[--i]; sample.overlayOver(ocolor); } *************** *** 125,131 **** public float getDepth() { int i = 0; ! int size = samples.size(); ! while (i < size) { ! Sample sample = (Sample) samples.get(i++); if (sample.isOpaque()) return sample.getZ(); --- 120,125 ---- public float getDepth() { int i = 0; ! while (i < sampleCount) { ! Sample sample = samples[i++]; if (sample.isOpaque()) return sample.getZ(); *************** *** 147,165 **** /* ! public void addMicropolygon(Micropolygon mp) { ! mp.next = micropolygons; ! micropolygons = mp; ! } ! ! public boolean hasMoreMicropolygons() { ! return micropolygons != null; ! } ! ! public Micropolygon getNextMicropolygon() { ! Micropolygon result = micropolygons; ! micropolygons = result.next; ! return result; ! } ! */ ! } --- 141,152 ---- /* ! * public void addMicropolygon(Micropolygon mp) { mp.next = micropolygons; ! * micropolygons = mp; } ! * ! * public boolean hasMoreMicropolygons() { return micropolygons != null; } ! * ! * public Micropolygon getNextMicropolygon() { Micropolygon result = ! * micropolygons; micropolygons = result.next; return result; } ! */ ! } \ No newline at end of file Index: MemoryBucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/MemoryBucket.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MemoryBucket.java 20 Sep 2004 21:09:06 -0000 1.8 --- MemoryBucket.java 4 Jul 2005 06:32:02 -0000 1.9 *************** *** 20,40 **** package org.jrman.render; ! import java.util.ArrayList; ! import java.util.Collections; ! import java.util.List; import org.jrman.primitive.Primitive; - import org.jrman.util.NullList; public class MemoryBucket implements Bucket { ! private final static List NULL_LIST = new NullList(); ! ! private List primitives = new ArrayList(50); ! private List micropolygons = new ArrayList(200); private boolean primitivesModified; private boolean micropolygonsModified; --- 20,41 ---- package org.jrman.render; ! import java.util.Arrays; import org.jrman.primitive.Primitive; public class MemoryBucket implements Bucket { ! private Primitive[] primitives = new Primitive[50]; ! private int primitiveCount = 0; ! ! private Micropolygon[] micropolygons = new Micropolygon[200]; ! ! private int micropolygonCount = 0; private boolean primitivesModified; + private boolean flushed; + private boolean micropolygonsModified; *************** *** 43,57 **** public void addPrimitive(Primitive primitive) { ! primitives.add(primitive); primitivesModified = true; } public boolean hasMorePrimitives() { ! return !primitives.isEmpty(); } public Primitive getNextPrimitive() { ! Primitive p = (Primitive) primitives.get(primitives.size() - 1); ! primitives.remove(primitives.size() - 1); return p; } --- 44,63 ---- public void addPrimitive(Primitive primitive) { ! if (primitiveCount == primitives.length) { ! Primitive[] tmp = new Primitive[primitiveCount * 2]; ! System.arraycopy(primitives, 0, tmp, 0, primitiveCount); ! primitives = tmp; ! } ! primitives[primitiveCount++] = primitive; primitivesModified = true; } public boolean hasMorePrimitives() { ! return primitiveCount != 0; } public Primitive getNextPrimitive() { ! Primitive p = primitives[--primitiveCount]; ! primitives[primitiveCount] = null; return p; } *************** *** 59,63 **** public void sortPrimitives() { if (primitivesModified) { ! Collections.sort(primitives); primitivesModified = false; } --- 65,69 ---- public void sortPrimitives() { if (primitivesModified) { ! Arrays.sort(primitives, 0, primitiveCount); primitivesModified = false; } *************** *** 66,70 **** public void sortMicropolygons() { if (micropolygonsModified) { ! Collections.sort(micropolygons); micropolygonsModified = false; } --- 72,76 ---- public void sortMicropolygons() { if (micropolygonsModified) { ! Arrays.sort(micropolygons, 0, micropolygonCount); micropolygonsModified = false; } *************** *** 72,93 **** public void addMicropolygon(Micropolygon mp) { ! micropolygons.add(mp); micropolygonsModified = true; } public boolean hasMoreMicropolygons() { ! return !micropolygons.isEmpty(); } public Micropolygon getNextMicropolygon() { ! int n = micropolygons.size() - 1; ! Micropolygon mp = (Micropolygon) micropolygons.get(n); ! micropolygons.remove(n); return mp; } public void flush() { ! primitives = new ArrayList(); ! micropolygons = NULL_LIST; } --- 78,110 ---- public void addMicropolygon(Micropolygon mp) { ! if (flushed) ! return; ! if (micropolygonCount == micropolygons.length) { ! Micropolygon[] tmp = new Micropolygon[micropolygonCount * 2]; ! System.arraycopy(micropolygons, 0, tmp, 0, micropolygonCount); ! micropolygons = tmp; ! } ! micropolygons[micropolygonCount++] = mp; micropolygonsModified = true; } public boolean hasMoreMicropolygons() { ! return micropolygonCount != 0; } public Micropolygon getNextMicropolygon() { ! Micropolygon mp = micropolygons[--micropolygonCount]; ! micropolygons[micropolygonCount] = null; return mp; } public void flush() { ! flushed = true; ! for (int i = 0; i < primitiveCount; i++) ! primitives[i] = null; ! primitiveCount = 0; ! for (int i = 0; i < micropolygonCount; i++) ! micropolygons[i] = null; ! micropolygonCount = 0; } |
From: Gerardo H. <ma...@us...> - 2005-07-04 06:32:28
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parameters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14683/src/org/jrman/parameters Modified Files: Declaration.java Log Message: More optimizations Index: Declaration.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parameters/Declaration.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Declaration.java 3 Jul 2005 00:23:04 -0000 1.7 --- Declaration.java 4 Jul 2005 06:32:05 -0000 1.8 *************** *** 25,28 **** --- 25,30 ---- import java.util.Map; + import org.jrman.parser.Tokenizer; + public class Declaration { *************** *** 141,145 **** count = 1; try { ! StreamTokenizer st = new StreamTokenizer(new StringReader(decl)); if (st.nextToken() != StreamTokenizer.TT_WORD) throw new Exception("expected storage class"); --- 143,147 ---- count = 1; try { ! Tokenizer st = new Tokenizer(new StringReader(decl)); if (st.nextToken() != StreamTokenizer.TT_WORD) throw new Exception("expected storage class"); |
From: Gerardo H. <ma...@us...> - 2005-07-04 06:32:13
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14683/src/org/jrman/parser Modified Files: Tokenizer.java Parser.java Log Message: More optimizations Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** Parser.java 3 Jul 2005 04:37:36 -0000 1.104 --- Parser.java 4 Jul 2005 06:32:04 -0000 1.105 *************** *** 99,102 **** --- 99,104 ---- private final static String KEYWORD_PREFIX = "org.jrman.parser.keywords.Keyword"; + private final static Map fullFileNames = new HashMap(); + private String currentDirectory; *************** *** 209,214 **** public void parse(String filename) throws Exception { ! if (currentDirectory != null) ! filename = currentDirectory + File.separator + filename; FileReader fr = new FileReader(filename); Tokenizer st = new Tokenizer(new BufferedReader(fr)); --- 211,222 ---- public void parse(String filename) throws Exception { ! if (currentDirectory != null) { ! String fullFileName = (String) fullFileNames.get(filename); ! if (fullFileName == null) { ! fullFileName = currentDirectory + File.separator + filename; ! fullFileNames.put(filename, fullFileName); ! } ! filename = fullFileName; ! } FileReader fr = new FileReader(filename); Tokenizer st = new Tokenizer(new BufferedReader(fr)); *************** *** 265,269 **** private KeywordParser getKeyWordParser(String keyword) throws Exception { ! KeywordParser kp = (KeywordParser) keywordParsers.get(keyword.toLowerCase()); if (kp == null) { char c = keyword.charAt(0); --- 273,279 ---- private KeywordParser getKeyWordParser(String keyword) throws Exception { ! KeywordParser kp = (KeywordParser) keywordParsers.get(keyword); ! if (kp == null) ! kp = (KeywordParser) keywordParsers.get(keyword.toLowerCase()); if (kp == null) { char c = keyword.charAt(0); *************** *** 272,275 **** --- 282,286 ---- kp = (KeywordParser) Class.forName(KEYWORD_PREFIX + keyword).newInstance(); kp.setParser(this); + keywordParsers.put(keyword, kp); keywordParsers.put(keyword.toLowerCase(), kp); } Index: Tokenizer.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Tokenizer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Tokenizer.java 17 Sep 2004 06:33:46 -0000 1.2 --- Tokenizer.java 4 Jul 2005 06:32:03 -0000 1.3 *************** *** 23,29 **** --- 23,35 ---- import java.io.Reader; import java.io.StreamTokenizer; + import java.util.ArrayList; + import java.util.List; public class Tokenizer { + private static List strings = new ArrayList(); + + private static char[] buffer = new char[2000]; + public String sval; *************** *** 34,39 **** private char ch; - private char[] buffer = new char[200]; - private int pos; --- 40,43 ---- *************** *** 67,72 **** } private String bufferToString() { ! return new String(buffer, 0, pos); } --- 71,92 ---- } + private static boolean matches(char[] buffer, int pos, String s) { + if (s.length() != pos) + return false; + for (int i = 0; i < pos; i++) + if (buffer[i] != s.charAt(i)) + return false; + return true; + } + private String bufferToString() { ! for (int i = 0; i < strings.size(); i++) { ! String s = (String) strings.get(i); ! if (matches(buffer, pos, s)) ! return s; ! } ! String s = new String(buffer, 0, pos); ! strings.add(s); ! return s; } |
From: Gerardo H. <ma...@us...> - 2005-07-04 06:32:13
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser/keywords In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14683/src/org/jrman/parser/keywords Modified Files: AbstractKeywordParser.java Log Message: More optimizations Index: AbstractKeywordParser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/AbstractKeywordParser.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AbstractKeywordParser.java 3 Jul 2005 04:37:36 -0000 1.13 --- AbstractKeywordParser.java 4 Jul 2005 06:32:04 -0000 1.14 *************** *** 327,337 **** return declaration; // Check for inline declaration name = name.trim(); // Just being careful... int pos = name.lastIndexOf(' '); if (pos == -1) throw new IllegalArgumentException(); - declaration = (Declaration) declarationsCache.get(name); - if (declaration != null) - return declaration; String decl = name.substring(0, pos); String vname = name.substring(pos + 1); --- 327,337 ---- return declaration; // Check for inline declaration + declaration = (Declaration) declarationsCache.get(name); + if (declaration != null) + return declaration; name = name.trim(); // Just being careful... int pos = name.lastIndexOf(' '); if (pos == -1) throw new IllegalArgumentException(); String decl = name.substring(0, pos); String vname = name.substring(pos + 1); |
From: Gerardo H. <ma...@us...> - 2005-07-03 04:37:45
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9329/src/org/jrman/parser Modified Files: Parser.java Log Message: More performance enhancements. Removed unnecessary constant declarations! (Java Spec says that literal string constants are always interned). Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -d -r1.103 -r1.104 *** Parser.java 3 Jul 2005 00:23:04 -0000 1.103 --- Parser.java 3 Jul 2005 04:37:36 -0000 1.104 *************** *** 99,138 **** private final static String KEYWORD_PREFIX = "org.jrman.parser.keywords.Keyword"; - private final static String PARAM_FOV = "fov".intern(); - - private final static String PARAM_NAME = "name".intern(); - - private final static String PARAM_SPHERE = "sphere".intern(); - - private final static String PARAM_SENSE = "sense".intern(); - - private final static String PARAM_ORIGIN = "origin".intern(); - - private final static String PARAM_GRIDSIZE = "gridsize".intern(); - - private final static String PARAM_BUCKETSIZE = "bucketsize".intern(); - - private final static String PARAM_COORDINATESYSTEM = "coordinatesystem".intern(); - - private final static String PARAM_ENDOFFRAME = "endofframe".intern(); - - private final static String PARAM_HIGHLIGHTS = "highlights".intern(); - - private final static String PARAM_U = "u".intern(); - - private final static String PARAM_V = "v".intern(); - - private final static String PARAM_S = "s".intern(); - - private final static String PARAM_T = "t".intern(); - - private final static String PARAM_ST = "st".intern(); - - private final static String PARAM_P = "P".intern(); - - private final static String PARAM_WIDTH = "width".intern(); - - private final static String PARAM_CONSTANTWIDTH = "constantwidth".intern(); - private String currentDirectory; --- 99,102 ---- *************** *** 623,627 **** if (cameraProjection == CameraProjection.PERSPECTIVE) { UniformScalarFloat parameter = ! (UniformScalarFloat) parameters.getParameter(PARAM_FOV); if (parameter != null) frame.setFieldOfView(parameter.getValue()); --- 587,591 ---- if (cameraProjection == CameraProjection.PERSPECTIVE) { UniformScalarFloat parameter = ! (UniformScalarFloat) parameters.getParameter("fov"); if (parameter != null) frame.setFieldOfView(parameter.getValue()); *************** *** 690,694 **** frame.setDisplay(new Display(name, type, mode)); UniformArrayInteger parameter = ! (UniformArrayInteger) parameters.getParameter(PARAM_ORIGIN); if (parameter != null) { frame.setOriginX(parameter.getValue(0)); --- 654,658 ---- frame.setDisplay(new Display(name, type, mode)); UniformArrayInteger parameter = ! (UniformArrayInteger) parameters.getParameter("origin"); if (parameter != null) { frame.setOriginX(parameter.getValue(0)); *************** *** 709,717 **** if (name.equals("limits")) { UniformScalarInteger param1 = ! (UniformScalarInteger) parameters.getParameter(PARAM_GRIDSIZE); if (param1 != null) frame.setGridSize(param1.getValue()); UniformArrayInteger param2 = ! (UniformArrayInteger) parameters.getParameter(PARAM_BUCKETSIZE); if (param2 != null) { frame.setBucketSizeX(param2.getValue(0)); --- 673,681 ---- if (name.equals("limits")) { UniformScalarInteger param1 = ! (UniformScalarInteger) parameters.getParameter("gridsize"); if (param1 != null) frame.setGridSize(param1.getValue()); UniformArrayInteger param2 = ! (UniformArrayInteger) parameters.getParameter("bucketsize"); if (param2 != null) { frame.setBucketSizeX(param2.getValue(0)); *************** *** 720,729 **** } else if (name.equals("statistics")) { UniformScalarInteger param = ! (UniformScalarInteger) parameters.getParameter(PARAM_ENDOFFRAME); if (param != null) frame.setEndOfFrameStatistics(param.getValue() != 0); } else if (name.equals("quality")) { UniformScalarInteger param = ! (UniformScalarInteger) parameters.getParameter(PARAM_HIGHLIGHTS); if (param != null) SurfaceShader.setBetterHighlights(param.getValue() != 0); --- 684,693 ---- } else if (name.equals("statistics")) { UniformScalarInteger param = ! (UniformScalarInteger) parameters.getParameter("endofframe"); if (param != null) frame.setEndOfFrameStatistics(param.getValue() != 0); } else if (name.equals("quality")) { UniformScalarInteger param = ! (UniformScalarInteger) parameters.getParameter("highlights"); if (param != null) SurfaceShader.setBetterHighlights(param.getValue() != 0); *************** *** 734,752 **** if (name.equals("displacementbound")) { UniformScalarFloat param1 = ! (UniformScalarFloat) parameters.getParameter(PARAM_SPHERE); if (param1 != null) currentAttributes.setDisplacementBound(param1.getValue()); UniformScalarString param2 = ! (UniformScalarString) parameters.getParameter(PARAM_COORDINATESYSTEM); if (param2 != null) currentAttributes.setDisplacementBoundCoordinateSystem(param2.getValue()); } else if (name.equals("identifier")) { UniformScalarString param = ! (UniformScalarString) parameters.getParameter(PARAM_NAME); if (param != null) currentAttributes.setObjectIdentifer(param.getValue()); } else if (name.equals("trimcurve")) { UniformScalarString param = ! (UniformScalarString) parameters.getParameter(PARAM_SENSE); if (param != null) currentAttributes.setTrimCurveSense(TrimCurveSense.getNamed(param.getValue())); --- 698,716 ---- if (name.equals("displacementbound")) { UniformScalarFloat param1 = ! (UniformScalarFloat) parameters.getParameter("sphere"); if (param1 != null) currentAttributes.setDisplacementBound(param1.getValue()); UniformScalarString param2 = ! (UniformScalarString) parameters.getParameter("coordinatesystem"); if (param2 != null) currentAttributes.setDisplacementBoundCoordinateSystem(param2.getValue()); } else if (name.equals("identifier")) { UniformScalarString param = ! (UniformScalarString) parameters.getParameter("name"); if (param != null) currentAttributes.setObjectIdentifer(param.getValue()); } else if (name.equals("trimcurve")) { UniformScalarString param = ! (UniformScalarString) parameters.getParameter("sense"); if (param != null) currentAttributes.setTrimCurveSense(TrimCurveSense.getNamed(param.getValue())); *************** *** 1161,1171 **** private void setPatchMeshDefaultParameters(int nu, int nv, ParameterList parameters) { Primitive.setDefaultParameters(parameters, getAttributes()); ! VaryingScalarFloat p = (VaryingScalarFloat) parameters.getParameter(PARAM_U); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter(PARAM_V); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter(PARAM_S); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter(PARAM_T); p.expandTo(nu, nv); } --- 1125,1135 ---- private void setPatchMeshDefaultParameters(int nu, int nv, ParameterList parameters) { Primitive.setDefaultParameters(parameters, getAttributes()); ! VaryingScalarFloat p = (VaryingScalarFloat) parameters.getParameter("u"); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter("v"); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter("s"); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter("t"); p.expandTo(nu, nv); } *************** *** 1367,1375 **** private void setPolygonST(ParameterList parameters) { ! VaryingScalarFloat sParam = (VaryingScalarFloat) parameters.getParameter(PARAM_S); ! VaryingScalarFloat tParam = (VaryingScalarFloat) parameters.getParameter(PARAM_T); ! VaryingArrayFloat stParam = (VaryingArrayFloat) parameters.getParameter(PARAM_ST); VaryingScalarTuple3f pParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); if (sParam == null && stParam == null) parameters.addParameter(pParam.extract(Global.getDeclaration("s"), 0)); --- 1331,1339 ---- private void setPolygonST(ParameterList parameters) { ! VaryingScalarFloat sParam = (VaryingScalarFloat) parameters.getParameter("s"); ! VaryingScalarFloat tParam = (VaryingScalarFloat) parameters.getParameter("t"); ! VaryingArrayFloat stParam = (VaryingArrayFloat) parameters.getParameter("st"); VaryingScalarTuple3f pParam = ! (VaryingScalarTuple3f) parameters.getParameter("P"); if (sParam == null && stParam == null) parameters.addParameter(pParam.extract(Global.getDeclaration("s"), 0)); *************** *** 1383,1387 **** setPolygonST(parameters); VaryingScalarTuple3f pParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); int[] uniformIndex = new int[1]; uniformIndex[0] = 0; --- 1347,1351 ---- setPolygonST(parameters); VaryingScalarTuple3f pParam = ! (VaryingScalarTuple3f) parameters.getParameter("P"); int[] uniformIndex = new int[1]; uniformIndex[0] = 0; *************** *** 1400,1410 **** return; VaryingScalarTuple3f pParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); parameters.removeParameter("P"); VaryingScalarFloat widthParam = ! (VaryingScalarFloat) parameters.getParameter(PARAM_WIDTH); parameters.removeParameter("width"); UniformScalarFloat constantWidthParam = ! (UniformScalarFloat) parameters.getParameter(PARAM_CONSTANTWIDTH); parameters.removeParameter("constantwidth"); // TODO: same space optimization as for PointsPolygon --- 1364,1374 ---- return; VaryingScalarTuple3f pParam = ! (VaryingScalarTuple3f) parameters.getParameter("P"); parameters.removeParameter("P"); VaryingScalarFloat widthParam = ! (VaryingScalarFloat) parameters.getParameter("width"); parameters.removeParameter("width"); UniformScalarFloat constantWidthParam = ! (UniformScalarFloat) parameters.getParameter("constantwidth"); parameters.removeParameter("constantwidth"); // TODO: same space optimization as for PointsPolygon |
From: Gerardo H. <ma...@us...> - 2005-07-03 04:37:45
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9329/src/org/jrman/primitive Modified Files: Point.java Primitive.java Nurbs.java BicubicPatch.java BilinearPatch.java PointsPolygons.java Log Message: More performance enhancements. Removed unnecessary constant declarations! (Java Spec says that literal string constants are always interned). Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Primitive.java 3 Jul 2005 00:23:04 -0000 1.34 --- Primitive.java 3 Jul 2005 04:37:36 -0000 1.35 *************** *** 40,59 **** public abstract class Primitive implements Comparable { - private final static String PARAM_U = "u".intern(); - - private final static String PARAM_V = "v".intern(); - - private final static String PARAM_S = "s".intern(); - - private final static String PARAM_T = "t".intern(); - - private final static String PARAM_ST = "st".intern(); - - private final static String PARAM_N = "N".intern(); - - private final static String PARAM_CS = "Cs".intern(); - - private final static String PARAM_OS = "Os".intern(); - private static Declaration U_DECL = new Declaration("u", "varying float"); --- 40,43 ---- *************** *** 175,179 **** protected void dice_N(ShaderVariables shaderVariables) { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_N); if (param != null) param.linearDice(shaderVariables.N); --- 159,163 ---- protected void dice_N(ShaderVariables shaderVariables) { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter("N"); if (param != null) param.linearDice(shaderVariables.N); *************** *** 184,188 **** protected void dice_Cs(ShaderVariables shaderVariables) { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_CS); if (param != null) { if (param.getCount() == 4) --- 168,172 ---- protected void dice_Cs(ShaderVariables shaderVariables) { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter("Cs"); if (param != null) { if (param.getCount() == 4) *************** *** 198,202 **** protected void dice_Os(ShaderVariables shaderVariables) { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_OS); if (param != null) { if (param.getCount() == 4) --- 182,186 ---- protected void dice_Os(ShaderVariables shaderVariables) { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter("Os"); if (param != null) { if (param.getCount() == 4) *************** *** 212,216 **** protected void dice_u(ShaderVariables shaderVariables) { VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter(PARAM_U); param.linearDice(shaderVariables.u); } --- 196,200 ---- protected void dice_u(ShaderVariables shaderVariables) { VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter("u"); param.linearDice(shaderVariables.u); } *************** *** 218,222 **** protected void dice_v(ShaderVariables shaderVariables) { VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter(PARAM_V); param.linearDice(shaderVariables.v); } --- 202,206 ---- protected void dice_v(ShaderVariables shaderVariables) { VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter("v"); param.linearDice(shaderVariables.v); } *************** *** 224,228 **** protected void dice_s(ShaderVariables shaderVariables) { VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter(PARAM_S); param.linearDice(shaderVariables.s); } --- 208,212 ---- protected void dice_s(ShaderVariables shaderVariables) { VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter("s"); param.linearDice(shaderVariables.s); } *************** *** 230,234 **** protected void dice_t(ShaderVariables shaderVariables) { VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter(PARAM_T); param.linearDice(shaderVariables.t); } --- 214,218 ---- protected void dice_t(ShaderVariables shaderVariables) { VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter("t"); param.linearDice(shaderVariables.t); } *************** *** 256,260 **** public static void setDefaultParameters(ParameterList parameters, Attributes attributes) { ! Parameter parameter = parameters.getParameter(PARAM_U); if (parameter == null) { float[] u = new float[4]; --- 240,244 ---- public static void setDefaultParameters(ParameterList parameters, Attributes attributes) { ! Parameter parameter = parameters.getParameter("u"); if (parameter == null) { float[] u = new float[4]; *************** *** 265,269 **** parameters.addParameter(new VaryingScalarFloat(U_DECL, u)); } ! parameter = parameters.getParameter(PARAM_V); if (parameter == null) { float[] v = new float[4]; --- 249,253 ---- parameters.addParameter(new VaryingScalarFloat(U_DECL, u)); } ! parameter = parameters.getParameter("v"); if (parameter == null) { float[] v = new float[4]; *************** *** 274,281 **** parameters.addParameter(new VaryingScalarFloat(V_DECL, v)); } ! parameter = parameters.getParameter(PARAM_S); if (parameter == null) { VaryingArrayFloat stParam = ! (VaryingArrayFloat) parameters.getParameter(PARAM_ST); if (stParam != null) { parameters.addParameter(stParam.extract(Global.getDeclaration("s"), 0)); --- 258,265 ---- parameters.addParameter(new VaryingScalarFloat(V_DECL, v)); } ! parameter = parameters.getParameter("s"); if (parameter == null) { VaryingArrayFloat stParam = ! (VaryingArrayFloat) parameters.getParameter("st"); if (stParam != null) { parameters.addParameter(stParam.extract(Global.getDeclaration("s"), 0)); *************** *** 290,297 **** } } ! parameter = parameters.getParameter(PARAM_T); if (parameter == null) { VaryingArrayFloat stParam = ! (VaryingArrayFloat) parameters.getParameter(PARAM_ST); if (stParam != null) { parameters.addParameter(stParam.extract(Global.getDeclaration("t"), 1)); --- 274,281 ---- } } ! parameter = parameters.getParameter("t"); if (parameter == null) { VaryingArrayFloat stParam = ! (VaryingArrayFloat) parameters.getParameter("st"); if (stParam != null) { parameters.addParameter(stParam.extract(Global.getDeclaration("t"), 1)); *************** *** 306,310 **** } } ! parameters.removeParameter(PARAM_ST); } --- 290,294 ---- } } ! parameters.removeParameter("st"); } Index: Point.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Point.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Point.java 3 Jul 2005 00:23:04 -0000 1.7 --- Point.java 3 Jul 2005 04:37:36 -0000 1.8 *************** *** 36,43 **** public class Point extends Primitive { - private final static String PARAM_CS = "Cs".intern(); - - private final static String PARAM_OS = "Os".intern(); - private static Point3f tmp = new Point3f(); --- 36,39 ---- *************** *** 91,95 **** sv.N.set(sv.Ng); VaryingScalarTuple3f csParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_CS); if (csParam != null) { csParam.getValue(0, color); --- 87,91 ---- sv.N.set(sv.Ng); VaryingScalarTuple3f csParam = ! (VaryingScalarTuple3f) parameters.getParameter("Cs"); if (csParam != null) { csParam.getValue(0, color); *************** *** 98,102 **** sv.Cs.set(attributes.getColor()); VaryingScalarTuple3f osParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_OS); if (osParam != null) { osParam.getValue(0, color); --- 94,98 ---- sv.Cs.set(attributes.getColor()); VaryingScalarTuple3f osParam = ! (VaryingScalarTuple3f) parameters.getParameter("Os"); if (osParam != null) { osParam.getValue(0, color); Index: Nurbs.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Nurbs.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Nurbs.java 3 Jul 2005 00:23:04 -0000 1.11 --- Nurbs.java 3 Jul 2005 04:37:36 -0000 1.12 *************** *** 40,47 **** public class Nurbs extends Primitive { - private final static String PARAM_P = "P".intern(); - - private final static String PARAM_PW = "PW".intern(); - /* Used to determine when things are too small. */ private final static float EPSILON = 0.0000001F; --- 40,43 ---- *************** *** 145,156 **** private void extractPoints(ParameterList parameters) { VaryingScalarTuple3f param3f = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); if (param3f != null) { ! parameters.removeParameter(PARAM_P); parameters.addParameter( new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), param3f)); } VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter(PARAM_PW); //parameters.removeParameter("Pw"); points = new Point4f[nv][nu]; --- 141,152 ---- private void extractPoints(ParameterList parameters) { VaryingScalarTuple3f param3f = ! (VaryingScalarTuple3f) parameters.getParameter("P"); if (param3f != null) { ! parameters.removeParameter("P"); parameters.addParameter( new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), param3f)); } VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter("Pw"); //parameters.removeParameter("Pw"); points = new Point4f[nv][nu]; *************** *** 731,735 **** float vmax) { VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter(PARAM_PW); ParameterList result = linearInterpolateParameters(umin, umax, vmin, vmax); result.addParameter(paramHp); --- 727,731 ---- float vmax) { VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter("Pw"); ParameterList result = linearInterpolateParameters(umin, umax, vmin, vmax); result.addParameter(paramHp); Index: PointsPolygons.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/PointsPolygons.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PointsPolygons.java 3 Jul 2005 00:23:04 -0000 1.4 --- PointsPolygons.java 3 Jul 2005 04:37:36 -0000 1.5 *************** *** 31,36 **** public class PointsPolygons extends Primitive { - private final static String PARAM_P = "P".intern(); - static Point3f tmpPoint = new Point3f(); --- 31,34 ---- *************** *** 50,55 **** this.nVertices = nVertices; this.vertices = vertices; ! points = (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); ! parameters.removeParameter(PARAM_P); } --- 48,53 ---- this.nVertices = nVertices; this.vertices = vertices; ! points = (VaryingScalarTuple3f) parameters.getParameter("P"); ! parameters.removeParameter("P"); } Index: BilinearPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BilinearPatch.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BilinearPatch.java 3 Jul 2005 00:23:04 -0000 1.8 --- BilinearPatch.java 3 Jul 2005 04:37:36 -0000 1.9 *************** *** 32,37 **** public class BilinearPatch extends Primitive { - private final static String PARAM_P = "P".intern(); - private static Point3f P00 = new Point3f(); --- 32,35 ---- *************** *** 50,54 **** private void extractPoints() { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); param.getValue(0, P00); param.getValue(1, P10); --- 48,52 ---- private void extractPoints() { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter("P"); param.getValue(0, P00); param.getValue(1, P10); *************** *** 96,100 **** protected void dice_P(ShaderVariables sv) { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); param.linearDice(sv.P); } --- 94,98 ---- protected void dice_P(ShaderVariables sv) { VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter("P"); param.linearDice(sv.P); } Index: BicubicPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BicubicPatch.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** BicubicPatch.java 3 Jul 2005 00:23:04 -0000 1.15 --- BicubicPatch.java 3 Jul 2005 04:37:36 -0000 1.16 *************** *** 38,45 **** public class BicubicPatch extends Primitive { - private final static String PARAM_P = "P".intern(); - - private final static String PARAM_PW = "Pw".intern(); - private static Point4f P00 = new Point4f(); --- 38,41 ---- *************** *** 126,133 **** private void extractPoints() { VaryingScalarTuple3f param3f = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); if (param3f != null) { ! parameters.removeParameter(PARAM_P); parameters.addParameter( new VaryingScalarHPoint(new Declaration("Pw", --- 122,129 ---- private void extractPoints() { VaryingScalarTuple3f param3f = ! (VaryingScalarTuple3f) parameters.getParameter("P"); if (param3f != null) { ! parameters.removeParameter("P"); parameters.addParameter( new VaryingScalarHPoint(new Declaration("Pw", *************** *** 136,140 **** } VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter(PARAM_PW); paramHp.getValue(0, P00); --- 132,136 ---- } VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter("Pw"); paramHp.getValue(0, P00); *************** *** 158,162 **** private void setPoints() { VaryingScalarHPoint param = ! (VaryingScalarHPoint) parameters.getParameter(PARAM_PW); param.setValue(0, P00); param.setValue(1, P10); --- 154,158 ---- private void setPoints() { VaryingScalarHPoint param = ! (VaryingScalarHPoint) parameters.getParameter("Pw"); param.setValue(0, P00); param.setValue(1, P10); |
From: Gerardo H. <ma...@us...> - 2005-07-03 04:37:44
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser/keywords In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9329/src/org/jrman/parser/keywords Modified Files: AbstractKeywordParser.java Log Message: More performance enhancements. Removed unnecessary constant declarations! (Java Spec says that literal string constants are always interned). Index: AbstractKeywordParser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/keywords/AbstractKeywordParser.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AbstractKeywordParser.java 17 Sep 2004 06:33:45 -0000 1.12 --- AbstractKeywordParser.java 3 Jul 2005 04:37:36 -0000 1.13 *************** *** 23,28 **** --- 23,30 ---- import java.io.StreamTokenizer; import java.util.ArrayList; + import java.util.HashMap; import java.util.HashSet; import java.util.List; + import java.util.Map; import java.util.Set; *************** *** 34,39 **** import org.jrman.parameters.ParameterList; import org.jrman.parser.Global; - import org.jrman.parser.Tokenizer; import org.jrman.parser.Parser; public abstract class AbstractKeywordParser implements KeywordParser { --- 36,41 ---- import org.jrman.parameters.ParameterList; import org.jrman.parser.Global; import org.jrman.parser.Parser; + import org.jrman.parser.Tokenizer; public abstract class AbstractKeywordParser implements KeywordParser { *************** *** 64,67 **** --- 66,71 ---- protected Set validStates = new HashSet(); + + private Map declarationsCache = new HashMap(); public static void reset() { *************** *** 327,333 **** if (pos == -1) throw new IllegalArgumentException(); String decl = name.substring(0, pos); ! name = name.substring(pos + 1); ! return new Declaration(name, decl); } --- 331,342 ---- if (pos == -1) throw new IllegalArgumentException(); + declaration = (Declaration) declarationsCache.get(name); + if (declaration != null) + return declaration; String decl = name.substring(0, pos); ! String vname = name.substring(pos + 1); ! declaration = new Declaration(vname, decl); ! declarationsCache.put(name, declaration); ! return declaration; } |
From: Gerardo H. <ma...@us...> - 2005-07-03 04:37:44
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9329/src/org/jrman/shaders Modified Files: Shader.java LightPointlight.java Log Message: More performance enhancements. Removed unnecessary constant declarations! (Java Spec says that literal string constants are always interned). Index: LightPointlight.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/LightPointlight.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LightPointlight.java 16 Sep 2004 04:16:42 -0000 1.5 --- LightPointlight.java 3 Jul 2005 04:37:36 -0000 1.6 *************** *** 36,40 **** public class LightPointlight extends LightShader { ! private static Point3f from = new Point3f(); --- 36,40 ---- public class LightPointlight extends LightShader { ! private static Point3f from = new Point3f(); *************** *** 80,84 **** float angle) { super.shade(sv, P, N, angle); ! UniformScalarFloat paramIntensity = (UniformScalarFloat) getParameter(sv, "intensity"); float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = --- 80,85 ---- float angle) { super.shade(sv, P, N, angle); ! UniformScalarFloat paramIntensity = ! (UniformScalarFloat) getParameter(sv, "intensity"); float intensity = paramIntensity.getValue(); UniformScalarTuple3f paramLightcolor = Index: Shader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/Shader.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Shader.java 3 Jul 2005 00:23:03 -0000 1.6 --- Shader.java 3 Jul 2005 04:37:36 -0000 1.7 *************** *** 49,53 **** protected Parameter getParameter(ShaderVariables sv, String name) { - name = name.intern(); Parameter result = sv.parameters.getParameter(name); if (result != null) --- 49,52 ---- *************** *** 72,76 **** public float messagePassing(String paramName, Object resultHolder) { ! Parameter param = parameters.getParameter(paramName.intern()); if (param == null) return 0f; --- 71,75 ---- public float messagePassing(String paramName, Object resultHolder) { ! Parameter param = parameters.getParameter(paramName); if (param == null) return 0f; |
From: Gerardo H. <ma...@us...> - 2005-07-03 00:23:16
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parameters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11732/src/org/jrman/parameters Modified Files: ParameterList.java Declaration.java Log Message: More performance optimizations. Index: Declaration.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parameters/Declaration.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Declaration.java 12 Apr 2004 04:37:25 -0000 1.6 --- Declaration.java 3 Jul 2005 00:23:04 -0000 1.7 *************** *** 131,135 **** public Declaration(String name, StorageClass storageClass, Type type, int count) { ! this.name = name; this.storageClass = storageClass; this.type = type; --- 131,135 ---- public Declaration(String name, StorageClass storageClass, Type type, int count) { ! this.name = name.intern(); this.storageClass = storageClass; this.type = type; *************** *** 138,142 **** public Declaration(String name, String decl) { ! this.name = name; count = 1; try { --- 138,142 ---- public Declaration(String name, String decl) { ! this.name = name.intern(); count = 1; try { *************** *** 193,197 **** Declaration d = (Declaration) other; return ( ! d.name.equals(name) && d.storageClass == storageClass && d.type == type --- 193,197 ---- Declaration d = (Declaration) other; return ( ! d.name == name && d.storageClass == storageClass && d.type == type Index: ParameterList.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parameters/ParameterList.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ParameterList.java 7 Nov 2004 22:42:18 -0000 1.8 --- ParameterList.java 3 Jul 2005 00:23:04 -0000 1.9 *************** *** 20,34 **** package org.jrman.parameters; - import java.util.ArrayList; - import java.util.List; public class ParameterList { ! final private List list = new ArrayList(); public ParameterList() { } public ParameterList(ParameterList pl) { for (int i = 0; i < pl.getParameterCount(); i++) addParameter(pl.getParameter(i)); --- 20,40 ---- package org.jrman.parameters; public class ParameterList { ! private Parameter[] list; ! ! int count = 0; public ParameterList() { + list = new Parameter[8]; + } + + public ParameterList(int size) { + list = new Parameter[size]; } public ParameterList(ParameterList pl) { + list = new Parameter[pl.getParameterCount()]; for (int i = 0; i < pl.getParameterCount(); i++) addParameter(pl.getParameter(i)); *************** *** 36,40 **** public ParameterList linearInterpolate(float uMin, float uMax, float vMin, float vMax) { ! ParameterList pl = new ParameterList(); for (int i = 0; i < getParameterCount(); i++) pl.addParameter(getParameter(i).linearInterpolate(uMin, uMax, vMin, vMax)); --- 42,46 ---- public ParameterList linearInterpolate(float uMin, float uMax, float vMin, float vMax) { ! ParameterList pl = new ParameterList(count); for (int i = 0; i < getParameterCount(); i++) pl.addParameter(getParameter(i).linearInterpolate(uMin, uMax, vMin, vMax)); *************** *** 46,50 **** int[] varyingIndexes, int[] vertexIndexes) { ! ParameterList pl = new ParameterList(); for (int i = 0; i < getParameterCount(); i++) { Parameter p = getParameter(i); --- 52,56 ---- int[] varyingIndexes, int[] vertexIndexes) { ! ParameterList pl = new ParameterList(count); for (int i = 0; i < getParameterCount(); i++) { Parameter p = getParameter(i); *************** *** 63,74 **** public void addParameter(Parameter parameter) { ! list.add(parameter); } public Parameter getParameter(String name) { Parameter result = null; ! for (int i = list.size() - 1; i >= 0; i--) { ! Parameter parameter = (Parameter) list.get(i); ! if (parameter.getDeclaration().getName().equals(name)) { result = parameter; break; --- 69,85 ---- public void addParameter(Parameter parameter) { ! if (count == list.length) { ! Parameter[] tmp = new Parameter[count * 2]; ! System.arraycopy(list, 0, tmp, 0, count); ! list = tmp; ! } ! list[count++] = parameter; } public Parameter getParameter(String name) { Parameter result = null; ! for (int i = count - 1; i >= 0; i--) { ! Parameter parameter = list[i]; ! if (parameter.getDeclaration().getName() == name) { result = parameter; break; *************** *** 79,94 **** public int getParameterCount() { ! return list.size(); } public Parameter getParameter(int index) { ! return (Parameter) list.get(index); } public void removeParameter(String name) { ! for (int i = 0; i < list.size(); i++) { ! Parameter parameter = (Parameter) list.get(i); ! if (parameter.getDeclaration().getName().equals(name)) { ! list.remove(i); break; } --- 90,106 ---- public int getParameterCount() { ! return count; } public Parameter getParameter(int index) { ! return list[index]; } public void removeParameter(String name) { ! for (int i = 0; i < count; i++) { ! Parameter parameter = list[i]; ! if (parameter.getDeclaration().getName() == name) { ! System.arraycopy(list, i + 1, list, i, count - i - 1); ! count--; break; } |
From: Gerardo H. <ma...@us...> - 2005-07-03 00:23:15
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11732/src/org/jrman/parser Modified Files: Parser.java Log Message: More performance optimizations. Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** Parser.java 20 Dec 2004 03:22:54 -0000 1.102 --- Parser.java 3 Jul 2005 00:23:04 -0000 1.103 *************** *** 99,102 **** --- 99,138 ---- private final static String KEYWORD_PREFIX = "org.jrman.parser.keywords.Keyword"; + private final static String PARAM_FOV = "fov".intern(); + + private final static String PARAM_NAME = "name".intern(); + + private final static String PARAM_SPHERE = "sphere".intern(); + + private final static String PARAM_SENSE = "sense".intern(); + + private final static String PARAM_ORIGIN = "origin".intern(); + + private final static String PARAM_GRIDSIZE = "gridsize".intern(); + + private final static String PARAM_BUCKETSIZE = "bucketsize".intern(); + + private final static String PARAM_COORDINATESYSTEM = "coordinatesystem".intern(); + + private final static String PARAM_ENDOFFRAME = "endofframe".intern(); + + private final static String PARAM_HIGHLIGHTS = "highlights".intern(); + + private final static String PARAM_U = "u".intern(); + + private final static String PARAM_V = "v".intern(); + + private final static String PARAM_S = "s".intern(); + + private final static String PARAM_T = "t".intern(); + + private final static String PARAM_ST = "st".intern(); + + private final static String PARAM_P = "P".intern(); + + private final static String PARAM_WIDTH = "width".intern(); + + private final static String PARAM_CONSTANTWIDTH = "constantwidth".intern(); + private String currentDirectory; *************** *** 586,590 **** frame.setCameraProjection(cameraProjection); if (cameraProjection == CameraProjection.PERSPECTIVE) { ! UniformScalarFloat parameter = (UniformScalarFloat) parameters.getParameter("fov"); if (parameter != null) frame.setFieldOfView(parameter.getValue()); --- 622,627 ---- frame.setCameraProjection(cameraProjection); if (cameraProjection == CameraProjection.PERSPECTIVE) { ! UniformScalarFloat parameter = ! (UniformScalarFloat) parameters.getParameter(PARAM_FOV); if (parameter != null) frame.setFieldOfView(parameter.getValue()); *************** *** 653,657 **** frame.setDisplay(new Display(name, type, mode)); UniformArrayInteger parameter = ! (UniformArrayInteger) parameters.getParameter("origin"); if (parameter != null) { frame.setOriginX(parameter.getValue(0)); --- 690,694 ---- frame.setDisplay(new Display(name, type, mode)); UniformArrayInteger parameter = ! (UniformArrayInteger) parameters.getParameter(PARAM_ORIGIN); if (parameter != null) { frame.setOriginX(parameter.getValue(0)); *************** *** 672,680 **** if (name.equals("limits")) { UniformScalarInteger param1 = ! (UniformScalarInteger) parameters.getParameter("gridsize"); if (param1 != null) frame.setGridSize(param1.getValue()); UniformArrayInteger param2 = ! (UniformArrayInteger) parameters.getParameter("bucketsize"); if (param2 != null) { frame.setBucketSizeX(param2.getValue(0)); --- 709,717 ---- if (name.equals("limits")) { UniformScalarInteger param1 = ! (UniformScalarInteger) parameters.getParameter(PARAM_GRIDSIZE); if (param1 != null) frame.setGridSize(param1.getValue()); UniformArrayInteger param2 = ! (UniformArrayInteger) parameters.getParameter(PARAM_BUCKETSIZE); if (param2 != null) { frame.setBucketSizeX(param2.getValue(0)); *************** *** 683,692 **** } else if (name.equals("statistics")) { UniformScalarInteger param = ! (UniformScalarInteger) parameters.getParameter("endofframe"); if (param != null) frame.setEndOfFrameStatistics(param.getValue() != 0); } else if (name.equals("quality")) { UniformScalarInteger param = ! (UniformScalarInteger) parameters.getParameter("highlights"); if (param != null) SurfaceShader.setBetterHighlights(param.getValue() != 0); --- 720,729 ---- } else if (name.equals("statistics")) { UniformScalarInteger param = ! (UniformScalarInteger) parameters.getParameter(PARAM_ENDOFFRAME); if (param != null) frame.setEndOfFrameStatistics(param.getValue() != 0); } else if (name.equals("quality")) { UniformScalarInteger param = ! (UniformScalarInteger) parameters.getParameter(PARAM_HIGHLIGHTS); if (param != null) SurfaceShader.setBetterHighlights(param.getValue() != 0); *************** *** 696,712 **** public void setAttribute(String name, ParameterList parameters) { if (name.equals("displacementbound")) { ! UniformScalarFloat param1 = (UniformScalarFloat) parameters.getParameter("sphere"); if (param1 != null) currentAttributes.setDisplacementBound(param1.getValue()); UniformScalarString param2 = ! (UniformScalarString) parameters.getParameter("coordinatesystem"); if (param2 != null) currentAttributes.setDisplacementBoundCoordinateSystem(param2.getValue()); } else if (name.equals("identifier")) { ! UniformScalarString param = (UniformScalarString) parameters.getParameter("name"); if (param != null) currentAttributes.setObjectIdentifer(param.getValue()); } else if (name.equals("trimcurve")) { ! UniformScalarString param = (UniformScalarString) parameters.getParameter("sense"); if (param != null) currentAttributes.setTrimCurveSense(TrimCurveSense.getNamed(param.getValue())); --- 733,752 ---- public void setAttribute(String name, ParameterList parameters) { if (name.equals("displacementbound")) { ! UniformScalarFloat param1 = ! (UniformScalarFloat) parameters.getParameter(PARAM_SPHERE); if (param1 != null) currentAttributes.setDisplacementBound(param1.getValue()); UniformScalarString param2 = ! (UniformScalarString) parameters.getParameter(PARAM_COORDINATESYSTEM); if (param2 != null) currentAttributes.setDisplacementBoundCoordinateSystem(param2.getValue()); } else if (name.equals("identifier")) { ! UniformScalarString param = ! (UniformScalarString) parameters.getParameter(PARAM_NAME); if (param != null) currentAttributes.setObjectIdentifer(param.getValue()); } else if (name.equals("trimcurve")) { ! UniformScalarString param = ! (UniformScalarString) parameters.getParameter(PARAM_SENSE); if (param != null) currentAttributes.setTrimCurveSense(TrimCurveSense.getNamed(param.getValue())); *************** *** 1121,1131 **** private void setPatchMeshDefaultParameters(int nu, int nv, ParameterList parameters) { Primitive.setDefaultParameters(parameters, getAttributes()); ! VaryingScalarFloat p = (VaryingScalarFloat) parameters.getParameter("u"); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter("v"); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter("s"); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter("t"); p.expandTo(nu, nv); } --- 1161,1171 ---- private void setPatchMeshDefaultParameters(int nu, int nv, ParameterList parameters) { Primitive.setDefaultParameters(parameters, getAttributes()); ! VaryingScalarFloat p = (VaryingScalarFloat) parameters.getParameter(PARAM_U); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter(PARAM_V); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter(PARAM_S); p.expandTo(nu, nv); ! p = (VaryingScalarFloat) parameters.getParameter(PARAM_T); p.expandTo(nu, nv); } *************** *** 1327,1334 **** private void setPolygonST(ParameterList parameters) { ! VaryingScalarFloat sParam = (VaryingScalarFloat) parameters.getParameter("s"); ! VaryingScalarFloat tParam = (VaryingScalarFloat) parameters.getParameter("t"); ! VaryingArrayFloat stParam = (VaryingArrayFloat) parameters.getParameter("st"); ! VaryingScalarTuple3f pParam = (VaryingScalarTuple3f) parameters.getParameter("P"); if (sParam == null && stParam == null) parameters.addParameter(pParam.extract(Global.getDeclaration("s"), 0)); --- 1367,1375 ---- private void setPolygonST(ParameterList parameters) { ! VaryingScalarFloat sParam = (VaryingScalarFloat) parameters.getParameter(PARAM_S); ! VaryingScalarFloat tParam = (VaryingScalarFloat) parameters.getParameter(PARAM_T); ! VaryingArrayFloat stParam = (VaryingArrayFloat) parameters.getParameter(PARAM_ST); ! VaryingScalarTuple3f pParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); if (sParam == null && stParam == null) parameters.addParameter(pParam.extract(Global.getDeclaration("s"), 0)); *************** *** 1341,1345 **** return; setPolygonST(parameters); ! VaryingScalarTuple3f pParam = (VaryingScalarTuple3f) parameters.getParameter("P"); int[] uniformIndex = new int[1]; uniformIndex[0] = 0; --- 1382,1387 ---- return; setPolygonST(parameters); ! VaryingScalarTuple3f pParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); int[] uniformIndex = new int[1]; uniformIndex[0] = 0; *************** *** 1357,1366 **** if (inAreaLightSource) return; ! VaryingScalarTuple3f pParam = (VaryingScalarTuple3f) parameters.getParameter("P"); parameters.removeParameter("P"); ! VaryingScalarFloat widthParam = (VaryingScalarFloat) parameters.getParameter("width"); parameters.removeParameter("width"); UniformScalarFloat constantWidthParam = ! (UniformScalarFloat) parameters.getParameter("constantwidth"); parameters.removeParameter("constantwidth"); // TODO: same space optimization as for PointsPolygon --- 1399,1410 ---- if (inAreaLightSource) return; ! VaryingScalarTuple3f pParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); parameters.removeParameter("P"); ! VaryingScalarFloat widthParam = ! (VaryingScalarFloat) parameters.getParameter(PARAM_WIDTH); parameters.removeParameter("width"); UniformScalarFloat constantWidthParam = ! (UniformScalarFloat) parameters.getParameter(PARAM_CONSTANTWIDTH); parameters.removeParameter("constantwidth"); // TODO: same space optimization as for PointsPolygon |
From: Gerardo H. <ma...@us...> - 2005-07-03 00:23:15
|
Update of /cvsroot/jrman/drafts/src/org/jrman/shaders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11732/src/org/jrman/shaders Modified Files: Shader.java Log Message: More performance optimizations. Index: Shader.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/shaders/Shader.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Shader.java 9 Dec 2003 04:51:52 -0000 1.5 --- Shader.java 3 Jul 2005 00:23:03 -0000 1.6 *************** *** 49,52 **** --- 49,53 ---- protected Parameter getParameter(ShaderVariables sv, String name) { + name = name.intern(); Parameter result = sv.parameters.getParameter(name); if (result != null) *************** *** 71,75 **** public float messagePassing(String paramName, Object resultHolder) { ! Parameter param = parameters.getParameter(paramName); if (param == null) return 0f; --- 72,76 ---- public float messagePassing(String paramName, Object resultHolder) { ! Parameter param = parameters.getParameter(paramName.intern()); if (param == null) return 0f; |
From: Gerardo H. <ma...@us...> - 2005-07-03 00:23:15
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11732/src/org/jrman/primitive Modified Files: Point.java Primitive.java Nurbs.java BicubicPatch.java BilinearPatch.java PointsPolygons.java Log Message: More performance optimizations. Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Primitive.java 12 Apr 2004 05:05:56 -0000 1.33 --- Primitive.java 3 Jul 2005 00:23:04 -0000 1.34 *************** *** 39,42 **** --- 39,58 ---- public abstract class Primitive implements Comparable { + + private final static String PARAM_U = "u".intern(); + + private final static String PARAM_V = "v".intern(); + + private final static String PARAM_S = "s".intern(); + + private final static String PARAM_T = "t".intern(); + + private final static String PARAM_ST = "st".intern(); + + private final static String PARAM_N = "N".intern(); + + private final static String PARAM_CS = "Cs".intern(); + + private final static String PARAM_OS = "Os".intern(); private static Declaration U_DECL = new Declaration("u", "varying float"); *************** *** 158,162 **** protected void dice_N(ShaderVariables shaderVariables) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("N"); if (param != null) param.linearDice(shaderVariables.N); --- 174,179 ---- protected void dice_N(ShaderVariables shaderVariables) { ! VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_N); if (param != null) param.linearDice(shaderVariables.N); *************** *** 166,170 **** protected void dice_Cs(ShaderVariables shaderVariables) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("Cs"); if (param != null) { if (param.getCount() == 4) --- 183,188 ---- protected void dice_Cs(ShaderVariables shaderVariables) { ! VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_CS); if (param != null) { if (param.getCount() == 4) *************** *** 179,183 **** protected void dice_Os(ShaderVariables shaderVariables) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("Os"); if (param != null) { if (param.getCount() == 4) --- 197,202 ---- protected void dice_Os(ShaderVariables shaderVariables) { ! VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_OS); if (param != null) { if (param.getCount() == 4) *************** *** 192,211 **** protected void dice_u(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = (VaryingScalarFloat) parameters.getParameter("u"); param.linearDice(shaderVariables.u); } protected void dice_v(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = (VaryingScalarFloat) parameters.getParameter("v"); param.linearDice(shaderVariables.v); } protected void dice_s(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = (VaryingScalarFloat) parameters.getParameter("s"); param.linearDice(shaderVariables.s); } protected void dice_t(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = (VaryingScalarFloat) parameters.getParameter("t"); param.linearDice(shaderVariables.t); } --- 211,234 ---- protected void dice_u(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter(PARAM_U); param.linearDice(shaderVariables.u); } protected void dice_v(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter(PARAM_V); param.linearDice(shaderVariables.v); } protected void dice_s(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter(PARAM_S); param.linearDice(shaderVariables.s); } protected void dice_t(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = ! (VaryingScalarFloat) parameters.getParameter(PARAM_T); param.linearDice(shaderVariables.t); } *************** *** 233,237 **** public static void setDefaultParameters(ParameterList parameters, Attributes attributes) { ! Parameter parameter = parameters.getParameter("u"); if (parameter == null) { float[] u = new float[4]; --- 256,260 ---- public static void setDefaultParameters(ParameterList parameters, Attributes attributes) { ! Parameter parameter = parameters.getParameter(PARAM_U); if (parameter == null) { float[] u = new float[4]; *************** *** 242,246 **** parameters.addParameter(new VaryingScalarFloat(U_DECL, u)); } ! parameter = parameters.getParameter("v"); if (parameter == null) { float[] v = new float[4]; --- 265,269 ---- parameters.addParameter(new VaryingScalarFloat(U_DECL, u)); } ! parameter = parameters.getParameter(PARAM_V); if (parameter == null) { float[] v = new float[4]; *************** *** 251,257 **** parameters.addParameter(new VaryingScalarFloat(V_DECL, v)); } ! parameter = parameters.getParameter("s"); if (parameter == null) { ! VaryingArrayFloat stParam = (VaryingArrayFloat) parameters.getParameter("st"); if (stParam != null) { parameters.addParameter(stParam.extract(Global.getDeclaration("s"), 0)); --- 274,281 ---- parameters.addParameter(new VaryingScalarFloat(V_DECL, v)); } ! parameter = parameters.getParameter(PARAM_S); if (parameter == null) { ! VaryingArrayFloat stParam = ! (VaryingArrayFloat) parameters.getParameter(PARAM_ST); if (stParam != null) { parameters.addParameter(stParam.extract(Global.getDeclaration("s"), 0)); *************** *** 266,272 **** } } ! parameter = parameters.getParameter("t"); if (parameter == null) { ! VaryingArrayFloat stParam = (VaryingArrayFloat) parameters.getParameter("st"); if (stParam != null) { parameters.addParameter(stParam.extract(Global.getDeclaration("t"), 1)); --- 290,297 ---- } } ! parameter = parameters.getParameter(PARAM_T); if (parameter == null) { ! VaryingArrayFloat stParam = ! (VaryingArrayFloat) parameters.getParameter(PARAM_ST); if (stParam != null) { parameters.addParameter(stParam.extract(Global.getDeclaration("t"), 1)); *************** *** 281,285 **** } } ! parameters.removeParameter("st"); } --- 306,310 ---- } } ! parameters.removeParameter(PARAM_ST); } Index: Point.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Point.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Point.java 20 Dec 2004 03:22:50 -0000 1.6 --- Point.java 3 Jul 2005 00:23:04 -0000 1.7 *************** *** 35,38 **** --- 35,42 ---- public class Point extends Primitive { + + private final static String PARAM_CS = "Cs".intern(); + + private final static String PARAM_OS = "Os".intern(); private static Point3f tmp = new Point3f(); *************** *** 86,90 **** dice_PandNg(sv); sv.N.set(sv.Ng); ! VaryingScalarTuple3f csParam = (VaryingScalarTuple3f) parameters.getParameter("Cs"); if (csParam != null) { csParam.getValue(0, color); --- 90,95 ---- dice_PandNg(sv); sv.N.set(sv.Ng); ! VaryingScalarTuple3f csParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_CS); if (csParam != null) { csParam.getValue(0, color); *************** *** 92,96 **** } else sv.Cs.set(attributes.getColor()); ! VaryingScalarTuple3f osParam = (VaryingScalarTuple3f) parameters.getParameter("Os"); if (osParam != null) { osParam.getValue(0, color); --- 97,102 ---- } else sv.Cs.set(attributes.getColor()); ! VaryingScalarTuple3f osParam = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_OS); if (osParam != null) { osParam.getValue(0, color); Index: Nurbs.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Nurbs.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Nurbs.java 27 Jun 2005 05:23:49 -0000 1.10 --- Nurbs.java 3 Jul 2005 00:23:04 -0000 1.11 *************** *** 39,42 **** --- 39,46 ---- public class Nurbs extends Primitive { + + private final static String PARAM_P = "P".intern(); + + private final static String PARAM_PW = "PW".intern(); /* Used to determine when things are too small. */ *************** *** 140,150 **** private void extractPoints(ParameterList parameters) { ! VaryingScalarTuple3f param3f = (VaryingScalarTuple3f) parameters.getParameter("P"); if (param3f != null) { ! parameters.removeParameter("P"); parameters.addParameter( new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), param3f)); } ! VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); //parameters.removeParameter("Pw"); points = new Point4f[nv][nu]; --- 144,156 ---- private void extractPoints(ParameterList parameters) { ! VaryingScalarTuple3f param3f = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); if (param3f != null) { ! parameters.removeParameter(PARAM_P); parameters.addParameter( new VaryingScalarHPoint(new Declaration("Pw", "vertex hpoint"), param3f)); } ! VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter(PARAM_PW); //parameters.removeParameter("Pw"); points = new Point4f[nv][nu]; *************** *** 724,728 **** float vmin, float vmax) { ! VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); ParameterList result = linearInterpolateParameters(umin, umax, vmin, vmax); result.addParameter(paramHp); --- 730,735 ---- float vmin, float vmax) { ! VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter(PARAM_PW); ParameterList result = linearInterpolateParameters(umin, umax, vmin, vmax); result.addParameter(paramHp); Index: PointsPolygons.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/PointsPolygons.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PointsPolygons.java 9 Apr 2004 22:33:22 -0000 1.3 --- PointsPolygons.java 3 Jul 2005 00:23:04 -0000 1.4 *************** *** 30,33 **** --- 30,35 ---- public class PointsPolygons extends Primitive { + + private final static String PARAM_P = "P".intern(); static Point3f tmpPoint = new Point3f(); *************** *** 48,53 **** this.nVertices = nVertices; this.vertices = vertices; ! points = (VaryingScalarTuple3f) parameters.getParameter("P"); ! parameters.removeParameter("P"); } --- 50,55 ---- this.nVertices = nVertices; this.vertices = vertices; ! points = (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); ! parameters.removeParameter(PARAM_P); } Index: BilinearPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BilinearPatch.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** BilinearPatch.java 8 Apr 2004 17:34:38 -0000 1.7 --- BilinearPatch.java 3 Jul 2005 00:23:04 -0000 1.8 *************** *** 31,34 **** --- 31,36 ---- public class BilinearPatch extends Primitive { + + private final static String PARAM_P = "P".intern(); private static Point3f P00 = new Point3f(); *************** *** 47,51 **** private void extractPoints() { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("P"); param.getValue(0, P00); param.getValue(1, P10); --- 49,54 ---- private void extractPoints() { ! VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); param.getValue(0, P00); param.getValue(1, P10); *************** *** 92,96 **** protected void dice_P(ShaderVariables sv) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("P"); param.linearDice(sv.P); } --- 95,100 ---- protected void dice_P(ShaderVariables sv) { ! VaryingScalarTuple3f param = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); param.linearDice(sv.P); } Index: BicubicPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BicubicPatch.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** BicubicPatch.java 18 Sep 2004 21:19:05 -0000 1.14 --- BicubicPatch.java 3 Jul 2005 00:23:04 -0000 1.15 *************** *** 37,40 **** --- 37,44 ---- public class BicubicPatch extends Primitive { + + private final static String PARAM_P = "P".intern(); + + private final static String PARAM_PW = "Pw".intern(); private static Point4f P00 = new Point4f(); *************** *** 121,128 **** private void extractPoints() { ! VaryingScalarTuple3f param3f = (VaryingScalarTuple3f) parameters.getParameter("P"); if (param3f != null) { ! parameters.removeParameter("P"); parameters.addParameter( new VaryingScalarHPoint(new Declaration("Pw", --- 125,133 ---- private void extractPoints() { ! VaryingScalarTuple3f param3f = ! (VaryingScalarTuple3f) parameters.getParameter(PARAM_P); if (param3f != null) { ! parameters.removeParameter(PARAM_P); parameters.addParameter( new VaryingScalarHPoint(new Declaration("Pw", *************** *** 130,134 **** Declaration.Type.HPOINT, 1), param3f)); } ! VaryingScalarHPoint paramHp = (VaryingScalarHPoint) parameters.getParameter("Pw"); paramHp.getValue(0, P00); --- 135,140 ---- Declaration.Type.HPOINT, 1), param3f)); } ! VaryingScalarHPoint paramHp = ! (VaryingScalarHPoint) parameters.getParameter(PARAM_PW); paramHp.getValue(0, P00); *************** *** 151,155 **** private void setPoints() { ! VaryingScalarHPoint param = (VaryingScalarHPoint) parameters.getParameter("Pw"); param.setValue(0, P00); param.setValue(1, P10); --- 157,162 ---- private void setPoints() { ! VaryingScalarHPoint param = ! (VaryingScalarHPoint) parameters.getParameter(PARAM_PW); param.setValue(0, P00); param.setValue(1, P10); |