Permalink
Browse files

- moved particle storage to FLevelLocals.

  • Loading branch information...
coelckers committed Jan 10, 2019
1 parent 2aa9c06 commit 8cc563b80f4f40dd58e6388fdae0451435a8d34e
@@ -80,6 +80,7 @@
#include "i_music.h"
#include "a_dynlight.h"
#include "p_conversation.h"
#include "p_effect.h"

#include "gi.h"

@@ -1469,6 +1470,8 @@ int G_FinishTravel ()

void FLevelLocals::InitLevelLocals ()
{
P_InitParticles(this);
P_ClearParticles(this);
BaseBlendA = 0.0f; // Remove underwater blend effect, if any

gravity = sv_gravity * 35/TICRATE;
@@ -45,6 +45,7 @@
#include "po_man.h"
#include "p_acs.h"
#include "p_tags.h"
#include "p_effect.h"
#include "p_destructible.h"
#include "r_data/r_interpolate.h"
#include "r_data/r_sections.h"
@@ -228,6 +229,12 @@ struct FLevelLocals : public FLevelData
int ActiveSequences;
DSeqNode *SequenceListHead;

// [RH] particle globals
uint32_t ActiveParticles;
uint32_t InactiveParticles;
TArray<particle_t> Particles;
TArray<uint16_t> ParticlesInSubsec;

TArray<DVector2> Scrolls; // NULL if no DScrollers in this level

int8_t WallVertLight; // Light diffs for vert/horiz walls
@@ -246,7 +246,8 @@ sector_t *FGLRenderer::RenderView(player_t* player)
if (cl_capfps || r_NoInterpolate) r_viewpoint.TicFrac = 1.;
else r_viewpoint.TicFrac = I_GetTimeFrac();

P_FindParticleSubsectors();
auto Level = player->camera->Level;
ForAllLevels(P_FindParticleSubsectors);

screen->mLights->Clear();
screen->mViewpoints->Clear();
@@ -255,7 +256,6 @@ sector_t *FGLRenderer::RenderView(player_t* player)
bool saved_niv = NoInterpolateView;
NoInterpolateView = false;
// prepare all camera textures that have been used in the last frame
auto Level = player->camera->Level;
gl_RenderState.CheckTimer(Level->ShaderStartTime);
Level->canvasTextureInfo.UpdateAll([&](AActor *camera, FCanvasTexture *camtex, double fov)
{
@@ -354,7 +354,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, i
mBuffers = mSaveBuffers;

hw_ClearFakeFlat();
P_FindParticleSubsectors(); // make sure that all recently spawned particles have a valid subsector.
ForAllLevels(P_FindParticleSubsectors);
gl_RenderState.SetVertexBuffer(screen->mVertexData);
screen->mVertexData->Reset();
screen->mLights->Clear();
@@ -554,16 +554,16 @@ void HWDrawInfo::RenderThings(subsector_t * sub, sector_t * sector)
void HWDrawInfo::RenderParticles(subsector_t *sub, sector_t *front)
{
SetupSprite.Clock();
for (int i = ParticlesInSubsec[sub->Index()]; i != NO_PARTICLE; i = Particles[i].snext)
for (int i = Level->ParticlesInSubsec[sub->Index()]; i != NO_PARTICLE; i = Level->Particles[i].snext)
{
if (mClipPortal)
{
int clipres = mClipPortal->ClipPoint(Particles[i].Pos);
int clipres = mClipPortal->ClipPoint(Level->Particles[i].Pos);
if (clipres == PClip_InFront) continue;
}

GLSprite sprite;
sprite.ProcessParticle(this, &Particles[i], front);
sprite.ProcessParticle(this, &Level->Particles[i], front);
}
SetupSprite.Unclock();
}
@@ -626,7 +626,7 @@ void HWDrawInfo::DoSubsector(subsector_t * sub)
}

// [RH] Add particles
if (gl_render_things && ParticlesInSubsec[sub->Index()] != NO_PARTICLE)
if (gl_render_things &&Level->ParticlesInSubsec[sub->Index()] != NO_PARTICLE)
{
if (multithread)
{
@@ -424,7 +424,7 @@ void HWDrawInfo::CreateScene()

// reset the portal manager
screen->mPortalState->StartFrame();
PO_LinkToSubsectors(Level);
ForAllLevels(PO_LinkToSubsectors);

ProcessAll.Clock();

@@ -6485,7 +6485,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
size = fabs(size);

if (lifetime != 0)
P_SpawnParticle(DVector3(ACSToDouble(x), ACSToDouble(y), ACSToDouble(z)),
P_SpawnParticle(Level, DVector3(ACSToDouble(x), ACSToDouble(y), ACSToDouble(z)),
DVector3(ACSToDouble(xvel), ACSToDouble(yvel), ACSToDouble(zvel)),
DVector3(ACSToDouble(accelx), ACSToDouble(accely), ACSToDouble(accelz)),
color, startalpha/255., lifetime, size, endsize, fadestep/255., fullbright);
@@ -1656,7 +1656,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnParticle)
acc.X = accelx * c + accely * s;
acc.Y = accelx * s - accely * c;
}
P_SpawnParticle(self->Vec3Offset(pos), vel, acc, color, startalpha, lifetime, size, fadestep, sizestep, flags);
P_SpawnParticle(self->Level, self->Vec3Offset(pos), vel, acc, color, startalpha, lifetime, size, fadestep, sizestep, flags);
}
return 0;
}
Oops, something went wrong.

0 comments on commit 8cc563b

Please sign in to comment.