- removed the Vector class in the GL renderer and replaced all its uses with FVector3.

- optimized the math to get a plane equation from a linedef. The original code used a generic algorithm that knew nothing about the fact that Doom walls are always perfectly vertical. With this knowledge the plane calculation can be reduced to a lot less code because retrieving the normal is trivial in this special case.
- use the SSE2 rsqrtss instruction to calculate a wall's length, because this is by far the most frequent use of square roots in the GL renderer. So far this is only active on x64, it may be activated on 32 bit later as well, but only after it has been decided if 32 bit builds should be x87 or SSE2.

# Conflicts:
#	src/gl/dynlights/gl_dynlight.cpp

# Conflicts:
#	src/g_shared/a_dynlightdata.cpp
This commit is contained in:
Christoph Oelckers 2017-03-12 19:44:00 +01:00
commit 4cd0d3d454
8 changed files with 137 additions and 429 deletions

View file

@ -74,12 +74,14 @@ void GLWall::SetupLights()
Plane p;
lightdata.Clear();
p.Init(vtx,4);
p.Set(&glseg);
/*
if (!p.ValidNormal())
{
return;
}
*/
FLightNode *node;
if (seg->sidedef == NULL)
{
@ -103,8 +105,6 @@ void GLWall::SetupLights()
{
iter_dlight++;
Vector fn, pos;
DVector3 posrel = node->lightsource->PosRelative(seg->frontsector);
float x = posrel.X;
float y = posrel.Y;
@ -112,29 +112,31 @@ void GLWall::SetupLights()
float dist = fabsf(p.DistToPoint(x, z, y));
float radius = node->lightsource->GetRadius();
float scale = 1.0f / ((2.f * radius) - dist);
FVector3 fn, pos;
if (radius > 0.f && dist < radius)
{
Vector nearPt, up, right;
FVector3 nearPt, up, right;
pos = { x, z, y };
fn = p.Normal();
pos.Set(x,z,y);
fn=p.Normal();
fn.GetRightUp(right, up);
Vector tmpVec = fn * dist;
FVector3 tmpVec = fn * dist;
nearPt = pos + tmpVec;
Vector t1;
FVector3 t1;
int outcnt[4]={0,0,0,0};
texcoord tcs[4];
// do a quick check whether the light touches this polygon
for(int i=0;i<4;i++)
{
t1.Set(&vtx[i*3]);
Vector nearToVert = t1 - nearPt;
tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f;
tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f;
t1 = FVector3(&vtx[i*3]);
FVector3 nearToVert = t1 - nearPt;
tcs[i].u = ((nearToVert | right) * scale) + 0.5f;
tcs[i].v = ((nearToVert | up) * scale) + 0.5f;
if (tcs[i].u<0) outcnt[0]++;
if (tcs[i].u>1) outcnt[1]++;