From: Holger Z. <hz...@us...> - 2004-07-12 22:08:18
|
Update of /cvsroot/jake2/jake2/src/jake2/render/jogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28123/src/jake2/render/jogl Modified Files: Image.java Warp.java Model.java Mesh.java Light.java Log Message: small optimizations Index: Light.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Light.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Light.java 9 Jul 2004 06:50:48 -0000 1.4 --- Light.java 12 Jul 2004 22:08:04 -0000 1.5 *************** *** 231,239 **** int RecursiveLightPoint (mnode_t node, float[] start, float[] end) { ! float front, back, frac; ! boolean side; ! int sideIndex; ! cplane_t plane; ! float[] mid = {0, 0, 0}; msurface_t surf; int s, t, ds, dt; --- 231,237 ---- int RecursiveLightPoint (mnode_t node, float[] start, float[] end) { ! if (node.contents != -1) ! return -1; // didn't hit anything ! msurface_t surf; int s, t, ds, dt; *************** *** 242,263 **** ByteBuffer lightmap; int maps; ! int r; ! ! if (node.contents != -1) ! return -1; // didn't hit anything // calculate mid point // FIXME: optimize for axial ! plane = node.plane; ! front = Math3D.DotProduct (start, plane.normal) - plane.dist; ! back = Math3D.DotProduct (end, plane.normal) - plane.dist; ! side = (front < 0); ! sideIndex = (side) ? 1 : 0; if ( (back < 0) == side) return RecursiveLightPoint (node.children[sideIndex], start, end); ! frac = front / (front-back); mid[0] = start[0] + (end[0] - start[0])*frac; mid[1] = start[1] + (end[1] - start[1])*frac; --- 240,258 ---- ByteBuffer lightmap; int maps; ! float[] mid = {0, 0, 0}; // calculate mid point // FIXME: optimize for axial ! cplane_t plane = node.plane; ! float front = Math3D.DotProduct (start, plane.normal) - plane.dist; ! float back = Math3D.DotProduct (end, plane.normal) - plane.dist; ! boolean side = (front < 0); ! int sideIndex = (side) ? 1 : 0; if ( (back < 0) == side) return RecursiveLightPoint (node.children[sideIndex], start, end); ! float frac = front / (front-back); mid[0] = start[0] + (end[0] - start[0])*frac; mid[1] = start[1] + (end[1] - start[1])*frac; *************** *** 265,269 **** // go down front side ! r = RecursiveLightPoint (node.children[sideIndex], start, mid); if (r >= 0) return r; // hit something --- 260,264 ---- // go down front side ! int r = RecursiveLightPoint (node.children[sideIndex], start, mid); if (r >= 0) return r; // hit something *************** *** 277,280 **** --- 272,276 ---- int surfIndex = node.firstsurface; + float[] scale = {0, 0, 0}; for (i=0 ; i<node.numsurfaces ; i++, surfIndex++) { *************** *** 310,320 **** if (lightmap != null) { ! float[] scale = {0, 0, 0}; lightmapIndex += 3 * (dt * ((surf.extents[0] >> 4) + 1) + ds); for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++) { ! for (i=0 ; i<3 ; i++) ! scale[i] = gl_modulate.value * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i]; pointcolor[0] += (lightmap.get(lightmapIndex + 0) & 0xFF) * scale[0] * (1.0f/255); --- 306,319 ---- if (lightmap != null) { ! //float[] scale = {0, 0, 0}; ! float[] rgb; lightmapIndex += 3 * (dt * ((surf.extents[0] >> 4) + 1) + ds); for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++) { ! rgb = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb; ! scale[0] = gl_modulate.value * rgb[0]; ! scale[1] = gl_modulate.value * rgb[1]; ! scale[2] = gl_modulate.value * rgb[2]; pointcolor[0] += (lightmap.get(lightmapIndex + 0) & 0xFF) * scale[0] * (1.0f/255); *************** *** 326,329 **** --- 325,329 ---- return 1; } + // go down back side return RecursiveLightPoint (node.children[1 - sideIndex], mid, end); *************** *** 341,349 **** float[] end = {0, 0, 0}; - float r; - int lnum; dlight_t dl; - float light; - float[] dist = {0, 0, 0}; float add; --- 341,345 ---- *************** *** 358,362 **** end[2] = p[2] - 2048; ! r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); if (r == -1) --- 354,358 ---- end[2] = p[2] - 2048; ! float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); if (r == -1) *************** *** 372,382 **** // add dynamic lights // ! light = 0; ! for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++) { dl = r_newrefdef.dlights[lnum]; ! Math3D.VectorSubtract (currententity.origin, dl.origin, dist); ! add = dl.intensity - Math3D.VectorLength(dist); add *= (1.0f/256); if (add > 0) --- 368,377 ---- // add dynamic lights // ! for (int lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++) { dl = r_newrefdef.dlights[lnum]; ! Math3D.VectorSubtract (currententity.origin, dl.origin, end); ! add = dl.intensity - Math3D.VectorLength(end); add *= (1.0f/256); if (add > 0) *************** *** 389,393 **** } - // =================================================================== --- 384,387 ---- Index: Warp.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Warp.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Warp.java 9 Jul 2004 06:50:48 -0000 1.4 --- Warp.java 12 Jul 2004 22:08:03 -0000 1.5 *************** *** 28,35 **** import jake2.Defines; import jake2.Globals; ! import jake2.game.GameBase; ! import jake2.render.glpoly_t; ! import jake2.render.image_t; ! import jake2.render.msurface_t; import jake2.util.Math3D; import net.java.games.jogl.GL; --- 28,32 ---- import jake2.Defines; import jake2.Globals; ! import jake2.render.*; import jake2.util.Math3D; import net.java.games.jogl.GL; *************** *** 118,122 **** float m; float[] v = {0, 0, 0}; ! float[][] front = new float[64][3]; float[][] back = new float[64][3]; --- 115,119 ---- float m; float[] v = {0, 0, 0}; ! float[][] front = new float[64][3]; float[][] back = new float[64][3]; *************** *** 124,128 **** float[] dist = new float[64]; float frac; - glpoly_t poly; float s, t; float[] total = {0, 0, 0}; --- 121,124 ---- *************** *** 193,197 **** // init polys ! poly = new glpoly_t(numverts + 2); poly.next = warpface.polys; --- 189,193 ---- // init polys ! glpoly_t poly = new glpoly_t(numverts + 2); poly.next = warpface.polys; Index: Mesh.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Mesh.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Mesh.java 9 Jul 2004 06:50:48 -0000 1.4 --- Mesh.java 12 Jul 2004 22:08:03 -0000 1.5 *************** *** 26,36 **** package jake2.render.jogl; - import java.nio.FloatBuffer; - - import net.java.games.gluegen.runtime.BufferFactory; - import net.java.games.jogl.GL; - import net.java.games.jogl.util.BufferUtils; import jake2.Defines; - import jake2.Globals; import jake2.client.entity_t; import jake2.qcommon.qfiles; --- 26,30 ---- *************** *** 38,41 **** --- 32,40 ---- import jake2.util.Math3D; + import java.nio.FloatBuffer; + + import net.java.games.jogl.GL; + import net.java.games.jogl.util.BufferUtils; + /** * Mesh *************** *** 101,109 **** } ! void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, FloatBuffer lerp, float[] move, float[] frontv, float[] backv ) { - int i; int lerpIndex = 0; //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) --- 100,111 ---- } ! void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv ) { int lerpIndex = 0; + int[] ovv; + int[] vv; + FloatBuffer lerp = vertexArrayBuf; + //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) *************** *** 111,121 **** float[] normal; int j = 0; ! for (i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) { normal = r_avertexnormals[verts[i].lightnormalindex]; ! ! lerp.put(j++, move[0] + ov[i].v[0]*backv[0] + v[i].v[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); ! lerp.put(j++, move[1] + ov[i].v[1]*backv[1] + v[i].v[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); ! lerp.put(j++, move[2] + ov[i].v[2]*backv[2] + v[i].v[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); } } --- 113,126 ---- float[] normal; int j = 0; ! for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) { normal = r_avertexnormals[verts[i].lightnormalindex]; ! ovv = ov[i].v; ! vv = v[i].v; ! ! lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); ! lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); ! lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); ! j+=3; } } *************** *** 123,132 **** { int j = 0; ! for (i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) { ! lerp.put(j++, move[0] + ov[i].v[0]*backv[0] + v[i].v[0]*frontv[0]); ! lerp.put(j++, move[1] + ov[i].v[1]*backv[1] + v[i].v[1]*frontv[1]); ! lerp.put(j++, move[2] + ov[i].v[2]*backv[2] + v[i].v[2]*frontv[2]); } } --- 128,140 ---- { int j = 0; ! for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) { + ovv = ov[i].v; + vv = v[i].v; ! lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0]); ! lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1]); ! lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2]); ! j+=3; } } *************** *** 160,164 **** float[] move = {0, 0, 0}; // vec3_t - float[] delta = {0, 0, 0}; // vec3_t float[][] vectors = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0} // 3 mal vec3_t --- 168,171 ---- *************** *** 194,203 **** // move should be the delta back to the previous frame * backlerp ! Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, delta); Math3D.AngleVectors (currententity.angles, vectors[0], vectors[1], vectors[2]); ! move[0] = Math3D.DotProduct (delta, vectors[0]); // forward ! move[1] = -Math3D.DotProduct (delta, vectors[1]); // left ! move[2] = Math3D.DotProduct (delta, vectors[2]); // up Math3D.VectorAdd (move, oldframe.translate, move); --- 201,210 ---- // move should be the delta back to the previous frame * backlerp ! Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv); Math3D.AngleVectors (currententity.angles, vectors[0], vectors[1], vectors[2]); ! move[0] = Math3D.DotProduct(frontv, vectors[0]); // forward ! move[1] = -Math3D.DotProduct(frontv, vectors[1]); // left ! move[2] = Math3D.DotProduct(frontv, vectors[2]); // up Math3D.VectorAdd (move, oldframe.translate, move); *************** *** 206,213 **** { move[i] = backlerp*move[i] + frontlerp*frame.translate[i]; - } - - for (i=0 ; i<3 ; i++) - { frontv[i] = frontlerp*frame.scale[i]; backv[i] = backlerp*oldframe.scale[i]; --- 213,216 ---- *************** *** 216,220 **** if ( gl_vertex_arrays.value != 0.0f ) { ! GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, vertexArrayBuf, move, frontv, backv ); gl.glEnableClientState( GL.GL_VERTEX_ARRAY ); --- 219,223 ---- if ( gl_vertex_arrays.value != 0.0f ) { ! GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, move, frontv, backv ); gl.glEnableClientState( GL.GL_VERTEX_ARRAY ); Index: Image.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Image.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Image.java 9 Jul 2004 06:50:48 -0000 1.3 --- Image.java 12 Jul 2004 22:08:03 -0000 1.4 *************** *** 762,779 **** // else if (pos[off] != 255) fdc = pos[off]; // } ! // TODO check this: R_FloodFillSkin( byte[] skin, int skinwidth, int skinheight) void R_FloodFillSkin(byte[] skin, int skinwidth, int skinheight) { // byte fillcolor = *skin; // assume this is the pixel to fill int fillcolor = skin[0] & 0xff; - floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; int inpt = 0, outpt = 0; int filledcolor = -1; int i; - for (int j = 0; j < fifo.length; j++) { - fifo[j] = new floodfill_t(); - } - if (filledcolor == -1) { filledcolor = 0; --- 762,779 ---- // else if (pos[off] != 255) fdc = pos[off]; // } ! static floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; ! static { ! for (int j = 0; j < fifo.length; j++) { ! fifo[j] = new floodfill_t(); ! } ! } // TODO check this: R_FloodFillSkin( byte[] skin, int skinwidth, int skinheight) void R_FloodFillSkin(byte[] skin, int skinwidth, int skinheight) { // byte fillcolor = *skin; // assume this is the pixel to fill int fillcolor = skin[0] & 0xff; int inpt = 0, outpt = 0; int filledcolor = -1; int i; if (filledcolor == -1) { filledcolor = 0; Index: Model.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Model.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Model.java 9 Jul 2004 06:50:48 -0000 1.2 --- Model.java 12 Jul 2004 22:08:03 -0000 1.3 *************** *** 26,51 **** package jake2.render.jogl; - import java.nio.ByteBuffer; - import java.nio.ByteOrder; - import java.util.Arrays; - import java.util.Vector; - import jake2.Defines; import jake2.game.cplane_t; import jake2.game.cvar_t; ! import jake2.qcommon.lump_t; ! import jake2.qcommon.qfiles; ! import jake2.qcommon.texinfo_t; ! import jake2.render.medge_t; ! import jake2.render.mleaf_t; ! import jake2.render.mmodel_t; ! import jake2.render.mnode_t; ! import jake2.render.model_t; ! import jake2.render.msurface_t; ! import jake2.render.mtexinfo_t; ! import jake2.render.mvertex_t; import jake2.util.Math3D; import jake2.util.Vargs; /** * Model --- 26,41 ---- package jake2.render.jogl; import jake2.Defines; import jake2.game.cplane_t; import jake2.game.cvar_t; ! import jake2.qcommon.*; ! import jake2.render.*; import jake2.util.Math3D; import jake2.util.Vargs; + import java.nio.ByteBuffer; + import java.nio.ByteOrder; + import java.util.Arrays; + /** * Model *************** *** 569,575 **** float val; ! int i, j, e; mvertex_t v; - mtexinfo_t tex; int[] bmins = {0, 0}; int[] bmaxs = {0, 0}; --- 559,564 ---- float val; ! int j, e; mvertex_t v; int[] bmins = {0, 0}; int[] bmaxs = {0, 0}; *************** *** 578,584 **** maxs[0] = maxs[1] = -99999; ! tex = s.texinfo; ! for (i=0 ; i<s.numedges ; i++) { e = loadmodel.surfedges[s.firstedge+i]; --- 567,573 ---- maxs[0] = maxs[1] = -99999; ! mtexinfo_t tex = s.texinfo; ! for (int i=0 ; i<s.numedges ; i++) { e = loadmodel.surfedges[s.firstedge+i]; *************** *** 601,605 **** } ! for (i=0 ; i<2 ; i++) { bmins[i] = (int)Math.floor(mins[i]/16); --- 590,594 ---- } ! for (int i=0 ; i<2 ; i++) { bmins[i] = (int)Math.floor(mins[i]/16); |