diff options
author | Carsten Weisse <[email protected]> | 2005-05-07 23:44:38 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2005-05-07 23:44:38 +0000 |
commit | 645763d5c333568d44a05456f1ace37bd6341f1c (patch) | |
tree | b7cb1116d884e7266068df8eba885f723a10ec90 /src/jake2/render | |
parent | 7b85a1449e8ab61c0aac8069d3e7c9c2cd64218e (diff) |
model frame animation is now stored in an int[];
an int value contains the x, y, z, lightnormal (8bit for each element)
this reduces the memory footprint massive and performs better
Diffstat (limited to 'src/jake2/render')
-rw-r--r-- | src/jake2/render/fastjogl/Mesh.java | 60 | ||||
-rw-r--r-- | src/jake2/render/fastjogl/Model.java | 6 | ||||
-rw-r--r-- | src/jake2/render/lwjgl/Mesh.java | 35 | ||||
-rw-r--r-- | src/jake2/render/lwjgl/Model.java | 6 |
4 files changed, 48 insertions, 59 deletions
diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java index 9635052..e15e698 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.9 2005-05-07 22:15:05 cawe Exp $ + * $Id: Mesh.java,v 1.10 2005-05-07 23:44:38 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -71,10 +71,9 @@ public abstract class Mesh extends Light { float[] shadedots = r_avertexnormal_dots[0]; - void GL_LerpVerts(int nverts, qfiles.dtrivertx_t[] ov, - qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, + void GL_LerpVerts(int nverts, int[] ov, int[] v, float[] move, float[] frontv, float[] backv) { - qfiles.dtrivertx_t ovv, vv; + int ovv, vv; FloatBuffer lerp = vertexArrayBuf; //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM @@ -82,31 +81,27 @@ public abstract class Mesh extends Light { | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) { float[] normal; - int j = 0; - for (int i = 0; i < nverts; i++ /* , v++, ov++, lerp+=4 */ - ) { - normal = r_avertexnormals[verts[i].lightnormalindex()]; - ovv = ov[i]; - vv = verts[i]; - - lerp.put(j++, move[0] + ovv.v0() * backv[0] + vv.v0() * frontv[0] - + normal[0] * Defines.POWERSUIT_SCALE); - lerp.put(j++, move[1] + ovv.v1() * backv[1] + vv.v1() * frontv[1] - + normal[1] * Defines.POWERSUIT_SCALE); - lerp.put(j++, move[2] + ovv.v2() * backv[2] + vv.v2() * frontv[2] - + normal[2] * Defines.POWERSUIT_SCALE); - } + int j = -1; + for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) + { + vv = v[i]; + normal = r_avertexnormals[(vv >>> 24 ) & 0xFF]; + ovv = ov[i]; + lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); + lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF) * backv[1] + ((vv >>> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); + lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF) * backv[2] + ((vv >>> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); + } } else { - int j = 0; - for (int i = 0; i < nverts; i++ /* , v++, ov++, lerp+=4 */ - ) { - ovv = ov[i]; - vv = verts[i]; - - lerp.put(j++, move[0] + ovv.v0() * backv[0] + vv.v0() * frontv[0]); - lerp.put(j++, move[1] + ovv.v1() * backv[1] + vv.v1() * frontv[1]); - lerp.put(j++, move[2] + ovv.v2() * backv[2] + vv.v2() * frontv[2]); - } + int j = -1; + for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) + { + ovv = ov[i]; + vv = v[i]; + + lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF)*frontv[0]); + lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF)* backv[1] + ((vv >>> 8) & 0xFF)*frontv[1]); + lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF)* backv[2] + ((vv >>> 16) & 0xFF)*frontv[2]); + } } } @@ -140,11 +135,11 @@ public abstract class Mesh extends Light { qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; - qfiles.dtrivertx_t[] verts = frame.verts; + int[] verts = frame.verts; qfiles.daliasframe_t oldframe = paliashdr.aliasFrames[currententity.oldframe]; - qfiles.dtrivertx_t[] ov = oldframe.verts; + int[] ov = oldframe.verts; if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) alpha = currententity.alpha; @@ -205,7 +200,7 @@ public abstract class Mesh extends Light { int j = 0; float l; for (int i = 0; i < paliashdr.num_xyz; i++) { - l = shadedots[verts[i].lightnormalindex()]; + l = shadedots[(verts[i] >>> 24 ) & 0xFF]; color.put(j++, l * shadelight[0]); color.put(j++, l * shadelight[1]); color.put(j++, l * shadelight[2]); @@ -270,7 +265,6 @@ public abstract class Mesh extends Light { * ============= GL_DrawAliasShadow ============= */ void GL_DrawAliasShadow(qfiles.dmdl_t paliashdr, int posenum) { - qfiles.dtrivertx_t[] verts; int[] order; float height, lheight; int count; @@ -280,8 +274,6 @@ public abstract class Mesh extends Light { frame = paliashdr.aliasFrames[currententity.frame]; - verts = frame.verts; - height = 0; order = paliashdr.glCmds; diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java index 02eaddf..1feadbf 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.10 2005-05-07 18:00:03 cawe Exp $ + * $Id: Model.java,v 1.11 2005-05-07 23:44:38 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -994,9 +994,9 @@ public abstract class Model extends Surf { for (i = 0; i < pheader.num_frames; i++) { poutframe[i] = new qfiles.daliasframe_t(buffer); // verts are all 8 bit, so no swapping needed - poutframe[i].verts = new qfiles.dtrivertx_t[pheader.num_xyz]; + poutframe[i].verts = new int[pheader.num_xyz]; for (int k = 0; k < pheader.num_xyz; k++) { - poutframe[i].verts[k] = new qfiles.dtrivertx_t(buffer); + poutframe[i].verts[k] = buffer.getInt(); } } diff --git a/src/jake2/render/lwjgl/Mesh.java b/src/jake2/render/lwjgl/Mesh.java index 48a62ff..db5faba 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.6 2005-05-07 22:15:05 cawe Exp $ + * $Id: Mesh.java,v 1.7 2005-05-07 23:44:37 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -76,27 +76,25 @@ public abstract class Mesh extends Light { * @param frontv * @param backv */ - void GL_LerpVerts(int nverts, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv ) + void GL_LerpVerts(int nverts, int[] ov, int[] v, float[] move, float[] frontv, float[] backv ) { FloatBuffer lerp = vertexArrayBuf; lerp.limit((nverts << 2) - nverts); // nverts * 3 - qfiles.dtrivertx_t ovv, vv; - - //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM + int ovv, vv; + //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 = -1; for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) { - normal = r_avertexnormals[verts[i].lightnormalindex()]; + vv = v[i]; + normal = r_avertexnormals[(vv >>> 24 ) & 0xFF]; ovv = ov[i]; - vv = verts[i]; - - lerp.put(++j, move[0] + ovv.v0() * backv[0] + vv.v0() * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); - lerp.put(++j, move[1] + ovv.v1() * backv[1] + vv.v1() * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); - lerp.put(++j, move[2] + ovv.v2() * backv[2] + vv.v2() * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); + lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); + lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF) * backv[1] + ((vv >>> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); + lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF) * backv[2] + ((vv >>> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); } } else @@ -105,11 +103,11 @@ public abstract class Mesh extends Light { for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) { ovv = ov[i]; - vv = verts[i]; + vv = v[i]; - lerp.put(++j, move[0] + ovv.v0()* backv[0] + vv.v0()*frontv[0]); - lerp.put(++j, move[1] + ovv.v1()* backv[1] + vv.v1()*frontv[1]); - lerp.put(++j, move[2] + ovv.v2()* backv[2] + vv.v2()*frontv[2]); + lerp.put(++j, move[0] + (ovv & 0xFF)* backv[0] + (vv & 0xFF)*frontv[0]); + lerp.put(++j, move[1] + ((ovv >>> 8) & 0xFF)* backv[1] + ((vv >>> 8) & 0xFF)*frontv[1]); + lerp.put(++j, move[2] + ((ovv >>> 16) & 0xFF)* backv[2] + ((vv >>> 16) & 0xFF)*frontv[2]); } } } @@ -137,11 +135,11 @@ public abstract class Mesh extends Light { { qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; - qfiles.dtrivertx_t[] verts = frame.verts; + int[] verts = frame.verts; qfiles.daliasframe_t oldframe = paliashdr.aliasFrames[currententity.oldframe]; - qfiles.dtrivertx_t[] ov = oldframe.verts; + int[] ov = oldframe.verts; float alpha; if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) @@ -198,7 +196,7 @@ public abstract class Mesh extends Light { int size = paliashdr.num_xyz; for (int i = 0; i < size; i++ ) { - l = shadedots[verts[i].lightnormalindex()]; + l = shadedots[(verts[i] >>> 24) & 0xFF]; color.put(++j, l * shadelight[0]); color.put(++j, l * shadelight[1]); color.put(++j, l * shadelight[2]); @@ -264,7 +262,6 @@ public abstract class Mesh extends Light { { float lheight = currententity.origin[2] - lightspot[2]; qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; - qfiles.dtrivertx_t[] verts = frame.verts; int[] order = paliashdr.glCmds; float height = -lheight + 1.0f; diff --git a/src/jake2/render/lwjgl/Model.java b/src/jake2/render/lwjgl/Model.java index c6c8daf..6875dbe 100644 --- a/src/jake2/render/lwjgl/Model.java +++ b/src/jake2/render/lwjgl/Model.java @@ -2,7 +2,7 @@ * Model.java * Copyright (C) 2003 * - * $Id: Model.java,v 1.8 2005-05-07 18:00:03 cawe Exp $ + * $Id: Model.java,v 1.9 2005-05-07 23:44:37 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -1069,9 +1069,9 @@ public abstract class Model extends Surf { { poutframe[i] = new qfiles.daliasframe_t(buffer); // verts are all 8 bit, so no swapping needed - poutframe[i].verts = new qfiles.dtrivertx_t[pheader.num_xyz]; + poutframe[i].verts = new int[pheader.num_xyz]; for (int k=0; k < pheader.num_xyz; k++) { - poutframe[i].verts[k] = new qfiles.dtrivertx_t(buffer); + poutframe[i].verts[k] = buffer.getInt(); } } |