mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
- avoid reusing the same mVBuf pointer for the different renderers as that causes too many problems when switching between them
- remove gl_ prefix for model functions that are no longer GL specific
This commit is contained in:
parent
cc4a09a3d2
commit
31abe3df7e
20 changed files with 94 additions and 90 deletions
|
@ -36,6 +36,7 @@ class FGLModelRenderer : public FModelRenderer
|
|||
public:
|
||||
FGLModelRenderer(int mli) : modellightindex(mli)
|
||||
{}
|
||||
ModelRendererType GetType() const override { return GLModelRendererType; }
|
||||
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) override;
|
||||
void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
|
||||
IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) override;
|
||||
|
|
|
@ -121,9 +121,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
|||
mCustomPostProcessShaders = nullptr;
|
||||
}
|
||||
|
||||
void gl_LoadModels();
|
||||
void gl_FlushModels();
|
||||
|
||||
void FGLRenderer::Initialize(int width, int height)
|
||||
{
|
||||
mBuffers = new FGLRenderBuffers();
|
||||
|
@ -175,7 +172,6 @@ void FGLRenderer::Initialize(int width, int height)
|
|||
SetupLevel();
|
||||
mShaderManager = new FShaderManager;
|
||||
mSamplerManager = new FSamplerManager;
|
||||
gl_LoadModels();
|
||||
|
||||
GLPortal::Initialize();
|
||||
}
|
||||
|
@ -184,7 +180,7 @@ FGLRenderer::~FGLRenderer()
|
|||
{
|
||||
GLPortal::Shutdown();
|
||||
|
||||
gl_FlushModels();
|
||||
FlushModels();
|
||||
AActor::DeleteAllAttachedLights();
|
||||
FMaterial::FlushAll();
|
||||
if (legacyShaders) delete legacyShaders;
|
||||
|
|
|
@ -510,7 +510,7 @@ void GLSceneDrawer::EndDrawScene(sector_t * viewsector)
|
|||
gl_RenderState.EnableFog(false);
|
||||
|
||||
// [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 )
|
||||
{
|
||||
// [BB] The HUD model should be drawn over everything else already drawn.
|
||||
|
@ -539,7 +539,7 @@ void GLSceneDrawer::EndDrawScene(sector_t * viewsector)
|
|||
|
||||
void GLSceneDrawer::DrawEndScene2D(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.
|
||||
gl_RenderState.mViewMatrix.loadIdentity();
|
||||
|
|
|
@ -448,7 +448,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
// exclude vertically moving objects from this check.
|
||||
if (!thing->Vel.isZero())
|
||||
{
|
||||
if (!gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, false))
|
||||
if (!FindModelFrame(thing->GetClass(), spritenum, thing->frame, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
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)
|
||||
{
|
||||
bool mirror;
|
||||
|
|
|
@ -425,7 +425,7 @@ 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);
|
||||
const bool hudModelStep = IsHUDModelForPlayerAvailable(player);
|
||||
|
||||
AActor *camera = r_viewpoint.camera;
|
||||
|
||||
|
@ -448,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())
|
||||
{
|
||||
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.
|
||||
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];
|
||||
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)
|
||||
{
|
||||
for (int i = 0; i < MAX_MODELS_PER_FRAME; i++)
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
#include "actorinlines.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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!polymodelsInUse)
|
||||
{
|
||||
gl_FlushModels();
|
||||
polymodelsInUse = true;
|
||||
}
|
||||
}
|
||||
|
||||
void PolyModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix)
|
||||
|
|
|
@ -34,6 +34,8 @@ class PolyModelRenderer : public FModelRenderer
|
|||
public:
|
||||
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 EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
|
||||
IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) override;
|
||||
|
|
|
@ -60,7 +60,7 @@ void RenderPolyPlayerSprites::Render(PolyRenderThread *thread)
|
|||
(r_deathcamera && viewpoint.camera->health <= 0))
|
||||
return;
|
||||
|
||||
renderHUDModel = r_models && gl_IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
||||
renderHUDModel = r_models && IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
||||
|
||||
PolyTransferHeights fakeflat(viewpoint.camera->subsector);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ void RenderPolySprite::Render(PolyRenderThread *thread, AActor *thing, subsector
|
|||
{
|
||||
int spritenum = thing->sprite;
|
||||
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)
|
||||
{
|
||||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
|
|
|
@ -171,7 +171,7 @@ void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *s
|
|||
void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY)
|
||||
{
|
||||
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.
|
||||
if (smf == nullptr)
|
||||
|
@ -247,7 +247,7 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf, const FStat
|
|||
}
|
||||
}
|
||||
if (inter != 0.0)
|
||||
smfNext = gl_FindModelFrame(ti, nextState->sprite, nextState->Frame, false);
|
||||
smfNext = FindModelFrame(ti, nextState->sprite, nextState->Frame, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf, const FStat
|
|||
FModel * mdl = Models[smf->modelIDs[i]];
|
||||
FTexture *tex = smf->skinIDs[i].isValid() ? TexMan(smf->skinIDs[i]) : nullptr;
|
||||
mdl->BuildVertexBuffer(this);
|
||||
SetVertexBuffer(mdl->mVBuf);
|
||||
SetVertexBuffer(mdl->GetVertexBuffer(this));
|
||||
|
||||
mdl->PushSpriteMDLFrame(smf, i);
|
||||
|
||||
|
@ -275,17 +275,7 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf, const FStat
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void gl_LoadModels()
|
||||
{
|
||||
/*
|
||||
for (int i = Models.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
Models[i]->BuildVertexBuffer();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void gl_FlushModels()
|
||||
void FlushModels()
|
||||
{
|
||||
for (int i = Models.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
|
@ -295,9 +285,24 @@ void gl_FlushModels()
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FModel::FModel()
|
||||
{
|
||||
for (int i = 0; i < NumModelRendererTypes; i++)
|
||||
mVBuf[i] = nullptr;
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -842,11 +847,11 @@ void gl_InitModels()
|
|||
|
||||
//===========================================================================
|
||||
//
|
||||
// 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)
|
||||
{
|
||||
|
@ -887,11 +892,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)
|
||||
return false;
|
||||
|
@ -902,7 +907,7 @@ bool gl_IsHUDModelForPlayerAvailable (player_t * player)
|
|||
return false;
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,14 @@ FTextureID LoadSkin(const char * path, const char * fn);
|
|||
struct FSpriteModelFrame;
|
||||
class IModelVertexBuffer;
|
||||
|
||||
enum ModelRendererType
|
||||
{
|
||||
GLModelRendererType,
|
||||
SWModelRendererType,
|
||||
PolyModelRendererType,
|
||||
NumModelRendererTypes
|
||||
};
|
||||
|
||||
class FModelRenderer
|
||||
{
|
||||
public:
|
||||
|
@ -54,6 +62,8 @@ public:
|
|||
void RenderModel(float x, float y, float z, FSpriteModelFrame *modelframe, AActor *actor);
|
||||
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 EndDrawModel(AActor *actor, FSpriteModelFrame *smf) = 0;
|
||||
|
||||
|
@ -122,11 +132,7 @@ public:
|
|||
class FModel
|
||||
{
|
||||
public:
|
||||
|
||||
FModel()
|
||||
{
|
||||
mVBuf = NULL;
|
||||
}
|
||||
FModel();
|
||||
virtual ~FModel();
|
||||
|
||||
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0;
|
||||
|
@ -134,19 +140,20 @@ public:
|
|||
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 AddSkins(uint8_t *hitlist) = 0;
|
||||
void DestroyVertexBuffer()
|
||||
{
|
||||
delete mVBuf;
|
||||
mVBuf = NULL;
|
||||
}
|
||||
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;
|
||||
int curMDLIndex;
|
||||
void PushSpriteMDLFrame(const FSpriteModelFrame *smf, int index) { curSpriteMDLFrame = smf; curMDLIndex = index; };
|
||||
|
||||
IModelVertexBuffer *mVBuf;
|
||||
FString mFileName;
|
||||
|
||||
private:
|
||||
IModelVertexBuffer *mVBuf[NumModelRendererTypes];
|
||||
};
|
||||
|
||||
class FDMDModel : public FModel
|
||||
|
@ -472,9 +479,9 @@ struct FSpriteModelFrame
|
|||
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);
|
||||
|
||||
bool gl_IsHUDModelForPlayerAvailable (player_t * player);
|
||||
FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped);
|
||||
bool IsHUDModelForPlayerAvailable(player_t * player);
|
||||
void FlushModels();
|
||||
|
||||
class DeletingModelArray : public TArray<FModel *>
|
||||
{
|
||||
|
|
|
@ -279,15 +279,17 @@ FDMDModel::~FDMDModel()
|
|||
|
||||
void FDMDModel::BuildVertexBuffer(FModelRenderer *renderer)
|
||||
{
|
||||
if (mVBuf == NULL)
|
||||
if (!GetVertexBuffer(renderer))
|
||||
{
|
||||
LoadGeometry();
|
||||
|
||||
int VertexBufferSize = info.numFrames * lodInfo[0].numTriangles * 3;
|
||||
unsigned int vindex = 0;
|
||||
|
||||
mVBuf = renderer->CreateVertexBuffer(false, info.numFrames == 1);
|
||||
FModelVertex *vertptr = mVBuf->LockVertexBuffer(VertexBufferSize);
|
||||
auto vbuf = renderer->CreateVertexBuffer(false, info.numFrames == 1);
|
||||
SetVertexBuffer(renderer, vbuf);
|
||||
|
||||
FModelVertex *vertptr = vbuf->LockVertexBuffer(VertexBufferSize);
|
||||
|
||||
for (int i = 0; i < info.numFrames; i++)
|
||||
{
|
||||
|
@ -313,7 +315,7 @@ void FDMDModel::BuildVertexBuffer(FModelRenderer *renderer)
|
|||
tri++;
|
||||
}
|
||||
}
|
||||
mVBuf->UnlockVertexBuffer();
|
||||
vbuf->UnlockVertexBuffer();
|
||||
UnloadGeometry();
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +370,7 @@ void FDMDModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
|
|||
|
||||
renderer->SetInterpolation(inter);
|
||||
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->SetInterpolation(0.f);
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ void FMD3Model::LoadGeometry()
|
|||
|
||||
void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer)
|
||||
{
|
||||
if (mVBuf == nullptr)
|
||||
if (!GetVertexBuffer(renderer))
|
||||
{
|
||||
LoadGeometry();
|
||||
|
||||
|
@ -251,9 +251,11 @@ void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer)
|
|||
ibufsize += 3 * surf->numTriangles;
|
||||
}
|
||||
|
||||
mVBuf = renderer->CreateVertexBuffer(true, numFrames == 1);
|
||||
FModelVertex *vertptr = mVBuf->LockVertexBuffer(vbufsize);
|
||||
unsigned int *indxptr = mVBuf->LockIndexBuffer(ibufsize);
|
||||
auto vbuf = renderer->CreateVertexBuffer(true, numFrames == 1);
|
||||
SetVertexBuffer(renderer, vbuf);
|
||||
|
||||
FModelVertex *vertptr = vbuf->LockVertexBuffer(vbufsize);
|
||||
unsigned int *indxptr = vbuf->LockIndexBuffer(ibufsize);
|
||||
|
||||
assert(vertptr != nullptr && indxptr != nullptr);
|
||||
|
||||
|
@ -285,8 +287,8 @@ void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer)
|
|||
}
|
||||
surf->UnloadGeometry();
|
||||
}
|
||||
mVBuf->UnlockVertexBuffer();
|
||||
mVBuf->UnlockIndexBuffer();
|
||||
vbuf->UnlockVertexBuffer();
|
||||
vbuf->UnlockIndexBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,7 +367,7 @@ void FMD3Model::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
|
|||
}
|
||||
|
||||
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->SetInterpolation(0.f);
|
||||
|
|
|
@ -198,7 +198,7 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame
|
|||
}
|
||||
}
|
||||
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);
|
||||
vofs += vsize;
|
||||
}
|
||||
|
@ -207,14 +207,15 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame
|
|||
|
||||
void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer )
|
||||
{
|
||||
if ( mVBuf != NULL )
|
||||
if (GetVertexBuffer(renderer))
|
||||
return;
|
||||
int vsize = 0;
|
||||
for ( int i=0; i<numGroups; i++ )
|
||||
vsize += groups[i].numPolys*3;
|
||||
vsize *= numFrames;
|
||||
mVBuf = renderer->CreateVertexBuffer(false,numFrames==1);
|
||||
FModelVertex *vptr = mVBuf->LockVertexBuffer(vsize);
|
||||
auto vbuf = renderer->CreateVertexBuffer(false,numFrames==1);
|
||||
SetVertexBuffer(renderer, vbuf);
|
||||
FModelVertex *vptr = vbuf->LockVertexBuffer(vsize);
|
||||
int vidx = 0;
|
||||
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 )
|
||||
|
|
|
@ -321,19 +321,21 @@ void FVoxelModel::Initialize()
|
|||
|
||||
void FVoxelModel::BuildVertexBuffer(FModelRenderer *renderer)
|
||||
{
|
||||
if (mVBuf == NULL)
|
||||
if (!GetVertexBuffer(renderer))
|
||||
{
|
||||
Initialize();
|
||||
|
||||
mVBuf = renderer->CreateVertexBuffer(true, true);
|
||||
FModelVertex *vertptr = mVBuf->LockVertexBuffer(mVertices.Size());
|
||||
unsigned int *indxptr = mVBuf->LockIndexBuffer(mIndices.Size());
|
||||
auto vbuf = renderer->CreateVertexBuffer(true, true);
|
||||
SetVertexBuffer(renderer, vbuf);
|
||||
|
||||
FModelVertex *vertptr = vbuf->LockVertexBuffer(mVertices.Size());
|
||||
unsigned int *indxptr = vbuf->LockIndexBuffer(mIndices.Size());
|
||||
|
||||
memcpy(vertptr, &mVertices[0], sizeof(FModelVertex)* mVertices.Size());
|
||||
memcpy(indxptr, &mIndices[0], sizeof(unsigned int)* mIndices.Size());
|
||||
|
||||
mVBuf->UnlockVertexBuffer();
|
||||
mVBuf->UnlockIndexBuffer();
|
||||
vbuf->UnlockVertexBuffer();
|
||||
vbuf->UnlockIndexBuffer();
|
||||
mNumIndices = mIndices.Size();
|
||||
|
||||
// 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)
|
||||
{
|
||||
renderer->SetMaterial(skin, true, translation);
|
||||
mVBuf->SetupFrame(renderer, 0, 0, 0);
|
||||
GetVertexBuffer(renderer)->SetupFrame(renderer, 0, 0, 0);
|
||||
renderer->DrawElements(mNumIndices, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -962,7 +962,7 @@ namespace swrenderer
|
|||
{
|
||||
int spritenum = thing->sprite;
|
||||
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)
|
||||
{
|
||||
DVector3 pos = thing->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "swrenderer/scene/r_light.h"
|
||||
|
||||
void gl_FlushModels();
|
||||
extern bool polymodelsInUse;
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (polymodelsInUse)
|
||||
{
|
||||
gl_FlushModels();
|
||||
polymodelsInUse = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SWModelRenderer::BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix)
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace swrenderer
|
|||
public:
|
||||
SWModelRenderer(RenderThread *thread, Fake3DTranslucent clip3DFloor);
|
||||
|
||||
ModelRendererType GetType() const override { return SWModelRendererType; }
|
||||
|
||||
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix) override;
|
||||
void EndDrawModel(AActor *actor, FSpriteModelFrame *smf) override;
|
||||
IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) override;
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace swrenderer
|
|||
(r_deathcamera && Thread->Viewport->viewpoint.camera->health <= 0))
|
||||
return;
|
||||
|
||||
renderHUDModel = r_models && gl_IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
||||
renderHUDModel = r_models && IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
|
||||
|
||||
FDynamicColormap *basecolormap;
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
|
|
Loading…
Reference in a new issue