Skip to content

Commit

Permalink
Added textured particles, planeflat sticks to planes
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 28, 2003
1 parent b920df7 commit b2c8a70
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 48 deletions.
2 changes: 2 additions & 0 deletions doomsday/Include/gl_tex.h
Expand Up @@ -40,6 +40,8 @@ byte * GL_LoadImage(const char *imagefn, int *width, int *height,
int *pixsize, boolean *masked, boolean usemodelpath);
byte * GL_LoadImageCK(const char *imagefn, int *width, int *height,
int *pixsize, boolean *masked, boolean usemodelpath);
byte * GL_LoadHighResTexture(char *name, int *width, int *height,
int *pixsize, boolean *masked);
DGLuint GL_PrepareTexture(int idx);
DGLuint GL_PrepareFlat(int idx);
DGLuint GL_PrepareLightTexture(void); // The dynamic light map.
Expand Down
7 changes: 6 additions & 1 deletion doomsday/Include/p_particle.h
Expand Up @@ -3,6 +3,7 @@

#define MAX_ACTIVE_PTCGENS 96
#define MAX_PTC_STAGES DED_PTC_STAGES
#define MAX_PTC_TEXTURES 32 // Maximum # of textures in particle system

// Generator flags
#define PGF_STATIC 0x1 // Can't be replaced by anything.
Expand All @@ -26,7 +27,10 @@ enum
{
PTC_NONE,
PTC_POINT,
PTC_LINE
PTC_LINE,
// New types can be added here.
PTC_TEXTURE = 100
// ...followed by MAX_PTC_TEXTURES types.
} ptc_type_e;

// Particle flags
Expand Down Expand Up @@ -92,5 +96,6 @@ void P_SpawnDamageParticleGen(mobj_t *mo, mobj_t *inflictor, int amount);
void P_CheckPtcPlanes(void);

float P_GetParticleRadius(ded_ptcstage_t *stage_def, int ptc_index);
fixed_t P_GetParticleZ(particle_t *pt);

#endif
3 changes: 3 additions & 0 deletions doomsday/Src/gl_tex.c
Expand Up @@ -1534,6 +1534,7 @@ byte *GL_LoadHighRes(char *name, char *path, char *altPath, char *prefix,

//===========================================================================
// GL_LoadHighResTexture
// The returned buffer must be freed with M_Free.
//===========================================================================
byte *GL_LoadHighResTexture
(char *name, int *width, int *height, int *pixsize, boolean *masked)
Expand All @@ -1544,11 +1545,13 @@ byte *GL_LoadHighResTexture

//===========================================================================
// GL_LoadHighResFlat
// The returned buffer must be freed with M_Free.
//===========================================================================
byte *GL_LoadHighResFlat(char *name, int *width, int *height, int *pixsize)
{
boolean masked;

// FIXME: Why no subdir named "Flats"?
return GL_LoadHighRes(name, hiTexPath, hiTexPath2, "Flat-", width,
height, pixsize, &masked, false);
}
Expand Down
90 changes: 62 additions & 28 deletions doomsday/Src/p_particle.c
Expand Up @@ -603,6 +603,19 @@ float P_GetParticleRadius(ded_ptcstage_t *stage_def, int ptc_index)
+ (1 - stage_def->radius_variance)) * stage_def->radius;
}

//===========================================================================
// P_GetParticleZ
// A particle may be attached to the floor or ceiling of the sector.
//===========================================================================
fixed_t P_GetParticleZ(particle_t *pt)
{
if(pt->pos[VZ] == DDMAXINT)
return pt->sector->ceilingheight - 2*FRACUNIT;
if(pt->pos[VZ] == DDMININT)
return pt->sector->floorheight + 2*FRACUNIT;
return pt->pos[VZ];
}

//===========================================================================
// P_MoveParticle
// The movement is done in two steps:
Expand All @@ -615,6 +628,7 @@ void P_MoveParticle(ptcgen_t *gen, particle_t *pt)
int x, y, z, xl, xh, yl, yh, bx, by;
ptcstage_t *st = gen->stages + pt->stage;
boolean zbounce = false;
boolean hitFloor;
fixed_t hardRadius = st->radius/2;

// Changes to momentum.
Expand All @@ -632,7 +646,8 @@ void P_MoveParticle(ptcgen_t *gen, particle_t *pt)
{
delta[VX] = pt->pos[VX] - gen->source->x;
delta[VY] = pt->pos[VY] - gen->source->y;
delta[VZ] = pt->pos[VZ] - (gen->source->z + gen->center[VZ]);
delta[VZ] = P_GetParticleZ(pt)
- (gen->source->z + gen->center[VZ]);
}
else
{
Expand Down Expand Up @@ -684,37 +699,55 @@ void P_MoveParticle(ptcgen_t *gen, particle_t *pt)
// collisions.
if(st->flags & PTCF_PLANE_FLAT) hardRadius = FRACUNIT;

// Check the new Z position.
z = pt->pos[VZ] + pt->mov[VZ];
if(z > pt->sector->ceilingheight - hardRadius)
// Check the new Z position only if not stuck to a plane.
if(pt->pos[VZ] != DDMININT && pt->pos[VZ] != DDMAXINT)
{
// The Z is through the roof!
if(pt->sector->ceilingpic == skyflatnum)
z = pt->pos[VZ] + pt->mov[VZ];
if(z > pt->sector->ceilingheight - hardRadius)
{
// Special case: particle gets lost in the sky.
pt->stage = -1;
return;
// The Z is through the roof!
if(pt->sector->ceilingpic == skyflatnum)
{
// Special case: particle gets lost in the sky.
pt->stage = -1;
return;
}
if(!P_TouchParticle(pt, st, false)) return;
z = pt->sector->ceilingheight - hardRadius;
zbounce = true;
hitFloor = false;
}
if(!P_TouchParticle(pt, st, false)) return;
z = pt->sector->ceilingheight - hardRadius;
zbounce = true;
}
// Also check the floor.
if(z < pt->sector->floorheight + hardRadius)
{
if(pt->sector->floorpic == skyflatnum)
// Also check the floor.
if(z < pt->sector->floorheight + hardRadius)
{
pt->stage = -1;
return;
if(pt->sector->floorpic == skyflatnum)
{
pt->stage = -1;
return;
}
if(!P_TouchParticle(pt, st, false)) return;
z = pt->sector->floorheight + hardRadius;
zbounce = true;
hitFloor = true;
}
if(zbounce)
{
pt->mov[VZ] = FixedMul(-pt->mov[VZ], st->bounce);
if(!pt->mov[VZ])
{
// The particle has stopped moving. This means its Z-movement
// has ceased because of the collision with a plane. Plane-flat
// particles will stick to the plane.
if(st->flags & PTCF_PLANE_FLAT)
{
z = hitFloor? DDMININT : DDMAXINT;
}
}
}
if(!P_TouchParticle(pt, st, false)) return;
z = pt->sector->floorheight + hardRadius;
zbounce = true;

// Move to the new Z coordinate.
pt->pos[VZ] = z;
}
if(zbounce) pt->mov[VZ] = FixedMul(-pt->mov[VZ], st->bounce);

// Move to the new Z coordinate.
pt->pos[VZ] = z;

// Now check the XY direction.
// - Check if the movement crosses any solid lines.
Expand All @@ -739,8 +772,9 @@ void P_MoveParticle(ptcgen_t *gen, particle_t *pt)
{
// If the particle is in the opening of a 2-sided line, it's
// quite likely that it shouldn't be here...
if(pt->pos[VZ] > MAX_OF(front->floorheight, back->floorheight)
&& pt->pos[VZ] < MIN_OF(front->ceilingheight,
if(P_GetParticleZ(pt) > MAX_OF(front->floorheight,
back->floorheight)
&& P_GetParticleZ(pt) < MIN_OF(front->ceilingheight,
back->ceilingheight))
{
// Kill the particle.
Expand Down

0 comments on commit b2c8a70

Please sign in to comment.