summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-12 22:08:04 +0000
committerHolger Zickner <[email protected]>2004-07-12 22:08:04 +0000
commit87169713e60b4e00e9179c1bc32a1bcbf2ce8d75 (patch)
tree1ac285e316d8a9b9f3b4229a25351f489eac47ed /src
parent4dca2574fe978cb98a9320f6db8176ee77973e91 (diff)
small optimizations
Diffstat (limited to 'src')
-rw-r--r--src/jake2/render/fastjogl/Image.java3
-rw-r--r--src/jake2/render/fastjogl/Light.java42
-rw-r--r--src/jake2/render/fastjogl/Mesh.java25
-rw-r--r--src/jake2/render/fastjogl/Model.java11
-rw-r--r--src/jake2/render/fastjogl/Warp.java15
-rw-r--r--src/jake2/render/jogl/Image.java14
-rw-r--r--src/jake2/render/jogl/Light.java54
-rw-r--r--src/jake2/render/jogl/Mesh.java59
-rw-r--r--src/jake2/render/jogl/Model.java33
-rw-r--r--src/jake2/render/jogl/Warp.java12
10 files changed, 114 insertions, 154 deletions
diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java
index b05321b..1f80af0 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.2 2004-07-09 10:22:28 hzi Exp $
+ * $Id: Image.java,v 1.3 2004-07-12 22:08:02 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -750,7 +750,6 @@ public abstract class Image extends Main {
}
}
// 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;
diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java
index 298a3db..a9e64a5 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.3 2004-07-09 16:44:01 hzi Exp $
+ * $Id: Light.java,v 1.4 2004-07-12 22:08:02 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -223,44 +223,38 @@ public abstract class Light extends Warp {
cplane_t lightplane; // used as shadow plane
float[] lightspot = {0, 0, 0}; // vec3_t
-// 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;
+ 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;
- int r;
float[] mid = {0, 0, 0};
-
- 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;
+ 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);
- frac = front / (front-back);
+ float frac = front / (front-back);
mid[0] = start[0] + (end[0] - start[0])*frac;
mid[1] = start[1] + (end[1] - start[1])*frac;
mid[2] = start[2] + (end[2] - start[2])*frac;
// go down front side
- r = RecursiveLightPoint (node.children[sideIndex], start, mid);
+ int r = RecursiveLightPoint (node.children[sideIndex], start, mid);
if (r >= 0)
return r; // hit something
@@ -341,11 +335,7 @@ public abstract class Light extends Warp {
assert (color.length == 3) : "rgb bug";
float[] end = {0, 0, 0};
- float r;
- int lnum;
dlight_t dl;
- float light;
- float[] dist = {0, 0, 0};
float add;
if (r_worldmodel.lightdata == null)
@@ -358,7 +348,7 @@ public abstract class Light extends Warp {
end[1] = p[1];
end[2] = p[2] - 2048;
- r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end);
+ float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end);
if (r == -1)
{
@@ -372,13 +362,12 @@ public abstract class Light extends Warp {
//
// add dynamic lights
//
- light = 0;
- for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
+ for (int 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);
+ Math3D.VectorSubtract (currententity.origin, dl.origin, end);
+ add = dl.intensity - Math3D.VectorLength(end);
add *= (1.0f/256);
if (add > 0)
{
@@ -389,7 +378,6 @@ public abstract class Light extends Warp {
Math3D.VectorScale (color, gl_modulate.value, color);
}
-
// ===================================================================
float[] s_blocklights = new float[34 * 34 * 3];
diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java
index 572e691..257fc68 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.2 2004-07-09 10:25:29 hzi Exp $
+ * $Id: Mesh.java,v 1.3 2004-07-12 22:08:02 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -67,20 +67,20 @@ public abstract class Mesh extends Light {
float[] shadedots = r_avertexnormal_dots[0];
- 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 )
+ void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv )
{
- int i;
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 )
{
float[] normal;
int j = 0;
- for (i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */)
+ for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */)
{
normal = r_avertexnormals[verts[i].lightnormalindex];
ovv = ov[i].v;
@@ -95,7 +95,7 @@ public abstract class Mesh extends Light {
else
{
int j = 0;
- for (i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */)
+ for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */)
{
ovv = ov[i].v;
vv = v[i].v;
@@ -140,7 +140,6 @@ public abstract class Mesh extends Light {
float alpha;
float[] move = {0, 0, 0}; // vec3_t
- float[] delta = {0, 0, 0}; // vec3_t
float[] frontv = {0, 0, 0}; // vec3_t
float[] backv = {0, 0, 0}; // vec3_t
@@ -168,29 +167,25 @@ public abstract class Mesh extends Light {
frontlerp = 1.0f - backlerp;
// move should be the delta back to the previous frame * backlerp
- Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, delta);
+ Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv);
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
+ 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);
for (i=0 ; i<3 ; i++)
{
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];
}
// ab hier wird optimiert
- GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, vertexArrayBuf, move, frontv, backv );
+ GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, move, frontv, backv );
//gl.glEnableClientState( GL.GL_VERTEX_ARRAY );
gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexArrayBuf );
diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java
index 4b781be..c7d83e9 100644
--- a/src/jake2/render/fastjogl/Model.java
+++ b/src/jake2/render/fastjogl/Model.java
@@ -2,7 +2,7 @@
* Model.java
* Copyright (C) 2003
*
- * $Id: Model.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Model.java,v 1.2 2004-07-12 22:08:02 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -560,18 +560,17 @@ public abstract class Model extends Surf {
float[] maxs = {0, 0};
float val;
- int i, j, e;
+ int j, e;
mvertex_t v;
- mtexinfo_t tex;
int[] bmins = {0, 0};
int[] bmaxs = {0, 0};
mins[0] = mins[1] = 999999;
maxs[0] = maxs[1] = -99999;
- tex = s.texinfo;
+ mtexinfo_t tex = s.texinfo;
- for (i=0 ; i<s.numedges ; i++)
+ for (int i=0 ; i<s.numedges ; i++)
{
e = loadmodel.surfedges[s.firstedge+i];
if (e >= 0)
@@ -592,7 +591,7 @@ public abstract class Model extends Surf {
}
}
- for (i=0 ; i<2 ; i++)
+ for (int i=0 ; i<2 ; i++)
{
bmins[i] = (int)Math.floor(mins[i]/16);
bmaxs[i] = (int)Math.ceil(maxs[i]/16);
diff --git a/src/jake2/render/fastjogl/Warp.java b/src/jake2/render/fastjogl/Warp.java
index f9a5b07..d7645f8 100644
--- a/src/jake2/render/fastjogl/Warp.java
+++ b/src/jake2/render/fastjogl/Warp.java
@@ -2,7 +2,7 @@
* Warp.java
* Copyright (C) 2003
*
- * $Id: Warp.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Warp.java,v 1.2 2004-07-12 22:08:02 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,15 +25,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.render.fastjogl;
-import java.nio.FloatBuffer;
-
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.render.*;
import jake2.util.Math3D;
+
+import java.nio.FloatBuffer;
+
import net.java.games.jogl.GL;
/**
@@ -125,7 +123,6 @@ public abstract class Warp extends Model {
int f, b;
float[] dist = new float[64];
float frac;
- glpoly_t poly;
float s, t;
float[] total = {0, 0, 0};
float total_s, total_t;
@@ -194,7 +191,7 @@ public abstract class Warp extends Model {
// poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float));
// init polys
- poly = new glpoly_t(numverts + 2);
+ glpoly_t poly = new glpoly_t(numverts + 2);
poly.next = warpface.polys;
warpface.polys = poly;
diff --git a/src/jake2/render/jogl/Image.java b/src/jake2/render/jogl/Image.java
index f0034fe..3a58884 100644
--- a/src/jake2/render/jogl/Image.java
+++ b/src/jake2/render/jogl/Image.java
@@ -2,7 +2,7 @@
* Image.java
* Copyright (C) 2003
*
- * $Id: Image.java,v 1.3 2004-07-09 06:50:48 hzi Exp $
+ * $Id: Image.java,v 1.4 2004-07-12 22:08:03 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -761,20 +761,20 @@ 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)
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;
// attempt to find opaque black
diff --git a/src/jake2/render/jogl/Light.java b/src/jake2/render/jogl/Light.java
index 851f4e6..e9e83af 100644
--- a/src/jake2/render/jogl/Light.java
+++ b/src/jake2/render/jogl/Light.java
@@ -2,7 +2,7 @@
* Light.java
* Copyright (C) 2003
*
- * $Id: Light.java,v 1.4 2004-07-09 06:50:48 hzi Exp $
+ * $Id: Light.java,v 1.5 2004-07-12 22:08:04 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -230,41 +230,36 @@ public abstract class Light extends Warp {
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};
+ 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;
- int r;
-
- if (node.contents != -1)
- return -1; // didn't hit anything
+ float[] mid = {0, 0, 0};
// 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;
+ 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);
- frac = front / (front-back);
+ float frac = front / (front-back);
mid[0] = start[0] + (end[0] - start[0])*frac;
mid[1] = start[1] + (end[1] - start[1])*frac;
mid[2] = start[2] + (end[2] - start[2])*frac;
// go down front side
- r = RecursiveLightPoint (node.children[sideIndex], start, mid);
+ int r = RecursiveLightPoint (node.children[sideIndex], start, mid);
if (r >= 0)
return r; // hit something
@@ -276,6 +271,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];
@@ -309,13 +305,16 @@ 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);
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];
+ 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);
@@ -325,6 +324,7 @@ public abstract class Light extends Warp {
}
return 1;
}
+
// go down back side
return RecursiveLightPoint (node.children[1 - sideIndex], mid, end);
}
@@ -340,11 +340,7 @@ public abstract class Light extends Warp {
assert (color.length == 3) : "rgb bug";
float[] end = {0, 0, 0};
- float r;
- int lnum;
dlight_t dl;
- float light;
- float[] dist = {0, 0, 0};
float add;
if (r_worldmodel.lightdata == null)
@@ -357,7 +353,7 @@ public abstract class Light extends Warp {
end[1] = p[1];
end[2] = p[2] - 2048;
- r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end);
+ float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end);
if (r == -1)
{
@@ -371,13 +367,12 @@ public abstract class Light extends Warp {
//
// add dynamic lights
//
- light = 0;
- for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
+ for (int 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);
+ Math3D.VectorSubtract (currententity.origin, dl.origin, end);
+ add = dl.intensity - Math3D.VectorLength(end);
add *= (1.0f/256);
if (add > 0)
{
@@ -388,7 +383,6 @@ public abstract class Light extends Warp {
Math3D.VectorScale (color, gl_modulate.value, color);
}
-
// ===================================================================
float[] s_blocklights = new float[34 * 34 * 3];
diff --git a/src/jake2/render/jogl/Mesh.java b/src/jake2/render/jogl/Mesh.java
index 991bf37..4a53371 100644
--- a/src/jake2/render/jogl/Mesh.java
+++ b/src/jake2/render/jogl/Mesh.java
@@ -2,7 +2,7 @@
* Mesh.java
* Copyright (C) 2003
*
- * $Id: Mesh.java,v 1.4 2004-07-09 06:50:48 hzi Exp $
+ * $Id: Mesh.java,v 1.5 2004-07-12 22:08:03 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,18 +25,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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;
import jake2.render.image_t;
import jake2.util.Math3D;
+import java.nio.FloatBuffer;
+
+import net.java.games.jogl.GL;
+import net.java.games.jogl.util.BufferUtils;
+
/**
* Mesh
*
@@ -100,34 +99,43 @@ public abstract class Mesh extends Light {
}
}
- 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 )
+ void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv )
{
- int i;
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 )
{
float[] normal;
int j = 0;
- for (i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */)
+ for (int 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);
+ 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;
}
}
else
{
int j = 0;
- for (i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */)
+ for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */)
{
+ ovv = ov[i].v;
+ vv = v[i].v;
- 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]);
+ 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;
}
}
}
@@ -159,7 +167,6 @@ public abstract class Mesh extends Light {
float alpha;
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
};
@@ -193,29 +200,25 @@ public abstract class Mesh extends Light {
frontlerp = 1.0f - backlerp;
// move should be the delta back to the previous frame * backlerp
- Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, delta);
+ Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv);
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
+ 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);
for (i=0 ; i<3 ; i++)
{
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];
}
if ( gl_vertex_arrays.value != 0.0f )
{
- GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, vertexArrayBuf, move, frontv, backv );
+ GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, move, frontv, backv );
gl.glEnableClientState( GL.GL_VERTEX_ARRAY );
gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexArrayBuf );
diff --git a/src/jake2/render/jogl/Model.java b/src/jake2/render/jogl/Model.java
index 75357c3..9a10cf5 100644
--- a/src/jake2/render/jogl/Model.java
+++ b/src/jake2/render/jogl/Model.java
@@ -2,7 +2,7 @@
* Model.java
* Copyright (C) 2003
*
- * $Id: Model.java,v 1.2 2004-07-09 06:50:48 hzi Exp $
+ * $Id: Model.java,v 1.3 2004-07-12 22:08:03 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,28 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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.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
*
@@ -568,18 +558,17 @@ public abstract class Model extends Surf {
float[] maxs = {0, 0};
float val;
- int i, j, e;
+ int j, e;
mvertex_t v;
- mtexinfo_t tex;
int[] bmins = {0, 0};
int[] bmaxs = {0, 0};
mins[0] = mins[1] = 999999;
maxs[0] = maxs[1] = -99999;
- tex = s.texinfo;
+ mtexinfo_t tex = s.texinfo;
- for (i=0 ; i<s.numedges ; i++)
+ for (int i=0 ; i<s.numedges ; i++)
{
e = loadmodel.surfedges[s.firstedge+i];
if (e >= 0)
@@ -600,7 +589,7 @@ public abstract class Model extends Surf {
}
}
- for (i=0 ; i<2 ; i++)
+ for (int i=0 ; i<2 ; i++)
{
bmins[i] = (int)Math.floor(mins[i]/16);
bmaxs[i] = (int)Math.ceil(maxs[i]/16);
diff --git a/src/jake2/render/jogl/Warp.java b/src/jake2/render/jogl/Warp.java
index 6dc5145..ba89fc6 100644
--- a/src/jake2/render/jogl/Warp.java
+++ b/src/jake2/render/jogl/Warp.java
@@ -2,7 +2,7 @@
* Warp.java
* Copyright (C) 2003
*
- * $Id: Warp.java,v 1.4 2004-07-09 06:50:48 hzi Exp $
+ * $Id: Warp.java,v 1.5 2004-07-12 22:08:03 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -27,10 +27,7 @@ package jake2.render.jogl;
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.render.*;
import jake2.util.Math3D;
import net.java.games.jogl.GL;
@@ -117,13 +114,12 @@ public abstract class Warp extends Model {
float[] maxs = {0, 0, 0};
float m;
float[] v = {0, 0, 0};
- float[][] front = new float[64][3];
+ float[][] front = new float[64][3];
float[][] back = new float[64][3];
int f, b;
float[] dist = new float[64];
float frac;
- glpoly_t poly;
float s, t;
float[] total = {0, 0, 0};
float total_s, total_t;
@@ -192,7 +188,7 @@ public abstract class Warp extends Model {
// poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float));
// init polys
- poly = new glpoly_t(numverts + 2);
+ glpoly_t poly = new glpoly_t(numverts + 2);
poly.next = warpface.polys;
warpface.polys = poly;