Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor|World: Continued splitting up p_particle.h/cpp
  • Loading branch information
danij-deng committed Jan 15, 2014
1 parent 2a3ce81 commit 54d54b4
Show file tree
Hide file tree
Showing 14 changed files with 408 additions and 404 deletions.
7 changes: 7 additions & 0 deletions doomsday/client/include/def_data.h
Expand Up @@ -83,6 +83,13 @@ typedef struct ded_ptcstage_s {
ded_string_t endFrameName;
short frame, endFrame;
ded_embsound_t sound, hitSound;

/**
* Takes care of consistent variance.
* Currently only used visually, collisions use the constant radius.
* The variance can be negative (results will be larger).
*/
float particleRadius(int ptcIDX) const;
} ded_ptcstage_t;

typedef struct ded_count_s {
Expand Down
9 changes: 9 additions & 0 deletions doomsday/client/include/world/map.h
Expand Up @@ -793,6 +793,15 @@ class Map
*/
void initGenerators();

/**
* Attempt to spawn all flat-triggered particle generators for the map.
* To be called after map setup is completed.
*
* @note Cannot presently be done in @ref initGenerators() as this is called
* during initial Map load and before any saved game has been loaded.
*/
void spawnPlaneParticleGens();

/**
* Destroys all clientside clmobjs in the map. To be called when a network
* game ends.
Expand Down
8 changes: 8 additions & 0 deletions doomsday/client/include/world/p_object.h
Expand Up @@ -25,6 +25,8 @@
# error Attempted to include internal Doomsday p_object.h from a game
#endif

#include "api_map.h"
#include "def_data.h"
#ifdef __CLIENT__
# include "ModelDef"
# include "Sprite"
Expand Down Expand Up @@ -143,6 +145,12 @@ SectorCluster &Mobj_Cluster(mobj_t const &mobj);
*/
SectorCluster *Mobj_ClusterPtr(mobj_t const &mobj);

/**
* Creates a new mobj-triggered particle generator based on the given
* definition. The generator is added to the list of active ptcgens.
*/
void Mobj_SpawnParticleGen(mobj_t *source, ded_ptcgen_t const *def);

#ifdef __CLIENT__

/**
Expand Down
44 changes: 0 additions & 44 deletions doomsday/client/include/world/p_particle.h
Expand Up @@ -237,48 +237,4 @@ typedef Generator::ParticleStage GeneratorParticleStage;
void Generator_Delete(Generator *gen);
void Generator_Thinker(Generator *gen);

/**
* Attempt to spawn all flat-triggered particle generators for the @a map.
* To be called after map setup is completed.
*
* @note Cannot presently be done in P_PtcInitForMap as this is called during
* initial Map load and before any saved game has been loaded.
*/
void P_MapSpawnPlaneParticleGens(de::Map &map);

/**
* Spawns all type-triggered particle generators, regardless of whether
* the type of mobj exists in the map or not (mobjs might be dynamically
* created).
*/
void P_SpawnTypeParticleGens(de::Map &map);

void P_SpawnMapParticleGens(de::Map &map);

/**
* Update existing generators in the map following an engine reset.
*/
void P_UpdateParticleGens(de::Map &map);

/**
* Creates a new mobj-triggered particle generator based on the given
* definition. The generator is added to the list of active ptcgens.
*/
void P_SpawnMobjParticleGen(ded_ptcgen_t const *def, struct mobj_s *source);

void P_SpawnMapDamageParticleGen(struct mobj_s *mo, struct mobj_s *inflictor, int amount);

/**
* Creates a new flat-triggered particle generator based on the given
* definition. The generator is added to the list of active ptcgens.
*/
void P_SpawnPlaneParticleGen(ded_ptcgen_t const *def, Plane *plane);

/**
* Takes care of consistent variance.
* Currently only used visually, collisions use the constant radius.
* The variance can be negative (results will be larger).
*/
float P_GetParticleRadius(ded_ptcstage_t const *stageDef, int ptcIndex);

#endif // DENG_CLIENT_WORLD_P_PARTICLE_H
10 changes: 10 additions & 0 deletions doomsday/client/include/world/plane.h
Expand Up @@ -22,6 +22,9 @@
#define DENG_WORLD_PLANE_H

#include "dd_share.h" // SoundEmitter
#ifdef __CLIENT__
# include "def_main.h"
#endif

#include "MapElement"

Expand Down Expand Up @@ -221,6 +224,13 @@ class Plane : public de::MapElement
*/
Generator &generator() const;

/**
* Creates a new flat-triggered particle generator based on the given
* definition. Note that it may @em not be "this" plane to which the resultant
* generator is attached as the definition may override this.
*/
void spawnParticleGen(ded_ptcgen_t const *def);

#endif // __CLIENT__

protected:
Expand Down
14 changes: 14 additions & 0 deletions doomsday/client/src/def_data.cpp
Expand Up @@ -38,6 +38,20 @@

// Helper Routines -------------------------------------------------------

float ded_ptcstage_t::particleRadius(int ptcIDX) const
{
if(radiusVariance)
{
static float const rnd[16] = { .875f, .125f, .3125f, .75f, .5f, .375f,
.5625f, .0625f, 1, .6875f, .625f, .4375f, .8125f, .1875f,
.9375f, .25f
};
return (rnd[ptcIDX & 0xf] * radiusVariance +
(1 - radiusVariance)) * radius;
}
return radius;
}

void* DED_NewEntries(void** ptr, ded_count_t* cnt, size_t elemSize, int count)
{
void* np;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/render/rend_particle.cpp
Expand Up @@ -591,8 +591,8 @@ static void renderParticles(int rtype, bool withBlend)
float mark = 1 - invMark;

// Calculate size and color.
float size = P_GetParticleRadius(dst, slot->ptID) * invMark
+ P_GetParticleRadius(nextDst, slot->ptID) * mark;
float size = dst->particleRadius(slot->ptID) * invMark
+ nextDst->particleRadius(slot->ptID) * mark;

// Infinitely small?
if(!size) continue;
Expand Down
9 changes: 1 addition & 8 deletions doomsday/client/src/world/api_map.cpp
Expand Up @@ -1696,14 +1696,7 @@ DENG_EXTERN_C void Mobj_SetState(mobj_t *mobj, int statenum);
DENG_EXTERN_C angle_t Mobj_AngleSmoothed(mobj_t *mobj);
DENG_EXTERN_C void Mobj_OriginSmoothed(mobj_t *mobj, coord_t origin[3]);
DENG_EXTERN_C Sector *Mobj_Sector(mobj_t const *mobj);

#undef Mobj_SpawnDamageParticleGen
DENG_EXTERN_C void Mobj_SpawnDamageParticleGen(mobj_t *mobj, mobj_t *inflictor, int amount)
{
#ifdef __CLIENT__
P_SpawnMapDamageParticleGen(mobj, inflictor, amount);
#endif
}
DENG_EXTERN_C void Mobj_SpawnDamageParticleGen(mobj_t *mobj, mobj_t *inflictor, int amount);

// p_think.c
DENG_EXTERN_C struct mobj_s* Mobj_ById(int id);
Expand Down

0 comments on commit 54d54b4

Please sign in to comment.