aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-09 10:25:29 +0000
committerHolger Zickner <[email protected]>2004-07-09 10:25:29 +0000
commitbd16aab44f7774f6127702cfa036407462b5a0ba (patch)
treea83612a3d864d6d60bca8493b83dd20725a9a027 /src/jake2
parent20a66a892a3f0704ef37f1eebb681edfee6fc165 (diff)
performance tweaks
Diffstat (limited to 'src/jake2')
-rw-r--r--src/jake2/client/CL_tent.java23
-rw-r--r--src/jake2/render/fastjogl/Image.java18
-rw-r--r--src/jake2/render/fastjogl/Light.java68
-rw-r--r--src/jake2/render/fastjogl/Mesh.java118
4 files changed, 111 insertions, 116 deletions
diff --git a/src/jake2/client/CL_tent.java b/src/jake2/client/CL_tent.java
index 8966e01..bca8edf 100644
--- a/src/jake2/client/CL_tent.java
+++ b/src/jake2/client/CL_tent.java
@@ -2,7 +2,7 @@
* CL_tent.java
* Copyright (C) 2004
*
- * $Id: CL_tent.java,v 1.3 2004-07-08 20:56:50 hzi Exp $
+ * $Id: CL_tent.java,v 1.4 2004-07-09 10:19:57 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -1358,8 +1358,6 @@ public class CL_tent extends Globals {
=================
*/
static void AddPlayerBeams() {
- int i, j;
- beam_t[] b;
float[] dist = new float[3];
float[] org = new float[3];
float d;
@@ -1388,11 +1386,12 @@ public class CL_tent extends Globals {
// PMM
// update beams
- b = cl_playerbeams;
- for (i = 0; i < MAX_BEAMS; i++) {
- float[] f = new float[3];
- float[] u = new float[3];
- float[] r = new float[3];
+ beam_t[] b = cl_playerbeams;
+ float[] f = new float[3];
+ float[] u = new float[3];
+ float[] r = new float[3];
+ for (int i = 0; i < MAX_BEAMS; i++) {
+
if (b[i].model == null || b[i].endtime < cl.time)
continue;
@@ -1404,7 +1403,7 @@ public class CL_tent extends Globals {
// set up gun position
// code straight out of CL_AddViewWeapon
ps = cl.frame.playerstate;
- j = (cl.frame.serverframe - 1) & UPDATE_MASK;
+ int j = (cl.frame.serverframe - 1) & UPDATE_MASK;
oldframe = cl.frames[j];
if (oldframe.serverframe != cl.frame.serverframe - 1 || !oldframe.valid)
@@ -1513,7 +1512,9 @@ public class CL_tent extends Globals {
d = VectorNormalize(dist);
//memset (&ent, 0, sizeof(ent));
- ent = new entity_t();
+ //ent = new entity_t();
+ // this is not required. hoz
+
if (b[i].model == cl_mod_heatbeam) {
model_length = 32.0f;
} else if (b[i].model == cl_mod_lightning) {
@@ -1569,7 +1570,7 @@ public class CL_tent extends Globals {
// Com_Printf("B: %d . %d\n", b[i].entity, b[i].dest_entity);
V.AddEntity(ent);
- for (j = 0; j < 3; j++)
+ for (int j = 0; j < 3; j++)
org[j] += dist[j] * len;
d -= model_length;
}
diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java
index de364c3..b05321b 100644
--- a/src/jake2/render/fastjogl/Image.java
+++ b/src/jake2/render/fastjogl/Image.java
@@ -2,7 +2,7 @@
* Image.java
* Copyright (C) 2003
*
- * $Id: Image.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Image.java,v 1.2 2004-07-09 10:22:28 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -743,19 +743,25 @@ public abstract class Image extends Main {
// }
// 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)
+ // TODO sync with jogl renderer. hoz
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];
+// 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();
- }
+// for (int j = 0; j < fifo.length; j++) {
+// fifo[j] = new floodfill_t();
+// }
if (filledcolor == -1) {
filledcolor = 0;
diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java
index b963b21..9f85766 100644
--- a/src/jake2/render/fastjogl/Light.java
+++ b/src/jake2/render/fastjogl/Light.java
@@ -2,7 +2,7 @@
* Light.java
* Copyright (C) 2003
*
- * $Id: Light.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Light.java,v 1.2 2004-07-09 10:24:32 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -28,7 +28,6 @@ package jake2.render.fastjogl;
import jake2.Defines;
import jake2.Globals;
import jake2.client.dlight_t;
-import jake2.client.lightstyle_t;
import jake2.game.GameBase;
import jake2.game.cplane_t;
import jake2.qcommon.longjmpException;
@@ -223,14 +222,15 @@ public abstract class Light extends Warp {
float[] pointcolor = {0, 0, 0}; // vec3_t
cplane_t lightplane; // used as shadow plane
float[] lightspot = {0, 0, 0}; // vec3_t
-
+ float[] mid = {0, 0, 0};
+
+// TODO sync with jogl renderer. hoz
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};
+ cplane_t plane;
msurface_t surf;
int s, t, ds, dt;
int i;
@@ -272,6 +272,7 @@ public abstract class Light extends Warp {
lightplane = plane;
int surfIndex = node.firstsurface;
+ float[] scale = {0, 0, 0};
for (i=0 ; i<node.numsurfaces ; i++, surfIndex++)
{
surf = r_worldmodel.surfaces[surfIndex];
@@ -305,7 +306,7 @@ public abstract class Light extends Warp {
Math3D.VectorCopy (Globals.vec3_origin, pointcolor);
if (lightmap != null)
{
- float[] scale = {0, 0, 0};
+ //float[] scale = {0, 0, 0};
float[] rgb;
lightmapIndex += 3 * (dt * ((surf.extents[0] >> 4) + 1) + ds);
@@ -398,26 +399,23 @@ public abstract class Light extends Warp {
R_AddDynamicLights
===============
*/
+ // TODO sync with jogl renderer. hoz
void R_AddDynamicLights(msurface_t surf)
{
- int lnum;
int sd, td;
float fdist, frad, fminlight;
float[] impact = {0, 0, 0};
float[] local = {0, 0, 0};
int s, t;
- int i;
- int smax, tmax;
- mtexinfo_t tex;
dlight_t dl;
float[] pfBL;
float fsacc, ftacc;
- smax = (surf.extents[0]>>4)+1;
- tmax = (surf.extents[1]>>4)+1;
- tex = surf.texinfo;
+ int smax = (surf.extents[0]>>4)+1;
+ int tmax = (surf.extents[1]>>4)+1;
+ mtexinfo_t tex = surf.texinfo;
- for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
+ for (int lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
{
if ( (surf.dlightbits & (1<<lnum)) == 0 )
continue; // not lit by this light
@@ -434,7 +432,7 @@ public abstract class Light extends Warp {
continue;
fminlight = frad - fminlight;
- for (i=0 ; i<3 ; i++)
+ for (int i=0 ; i<3 ; i++)
{
impact[i] = dl.origin[i] -
surf.plane.normal[i]*fdist;
@@ -451,7 +449,7 @@ public abstract class Light extends Warp {
if ( td < 0 )
td = -td;
- for ( s=0, fsacc = 0 ; s<smax ; s++, fsacc += 16, pfBLindex += 3)
+ for (s=0, fsacc = 0 ; s<smax ; s++, fsacc += 16, pfBLindex += 3)
{
sd = (int)( local[0] - fsacc );
@@ -480,10 +478,7 @@ public abstract class Light extends Warp {
*/
void R_SetCacheState( msurface_t surf )
{
- int maps;
-
- for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ;
- maps++)
+ for (int maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ; maps++)
{
surf.cached_light[maps] = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].white;
}
@@ -496,24 +491,23 @@ public abstract class Light extends Warp {
Combine and scale multiple lightmaps into the floating format in blocklights
===============
*/
+// TODO sync with jogl renderer. hoz
void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride)
{
- int smax, tmax;
int r, g, b, a, max;
- int i, j, size;
+ int i, j;
ByteBuffer lightmap;
- float[] scale = {0, 0, 0, 0};
+ float[] scale = {0, 0, 0};
int nummaps;
float[] bl;
- lightstyle_t style;
- int monolightmap;
+ //lightstyle_t style;
if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) != 0 )
ri.Sys_Error(Defines.ERR_DROP, "R_BuildLightMap called for non-lit surface");
- smax = (surf.extents[0] >> 4) + 1;
- tmax = (surf.extents[1] >> 4) + 1;
- size = smax * tmax;
+ int smax = (surf.extents[0] >> 4) + 1;
+ int tmax = (surf.extents[1] >> 4) + 1;
+ int size = smax * tmax;
if (size > ((s_blocklights.length * Defines.SIZE_OF_FLOAT) >> 4) )
ri.Sys_Error(Defines.ERR_DROP, "Bad s_blocklights size");
@@ -525,11 +519,13 @@ public abstract class Light extends Warp {
for (i=0 ; i<size*3 ; i++)
s_blocklights[i] = 255;
-
- for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++)
- {
- style = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF];
- }
+
+// TODO useless? hoz
+// for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++)
+// {
+// style = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF];
+// }
+
// goto store;
throw new longjmpException();
}
@@ -632,7 +628,7 @@ public abstract class Light extends Warp {
bl = s_blocklights;
int blp = 0;
- monolightmap = gl_monolightmap.string.charAt(0);
+ int monolightmap = gl_monolightmap.string.charAt(0);
int destp = 0;
@@ -687,7 +683,7 @@ public abstract class Light extends Warp {
b = (int)(b*t);
a = (int)(a*t);
}
- r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF;
+ //r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF;
dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | (r << 0));
}
}
@@ -768,7 +764,7 @@ public abstract class Light extends Warp {
a = 255 - a;
break;
}
- r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF;
+ //r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF;
dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | (r << 0));
}
}
diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java
index e7da997..572e691 100644
--- a/src/jake2/render/fastjogl/Mesh.java
+++ b/src/jake2/render/fastjogl/Mesh.java
@@ -2,7 +2,7 @@
* Mesh.java
* Copyright (C) 2003
*
- * $Id: Mesh.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Mesh.java,v 1.2 2004-07-09 10:25:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,19 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.render.fastjogl;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-
-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;
import jake2.render.image_t;
import jake2.util.Math3D;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+
+import net.java.games.jogl.GL;
+import net.java.games.jogl.util.BufferUtils;
+
/**
* Mesh
*
@@ -340,22 +339,13 @@ public abstract class Mesh extends Light {
/*
** R_CullAliasModel
*/
- boolean R_CullAliasModel( float[][] bbox, entity_t e )
+// TODO sync with jogl renderer. hoz
+ boolean R_CullAliasModel(entity_t e)
{
- int i;
float[] mins = {0, 0, 0};
float[] maxs = {0, 0, 0};
- qfiles.dmdl_t paliashdr;
-
- float[] thismins = {0, 0, 0};
- float[] oldmins = {0, 0, 0};
- float[] thismaxs = {0, 0, 0};
- float[] oldmaxs = {0, 0, 0};
- qfiles.daliasframe_t pframe, poldframe;
- float[] angles = {0, 0, 0};
-
- paliashdr = (qfiles.dmdl_t)currentmodel.extradata;
+ qfiles.dmdl_t paliashdr = (qfiles.dmdl_t)currentmodel.extradata;
if ( ( e.frame >= paliashdr.num_frames ) || ( e.frame < 0 ) )
{
@@ -368,15 +358,15 @@ public abstract class Mesh extends Light {
e.oldframe = 0;
}
- pframe = paliashdr.aliasFrames[e.frame];
- poldframe = paliashdr.aliasFrames[e.oldframe];
+ qfiles.daliasframe_t pframe = paliashdr.aliasFrames[e.frame];
+ qfiles.daliasframe_t poldframe = paliashdr.aliasFrames[e.oldframe];
/*
** compute axially aligned mins and maxs
*/
if ( pframe == poldframe )
{
- for ( i = 0; i < 3; i++ )
+ for ( int i = 0; i < 3; i++ )
{
mins[i] = pframe.translate[i];
maxs[i] = mins[i] + pframe.scale[i]*255;
@@ -384,18 +374,22 @@ public abstract class Mesh extends Light {
}
else
{
- for ( i = 0; i < 3; i++ )
+ //float[] thismins = {0, 0, 0};
+ //float[] oldmins = {0, 0, 0};
+ float[] thismaxs = {0, 0, 0};
+ float[] oldmaxs = {0, 0, 0};
+ for ( int i = 0; i < 3; i++ )
{
- thismins[i] = pframe.translate[i];
- thismaxs[i] = thismins[i] + pframe.scale[i]*255;
+ //thismins[i] = pframe.translate[i];
+ thismaxs[i] = pframe.translate[i] + pframe.scale[i]*255;
- oldmins[i] = poldframe.translate[i];
- oldmaxs[i] = oldmins[i] + poldframe.scale[i]*255;
+ //oldmins[i] = poldframe.translate[i];
+ oldmaxs[i] = poldframe.translate[i] + poldframe.scale[i]*255;
- if ( thismins[i] < oldmins[i] )
- mins[i] = thismins[i];
+ if ( pframe.translate[i] < poldframe.translate[i] )
+ mins[i] = pframe.translate[i];
else
- mins[i] = oldmins[i];
+ mins[i] = poldframe.translate[i];
if ( thismaxs[i] > oldmaxs[i] )
maxs[i] = thismaxs[i];
@@ -407,9 +401,9 @@ public abstract class Mesh extends Light {
/*
** compute a full bounding box
*/
- for ( i = 0; i < 8; i++ )
+ float[] tmp = {0, 0, 0};
+ for ( int i = 0; i < 8; i++ )
{
- float[] tmp = {0, 0, 0};
if ( (i & 1) != 0 )
tmp[0] = mins[0];
@@ -432,13 +426,12 @@ public abstract class Mesh extends Light {
/*
** rotate the bounding box
*/
- Math3D.VectorCopy( e.angles, angles );
- angles[YAW] = -angles[YAW];
- Math3D.AngleVectors( angles, vectors[0], vectors[1], vectors[2] );
-
- float[] tmp = {0, 0, 0};
+ //float[] angles = {0, 0, 0};
+ Math3D.VectorCopy( e.angles, tmp );
+ tmp[YAW] = -tmp[YAW];
+ Math3D.AngleVectors( tmp, vectors[0], vectors[1], vectors[2] );
- for ( i = 0; i < 8; i++ )
+ for ( int i = 0; i < 8; i++ )
{
Math3D.VectorCopy( bbox[i], tmp );
@@ -449,34 +442,32 @@ public abstract class Mesh extends Light {
Math3D.VectorAdd( e.origin, bbox[i], bbox[i] );
}
+ int f, mask;
+ int aggregatemask = ~0; // 0xFFFFFFFF
+
+ for ( int p = 0; p < 8; p++ )
{
- int p, f;
- int aggregatemask = ~0; // 0xFFFFFFFF
-
- for ( p = 0; p < 8; p++ )
+ mask = 0;
+
+ for ( f = 0; f < 4; f++ )
{
- int mask = 0;
+ float dp = Math3D.DotProduct( frustum[f].normal, bbox[p] );
- for ( f = 0; f < 4; f++ )
+ if ( ( dp - frustum[f].dist ) < 0 )
{
- float dp = Math3D.DotProduct( frustum[f].normal, bbox[p] );
-
- if ( ( dp - frustum[f].dist ) < 0 )
- {
- mask |= ( 1 << f );
- }
+ mask |= ( 1 << f );
}
-
- aggregatemask &= mask;
}
- if ( aggregatemask != 0 )
- {
- return true;
- }
+ aggregatemask &= mask;
+ }
- return false;
+ if ( aggregatemask != 0 )
+ {
+ return true;
}
+
+ return false;
}
@@ -492,17 +483,18 @@ public abstract class Mesh extends Light {
=================
*/
+// TODO sync with jogl renderer. hoz
void R_DrawAliasModel(entity_t e)
{
int i;
- qfiles.dmdl_t paliashdr;
- float an;
+ //qfiles.dmdl_t paliashdr;
+ //float an;
image_t skin;
if ( ( e.flags & Defines.RF_WEAPONMODEL ) == 0)
{
- if ( R_CullAliasModel( bbox, e ) )
+ if ( R_CullAliasModel(e) )
return;
}
@@ -512,7 +504,7 @@ public abstract class Mesh extends Light {
return;
}
- paliashdr = (qfiles.dmdl_t)currentmodel.extradata;
+ qfiles.dmdl_t paliashdr = (qfiles.dmdl_t)currentmodel.extradata;
//
// get lighting information
@@ -629,7 +621,7 @@ public abstract class Mesh extends Light {
shadedots = r_avertexnormal_dots[((int)(currententity.angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
- an = (float)(currententity.angles[1]/180*Math.PI);
+ float an = (float)(currententity.angles[1]/180*Math.PI);
shadevector[0] = (float)Math.cos(-an);
shadevector[1] = (float)Math.sin(-an);
shadevector[2] = 1;