Update of /cvsroot/jake2/jake2/src/jake2/render/fastjogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29339/src/jake2/render/fastjogl Modified Files: Tag: RST Model.java Surf.java Main.java Light.java Mesh.java Warp.java Added Files: Tag: RST Polygon.java Log Message: This has vec3-optimize and the OAK bot. Index: Model.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Model.java,v retrieving revision 1.5 retrieving revision 1.5.6.1 diff -C2 -d -r1.5 -r1.5.6.1 *** Model.java 22 Sep 2004 19:22:10 -0000 1.5 --- Model.java 16 Jan 2005 21:21:04 -0000 1.5.6.1 *************** *** 30,54 **** import jake2.game.cplane_t; import jake2.game.cvar_t; ! import jake2.qcommon.Com; ! import jake2.qcommon.Cvar; ! import jake2.qcommon.FS; ! 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; ! import java.nio.ByteBuffer; ! import java.nio.ByteOrder; ! import java.nio.FloatBuffer; ! import java.nio.IntBuffer; import java.util.Arrays; import java.util.Vector; --- 30,39 ---- 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.*; import java.util.Arrays; import java.util.Vector; *************** *** 1090,1094 **** protected void R_BeginRegistration(String model) { resetModelArrays(); ! resetPolygonArrays(); cvar_t flushmap; --- 1075,1080 ---- protected void R_BeginRegistration(String model) { resetModelArrays(); ! // resetPolygonArrays(); ! Polygon.reset(); cvar_t flushmap; Index: Main.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Main.java,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** Main.java 8 Dec 2004 09:58:34 -0000 1.5 --- Main.java 16 Jan 2005 21:21:04 -0000 1.5.2.1 *************** *** 29,38 **** import jake2.Globals; import jake2.client.*; ! import jake2.game.*; import jake2.game.cplane_t; import jake2.game.cvar_t; import jake2.qcommon.*; - import jake2.qcommon.qfiles; - import jake2.qcommon.xcommand_t; import jake2.render.*; import jake2.util.Math3D; --- 29,36 ---- import jake2.Globals; import jake2.client.*; ! import jake2.game.Cmd; import jake2.game.cplane_t; import jake2.game.cvar_t; import jake2.qcommon.*; import jake2.render.*; import jake2.util.Math3D; *************** *** 640,643 **** --- 638,644 ---- =============== */ + + private final float[] temp = { 0, 0, 0 }; + void R_SetupFrame() { int i; *************** *** 660,665 **** // check above and below so crossing solid water doesn't draw wrong if (leaf.contents == 0) { // look down a bit - float[] temp = { 0, 0, 0 }; - Math3D.VectorCopy(r_origin, temp); temp[2] -= 16; --- 661,664 ---- *************** *** 669,674 **** } else { // look up a bit - float[] temp = { 0, 0, 0 }; - Math3D.VectorCopy(r_origin, temp); temp[2] += 16; --- 668,671 ---- *************** *** 898,904 **** ==================== */ void R_SetLightLevel() { - float[] shadelight = { 0, 0, 0 }; - if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) return; --- 895,901 ---- ==================== */ + private final float[] shadelight = { 0, 0, 0 }; + void R_SetLightLevel() { if ((r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) != 0) return; Index: Surf.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Surf.java,v retrieving revision 1.5 retrieving revision 1.5.6.1 diff -C2 -d -r1.5 -r1.5.6.1 *** Surf.java 22 Sep 2004 19:22:11 -0000 1.5 --- Surf.java 16 Jan 2005 21:21:04 -0000 1.5.6.1 *************** *** 27,49 **** import jake2.Defines; ! import jake2.client.dlight_t; ! import jake2.client.entity_t; ! import jake2.client.lightstyle_t; import jake2.game.cplane_t; import jake2.qcommon.Com; ! import jake2.render.glpoly_t; ! import jake2.render.image_t; ! import jake2.render.medge_t; ! import jake2.render.mleaf_t; ! import jake2.render.mnode_t; ! import jake2.render.model_t; ! import jake2.render.msurface_t; ! import jake2.render.mtexinfo_t; import jake2.util.Lib; import jake2.util.Math3D; ! import java.nio.ByteOrder; ! import java.nio.FloatBuffer; ! import java.nio.IntBuffer; import java.util.Arrays; --- 27,39 ---- import jake2.Defines; ! import jake2.client.*; import jake2.game.cplane_t; import jake2.qcommon.Com; ! import jake2.render.*; ! import jake2.util.*; import jake2.util.Lib; import jake2.util.Math3D; ! import java.nio.*; import java.util.Arrays; *************** *** 173,192 **** */ void DrawGLFlowingPoly(glpoly_t p) { ! int i; ! float scroll; ! ! scroll = -64 * ((r_newrefdef.time / 40.0f) - (int) (r_newrefdef.time / 40.0f)); if (scroll == 0.0f) scroll = -64.0f; ! FloatBuffer texCoord = globalPolygonInterleavedBuf; ! float[][] v = p.verts; ! int index = p.pos * POLYGON_STRIDE; ! for (i = 0; i < p.numverts; i++) { ! texCoord.put(index, v[i][3] + scroll); ! index += POLYGON_STRIDE; ! } gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); } --- 163,174 ---- */ void DrawGLFlowingPoly(glpoly_t p) { ! float scroll = -64 * ((r_newrefdef.time / 40.0f) - (int) (r_newrefdef.time / 40.0f)); if (scroll == 0.0f) scroll = -64.0f; ! p.beginScrolling(scroll); gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); + p.endScrolling(); } *************** *** 198,205 **** */ void R_DrawTriangleOutlines() { ! int i, j; ! glpoly_t p; ! ! if (gl_showtris.value == 0) return; --- 180,184 ---- */ void R_DrawTriangleOutlines() { ! if (gl_showtris.value == 0) return; *************** *** 208,223 **** gl.glColor4f(1, 1, 1, 1); ! for (i = 0; i < MAX_LIGHTMAPS; i++) { ! msurface_t surf; ! ! for (surf = gl_lms.lightmap_surfaces[i]; surf != null; surf = surf.lightmapchain) { ! p = surf.polys; ! for (; p != null; p = p.chain) { ! for (j = 2; j < p.numverts; j++) { gl.glBegin(GL.GL_LINE_STRIP); ! gl.glVertex3fv(p.verts[0]); ! gl.glVertex3fv(p.verts[j - 1]); ! gl.glVertex3fv(p.verts[j]); ! gl.glVertex3fv(p.verts[0]); gl.glEnd(); } --- 187,199 ---- gl.glColor4f(1, 1, 1, 1); ! for (int i = 0; i < MAX_LIGHTMAPS; i++) { ! for (msurface_t surf = gl_lms.lightmap_surfaces[i]; surf != null; surf = surf.lightmapchain) { ! for (glpoly_t p = surf.polys; p != null; p = p.chain) { ! for (int j = 2; j < p.numverts; j++) { gl.glBegin(GL.GL_LINE_STRIP); ! gl.glVertex3f(p.x(0), p.y(0), p.z(0)); ! gl.glVertex3f(p.x(j-1), p.y(j-1), p.z(j-1)); ! gl.glVertex3f(p.x(j), p.y(j), p.z(j)); ! gl.glVertex3f(p.x(0), p.y(0), p.z(0)); gl.glEnd(); } *************** *** 352,356 **** intens = gl_state.inverse_intensity; ! gl.glInterleavedArrays(GL.GL_T2F_V3F, POLYGON_BYTE_STRIDE, globalPolygonInterleavedBuf); --- 328,332 ---- intens = gl_state.inverse_intensity; ! gl.glInterleavedArrays(GL.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf); *************** *** 520,530 **** for (p = surf.polys; p != null; p = p.chain) { ! v = p.verts; ! index = p.pos * POLYGON_STRIDE; ! for (i = 0; i < p.numverts; i++) { ! texCoord.put(index, v[i][3] + scroll); ! index += POLYGON_STRIDE; ! } gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); } } else { --- 496,502 ---- for (p = surf.polys; p != null; p = p.chain) { ! p.beginScrolling(scroll); gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); + p.endScrolling(); } } else { *************** *** 552,562 **** for (p = surf.polys; p != null; p = p.chain) { ! v = p.verts; ! index = p.pos * POLYGON_STRIDE; ! for (i = 0; i < p.numverts; i++) { ! texCoord.put(index, v[i][3] + scroll); ! index += POLYGON_STRIDE; ! } gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); } } else { --- 524,530 ---- for (p = surf.polys; p != null; p = p.chain) { ! p.beginScrolling(scroll); gl.glDrawArrays(GL.GL_POLYGON, p.pos, p.numverts); + p.endScrolling(); } } else { *************** *** 644,652 **** */ void R_DrawBrushModel(entity_t e) { - float[] mins = { 0, 0, 0 }; - float[] maxs = { 0, 0, 0 }; - int i; - boolean rotated; - if (currentmodel.nummodelsurfaces == 0) return; --- 612,615 ---- *************** *** 655,661 **** gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1; if (e.angles[0] != 0 || e.angles[1] != 0 || e.angles[2] != 0) { rotated = true; ! for (i = 0; i < 3; i++) { mins[i] = e.origin[i] - currentmodel.radius; maxs[i] = e.origin[i] + currentmodel.radius; --- 618,627 ---- gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1; + float[] mins = Vec3Cache.get(); + float[] maxs = Vec3Cache.get(); + boolean rotated; if (e.angles[0] != 0 || e.angles[1] != 0 || e.angles[2] != 0) { rotated = true; ! for (int i = 0; i < 3; i++) { mins[i] = e.origin[i] - currentmodel.radius; maxs[i] = e.origin[i] + currentmodel.radius; *************** *** 667,672 **** } ! if (R_CullBox(mins, maxs)) return; gl.glColor3f(1, 1, 1); --- 633,642 ---- } ! if (R_CullBox(mins, maxs)) { ! Vec3Cache.release(2); // mins, maxs return; + } + + Vec3Cache.release(2); // mins, maxs gl.glColor3f(1, 1, 1); *************** *** 680,687 **** Math3D.VectorSubtract(r_newrefdef.vieworg, e.origin, modelorg); if (rotated) { ! float[] temp = { 0, 0, 0 }; ! float[] forward = { 0, 0, 0 }; ! float[] right = { 0, 0, 0 }; ! float[] up = { 0, 0, 0 }; Math3D.VectorCopy(modelorg, temp); --- 650,657 ---- Math3D.VectorSubtract(r_newrefdef.vieworg, e.origin, modelorg); if (rotated) { ! float[] temp = Vec3Cache.get(); ! float[] forward = Vec3Cache.get(); ! float[] right = Vec3Cache.get(); ! float[] up = Vec3Cache.get(); Math3D.VectorCopy(modelorg, temp); *************** *** 690,693 **** --- 660,665 ---- modelorg[1] = -Math3D.DotProduct(temp, right); modelorg[2] = Math3D.DotProduct(temp, up); + + Vec3Cache.release(4); // temp, forward, right, up } *************** *** 703,711 **** GL_SelectTexture(GL_TEXTURE0); GL_TexEnv(GL.GL_REPLACE); ! gl.glInterleavedArrays(GL.GL_T2F_V3F, POLYGON_BYTE_STRIDE, globalPolygonInterleavedBuf); GL_SelectTexture(GL_TEXTURE1); GL_TexEnv(GL.GL_MODULATE); ! gl.glTexCoordPointer(2, GL.GL_FLOAT, POLYGON_BYTE_STRIDE, globalPolygonTexCoord1Buf); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); --- 675,683 ---- GL_SelectTexture(GL_TEXTURE0); GL_TexEnv(GL.GL_REPLACE); ! gl.glInterleavedArrays(GL.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf); GL_SelectTexture(GL_TEXTURE1); GL_TexEnv(GL.GL_MODULATE); ! gl.glTexCoordPointer(2, GL.GL_FLOAT, Polygon.BYTE_STRIDE, globalPolygonTexCoord1Buf); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); *************** *** 846,854 **** * ============= R_DrawWorld ============= */ void R_DrawWorld() { - entity_t ent = new entity_t(); - // auto cycle the world frame for texture animation - ent.frame = (int) (r_newrefdef.time * 2); - currententity = ent; if (r_drawworld.value == 0) --- 818,824 ---- * ============= R_DrawWorld ============= */ + entity_t worldEnt = new entity_t(); + void R_DrawWorld() { if (r_drawworld.value == 0) *************** *** 861,864 **** --- 831,840 ---- Math3D.VectorCopy(r_newrefdef.vieworg, modelorg); + + entity_t ent = worldEnt; + // auto cycle the world frame for texture animation + ent.clear(); + ent.frame = (int) (r_newrefdef.time * 2); + currententity = ent; gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1; *************** *** 876,883 **** GL_SelectTexture(GL_TEXTURE0); GL_TexEnv(GL.GL_REPLACE); ! gl.glInterleavedArrays(GL.GL_T2F_V3F, POLYGON_BYTE_STRIDE, globalPolygonInterleavedBuf); GL_SelectTexture(GL_TEXTURE1); ! gl.glTexCoordPointer(2, GL.GL_FLOAT, POLYGON_BYTE_STRIDE, globalPolygonTexCoord1Buf); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); --- 852,859 ---- GL_SelectTexture(GL_TEXTURE0); GL_TexEnv(GL.GL_REPLACE); ! gl.glInterleavedArrays(GL.GL_T2F_V3F, Polygon.BYTE_STRIDE, globalPolygonInterleavedBuf); GL_SelectTexture(GL_TEXTURE1); ! gl.glTexCoordPointer(2, GL.GL_FLOAT, Polygon.BYTE_STRIDE, globalPolygonTexCoord1Buf); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); *************** *** 1075,1098 **** float[] vec; float s, t; ! glpoly_t poly; ! float[] total = { 0, 0, 0 }; ! ! // reconstruct the polygon pedges = currentmodel.edges; lnumverts = fa.numedges; vertpage = 0; - Math3D.VectorClear(total); // // draw texture // ! // poly = Hunk_Alloc (sizeof(glpoly_t) + (lnumverts-4) * ! // VERTEXSIZE*sizeof(float)); ! poly = new glpoly_t(lnumverts); poly.next = fa.polys; poly.flags = fa.flags; fa.polys = poly; - poly.numverts = lnumverts; for (i = 0; i < lnumverts; i++) { --- 1051,1067 ---- float[] vec; float s, t; ! // reconstruct the polygon pedges = currentmodel.edges; lnumverts = fa.numedges; vertpage = 0; // // draw texture // ! glpoly_t poly = Polygon.create(lnumverts); poly.next = fa.polys; poly.flags = fa.flags; fa.polys = poly; for (i = 0; i < lnumverts; i++) { *************** *** 1114,1121 **** t /= fa.texinfo.image.height; ! Math3D.VectorAdd(total, vec, total); ! Math3D.VectorCopy(vec, poly.verts[i]); ! poly.verts[i][3] = s; ! poly.verts[i][4] = t; // --- 1083,1091 ---- t /= fa.texinfo.image.height; ! poly.x(i, vec[0]); ! poly.y(i, vec[1]); ! poly.z(i, vec[2]); ! poly.s1(i, s); ! poly.t1(i, t); // *************** *** 1136,1147 **** t /= BLOCK_HEIGHT * 16; //fa.texinfo.texture.height; ! poly.verts[i][5] = s; ! poly.verts[i][6] = t; } - - poly.numverts = lnumverts; - - precompilePolygon(poly); - } --- 1106,1112 ---- t /= BLOCK_HEIGHT * 16; //fa.texinfo.texture.height; ! poly.s2(i, s); ! poly.t2(i, t); } } *************** *** 1197,1206 **** void GL_BeginBuildingLightmaps(model_t m) { // static lightstyle_t lightstyles[MAX_LIGHTSTYLES]; ! int i; ! ! // init lightstyles if (lightstyles == null) { lightstyles = new lightstyle_t[Defines.MAX_LIGHTSTYLES]; ! for (i = 0; i < lightstyles.length; i++) { lightstyles[i] = new lightstyle_t(); } --- 1162,1169 ---- void GL_BeginBuildingLightmaps(model_t m) { // static lightstyle_t lightstyles[MAX_LIGHTSTYLES]; ! // init lightstyles if (lightstyles == null) { lightstyles = new lightstyle_t[Defines.MAX_LIGHTSTYLES]; ! for (int i = 0; i < lightstyles.length; i++) { lightstyles[i] = new lightstyle_t(); } *************** *** 1219,1223 **** * regenerated * the first time they're seen */ ! for (i = 0; i < Defines.MAX_LIGHTSTYLES; i++) { lightstyles[i].rgb[0] = 1; lightstyles[i].rgb[1] = 1; --- 1182,1186 ---- * regenerated * the first time they're seen */ ! for (int i = 0; i < Defines.MAX_LIGHTSTYLES; i++) { lightstyles[i].rgb[0] = 1; lightstyles[i].rgb[1] = 1; *************** *** 1285,1337 **** /* ! * new functions for vertex array handling */ ! static final int POLYGON_BUFFER_SIZE = 120000; ! ! static final int POLYGON_STRIDE = 7; ! ! static final int POLYGON_BYTE_STRIDE = POLYGON_STRIDE ! * BufferUtils.SIZEOF_FLOAT; ! ! static FloatBuffer globalPolygonInterleavedBuf = BufferUtils ! .newFloatBuffer(POLYGON_BUFFER_SIZE * 7); static FloatBuffer globalPolygonTexCoord1Buf = null; static { ! globalPolygonInterleavedBuf.position(POLYGON_STRIDE - 2); globalPolygonTexCoord1Buf = globalPolygonInterleavedBuf.slice(); globalPolygonInterleavedBuf.position(0); }; ! void precompilePolygon(glpoly_t p) { ! ! p.pos = globalPolygonInterleavedBuf.position() / POLYGON_STRIDE; ! ! float[] v; ! FloatBuffer buffer = globalPolygonInterleavedBuf; ! ! for (int i = 0; i < p.verts.length; i++) { ! v = p.verts[i]; ! // textureCoord0 ! buffer.put(v[3]); ! buffer.put(v[4]); ! ! // vertex ! buffer.put(v[0]); ! buffer.put(v[1]); ! buffer.put(v[2]); ! ! // textureCoord1 ! buffer.put(v[5]); ! buffer.put(v[6]); ! } ! } ! ! public static void resetPolygonArrays() { ! globalPolygonInterleavedBuf.rewind(); ! } ! ! //ImageFrame frame; // void debugLightmap(byte[] buf, int w, int h, float scale) { --- 1248,1264 ---- /* ! * new buffers for vertex array handling */ ! static FloatBuffer globalPolygonInterleavedBuf = Polygon.getInterleavedBuffer(); static FloatBuffer globalPolygonTexCoord1Buf = null; static { ! globalPolygonInterleavedBuf.position(Polygon.STRIDE - 2); globalPolygonTexCoord1Buf = globalPolygonInterleavedBuf.slice(); globalPolygonInterleavedBuf.position(0); }; ! //ImageFrame frame; // void debugLightmap(byte[] buf, int w, int h, float scale) { --- NEW FILE: Polygon.java --- /* * Polygon.java * Copyright (C) 2003 * * $Id: Polygon.java,v 1.2.2.1 2005/01/16 21:21:04 salomo Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. 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 jake2.render.fastjogl; import jake2.render.glpoly_t; import jake2.util.Lib; import java.nio.FloatBuffer; /** * Polygon * * @author cwei */ public final class Polygon extends glpoly_t { private final static int MAX_POLYS = 20000; private final static int MAX_BUFFER_VERTICES = 120000; // backup for s1 scrolling private static float[] s1_old = new float[MAX_VERTICES]; private static FloatBuffer buffer = Lib.newFloatBuffer(MAX_BUFFER_VERTICES * STRIDE); private static int bufferIndex = 0; private static int polyCount = 0; private static Polygon[] polyCache = new Polygon[MAX_POLYS]; static { for (int i = 0; i < polyCache.length; i++) { polyCache[i] = new Polygon(); } } static glpoly_t create(int numverts) { Polygon poly = polyCache[polyCount++]; poly.clear(); poly.numverts = numverts; poly.pos = bufferIndex; bufferIndex += numverts; return poly; } static void reset() { polyCount = 0; bufferIndex = 0; } static FloatBuffer getInterleavedBuffer() { return (FloatBuffer)buffer.rewind(); } private Polygon() { } private final void clear() { next = null; chain = null; numverts = 0; flags = 0; } // the interleaved buffer has the format: // textureCoord0 (index 0, 1) // vertex (index 2, 3, 4) // textureCoord1 (index 5, 6) public final float x(int index) { return buffer.get((index + pos) * 7 + 2); } public final void x(int index, float value) { buffer.put((index + pos) * 7 + 2, value); } public final float y(int index) { return buffer.get((index + pos) * 7 + 3); } public final void y(int index, float value) { buffer.put((index + pos) * 7 + 3, value); } public final float z(int index) { return buffer.get((index + pos) * 7 + 4); } public final void z(int index, float value) { buffer.put((index + pos) * 7 + 4, value); } public final float s1(int index) { return buffer.get((index + pos) * 7 + 0); } public final void s1(int index, float value) { buffer.put((index + pos) * 7 + 0, value); } public final float t1(int index) { return buffer.get((index + pos) * 7 + 1); } public final void t1(int index, float value) { buffer.put((index + pos) * 7 + 1, value); } public final float s2(int index) { return buffer.get((index + pos) * 7 + 5); } public final void s2(int index, float value) { buffer.put((index + pos) * 7 + 5, value); } public final float t2(int index) { return buffer.get((index + pos) * 7 + 6); } public final void t2(int index, float value) { buffer.put((index + pos) * 7 + 6, value); } public final void beginScrolling(float scroll) { int index = pos * 7; for (int i = 0; i < numverts; i++, index+=7) { scroll += s1_old[i] = buffer.get(index); buffer.put(index, scroll); } } public final void endScrolling() { int index = pos * 7; for (int i = 0; i < numverts; i++, index+=7) { buffer.put(index, s1_old[i]); } } } Index: Light.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Light.java,v retrieving revision 1.9 retrieving revision 1.9.6.1 diff -C2 -d -r1.9 -r1.9.6.1 *** Light.java 22 Sep 2004 19:22:11 -0000 1.9 --- Light.java 16 Jan 2005 21:21:04 -0000 1.9.6.1 *************** *** 32,39 **** import jake2.qcommon.Com; import jake2.qcommon.longjmpException; ! import jake2.render.mnode_t; ! import jake2.render.msurface_t; ! import jake2.render.mtexinfo_t; import jake2.util.Math3D; import java.nio.ByteBuffer; --- 32,38 ---- import jake2.qcommon.Com; import jake2.qcommon.longjmpException; ! import jake2.render.*; import jake2.util.Math3D; + import jake2.util.Vec3Cache; import java.nio.ByteBuffer; *************** *** 64,74 **** void R_RenderDlight(dlight_t light) { ! int i, j; ! float a; ! float[] v = { 0, 0, 0 }; ! float rad; ! ! rad = light.intensity * 0.35f; ! Math3D.VectorSubtract(light.origin, r_origin, v); --- 63,68 ---- void R_RenderDlight(dlight_t light) { ! float rad = light.intensity * 0.35f; ! float[] v = Vec3Cache.get(); Math3D.VectorSubtract(light.origin, r_origin, v); *************** *** 76,86 **** gl.glColor3f(light.color[0] * 0.2f, light.color[1] * 0.2f, light.color[2] * 0.2f); ! for (i = 0; i < 3; i++) v[i] = light.origin[i] - vpn[i] * rad; gl.glVertex3f(v[0], v[1], v[2]); gl.glColor3f(0, 0, 0); ! for (i = 16; i >= 0; i--) { a = (float) (i / 16.0f * Math.PI * 2); ! for (j = 0; j < 3; j++) v[j] = (float) (light.origin[j] + vright[j] * Math.cos(a) * rad + vup[j] * Math.sin(a) * rad); --- 70,82 ---- gl.glColor3f(light.color[0] * 0.2f, light.color[1] * 0.2f, light.color[2] * 0.2f); ! for (int i = 0; i < 3; i++) v[i] = light.origin[i] - vpn[i] * rad; + gl.glVertex3f(v[0], v[1], v[2]); gl.glColor3f(0, 0, 0); ! float a; ! for (int i = 16; i >= 0; i--) { a = (float) (i / 16.0f * Math.PI * 2); ! for (int j = 0; j < 3; j++) v[j] = (float) (light.origin[j] + vright[j] * Math.cos(a) * rad + vup[j] * Math.sin(a) * rad); *************** *** 88,91 **** --- 84,88 ---- } gl.glEnd(); + Vec3Cache.release(); } *************** *** 128,142 **** */ void R_MarkLights(dlight_t light, int bit, mnode_t node) { - cplane_t splitplane; - float dist; - msurface_t surf; - int i; - int sidebit; - if (node.contents != -1) return; ! splitplane = node.plane; ! dist = Math3D.DotProduct(light.origin, splitplane.normal) - splitplane.dist; --- 125,133 ---- */ void R_MarkLights(dlight_t light, int bit, mnode_t node) { if (node.contents != -1) return; ! cplane_t splitplane = node.plane; ! float dist = Math3D.DotProduct(light.origin, splitplane.normal) - splitplane.dist; *************** *** 150,155 **** } // mark the polygons ! for (i = 0; i < node.numsurfaces; i++) { surf = r_worldmodel.surfaces[node.firstsurface + i]; --- 141,148 ---- } + msurface_t surf; + int sidebit; // mark the polygons ! for (int i = 0; i < node.numsurfaces; i++) { surf = r_worldmodel.surfaces[node.firstsurface + i]; *************** *** 182,194 **** */ void R_PushDlights() { - int i; - dlight_t l; - if (gl_flashblend.value != 0) return; r_dlightframecount = r_framecount + 1; // because the count hasn't // advanced yet for this frame ! for (i = 0; i < r_newrefdef.num_dlights; i++) { l = r_newrefdef.dlights[i]; R_MarkLights(l, 1 << i, r_worldmodel.nodes[0]); --- 175,186 ---- */ void R_PushDlights() { if (gl_flashblend.value != 0) return; r_dlightframecount = r_framecount + 1; // because the count hasn't + // advanced yet for this frame ! dlight_t l; ! for (int i = 0; i < r_newrefdef.num_dlights; i++) { l = r_newrefdef.dlights[i]; R_MarkLights(l, 1 << i, r_worldmodel.nodes[0]); *************** *** 209,224 **** float[] lightspot = { 0, 0, 0 }; // vec3_t ! 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; ! int i; ! mtexinfo_t tex; ! ByteBuffer lightmap; ! int maps; ! float[] mid = { 0, 0, 0 }; // calculate mid point --- 201,213 ---- float[] lightspot = { 0, 0, 0 }; // vec3_t ! ! float scalef = 1.0f/255; ! int RecursiveLightPoint(mnode_t node, float[] start, float[] end) { if (node.contents != -1) return -1; // didn't hit anything ! // ByteBuffer lightmap; ! // int maps; // calculate mid point *************** *** 235,238 **** --- 224,228 ---- float frac = front / (front - back); + float[] mid = Vec3Cache.get(); mid[0] = start[0] + (end[0] - start[0]) * frac; mid[1] = start[1] + (end[1] - start[1]) * frac; *************** *** 241,249 **** // go down front side int r = RecursiveLightPoint(node.children[sideIndex], start, mid); ! if (r >= 0) return r; // hit something ! if ((back < 0) == side) return -1; // didn't hit anuthing // check for impact on this node --- 231,243 ---- // go down front side int r = RecursiveLightPoint(node.children[sideIndex], start, mid); ! if (r >= 0) { ! Vec3Cache.release(); return r; // hit something + } ! if ((back < 0) == side) { ! Vec3Cache.release(); return -1; // didn't hit anuthing + } // check for impact on this node *************** *** 252,257 **** int surfIndex = node.firstsurface; ! float[] scale = { 0, 0, 0 }; ! for (i = 0; i < node.numsurfaces; i++, surfIndex++) { surf = r_worldmodel.surfaces[surfIndex]; --- 246,260 ---- int surfIndex = node.firstsurface; ! ! msurface_t surf; ! mtexinfo_t tex; ! float scale0; ! float scale1; ! float scale2; ! int s, t, ds, dt; ! ByteBuffer lightmap; ! int maps; ! ! for (int i = 0; i < node.numsurfaces; i++, surfIndex++) { surf = r_worldmodel.surfaces[surfIndex]; *************** *** 284,288 **** Math3D.VectorCopy(Globals.vec3_origin, pointcolor); if (lightmap != null) { - //float[] scale = {0, 0, 0}; float[] rgb; lightmapIndex += 3 * (dt * ((surf.extents[0] >> 4) + 1) + ds); --- 287,290 ---- *************** *** 291,313 **** && 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); pointcolor[1] += (lightmap.get(lightmapIndex + 1) & 0xFF) ! * scale[1] * (1.0f / 255); pointcolor[2] += (lightmap.get(lightmapIndex + 2) & 0xFF) ! * scale[2] * (1.0f / 255); lightmapIndex += 3 * ((surf.extents[0] >> 4) + 1) * ((surf.extents[1] >> 4) + 1); } } return 1; } // go down back side ! return RecursiveLightPoint(node.children[1 - sideIndex], mid, end); } --- 293,318 ---- && surf.styles[maps] != (byte) 255; maps++) { rgb = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb; ! scale0 = gl_modulate.value * rgb[0]; ! scale1 = gl_modulate.value * rgb[1]; ! scale2 = gl_modulate.value * rgb[2]; pointcolor[0] += (lightmap.get(lightmapIndex + 0) & 0xFF) ! * scale0 * scalef; pointcolor[1] += (lightmap.get(lightmapIndex + 1) & 0xFF) ! * scale1 * scalef; pointcolor[2] += (lightmap.get(lightmapIndex + 2) & 0xFF) ! * scale2 * scalef; lightmapIndex += 3 * ((surf.extents[0] >> 4) + 1) * ((surf.extents[1] >> 4) + 1); } } + Vec3Cache.release(); return 1; } // go down back side ! r = RecursiveLightPoint(node.children[1 - sideIndex], mid, end); ! Vec3Cache.release(); ! return r; } *************** *** 319,331 **** assert (color.length == 3) : "rgb bug"; - float[] end = { 0, 0, 0 }; - dlight_t dl; - float add; - if (r_worldmodel.lightdata == null) { color[0] = color[1] = color[2] = 1.0f; return; } ! end[0] = p[0]; end[1] = p[1]; --- 324,333 ---- assert (color.length == 3) : "rgb bug"; if (r_worldmodel.lightdata == null) { color[0] = color[1] = color[2] = 1.0f; return; } ! ! float[] end = Vec3Cache.get(); end[0] = p[0]; end[1] = p[1]; *************** *** 343,358 **** // 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) { ! Math3D.VectorMA(color, add, dl.color, color); } } Math3D.VectorScale(color, gl_modulate.value, color); } --- 345,363 ---- // add dynamic lights // + float add; + dlight_t dl; 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)); ! if (add > 0) { ! Math3D.VectorMA(color, add * scalef, dl.color, color); } } Math3D.VectorScale(color, gl_modulate.value, color); + Vec3Cache.release(); } *************** *** 368,373 **** int sd, td; float fdist, frad, fminlight; ! float[] impact = { 0, 0, 0 }; ! float[] local = { 0, 0, 0 }; int s, t; dlight_t dl; --- 373,377 ---- int sd, td; float fdist, frad, fminlight; ! float[] impact = Vec3Cache.get(); int s, t; dlight_t dl; *************** *** 379,382 **** --- 383,388 ---- mtexinfo_t tex = surf.texinfo; + float local0; + float local1; for (int lnum = 0; lnum < r_newrefdef.num_dlights; lnum++) { if ((surf.dlightbits & (1 << lnum)) == 0) *************** *** 399,405 **** } ! local[0] = Math3D.DotProduct(impact, tex.vecs[0]) + tex.vecs[0][3] - surf.texturemins[0]; ! local[1] = Math3D.DotProduct(impact, tex.vecs[1]) + tex.vecs[1][3] - surf.texturemins[1]; --- 405,411 ---- } ! local0 = Math3D.DotProduct(impact, tex.vecs[0]) + tex.vecs[0][3] - surf.texturemins[0]; ! local1 = Math3D.DotProduct(impact, tex.vecs[1]) + tex.vecs[1][3] - surf.texturemins[1]; *************** *** 407,416 **** int pfBLindex = 0; for (t = 0, ftacc = 0; t < tmax; t++, ftacc += 16) { ! td = (int) (local[1] - ftacc); if (td < 0) td = -td; for (s = 0, fsacc = 0; s < smax; s++, fsacc += 16, pfBLindex += 3) { ! sd = (int) (local[0] - fsacc); if (sd < 0) --- 413,422 ---- int pfBLindex = 0; for (t = 0, ftacc = 0; t < tmax; t++, ftacc += 16) { ! td = (int) (local1 - ftacc); if (td < 0) td = -td; for (s = 0, fsacc = 0; s < smax; s++, fsacc += 16, pfBLindex += 3) { ! sd = (int) (local0 - fsacc); if (sd < 0) *************** *** 430,433 **** --- 436,440 ---- } } + Vec3Cache.release(); } *************** *** 452,457 **** int r, g, b, a, max; int i, j; - ByteBuffer lightmap; - float[] scale = { 0, 0, 0 }; int nummaps; float[] bl; --- 459,462 ---- *************** *** 493,500 **** ; ! lightmap = surf.samples; int lightmapIndex = 0; // add all the lightmaps if (nummaps == 1) { int maps; --- 498,508 ---- ; ! ByteBuffer lightmap = surf.samples; int lightmapIndex = 0; // add all the lightmaps + float scale0; + float scale1; + float scale2; if (nummaps == 1) { int maps; *************** *** 505,514 **** int blp = 0; ! for (i = 0; i < 3; i++) ! scale[i] = gl_modulate.value ! * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i]; ! if (scale[0] == 1.0F && scale[1] == 1.0F ! && scale[2] == 1.0F) { for (i = 0; i < size; i++) { bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF; --- 513,525 ---- int blp = 0; ! // for (i = 0; i < 3; i++) ! // scale[i] = gl_modulate.value ! // * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i]; ! scale0 = gl_modulate.value * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[0]; ! scale1 = gl_modulate.value * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[1]; ! scale2 = gl_modulate.value * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[2]; ! if (scale0 == 1.0F && scale1 == 1.0F ! && scale2 == 1.0F) { for (i = 0; i < size; i++) { bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF; *************** *** 519,527 **** for (i = 0; i < size; i++) { bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) ! * scale[0]; bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) ! * scale[1]; bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) ! * scale[2]; } } --- 530,538 ---- for (i = 0; i < size; i++) { bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) ! * scale0; bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) ! * scale1; bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) ! * scale2; } } *************** *** 541,550 **** int blp = 0; ! for (i = 0; i < 3; i++) ! scale[i] = gl_modulate.value ! * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i]; ! if (scale[0] == 1.0F && scale[1] == 1.0F ! && scale[2] == 1.0F) { for (i = 0; i < size; i++) { bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF; --- 552,570 ---- int blp = 0; ! // for (i = 0; i < 3; i++) ! // scale[i] = gl_modulate.value ! // * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i]; ! scale0 = gl_modulate.value ! * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[0]; ! scale1 = gl_modulate.value ! * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[1]; ! scale2 = gl_modulate.value ! * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[2]; ! ! ! ! if (scale0 == 1.0F && scale1 == 1.0F ! && scale2 == 1.0F) { for (i = 0; i < size; i++) { bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF; *************** *** 555,563 **** for (i = 0; i < size; i++) { bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) ! * scale[0]; bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) ! * scale[1]; bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) ! * scale[2]; } } --- 575,583 ---- for (i = 0; i < size; i++) { bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) ! * scale0; bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) ! * scale1; bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) ! * scale2; } } *************** *** 631,636 **** } //r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF; ! dest.put(destp++, (a << 24) | (b << 16) | (g << 8) ! | (r << 0)); } } --- 651,655 ---- } //r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF; ! dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | r); } } *************** *** 697,703 **** // try faking colored lighting a = 255 - ((r + g + b) / 3); ! r *= a / 255.0f; ! g *= a / 255.0f; ! b *= a / 255.0f; break; case 'A': --- 716,723 ---- // try faking colored lighting a = 255 - ((r + g + b) / 3); ! float af = a / 255.0f; ! r *= af; ! g *= af; ! b *= af; break; case 'A': *************** *** 708,713 **** } //r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF; ! dest.put(destp++, (a << 24) | (b << 16) | (g << 8) ! | (r << 0)); } } --- 728,732 ---- } //r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF; ! dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | r); } } Index: Warp.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Warp.java,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -C2 -d -r1.4 -r1.4.6.1 *** Warp.java 22 Sep 2004 19:22:11 -0000 1.4 --- Warp.java 16 Jan 2005 21:21:05 -0000 1.4.6.1 *************** *** 29,39 **** import jake2.Globals; import jake2.qcommon.Com; ! import jake2.render.glpoly_t; ! import jake2.render.image_t; ! import jake2.render.msurface_t; import jake2.util.Math3D; ! ! import java.nio.FloatBuffer; ! import net.java.games.jogl.GL; --- 29,35 ---- import jake2.Globals; import jake2.qcommon.Com; ! import jake2.render.*; import jake2.util.Math3D; ! import jake2.util.Vec3Cache; import net.java.games.jogl.GL; *************** *** 201,214 **** // init polys ! glpoly_t poly = new glpoly_t(numverts + 2); poly.next = warpface.polys; warpface.polys = poly; - poly.numverts = numverts + 2; Math3D.VectorClear(total); total_s = 0; total_t = 0; for (i = 0; i < numverts; i++) { ! Math3D.VectorCopy(verts[i], poly.verts[i + 1]); s = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[0]); t = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[1]); --- 197,211 ---- // init polys ! glpoly_t poly = Polygon.create(numverts + 2); poly.next = warpface.polys; warpface.polys = poly; Math3D.VectorClear(total); total_s = 0; total_t = 0; for (i = 0; i < numverts; i++) { ! poly.x(i + 1, verts[i][0]); ! poly.y(i + 1, verts[i][1]); ! poly.z(i + 1, verts[i][2]); s = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[0]); t = Math3D.DotProduct(verts[i], warpface.texinfo.vecs[1]); *************** *** 218,258 **** Math3D.VectorAdd(total, verts[i], total); ! poly.verts[i + 1][3] = s; ! poly.verts[i + 1][4] = t; } ! Math3D.VectorScale(total, (1.0f / numverts), poly.verts[0]); ! poly.verts[0][3] = total_s / numverts; ! poly.verts[0][4] = total_t / numverts; ! ! // memcpy (poly.verts[i+1], poly.verts[1], sizeof(poly.verts[0])); ! System.arraycopy(poly.verts[1], 0, poly.verts[i + 1], 0, ! poly.verts[1].length); // :-) ! ! precompilePolygon(poly); } /* ! * ================ GL_SubdivideSurface * * Breaks a polygon up along axial 64 unit boundaries so that turbulent and ! * sky warps can be done reasonably. ================ */ ! void GL_SubdivideSurface(msurface_t fa) { ! float[][] verts = new float[64][3]; ! int numverts; ! int i; ! int lindex; float[] vec; - warpface = fa; - // // convert edges back to a normal polygon // ! numverts = 0; ! for (i = 0; i < fa.numedges; i++) { ! lindex = loadmodel.surfedges[fa.firstedge + i]; if (lindex > 0) --- 215,256 ---- Math3D.VectorAdd(total, verts[i], total); ! poly.s1(i + 1, s); ! poly.t1(i + 1, t); } + + float scale = 1.0f / numverts; + poly.x(0, total[0] * scale); + poly.y(0, total[1] * scale); + poly.z(0, total[2] * scale); + poly.s1(0, total_s * scale); + poly.t1(0, total_t * scale); ! poly.x(i + 1, poly.x(1)); ! poly.y(i + 1, poly.y(1)); ! poly.z(i + 1, poly.z(1)); ! poly.s1(i + 1, poly.s1(1)); ! poly.t1(i + 1, poly.t1(1)); ! poly.s2(i + 1, poly.s2(1)); ! poly.t2(i + 1, poly.t2(1)); } /* ! * GL_SubdivideSurface * * Breaks a polygon up along axial 64 unit boundaries so that turbulent and ! * sky warps can be done reasonably. */ ! float[][] tmpVerts = new float[64][3]; ! void GL_SubdivideSurface(msurface_t fa) { ! float[][] verts = tmpVerts; float[] vec; warpface = fa; // // convert edges back to a normal polygon // ! int numverts = 0; ! for (int i = 0; i < fa.numedges; i++) { ! int lindex = loadmodel.surfedges[fa.firstedge + i]; if (lindex > 0) *************** *** 263,267 **** numverts++; } - SubdividePolygon(numverts, verts); } --- 261,264 ---- *************** *** 283,288 **** void EmitWaterPolys(msurface_t fa) { glpoly_t p, bp; - float[] v; - int i; float s = 0; float t = 0; --- 280,283 ---- *************** *** 297,310 **** scroll = 0; - int index; - FloatBuffer texCoord = globalPolygonInterleavedBuf; for (bp = fa.polys; bp != null; bp = bp.next) { p = bp; ! index = p.pos * POLYGON_STRIDE; ! for (i = 0; i < p.numverts; i++) { ! v = p.verts[i]; ! os = v[3]; ! ot = v[4]; s = os --- 292,302 ---- scroll = 0; for (bp = fa.polys; bp != null; bp = bp.next) { p = bp; ! gl.glBegin(GL.GL_TRIANGLE_FAN); ! for (int i = 0; i < p.numverts; i++) { ! os = p.s1(i); ! ot = p.t1(i); s = os *************** *** 317,325 **** t *= (1.0f / 64); ! texCoord.put(index, s); ! texCoord.put(index + 1, t); ! index += POLYGON_STRIDE; } ! gl.glDrawArrays(GL.GL_TRIANGLE_FAN, p.pos, p.numverts); } } --- 309,316 ---- t *= (1.0f / 64); ! gl.glTexCoord2f(s, t); ! gl.glVertex3f(p.x(i), p.y(i), p.z(i)); } ! gl.glEnd(); } } *************** *** 358,363 **** void DrawSkyPolygon(int nump, float[][] vecs) { int i, j; - float[] v = { 0, 0, 0 }; - float[] av = { 0, 0, 0 }; float s, t, dv; int axis; --- 349,352 ---- *************** *** 366,373 **** --- 355,364 ---- c_sky++; // decide which face it maps to + float[] v = Vec3Cache.get(); Math3D.VectorCopy(Globals.vec3_origin, v); for (i = 0; i < nump; i++) { Math3D.VectorAdd(vecs[i], v, v); } + float[] av = Vec3Cache.get(); av[0] = Math.abs(v[0]); av[1] = Math.abs(v[1]); *************** *** 389,392 **** --- 380,385 ---- axis = 4; } + + Vec3Cache.release(2); // v, av // project new texture coords *************** *** 522,532 **** */ void R_AddSkySurface(msurface_t fa) { - int i; - glpoly_t p; - // calculate vertex values for sky box ! for (p = fa.polys; p != null; p = p.next) { ! for (i = 0; i < p.numverts; i++) { ! Math3D.VectorSubtract(p.verts[i], r_origin, verts[i]); } ClipSkyPolygon(p.numverts, verts, 0); --- 515,524 ---- */ void R_AddSkySurface(msurface_t fa) { // calculate vertex values for sky box ! for (glpoly_t p = fa.polys; p != null; p = p.next) { ! for (int i = 0; i < p.numverts; i++) { ! verts[i][0] = p.x(i) - r_origin[0]; ! verts[i][1] = p.y(i) - r_origin[1]; ! verts[i][2] = p.z(i) - r_origin[2]; } ClipSkyPolygon(p.numverts, verts, 0); *************** *** 538,544 **** */ void R_ClearSkyBox() { ! int i; ! ! for (i = 0; i < 6; i++) { skymins[0][i] = skymins[1][i] = 9999; skymaxs[0][i] = skymaxs[1][i] = -9999; --- 530,534 ---- */ void R_ClearSkyBox() { ! for (int i = 0; i < 6; i++) { skymins[0][i] = skymins[1][i] = 9999; skymaxs[0][i] = skymaxs[1][i] = -9999; *************** *** 547,559 **** void MakeSkyVec(float s, float t, int axis) { ! float[] v = { 0, 0, 0 }; ! float[] b = { 0, 0, 0 }; ! int j, k; ! b[0] = s * 2300; b[1] = t * 2300; b[2] = 2300; ! for (j = 0; j < 3; j++) { k = st_to_vec[axis][j]; if (k < 0) --- 537,549 ---- void MakeSkyVec(float s, float t, int axis) { ! float[] b = Vec3Cache.get(); b[0] = s * 2300; b[1] = t * 2300; b[2] = 2300; ! float[] v = Vec3Cache.get(); ! int k; ! ! for (int j = 0; j < 3; j++) { k = st_to_vec[axis][j]; if (k < 0) *************** *** 579,582 **** --- 569,574 ---- gl.glTexCoord2f(s, t); gl.glVertex3f(v[0], v[1], v[2]); + + Vec3Cache.release(2); // b, v } *************** *** 588,592 **** void R_DrawSkyBox() { int i; ! if (skyrotate != 0) { // check for no sky at all for (i = 0; i < 6; i++) --- 580,584 ---- void R_DrawSkyBox() { int i; ! if (skyrotate != 0) { // check for no sky at all for (i = 0; i < 6; i++) Index: Mesh.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/fastjogl/Mesh.java,v retrieving revision 1.6 retrieving revision 1.6.6.1 diff -C2 -d -r1.6 -r1.6.6.1 *** Mesh.java 22 Sep 2004 19:22:11 -0000 1.6 --- Mesh.java 16 Jan 2005 21:21:04 -0000 1.6.6.1 *************** *** 32,35 **** --- 32,36 ---- import jake2.render.image_t; import jake2.util.Math3D; + import jake2.util.Vec3Cache; import java.nio.FloatBuffer; *************** *** 138,144 **** float alpha; - float[] move = { 0, 0, 0 }; // vec3_t - float[] frontv = { 0, 0, 0 }; // vec3_t - float[] backv = { 0, 0, 0 }; // vec3_t qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; --- 139,142 ---- *************** *** 163,166 **** --- 161,165 ---- float frontlerp = 1.0f - backlerp; + float[] frontv = Vec3Cache.get(); // vec3_t // move should be the delta back to the previous frame * backlerp Math3D.VectorSubtract(currententity.oldorigin, currententity.origin, *************** *** 169,172 **** --- 168,172 ---- vectors[2]); + float[] move = Vec3Cache.get(); // vec3_t move[0] = Math3D.DotProduct(frontv, vectors[0]); // forward move[1] = -Math3D.DotProduct(frontv, vectors[1]); // left *************** *** 175,178 **** --- 175,179 ---- Math3D.VectorAdd(move, oldframe.translate, move); + float[] backv = Vec3Cache.get(); // vec3_t for (int i = 0; i < 3; i++) { move[i] = backlerp * move[i] + frontlerp * frame.translate[i]; *************** *** 184,187 **** --- 185,190 ---- GL_LerpVerts(paliashdr.num_xyz, ov, verts, move, frontv, backv); + + Vec3Cache.release(3); // frontv, move, backv //gl.glEnableClientState( GL.GL_VERTEX_ARRAY ); *************** *** 273,277 **** qfiles.dtrivertx_t[] verts; int[] order; - float[] point = { 0, 0, 0 }; float height, lheight; int count; --- 276,279 ---- *************** *** 295,298 **** --- 297,301 ---- // TODO shadow drawing with vertex arrays + float[] point = Vec3Cache.get(); while (true) { // get the vertex count and primitive type *************** *** 323,326 **** --- 326,330 ---- gl.glEnd(); } + Vec3Cache.release(); // point } *************** *** 330,336 **** // TODO sync with jogl renderer. hoz boolean R_CullAliasModel(entity_t e) { - float[] mins = { 0, 0, 0 }; - float[] maxs = { 0, 0, 0 }; - qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata; --- 334,337 ---- *************** *** 353,356 **** --- 354,360 ---- * * compute axially aligned mins and maxs */ + float[] mins = Vec3Cache.get(); + float[] maxs = Vec3Cache.get(); + if (pframe == poldframe) { for (int i = 0; i < 3; i++) { *************** *** 416,419 **** --- 420,425 ---- Math3D.VectorAdd(e.origin, bbox[i], bbox[i]); } + + Vec3Cache.release(2); // mins, maxs int f, mask; |