aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2
diff options
context:
space:
mode:
authorCarsten Weisse <[email protected]>2005-02-01 16:55:28 +0000
committerCarsten Weisse <[email protected]>2005-02-01 16:55:28 +0000
commit362abe1e11a7ec5b63a7e703c03edeb639422561 (patch)
treedddbebf9cc611330be7c9e322ec9886c4aaa9376 /src/jake2
parente39c6f05a296e872b4b4dd024913c67dfdc9c19f (diff)
a little bit faster
Diffstat (limited to 'src/jake2')
-rw-r--r--src/jake2/render/lwjgl/Mesh.java43
-rw-r--r--src/jake2/render/lwjgl/Surf.java16
2 files changed, 32 insertions, 27 deletions
diff --git a/src/jake2/render/lwjgl/Mesh.java b/src/jake2/render/lwjgl/Mesh.java
index 6bb8f95..34af9ec 100644
--- a/src/jake2/render/lwjgl/Mesh.java
+++ b/src/jake2/render/lwjgl/Mesh.java
@@ -2,7 +2,7 @@
* Mesh.java
* Copyright (C) 2003
*
- * $Id: Mesh.java,v 1.4 2005-01-22 22:28:15 cawe Exp $
+ * $Id: Mesh.java,v 1.5 2005-02-01 16:55:07 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -81,34 +81,35 @@ public abstract class Mesh extends Light {
int[] ovv;
int[] vv;
FloatBuffer lerp = vertexArrayBuf;
+ lerp.limit((nverts << 2) - nverts); // nverts * 3
//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 )
{
float[] normal;
- int j = 0;
+ int j = -1;
for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */)
{
normal = r_avertexnormals[verts[i].lightnormalindex];
ovv = ov[i].v;
vv = verts[i].v;
- lerp.put(j++, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE);
- lerp.put(j++, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE);
- lerp.put(j++, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE);
+ lerp.put(++j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE);
+ lerp.put(++j, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE);
+ lerp.put(++j, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE);
}
}
else
{
- int j = 0;
+ int j = -1;
for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */)
{
ovv = ov[i].v;
vv = verts[i].v;
- lerp.put(j++, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0]);
- lerp.put(j++, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1]);
- lerp.put(j++, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2]);
+ lerp.put(++j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0]);
+ lerp.put(++j, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1]);
+ lerp.put(++j, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2]);
}
}
}
@@ -192,15 +193,16 @@ public abstract class Mesh extends Light {
// pre light everything
//
FloatBuffer color = colorArrayBuf;
- int j = 0;
+ int j = -1;
float l;
- for (int i = 0; i < paliashdr.num_xyz; i++ )
+ int size = paliashdr.num_xyz;
+ for (int i = 0; i < size; i++ )
{
l = shadedots[verts[i].lightnormalindex];
- color.put(j++, l * shadelight[0]);
- color.put(j++, l * shadelight[1]);
- color.put(j++, l * shadelight[2]);
- color.put(j++, alpha);
+ color.put(++j, l * shadelight[0]);
+ color.put(++j, l * shadelight[1]);
+ color.put(++j, l * shadelight[2]);
+ color.put(++j, alpha);
}
}
@@ -219,7 +221,9 @@ public abstract class Mesh extends Light {
int dstIndex = 0;
int srcIndex = 0;
int count;
- for (int j = 0; j < counts.length; j++) {
+ int mode;
+ int size = counts.length;
+ for (int j = 0; j < size; j++) {
// get the vertex count and primitive type
count = counts[j];
@@ -228,16 +232,17 @@ public abstract class Mesh extends Light {
srcIndexBuf = paliashdr.indexElements[j];
- int mode = GL11.GL_TRIANGLE_STRIP;
+ mode = GL11.GL_TRIANGLE_STRIP;
if (count < 0) {
mode = GL11.GL_TRIANGLE_FAN;
count = -count;
}
srcIndex = pos << 1;
+ srcIndex--;
for (int k = 0; k < count; k++) {
dstIndex = srcIndexBuf.get(k) << 1;
- dstTextureCoords.put(dstIndex++, srcTextureCoords.get(srcIndex++));
- dstTextureCoords.put(dstIndex, srcTextureCoords.get(srcIndex++));
+ dstTextureCoords.put(dstIndex, srcTextureCoords.get(++srcIndex));
+ dstTextureCoords.put(++dstIndex, srcTextureCoords.get(++srcIndex));
}
gl.glDrawElements(mode, srcIndexBuf);
diff --git a/src/jake2/render/lwjgl/Surf.java b/src/jake2/render/lwjgl/Surf.java
index 4da9ae9..40e9bcf 100644
--- a/src/jake2/render/lwjgl/Surf.java
+++ b/src/jake2/render/lwjgl/Surf.java
@@ -2,7 +2,7 @@
* Surf.java
* Copyright (C) 2003
*
- * $Id: Surf.java,v 1.7 2005-01-17 16:50:24 cawe Exp $
+ * $Id: Surf.java,v 1.8 2005-02-01 16:55:28 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -937,15 +937,15 @@ public abstract class Surf extends Draw {
if (r_viewcluster2 != r_viewcluster)
{
// memcpy (fatvis, vis, (r_worldmodel.numleafs+7)/8);
- System.arraycopy(vis, 0, fatvis, 0, (r_worldmodel.numleafs+7) / 8);
+ System.arraycopy(vis, 0, fatvis, 0, (r_worldmodel.numleafs+7) >> 3);
vis = Mod_ClusterPVS(r_viewcluster2, r_worldmodel);
- c = (r_worldmodel.numleafs + 31) / 32;
- int k = 0;
+ c = (r_worldmodel.numleafs + 31) >> 5;
+ int k = -1;
for (i=0 ; i<c ; i++) {
- fatvis[k] |= vis[k++];
- fatvis[k] |= vis[k++];
- fatvis[k] |= vis[k++];
- fatvis[k] |= vis[k++];
+ fatvis[++k] |= vis[k];
+ fatvis[++k] |= vis[k];
+ fatvis[++k] |= vis[k];
+ fatvis[++k] |= vis[k];
}
vis = fatvis;