Skip to content

Commit

Permalink
-fixed some lights
Browse files Browse the repository at this point in the history
-fixed some shadows
-fixed the heads(*sigh*..they kind of looked better all fucked up)
***drum roll
-fixed LOTS of texture mapping issues(look at them beautiful levels bitches!)
  • Loading branch information
blackbeard334 committed Oct 20, 2018
1 parent f67e18b commit b9adea7
Show file tree
Hide file tree
Showing 17 changed files with 130 additions and 99 deletions.
6 changes: 3 additions & 3 deletions src/main/java/neo/Game/Animation/Anim_Blend.java
Original file line number Diff line number Diff line change
Expand Up @@ -1944,9 +1944,9 @@ private void CallFrameCommands(idEntity ent, int fromtime, int totime) {

if (fromFrameTime <= 0) {
// make sure first frame is called
CallFrameCommands(ent, -1, frame2.frame1);
anim.CallFrameCommands(ent, -1, frame2.frame1);
} else {
CallFrameCommands(ent, frame1.frame1, frame2.frame1);
anim.CallFrameCommands(ent, frame1.frame1, frame2.frame1);
}
}

Expand Down Expand Up @@ -4065,7 +4065,7 @@ public boolean GetJointLocalTransform(int/*jointHandle_t*/ jointHandle, int curr
CreateFrame(currentTime, false);

if (jointHandle > 0) {
idJointMat m = joints[ jointHandle];
idJointMat m = new idJointMat(joints[ jointHandle]);
m.oDivSet(joints[ modelJoints.oGet(jointHandle).parentNum]);
offset.oSet(m.ToVec3());
axis.oSet(m.ToMat3());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neo/Game/Mover.java
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ protected void BeginMove(idThread thread) {
move.acceleration = at;
move.movetime = move_time - at - dt;
move.deceleration = dt;
move.dir = move_delta;
move.dir = new idVec3(move_delta);

ProcessEvent(EV_ReachedPos);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neo/Renderer/Model_md5.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public void UpdateSurface(final renderEntity_s ent, final idJointMat[] entJoints
R_AllocStaticTriSurfVerts(tri, tri.numVerts);
for (i = 0; i < deformInfo.numSourceVerts; i++) {
tri.verts[i].Clear();
tri.verts[i].st = texCoords.oGet(i);
tri.verts[i].st.oSet(texCoords.oGet(i));
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/neo/Renderer/RenderWorld_local.java
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ public int NumAreas() {
===============
*/
@Override
public int PointInArea(idVec3 point) {
public int PointInArea(final idVec3 point) {
areaNode_t node;
int nodeNum;
float d;
Expand Down Expand Up @@ -2863,7 +2863,7 @@ public boolean CullLightByPortals(final idRenderLightLocal light, final portalSt
int i, j;
srfTriangles_s tri;
float d;
idFixedWinding w; // we won't overflow because MAX_PORTAL_PLANES = 20
idFixedWinding w = new idFixedWinding(); // we won't overflow because MAX_PORTAL_PLANES = 20

if (r_useLightCulling.GetInteger() == 0) {
return false;
Expand All @@ -2888,7 +2888,7 @@ public boolean CullLightByPortals(final idRenderLightLocal light, final portalSt
continue;
}

w = new idFixedWinding(ow);
w.oSet(ow);

// now check the winding against each of the portalStack planes
for (j = 0; j < ps.numPortalPlanes - 1; j++) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neo/Renderer/draw_common.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public class draw_common {
=====================
*/

public static void RB_BakeTextureMatrixIntoTexgen(idPlane[] lightProject/*[3]*/, final float[] textureMatrix) {
public static void RB_BakeTextureMatrixIntoTexgen(idVec4[]/*idPlane[]*/ lightProject/*[3]*/, final float[] textureMatrix) {
float[] genMatrix = new float[16];
float[] finale = new float[16];

Expand Down
17 changes: 11 additions & 6 deletions src/main/java/neo/Renderer/tr_light.java
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ public static idScreenRect R_ClippedLightScissorRectangle(viewLight_s vLight) {
int i, j;
idRenderLightLocal light = vLight.lightDef;
idScreenRect r = new idScreenRect();
idFixedWinding w;
idFixedWinding w = new idFixedWinding();

r.Clear();

Expand All @@ -639,7 +639,7 @@ public static idScreenRect R_ClippedLightScissorRectangle(viewLight_s vLight) {
continue;
}

w = new idFixedWinding(ow);
w.oSet(ow);

// now check the winding against each of the frustum planes
for (j = 0; j < 5; j++) {
Expand Down Expand Up @@ -780,11 +780,12 @@ public static idScreenRect R_CalcLightScissorRectangle(viewLight_s vLight) {
public static void R_AddLightSurfaces() throws idException {
viewLight_s vLight;
idRenderLightLocal light;
viewLight_s ptr;
viewLight_s ptr, prevPtr;
int z = 0;

// go through each visible light, possibly removing some from the list
ptr = tr.viewDef.viewLights;
prevPtr = null;
while (ptr != null) {
z++;
vLight = ptr;
Expand All @@ -799,13 +800,15 @@ public static void R_AddLightSurfaces() throws idException {
if (!r_skipSuppress.GetBool()) {
if (light.parms.suppressLightInViewID != 0
&& light.parms.suppressLightInViewID == tr.viewDef.renderView.viewID) {
ptr = vLight.next;
if (vLight == tr.viewDef.viewLights) tr.viewDef.viewLights = ptr = vLight.next;
else prevPtr.next = ptr = vLight.next;
light.viewCount = -1;
continue;
}
if (light.parms.allowLightInViewID != 0
&& light.parms.allowLightInViewID != tr.viewDef.renderView.viewID) {
ptr = vLight.next;
if (vLight == tr.viewDef.viewLights) tr.viewDef.viewLights = ptr = vLight.next;
else prevPtr.next = ptr = vLight.next;
light.viewCount = -1;
continue;
}
Expand Down Expand Up @@ -857,7 +860,8 @@ public static void R_AddLightSurfaces() throws idException {
// remove the light from the viewLights list, and change its frame marker
// so interaction generation doesn't think the light is visible and
// create a shadow for it
ptr = vLight.next;
if (vLight == tr.viewDef.viewLights) tr.viewDef.viewLights = ptr = vLight.next;
else prevPtr.next = ptr = vLight.next;
light.viewCount = -1;
continue;
}
Expand Down Expand Up @@ -885,6 +889,7 @@ public static void R_AddLightSurfaces() throws idException {
// }
// }
// this one stays on the list
prevPtr = ptr;
ptr = vLight.next;

// if we are doing a soft-shadow novelty test, regenerate the light with
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/neo/Renderer/tr_lightrun.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,30 +426,30 @@ public static void R_DeriveLightData(idRenderLightLocal light) throws idExceptio
R_AxisToModelMatrix(light.parms.axis, light.parms.origin, light.modelMatrix);

for (i = 0; i < 6; i++) {
idPlane temp;
temp = light.frustum[i];
idPlane temp = new idPlane();
temp.oSet(light.frustum[i]);
R_LocalPlaneToGlobal(light.modelMatrix, temp, light.frustum[i]);
}
for (i = 0; i < 4; i++) {
idPlane temp;
temp = light.lightProject[i];
idPlane temp = new idPlane();
temp.oSet(light.lightProject[i]);
R_LocalPlaneToGlobal(light.modelMatrix, temp, light.lightProject[i]);
}

// adjust global light origin for off center projections and parallel projections
// we are just faking parallel by making it a very far off center for now
if (light.parms.parallel) {
idVec3 dir;
idVec3 dir = new idVec3();

dir = light.parms.lightCenter;
dir.oSet(light.parms.lightCenter);
if (0 == dir.Normalize()) {
// make point straight up if not specified
dir.oSet(2, 1);
}
light.globalLightOrigin = light.parms.origin.oPlus(dir.oMultiply(100000));
} else {
light.globalLightOrigin = light.parms.origin.oPlus(light.parms.axis.oMultiply(light.parms.lightCenter));
}
}

R_FreeLightDefFrustum(light);

Expand Down
8 changes: 1 addition & 7 deletions src/main/java/neo/Renderer/tr_render.java
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,7 @@ public static void RB_CreateSingleDrawInteractions(final drawSurf_s surf, DrawIn
// now multiply the texgen by the light texture matrix
if (lightStage.texture.hasMatrix) {
RB_GetShaderTextureMatrix(lightRegs, lightStage.texture, backEnd.lightTextureMatrix);
{
idPlane[] planes = new idPlane[inter.lightProjection.length];
for (int a = 0; a < planes.length; a++) {
planes[a] = new idPlane(inter.lightProjection[a]);
}
RB_BakeTextureMatrixIntoTexgen( /*reinterpret_cast<class idPlane *>*/planes, backEnd.lightTextureMatrix);
}
RB_BakeTextureMatrixIntoTexgen( /*reinterpret_cast<class idPlane *>*/inter.lightProjection, backEnd.lightTextureMatrix);
}

inter.bumpImage = null;
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/neo/Renderer/tr_rendertools.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public static void RB_CountStencilBuffer() {
int i;
ByteBuffer stencilReadback;

stencilReadback = ByteBuffer.allocate(glConfig.vidWidth * glConfig.vidHeight);// R_StaticAlloc(glConfig.vidWidth * glConfig.vidHeight);
stencilReadback = BufferUtils.createByteBuffer(glConfig.vidWidth * glConfig.vidHeight);// R_StaticAlloc(glConfig.vidWidth * glConfig.vidHeight);
qglReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback);

count = 0;
Expand Down Expand Up @@ -820,8 +820,8 @@ public static void RB_ShowShadowCount() {
}
}

shadowCache_s cache = new shadowCache_s(vertexCache.Position(tri.shadowCache));//TODO:figure out how to work these damn casts.
qglVertexPointer(4, GL_FLOAT, 0/*sizeof(cache)*/, cache.xyz.ToFloatPtr());
ByteBuffer cache = vertexCache.Position(tri.shadowCache);//TODO:figure out how to work these damn casts.
qglVertexPointer(4, GL_FLOAT, shadowCache_s.BYTES/*sizeof(cache)*/, cache);
RB_DrawElementsWithCounters(tri);
}
}
Expand Down Expand Up @@ -1466,6 +1466,8 @@ public static void RB_ShowTextureVectors(drawSurf_s[] drawSurfs, int numDrawSurf
for (i = 0; i < numDrawSurfs; i++) {
drawSurf = drawSurfs[i];

if(i!=101)continue;

tri = drawSurf.geo;

if (null == tri.verts) {
Expand All @@ -1485,7 +1487,7 @@ public static void RB_ShowTextureVectors(drawSurf_s[] drawSurfs, int numDrawSurf
idVec3 temp = new idVec3();
float[] d0 = new float[5], d1 = new float[5];
idVec3 mid;
idVec3[] tangents = new idVec3[2];
idVec3[] tangents = {new idVec3(), new idVec3()};

a = tri.verts[tri.indexes[j + 0]];
b = tri.verts[tri.indexes[j + 1]];
Expand Down Expand Up @@ -1513,13 +1515,13 @@ public static void RB_ShowTextureVectors(drawSurf_s[] drawSurfs, int numDrawSurf
temp.oSet(1, (d0[1] * d1[4] - d0[4] * d1[1]) * inva);
temp.oSet(2, (d0[2] * d1[4] - d0[4] * d1[2]) * inva);
temp.Normalize();
tangents[0] = temp;
tangents[0].oSet(temp);

temp.oSet(0, (d0[3] * d1[0] - d0[0] * d1[3]) * inva);
temp.oSet(1, (d0[3] * d1[1] - d0[1] * d1[3]) * inva);
temp.oSet(2, (d0[3] * d1[2] - d0[2] * d1[3]) * inva);
temp.Normalize();
tangents[1] = temp;
tangents[1].oSet(temp);

// draw the tangents
tangents[0] = mid.oPlus(tangents[0].oMultiply(r_showTextureVectors.GetFloat()));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neo/Tools/Compilers/DMap/usurface.java
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ static void BuildLightShadows(uEntity_t e, mapLight_t light) {
// shadowers will contain all the triangles that will contribute to the
// shadow volume
shadowerGroups = null;
lightOrigin = light.def.globalLightOrigin;
lightOrigin = new idVec3(light.def.globalLightOrigin);

// if the light is no-shadows, don't add any surfaces
// to the beam tree at all
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/neo/framework/DeclParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -799,10 +799,10 @@ public int ParticleVerts(particleGen_t g, final idVec3 origin, idDrawVert[] vert
left.oMulSet(width);
up.oMulSet(height);

verts[0].xyz = origin.oMinus(left).oPluSet(up);
verts[1].xyz = origin.oPluSet(left).oPluSet(up);
verts[0].xyz = origin.oMinus(left).oPlus(up);
verts[1].xyz = origin.oPlus(left).oPlus(up);
verts[2].xyz = origin.oMinus(left).oMinus(up);
verts[3].xyz = origin.oPluSet(left).oMinus(up);
verts[3].xyz = origin.oPlus(left).oMinus(up);

return 4;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/neo/framework/File_h.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public int WriteFloatString(final String fmt, final Object... args)/* id_attribu
public int ReadInt(int[] value) {
ByteBuffer intBytes = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
int result = Read(intBytes);
value[0] = LittleLong(intBytes.getInt());
value[0] = LittleLong(intBytes.getInt(0));
return result;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/neo/idlib/geometry/JointTransform.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public idJointMat(final float[] mat) {
System.arraycopy(mat, 0, this.mat, 0, this.mat.length);
}

public idJointMat(final idJointMat mat) {
this(mat.mat);
}

public void SetRotation(final idMat3 m) {
// NOTE: idMat3 is transposed because it is column-major
mat[0 * 4 + 0] = m.oGet(0).oGet(0);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/neo/idlib/math/Plane.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static class idPlane {

private final idVec3 abc = new idVec3();
private float d;

//
//

Expand Down
Loading

0 comments on commit b9adea7

Please sign in to comment.