2016-09-14 18:01:13 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright(C) 2002-2016 Christoph Oelckers
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2013-06-23 07:49:34 +00:00
|
|
|
/*
|
|
|
|
** gl_sprite.cpp
|
|
|
|
** Sprite/Particle rendering
|
|
|
|
**
|
|
|
|
*/
|
2016-09-14 18:01:13 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/system/gl_system.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_effect.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "gl/gl_functions.h"
|
|
|
|
#include "r_defs.h"
|
|
|
|
#include "r_sky.h"
|
|
|
|
#include "r_utility.h"
|
2016-02-16 21:01:04 +00:00
|
|
|
#include "a_pickups.h"
|
|
|
|
#include "d_player.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2013-09-03 16:29:39 +00:00
|
|
|
#include "gl/system/gl_interface.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/system/gl_framebuffer.h"
|
|
|
|
#include "gl/system/gl_cvars.h"
|
|
|
|
#include "gl/renderer/gl_lightdata.h"
|
|
|
|
#include "gl/renderer/gl_renderstate.h"
|
2014-05-12 18:23:54 +00:00
|
|
|
#include "gl/renderer/gl_renderer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/data/gl_data.h"
|
|
|
|
#include "gl/dynlights/gl_glow.h"
|
|
|
|
#include "gl/scene/gl_drawinfo.h"
|
|
|
|
#include "gl/scene/gl_portal.h"
|
|
|
|
#include "gl/models/gl_models.h"
|
|
|
|
#include "gl/shaders/gl_shader.h"
|
|
|
|
#include "gl/textures/gl_material.h"
|
|
|
|
#include "gl/utility/gl_clock.h"
|
2014-05-12 18:23:54 +00:00
|
|
|
#include "gl/data/gl_vertexbuffer.h"
|
2016-08-22 12:00:25 +00:00
|
|
|
#include "gl/renderer/gl_quaddrawer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|
|
|
CVAR(Bool, gl_spritebrightfog, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
|
|
|
CVAR(Bool, gl_sprite_blend, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
|
|
|
CVAR(Int, gl_spriteclip, 1, CVAR_ARCHIVE)
|
|
|
|
CVAR(Float, gl_sclipthreshold, 10.0, CVAR_ARCHIVE)
|
|
|
|
CVAR(Float, gl_sclipfactor, 1.8, CVAR_ARCHIVE)
|
|
|
|
CVAR(Int, gl_particles_style, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // 0 = square, 1 = round, 2 = smooth
|
|
|
|
CVAR(Int, gl_billboard_mode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
2016-04-30 19:52:39 +00:00
|
|
|
CVAR(Bool, gl_billboard_faces_camera, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
2013-06-23 07:49:34 +00:00
|
|
|
CVAR(Bool, gl_billboard_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|
|
|
CVAR(Int, gl_enhanced_nv_stealth, 3, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|
|
|
CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE)
|
|
|
|
{
|
|
|
|
if (self < 0 || self > 7) self = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXTERN_CVAR (Float, transsouls)
|
|
|
|
|
|
|
|
extern TArray<spritedef_t> sprites;
|
|
|
|
extern TArray<spriteframe_t> SpriteFrames;
|
|
|
|
extern TArray<PalEntry> BloodTranslationColors;
|
|
|
|
|
|
|
|
enum HWRenderStyle
|
|
|
|
{
|
|
|
|
STYLEHW_Normal, // default
|
|
|
|
STYLEHW_Solid, // drawn solid (needs special treatment for sprites)
|
|
|
|
STYLEHW_NoAlphaTest, // disable alpha test
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending)
|
|
|
|
{
|
|
|
|
int tm, sb, db, be;
|
|
|
|
|
|
|
|
gl_GetRenderStyle(style, drawopaque, allowcolorblending, &tm, &sb, &db, &be);
|
|
|
|
gl_RenderState.BlendEquation(be);
|
|
|
|
gl_RenderState.BlendFunc(sb, db);
|
|
|
|
gl_RenderState.SetTextureMode(tm);
|
|
|
|
}
|
|
|
|
|
2013-12-05 14:06:10 +00:00
|
|
|
CVAR(Bool, gl_nolayer, false, 0)
|
|
|
|
|
2016-04-18 14:27:04 +00:00
|
|
|
static const float LARGE_VALUE = 1e19f;
|
|
|
|
|
2016-09-06 10:22:00 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2016-09-06 10:22:00 +00:00
|
|
|
|
|
|
|
void GLSprite::CalculateVertices(FVector3 *v)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-09-16 17:07:01 +00:00
|
|
|
if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
|
|
|
|
{
|
|
|
|
Matrix3x4 mat;
|
|
|
|
mat.MakeIdentity();
|
|
|
|
|
|
|
|
// [MC] Rotate around the center or offsets given to the sprites.
|
|
|
|
// Counteract any existing rotations, then rotate the angle.
|
|
|
|
// Tilt the actor up or down based on pitch (increase 'somersaults' forward).
|
|
|
|
// Then counteract the roll and DO A BARREL ROLL.
|
|
|
|
|
|
|
|
FAngle pitch = (float)-actor->Angles.Pitch.Degrees;
|
|
|
|
pitch.Normalized180();
|
|
|
|
|
2016-09-17 06:26:30 +00:00
|
|
|
mat.Translate(x, z, y);
|
|
|
|
mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees);
|
2016-09-17 17:08:58 +00:00
|
|
|
mat.Rotate(1, 0, 0, pitch.Degrees);
|
2016-09-17 06:26:30 +00:00
|
|
|
|
|
|
|
if (actor->renderflags & RF_ROLLCENTER)
|
|
|
|
{
|
|
|
|
float cx = (x1 + x2) * 0.5;
|
|
|
|
float cy = (y1 + y2) * 0.5;
|
|
|
|
|
|
|
|
mat.Translate(cx - x, 0, cy - y);
|
|
|
|
mat.Rotate(0, 1, 0, - actor->Angles.Roll.Degrees);
|
|
|
|
mat.Translate(-cx, -z, -cy);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mat.Rotate(0, 1, 0, - actor->Angles.Roll.Degrees);
|
|
|
|
mat.Translate(-x, -z, -y);
|
|
|
|
}
|
2016-10-04 15:04:33 +00:00
|
|
|
v[0] = mat * FVector3(x2, z, y2);
|
|
|
|
v[1] = mat * FVector3(x1, z, y2);
|
|
|
|
v[2] = mat * FVector3(x2, z, y1);
|
|
|
|
v[3] = mat * FVector3(x1, z, y1);
|
2016-12-06 18:17:02 +00:00
|
|
|
|
|
|
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
glPolygonOffset(-1.0f, -128.0f);
|
2016-09-16 17:07:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-06 10:22:00 +00:00
|
|
|
// [BB] Billboard stuff
|
|
|
|
const bool drawWithXYBillboard = ((particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD)
|
|
|
|
//&& GLRenderer->mViewActor != NULL
|
|
|
|
&& (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD))));
|
|
|
|
|
|
|
|
const bool drawBillboardFacingCamera = gl_billboard_faces_camera;
|
|
|
|
// [Nash] has +ROLLSPRITE
|
|
|
|
const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE);
|
|
|
|
|
|
|
|
|
|
|
|
// [fgsfds] check sprite type mask
|
|
|
|
DWORD spritetype = (DWORD)-1;
|
|
|
|
if (actor != nullptr) spritetype = actor->renderflags & RF_SPRITETYPEMASK;
|
|
|
|
|
|
|
|
// [Nash] is a flat sprite
|
|
|
|
const bool isFlatSprite = (actor != nullptr) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE);
|
|
|
|
const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER);
|
|
|
|
|
|
|
|
// [Nash] check for special sprite drawing modes
|
|
|
|
if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite)
|
|
|
|
{
|
|
|
|
// Compute center of sprite
|
|
|
|
float xcenter = (x1 + x2)*0.5;
|
|
|
|
float ycenter = (y1 + y2)*0.5;
|
|
|
|
float zcenter = (z1 + z2)*0.5;
|
|
|
|
float xx = -xcenter + x;
|
|
|
|
float zz = -zcenter + z;
|
|
|
|
float yy = -ycenter + y;
|
|
|
|
Matrix3x4 mat;
|
|
|
|
mat.MakeIdentity();
|
|
|
|
mat.Translate(xcenter, zcenter, ycenter); // move to sprite center
|
|
|
|
|
|
|
|
// Order of rotations matters. Perform yaw rotation (Y, face camera) before pitch (X, tilt up/down).
|
|
|
|
if (drawBillboardFacingCamera && !isFlatSprite)
|
|
|
|
{
|
|
|
|
// [CMB] Rotate relative to camera XY position, not just camera direction,
|
|
|
|
// which is nicer in VR
|
|
|
|
float xrel = xcenter - ViewPos.X;
|
|
|
|
float yrel = ycenter - ViewPos.Y;
|
|
|
|
float absAngleDeg = RAD2DEG(atan2(-yrel, xrel));
|
|
|
|
float counterRotationDeg = 270. - GLRenderer->mAngles.Yaw.Degrees; // counteracts existing sprite rotation
|
|
|
|
float relAngleDeg = counterRotationDeg + absAngleDeg;
|
|
|
|
|
|
|
|
mat.Rotate(0, 1, 0, relAngleDeg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// [fgsfds] calculate yaw vectors
|
|
|
|
float yawvecX = 0, yawvecY = 0, rollDegrees = 0;
|
|
|
|
float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians();
|
|
|
|
if (actor) rollDegrees = actor->Angles.Roll.Degrees;
|
|
|
|
if (isFlatSprite)
|
|
|
|
{
|
|
|
|
yawvecX = actor->Angles.Yaw.Cos();
|
|
|
|
yawvecY = actor->Angles.Yaw.Sin();
|
|
|
|
}
|
|
|
|
|
|
|
|
// [fgsfds] Rotate the sprite about the sight vector (roll)
|
2016-09-10 08:58:53 +00:00
|
|
|
if (spritetype == RF_WALLSPRITE)
|
2016-09-06 10:22:00 +00:00
|
|
|
{
|
|
|
|
mat.Rotate(0, 1, 0, 0);
|
|
|
|
if (drawRollSpriteActor)
|
|
|
|
{
|
|
|
|
if (useOffsets) mat.Translate(xx, zz, yy);
|
|
|
|
mat.Rotate(yawvecX, 0, yawvecY, rollDegrees);
|
|
|
|
if (useOffsets) mat.Translate(-xx, -zz, -yy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (drawRollSpriteActor)
|
|
|
|
{
|
|
|
|
if (useOffsets) mat.Translate(xx, zz, yy);
|
|
|
|
if (drawWithXYBillboard)
|
|
|
|
{
|
|
|
|
mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees);
|
|
|
|
}
|
|
|
|
mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees);
|
|
|
|
if (useOffsets) mat.Translate(-xx, -zz, -yy);
|
|
|
|
}
|
|
|
|
else if (drawWithXYBillboard)
|
|
|
|
{
|
|
|
|
// Rotate the sprite about the vector starting at the center of the sprite
|
|
|
|
// triangle strip and with direction orthogonal to where the player is looking
|
|
|
|
// in the x/y plane.
|
|
|
|
mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-09-06 10:22:00 +00:00
|
|
|
mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center
|
|
|
|
v[0] = mat * FVector3(x1, z1, y1);
|
|
|
|
v[1] = mat * FVector3(x2, z1, y2);
|
|
|
|
v[2] = mat * FVector3(x1, z2, y1);
|
|
|
|
v[3] = mat * FVector3(x2, z2, y2);
|
|
|
|
}
|
|
|
|
else // traditional "Y" billboard mode
|
|
|
|
{
|
|
|
|
v[0] = FVector3(x1, z1, y1);
|
|
|
|
v[1] = FVector3(x2, z1, y2);
|
|
|
|
v[2] = FVector3(x1, z2, y1);
|
|
|
|
v[3] = FVector3(x2, z2, y2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void GLSprite::Draw(int pass)
|
|
|
|
{
|
|
|
|
if (pass == GLPASS_DECALS || pass == GLPASS_LIGHTSONLY) return;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
bool additivefog = false;
|
2013-12-05 14:06:10 +00:00
|
|
|
bool foglayer = false;
|
2014-12-25 17:30:34 +00:00
|
|
|
int rel = fullbright? 0 : getExtraLight();
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (pass==GLPASS_TRANSLUCENT)
|
|
|
|
{
|
|
|
|
// The translucent pass requires special setup for the various modes.
|
|
|
|
|
2014-05-11 20:57:42 +00:00
|
|
|
// for special render styles brightmaps would not look good - especially for subtractive.
|
|
|
|
if (RenderStyle.BlendOp != STYLEOP_Add)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
gl_RenderState.EnableBrightmap(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
gl_SetRenderStyle(RenderStyle, false,
|
|
|
|
// The rest of the needed checks are done inside gl_SetRenderStyle
|
2014-05-11 20:57:42 +00:00
|
|
|
trans > 1.f - FLT_EPSILON && gl_usecolorblending && gl_fixedcolormap == CM_DEFAULT && actor &&
|
2013-06-23 07:49:34 +00:00
|
|
|
fullbright && gltexture && !gltexture->GetTransparent());
|
|
|
|
|
|
|
|
if (hw_styleflags == STYLEHW_NoAlphaTest)
|
|
|
|
{
|
2014-07-14 19:14:43 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-14 19:14:43 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (RenderStyle.BlendOp == STYLEOP_Shadow)
|
|
|
|
{
|
|
|
|
float fuzzalpha=0.44f;
|
|
|
|
float minalpha=0.1f;
|
|
|
|
|
|
|
|
// fog + fuzz don't work well without some fiddling with the alpha value!
|
|
|
|
if (!gl_isBlack(Colormap.FadeColor))
|
|
|
|
{
|
2016-04-02 21:17:16 +00:00
|
|
|
float dist=Dist2(ViewPos.X, ViewPos.Y, x,y);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (!Colormap.FadeColor.a) Colormap.FadeColor.a=clamp<int>(255-lightlevel,60,255);
|
|
|
|
|
|
|
|
// this value was determined by trial and error and is scale dependent!
|
|
|
|
float factor=0.05f+exp(-Colormap.FadeColor.a*dist/62500.f);
|
|
|
|
fuzzalpha*=factor;
|
|
|
|
minalpha*=factor;
|
|
|
|
}
|
|
|
|
|
2014-07-14 19:14:43 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
2014-05-11 20:57:42 +00:00
|
|
|
gl_RenderState.SetColor(0.2f,0.2f,0.2f,fuzzalpha, Colormap.desaturation);
|
2013-06-23 07:49:34 +00:00
|
|
|
additivefog = true;
|
|
|
|
}
|
|
|
|
else if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One)
|
|
|
|
{
|
|
|
|
additivefog = true;
|
|
|
|
}
|
|
|
|
}
|
2016-09-22 08:00:40 +00:00
|
|
|
else if (modelframe == nullptr)
|
|
|
|
{
|
|
|
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
glPolygonOffset(-1.0f, -128.0f);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
if (RenderStyle.BlendOp!=STYLEOP_Shadow)
|
|
|
|
{
|
2014-10-23 08:54:26 +00:00
|
|
|
if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && !fullbright)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-05-11 19:47:54 +00:00
|
|
|
gl_SetDynSpriteLight(gl_light_sprites ? actor : NULL, gl_light_particles ? particle : NULL);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-05-11 22:13:19 +00:00
|
|
|
gl_SetColor(lightlevel, rel, Colormap, trans);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-05-11 15:56:38 +00:00
|
|
|
gl_RenderState.SetObjectColor(ThingColor);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (gl_isBlack(Colormap.FadeColor)) foglevel=lightlevel;
|
|
|
|
|
|
|
|
if (RenderStyle.Flags & STYLEF_FadeToBlack)
|
|
|
|
{
|
|
|
|
Colormap.FadeColor=0;
|
|
|
|
additivefog = true;
|
|
|
|
}
|
|
|
|
|
2013-12-05 14:06:10 +00:00
|
|
|
if (RenderStyle.BlendOp == STYLEOP_RevSub || RenderStyle.BlendOp == STYLEOP_Sub)
|
|
|
|
{
|
|
|
|
if (!modelframe)
|
|
|
|
{
|
|
|
|
// non-black fog with subtractive style needs special treatment
|
|
|
|
if (!gl_isBlack(Colormap.FadeColor))
|
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
foglayer = true;
|
|
|
|
// Due to the two-layer approach we need to force an alpha test that lets everything pass
|
|
|
|
gl_RenderState.AlphaFunc(GL_GREATER, 0);
|
2013-12-05 14:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else RenderStyle.BlendOp = STYLEOP_Fuzz; // subtractive with models is not going to work.
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2013-12-05 14:06:10 +00:00
|
|
|
if (!foglayer) gl_SetFog(foglevel, rel, &Colormap, additivefog);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gl_RenderState.EnableFog(false);
|
|
|
|
gl_RenderState.SetFog(0, 0);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-09-09 10:00:42 +00:00
|
|
|
if (gltexture) gl_RenderState.SetMaterial(gltexture, CLAMP_XY, translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha));
|
2013-06-23 07:49:34 +00:00
|
|
|
else if (!modelframe) gl_RenderState.EnableTexture(false);
|
|
|
|
|
2016-02-01 17:14:00 +00:00
|
|
|
//gl_SetColor(lightlevel, rel, Colormap, trans);
|
|
|
|
|
2016-04-18 14:27:04 +00:00
|
|
|
unsigned int iter = lightlist? lightlist->Size() : 1;
|
|
|
|
bool clipping = false;
|
|
|
|
if (lightlist || topclip != LARGE_VALUE || bottomclip != -LARGE_VALUE)
|
2016-02-01 17:14:00 +00:00
|
|
|
{
|
2016-04-18 14:27:04 +00:00
|
|
|
clipping = true;
|
2016-02-01 17:14:00 +00:00
|
|
|
gl_RenderState.EnableSplit(true);
|
|
|
|
}
|
|
|
|
|
2016-04-18 14:27:04 +00:00
|
|
|
secplane_t bottomp = { { 0, 0, -1. }, bottomclip };
|
|
|
|
secplane_t topp = { { 0, 0, -1. }, topclip };
|
2016-02-01 17:14:00 +00:00
|
|
|
for (unsigned i = 0; i < iter; i++)
|
|
|
|
{
|
|
|
|
if (lightlist)
|
|
|
|
{
|
|
|
|
// set up the light slice
|
2016-04-18 14:27:04 +00:00
|
|
|
secplane_t *topplane = i == 0 ? &topp : &(*lightlist)[i].plane;
|
|
|
|
secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottomp : &(*lightlist)[i + 1].plane;
|
2016-02-01 17:14:00 +00:00
|
|
|
|
2016-06-17 14:16:31 +00:00
|
|
|
int thislight = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel;
|
2016-06-18 08:01:24 +00:00
|
|
|
int thisll = actor == nullptr? thislight : (uint8_t)gl_CheckSpriteGlow(actor->Sector, thislight, actor->InterpolatedPosition(r_TicFracF));
|
2016-06-17 14:16:31 +00:00
|
|
|
|
2016-02-01 17:14:00 +00:00
|
|
|
FColormap thiscm;
|
|
|
|
thiscm.FadeColor = Colormap.FadeColor;
|
|
|
|
thiscm.CopyFrom3DLight(&(*lightlist)[i]);
|
2016-02-01 18:10:15 +00:00
|
|
|
if (glset.nocoloredspritelighting)
|
|
|
|
{
|
|
|
|
thiscm.Decolorize();
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:14:00 +00:00
|
|
|
gl_SetColor(thisll, rel, thiscm, trans);
|
2016-06-17 14:16:31 +00:00
|
|
|
if (!foglayer)
|
|
|
|
{
|
|
|
|
gl_SetFog(thislight, rel, &thiscm, additivefog);
|
|
|
|
}
|
2016-02-01 17:14:00 +00:00
|
|
|
gl_RenderState.SetSplitPlanes(*topplane, *lowplane);
|
2013-12-05 14:06:10 +00:00
|
|
|
}
|
2016-04-18 14:27:04 +00:00
|
|
|
else if (clipping)
|
|
|
|
{
|
|
|
|
gl_RenderState.SetSplitPlanes(topp, bottomp);
|
|
|
|
}
|
2016-02-01 17:14:00 +00:00
|
|
|
|
|
|
|
if (!modelframe)
|
2013-12-05 14:06:10 +00:00
|
|
|
{
|
|
|
|
gl_RenderState.Apply();
|
2016-02-01 17:14:00 +00:00
|
|
|
|
2016-09-06 10:22:00 +00:00
|
|
|
FVector3 v[4];
|
2016-10-03 14:09:32 +00:00
|
|
|
gl_RenderState.SetNormal(0, 0, 0);
|
2016-09-16 17:07:01 +00:00
|
|
|
CalculateVertices(v);
|
|
|
|
|
2016-08-22 12:00:25 +00:00
|
|
|
FQuadDrawer qd;
|
2016-09-06 10:22:00 +00:00
|
|
|
qd.Set(0, v[0][0], v[0][1], v[0][2], ul, vt);
|
|
|
|
qd.Set(1, v[1][0], v[1][1], v[1][2], ur, vt);
|
|
|
|
qd.Set(2, v[2][0], v[2][1], v[2][2], ul, vb);
|
|
|
|
qd.Set(3, v[3][0], v[3][1], v[3][2], ur, vb);
|
2016-08-22 12:00:25 +00:00
|
|
|
qd.Render(GL_TRIANGLE_STRIP);
|
2016-02-01 17:14:00 +00:00
|
|
|
|
|
|
|
if (foglayer)
|
|
|
|
{
|
|
|
|
// If we get here we know that we have colored fog and no fixed colormap.
|
|
|
|
gl_SetFog(foglevel, rel, &Colormap, additivefog);
|
|
|
|
gl_RenderState.SetFixedColormap(CM_FOGLAYER);
|
|
|
|
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
|
|
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
gl_RenderState.Apply();
|
2016-08-22 12:00:25 +00:00
|
|
|
qd.Render(GL_TRIANGLE_STRIP);
|
2016-02-01 17:14:00 +00:00
|
|
|
gl_RenderState.SetFixedColormap(CM_DEFAULT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gl_RenderModel(this);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-01 17:14:00 +00:00
|
|
|
|
2016-04-18 14:27:04 +00:00
|
|
|
if (clipping)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-02-01 17:14:00 +00:00
|
|
|
gl_RenderState.EnableSplit(false);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pass==GLPASS_TRANSLUCENT)
|
|
|
|
{
|
|
|
|
gl_RenderState.EnableBrightmap(true);
|
|
|
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
|
|
|
gl_RenderState.SetTextureMode(TM_MODULATE);
|
2016-12-06 18:17:02 +00:00
|
|
|
if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
|
|
|
|
{
|
|
|
|
glPolygonOffset(0.0f, 0.0f);
|
|
|
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-09-22 08:00:40 +00:00
|
|
|
else if (modelframe == nullptr)
|
|
|
|
{
|
|
|
|
glPolygonOffset(0.0f, 0.0f);
|
|
|
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-05-11 19:47:54 +00:00
|
|
|
gl_RenderState.SetObjectColor(0xffffffff);
|
2014-05-11 20:57:42 +00:00
|
|
|
gl_RenderState.EnableTexture(true);
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_RenderState.SetDynLight(0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
inline void GLSprite::PutSprite(bool translucent)
|
|
|
|
{
|
|
|
|
int list;
|
|
|
|
// [BB] Allow models to be drawn in the GLDL_TRANSLUCENT pass.
|
2016-09-13 21:35:25 +00:00
|
|
|
if (translucent || actor == nullptr || (!modelframe && (actor->renderflags & RF_SPRITETYPEMASK) != RF_WALLSPRITE))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
list = GLDL_TRANSLUCENT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-15 19:16:59 +00:00
|
|
|
list = GLDL_MODELS;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
gl_drawinfo->drawlists[list].AddSprite(this);
|
|
|
|
}
|
|
|
|
|
2016-04-26 19:31:24 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLSprite::SplitSprite(sector_t * frontsector, bool translucent)
|
|
|
|
{
|
|
|
|
GLSprite copySprite;
|
|
|
|
double lightbottom;
|
|
|
|
unsigned int i;
|
|
|
|
bool put=false;
|
|
|
|
TArray<lightlist_t> & lightlist=frontsector->e->XFloor.lightlist;
|
|
|
|
|
|
|
|
for(i=0;i<lightlist.Size();i++)
|
|
|
|
{
|
|
|
|
// Particles don't go through here so we can safely assume that actor is not NULL
|
|
|
|
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor);
|
|
|
|
else lightbottom=frontsector->floorplane.ZatPoint(actor);
|
|
|
|
|
|
|
|
if (lightbottom<z2) lightbottom=z2;
|
|
|
|
|
|
|
|
if (lightbottom<z1)
|
|
|
|
{
|
|
|
|
copySprite=*this;
|
|
|
|
copySprite.lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel);
|
|
|
|
copySprite.Colormap.CopyLightColor(lightlist[i].extra_colormap);
|
|
|
|
|
|
|
|
if (glset.nocoloredspritelighting)
|
|
|
|
{
|
|
|
|
copySprite.Colormap.Decolorize();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gl_isWhite(ThingColor))
|
|
|
|
{
|
|
|
|
copySprite.Colormap.LightColor.r=(copySprite.Colormap.LightColor.r*ThingColor.r)>>8;
|
|
|
|
copySprite.Colormap.LightColor.g=(copySprite.Colormap.LightColor.g*ThingColor.g)>>8;
|
|
|
|
copySprite.Colormap.LightColor.b=(copySprite.Colormap.LightColor.b*ThingColor.b)>>8;
|
|
|
|
}
|
|
|
|
|
|
|
|
z1=copySprite.z2=lightbottom;
|
|
|
|
vt=copySprite.vb=copySprite.vt+
|
|
|
|
(lightbottom-copySprite.z1)*(copySprite.vb-copySprite.vt)/(z2-copySprite.z1);
|
|
|
|
copySprite.PutSprite(translucent);
|
|
|
|
put=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-04-03 11:00:09 +00:00
|
|
|
void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight)
|
2014-08-03 08:22:12 +00:00
|
|
|
{
|
2016-04-07 12:09:07 +00:00
|
|
|
const float NO_VAL = 100000000.0f;
|
|
|
|
bool clipthing = (thing->player || thing->flags3&MF3_ISMONSTER || thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || !(thing->flags&MF_CORPSE));
|
|
|
|
bool smarterclip = !clipthing && gl_spriteclip == 3;
|
|
|
|
if (clipthing || gl_spriteclip > 1)
|
2014-08-03 08:22:12 +00:00
|
|
|
{
|
2016-04-07 12:09:07 +00:00
|
|
|
|
|
|
|
float btm = NO_VAL;
|
|
|
|
float top = -NO_VAL;
|
2014-08-03 08:22:12 +00:00
|
|
|
extsector_t::xfloor &x = thing->Sector->e->XFloor;
|
|
|
|
|
|
|
|
if (x.ffloors.Size())
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < x.ffloors.Size(); i++)
|
|
|
|
{
|
|
|
|
F3DFloor * ff = x.ffloors[i];
|
2016-04-03 11:00:09 +00:00
|
|
|
float floorh = ff->top.plane->ZatPoint(thingpos);
|
|
|
|
float ceilingh = ff->bottom.plane->ZatPoint(thingpos);
|
2014-08-03 08:22:12 +00:00
|
|
|
if (floorh == thing->floorz)
|
|
|
|
{
|
2016-03-21 01:57:02 +00:00
|
|
|
btm = floorh;
|
2014-08-03 08:22:12 +00:00
|
|
|
}
|
|
|
|
if (ceilingh == thing->ceilingz)
|
|
|
|
{
|
2016-03-21 01:57:02 +00:00
|
|
|
top = ceilingh;
|
2014-08-03 08:22:12 +00:00
|
|
|
}
|
2016-04-07 12:09:07 +00:00
|
|
|
if (btm != NO_VAL && top != -NO_VAL)
|
2014-08-03 08:22:12 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
|
|
|
{
|
|
|
|
if (thing->flags2&MF2_ONMOBJ && thing->floorz ==
|
2016-04-03 20:13:38 +00:00
|
|
|
thing->Sector->heightsec->floorplane.ZatPoint(thingpos))
|
2014-08-03 08:22:12 +00:00
|
|
|
{
|
2016-03-21 01:57:02 +00:00
|
|
|
btm = thing->floorz;
|
|
|
|
top = thing->ceilingz;
|
2014-08-03 08:22:12 +00:00
|
|
|
}
|
|
|
|
}
|
2016-04-07 12:09:07 +00:00
|
|
|
if (btm == NO_VAL)
|
2016-03-30 18:01:44 +00:00
|
|
|
btm = thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip;
|
2016-04-07 12:09:07 +00:00
|
|
|
if (top == NO_VAL)
|
2016-04-03 11:00:09 +00:00
|
|
|
top = thing->Sector->ceilingplane.ZatPoint(thingpos);
|
2014-08-03 08:22:12 +00:00
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
// +/-1 to account for the one pixel empty frame around the sprite.
|
|
|
|
float diffb = (z2+1) - btm;
|
|
|
|
float difft = (z1-1) - top;
|
2014-08-03 08:22:12 +00:00
|
|
|
if (diffb >= 0 /*|| !gl_sprite_clip_to_floor*/) diffb = 0;
|
|
|
|
// Adjust sprites clipping into ceiling and adjust clipping adjustment for tall graphics
|
|
|
|
if (smarterclip)
|
|
|
|
{
|
|
|
|
// Reduce slightly clipping adjustment of corpses
|
|
|
|
if (thing->flags & MF_CORPSE || spriteheight > fabs(diffb))
|
|
|
|
{
|
|
|
|
float ratio = clamp<float>((fabs(diffb) * (float)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0);
|
|
|
|
diffb *= ratio;
|
|
|
|
}
|
|
|
|
if (!diffb)
|
|
|
|
{
|
|
|
|
if (difft <= 0) difft = 0;
|
|
|
|
if (difft >= (float)gl_sclipthreshold)
|
|
|
|
{
|
|
|
|
// dumb copy of the above.
|
|
|
|
if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || difft > (float)gl_sclipthreshold)
|
|
|
|
{
|
|
|
|
difft = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (spriteheight > fabs(difft))
|
|
|
|
{
|
|
|
|
float ratio = clamp<float>((fabs(difft) * (float)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0);
|
|
|
|
difft *= ratio;
|
|
|
|
}
|
|
|
|
z2 -= difft;
|
|
|
|
z1 -= difft;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (diffb <= (0 - (float)gl_sclipthreshold)) // such a large displacement can't be correct!
|
|
|
|
{
|
|
|
|
// for living monsters standing on the floor allow a little more.
|
|
|
|
if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || diffb < (-1.8*(float)gl_sclipthreshold))
|
|
|
|
{
|
|
|
|
diffb = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z2 -= diffb;
|
|
|
|
z1 -= diffb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-04-30 14:57:53 +00:00
|
|
|
void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
sector_t rs;
|
|
|
|
sector_t * rendersector;
|
|
|
|
|
|
|
|
// Don't waste time projecting sprites that are definitely not visible.
|
2016-09-24 10:09:53 +00:00
|
|
|
if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer() || !thing->IsInsideVisibleAngles())
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-18 10:14:20 +00:00
|
|
|
if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->Alpha))
|
|
|
|
{
|
|
|
|
if (!(thing->flags & MF_STEALTH) || !gl_fixedcolormap || !gl_enhanced_nightvision || thing == camera)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
int spritenum = thing->sprite;
|
2016-03-21 01:57:02 +00:00
|
|
|
DVector2 sprscale = thing->Scale;
|
2013-06-23 07:49:34 +00:00
|
|
|
if (thing->player != NULL)
|
|
|
|
{
|
2016-03-21 01:57:02 +00:00
|
|
|
P_CheckPlayerSprite(thing, spritenum, sprscale);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If this thing is in a map section that's not in view it can't possibly be visible
|
2016-04-18 21:52:15 +00:00
|
|
|
if (!thruportal && !(currentmapsection[thing->subsector->mapsection >> 3] & (1 << (thing->subsector->mapsection & 7)))) return;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// [RH] Interpolate the sprite's position to make it look smooth
|
2016-03-29 09:26:33 +00:00
|
|
|
DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF);
|
2016-04-30 14:57:53 +00:00
|
|
|
if (thruportal == 1) thingpos += Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// Too close to the camera. This doesn't look good if it is a sprite.
|
2016-04-02 21:17:16 +00:00
|
|
|
if (fabs(thingpos.X - ViewPos.X) < 2 && fabs(thingpos.Y - ViewPos.Y) < 2)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-02 21:17:16 +00:00
|
|
|
if (ViewPos.Z >= thingpos.Z - 2 && ViewPos.Z <= thingpos.Z + thing->Height + 2)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-02-01 17:14:00 +00:00
|
|
|
// exclude vertically moving objects from this check.
|
2016-03-21 01:57:02 +00:00
|
|
|
if (!thing->Vel.isZero())
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-02-05 11:31:41 +00:00
|
|
|
if (!gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, false))
|
2016-02-01 17:14:00 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// don't draw first frame of a player missile
|
2016-02-12 10:20:33 +00:00
|
|
|
if (thing->flags&MF_MISSILE)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-18 14:27:04 +00:00
|
|
|
if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target == GLRenderer->mViewActor && GLRenderer->mViewActor != NULL)
|
2016-02-12 10:20:33 +00:00
|
|
|
{
|
2016-05-04 18:31:21 +00:00
|
|
|
double speed = thing->Vel.Length();
|
|
|
|
if (speed >= thing->target->radius / 2)
|
|
|
|
{
|
|
|
|
double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius * 2);
|
|
|
|
if ((thingpos - ViewPos).LengthSquared() < clipdist * clipdist) return;
|
|
|
|
}
|
2016-02-12 10:20:33 +00:00
|
|
|
}
|
|
|
|
thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again.
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2016-04-30 14:57:53 +00:00
|
|
|
if (thruportal != 2 && GLRenderer->mClipPortal)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-28 23:48:06 +00:00
|
|
|
int clipres = GLRenderer->mClipPortal->ClipPoint(thingpos);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (clipres == GLPortal::PClip_InFront) return;
|
|
|
|
}
|
|
|
|
|
2016-04-18 14:27:04 +00:00
|
|
|
player_t *player = &players[consoleplayer];
|
2013-06-23 07:49:34 +00:00
|
|
|
FloatRect r;
|
|
|
|
|
2016-04-18 14:27:04 +00:00
|
|
|
if (sector->sectornum != thing->Sector->sectornum && !thruportal)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-18 14:27:04 +00:00
|
|
|
rendersector = gl_FakeFlat(thing->Sector, &rs, false);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-18 14:27:04 +00:00
|
|
|
rendersector = sector;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-04-20 09:39:41 +00:00
|
|
|
topclip = rendersector->PortalBlocksMovement(sector_t::ceiling) ? LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::ceiling);
|
|
|
|
bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::floor);
|
2016-04-18 14:27:04 +00:00
|
|
|
|
2016-07-03 23:00:01 +00:00
|
|
|
DWORD spritetype = (thing->renderflags & RF_SPRITETYPEMASK);
|
2016-03-29 09:26:33 +00:00
|
|
|
x = thingpos.X;
|
2016-07-03 23:00:01 +00:00
|
|
|
z = thingpos.Z;
|
2016-03-29 09:26:33 +00:00
|
|
|
y = thingpos.Y;
|
2016-09-10 08:58:53 +00:00
|
|
|
if (spritetype == RF_FACESPRITE) z -= thing->Floorclip; // wall and flat sprites are to be considered level geometry so this may not apply.
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-07-03 23:00:01 +00:00
|
|
|
// [RH] Make floatbobbing a renderer-only effect.
|
|
|
|
if (thing->flags2 & MF2_FLOATBOB)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-07-03 23:00:01 +00:00
|
|
|
float fz = thing->GetBobOffset(r_TicFracF);
|
|
|
|
z += fz;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-07-03 23:00:01 +00:00
|
|
|
|
2016-02-05 11:31:41 +00:00
|
|
|
modelframe = gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!modelframe)
|
|
|
|
{
|
|
|
|
bool mirror;
|
2016-04-02 21:17:16 +00:00
|
|
|
DAngle ang = (thingpos - ViewPos).Angle();
|
2016-07-28 21:47:04 +00:00
|
|
|
FTextureID patch;
|
|
|
|
if (thing->flags7 & MF7_SPRITEANGLE)
|
2016-09-10 08:58:53 +00:00
|
|
|
{
|
2016-07-28 21:47:04 +00:00
|
|
|
patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (thing->SpriteAngle).BAMs(), &mirror);
|
2016-09-10 08:58:53 +00:00
|
|
|
}
|
|
|
|
else if (!(thing->renderflags & RF_FLATSPRITE))
|
|
|
|
{
|
2016-07-28 21:47:04 +00:00
|
|
|
patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - (thing->Angles.Yaw + thing->SpriteRotation)).BAMs(), &mirror);
|
2016-09-10 08:58:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Flat sprites cannot rotate in a predictable manner.
|
|
|
|
patch = gl_GetSpriteFrame(spritenum, thing->frame, 0, 0, &mirror);
|
|
|
|
}
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!patch.isValid()) return;
|
2014-08-22 21:50:38 +00:00
|
|
|
int type = thing->renderflags & RF_SPRITETYPEMASK;
|
|
|
|
gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!gltexture) return;
|
|
|
|
|
2014-04-06 12:35:44 +00:00
|
|
|
vt = gltexture->GetSpriteVT();
|
|
|
|
vb = gltexture->GetSpriteVB();
|
2014-08-22 21:50:38 +00:00
|
|
|
gltexture->GetSpriteRect(&r);
|
2014-04-06 12:35:44 +00:00
|
|
|
if (mirror)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-03 08:57:58 +00:00
|
|
|
r.left = -r.width - r.left; // mirror the sprite's x-offset
|
2014-04-06 12:35:44 +00:00
|
|
|
ul = gltexture->GetSpriteUL();
|
|
|
|
ur = gltexture->GetSpriteUR();
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-04-06 12:35:44 +00:00
|
|
|
ul = gltexture->GetSpriteUR();
|
|
|
|
ur = gltexture->GetSpriteUL();
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2016-03-21 01:57:02 +00:00
|
|
|
r.Scale(sprscale.X, sprscale.Y);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-08-03 08:57:58 +00:00
|
|
|
float rightfac = -r.left;
|
|
|
|
float leftfac = rightfac - r.width;
|
2016-09-16 16:45:58 +00:00
|
|
|
float bottomfac = -r.top;
|
|
|
|
float topfac = bottomfac - r.height;
|
2014-08-03 08:57:58 +00:00
|
|
|
z1 = z - r.top;
|
|
|
|
z2 = z1 - r.height;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-03-21 01:57:02 +00:00
|
|
|
float spriteheight = sprscale.Y * r.height;
|
2014-08-03 08:57:58 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
// Tests show that this doesn't look good for many decorations and corpses
|
2014-08-03 08:22:12 +00:00
|
|
|
if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-03 11:00:09 +00:00
|
|
|
PerformSpriteClipAdjustment(thing, thingpos, spriteheight);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2014-08-03 08:57:58 +00:00
|
|
|
float viewvecX;
|
|
|
|
float viewvecY;
|
2016-05-01 19:08:09 +00:00
|
|
|
switch (spritetype)
|
2014-08-03 08:57:58 +00:00
|
|
|
{
|
|
|
|
case RF_FACESPRITE:
|
|
|
|
viewvecX = GLRenderer->mViewVector.X;
|
|
|
|
viewvecY = GLRenderer->mViewVector.Y;
|
|
|
|
|
|
|
|
x1 = x - viewvecY*leftfac;
|
|
|
|
x2 = x - viewvecY*rightfac;
|
|
|
|
y1 = y + viewvecX*leftfac;
|
|
|
|
y2 = y + viewvecX*rightfac;
|
|
|
|
break;
|
2016-09-16 16:45:58 +00:00
|
|
|
|
2016-05-01 19:08:09 +00:00
|
|
|
case RF_FLATSPRITE:
|
2016-09-16 16:45:58 +00:00
|
|
|
{
|
|
|
|
x1 = x + leftfac;
|
|
|
|
x2 = x + rightfac;
|
|
|
|
y1 = y - topfac;
|
|
|
|
y2 = y - bottomfac;
|
|
|
|
}
|
|
|
|
break;
|
2014-08-03 08:57:58 +00:00
|
|
|
case RF_WALLSPRITE:
|
2016-03-21 01:57:02 +00:00
|
|
|
viewvecX = thing->Angles.Yaw.Cos();
|
|
|
|
viewvecY = thing->Angles.Yaw.Sin();
|
2014-08-03 08:57:58 +00:00
|
|
|
|
|
|
|
x1 = x + viewvecY*leftfac;
|
|
|
|
x2 = x + viewvecY*rightfac;
|
|
|
|
y1 = y - viewvecX*leftfac;
|
|
|
|
y2 = y - viewvecX*rightfac;
|
|
|
|
break;
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x1 = x2 = x;
|
|
|
|
y1 = y2 = y;
|
|
|
|
z1 = z2 = z;
|
|
|
|
gltexture=NULL;
|
|
|
|
}
|
|
|
|
|
2016-04-23 08:50:19 +00:00
|
|
|
depth = FloatToFixed((x - ViewPos.X) * ViewTanCos + (y - ViewPos.Y) * ViewTanSin);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// light calculation
|
|
|
|
|
|
|
|
bool enhancedvision=false;
|
|
|
|
|
|
|
|
// allow disabling of the fullbright flag by a brightmap definition
|
|
|
|
// (e.g. to do the gun flashes of Doom's zombies correctly.
|
|
|
|
fullbright = (thing->flags5 & MF5_BRIGHT) ||
|
2014-10-26 07:41:52 +00:00
|
|
|
((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->gl_info.bDisableFullbright));
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
lightlevel=fullbright? 255 :
|
|
|
|
gl_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ?
|
|
|
|
rendersector->GetCeilingLight() : rendersector->GetFloorLight());
|
|
|
|
foglevel = (BYTE)clamp<short>(rendersector->lightlevel, 0, 255);
|
|
|
|
|
2016-03-31 19:42:27 +00:00
|
|
|
lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingpos);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-05-11 15:56:38 +00:00
|
|
|
ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff;
|
|
|
|
ThingColor.a = 255;
|
|
|
|
RenderStyle = thing->RenderStyle;
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
// colormap stuff is a little more complicated here...
|
|
|
|
if (gl_fixedcolormap)
|
|
|
|
{
|
|
|
|
if ((gl_enhanced_nv_stealth > 0 && gl_fixedcolormap == CM_LITE) // Infrared powerup only
|
|
|
|
|| (gl_enhanced_nv_stealth == 2 && gl_fixedcolormap >= CM_TORCH)// Also torches
|
|
|
|
|| (gl_enhanced_nv_stealth == 3)) // Any fixed colormap
|
|
|
|
enhancedvision=true;
|
|
|
|
|
2014-05-11 20:57:42 +00:00
|
|
|
Colormap.Clear();
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (gl_fixedcolormap==CM_LITE)
|
|
|
|
{
|
|
|
|
if (gl_enhanced_nightvision &&
|
|
|
|
(thing->IsKindOf(RUNTIME_CLASS(AInventory)) || thing->flags3&MF3_ISMONSTER || thing->flags&MF_MISSILE || thing->flags&MF_CORPSE))
|
|
|
|
{
|
2014-05-11 15:56:38 +00:00
|
|
|
RenderStyle.Flags |= STYLEF_InvertSource;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Colormap=rendersector->ColorMap;
|
|
|
|
if (fullbright)
|
|
|
|
{
|
|
|
|
if (rendersector == §ors[rendersector->sectornum] || in_area != area_below)
|
|
|
|
// under water areas keep their color for fullbright objects
|
|
|
|
{
|
|
|
|
// Only make the light white but keep everything else (fog, desaturation and Boom colormap.)
|
|
|
|
Colormap.LightColor.r=
|
|
|
|
Colormap.LightColor.g=
|
|
|
|
Colormap.LightColor.b=0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Colormap.LightColor.r = (3*Colormap.LightColor.r + 0xff)/4;
|
|
|
|
Colormap.LightColor.g = (3*Colormap.LightColor.g + 0xff)/4;
|
|
|
|
Colormap.LightColor.b = (3*Colormap.LightColor.b + 0xff)/4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (glset.nocoloredspritelighting)
|
|
|
|
{
|
2014-05-11 20:57:42 +00:00
|
|
|
Colormap.Decolorize();
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
translation=thing->Translation;
|
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
OverrideShader = -1;
|
2016-03-22 11:56:20 +00:00
|
|
|
trans = thing->Alpha;
|
2013-06-23 07:49:34 +00:00
|
|
|
hw_styleflags = STYLEHW_Normal;
|
|
|
|
|
|
|
|
if (RenderStyle.BlendOp >= STYLEOP_Fuzz && RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub)
|
|
|
|
{
|
|
|
|
RenderStyle.CheckFuzz();
|
|
|
|
if (RenderStyle.BlendOp == STYLEOP_Fuzz)
|
|
|
|
{
|
2016-09-01 09:52:52 +00:00
|
|
|
if (gl_fuzztype != 0 && !gl.legacyMode)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// Todo: implement shader selection here
|
|
|
|
RenderStyle = LegacyRenderStyles[STYLE_Translucent];
|
|
|
|
OverrideShader = gl_fuzztype + 4;
|
|
|
|
trans = 0.99f; // trans may not be 1 here
|
|
|
|
hw_styleflags |= STYLEHW_NoAlphaTest;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RenderStyle.BlendOp = STYLEOP_Shadow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RenderStyle.Flags & STYLEF_TransSoulsAlpha)
|
|
|
|
{
|
|
|
|
trans = transsouls;
|
|
|
|
}
|
|
|
|
else if (RenderStyle.Flags & STYLEF_Alpha1)
|
|
|
|
{
|
|
|
|
trans = 1.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trans >= 1.f-FLT_EPSILON && RenderStyle.BlendOp != STYLEOP_Shadow && (
|
|
|
|
(RenderStyle.SrcAlpha == STYLEALPHA_One && RenderStyle.DestAlpha == STYLEALPHA_Zero) ||
|
|
|
|
(RenderStyle.SrcAlpha == STYLEALPHA_Src && RenderStyle.DestAlpha == STYLEALPHA_InvSrc)
|
|
|
|
))
|
|
|
|
{
|
|
|
|
// This is a non-translucent sprite (i.e. STYLE_Normal or equivalent)
|
|
|
|
trans=1.f;
|
|
|
|
|
2016-09-18 15:45:02 +00:00
|
|
|
if (!gl_sprite_blend || modelframe || (thing->renderflags & (RF_FLATSPRITE|RF_WALLSPRITE)) || gl_billboard_faces_camera)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
RenderStyle.SrcAlpha = STYLEALPHA_One;
|
|
|
|
RenderStyle.DestAlpha = STYLEALPHA_Zero;
|
|
|
|
hw_styleflags = STYLEHW_Solid;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RenderStyle.SrcAlpha = STYLEALPHA_Src;
|
|
|
|
RenderStyle.DestAlpha = STYLEALPHA_InvSrc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((gltexture && gltexture->GetTransparent()) || (RenderStyle.Flags & STYLEF_RedIsAlpha))
|
|
|
|
{
|
|
|
|
if (hw_styleflags == STYLEHW_Solid)
|
|
|
|
{
|
|
|
|
RenderStyle.SrcAlpha = STYLEALPHA_Src;
|
|
|
|
RenderStyle.DestAlpha = STYLEALPHA_InvSrc;
|
|
|
|
}
|
|
|
|
hw_styleflags = STYLEHW_NoAlphaTest;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enhancedvision && gl_enhanced_nightvision)
|
|
|
|
{
|
|
|
|
if (RenderStyle.BlendOp == STYLEOP_Shadow)
|
|
|
|
{
|
|
|
|
// enhanced vision makes them more visible!
|
|
|
|
trans=0.5f;
|
2014-09-15 10:15:19 +00:00
|
|
|
FRenderStyle rs = RenderStyle;
|
2013-06-23 07:49:34 +00:00
|
|
|
RenderStyle = STYLE_Translucent;
|
2014-09-15 10:15:19 +00:00
|
|
|
RenderStyle.Flags = rs.Flags; // Flags must be preserved, at this point it can only be STYLEF_InvertSource
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else if (thing->flags & MF_STEALTH)
|
|
|
|
{
|
|
|
|
// enhanced vision overcomes stealth!
|
|
|
|
if (trans < 0.5f) trans = 0.5f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trans==0.0f) return;
|
|
|
|
|
|
|
|
// end of light calculation
|
|
|
|
|
|
|
|
actor=thing;
|
|
|
|
index = GLRenderer->gl_spriteindex++;
|
|
|
|
particle=NULL;
|
|
|
|
|
|
|
|
const bool drawWithXYBillboard = ( !(actor->renderflags & RF_FORCEYBILLBOARD)
|
2014-08-03 08:57:58 +00:00
|
|
|
&& (actor->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE
|
2013-06-23 07:49:34 +00:00
|
|
|
&& players[consoleplayer].camera
|
|
|
|
&& (gl_billboard_mode == 1 || actor->renderflags & RF_FORCEXYBILLBOARD ) );
|
|
|
|
|
|
|
|
|
2016-02-01 17:14:00 +00:00
|
|
|
// no light splitting when:
|
|
|
|
// 1. no lightlist
|
|
|
|
// 2. any fixed colormap
|
|
|
|
// 3. any bright object
|
|
|
|
// 4. any with render style shadow (which doesn't use the sector light)
|
|
|
|
// 5. anything with render style reverse subtract (light effect is not what would be desired here)
|
|
|
|
if (thing->Sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright &&
|
|
|
|
RenderStyle.BlendOp != STYLEOP_Shadow && RenderStyle.BlendOp != STYLEOP_RevSub)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-08-08 10:55:09 +00:00
|
|
|
if (gl.flags & RFL_NO_CLIP_PLANES) // on old hardware we are rather limited...
|
2016-04-26 19:31:24 +00:00
|
|
|
{
|
|
|
|
lightlist = NULL;
|
|
|
|
if (!drawWithXYBillboard && !modelframe)
|
|
|
|
{
|
|
|
|
SplitSprite(thing->Sector, hw_styleflags != STYLEHW_Solid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lightlist = &thing->Sector->e->XFloor.lightlist;
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-01 17:14:00 +00:00
|
|
|
lightlist = NULL;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-02-01 17:14:00 +00:00
|
|
|
|
|
|
|
PutSprite(hw_styleflags != STYLEHW_Solid);
|
2013-06-23 07:49:34 +00:00
|
|
|
rendered_sprites++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int shade, int fakeside)
|
|
|
|
{
|
2016-04-28 23:48:06 +00:00
|
|
|
if (GLRenderer->mClipPortal)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-28 23:48:06 +00:00
|
|
|
int clipres = GLRenderer->mClipPortal->ClipPoint(particle->Pos);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (clipres == GLPortal::PClip_InFront) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
player_t *player=&players[consoleplayer];
|
|
|
|
|
|
|
|
if (particle->trans==0) return;
|
|
|
|
|
|
|
|
lightlevel = gl_ClampLight(sector->GetTexture(sector_t::ceiling) == skyflatnum ?
|
|
|
|
sector->GetCeilingLight() : sector->GetFloorLight());
|
2016-06-17 14:16:31 +00:00
|
|
|
foglevel = (BYTE)clamp<short>(sector->lightlevel, 0, 255);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (gl_fixedcolormap)
|
|
|
|
{
|
2014-05-11 20:57:42 +00:00
|
|
|
Colormap.Clear();
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else if (!particle->bright)
|
|
|
|
{
|
|
|
|
TArray<lightlist_t> & lightlist=sector->e->XFloor.lightlist;
|
2016-04-02 21:17:16 +00:00
|
|
|
double lightbottom;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
Colormap = sector->ColorMap;
|
|
|
|
for(unsigned int i=0;i<lightlist.Size();i++)
|
|
|
|
{
|
2016-04-02 21:17:16 +00:00
|
|
|
if (i<lightlist.Size()-1) lightbottom = lightlist[i+1].plane.ZatPoint(particle->Pos);
|
|
|
|
else lightbottom = sector->floorplane.ZatPoint(particle->Pos);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-02 21:17:16 +00:00
|
|
|
if (lightbottom < particle->Pos.Z)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-04-06 12:03:21 +00:00
|
|
|
lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel);
|
2013-06-23 07:49:34 +00:00
|
|
|
Colormap.LightColor = (lightlist[i].extra_colormap)->Color;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-04-06 12:03:21 +00:00
|
|
|
if (glset.nocoloredspritelighting)
|
|
|
|
{
|
|
|
|
Colormap.Decolorize(); // ZDoom never applies colored light to particles.
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lightlevel = 255;
|
|
|
|
Colormap = sector->ColorMap;
|
|
|
|
Colormap.ClearColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
trans=particle->trans/255.0f;
|
|
|
|
RenderStyle = STYLE_Translucent;
|
|
|
|
OverrideShader = 0;
|
|
|
|
|
2013-11-30 11:35:38 +00:00
|
|
|
ThingColor = particle->color;
|
2014-05-11 15:56:38 +00:00
|
|
|
ThingColor.a = 255;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
modelframe=NULL;
|
|
|
|
gltexture=NULL;
|
2016-04-18 14:27:04 +00:00
|
|
|
topclip = LARGE_VALUE;
|
|
|
|
bottomclip = -LARGE_VALUE;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// [BB] Load the texture for round or smooth particles
|
|
|
|
if (gl_particles_style)
|
|
|
|
{
|
|
|
|
FTexture *lump = NULL;
|
|
|
|
if (gl_particles_style == 1)
|
|
|
|
{
|
|
|
|
lump = GLRenderer->glpart2;
|
|
|
|
}
|
|
|
|
else if (gl_particles_style == 2)
|
|
|
|
{
|
|
|
|
lump = GLRenderer->glpart;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lump != NULL)
|
|
|
|
{
|
2014-08-22 21:50:38 +00:00
|
|
|
gltexture = FMaterial::ValidateTexture(lump, true);
|
2013-06-23 07:49:34 +00:00
|
|
|
translation = 0;
|
|
|
|
|
|
|
|
ul = gltexture->GetUL();
|
|
|
|
ur = gltexture->GetUR();
|
|
|
|
vt = gltexture->GetVT();
|
|
|
|
vb = gltexture->GetVB();
|
|
|
|
FloatRect r;
|
2014-08-22 21:50:38 +00:00
|
|
|
gltexture->GetSpriteRect(&r);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-02 21:17:16 +00:00
|
|
|
x = particle->Pos.X;
|
|
|
|
y = particle->Pos.Y;
|
|
|
|
z = particle->Pos.Z;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
float scalefac=particle->size/4.0f;
|
|
|
|
// [BB] The smooth particles are smaller than the other ones. Compensate for this here.
|
|
|
|
if (gl_particles_style==2)
|
|
|
|
scalefac *= 1.7;
|
|
|
|
|
|
|
|
float viewvecX = GLRenderer->mViewVector.X;
|
|
|
|
float viewvecY = GLRenderer->mViewVector.Y;
|
|
|
|
|
|
|
|
x1=x+viewvecY*scalefac;
|
|
|
|
x2=x-viewvecY*scalefac;
|
|
|
|
y1=y-viewvecX*scalefac;
|
|
|
|
y2=y+viewvecX*scalefac;
|
|
|
|
z1=z-scalefac;
|
|
|
|
z2=z+scalefac;
|
|
|
|
|
2016-04-23 08:50:19 +00:00
|
|
|
depth = FloatToFixed((x - ViewPos.X) * ViewTanCos + (y - ViewPos.Y) * ViewTanSin);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
actor=NULL;
|
|
|
|
this->particle=particle;
|
2016-04-06 12:03:21 +00:00
|
|
|
fullbright = !!particle->bright;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// [BB] Translucent particles have to be rendered without the alpha test.
|
|
|
|
if (gl_particles_style != 2 && trans>=1.0f-FLT_EPSILON) hw_styleflags = STYLEHW_Solid;
|
|
|
|
else hw_styleflags = STYLEHW_NoAlphaTest;
|
|
|
|
|
2016-02-01 17:14:00 +00:00
|
|
|
if (sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright)
|
|
|
|
lightlist = §or->e->XFloor.lightlist;
|
|
|
|
else
|
|
|
|
lightlist = NULL;
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
PutSprite(hw_styleflags != STYLEHW_Solid);
|
|
|
|
rendered_sprites++;
|
|
|
|
}
|
|
|
|
|
2016-04-30 14:57:53 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-30 14:57:53 +00:00
|
|
|
void gl_RenderActorsInPortal(FGLLinePortal *glport)
|
|
|
|
{
|
|
|
|
TMap<AActor*, bool> processcheck;
|
|
|
|
if (glport->validcount == validcount) return; // only process once per frame
|
|
|
|
glport->validcount = validcount;
|
|
|
|
for (auto port : glport->lines)
|
|
|
|
{
|
|
|
|
line_t *line = port->mOrigin;
|
|
|
|
if (line->isLinePortal()) // only crossable ones
|
|
|
|
{
|
|
|
|
FLinePortal *port2 = port->mDestination->getPortal();
|
|
|
|
// process only if the other side links back to this one.
|
|
|
|
if (port2 != nullptr && port->mDestination == port2->mOrigin && port->mOrigin == port2->mDestination)
|
|
|
|
{
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-04-30 14:57:53 +00:00
|
|
|
for (portnode_t *node = port->render_thinglist; node != nullptr; node = node->m_snext)
|
|
|
|
{
|
|
|
|
AActor *th = node->m_thing;
|
|
|
|
|
|
|
|
// process each actor only once per portal.
|
|
|
|
bool *check = processcheck.CheckKey(th);
|
|
|
|
if (check && *check) continue;
|
|
|
|
processcheck[th] = true;
|
|
|
|
|
|
|
|
DAngle savedangle = th->Angles.Yaw;
|
|
|
|
DVector3 savedpos = th->Pos();
|
|
|
|
DVector3 newpos = savedpos;
|
|
|
|
sector_t fakesector;
|
|
|
|
|
|
|
|
P_TranslatePortalXY(line, newpos.X, newpos.Y);
|
|
|
|
P_TranslatePortalZ(line, newpos.Z);
|
|
|
|
P_TranslatePortalAngle(line, th->Angles.Yaw);
|
|
|
|
th->SetXYZ(newpos);
|
|
|
|
th->Prev += newpos - savedpos;
|
|
|
|
|
|
|
|
GLSprite spr;
|
|
|
|
th->fillcolor = 0xff0000ff;
|
|
|
|
spr.Process(th, gl_FakeFlat(th->Sector, &fakesector, false), 2);
|
|
|
|
th->fillcolor = 0xffffffff;
|
|
|
|
th->Angles.Yaw = savedangle;
|
|
|
|
th->SetXYZ(savedpos);
|
|
|
|
th->Prev -= newpos - savedpos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|