Skip to content

Commit

Permalink
effects: use vec3_t as scale
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Nov 23, 2024
1 parent 62efce3 commit eb5a518
Show file tree
Hide file tree
Showing 57 changed files with 1,127 additions and 634 deletions.
4 changes: 1 addition & 3 deletions src/client/vid/header/ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef struct entity_s {
/* misc */
float backlerp; /* 0.0 = current, 1.0 = old */
int skinnum; /* also used as RF_BEAM's palette index */
vec3_t scale; /* model scale before render */

int lightstyle; /* for flashing entities */
float alpha; /* ignore if RF_TRANSLUCENT isn't set */
Expand All @@ -76,9 +77,6 @@ typedef struct entity_s {
int flags;

/* Heretic 2 */

float scale; // model scale

float cl_scale; // scale of model - but only for client entity models - not server side models
// required for scaling mins and maxs that are used to cull models - mins and maxs
// are scaled on the server side, but not on the client side when the models are loaded in
Expand Down
1 change: 1 addition & 0 deletions src/common/header/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@ typedef struct entity_state_s
int event; /* impulse events -- muzzle flashes, footsteps, etc */
/* events only go out for a single frame, they */
/* are automatically cleared each frame */
/* New protocol fields */
vec3_t scale;

short clientnum; // In Quake 2, the client num was passed in skinnum. We need this value, however.
Expand Down
1 change: 1 addition & 0 deletions src/game/effects/client_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define DETAIL_HIGH 2
#define DETAIL_UBERHIGH 3
#define DETAIL_DEFAULT "2.0"
#define AVG_VEC3T(scale) (((scale)[0] + (scale)[1] + (scale)[2]) / 3)

extern client_fx_import_t fxi;

Expand Down
14 changes: 8 additions & 6 deletions src/game/effects/client_entities.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ client_entity_t *ClientEntity_new(int type, int flags, vec3_t origin, vec3_t dir
AnglesFromDirI(newEnt->direction, newEnt->r.angles);
// AnglesFromDirAndUp(newEnt->direction, newEnt->up, newEnt->r.angles);

newEnt->r.scale = 1.0F;
VectorSet(newEnt->r.scale, 1.0F, 1.0F, 1.0F);
newEnt->r.color.c = 0xffffffff;
newEnt->alpha = 1.0F;
newEnt->radius = 1.0F;
Expand Down Expand Up @@ -355,7 +355,7 @@ int AddEffectsToView(client_entity_t **root, centity_t *owner)

current->r.color.a = Q_ftol(current->alpha * 255.0);

if(current->r.color.a && (current->r.scale > 0.0))
if(current->r.color.a && (AVG_VEC3T(current->r.scale) > 0.0))
{
if(!AddEntityToView(&current->r))
{
Expand Down Expand Up @@ -388,7 +388,7 @@ void AddEffect(centity_t* owner, client_entity_t* fx)
}

// copy up the scale on a model so it can be culled properly
fx->r.cl_scale = fx->r.scale;
fx->r.cl_scale = AVG_VEC3T(fx->r.scale);
}

#define NUM_TRACES 100 // I really, really hope we don't ever see more than _this
Expand Down Expand Up @@ -469,9 +469,11 @@ int UpdateEffects(client_entity_t **root, centity_t *owner)

d_size = d_time * current->d_scale;

current->radius *= (1 + d_size/r->scale);
current->radius *= (1 + d_size / AVG_VEC3T(r->scale));

r->scale += d_size;
r->scale[0] += d_size;
r->scale[1] += d_size;
r->scale[2] += d_size;

// Apply scale to spritelines as appropriate.
if (current->r.spriteType == SPRITE_LINE)
Expand All @@ -484,7 +486,7 @@ int UpdateEffects(client_entity_t **root, centity_t *owner)
}
else
{ // Otherwise the second scale is copied from the first.
r->scale2 = r->scale;
r->scale2 = AVG_VEC3T(r->scale);
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/game/effects/fx_ammo_pickup.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,13 @@ void FXAmmoPickup(centity_t *owner, int type, int flags, vec3_t origin)

if ((tag == ITEM_AMMO_MANA_COMBO_HALF) || (tag == ITEM_AMMO_MANA_DEFENSIVE_FULL) ||
(tag == ITEM_AMMO_MANA_OFFENSIVE_FULL))
ce->r.scale = 1.25;
{
VectorSet(ce->r.scale, 1.25, 1.25, 1.25);
}
else
ce->r.scale = 1.0;
{
VectorSet(ce->r.scale, 1.0, 1.0, 1.0);
}
ce->radius = 10.0;
ce->alpha = 0.8;
ce->Update = FXAmmoPickupThink;
Expand Down
2 changes: 1 addition & 1 deletion src/game/effects/fx_animate.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void FXAnimate(centity_t *owner, int type, int flags, vec3_t origin)
atype = anim & 0x7f;

self->r.model = FXAnimModel[atype].model;
self->r.scale = scale * 0.02;
VectorSet(self->r.scale, scale * 0.02, scale * 0.02, scale * 0.02);
self->r.skinnum = skinnum;

self->alpha = FXAnimModel[atype].alpha;
Expand Down
5 changes: 4 additions & 1 deletion src/game/effects/fx_blood.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ void ThrowBlood(vec3_t origin, vec3_t tnormal, qboolean dark, qboolean yellow, q

if(trueplane || GetTruePlane(origin, normal))
{
float scale;

bloodmark = ClientEntity_new(FX_BLOOD, CEF_NOMOVE, origin, tnormal, 1000);

bloodmark->r.angles[ROLL] = flrand(0, ANGLE_360);
Expand Down Expand Up @@ -422,7 +424,8 @@ void ThrowBlood(vec3_t origin, vec3_t tnormal, qboolean dark, qboolean yellow, q
bloodmark->alpha = 1.0;

bloodmark->radius = 10.0;
bloodmark->r.scale = flrand(0.2, 0.45);
scale = flrand(0.2, 0.45);
VectorSet(bloodmark->r.scale, scale, scale, scale);

if(tnormal[2] <= -0.7 && !irand(0, 2) && bloodmark->r.frame != 2 && bloodmark->r.frame != 4)
{
Expand Down
3 changes: 2 additions & 1 deletion src/game/effects/fx_blue_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void FXBlueRing(centity_t *Owner, int Type, int Flags, vec3_t Origin)
flameitem->r.model = blue_models[0];
flameitem->r.flags = RF_FULLBRIGHT | RF_TRANSLUCENT | RF_TRANS_ADD | RF_TRANS_ADD_ALPHA;
flameitem->r.frame = 0;
flameitem->r.scale = FLAME_INIT_SCALE;
VectorSet(flameitem->r.scale,
FLAME_INIT_SCALE, FLAME_INIT_SCALE, FLAME_INIT_SCALE);
flameitem->d_scale = FLAME_DELTA_SCALE;

VectorSet(flameitem->velocity, FLAME_ABSVEL * cos(curAng), FLAME_ABSVEL * sin(curAng), 0);
Expand Down
11 changes: 7 additions & 4 deletions src/game/effects/fx_bubbler.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ qboolean FXBubbleThink(client_entity_t *bubble, centity_t *owner)

static qboolean FXBubblerParticleSpawner(client_entity_t *spawner, centity_t *owner)
{
client_entity_t *bubble;
client_entity_t *bubble;
vec3_t origin;
float scale;

VectorCopy(spawner->r.origin, origin);

Expand All @@ -72,7 +73,8 @@ static qboolean FXBubblerParticleSpawner(client_entity_t *spawner, centity_t *ow
bubble = ClientEntity_new(-1, 0, origin, NULL, spawner->SpawnData);

bubble->r.model = bubbler_models[0];
bubble->r.scale = flrand(0.10, 0.20);
scale = flrand(0.10, 0.20);
VectorSet(bubble->r.scale, scale, scale, scale);
bubble->r.flags = RF_TRANSLUCENT;

bubble->radius = flrand(0.5, 1.5);
Expand Down Expand Up @@ -122,7 +124,7 @@ void FXBubble(centity_t *Owner, int Type, int Flags, vec3_t Origin)
{
int time;
client_entity_t *bubble;
float up, down;
float up, down, scale;
vec3_t dest;

GetSolidDist(Origin, 1.0, 1000, &up);
Expand All @@ -137,7 +139,8 @@ void FXBubble(centity_t *Owner, int Type, int Flags, vec3_t Origin)
bubble = ClientEntity_new(FX_BUBBLE, Flags, Origin, NULL, time);

bubble->r.model = bubbler_models[0];
bubble->r.scale = flrand(0.025, 0.10);
scale = flrand(0.025, 0.10);
VectorSet(bubble->r.scale, scale, scale, scale);
bubble->r.flags = RF_TRANSLUCENT;
bubble->radius = BUBBLE_RADIUS*2;
bubble->acceleration[2] = BUBBLE_ACCELERATION;
Expand Down
9 changes: 8 additions & 1 deletion src/game/effects/fx_crosshair.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ static qboolean FXDrawCrosshair(struct client_entity_s *cross_hair, centity_t *o
// Get new destination
if (fxi.Get_Crosshair(cross_hair->r.origin, &type))
{
float scale;

if (type > 2)
{
cross_hair->r.frame = 0;
}
else
{
cross_hair->r.frame = type;
}

cross_hair->r.flags = RF_TRANSLUCENT | RF_TRANS_ADD | RF_TRANS_ADD_ALPHA | RF_NODEPTHTEST;

Expand All @@ -50,7 +56,8 @@ static qboolean FXDrawCrosshair(struct client_entity_s *cross_hair, centity_t *o
alpha = 0.0f;

cross_hair->alpha = 0.25 + alpha * 0.5;
cross_hair->r.scale = alpha * 0.5;
scale = alpha * 0.5;
VectorSet(cross_hair->r.scale, scale, scale, scale);

cross_hair->flags &= ~(CEF_CULLED | CEF_DISAPPEARED | CEF_NO_DRAW);
}
Expand Down
45 changes: 34 additions & 11 deletions src/game/effects/fx_cwatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ static qboolean FXCWBeamUpdate(struct client_entity_s *self, centity_t *owner)

while (i--)
{
float scale;

spawner = ClientEntity_new(FX_CWATCHER, CEF_DONT_LINK, self->r.origin, NULL, 1000);
spawner->r.model = cwmodels[CWM_BEAM_LINE];
spawner->radius = 400;
Expand All @@ -76,7 +78,9 @@ static qboolean FXCWBeamUpdate(struct client_entity_s *self, centity_t *owner)

spawner->r.spriteType = SPRITE_LINE;

spawner->r.scale=flrand(1.5, 2.5);
scale = flrand(1.5, 2.5);
VectorSet(spawner->r.scale, scale, scale, scale);

spawner->alpha=0.75;
spawner->d_alpha=-2.5;
spawner->d_scale=-2.5;
Expand Down Expand Up @@ -105,27 +109,40 @@ static qboolean FXCWBeamUpdate(struct client_entity_s *self, centity_t *owner)

static qboolean FXCWBeamThink(struct client_entity_s *self, centity_t *owner)
{
float scale;

if (self->LifeTime < fxi.cl->time)
{
return false;
}

self->r.scale = flrand(14.0, 16.0);
scale = flrand(14.0, 16.0);
VectorSet(self->r.scale, scale, scale, scale);

return true;
}

static qboolean FXCWBeamThink2(struct client_entity_s *self, centity_t *owner)
{
float scale;

if (self->LifeTime < fxi.cl->time)
{
return false;
}

self->r.scale = flrand(1.5, 2.0);
scale = flrand(1.5, 2.0);
VectorSet(self->r.scale, scale, scale, scale);

return true;
}

static qboolean FXCWStarThink(struct client_entity_s *self, centity_t *owner)
{
self->r.scale = flrand(0.3, 0.5);
float scale;

scale = flrand(0.3, 0.5);
VectorSet(self->r.scale, scale, scale, scale);

return true;
}
Expand Down Expand Up @@ -153,7 +170,7 @@ void FXCWatcherEffects(centity_t *owner, int type, int flags, vec3_t origin)

spawner->r.frame = 0;
spawner->r.flags |= RF_TRANSLUCENT | RF_TRANS_ADD | RF_TRANS_ADD_ALPHA;
spawner->r.scale=0.8;
VectorSet(spawner->r.scale, 0.8, 0.8, 0.8);
spawner->alpha=0.5;
spawner->d_alpha=0.0;

Expand All @@ -169,7 +186,7 @@ void FXCWatcherEffects(centity_t *owner, int type, int flags, vec3_t origin)

spawner->r.frame = 1;
spawner->r.flags |= RF_TRANSLUCENT | RF_TRANS_ADD;
spawner->r.scale=0.5;
VectorSet(spawner->r.scale, 0.5, 0.5, 0.5);
spawner->alpha=0.75;
spawner->d_alpha=0.0;

Expand All @@ -192,13 +209,16 @@ void FXCWatcherEffects(centity_t *owner, int type, int flags, vec3_t origin)

while (i--)
{
float scale;

spawner = ClientEntity_new(type, flags | CEF_DONT_LINK, origin, NULL, 500);
spawner->r.model = cwmodels[CWM_STAR_HALO];
spawner->radius = 400;

spawner->r.frame = 1;
spawner->r.flags |= RF_TRANSLUCENT | RF_TRANS_ADD | RF_TRANS_ADD_ALPHA;
spawner->r.scale=flrand(0.5, 0.25);
scale = flrand(0.5, 0.25);
VectorSet(spawner->r.scale, scale, scale, scale);
spawner->alpha=0.75;
spawner->d_alpha=-2.0;
spawner->d_scale=-0.5;
Expand All @@ -214,6 +234,8 @@ void FXCWatcherEffects(centity_t *owner, int type, int flags, vec3_t origin)

while (i--)
{
float scale;

spawner = ClientEntity_new(type, flags | CEF_DONT_LINK, origin, NULL, 1000);
spawner->r.model = cwmodels[CWM_STAR_TRAIL];
spawner->radius = 400;
Expand All @@ -223,7 +245,8 @@ void FXCWatcherEffects(centity_t *owner, int type, int flags, vec3_t origin)

spawner->r.spriteType = SPRITE_LINE;

spawner->r.scale=flrand(2.0, 1.5);
scale = flrand(2.0, 1.5);
VectorSet(spawner->r.scale, scale, scale, scale);
spawner->alpha=0.75;
spawner->d_alpha=-2.5;
spawner->d_scale=-4.0;
Expand All @@ -249,7 +272,7 @@ void FXCWatcherEffects(centity_t *owner, int type, int flags, vec3_t origin)
spawner->radius = 400;

spawner->r.flags = RF_TRANS_ADD | RF_FULLBRIGHT | RF_TRANSLUCENT | RF_TRANS_ADD_ALPHA;
spawner->r.scale = 16;
VectorSet(spawner->r.scale, 16, 16, 16);
spawner->r.color.c = 0xA0FFFFFF;
spawner->r.spriteType = SPRITE_LINE;
VectorCopy(vel, spawner->r.startpos);
Expand All @@ -268,7 +291,7 @@ void FXCWatcherEffects(centity_t *owner, int type, int flags, vec3_t origin)
spawner->radius = 400;

spawner->r.flags = RF_TRANS_ADD | RF_FULLBRIGHT | RF_TRANSLUCENT | RF_TRANS_ADD_ALPHA | RF_NODEPTHTEST;
spawner->r.scale = 2.5;
VectorSet(spawner->r.scale, 2.5, 2.5, 2.5);
spawner->r.color.c = 0xFFFFFFFF;

spawner->LifeTime = fxi.cl->time + 3100;
Expand All @@ -292,7 +315,7 @@ void FXCWatcherEffects(centity_t *owner, int type, int flags, vec3_t origin)
spawner->radius = 400;

spawner->r.flags = RF_TRANS_ADD | RF_FULLBRIGHT | RF_TRANSLUCENT | RF_TRANS_ADD_ALPHA | RF_NODEPTHTEST;
spawner->r.scale = 2.5;
VectorSet(spawner->r.scale, 2.5, 2.5, 2.5);
spawner->r.color.c = 0xFFFFFFFF;

spawner->dlight=CE_DLight_new(white_light,200.0f,0.0f);
Expand Down
Loading

0 comments on commit eb5a518

Please sign in to comment.