aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/render/jogl/Light.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jake2/render/jogl/Light.java')
-rw-r--r--src/jake2/render/jogl/Light.java54
1 files changed, 24 insertions, 30 deletions
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];