- interpolate particles

This commit is contained in:
Rachael Alexanderson 2017-12-28 11:04:43 -05:00
parent 8ca3427850
commit a441cea350
3 changed files with 30 additions and 11 deletions

View file

@ -40,6 +40,7 @@
#include "events.h"
#include "actorinlines.h"
#include "r_data/r_vanillatrans.h"
#include "i_time.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h"
@ -1209,9 +1210,16 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
}
}
x = particle->Pos.X;
y = particle->Pos.Y;
z = particle->Pos.Z;
double timefrac = r_viewpoint.TicFrac;
if (paused || bglobal.freeze)
timefrac = 0.;
float xvf = (particle->Vel.X) * timefrac;
float yvf = (particle->Vel.Y) * timefrac;
float zvf = (particle->Vel.Z) * timefrac;
x = float(particle->Pos.X) + xvf;
y = float(particle->Pos.Y) + yvf;
z = float(particle->Pos.Z) + zvf;
float factor;
if (gl_particles_style == 1) factor = 1.3f / 7.f;

View file

@ -34,7 +34,10 @@ EXTERN_CVAR(Int, gl_particles_style)
void RenderPolyParticle::Render(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t stencilValue)
{
DVector3 pos = particle->Pos;
double timefrac = r_viewpoint.TicFrac;
if (paused || bglobal.freeze)
timefrac = 0.;
DVector3 pos = particle->Pos + (particle->Vel * timefrac);
double psize = particle->size / 8.0;
double zpos = pos.Z;

View file

@ -77,7 +77,15 @@ namespace swrenderer
double xscale, yscale;
int x1, x2, y1, y2;
sector_t* heightsec = NULL;
double timefrac = r_viewpoint.TicFrac;
if (paused || bglobal.freeze)
timefrac = 0.;
double ippx = particle->Pos.X + particle->Vel.X * timefrac;
double ippy = particle->Pos.Y + particle->Vel.Y * timefrac;
double ippz = particle->Pos.Z + particle->Vel.Z * timefrac;
RenderPortal *renderportal = thread->Portal.get();
// [ZZ] Particle not visible through the portal plane
@ -85,8 +93,8 @@ namespace swrenderer
return;
// transform the origin point
tr_x = particle->Pos.X - thread->Viewport->viewpoint.Pos.X;
tr_y = particle->Pos.Y - thread->Viewport->viewpoint.Pos.Y;
tr_x = ippx - thread->Viewport->viewpoint.Pos.X;
tr_y = ippy - thread->Viewport->viewpoint.Pos.Y;
tz = tr_x * thread->Viewport->viewpoint.TanCos + tr_y * thread->Viewport->viewpoint.TanSin;
@ -121,7 +129,7 @@ namespace swrenderer
auto viewport = thread->Viewport.get();
yscale = xscale; // YaspectMul is not needed for particles as they should always be square
ty = (particle->Pos.Z - viewport->viewpoint.Pos.Z) * thread->Viewport->YaspectMul;
ty = (ippz - viewport->viewpoint.Pos.Z) * thread->Viewport->YaspectMul;
y1 = xs_RoundToInt(viewport->CenterY - (ty + psize) * yscale);
y2 = xs_RoundToInt(viewport->CenterY - (ty - psize) * yscale);
@ -184,9 +192,9 @@ namespace swrenderer
map = GetColorTable(sector->Colormap, sector->SpecialColors[sector_t::sprites], true);
}
if (botpic != skyflatnum && particle->Pos.Z < botplane->ZatPoint(particle->Pos))
if (botpic != skyflatnum && ippz < botplane->ZatPoint(particle->Pos))
return;
if (toppic != skyflatnum && particle->Pos.Z >= topplane->ZatPoint(particle->Pos))
if (toppic != skyflatnum && ippz >= topplane->ZatPoint(particle->Pos))
return;
// store information in a vissprite
@ -199,7 +207,7 @@ namespace swrenderer
// vis->yscale *= InvZtoScale;
vis->depth = (float)tz;
vis->idepth = float(1 / tz);
vis->gpos = { (float)particle->Pos.X, (float)particle->Pos.Y, (float)particle->Pos.Z };
vis->gpos = { (float)ippx, (float)ippy, (float)ippz };
vis->y1 = y1;
vis->y2 = y2;
vis->x1 = x1;