From: Rene S. <sa...@us...> - 2005-01-16 21:22:01
|
Update of /cvsroot/jake2/jake2/src/jake2/render/jogl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29339/src/jake2/render/jogl Modified Files: Tag: RST Warp.java Model.java Surf.java Added Files: Tag: RST Polygon.java Log Message: This has vec3-optimize and the OAK bot. Index: Warp.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Warp.java,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** Warp.java 22 Sep 2004 19:22:16 -0000 1.7 --- Warp.java 16 Jan 2005 21:21:10 -0000 1.7.6.1 *************** *** 29,35 **** 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 net.java.games.jogl.GL; --- 29,33 ---- import jake2.Globals; import jake2.qcommon.Com; ! import jake2.render.*; import jake2.util.Math3D; import net.java.games.jogl.GL; *************** *** 198,211 **** // 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]); --- 196,210 ---- // 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]); *************** *** 215,253 **** 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); // :-) } /* ! * ================ 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) --- 214,255 ---- 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) *************** *** 258,262 **** numverts++; } - SubdividePolygon(numverts, verts); } --- 260,263 ---- *************** *** 278,282 **** void EmitWaterPolys(msurface_t fa) { glpoly_t p, bp; - float[] v; int i; float s = 0; --- 279,282 ---- *************** *** 296,302 **** gl.glBegin(GL.GL_TRIANGLE_FAN); for (i = 0; i < p.numverts; i++) { ! v = p.verts[i]; ! os = v[3]; ! ot = v[4]; s = os --- 296,301 ---- gl.glBegin(GL.GL_TRIANGLE_FAN); for (i = 0; i < p.numverts; i++) { ! os = p.s1(i); ! ot = p.t1(i); s = os *************** *** 310,314 **** gl.glTexCoord2f(s, t); ! gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd(); --- 309,313 ---- gl.glTexCoord2f(s, t); ! gl.glVertex3f(p.x(i), p.y(i), p.z(i)); } gl.glEnd(); *************** *** 510,523 **** /* ! * ================= R_AddSkySurface ================= */ 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); --- 509,521 ---- /* ! * R_AddSkySurface */ 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); Index: Surf.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Surf.java,v retrieving revision 1.5 retrieving revision 1.5.6.1 diff -C2 -d -r1.5 -r1.5.6.1 *** Surf.java 16 Jul 2004 10:11:35 -0000 1.5 --- Surf.java 16 Jan 2005 21:21:11 -0000 1.5.6.1 *************** *** 155,167 **** void DrawGLPoly(glpoly_t p) { - int i; - float[] v; - gl.glBegin(GL.GL_POLYGON); ! for (i=0 ; i<p.numverts ; i++) { ! v = p.verts[i]; ! gl.glTexCoord2f(v[3], v[4]); ! gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd(); --- 155,163 ---- void DrawGLPoly(glpoly_t p) { gl.glBegin(GL.GL_POLYGON); ! for (int i=0 ; i<p.numverts ; i++) { ! gl.glTexCoord2f(p.s1(i), p.t1(i)); ! gl.glVertex3f(p.x(i), p.y(i), p.z(i)); } gl.glEnd(); *************** *** 177,197 **** void DrawGLFlowingPoly(msurface_t fa) { ! int i; ! float[] v; ! glpoly_t p; ! float scroll; ! ! p = fa.polys; ! ! scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) ); if(scroll == 0.0f) scroll = -64.0f; gl.glBegin (GL.GL_POLYGON); ! for (i=0 ; i<p.numverts ; i++) { ! v = p.verts[i]; ! gl.glTexCoord2f ((v[3] + scroll), v[4]); ! gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd (); --- 173,186 ---- void DrawGLFlowingPoly(msurface_t fa) { ! float scroll = -64 * ( (r_newrefdef.time / 40.0f) - (int)(r_newrefdef.time / 40.0f) ); if(scroll == 0.0f) scroll = -64.0f; gl.glBegin (GL.GL_POLYGON); ! glpoly_t p = fa.polys; ! for (int i=0 ; i<p.numverts ; i++) { ! gl.glTexCoord2f(p.s1(i) + scroll, p.t1(i)); ! gl.glVertex3f(p.x(i), p.y(i), p.z(i)); } gl.glEnd (); *************** *** 205,211 **** void R_DrawTriangleOutlines() { - int i, j; - glpoly_t p; - if (gl_showtris.value == 0) return; --- 194,197 ---- *************** *** 215,219 **** gl.glColor4f (1,1,1,1); ! for (i=0 ; i<MAX_LIGHTMAPS ; i++) { msurface_t surf; --- 201,205 ---- gl.glColor4f (1,1,1,1); ! for (int i=0 ; i<MAX_LIGHTMAPS ; i++) { msurface_t surf; *************** *** 221,234 **** 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 (); } --- 207,220 ---- for ( surf = gl_lms.lightmap_surfaces[i]; surf != null; surf = surf.lightmapchain ) { ! glpoly_t p = surf.polys; for ( ; 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 (); } *************** *** 236,240 **** } } - gl.glEnable (GL.GL_DEPTH_TEST); gl.glEnable (GL.GL_TEXTURE_2D); --- 222,225 ---- *************** *** 250,262 **** for ( ; p != null; p = p.chain ) { - float[] v; - int j; - gl.glBegin(GL.GL_POLYGON); ! for (j=0 ; j<p.numverts ; j++) { ! v = p.verts[j]; ! gl.glTexCoord2f (v[5], v[6] ); ! gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd(); --- 235,243 ---- for ( ; p != null; p = p.chain ) { gl.glBegin(GL.GL_POLYGON); ! for (int j=0 ; j<p.numverts ; j++) { ! gl.glTexCoord2f (p.s2(j), p.t2(j)); ! gl.glVertex3f(p.x(j), p.y(j), p.z(j)); } gl.glEnd(); *************** *** 267,279 **** for ( ; p != null; p = p.chain ) { - float[] v; - int j; - gl.glBegin(GL.GL_POLYGON); ! for (j=0 ; j<p.numverts ; j++) { ! v = p.verts[j]; ! gl.glTexCoord2f (v[5] - soffset, v[6] - toffset ); ! gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd(); --- 248,256 ---- for ( ; p != null; p = p.chain ) { gl.glBegin(GL.GL_POLYGON); ! for (int j=0 ; j<p.numverts ; j++) { ! gl.glTexCoord2f (p.s2(j) - soffset, p.t2(j) - toffset); ! gl.glVertex3f(p.x(j), p.y(j), p.z(j)); } gl.glEnd(); *************** *** 804,814 **** for (i=0 ; i< nv; i++) { ! v = p.verts[i]; ! ! gl.glMultiTexCoord2fARB(GL_TEXTURE0, (v[3] + scroll), v[4]); ! gl.glMultiTexCoord2fARB(GL_TEXTURE1, v[5], v[6]); ! //gglMTexCoord2fSGIS( GL_TEXTURE0, v[3], v[4]); //gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]); ! gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd (); --- 781,789 ---- for (i=0 ; i< nv; i++) { ! gl.glMultiTexCoord2fARB(GL_TEXTURE0, p.s1(i) + scroll, p.t1(i)); ! gl.glMultiTexCoord2fARB(GL_TEXTURE1, p.s2(i), p.t2(i)); ! //gglMTexCoord2fSGIS( GL_TEXTURE0, v[3] + scroll, v[4]); //gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]); ! gl.glVertex3f(p.x(i), p.y(i), p.z(i)); } gl.glEnd (); *************** *** 822,832 **** for (i=0 ; i< nv; i++) { ! v = p.verts[i]; ! ! gl.glMultiTexCoord2fARB(GL_TEXTURE0, v[3], v[4]); ! gl.glMultiTexCoord2fARB(GL_TEXTURE1, v[5], v[6]); //gglMTexCoord2fSGIS( GL_TEXTURE0, v[3], v[4]); //gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]); ! gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd (); --- 797,805 ---- for (i=0 ; i< nv; i++) { ! gl.glMultiTexCoord2fARB(GL_TEXTURE0, p.s1(i), p.t1(i)); ! gl.glMultiTexCoord2fARB(GL_TEXTURE1, p.s2(i), p.t2(i)); //gglMTexCoord2fSGIS( GL_TEXTURE0, v[3], v[4]); //gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]); ! gl.glVertex3f(p.x(i), p.y(i), p.z(i)); } gl.glEnd (); *************** *** 858,868 **** for (i=0 ; i< nv; i++) { ! v = p.verts[i]; ! ! gl.glMultiTexCoord2fARB(GL_TEXTURE0, (v[3]+scroll), v[4]); ! gl.glMultiTexCoord2fARB(GL_TEXTURE1, v[5], v[6]); ! // qglMTexCoord2fSGIS( GL_TEXTURE0, (v[3]+scroll), v[4]); ! // qglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]); ! gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd(); --- 831,839 ---- for (i=0 ; i< nv; i++) { ! gl.glMultiTexCoord2fARB(GL_TEXTURE0, p.s1(i) + scroll, p.t1(i)); ! gl.glMultiTexCoord2fARB(GL_TEXTURE1, p.s2(i), p.t2(i)); ! //gglMTexCoord2fSGIS( GL_TEXTURE0, v[3] + scroll, v[4]); ! //gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]); ! gl.glVertex3f(p.x(i), p.y(i), p.z(i)); } gl.glEnd(); *************** *** 878,888 **** for (i=0 ; i< nv; i++) { ! v = p.verts[i]; ! ! gl.glMultiTexCoord2fARB(GL_TEXTURE0, v[3], v[4]); ! gl.glMultiTexCoord2fARB(GL_TEXTURE1, v[5], v[6]); //gglMTexCoord2fSGIS( GL_TEXTURE0, v[3], v[4]); //gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]); ! gl.glVertex3f(v[0], v[1], v[2]); } gl.glEnd (); --- 849,857 ---- for (i=0 ; i< nv; i++) { ! gl.glMultiTexCoord2fARB(GL_TEXTURE0, p.s1(i), p.t1(i)); ! gl.glMultiTexCoord2fARB(GL_TEXTURE1, p.s2(i), p.t2(i)); //gglMTexCoord2fSGIS( GL_TEXTURE0, v[3], v[4]); //gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]); ! gl.glVertex3f(p.x(i), p.y(i), p.z(i)); } gl.glEnd (); *************** *** 1478,1487 **** // // 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++) --- 1447,1455 ---- // // poly = Hunk_Alloc (sizeof(glpoly_t) + (lnumverts-4) * VERTEXSIZE*sizeof(float)); ! poly = Polygon.create(lnumverts); poly.next = fa.polys; poly.flags = fa.flags; fa.polys = poly; for (i=0 ; i<lnumverts ; i++) *************** *** 1506,1512 **** Math3D.VectorAdd (total, vec, total); ! Math3D.VectorCopy (vec, poly.verts[i]); ! poly.verts[i][3] = s; ! poly.verts[i][4] = t; // --- 1474,1486 ---- Math3D.VectorAdd (total, vec, total); ! //Math3D.VectorCopy (vec, poly.verts[i]); ! poly.x(i, vec[0]); ! poly.y(i, vec[1]); ! poly.z(i, vec[2]); ! ! //poly.verts[i][3] = s; ! //poly.verts[i][4] = t; ! poly.s1(i, s); ! poly.t1(i, t); // *************** *** 1525,1534 **** t /= BLOCK_HEIGHT*16; //fa.texinfo.texture.height; ! poly.verts[i][5] = s; ! poly.verts[i][6] = t; } - - poly.numverts = lnumverts; - } --- 1499,1507 ---- t /= BLOCK_HEIGHT*16; //fa.texinfo.texture.height; ! //poly.verts[i][5] = s; ! //poly.verts[i][6] = t; ! poly.s2(i, s); ! poly.t2(i, t); } } --- NEW FILE: Polygon.java --- /* * Polygon.java * Copyright (C) 2003 * * $Id: Polygon.java,v 1.1.2.1 2005/01/16 21:21:10 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.jogl; import jake2.render.glpoly_t; /** * Polygon * * @author cwei */ public final class Polygon extends glpoly_t { private final static int MAXPOLYS = 20000; private final static int MAX_BUFFER_VERTICES = 120000; private static float[] buffer = new float[MAX_BUFFER_VERTICES * STRIDE]; private static int bufferIndex = 0; private static int polyCount = 0; private static Polygon[] polyCache = new Polygon[MAXPOLYS]; static { for (int i = 0; i < polyCache.length; i++) { polyCache[i] = new Polygon(); } } public static glpoly_t create(int numverts) { Polygon poly = polyCache[polyCount++]; poly.clear(); poly.numverts = numverts; poly.pos = bufferIndex; bufferIndex += numverts; return poly; } public static void reset() { polyCount = 0; bufferIndex = 0; } private Polygon() { } private final void clear() { next = null; chain = null; numverts = 0; flags = 0; } public final float x(int index) { return buffer[(index + pos) * 7 + 0]; } public final void x(int index, float value) { buffer[(index + pos) * 7 + 0] = value; } public final float y(int index) { return buffer[(index + pos) * 7 + 1]; } public final void y(int index, float value) { buffer[(index + pos) * 7 + 1] = value; } public final float z(int index) { return buffer[(index + pos) * 7 + 2]; } public final void z(int index, float value) { buffer[(index + pos) * 7 + 2] = value; } public final float s1(int index) { return buffer[(index + pos) * 7 + 3]; } public final void s1(int index, float value) { buffer[(index + pos) * 7 + 3] = value; } public final float t1(int index) { return buffer[(index + pos) * 7 + 4]; } public final void t1(int index, float value) { buffer[(index + pos) * 7 + 4] = value; } public final float s2(int index) { return buffer[(index + pos) * 7 + 5]; } public final void s2(int index, float value) { buffer[(index + pos) * 7 + 5] = value; } public final float t2(int index) { return buffer[(index + pos) * 7 + 6]; } public final void t2(int index, float value) { buffer[(index + pos) * 7 + 6] = value; } public final void beginScrolling(float value) { // not in use } public final void endScrolling() { // not in use } } Index: Model.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/render/jogl/Model.java,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -C2 -d -r1.4 -r1.4.6.1 *** Model.java 16 Jul 2004 10:11:35 -0000 1.4 --- Model.java 16 Jan 2005 21:21:10 -0000 1.4.6.1 *************** *** 1150,1153 **** --- 1150,1155 ---- { cvar_t flushmap; + + Polygon.reset(); registration_sequence++; |