2017-01-03 06:17:54 +00:00
|
|
|
//
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
//
|
|
|
|
// This source is available for distribution and/or modification
|
|
|
|
// only under the terms of the DOOM Source Code License as
|
|
|
|
// published by id Software. All rights reserved.
|
|
|
|
//
|
|
|
|
// The source is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
|
|
// for more details.
|
|
|
|
//
|
2016-12-30 05:42:20 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "r_sky.h"
|
|
|
|
#include "stats.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "c_console.h"
|
|
|
|
#include "cmdlib.h"
|
|
|
|
#include "d_net.h"
|
|
|
|
#include "g_level.h"
|
2016-12-31 13:45:41 +00:00
|
|
|
#include "gl/dynlights/gl_dynlight.h"
|
2017-01-11 22:08:24 +00:00
|
|
|
#include "swrenderer/r_memory.h"
|
2017-01-11 19:42:39 +00:00
|
|
|
#include "swrenderer/scene/r_opaque_pass.h"
|
2016-12-31 13:45:41 +00:00
|
|
|
#include "swrenderer/scene/r_3dfloors.h"
|
|
|
|
#include "swrenderer/scene/r_portal.h"
|
2017-01-12 15:21:46 +00:00
|
|
|
#include "swrenderer/scene/r_light.h"
|
2016-12-31 13:45:41 +00:00
|
|
|
#include "swrenderer/plane/r_flatplane.h"
|
|
|
|
#include "swrenderer/plane/r_slopeplane.h"
|
|
|
|
#include "swrenderer/plane/r_skyplane.h"
|
|
|
|
#include "swrenderer/plane/r_visibleplane.h"
|
|
|
|
#include "swrenderer/drawers/r_draw.h"
|
|
|
|
|
|
|
|
CVAR(Bool, tilt, false, 0);
|
2016-12-30 05:42:20 +00:00
|
|
|
|
|
|
|
namespace swrenderer
|
|
|
|
{
|
2017-01-11 22:08:24 +00:00
|
|
|
void visplane_t::AddLights(FLightNode *node)
|
|
|
|
{
|
|
|
|
if (!r_dynlights)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (node)
|
|
|
|
{
|
|
|
|
if (!(node->lightsource->flags2&MF2_DORMANT))
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
visplane_light *light_node = lights;
|
|
|
|
while (light_node)
|
|
|
|
{
|
|
|
|
if (light_node->lightsource == node->lightsource)
|
|
|
|
{
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
light_node = light_node->next;
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
{
|
2017-01-15 20:45:21 +00:00
|
|
|
visplane_light *newlight = RenderMemory::NewObject<visplane_light>();
|
2017-01-11 22:08:24 +00:00
|
|
|
newlight->next = lights;
|
|
|
|
newlight->lightsource = node->lightsource;
|
|
|
|
lights = newlight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
node = node->nextLight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void visplane_t::Render(fixed_t alpha, bool additive, bool masked)
|
|
|
|
{
|
|
|
|
if (left >= right)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (picnum == skyflatnum) // sky flat
|
|
|
|
{
|
|
|
|
RenderSkyPlane::Render(this);
|
|
|
|
}
|
|
|
|
else // regular flat
|
|
|
|
{
|
|
|
|
FTexture *tex = TexMan(picnum, true);
|
|
|
|
|
|
|
|
if (tex->UseType == FTexture::TEX_Null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!masked && !additive)
|
|
|
|
{ // If we're not supposed to see through this plane, draw it opaque.
|
|
|
|
alpha = OPAQUE;
|
|
|
|
}
|
|
|
|
else if (!tex->bMasked)
|
|
|
|
{ // Don't waste time on a masked texture if it isn't really masked.
|
|
|
|
masked = false;
|
|
|
|
}
|
|
|
|
R_SetSpanTexture(tex);
|
|
|
|
double xscale = xform.xScale * tex->Scale.X;
|
|
|
|
double yscale = xform.yScale * tex->Scale.Y;
|
|
|
|
|
|
|
|
if (!height.isSlope() && !tilt)
|
|
|
|
{
|
|
|
|
RenderFlatPlane renderer;
|
2017-01-12 20:29:19 +00:00
|
|
|
renderer.Render(this, xscale, yscale, alpha, additive, masked, colormap);
|
2017-01-11 22:08:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RenderSlopePlane renderer;
|
2017-01-12 20:29:19 +00:00
|
|
|
renderer.Render(this, xscale, yscale, alpha, additive, masked, colormap);
|
2017-01-11 22:08:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NetUpdate();
|
|
|
|
}
|
2016-12-30 05:42:20 +00:00
|
|
|
}
|