Skip to content

Commit

Permalink
Testing: Added a special mobj trigger type * for particle generators
Browse files Browse the repository at this point in the history
If the generator's mobj type is set to "*", it applies to all mobjs. This is
mostly useful for testing the renderer.
  • Loading branch information
skyjake committed Jul 5, 2012
1 parent 0b7d195 commit 72c8f95
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
14 changes: 8 additions & 6 deletions doomsday/engine/portable/include/def_data.h
Expand Up @@ -39,15 +39,17 @@ extern "C" {
#include "uri.h"

// Version 6 does not require semicolons.
#define DED_VERSION 6
#define DED_VERSION 6

#define DED_SPRITEID_LEN 4
#define DED_STRINGID_LEN 31
#define DED_FUNC_LEN 255
#define DED_SPRITEID_LEN 4
#define DED_STRINGID_LEN 31
#define DED_FUNC_LEN 255

#define DED_MAX_SUB_MODELS 8
#define DED_MAX_SUB_MODELS 8

#define DED_MAX_MATERIAL_LAYERS 1 //// \temp
#define DED_MAX_MATERIAL_LAYERS 1 ///< \temp

#define DED_PTCGEN_ANY_MOBJ_TYPE -2 ///< Particle generator applies to ANY mobj type.

typedef char ded_stringid_t[DED_STRINGID_LEN + 1];
typedef ded_stringid_t ded_string_t;
Expand Down
5 changes: 4 additions & 1 deletion doomsday/engine/portable/src/def_main.c
Expand Up @@ -1300,7 +1300,10 @@ void Def_Read(void)
ded_ptcgen_t* pg = &defs.ptcGens[i];
int st = Def_GetStateNum(pg->state);

pg->typeNum = Def_GetMobjNum(pg->type);
if(!strcmp(pg->type, "*"))
pg->typeNum = DED_PTCGEN_ANY_MOBJ_TYPE;
else
pg->typeNum = Def_GetMobjNum(pg->type);
pg->type2Num = Def_GetMobjNum(pg->type2);
pg->damageNum = Def_GetMobjNum(pg->damage);

Expand Down
16 changes: 10 additions & 6 deletions doomsday/engine/portable/src/p_particle.c
Expand Up @@ -740,7 +740,7 @@ static int manyNewParticles(thinker_t* th, void* context)
mobj_t* mo = (mobj_t *) th;

// Type match?
if(mo->type == gen->type || mo->type == gen->type2)
if(gen->type == DED_PTCGEN_ANY_MOBJ_TYPE || mo->type == gen->type || mo->type == gen->type2)
{
// Someone might think this is a slight hack...
gen->source = mo;
Expand Down Expand Up @@ -1208,7 +1208,7 @@ void P_PtcGenThinker(ptcgen_t* gen)

// Spawn new particles?
if((gen->age <= def->spawnAge || def->spawnAge < 0) &&
(gen->source || gen->plane || gen->type >= 0 ||
(gen->source || gen->plane || gen->type >= 0 || gen->type == DED_PTCGEN_ANY_MOBJ_TYPE ||
(gen->flags & PGF_UNTRIGGERED)))
{
newparts = def->spawnRate * gen->spawnRateMultiplier;
Expand All @@ -1220,7 +1220,7 @@ void P_PtcGenThinker(ptcgen_t* gen)
while(gen->spawnCount >= 1)
{
// Spawn a new particle.
if(gen->type >= 0) // Type-triggered?
if(gen->type == DED_PTCGEN_ANY_MOBJ_TYPE || gen->type >= 0) // Type-triggered?
{
// Client's should also check the client mobjs.
if(isClient)
Expand Down Expand Up @@ -1284,8 +1284,8 @@ void P_SpawnTypeParticleGens(void)
if(isDedicated || !useParticles) return;

for(i = 0, def = defs.ptcGens; i < defs.count.ptcGens.num; ++i, def++)
{
if(def->typeNum < 0) continue;
{
if(def->typeNum != DED_PTCGEN_ANY_MOBJ_TYPE && def->typeNum < 0) continue;

gen = P_NewGenerator();
if(!gen) return; // No more generators.
Expand Down Expand Up @@ -1390,6 +1390,10 @@ static int findDefForGenerator(ptcgen_t* gen, void* parameters)
for(i = 0; i < defs.count.ptcGens.num; ++i, def++)
{
// A type generator?
if(def->typeNum == DED_PTCGEN_ANY_MOBJ_TYPE && gen->type == DED_PTCGEN_ANY_MOBJ_TYPE)
{
return i+1; // Stop iteration.
}
if(def->typeNum >= 0 &&
(gen->type == def->typeNum || gen->type2 == def->type2Num))
{
Expand All @@ -1399,7 +1403,7 @@ static int findDefForGenerator(ptcgen_t* gen, void* parameters)
// A damage generator?
if(gen->source && gen->source->type == def->damageNum)
{
return i+1;
return i+1; // Stop iteration.
}

// A flat generator?
Expand Down

0 comments on commit 72c8f95

Please sign in to comment.