mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- weapon drawing code refactor complete.
Setup and drawing are now done separately, this also no longer needs the Quad drawer.
This commit is contained in:
parent
2be84dc636
commit
52d73eabbf
10 changed files with 195 additions and 191 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include "r_utility.h"
|
#include "r_utility.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
|
#include "tarray.h"
|
||||||
#include "hwrenderer/scene/hw_drawstructs.h"
|
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||||
|
|
||||||
#include "gl/data/gl_vertexbuffer.h"
|
#include "gl/data/gl_vertexbuffer.h"
|
||||||
|
@ -219,6 +220,7 @@ void FDrawInfo::StartScene()
|
||||||
}
|
}
|
||||||
decals[0].Clear();
|
decals[0].Clear();
|
||||||
decals[1].Clear();
|
decals[1].Clear();
|
||||||
|
hudsprites.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __GL_DRAWINFO_H
|
#define __GL_DRAWINFO_H
|
||||||
|
|
||||||
#include "hwrenderer/scene/hw_drawlist.h"
|
#include "hwrenderer/scene/hw_drawlist.h"
|
||||||
|
#include "hwrenderer/scene/hw_weapon.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable:4244)
|
#pragma warning(disable:4244)
|
||||||
|
@ -67,6 +68,7 @@ struct FDrawInfo : public HWDrawInfo
|
||||||
|
|
||||||
FDrawInfo * next;
|
FDrawInfo * next;
|
||||||
HWDrawList drawlists[GLDL_TYPES];
|
HWDrawList drawlists[GLDL_TYPES];
|
||||||
|
TArray<HUDSprite> hudsprites; // These may just be stored by value.
|
||||||
TArray<GLDecal *> decals[2]; // the second slot is for mirrors which get rendered in a separate pass.
|
TArray<GLDecal *> decals[2]; // the second slot is for mirrors which get rendered in a separate pass.
|
||||||
HWDrawList *dldrawlists = NULL; // only gets allocated when needed.
|
HWDrawList *dldrawlists = NULL; // only gets allocated when needed.
|
||||||
|
|
||||||
|
@ -79,6 +81,7 @@ struct FDrawInfo : public HWDrawInfo
|
||||||
void AddPortal(GLWall *w, int portaltype) override;
|
void AddPortal(GLWall *w, int portaltype) override;
|
||||||
void AddFlat(GLFlat *flat, bool fog) override;
|
void AddFlat(GLFlat *flat, bool fog) override;
|
||||||
void AddSprite(GLSprite *sprite, bool translucent) override;
|
void AddSprite(GLSprite *sprite, bool translucent) override;
|
||||||
|
void AddHUDSprite(HUDSprite *huds) override;
|
||||||
|
|
||||||
std::pair<FFlatVertex *, unsigned int> AllocVertices(unsigned int count) override;
|
std::pair<FFlatVertex *, unsigned int> AllocVertices(unsigned int count) override;
|
||||||
int UploadLights(FDynLightData &data) override;
|
int UploadLights(FDynLightData &data) override;
|
||||||
|
@ -121,6 +124,8 @@ struct FDrawInfo : public HWDrawInfo
|
||||||
|
|
||||||
// Sprite drawer
|
// Sprite drawer
|
||||||
void DrawSprite(GLSprite *sprite, int pass);
|
void DrawSprite(GLSprite *sprite, int pass);
|
||||||
|
void DrawPSprite(HUDSprite *huds);
|
||||||
|
void DrawPlayerSprites(bool hudModelStep);
|
||||||
|
|
||||||
void DoDrawSorted(HWDrawList *dl, SortNode * head);
|
void DoDrawSorted(HWDrawList *dl, SortNode * head);
|
||||||
void DrawSorted(int listindex);
|
void DrawSorted(int listindex);
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include "gl/renderer/gl_lightdata.h"
|
#include "gl/renderer/gl_lightdata.h"
|
||||||
#include "gl/renderer/gl_renderer.h"
|
#include "gl/renderer/gl_renderer.h"
|
||||||
#include "gl/renderer/gl_renderstate.h"
|
#include "gl/renderer/gl_renderstate.h"
|
||||||
#include "gl/renderer/gl_quaddrawer.h"
|
#include "gl/data/gl_vertexbuffer.h"
|
||||||
#include "hwrenderer/scene/hw_clipper.h"
|
#include "hwrenderer/scene/hw_clipper.h"
|
||||||
#include "gl/scene/gl_drawinfo.h"
|
#include "gl/scene/gl_drawinfo.h"
|
||||||
#include "gl/scene/gl_portal.h"
|
#include "gl/scene/gl_portal.h"
|
||||||
|
|
|
@ -261,6 +261,8 @@ void GLSceneDrawer::CreateScene()
|
||||||
gl_drawinfo->mShadowMap = &GLRenderer->mShadowMap;
|
gl_drawinfo->mShadowMap = &GLRenderer->mShadowMap;
|
||||||
|
|
||||||
RenderBSPNode (level.HeadNode());
|
RenderBSPNode (level.HeadNode());
|
||||||
|
gl_drawinfo->PreparePlayerSprites(r_viewpoint.sector, in_area);
|
||||||
|
|
||||||
// Process all the sprites on the current portal's back side which touch the portal.
|
// Process all the sprites on the current portal's back side which touch the portal.
|
||||||
if (GLRenderer->mCurrentPortal != NULL) GLRenderer->mCurrentPortal->RenderAttached();
|
if (GLRenderer->mCurrentPortal != NULL) GLRenderer->mCurrentPortal->RenderAttached();
|
||||||
Bsp.Unclock();
|
Bsp.Unclock();
|
||||||
|
@ -272,7 +274,6 @@ void GLSceneDrawer::CreateScene()
|
||||||
gl_drawinfo->HandleMissingTextures(in_area); // Missing upper/lower textures
|
gl_drawinfo->HandleMissingTextures(in_area); // Missing upper/lower textures
|
||||||
gl_drawinfo->HandleHackedSubsectors(); // open sector hacks for deep water
|
gl_drawinfo->HandleHackedSubsectors(); // open sector hacks for deep water
|
||||||
gl_drawinfo->ProcessSectorStacks(in_area); // merge visplanes of sector stacks
|
gl_drawinfo->ProcessSectorStacks(in_area); // merge visplanes of sector stacks
|
||||||
SetupWeaponLight();
|
|
||||||
GLRenderer->mLights->Finish();
|
GLRenderer->mLights->Finish();
|
||||||
GLRenderer->mVBO->Unmap();
|
GLRenderer->mVBO->Unmap();
|
||||||
|
|
||||||
|
@ -508,15 +509,13 @@ void GLSceneDrawer::EndDrawScene(sector_t * viewsector)
|
||||||
{
|
{
|
||||||
gl_RenderState.EnableFog(false);
|
gl_RenderState.EnableFog(false);
|
||||||
|
|
||||||
// [BB] HUD models need to be rendered here. Make sure that
|
// [BB] HUD models need to be rendered here.
|
||||||
// DrawPlayerSprites is only called once. Either to draw
|
|
||||||
// HUD models or to draw the weapon sprites.
|
|
||||||
const bool renderHUDModel = gl_IsHUDModelForPlayerAvailable( players[consoleplayer].camera->player );
|
const bool renderHUDModel = gl_IsHUDModelForPlayerAvailable( players[consoleplayer].camera->player );
|
||||||
if ( renderHUDModel )
|
if ( renderHUDModel )
|
||||||
{
|
{
|
||||||
// [BB] The HUD model should be drawn over everything else already drawn.
|
// [BB] The HUD model should be drawn over everything else already drawn.
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
DrawPlayerSprites (viewsector, true);
|
gl_drawinfo->DrawPlayerSprites(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
@ -550,11 +549,8 @@ void GLSceneDrawer::DrawEndScene2D(sector_t * viewsector)
|
||||||
glDisable(GL_MULTISAMPLE);
|
glDisable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
|
|
||||||
// [BB] Only draw the sprites if we didn't render a HUD model before.
|
gl_drawinfo->DrawPlayerSprites(false);
|
||||||
if (renderHUDModel == false)
|
|
||||||
{
|
|
||||||
DrawPlayerSprites(viewsector, false);
|
|
||||||
}
|
|
||||||
if (gl.legacyMode)
|
if (gl.legacyMode)
|
||||||
{
|
{
|
||||||
gl_RenderState.DrawColormapOverlay();
|
gl_RenderState.DrawColormapOverlay();
|
||||||
|
@ -562,7 +558,6 @@ void GLSceneDrawer::DrawEndScene2D(sector_t * viewsector)
|
||||||
|
|
||||||
gl_RenderState.SetFixedColormap(CM_DEFAULT);
|
gl_RenderState.SetFixedColormap(CM_DEFAULT);
|
||||||
gl_RenderState.SetSoftLightLevel(-1);
|
gl_RenderState.SetSoftLightLevel(-1);
|
||||||
DrawTargeterSprites();
|
|
||||||
if (!FGLRenderBuffers::IsEnabled())
|
if (!FGLRenderBuffers::IsEnabled())
|
||||||
{
|
{
|
||||||
DrawBlend(viewsector);
|
DrawBlend(viewsector);
|
||||||
|
|
|
@ -20,8 +20,6 @@ class GLSceneDrawer
|
||||||
|
|
||||||
TMap<DPSprite*, int> weapondynlightindex;
|
TMap<DPSprite*, int> weapondynlightindex;
|
||||||
|
|
||||||
void SetupWeaponLight();
|
|
||||||
|
|
||||||
void RenderMultipassStuff();
|
void RenderMultipassStuff();
|
||||||
|
|
||||||
void UnclipSubsector(subsector_t *sub);
|
void UnclipSubsector(subsector_t *sub);
|
||||||
|
@ -70,11 +68,6 @@ public:
|
||||||
void RenderView(player_t *player);
|
void RenderView(player_t *player);
|
||||||
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
|
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
|
||||||
|
|
||||||
void DrawPSprite(HUDSprite *huds);
|
|
||||||
void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep);
|
|
||||||
void DrawTargeterSprites();
|
|
||||||
void DrawPlayerHUDModel(sector_t * viewsector);
|
|
||||||
|
|
||||||
void InitClipper(angle_t a1, angle_t a2)
|
void InitClipper(angle_t a1, angle_t a2)
|
||||||
{
|
{
|
||||||
clipper.Clear();
|
clipper.Clear();
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include "gl/scene/gl_drawinfo.h"
|
#include "gl/scene/gl_drawinfo.h"
|
||||||
#include "gl/scene/gl_portal.h"
|
#include "gl/scene/gl_portal.h"
|
||||||
#include "gl/scene/gl_scenedrawer.h"
|
#include "gl/scene/gl_scenedrawer.h"
|
||||||
#include "gl/renderer/gl_quaddrawer.h"
|
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, gl_seamless)
|
EXTERN_CVAR(Bool, gl_seamless)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Copyright(C) 2000-2016 Christoph Oelckers
|
// Copyright(C) 2000-2018 Christoph Oelckers
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -26,12 +26,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gl/system/gl_system.h"
|
#include "gl/system/gl_system.h"
|
||||||
#include "sbar.h"
|
|
||||||
#include "r_utility.h"
|
#include "r_utility.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "doomstat.h"
|
|
||||||
#include "d_player.h"
|
|
||||||
#include "g_levellocals.h"
|
|
||||||
|
|
||||||
#include "gl/system/gl_interface.h"
|
#include "gl/system/gl_interface.h"
|
||||||
#include "hwrenderer/utility/hw_cvars.h"
|
#include "hwrenderer/utility/hw_cvars.h"
|
||||||
|
@ -43,21 +39,16 @@
|
||||||
#include "gl/scene/gl_drawinfo.h"
|
#include "gl/scene/gl_drawinfo.h"
|
||||||
#include "gl/scene/gl_scenedrawer.h"
|
#include "gl/scene/gl_scenedrawer.h"
|
||||||
#include "gl/models/gl_models.h"
|
#include "gl/models/gl_models.h"
|
||||||
#include "gl/renderer/gl_quaddrawer.h"
|
|
||||||
#include "gl/stereo3d/gl_stereo3d.h"
|
#include "gl/stereo3d/gl_stereo3d.h"
|
||||||
#include "gl/dynlights/gl_lightbuffer.h"
|
#include "gl/dynlights/gl_lightbuffer.h"
|
||||||
|
|
||||||
EXTERN_CVAR (Bool, r_drawplayersprites)
|
|
||||||
EXTERN_CVAR (Bool, r_deathcamera)
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// R_DrawPSprite
|
// R_DrawPSprite
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void GLSceneDrawer::DrawPSprite (HUDSprite *huds)
|
void FDrawInfo::DrawPSprite (HUDSprite *huds)
|
||||||
{
|
{
|
||||||
if (huds->RenderStyle.BlendOp == STYLEOP_Shadow)
|
if (huds->RenderStyle.BlendOp == STYLEOP_Shadow)
|
||||||
{
|
{
|
||||||
|
@ -65,23 +56,26 @@ void GLSceneDrawer::DrawPSprite (HUDSprite *huds)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetColor(huds->lightlevel, 0, huds->cm, huds->alpha, true);
|
mDrawer->SetColor(huds->lightlevel, 0, huds->cm, huds->alpha, true);
|
||||||
}
|
}
|
||||||
gl_SetRenderStyle(huds->RenderStyle, false, false);
|
gl_SetRenderStyle(huds->RenderStyle, false, false);
|
||||||
gl_RenderState.SetObjectColor(huds->ObjectColor);
|
gl_RenderState.SetObjectColor(huds->ObjectColor);
|
||||||
gl_RenderState.SetDynLight(huds->dynrgb[0], huds->dynrgb[1], huds->dynrgb[2]);
|
gl_RenderState.SetDynLight(huds->dynrgb[0], huds->dynrgb[1], huds->dynrgb[2]);
|
||||||
gl_RenderState.SetMaterial(huds->tex, CLAMP_XY_NOMIP, 0, huds->OverrideShader, !!(huds->RenderStyle.Flags & STYLEF_RedIsAlpha));
|
|
||||||
float thresh = (huds->tex->tex->GetTranslucency() || huds->OverrideShader != -1) ? 0.f : gl_mask_sprite_threshold;
|
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, thresh);
|
|
||||||
gl_RenderState.EnableBrightmap(!(huds->RenderStyle.Flags & STYLEF_ColorIsFixed));
|
gl_RenderState.EnableBrightmap(!(huds->RenderStyle.Flags & STYLEF_ColorIsFixed));
|
||||||
|
|
||||||
gl_RenderState.Apply();
|
if (huds->mframe)
|
||||||
FQuadDrawer qd;
|
{
|
||||||
qd.Set(0, huds->x1, huds->y1, 0, huds->u1, huds->v1);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0);
|
||||||
qd.Set(1, huds->x1, huds->y2, 0, huds->u1, huds->v2);
|
gl_RenderHUDModel(huds->weapon, huds->mx, huds->my, huds->lightindex);
|
||||||
qd.Set(2, huds->x2, huds->y1, 0, huds->u2, huds->v1);
|
}
|
||||||
qd.Set(3, huds->x2, huds->y2, 0, huds->u2, huds->v2);
|
else
|
||||||
qd.Render(GL_TRIANGLE_STRIP);
|
{
|
||||||
|
float thresh = (huds->tex->tex->GetTranslucency() || huds->OverrideShader != -1) ? 0.f : gl_mask_sprite_threshold;
|
||||||
|
gl_RenderState.AlphaFunc(GL_GEQUAL, thresh);
|
||||||
|
gl_RenderState.SetMaterial(huds->tex, CLAMP_XY_NOMIP, 0, huds->OverrideShader, !!(huds->RenderStyle.Flags & STYLEF_RedIsAlpha));
|
||||||
|
gl_RenderState.Apply();
|
||||||
|
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, huds->mx, 4);
|
||||||
|
}
|
||||||
|
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
||||||
gl_RenderState.SetObjectColor(0xffffffff);
|
gl_RenderState.SetObjectColor(0xffffffff);
|
||||||
|
@ -89,153 +83,27 @@ void GLSceneDrawer::DrawPSprite (HUDSprite *huds)
|
||||||
gl_RenderState.EnableBrightmap(false);
|
gl_RenderState.EnableBrightmap(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void GLSceneDrawer::SetupWeaponLight()
|
|
||||||
{
|
|
||||||
weapondynlightindex.Clear();
|
|
||||||
|
|
||||||
AActor *camera = r_viewpoint.camera;
|
|
||||||
AActor * playermo = players[consoleplayer].camera;
|
|
||||||
player_t * player = playermo->player;
|
|
||||||
|
|
||||||
// this is the same as in DrawPlayerSprites below (i.e. no weapon being drawn.)
|
|
||||||
if (!player ||
|
|
||||||
!r_drawplayersprites ||
|
|
||||||
!camera->player ||
|
|
||||||
(player->cheats & CF_CHASECAM) ||
|
|
||||||
(r_deathcamera && camera->health <= 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Check if lighting can be used on this item.
|
|
||||||
if (camera->RenderStyle.BlendOp == STYLEOP_Shadow || !level.HasDynamicLights || !gl_light_sprites || FixedColormap != CM_DEFAULT || gl.legacyMode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
|
|
||||||
{
|
|
||||||
if (psp->GetState() != nullptr)
|
|
||||||
{
|
|
||||||
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false) : nullptr;
|
|
||||||
if (smf)
|
|
||||||
{
|
|
||||||
hw_GetDynModelLight(playermo, lightdata);
|
|
||||||
weapondynlightindex[psp] = GLRenderer->mLights->UploadLights(lightdata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// R_DrawPlayerSprites
|
// R_DrawPlayerSprites
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
|
void FDrawInfo::DrawPlayerSprites(bool hudModelStep)
|
||||||
{
|
{
|
||||||
bool brightflash = false;
|
|
||||||
AActor * playermo=players[consoleplayer].camera;
|
|
||||||
player_t * player=playermo->player;
|
|
||||||
|
|
||||||
s3d::Stereo3DMode::getCurrentMode().AdjustPlayerSprites();
|
s3d::Stereo3DMode::getCurrentMode().AdjustPlayerSprites();
|
||||||
|
|
||||||
AActor *camera = r_viewpoint.camera;
|
|
||||||
|
|
||||||
// this is the same as the software renderer
|
|
||||||
if (!player ||
|
|
||||||
!r_drawplayersprites ||
|
|
||||||
!camera->player ||
|
|
||||||
(player->cheats & CF_CHASECAM) ||
|
|
||||||
(r_deathcamera && camera->health <= 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
WeaponPosition weap = GetWeaponPosition(camera->player);
|
|
||||||
WeaponLighting light = GetWeaponLighting(viewsector, r_viewpoint.Pos, FixedColormap, in_area, camera->Pos());
|
|
||||||
|
|
||||||
// hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change
|
|
||||||
// light mode here to draw the weapon sprite.
|
|
||||||
int oldlightmode = level.lightmode;
|
int oldlightmode = level.lightmode;
|
||||||
if (level.lightmode == 8) level.lightmode = 2;
|
if (!hudModelStep && level.lightmode == 8) level.lightmode = 2; // Software lighting cannot handle 2D content so revert to lightmode 2 for that.
|
||||||
|
for(auto &hudsprite : hudsprites)
|
||||||
for(DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
|
|
||||||
{
|
{
|
||||||
if (!psp->GetState()) continue;
|
if ((!!hudsprite.mframe) == hudModelStep)
|
||||||
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false) : nullptr;
|
|
||||||
// This is an 'either-or' proposition. This maybe needs some work to allow overlays with weapon models but as originally implemented this just won't work.
|
|
||||||
if (smf && !hudModelStep) continue;
|
|
||||||
if (!smf && hudModelStep) continue;
|
|
||||||
|
|
||||||
HUDSprite hudsprite;
|
|
||||||
hudsprite.owner = playermo;
|
|
||||||
hudsprite.mframe = smf;
|
|
||||||
|
|
||||||
if (!hudsprite.GetWeaponRenderStyle(psp, camera, viewsector, light)) continue;
|
|
||||||
|
|
||||||
FVector2 spos = BobWeapon(weap, psp);
|
|
||||||
|
|
||||||
hudsprite.dynrgb[0] = hudsprite.dynrgb[1] = hudsprite.dynrgb[2] = 0;
|
|
||||||
// set the lighting parameters
|
|
||||||
if (hudsprite.RenderStyle.BlendOp != STYLEOP_Shadow && level.HasDynamicLights && FixedColormap == CM_DEFAULT && gl_light_sprites && !hudModelStep || gl.legacyMode)
|
|
||||||
// For models with per-pixel lighting this was done in a previous pass.
|
|
||||||
{
|
|
||||||
gl_drawinfo->GetDynSpriteLight(playermo, nullptr, hudsprite.dynrgb);
|
|
||||||
}
|
|
||||||
|
|
||||||
// [BB] In the HUD model step we just render the model and break out.
|
|
||||||
if (hudModelStep)
|
|
||||||
{
|
|
||||||
hudsprite.x1 = spos.X;
|
|
||||||
hudsprite.y1 = spos.Y;
|
|
||||||
gl_RenderHUDModel(psp, spos.X, spos.Y, weapondynlightindex[psp]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!hudsprite.GetWeaponRect(psp, spos.X, spos.Y, player)) continue;
|
|
||||||
DrawPSprite(&hudsprite);
|
DrawPSprite(&hudsprite);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
level.lightmode = oldlightmode;
|
level.lightmode = oldlightmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FDrawInfo::AddHUDSprite(HUDSprite *huds)
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// R_DrawPlayerSprites
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void GLSceneDrawer::DrawTargeterSprites()
|
|
||||||
{
|
{
|
||||||
AActor * playermo = players[consoleplayer].camera;
|
hudsprites.Push(*huds);
|
||||||
player_t * player = playermo->player;
|
|
||||||
|
|
||||||
if (!player || playermo->renderflags&RF_INVISIBLE || !r_drawplayersprites || GLRenderer->mViewActor != playermo) return;
|
|
||||||
|
|
||||||
HUDSprite hudsprite;
|
|
||||||
|
|
||||||
hudsprite.owner = playermo;
|
|
||||||
hudsprite.mframe = nullptr;
|
|
||||||
hudsprite.cm.Clear();
|
|
||||||
hudsprite.lightlevel = 255;
|
|
||||||
hudsprite.ObjectColor = 0xffffffff;
|
|
||||||
hudsprite.alpha = 1;
|
|
||||||
hudsprite.RenderStyle = DefaultRenderStyle();
|
|
||||||
hudsprite.OverrideShader = -1;
|
|
||||||
hudsprite.dynrgb[0] = hudsprite.dynrgb[1] = hudsprite.dynrgb[2] = 0;
|
|
||||||
|
|
||||||
// The Targeter's sprites are always drawn normally.
|
|
||||||
for (DPSprite *psp = player->FindPSprite(PSP_TARGETCENTER); psp != nullptr; psp = psp->GetNext())
|
|
||||||
{
|
|
||||||
if (psp->GetState() != nullptr && (psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr))
|
|
||||||
{
|
|
||||||
hudsprite.weapon = psp;
|
|
||||||
hudsprite.GetWeaponRect(psp, psp->x, psp->y, player);
|
|
||||||
|
|
||||||
DrawPSprite(&hudsprite);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ struct GLDecal;
|
||||||
class IShadowMap;
|
class IShadowMap;
|
||||||
struct particle_t;
|
struct particle_t;
|
||||||
struct FDynLightData;
|
struct FDynLightData;
|
||||||
|
struct HUDSprite;
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -144,6 +145,9 @@ public:
|
||||||
void GetDynSpriteLight(AActor *self, float x, float y, float z, FLightNode *node, int portalgroup, float *out);
|
void GetDynSpriteLight(AActor *self, float x, float y, float z, FLightNode *node, int portalgroup, float *out);
|
||||||
void GetDynSpriteLight(AActor *thing, particle_t *particle, float *out);
|
void GetDynSpriteLight(AActor *thing, particle_t *particle, float *out);
|
||||||
|
|
||||||
|
void PreparePlayerSprites(sector_t * viewsector, area_t in_area);
|
||||||
|
void PrepareTargeterSprites();
|
||||||
|
|
||||||
virtual void DrawWall(GLWall *wall, int pass) = 0;
|
virtual void DrawWall(GLWall *wall, int pass) = 0;
|
||||||
virtual void DrawFlat(GLFlat *flat, int pass, bool trans) = 0;
|
virtual void DrawFlat(GLFlat *flat, int pass, bool trans) = 0;
|
||||||
virtual void DrawSprite(GLSprite *sprite, int pass) = 0;
|
virtual void DrawSprite(GLSprite *sprite, int pass) = 0;
|
||||||
|
@ -158,7 +162,8 @@ public:
|
||||||
virtual void AddMirrorSurface(GLWall *w) = 0;
|
virtual void AddMirrorSurface(GLWall *w) = 0;
|
||||||
virtual void AddFlat(GLFlat *flat, bool fog) = 0;
|
virtual void AddFlat(GLFlat *flat, bool fog) = 0;
|
||||||
virtual void AddSprite(GLSprite *sprite, bool translucent) = 0;
|
virtual void AddSprite(GLSprite *sprite, bool translucent) = 0;
|
||||||
|
virtual void AddHUDSprite(HUDSprite *huds) = 0;
|
||||||
|
|
||||||
virtual int UploadLights(FDynLightData &data) = 0;
|
virtual int UploadLights(FDynLightData &data) = 0;
|
||||||
|
|
||||||
virtual GLDecal *AddDecal(bool onmirror) = 0;
|
virtual GLDecal *AddDecal(bool onmirror) = 0;
|
||||||
|
|
|
@ -31,14 +31,21 @@
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "d_player.h"
|
#include "d_player.h"
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
|
#include "r_data/models/models.h"
|
||||||
#include "hw_weapon.h"
|
#include "hw_weapon.h"
|
||||||
#include "hw_fakeflat.h"
|
#include "hw_fakeflat.h"
|
||||||
|
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
||||||
#include "hwrenderer/textures/hw_material.h"
|
#include "hwrenderer/textures/hw_material.h"
|
||||||
#include "hwrenderer/utility/hw_lighting.h"
|
#include "hwrenderer/utility/hw_lighting.h"
|
||||||
#include "hwrenderer/utility/hw_cvars.h"
|
#include "hwrenderer/utility/hw_cvars.h"
|
||||||
|
#include "hwrenderer/scene/hw_drawinfo.h"
|
||||||
|
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||||
|
#include "hwrenderer/data/flatvertices.h"
|
||||||
|
|
||||||
EXTERN_CVAR(Float, transsouls)
|
EXTERN_CVAR(Float, transsouls)
|
||||||
EXTERN_CVAR(Int, gl_fuzztype)
|
EXTERN_CVAR(Int, gl_fuzztype)
|
||||||
|
EXTERN_CVAR(Bool, r_drawplayersprites)
|
||||||
|
EXTERN_CVAR(Bool, r_deathcamera)
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -69,7 +76,7 @@ static bool isBright(DPSprite *psp)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
WeaponPosition GetWeaponPosition(player_t *player)
|
static WeaponPosition GetWeaponPosition(player_t *player)
|
||||||
{
|
{
|
||||||
WeaponPosition w;
|
WeaponPosition w;
|
||||||
P_BobWeapon(player, &w.bobx, &w.boby, r_viewpoint.TicFrac);
|
P_BobWeapon(player, &w.bobx, &w.boby, r_viewpoint.TicFrac);
|
||||||
|
@ -102,7 +109,7 @@ WeaponPosition GetWeaponPosition(player_t *player)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FVector2 BobWeapon(WeaponPosition &weap, DPSprite *psp)
|
static FVector2 BobWeapon(WeaponPosition &weap, DPSprite *psp)
|
||||||
{
|
{
|
||||||
if (psp->firstTic)
|
if (psp->firstTic)
|
||||||
{ // Can't interpolate the first tic.
|
{ // Can't interpolate the first tic.
|
||||||
|
@ -134,7 +141,7 @@ FVector2 BobWeapon(WeaponPosition &weap, DPSprite *psp)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
WeaponLighting GetWeaponLighting(sector_t *viewsector, const DVector3 &pos, int FixedColormap, area_t in_area, const DVector3 &playerpos)
|
static WeaponLighting GetWeaponLighting(sector_t *viewsector, const DVector3 &pos, int FixedColormap, area_t in_area, const DVector3 &playerpos)
|
||||||
{
|
{
|
||||||
WeaponLighting l;
|
WeaponLighting l;
|
||||||
|
|
||||||
|
@ -321,7 +328,7 @@ bool HUDSprite::GetWeaponRenderStyle(DPSprite *psp, AActor *playermo, sector_t *
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool HUDSprite::GetWeaponRect(DPSprite *psp, float sx, float sy, player_t *player)
|
bool HUDSprite::GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy, player_t *player)
|
||||||
{
|
{
|
||||||
float tx;
|
float tx;
|
||||||
float scale;
|
float scale;
|
||||||
|
@ -345,6 +352,8 @@ bool HUDSprite::GetWeaponRect(DPSprite *psp, float sx, float sy, player_t *playe
|
||||||
// calculate edges of the shape
|
// calculate edges of the shape
|
||||||
scalex = (320.0f / (240.0f * r_viewwindow.WidescreenRatio)) * vw / 320;
|
scalex = (320.0f / (240.0f * r_viewwindow.WidescreenRatio)) * vw / 320;
|
||||||
|
|
||||||
|
float x1, y1, x2, y2, u1, v1, u2, v2;
|
||||||
|
|
||||||
tx = (psp->Flags & PSPF_MIRROR) ? ((160 - r.width) - (sx + r.left)) : (sx - (160 - r.left));
|
tx = (psp->Flags & PSPF_MIRROR) ? ((160 - r.width) - (sx + r.left)) : (sx - (160 - r.left));
|
||||||
x1 = tx * scalex + vw / 2;
|
x1 = tx * scalex + vw / 2;
|
||||||
if (x1 > vw) return false; // off the right side
|
if (x1 > vw) return false; // off the right side
|
||||||
|
@ -392,7 +401,142 @@ bool HUDSprite::GetWeaponRect(DPSprite *psp, float sx, float sy, player_t *playe
|
||||||
u2 = tex->GetSpriteUR();
|
u2 = tex->GetSpriteUR();
|
||||||
v2 = tex->GetSpriteVB();
|
v2 = tex->GetSpriteVB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto verts = di->AllocVertices(4);
|
||||||
|
mx = verts.second;
|
||||||
|
|
||||||
|
verts.first[0].Set(x1, y1, 0, u1, v1);
|
||||||
|
verts.first[1].Set(x1, y2, 0, u1, v2);
|
||||||
|
verts.first[2].Set(x2, y1, 0, u2, v1);
|
||||||
|
verts.first[3].Set(x2, y2, 0, u2, v2);
|
||||||
|
|
||||||
this->tex = tex;
|
this->tex = tex;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// R_DrawPlayerSprites
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void HWDrawInfo::PreparePlayerSprites(sector_t * viewsector, area_t in_area)
|
||||||
|
{
|
||||||
|
|
||||||
|
bool brightflash = false;
|
||||||
|
AActor * playermo = players[consoleplayer].camera;
|
||||||
|
player_t * player = playermo->player;
|
||||||
|
const bool hudModelStep = gl_IsHUDModelForPlayerAvailable(player);
|
||||||
|
|
||||||
|
AActor *camera = r_viewpoint.camera;
|
||||||
|
|
||||||
|
// this is the same as the software renderer
|
||||||
|
if (!player ||
|
||||||
|
!r_drawplayersprites ||
|
||||||
|
!camera->player ||
|
||||||
|
(player->cheats & CF_CHASECAM) ||
|
||||||
|
(r_deathcamera && camera->health <= 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
WeaponPosition weap = GetWeaponPosition(camera->player);
|
||||||
|
WeaponLighting light = GetWeaponLighting(viewsector, r_viewpoint.Pos, FixedColormap, in_area, camera->Pos());
|
||||||
|
|
||||||
|
// hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change
|
||||||
|
// light mode here to draw the weapon sprite.
|
||||||
|
int oldlightmode = level.lightmode;
|
||||||
|
if (level.lightmode == 8) level.lightmode = 2;
|
||||||
|
|
||||||
|
for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
|
||||||
|
{
|
||||||
|
if (!psp->GetState()) continue;
|
||||||
|
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false) : nullptr;
|
||||||
|
// This is an 'either-or' proposition. This maybe needs some work to allow overlays with weapon models but as originally implemented this just won't work.
|
||||||
|
if (smf && !hudModelStep) continue;
|
||||||
|
if (!smf && hudModelStep) continue;
|
||||||
|
|
||||||
|
HUDSprite hudsprite;
|
||||||
|
hudsprite.owner = playermo;
|
||||||
|
hudsprite.mframe = smf;
|
||||||
|
hudsprite.weapon = psp;
|
||||||
|
|
||||||
|
if (!hudsprite.GetWeaponRenderStyle(psp, camera, viewsector, light)) continue;
|
||||||
|
|
||||||
|
FVector2 spos = BobWeapon(weap, psp);
|
||||||
|
|
||||||
|
hudsprite.dynrgb[0] = hudsprite.dynrgb[1] = hudsprite.dynrgb[2] = 0;
|
||||||
|
hudsprite.lightindex = -1;
|
||||||
|
// set the lighting parameters
|
||||||
|
if (hudsprite.RenderStyle.BlendOp != STYLEOP_Shadow && level.HasDynamicLights && FixedColormap == CM_DEFAULT && gl_light_sprites)
|
||||||
|
{
|
||||||
|
if (!hudModelStep || (screen->hwcaps & RFL_NO_SHADERS))
|
||||||
|
{
|
||||||
|
GetDynSpriteLight(playermo, nullptr, hudsprite.dynrgb);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hw_GetDynModelLight(playermo, lightdata);
|
||||||
|
hudsprite.lightindex = UploadLights(lightdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// [BB] In the HUD model step we just render the model and break out.
|
||||||
|
if (hudModelStep)
|
||||||
|
{
|
||||||
|
hudsprite.mx = spos.X;
|
||||||
|
hudsprite.my = spos.Y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!hudsprite.GetWeaponRect(this, psp, spos.X, spos.Y, player)) continue;
|
||||||
|
}
|
||||||
|
AddHUDSprite(&hudsprite);
|
||||||
|
}
|
||||||
|
level.lightmode = oldlightmode;
|
||||||
|
PrepareTargeterSprites();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// R_DrawPlayerSprites
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void HWDrawInfo::PrepareTargeterSprites()
|
||||||
|
{
|
||||||
|
AActor * playermo = players[consoleplayer].camera;
|
||||||
|
player_t * player = playermo->player;
|
||||||
|
AActor *camera = r_viewpoint.camera;
|
||||||
|
|
||||||
|
// this is the same as above
|
||||||
|
if (!player ||
|
||||||
|
!r_drawplayersprites ||
|
||||||
|
!camera->player ||
|
||||||
|
(player->cheats & CF_CHASECAM) ||
|
||||||
|
(r_deathcamera && camera->health <= 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
HUDSprite hudsprite;
|
||||||
|
|
||||||
|
hudsprite.owner = playermo;
|
||||||
|
hudsprite.mframe = nullptr;
|
||||||
|
hudsprite.cm.Clear();
|
||||||
|
hudsprite.lightlevel = 255;
|
||||||
|
hudsprite.ObjectColor = 0xffffffff;
|
||||||
|
hudsprite.alpha = 1;
|
||||||
|
hudsprite.RenderStyle = DefaultRenderStyle();
|
||||||
|
hudsprite.OverrideShader = -1;
|
||||||
|
hudsprite.dynrgb[0] = hudsprite.dynrgb[1] = hudsprite.dynrgb[2] = 0;
|
||||||
|
|
||||||
|
// The Targeter's sprites are always drawn normally.
|
||||||
|
for (DPSprite *psp = player->FindPSprite(PSP_TARGETCENTER); psp != nullptr; psp = psp->GetNext())
|
||||||
|
{
|
||||||
|
if (psp->GetState() != nullptr && (psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr))
|
||||||
|
{
|
||||||
|
hudsprite.weapon = psp;
|
||||||
|
hudsprite.GetWeaponRect(this, psp, psp->x, psp->y, player);
|
||||||
|
|
||||||
|
AddHUDSprite(&hudsprite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ class player_t;
|
||||||
class AActor;
|
class AActor;
|
||||||
enum area_t : int;
|
enum area_t : int;
|
||||||
struct FSpriteModelFrame;
|
struct FSpriteModelFrame;
|
||||||
|
struct HWDrawInfo;
|
||||||
|
|
||||||
|
|
||||||
struct WeaponPosition
|
struct WeaponPosition
|
||||||
|
@ -39,20 +39,13 @@ struct HUDSprite
|
||||||
float alpha;
|
float alpha;
|
||||||
int OverrideShader;
|
int OverrideShader;
|
||||||
|
|
||||||
float x1, y1;
|
float mx, my;
|
||||||
float x2, y2;
|
|
||||||
float u1, v1;
|
|
||||||
float u2, v2;
|
|
||||||
float dynrgb[3];
|
float dynrgb[3];
|
||||||
|
|
||||||
|
int lightindex;
|
||||||
|
|
||||||
void SetBright(bool isbelow);
|
void SetBright(bool isbelow);
|
||||||
bool GetWeaponRenderStyle(DPSprite *psp, AActor *playermo, sector_t *viewsector, WeaponLighting &light);
|
bool GetWeaponRenderStyle(DPSprite *psp, AActor *playermo, sector_t *viewsector, WeaponLighting &light);
|
||||||
bool GetWeaponRect(DPSprite *psp, float sx, float sy, player_t *player);
|
bool GetWeaponRect(HWDrawInfo *di, DPSprite *psp, float sx, float sy, player_t *player);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WeaponPosition GetWeaponPosition(player_t *player);
|
|
||||||
FVector2 BobWeapon(WeaponPosition &weap, DPSprite *psp);
|
|
||||||
WeaponLighting GetWeaponLighting(sector_t *viewsector, const DVector3 &pos, int FixedColormap, area_t in_area, const DVector3 &playerpos );
|
|
||||||
|
|
Loading…
Reference in a new issue