mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-25 13:31:07 +00:00
Merge branch 'master' of https://github.com/coelckers/gzdoom
This commit is contained in:
commit
df6a50872d
22 changed files with 500 additions and 479 deletions
|
@ -124,6 +124,23 @@ Note: All <bool> fields default to false unless mentioned otherwise.
|
||||||
|
|
||||||
transparent = <bool>; // true = line is a Strife transparent line (alpha 0.25)
|
transparent = <bool>; // true = line is a Strife transparent line (alpha 0.25)
|
||||||
|
|
||||||
|
automapstyle = <integer>; // Explicit automap style. Possible values can be
|
||||||
|
// 0: Automap style is based on line properties (default).
|
||||||
|
// 1: One-sided wall.
|
||||||
|
// 2: Two-sided wall.
|
||||||
|
// 3: Floor levels of front and back sectors are different.
|
||||||
|
// 4: Ceiling levels of front and back sectors are different.
|
||||||
|
// 5: 3D floor border.
|
||||||
|
// 6: Wall with special non-door action.
|
||||||
|
// 7: Secret door.
|
||||||
|
// 8: Wall not seen yet.
|
||||||
|
// 9: Locked door.
|
||||||
|
// 10: Intra-level teleporter.
|
||||||
|
// 11: Inter-level or game-ending teleporter.
|
||||||
|
// 12: Unexplored secret wall.
|
||||||
|
// 13: Portal line.
|
||||||
|
revealed = <bool>; // true = line is initially visible on automap.
|
||||||
|
|
||||||
* Note about arg0str
|
* Note about arg0str
|
||||||
|
|
||||||
For lines with ACS specials (80-86 and 226), if arg0str is present and non-null, it
|
For lines with ACS specials (80-86 and 226), if arg0str is present and non-null, it
|
||||||
|
@ -430,6 +447,10 @@ sector material colors.
|
||||||
1.29 04.02.2018
|
1.29 04.02.2018
|
||||||
arg0str in dynamic lights.
|
arg0str in dynamic lights.
|
||||||
|
|
||||||
|
1.30 20.05.2018
|
||||||
|
Added automapstyle and revealed linedef properties.
|
||||||
|
Replaced tabs with spaces.
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
EOF
|
EOF
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|
|
@ -36,6 +36,7 @@ class FGLModelRenderer : public FModelRenderer
|
||||||
public:
|
public:
|
||||||
FGLModelRenderer(int mli) : modellightindex(mli)
|
FGLModelRenderer(int mli) : modellightindex(mli)
|
||||||
{}
|
{}
|
||||||
|
ModelRendererType GetType() const override { return GLModelRendererType; }
|
||||||
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) override;
|
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) override;
|
||||||
void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
|
void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
|
||||||
IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) override;
|
IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) override;
|
||||||
|
|
|
@ -120,9 +120,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
||||||
mCustomPostProcessShaders = nullptr;
|
mCustomPostProcessShaders = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_LoadModels();
|
|
||||||
void gl_FlushModels();
|
|
||||||
|
|
||||||
void FGLRenderer::Initialize(int width, int height)
|
void FGLRenderer::Initialize(int width, int height)
|
||||||
{
|
{
|
||||||
mBuffers = new FGLRenderBuffers();
|
mBuffers = new FGLRenderBuffers();
|
||||||
|
@ -174,7 +171,6 @@ void FGLRenderer::Initialize(int width, int height)
|
||||||
SetupLevel();
|
SetupLevel();
|
||||||
mShaderManager = new FShaderManager;
|
mShaderManager = new FShaderManager;
|
||||||
mSamplerManager = new FSamplerManager;
|
mSamplerManager = new FSamplerManager;
|
||||||
gl_LoadModels();
|
|
||||||
|
|
||||||
GLPortal::Initialize();
|
GLPortal::Initialize();
|
||||||
}
|
}
|
||||||
|
@ -183,7 +179,7 @@ FGLRenderer::~FGLRenderer()
|
||||||
{
|
{
|
||||||
GLPortal::Shutdown();
|
GLPortal::Shutdown();
|
||||||
|
|
||||||
gl_FlushModels();
|
FlushModels();
|
||||||
AActor::DeleteAllAttachedLights();
|
AActor::DeleteAllAttachedLights();
|
||||||
FMaterial::FlushAll();
|
FMaterial::FlushAll();
|
||||||
if (legacyShaders) delete legacyShaders;
|
if (legacyShaders) delete legacyShaders;
|
||||||
|
|
|
@ -488,7 +488,7 @@ void GLSceneDrawer::EndDrawScene(FDrawInfo *di, sector_t * viewsector)
|
||||||
gl_RenderState.EnableFog(false);
|
gl_RenderState.EnableFog(false);
|
||||||
|
|
||||||
// [BB] HUD models need to be rendered here.
|
// [BB] HUD models need to be rendered here.
|
||||||
const bool renderHUDModel = gl_IsHUDModelForPlayerAvailable( players[consoleplayer].camera->player );
|
const bool renderHUDModel = 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.
|
||||||
|
@ -517,7 +517,7 @@ void GLSceneDrawer::EndDrawScene(FDrawInfo *di, sector_t * viewsector)
|
||||||
|
|
||||||
void GLSceneDrawer::DrawEndScene2D(FDrawInfo *di, sector_t * viewsector)
|
void GLSceneDrawer::DrawEndScene2D(FDrawInfo *di, sector_t * viewsector)
|
||||||
{
|
{
|
||||||
const bool renderHUDModel = gl_IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
const bool renderHUDModel = IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
||||||
|
|
||||||
// This should be removed once all 2D stuff is really done through the 2D interface.
|
// This should be removed once all 2D stuff is really done through the 2D interface.
|
||||||
gl_RenderState.mViewMatrix.loadIdentity();
|
gl_RenderState.mViewMatrix.loadIdentity();
|
||||||
|
|
|
@ -449,7 +449,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
||||||
// exclude vertically moving objects from this check.
|
// exclude vertically moving objects from this check.
|
||||||
if (!thing->Vel.isZero())
|
if (!thing->Vel.isZero())
|
||||||
{
|
{
|
||||||
if (!gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, false))
|
if (!FindModelFrame(thing->GetClass(), spritenum, thing->frame, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
||||||
z += fz;
|
z += fz;
|
||||||
}
|
}
|
||||||
|
|
||||||
modelframe = isPicnumOverride ? nullptr : gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
|
modelframe = isPicnumOverride ? nullptr : FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
|
||||||
if (!modelframe)
|
if (!modelframe)
|
||||||
{
|
{
|
||||||
bool mirror;
|
bool mirror;
|
||||||
|
|
|
@ -252,14 +252,13 @@ bool HUDSprite::GetWeaponRenderStyle(DPSprite *psp, AActor *playermo, sector_t *
|
||||||
auto rs = psp->GetRenderStyle(playermo->RenderStyle, playermo->Alpha);
|
auto rs = psp->GetRenderStyle(playermo->RenderStyle, playermo->Alpha);
|
||||||
|
|
||||||
visstyle_t vis;
|
visstyle_t vis;
|
||||||
float trans = 0.f;
|
|
||||||
|
|
||||||
vis.RenderStyle = STYLE_Count;
|
vis.RenderStyle = STYLE_Count;
|
||||||
vis.Alpha = rs.second;
|
vis.Alpha = rs.second;
|
||||||
vis.Invert = false;
|
vis.Invert = false;
|
||||||
playermo->AlterWeaponSprite(&vis);
|
playermo->AlterWeaponSprite(&vis);
|
||||||
|
|
||||||
if (!(psp->Flags & PSPF_FORCEALPHA)) trans = vis.Alpha;
|
alpha = (psp->Flags & PSPF_FORCEALPHA) ? 0.f : vis.Alpha;
|
||||||
|
|
||||||
if (vis.RenderStyle != STYLE_Count && !(psp->Flags & PSPF_FORCESTYLE))
|
if (vis.RenderStyle != STYLE_Count && !(psp->Flags & PSPF_FORCESTYLE))
|
||||||
{
|
{
|
||||||
|
@ -303,14 +302,10 @@ bool HUDSprite::GetWeaponRenderStyle(DPSprite *psp, AActor *playermo, sector_t *
|
||||||
{
|
{
|
||||||
alpha = 1.f;
|
alpha = 1.f;
|
||||||
}
|
}
|
||||||
else if (trans == 0.f)
|
else if (alpha == 0.f)
|
||||||
{
|
{
|
||||||
alpha = vis.Alpha;
|
alpha = vis.Alpha;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
alpha = trans;
|
|
||||||
}
|
|
||||||
if (!RenderStyle.IsVisible(alpha)) return false; // if it isn't visible skip the rest.
|
if (!RenderStyle.IsVisible(alpha)) return false; // if it isn't visible skip the rest.
|
||||||
|
|
||||||
PalEntry ThingColor = (playermo->RenderStyle.Flags & STYLEF_ColorIsFixed) ? playermo->fillcolor : 0xffffff;
|
PalEntry ThingColor = (playermo->RenderStyle.Flags & STYLEF_ColorIsFixed) ? playermo->fillcolor : 0xffffff;
|
||||||
|
@ -430,7 +425,7 @@ void HWDrawInfo::PreparePlayerSprites(sector_t * viewsector, area_t in_area)
|
||||||
bool brightflash = false;
|
bool brightflash = false;
|
||||||
AActor * playermo = players[consoleplayer].camera;
|
AActor * playermo = players[consoleplayer].camera;
|
||||||
player_t * player = playermo->player;
|
player_t * player = playermo->player;
|
||||||
const bool hudModelStep = gl_IsHUDModelForPlayerAvailable(player);
|
const bool hudModelStep = IsHUDModelForPlayerAvailable(player);
|
||||||
|
|
||||||
AActor *camera = r_viewpoint.camera;
|
AActor *camera = r_viewpoint.camera;
|
||||||
|
|
||||||
|
@ -453,7 +448,7 @@ void HWDrawInfo::PreparePlayerSprites(sector_t * viewsector, area_t in_area)
|
||||||
for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
|
for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
|
||||||
{
|
{
|
||||||
if (!psp->GetState()) continue;
|
if (!psp->GetState()) continue;
|
||||||
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false) : nullptr;
|
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? 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.
|
// 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;
|
||||||
if (!smf && hudModelStep) continue;
|
if (!smf && hudModelStep) continue;
|
||||||
|
|
|
@ -119,7 +119,7 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
||||||
{
|
{
|
||||||
auto &state = cls->GetStates()[i];
|
auto &state = cls->GetStates()[i];
|
||||||
spritelist[state.sprite].Insert(gltrans, true);
|
spritelist[state.sprite].Insert(gltrans, true);
|
||||||
FSpriteModelFrame * smf = gl_FindModelFrame(cls, state.sprite, state.Frame, false);
|
FSpriteModelFrame * smf = FindModelFrame(cls, state.sprite, state.Frame, false);
|
||||||
if (smf != NULL)
|
if (smf != NULL)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_MODELS_PER_FRAME; i++)
|
for (int i = 0; i < MAX_MODELS_PER_FRAME; i++)
|
||||||
|
|
|
@ -33,9 +33,6 @@
|
||||||
#include "actorinlines.h"
|
#include "actorinlines.h"
|
||||||
#include "i_time.h"
|
#include "i_time.h"
|
||||||
|
|
||||||
void gl_FlushModels();
|
|
||||||
bool polymodelsInUse;
|
|
||||||
|
|
||||||
void PolyRenderModel(PolyRenderThread *thread, const Mat4f &worldToClip, uint32_t stencilValue, float x, float y, float z, FSpriteModelFrame *smf, AActor *actor)
|
void PolyRenderModel(PolyRenderThread *thread, const Mat4f &worldToClip, uint32_t stencilValue, float x, float y, float z, FSpriteModelFrame *smf, AActor *actor)
|
||||||
{
|
{
|
||||||
PolyModelRenderer renderer(thread, worldToClip, stencilValue);
|
PolyModelRenderer renderer(thread, worldToClip, stencilValue);
|
||||||
|
@ -52,11 +49,6 @@ void PolyRenderHUDModel(PolyRenderThread *thread, const Mat4f &worldToClip, uint
|
||||||
|
|
||||||
PolyModelRenderer::PolyModelRenderer(PolyRenderThread *thread, const Mat4f &worldToClip, uint32_t stencilValue) : Thread(thread), WorldToClip(worldToClip), StencilValue(stencilValue)
|
PolyModelRenderer::PolyModelRenderer(PolyRenderThread *thread, const Mat4f &worldToClip, uint32_t stencilValue) : Thread(thread), WorldToClip(worldToClip), StencilValue(stencilValue)
|
||||||
{
|
{
|
||||||
if (!polymodelsInUse)
|
|
||||||
{
|
|
||||||
gl_FlushModels();
|
|
||||||
polymodelsInUse = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix)
|
void PolyModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix)
|
||||||
|
|
|
@ -34,6 +34,8 @@ class PolyModelRenderer : public FModelRenderer
|
||||||
public:
|
public:
|
||||||
PolyModelRenderer(PolyRenderThread *thread, const Mat4f &worldToClip, uint32_t stencilValue);
|
PolyModelRenderer(PolyRenderThread *thread, const Mat4f &worldToClip, uint32_t stencilValue);
|
||||||
|
|
||||||
|
ModelRendererType GetType() const override { return PolyModelRendererType; }
|
||||||
|
|
||||||
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) override;
|
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) override;
|
||||||
void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
|
void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
|
||||||
IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) override;
|
IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) override;
|
||||||
|
|
|
@ -60,7 +60,7 @@ void RenderPolyPlayerSprites::Render(PolyRenderThread *thread)
|
||||||
(r_deathcamera && viewpoint.camera->health <= 0))
|
(r_deathcamera && viewpoint.camera->health <= 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
renderHUDModel = r_models && gl_IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
renderHUDModel = r_models && IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
||||||
|
|
||||||
PolyTransferHeights fakeflat(viewpoint.camera->subsector);
|
PolyTransferHeights fakeflat(viewpoint.camera->subsector);
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ void RenderPolySprite::Render(PolyRenderThread *thread, AActor *thing, subsector
|
||||||
{
|
{
|
||||||
int spritenum = thing->sprite;
|
int spritenum = thing->sprite;
|
||||||
bool isPicnumOverride = thing->picnum.isValid();
|
bool isPicnumOverride = thing->picnum.isValid();
|
||||||
FSpriteModelFrame *modelframe = isPicnumOverride ? nullptr : gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
|
FSpriteModelFrame *modelframe = isPicnumOverride ? nullptr : FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
|
||||||
if (modelframe)
|
if (modelframe)
|
||||||
{
|
{
|
||||||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||||
|
|
|
@ -94,8 +94,8 @@ void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *s
|
||||||
|
|
||||||
if (smf->flags & MDL_ROTATING)
|
if (smf->flags & MDL_ROTATING)
|
||||||
{
|
{
|
||||||
const double time = smf->rotationSpeed*GetTimeFloat() / 200.;
|
double turns = (I_GetTime() % 200 + I_GetTimeFrac()) / 200.0;
|
||||||
rotateOffset = double((time - xs_FloorToInt(time)) *360.);
|
rotateOffset = turns * 360.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Added MDL_USEACTORPITCH and MDL_USEACTORROLL flags processing.
|
// Added MDL_USEACTORPITCH and MDL_USEACTORROLL flags processing.
|
||||||
|
@ -164,14 +164,14 @@ void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *s
|
||||||
objectToWorldMatrix.scale(1, stretch, 1);
|
objectToWorldMatrix.scale(1, stretch, 1);
|
||||||
|
|
||||||
BeginDrawModel(actor, smf, objectToWorldMatrix);
|
BeginDrawModel(actor, smf, objectToWorldMatrix);
|
||||||
RenderFrameModels(smf, actor->state, actor->tics, actor->GetClass(), nullptr, translation);
|
RenderFrameModels(smf, actor->state, actor->tics, actor->GetClass(), translation);
|
||||||
EndDrawModel(actor, smf);
|
EndDrawModel(actor, smf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY)
|
void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY)
|
||||||
{
|
{
|
||||||
AActor * playermo = players[consoleplayer].camera;
|
AActor * playermo = players[consoleplayer].camera;
|
||||||
FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false);
|
FSpriteModelFrame *smf = FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false);
|
||||||
|
|
||||||
// [BB] No model found for this sprite, so we can't render anything.
|
// [BB] No model found for this sprite, so we can't render anything.
|
||||||
if (smf == nullptr)
|
if (smf == nullptr)
|
||||||
|
@ -200,16 +200,11 @@ void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY)
|
||||||
objectToWorldMatrix.rotate(-smf->rolloffset, 1, 0, 0);
|
objectToWorldMatrix.rotate(-smf->rolloffset, 1, 0, 0);
|
||||||
|
|
||||||
BeginDrawHUDModel(playermo, objectToWorldMatrix);
|
BeginDrawHUDModel(playermo, objectToWorldMatrix);
|
||||||
RenderFrameModels(smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), nullptr, 0);
|
RenderFrameModels(smf, psp->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), 0);
|
||||||
EndDrawHUDModel(playermo);
|
EndDrawHUDModel(playermo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf,
|
void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf, const FState *curState, const int curTics, const PClass *ti, int translation)
|
||||||
const FState *curState,
|
|
||||||
const int curTics,
|
|
||||||
const PClass *ti,
|
|
||||||
Matrix3x4 *normaltransform,
|
|
||||||
int translation)
|
|
||||||
{
|
{
|
||||||
// [BB] Frame interpolation: Find the FSpriteModelFrame smfNext which follows after smf in the animation
|
// [BB] Frame interpolation: Find the FSpriteModelFrame smfNext which follows after smf in the animation
|
||||||
// and the scalar value inter ( element of [0,1) ), both necessary to determine the interpolated frame.
|
// and the scalar value inter ( element of [0,1) ), both necessary to determine the interpolated frame.
|
||||||
|
@ -225,14 +220,13 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf,
|
||||||
// [BB] In case the tic counter is frozen we have to leave ticFraction at zero.
|
// [BB] In case the tic counter is frozen we have to leave ticFraction at zero.
|
||||||
if (ConsoleState == c_up && menuactive != MENU_On && !(level.flags2 & LEVEL2_FROZEN))
|
if (ConsoleState == c_up && menuactive != MENU_On && !(level.flags2 & LEVEL2_FROZEN))
|
||||||
{
|
{
|
||||||
double time = GetTimeFloat();
|
ticFraction = I_GetTimeFrac();
|
||||||
ticFraction = (time - static_cast<int>(time));
|
|
||||||
}
|
}
|
||||||
inter = static_cast<double>(curState->Tics - curTics - ticFraction) / static_cast<double>(curState->Tics);
|
inter = static_cast<double>(curState->Tics - curTics + ticFraction) / static_cast<double>(curState->Tics);
|
||||||
|
|
||||||
// [BB] For some actors (e.g. ZPoisonShroom) spr->actor->tics can be bigger than curState->Tics.
|
// [BB] For some actors (e.g. ZPoisonShroom) spr->actor->tics can be bigger than curState->Tics.
|
||||||
// In this case inter is negative and we need to set it to zero.
|
// In this case inter is negative and we need to set it to zero.
|
||||||
if (inter < 0.)
|
if (curState->Tics < curTics)
|
||||||
inter = 0.;
|
inter = 0.;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -253,7 +247,7 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inter != 0.0)
|
if (inter != 0.0)
|
||||||
smfNext = gl_FindModelFrame(ti, nextState->sprite, nextState->Frame, false);
|
smfNext = FindModelFrame(ti, nextState->sprite, nextState->Frame, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +259,7 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf,
|
||||||
FModel * mdl = Models[smf->modelIDs[i]];
|
FModel * mdl = Models[smf->modelIDs[i]];
|
||||||
FTexture *tex = smf->skinIDs[i].isValid() ? TexMan(smf->skinIDs[i]) : nullptr;
|
FTexture *tex = smf->skinIDs[i].isValid() ? TexMan(smf->skinIDs[i]) : nullptr;
|
||||||
mdl->BuildVertexBuffer(this);
|
mdl->BuildVertexBuffer(this);
|
||||||
SetVertexBuffer(mdl->mVBuf);
|
SetVertexBuffer(mdl->GetVertexBuffer(this));
|
||||||
|
|
||||||
mdl->PushSpriteMDLFrame(smf, i);
|
mdl->PushSpriteMDLFrame(smf, i);
|
||||||
|
|
||||||
|
@ -279,24 +273,9 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double FModelRenderer::GetTimeFloat()
|
|
||||||
{
|
|
||||||
return (double)I_msTime() * (double)TICRATE / 1000.;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void gl_LoadModels()
|
void FlushModels()
|
||||||
{
|
|
||||||
/*
|
|
||||||
for (int i = Models.Size() - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
Models[i]->BuildVertexBuffer();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void gl_FlushModels()
|
|
||||||
{
|
{
|
||||||
for (int i = Models.Size() - 1; i >= 0; i--)
|
for (int i = Models.Size() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
@ -306,9 +285,24 @@ void gl_FlushModels()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
FModel::FModel()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < NumModelRendererTypes; i++)
|
||||||
|
mVBuf[i] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
FModel::~FModel()
|
FModel::~FModel()
|
||||||
{
|
{
|
||||||
if (mVBuf != nullptr) delete mVBuf;
|
DestroyVertexBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FModel::DestroyVertexBuffer()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < NumModelRendererTypes; i++)
|
||||||
|
{
|
||||||
|
delete mVBuf[i];
|
||||||
|
mVBuf[i] = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static TArray<FSpriteModelFrame> SpriteModelFrames;
|
static TArray<FSpriteModelFrame> SpriteModelFrames;
|
||||||
|
@ -475,22 +469,15 @@ static unsigned FindModel(const char * path, const char * modelfile)
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// gl_InitModels
|
// InitModels
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
void gl_InitModels()
|
static void ParseModelDefLump(int Lump);
|
||||||
|
|
||||||
|
void InitModels()
|
||||||
{
|
{
|
||||||
int Lump, lastLump;
|
for (unsigned i = 0; i < Models.Size(); i++)
|
||||||
FString path;
|
|
||||||
int index, surface;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
FSpriteModelFrame smf;
|
|
||||||
|
|
||||||
lastLump = 0;
|
|
||||||
|
|
||||||
for(unsigned i=0;i<Models.Size();i++)
|
|
||||||
{
|
{
|
||||||
delete Models[i];
|
delete Models[i];
|
||||||
}
|
}
|
||||||
|
@ -508,6 +495,7 @@ void gl_InitModels()
|
||||||
for (unsigned i = 0; i < VoxelDefs.Size(); i++)
|
for (unsigned i = 0; i < VoxelDefs.Size(); i++)
|
||||||
{
|
{
|
||||||
FVoxelModel *md = (FVoxelModel*)Models[VoxelDefs[i]->Voxel->VoxelIndex];
|
FVoxelModel *md = (FVoxelModel*)Models[VoxelDefs[i]->Voxel->VoxelIndex];
|
||||||
|
FSpriteModelFrame smf;
|
||||||
memset(&smf, 0, sizeof(smf));
|
memset(&smf, 0, sizeof(smf));
|
||||||
smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1;
|
smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1;
|
||||||
smf.modelIDs[0] = VoxelDefs[i]->Voxel->VoxelIndex;
|
smf.modelIDs[0] = VoxelDefs[i]->Voxel->VoxelIndex;
|
||||||
|
@ -539,17 +527,39 @@ void gl_InitModels()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&smf, 0, sizeof(smf));
|
int Lump;
|
||||||
smf.modelIDs[0] = smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1;
|
int lastLump = 0;
|
||||||
while ((Lump = Wads.FindLump("MODELDEF", &lastLump)) != -1)
|
while ((Lump = Wads.FindLump("MODELDEF", &lastLump)) != -1)
|
||||||
{
|
{
|
||||||
|
ParseModelDefLump(Lump);
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a hash table for quick access
|
||||||
|
SpriteModelHash = new int[SpriteModelFrames.Size ()];
|
||||||
|
atterm(DeleteModelHash);
|
||||||
|
memset(SpriteModelHash, 0xff, SpriteModelFrames.Size () * sizeof(int));
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < SpriteModelFrames.Size (); i++)
|
||||||
|
{
|
||||||
|
int j = ModelFrameHash(&SpriteModelFrames[i]) % SpriteModelFrames.Size ();
|
||||||
|
|
||||||
|
SpriteModelFrames[i].hashnext = SpriteModelHash[j];
|
||||||
|
SpriteModelHash[j]=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ParseModelDefLump(int Lump)
|
||||||
|
{
|
||||||
FScanner sc(Lump);
|
FScanner sc(Lump);
|
||||||
while (sc.GetString())
|
while (sc.GetString())
|
||||||
{
|
{
|
||||||
if (sc.Compare("model"))
|
if (sc.Compare("model"))
|
||||||
{
|
{
|
||||||
path = "";
|
int index, surface;
|
||||||
|
FString path = "";
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
|
|
||||||
|
FSpriteModelFrame smf;
|
||||||
memset(&smf, 0, sizeof(smf));
|
memset(&smf, 0, sizeof(smf));
|
||||||
smf.modelIDs[0] = smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1;
|
smf.modelIDs[0] = smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1;
|
||||||
smf.xscale=smf.yscale=smf.zscale=1.f;
|
smf.xscale=smf.yscale=smf.zscale=1.f;
|
||||||
|
@ -758,7 +768,7 @@ void gl_InitModels()
|
||||||
|
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
smf.sprite = -1;
|
smf.sprite = -1;
|
||||||
for (i = 0; i < (int)sprites.Size (); ++i)
|
for (int i = 0; i < (int)sprites.Size (); ++i)
|
||||||
{
|
{
|
||||||
if (strnicmp (sprites[i].name, sc.String, 4) == 0)
|
if (strnicmp (sprites[i].name, sc.String, 4) == 0)
|
||||||
{
|
{
|
||||||
|
@ -801,7 +811,7 @@ void gl_InitModels()
|
||||||
smf.modelframes[index] = sc.Number;
|
smf.modelframes[index] = sc.Number;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; framechars[i]>0; i++)
|
for(int i=0; framechars[i]>0; i++)
|
||||||
{
|
{
|
||||||
char map[29]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
char map[29]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||||
int c = toupper(framechars[i])-'A';
|
int c = toupper(framechars[i])-'A';
|
||||||
|
@ -834,30 +844,27 @@ void gl_InitModels()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// This code is commented out because Gene Tech has broken include statements that blocks this feature..
|
||||||
}
|
/*else if (sc.Compare("#include"))
|
||||||
|
|
||||||
// create a hash table for quick access
|
|
||||||
SpriteModelHash = new int[SpriteModelFrames.Size ()];
|
|
||||||
atterm(DeleteModelHash);
|
|
||||||
memset(SpriteModelHash, 0xff, SpriteModelFrames.Size () * sizeof(int));
|
|
||||||
|
|
||||||
for (i = 0; i < (int)SpriteModelFrames.Size (); i++)
|
|
||||||
{
|
{
|
||||||
int j = ModelFrameHash(&SpriteModelFrames[i]) % SpriteModelFrames.Size ();
|
sc.MustGetString();
|
||||||
|
// This is not using sc.Open because it can print a more useful error message when done here
|
||||||
SpriteModelFrames[i].hashnext = SpriteModelHash[j];
|
int includelump = Wads.CheckNumForFullName(sc.String, true);
|
||||||
SpriteModelHash[j]=i;
|
if (includelump == -1)
|
||||||
|
sc.ScriptError("Lump '%s' not found", sc.String);
|
||||||
|
else
|
||||||
|
ParseModelDefLump(includelump);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// gl_FindModelFrame
|
// FindModelFrame
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped)
|
FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped)
|
||||||
{
|
{
|
||||||
if (GetDefaultByType(ti)->hasmodel)
|
if (GetDefaultByType(ti)->hasmodel)
|
||||||
{
|
{
|
||||||
|
@ -898,11 +905,11 @@ FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame,
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// gl_IsHUDModelForPlayerAvailable
|
// IsHUDModelForPlayerAvailable
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
bool gl_IsHUDModelForPlayerAvailable (player_t * player)
|
bool IsHUDModelForPlayerAvailable (player_t * player)
|
||||||
{
|
{
|
||||||
if (player == nullptr || player->ReadyWeapon == nullptr)
|
if (player == nullptr || player->ReadyWeapon == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -913,7 +920,7 @@ bool gl_IsHUDModelForPlayerAvailable (player_t * player)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FState* state = psp->GetState();
|
FState* state = psp->GetState();
|
||||||
FSpriteModelFrame *smf = gl_FindModelFrame(player->ReadyWeapon->GetClass(), state->sprite, state->GetFrame(), false);
|
FSpriteModelFrame *smf = FindModelFrame(player->ReadyWeapon->GetClass(), state->sprite, state->GetFrame(), false);
|
||||||
return ( smf != nullptr );
|
return ( smf != nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,14 @@ FTextureID LoadSkin(const char * path, const char * fn);
|
||||||
struct FSpriteModelFrame;
|
struct FSpriteModelFrame;
|
||||||
class IModelVertexBuffer;
|
class IModelVertexBuffer;
|
||||||
|
|
||||||
|
enum ModelRendererType
|
||||||
|
{
|
||||||
|
GLModelRendererType,
|
||||||
|
SWModelRendererType,
|
||||||
|
PolyModelRendererType,
|
||||||
|
NumModelRendererTypes
|
||||||
|
};
|
||||||
|
|
||||||
class FModelRenderer
|
class FModelRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -54,6 +62,8 @@ public:
|
||||||
void RenderModel(float x, float y, float z, FSpriteModelFrame *modelframe, AActor *actor);
|
void RenderModel(float x, float y, float z, FSpriteModelFrame *modelframe, AActor *actor);
|
||||||
void RenderHUDModel(DPSprite *psp, float ofsx, float ofsy);
|
void RenderHUDModel(DPSprite *psp, float ofsx, float ofsy);
|
||||||
|
|
||||||
|
virtual ModelRendererType GetType() const = 0;
|
||||||
|
|
||||||
virtual void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) = 0;
|
virtual void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) = 0;
|
||||||
virtual void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) = 0;
|
virtual void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) = 0;
|
||||||
|
|
||||||
|
@ -73,8 +83,7 @@ public:
|
||||||
virtual void DrawElements(int numIndices, size_t offset) = 0;
|
virtual void DrawElements(int numIndices, size_t offset) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RenderFrameModels(const FSpriteModelFrame *smf, const FState *curState, const int curTics, const PClass *ti, Matrix3x4 *normaltransform, int translation);
|
void RenderFrameModels(const FSpriteModelFrame *smf, const FState *curState, const int curTics, const PClass *ti, int translation);
|
||||||
static double GetTimeFloat();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FModelVertex
|
struct FModelVertex
|
||||||
|
@ -123,11 +132,7 @@ public:
|
||||||
class FModel
|
class FModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
FModel();
|
||||||
FModel()
|
|
||||||
{
|
|
||||||
mVBuf = NULL;
|
|
||||||
}
|
|
||||||
virtual ~FModel();
|
virtual ~FModel();
|
||||||
|
|
||||||
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0;
|
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0;
|
||||||
|
@ -135,19 +140,20 @@ public:
|
||||||
virtual void RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0;
|
virtual void RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0;
|
||||||
virtual void BuildVertexBuffer(FModelRenderer *renderer) = 0;
|
virtual void BuildVertexBuffer(FModelRenderer *renderer) = 0;
|
||||||
virtual void AddSkins(uint8_t *hitlist) = 0;
|
virtual void AddSkins(uint8_t *hitlist) = 0;
|
||||||
void DestroyVertexBuffer()
|
|
||||||
{
|
|
||||||
delete mVBuf;
|
|
||||||
mVBuf = NULL;
|
|
||||||
}
|
|
||||||
virtual float getAspectFactor() { return 1.f; }
|
virtual float getAspectFactor() { return 1.f; }
|
||||||
|
|
||||||
|
void SetVertexBuffer(FModelRenderer *renderer, IModelVertexBuffer *buffer) { mVBuf[renderer->GetType()] = buffer; }
|
||||||
|
IModelVertexBuffer *GetVertexBuffer(FModelRenderer *renderer) const { return mVBuf[renderer->GetType()]; }
|
||||||
|
void DestroyVertexBuffer();
|
||||||
|
|
||||||
const FSpriteModelFrame *curSpriteMDLFrame;
|
const FSpriteModelFrame *curSpriteMDLFrame;
|
||||||
int curMDLIndex;
|
int curMDLIndex;
|
||||||
void PushSpriteMDLFrame(const FSpriteModelFrame *smf, int index) { curSpriteMDLFrame = smf; curMDLIndex = index; };
|
void PushSpriteMDLFrame(const FSpriteModelFrame *smf, int index) { curSpriteMDLFrame = smf; curMDLIndex = index; };
|
||||||
|
|
||||||
IModelVertexBuffer *mVBuf;
|
|
||||||
FString mFileName;
|
FString mFileName;
|
||||||
|
|
||||||
|
private:
|
||||||
|
IModelVertexBuffer *mVBuf[NumModelRendererTypes];
|
||||||
};
|
};
|
||||||
|
|
||||||
class FDMDModel : public FModel
|
class FDMDModel : public FModel
|
||||||
|
@ -473,9 +479,9 @@ struct FSpriteModelFrame
|
||||||
float pitchoffset, rolloffset; // I don't want to bother with type transformations, so I made this variables float.
|
float pitchoffset, rolloffset; // I don't want to bother with type transformations, so I made this variables float.
|
||||||
};
|
};
|
||||||
|
|
||||||
FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped);
|
FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped);
|
||||||
|
bool IsHUDModelForPlayerAvailable(player_t * player);
|
||||||
bool gl_IsHUDModelForPlayerAvailable (player_t * player);
|
void FlushModels();
|
||||||
|
|
||||||
class DeletingModelArray : public TArray<FModel *>
|
class DeletingModelArray : public TArray<FModel *>
|
||||||
{
|
{
|
||||||
|
|
|
@ -279,15 +279,17 @@ FDMDModel::~FDMDModel()
|
||||||
|
|
||||||
void FDMDModel::BuildVertexBuffer(FModelRenderer *renderer)
|
void FDMDModel::BuildVertexBuffer(FModelRenderer *renderer)
|
||||||
{
|
{
|
||||||
if (mVBuf == NULL)
|
if (!GetVertexBuffer(renderer))
|
||||||
{
|
{
|
||||||
LoadGeometry();
|
LoadGeometry();
|
||||||
|
|
||||||
int VertexBufferSize = info.numFrames * lodInfo[0].numTriangles * 3;
|
int VertexBufferSize = info.numFrames * lodInfo[0].numTriangles * 3;
|
||||||
unsigned int vindex = 0;
|
unsigned int vindex = 0;
|
||||||
|
|
||||||
mVBuf = renderer->CreateVertexBuffer(false, info.numFrames == 1);
|
auto vbuf = renderer->CreateVertexBuffer(false, info.numFrames == 1);
|
||||||
FModelVertex *vertptr = mVBuf->LockVertexBuffer(VertexBufferSize);
|
SetVertexBuffer(renderer, vbuf);
|
||||||
|
|
||||||
|
FModelVertex *vertptr = vbuf->LockVertexBuffer(VertexBufferSize);
|
||||||
|
|
||||||
for (int i = 0; i < info.numFrames; i++)
|
for (int i = 0; i < info.numFrames; i++)
|
||||||
{
|
{
|
||||||
|
@ -313,7 +315,7 @@ void FDMDModel::BuildVertexBuffer(FModelRenderer *renderer)
|
||||||
tri++;
|
tri++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mVBuf->UnlockVertexBuffer();
|
vbuf->UnlockVertexBuffer();
|
||||||
UnloadGeometry();
|
UnloadGeometry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,7 +370,7 @@ void FDMDModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
|
||||||
|
|
||||||
renderer->SetInterpolation(inter);
|
renderer->SetInterpolation(inter);
|
||||||
renderer->SetMaterial(skin, false, translation);
|
renderer->SetMaterial(skin, false, translation);
|
||||||
mVBuf->SetupFrame(renderer, frames[frameno].vindex, frames[frameno2].vindex, lodInfo[0].numTriangles * 3);
|
GetVertexBuffer(renderer)->SetupFrame(renderer, frames[frameno].vindex, frames[frameno2].vindex, lodInfo[0].numTriangles * 3);
|
||||||
renderer->DrawArrays(0, lodInfo[0].numTriangles * 3);
|
renderer->DrawArrays(0, lodInfo[0].numTriangles * 3);
|
||||||
renderer->SetInterpolation(0.f);
|
renderer->SetInterpolation(0.f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ void FMD3Model::LoadGeometry()
|
||||||
|
|
||||||
void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer)
|
void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer)
|
||||||
{
|
{
|
||||||
if (mVBuf == nullptr)
|
if (!GetVertexBuffer(renderer))
|
||||||
{
|
{
|
||||||
LoadGeometry();
|
LoadGeometry();
|
||||||
|
|
||||||
|
@ -251,9 +251,11 @@ void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer)
|
||||||
ibufsize += 3 * surf->numTriangles;
|
ibufsize += 3 * surf->numTriangles;
|
||||||
}
|
}
|
||||||
|
|
||||||
mVBuf = renderer->CreateVertexBuffer(true, numFrames == 1);
|
auto vbuf = renderer->CreateVertexBuffer(true, numFrames == 1);
|
||||||
FModelVertex *vertptr = mVBuf->LockVertexBuffer(vbufsize);
|
SetVertexBuffer(renderer, vbuf);
|
||||||
unsigned int *indxptr = mVBuf->LockIndexBuffer(ibufsize);
|
|
||||||
|
FModelVertex *vertptr = vbuf->LockVertexBuffer(vbufsize);
|
||||||
|
unsigned int *indxptr = vbuf->LockIndexBuffer(ibufsize);
|
||||||
|
|
||||||
assert(vertptr != nullptr && indxptr != nullptr);
|
assert(vertptr != nullptr && indxptr != nullptr);
|
||||||
|
|
||||||
|
@ -285,8 +287,8 @@ void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer)
|
||||||
}
|
}
|
||||||
surf->UnloadGeometry();
|
surf->UnloadGeometry();
|
||||||
}
|
}
|
||||||
mVBuf->UnlockVertexBuffer();
|
vbuf->UnlockVertexBuffer();
|
||||||
mVBuf->UnlockIndexBuffer();
|
vbuf->UnlockIndexBuffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +367,7 @@ void FMD3Model::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer->SetMaterial(surfaceSkin, false, translation);
|
renderer->SetMaterial(surfaceSkin, false, translation);
|
||||||
mVBuf->SetupFrame(renderer, surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, surf->numVertices);
|
GetVertexBuffer(renderer)->SetupFrame(renderer, surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, surf->numVertices);
|
||||||
renderer->DrawElements(surf->numTriangles * 3, surf->iindex * sizeof(unsigned int));
|
renderer->DrawElements(surf->numTriangles * 3, surf->iindex * sizeof(unsigned int));
|
||||||
}
|
}
|
||||||
renderer->SetInterpolation(0.f);
|
renderer->SetInterpolation(0.f);
|
||||||
|
|
|
@ -198,7 +198,7 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
renderer->SetMaterial(sskin,false,translation);
|
renderer->SetMaterial(sskin,false,translation);
|
||||||
mVBuf->SetupFrame(renderer,vofs+frame*fsize,vofs+frame2*fsize,vsize);
|
GetVertexBuffer(renderer)->SetupFrame(renderer,vofs+frame*fsize,vofs+frame2*fsize,vsize);
|
||||||
renderer->DrawArrays(0,vsize);
|
renderer->DrawArrays(0,vsize);
|
||||||
vofs += vsize;
|
vofs += vsize;
|
||||||
}
|
}
|
||||||
|
@ -207,14 +207,15 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame
|
||||||
|
|
||||||
void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer )
|
void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer )
|
||||||
{
|
{
|
||||||
if ( mVBuf != NULL )
|
if (GetVertexBuffer(renderer))
|
||||||
return;
|
return;
|
||||||
int vsize = 0;
|
int vsize = 0;
|
||||||
for ( int i=0; i<numGroups; i++ )
|
for ( int i=0; i<numGroups; i++ )
|
||||||
vsize += groups[i].numPolys*3;
|
vsize += groups[i].numPolys*3;
|
||||||
vsize *= numFrames;
|
vsize *= numFrames;
|
||||||
mVBuf = renderer->CreateVertexBuffer(false,numFrames==1);
|
auto vbuf = renderer->CreateVertexBuffer(false,numFrames==1);
|
||||||
FModelVertex *vptr = mVBuf->LockVertexBuffer(vsize);
|
SetVertexBuffer(renderer, vbuf);
|
||||||
|
FModelVertex *vptr = vbuf->LockVertexBuffer(vsize);
|
||||||
int vidx = 0;
|
int vidx = 0;
|
||||||
for ( int i=0; i<numFrames; i++ )
|
for ( int i=0; i<numFrames; i++ )
|
||||||
{
|
{
|
||||||
|
@ -233,7 +234,7 @@ void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mVBuf->UnlockVertexBuffer();
|
vbuf->UnlockVertexBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FUE1Model::AddSkins( uint8_t *hitlist )
|
void FUE1Model::AddSkins( uint8_t *hitlist )
|
||||||
|
|
|
@ -321,19 +321,21 @@ void FVoxelModel::Initialize()
|
||||||
|
|
||||||
void FVoxelModel::BuildVertexBuffer(FModelRenderer *renderer)
|
void FVoxelModel::BuildVertexBuffer(FModelRenderer *renderer)
|
||||||
{
|
{
|
||||||
if (mVBuf == NULL)
|
if (!GetVertexBuffer(renderer))
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
||||||
mVBuf = renderer->CreateVertexBuffer(true, true);
|
auto vbuf = renderer->CreateVertexBuffer(true, true);
|
||||||
FModelVertex *vertptr = mVBuf->LockVertexBuffer(mVertices.Size());
|
SetVertexBuffer(renderer, vbuf);
|
||||||
unsigned int *indxptr = mVBuf->LockIndexBuffer(mIndices.Size());
|
|
||||||
|
FModelVertex *vertptr = vbuf->LockVertexBuffer(mVertices.Size());
|
||||||
|
unsigned int *indxptr = vbuf->LockIndexBuffer(mIndices.Size());
|
||||||
|
|
||||||
memcpy(vertptr, &mVertices[0], sizeof(FModelVertex)* mVertices.Size());
|
memcpy(vertptr, &mVertices[0], sizeof(FModelVertex)* mVertices.Size());
|
||||||
memcpy(indxptr, &mIndices[0], sizeof(unsigned int)* mIndices.Size());
|
memcpy(indxptr, &mIndices[0], sizeof(unsigned int)* mIndices.Size());
|
||||||
|
|
||||||
mVBuf->UnlockVertexBuffer();
|
vbuf->UnlockVertexBuffer();
|
||||||
mVBuf->UnlockIndexBuffer();
|
vbuf->UnlockIndexBuffer();
|
||||||
mNumIndices = mIndices.Size();
|
mNumIndices = mIndices.Size();
|
||||||
|
|
||||||
// delete our temporary buffers
|
// delete our temporary buffers
|
||||||
|
@ -398,7 +400,7 @@ float FVoxelModel::getAspectFactor()
|
||||||
void FVoxelModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation)
|
void FVoxelModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation)
|
||||||
{
|
{
|
||||||
renderer->SetMaterial(skin, true, translation);
|
renderer->SetMaterial(skin, true, translation);
|
||||||
mVBuf->SetupFrame(renderer, 0, 0, 0);
|
GetVertexBuffer(renderer)->SetupFrame(renderer, 0, 0, 0);
|
||||||
renderer->DrawElements(mNumIndices, 0);
|
renderer->DrawElements(mNumIndices, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include "r_data/voxels.h"
|
#include "r_data/voxels.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
||||||
void gl_InitModels();
|
void InitModels();
|
||||||
|
|
||||||
// variables used to look up
|
// variables used to look up
|
||||||
// and range check thing_t sprites patches
|
// and range check thing_t sprites patches
|
||||||
|
@ -1048,7 +1048,7 @@ void R_InitSprites ()
|
||||||
// [RH] Sort the skins, but leave base as skin 0
|
// [RH] Sort the skins, but leave base as skin 0
|
||||||
//qsort (&skins[PlayerClasses.Size ()], numskins-PlayerClasses.Size (), sizeof(FPlayerSkin), skinsorter);
|
//qsort (&skins[PlayerClasses.Size ()], numskins-PlayerClasses.Size (), sizeof(FPlayerSkin), skinsorter);
|
||||||
|
|
||||||
gl_InitModels();
|
InitModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -962,7 +962,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
int spritenum = thing->sprite;
|
int spritenum = thing->sprite;
|
||||||
bool isPicnumOverride = thing->picnum.isValid();
|
bool isPicnumOverride = thing->picnum.isValid();
|
||||||
FSpriteModelFrame *modelframe = isPicnumOverride ? nullptr : gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
|
FSpriteModelFrame *modelframe = isPicnumOverride ? nullptr : FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
|
||||||
if (modelframe && (thing->Pos() - Thread->Viewport->viewpoint.Pos).LengthSquared() < model_distance_cull)
|
if (modelframe && (thing->Pos() - Thread->Viewport->viewpoint.Pos).LengthSquared() < model_distance_cull)
|
||||||
{
|
{
|
||||||
DVector3 pos = thing->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
|
DVector3 pos = thing->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
|
||||||
|
|
|
@ -34,9 +34,6 @@
|
||||||
#include "swrenderer/viewport/r_viewport.h"
|
#include "swrenderer/viewport/r_viewport.h"
|
||||||
#include "swrenderer/scene/r_light.h"
|
#include "swrenderer/scene/r_light.h"
|
||||||
|
|
||||||
void gl_FlushModels();
|
|
||||||
extern bool polymodelsInUse;
|
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
void RenderModel::Project(RenderThread *thread, float x, float y, float z, FSpriteModelFrame *smf, AActor *actor)
|
void RenderModel::Project(RenderThread *thread, float x, float y, float z, FSpriteModelFrame *smf, AActor *actor)
|
||||||
|
@ -83,11 +80,6 @@ namespace swrenderer
|
||||||
|
|
||||||
SWModelRenderer::SWModelRenderer(RenderThread *thread, Fake3DTranslucent clip3DFloor) : Thread(thread), Clip3DFloor(clip3DFloor)
|
SWModelRenderer::SWModelRenderer(RenderThread *thread, Fake3DTranslucent clip3DFloor) : Thread(thread), Clip3DFloor(clip3DFloor)
|
||||||
{
|
{
|
||||||
if (polymodelsInUse)
|
|
||||||
{
|
|
||||||
gl_FlushModels();
|
|
||||||
polymodelsInUse = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SWModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix)
|
void SWModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix)
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace swrenderer
|
||||||
public:
|
public:
|
||||||
SWModelRenderer(RenderThread *thread, Fake3DTranslucent clip3DFloor);
|
SWModelRenderer(RenderThread *thread, Fake3DTranslucent clip3DFloor);
|
||||||
|
|
||||||
|
ModelRendererType GetType() const override { return SWModelRendererType; }
|
||||||
|
|
||||||
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) override;
|
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) override;
|
||||||
void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
|
void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
|
||||||
IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) override;
|
IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) override;
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace swrenderer
|
||||||
(r_deathcamera && Thread->Viewport->viewpoint.camera->health <= 0))
|
(r_deathcamera && Thread->Viewport->viewpoint.camera->health <= 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
renderHUDModel = r_models && gl_IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
renderHUDModel = r_models && IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
||||||
|
|
||||||
FDynamicColormap *basecolormap;
|
FDynamicColormap *basecolormap;
|
||||||
CameraLight *cameraLight = CameraLight::Instance();
|
CameraLight *cameraLight = CameraLight::Instance();
|
||||||
|
|
Loading…
Reference in a new issue