Skip to content

Commit

Permalink
renders: support scale in renders
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Nov 23, 2024
1 parent eb5a518 commit f520148
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 56 deletions.
19 changes: 12 additions & 7 deletions src/client/refresh/files/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ void
R_LerpVerts(qboolean powerUpEffect, int nverts,
const dxtrivertx_t *v, const dxtrivertx_t *ov,
float *lerp, const float move[3],
const float frontv[3], const float backv[3])
const float frontv[3], const float backv[3], const float *scale)
{
int i;

if (powerUpEffect)
{
int i;

for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
int n;
Expand All @@ -111,18 +111,23 @@ R_LerpVerts(qboolean powerUpEffect, int nverts,

normal = v->normal[n] / 127.f;

lerp[n] = move[n] + ov->v[n] * backv[n] + v->v[n] * frontv[n] +
lerp[n] = scale[n] * (move[n] + ov->v[n] * backv[n] + v->v[n] * frontv[n]) +
normal * POWERSUIT_SCALE;
}
}
}
else
{
int i;

for (i = 0; i < nverts; i++, v++, ov++, lerp += 4)
{
lerp[0] = move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0];
lerp[1] = move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1];
lerp[2] = move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2];
int n;

for (n = 0; n < 3; n++)
{
lerp[n] = scale[n] * (move[n] + ov->v[n] * backv[n] + v->v[n] * frontv[n]);
}
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/client/refresh/gl1/gl1_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp,
lerp = s_lerped[0];

R_LerpVerts(colorOnly, paliashdr->num_xyz, verts, ov, lerp,
move, frontv, backv);
move, frontv, backv, currententity->scale);

num_mesh_nodes = paliashdr->num_meshes;
mesh_nodes = (dmdxmesh_t *)((char*)paliashdr + paliashdr->ofs_meshes);
Expand Down Expand Up @@ -344,6 +344,15 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
}
}

for (i = 0; i < 3; i++)
{
/* fix scale */
if (!currententity->scale[i])
{
currententity->scale[i] = 1.0f;
}
}

paliashdr = (dmdx_t *)currentmodel->extradata;

/* get lighting information */
Expand Down
15 changes: 13 additions & 2 deletions src/client/refresh/gl3/gl3_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight,

lerp = s_lerped[0];

R_LerpVerts(colorOnly, paliashdr->num_xyz, verts, ov, lerp, move, frontv, backv);
R_LerpVerts(colorOnly, paliashdr->num_xyz, verts, ov, lerp,
move, frontv, backv, entity->scale);

YQ2_STATIC_ASSERT(sizeof(gl3_alias_vtx_t) == 9 * sizeof(GLfloat), "invalid gl3_alias_vtx_t size");

Expand Down Expand Up @@ -477,7 +478,8 @@ DrawAliasShadow(gl3_shadowinfo_t* shadowInfo)

// false: don't extrude vertices for powerup - this means the powerup shell
// is not seen in the shadow, only the underlying model..
R_LerpVerts(false, paliashdr->num_xyz, verts, ov, s_lerped[0], move, frontv, backv);
R_LerpVerts(false, paliashdr->num_xyz, verts, ov, s_lerped[0],
move, frontv, backv, entity->scale);
}

lheight = entity->origin[2] - shadowInfo->lightspot[2];
Expand Down Expand Up @@ -554,6 +556,15 @@ GL3_DrawAliasModel(entity_t *entity)
}
}

for (i = 0; i < 3; i++)
{
/* fix scale */
if (!entity->scale[i])
{
entity->scale[i] = 1.0f;
}
}

gl3model_t* model = entity->model;
paliashdr = (dmdx_t *)model->extradata;

Expand Down
15 changes: 13 additions & 2 deletions src/client/refresh/gl4/gl4_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight,

lerp = s_lerped[0];

R_LerpVerts(colorOnly, paliashdr->num_xyz, verts, ov, lerp, move, frontv, backv);
R_LerpVerts(colorOnly, paliashdr->num_xyz, verts, ov, lerp,
move, frontv, backv, entity->scale);

YQ2_STATIC_ASSERT(sizeof(gl4_alias_vtx_t) == 9 * sizeof(GLfloat), "invalid gl4_alias_vtx_t size");

Expand Down Expand Up @@ -469,7 +470,8 @@ DrawAliasShadow(gl4_shadowinfo_t* shadowInfo)

// false: don't extrude vertices for powerup - this means the powerup shell
// is not seen in the shadow, only the underlying model..
R_LerpVerts(false, paliashdr->num_xyz, verts, ov, s_lerped[0], move, frontv, backv);
R_LerpVerts(false, paliashdr->num_xyz, verts, ov, s_lerped[0],
move, frontv, backv, entity->scale);
}

lheight = entity->origin[2] - shadowInfo->lightspot[2];
Expand Down Expand Up @@ -546,6 +548,15 @@ GL4_DrawAliasModel(entity_t *entity)
}
}

for (i = 0; i < 3; i++)
{
/* fix scale */
if (!entity->scale[i])
{
entity->scale[i] = 1.0f;
}
}

gl4model_t* model = entity->model;
paliashdr = (dmdx_t *)model->extradata;

Expand Down
2 changes: 1 addition & 1 deletion src/client/refresh/ref_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ extern qboolean R_CullAliasMeshModel(dmdx_t *paliashdr, cplane_t *frustum,
extern void R_LerpVerts(qboolean powerUpEffect, int nverts,
const dxtrivertx_t *v, const dxtrivertx_t *ov,
float *lerp, const float move[3],
const float frontv[3], const float backv[3]);
const float frontv[3], const float backv[3], const float *scale);
extern void R_ConvertNormalMDL(byte in_normal, signed char *normal);
extern vec4_t *R_VertBufferRealloc(int num);
extern void R_VertBufferInit(void);
Expand Down
19 changes: 16 additions & 3 deletions src/client/refresh/soft/sw_alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ R_AliasPreparePoints(const entity_t *currententity, finalvert_t *verts, const fi
RF_SHELL_HALF_DAM));

R_LerpVerts(colorOnly, s_pmdl->num_xyz, r_thisframe->verts, r_lastframe->verts,
s_lerped[0], r_lerp_move, r_lerp_frontv, r_lerp_backv);
s_lerped[0], r_lerp_move, r_lerp_frontv, r_lerp_backv, currententity->scale);

R_AliasTransformFinalVerts(s_pmdl->num_xyz,
verts, /* destination for transformed verts */
Expand Down Expand Up @@ -803,17 +803,21 @@ R_AliasDrawModel
void
R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel)
{
int i;

s_pmdl = (dmdx_t *)currentmodel->extradata;

if ( r_lerpmodels->value == 0 )
{
currententity->backlerp = 0;
}

float oldAliasxscale = aliasxscale;
float oldAliasyscale = aliasyscale;

if ( currententity->flags & RF_WEAPONMODEL )
if (currententity->flags & RF_WEAPONMODEL)
{
if ( r_lefthand->value == 2.0F )
if (r_lefthand->value == 2.0F)
{
return;
}
Expand All @@ -829,6 +833,15 @@ R_AliasDrawModel(entity_t *currententity, const model_t *currentmodel)
aliasxscale = -aliasxscale;
}

for (i = 0; i < 3; i++)
{
/* fix scale */
if (!currententity->scale[i])
{
currententity->scale[i] = 1.0f;
}
}

/*
** we have to set our frame pointers and transformations before
** doing any real work
Expand Down
11 changes: 10 additions & 1 deletion src/client/refresh/vk/vk_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp
}

R_LerpVerts(colorOnly, paliashdr->num_xyz, verts, ov, (float*)s_lerped,
move, frontv, backv);
move, frontv, backv, currententity->scale);

VkDescriptorSet descriptorSets[] = {
skin->vk_texture.descriptorSet,
Expand Down Expand Up @@ -535,6 +535,15 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
}
}

for (i = 0; i < 3; i++)
{
/* fix scale */
if (!currententity->scale[i])
{
currententity->scale[i] = 1.0f;
}
}

paliashdr = (dmdx_t *)currentmodel->extradata;

/* get lighting information */
Expand Down
9 changes: 3 additions & 6 deletions src/game/effects/fx_magicmissile.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
#include "utilities.h"
#include "../header/g_playstats.h"

static qboolean
FXMagicMissileTrailThink(struct client_entity_s *Self, centity_t *Owner);
static qboolean
FXMagicMissileModelThink1(struct client_entity_s *Self, centity_t *Owner);
static qboolean
FXMagicMissileModelThink2(struct client_entity_s *Self, centity_t *Owner);
static qboolean FXMagicMissileTrailThink(struct client_entity_s *Self, centity_t *Owner);
static qboolean FXMagicMissileModelThink1(struct client_entity_s *Self, centity_t *Owner);
static qboolean FXMagicMissileModelThink2(struct client_entity_s *Self, centity_t *Owner);

#define NUM_MISSILE_MODELS 3

Expand Down
2 changes: 1 addition & 1 deletion src/game/effects/fx_wall.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ FXFireWormThink(client_entity_t *worm, centity_t *owner)
blast->d_alpha = -0.5;
scale = 0.25 * AVG_VEC3T(worm->r.scale);
VectorSet(blast->r.scale, scale, scale, scale);
blast->d_scale = -3.0* AVG_VEC3T(worm->r.scale);
blast->d_scale = -3.0 * AVG_VEC3T(worm->r.scale);
VectorSet(blast->velocity,
flrand(-0.25*FIREWORM_BLASTVEL* AVG_VEC3T(worm->r.scale), 0.25*FIREWORM_BLASTVEL* AVG_VEC3T(worm->r.scale)),
flrand(-0.25*FIREWORM_BLASTVEL* AVG_VEC3T(worm->r.scale), 0.25*FIREWORM_BLASTVEL* AVG_VEC3T(worm->r.scale)),
Expand Down
45 changes: 24 additions & 21 deletions src/game/g_light.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,19 @@ void firemove_think(edict_t *self)

/*
* QUAKED env_fire (1 .5 0) (0 -10 -24) (20 10 0) INVULNERABLE ANIMATE EXPLODING FIRE_OFF MOVEABLE LIGHT_ON
A fire about the size of a campfire. Triggerable.
------- FIELDS ------------------
INVULNERABLE - N/A
ANIMATE - N/A
EXPLODING - N/A
FIRE_OFF - fire will start off
MOVEABLE - fire will move if given a velocity
LIGHT_ON - fire will have light attached to it - if moveable, not required
-----------------------------------
scale - size of flame (default 1) (no bigger than 8)
*/
* Heretic 2: Flame effect. Does not emit light.
* A fire about the size of a campfire. Triggerable.
*
* ------- FIELDS ------------------
* INVULNERABLE - N/A
* ANIMATE - N/A
* EXPLODING - N/A
* FIRE_OFF - fire will start off
* MOVEABLE - fire will move if given a velocity
* LIGHT_ON - fire will have light attached to it - if moveable, not required
* -----------------------------------
* scale - size of flame (default 1) (no bigger than 8)
*/
void
SP_env_fire(edict_t *self)
{
Expand Down Expand Up @@ -372,7 +374,7 @@ SP_env_fire(edict_t *self)
self->s.origin,
"b",scale);

create_fire_touch (self,self->s.origin);
create_fire_touch(self,self->s.origin);
}

static void TorchUse (edict_t *self, edict_t *other, edict_t *activator)
Expand Down Expand Up @@ -406,15 +408,16 @@ static void TorchStart (edict_t *self)

/*
* QUAKED light_walltorch (1 .5 0) (-16 -10 -12) (10 10 12) INVULNERABLE ANIMATE EXPLODING STARTOFF
A torch that sticks out of a wall
------- FIELDS ------------------
INVULNERABLE - N/A
ANIMATE - Places a flame on it
EXPLODING - N/A
STARTOFF - Light will start off if targeted (default is on)
-----------------------------------
*/
void SP_light_walltorch (edict_t *self)
* A torch that sticks out of a wall
* ------- FIELDS ------------------
* INVULNERABLE - N/A
* ANIMATE - Places a flame on it
* EXPLODING - N/A
* STARTOFF - Light will start off if targeted (default is on)
* -----------------------------------
*/
void
SP_light_walltorch(edict_t *self)
{
vec3_t holdorigin;

Expand Down
12 changes: 8 additions & 4 deletions src/game/g_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2606,13 +2606,17 @@ misc_flare_use(edict_t *ent, edict_t *other, edict_t *activator)
void
SP_misc_flare(edict_t* ent)
{
int i;

ent->s.modelindex = 0;
ent->s.renderfx = RF_FLARE;
ent->solid = SOLID_NOT;
/*
* TODO: Add scale field
* ent->s.scale = st.radius;
*/

/* Radius saved to scale */
for (i = 0; i < 3; i++)
{
ent->s.scale[i] = st.radius;
}

if (ent->spawnflags & SPAWNFLAG_FLARE_RED)
{
Expand Down
4 changes: 3 additions & 1 deletion src/game/g_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ barrel_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec
/*
* QUAKED object_flame1 (1 .5 .5) (-3 -3 -6) (3 3 11)
*
* Dawn of Darkness:
* "sounds"
* 0) no sound (default)
* 1) sound torch
Expand Down Expand Up @@ -5020,6 +5021,7 @@ void SP_obj_bloodsplat (edict_t *self)
/*
* QUAKED object_big_fire (1 .5 .5) (-3 -3 -6) (3 3 11)
*
* Dawn of Darkness:
* "sounds"
* 0) no sound (default)
* 1) sound campfire
Expand Down Expand Up @@ -5062,7 +5064,7 @@ SP_object_big_fire(edict_t *self)
/*
* QUAKED object_campfire (1 .5 .5) (-10 -10 -5) (10 10 5)
*
*
* Dawn of Darkness:
* "sounds"
* 0) no sound (default)
* 1) sound campfire
Expand Down
4 changes: 3 additions & 1 deletion src/game/g_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1563,9 +1563,11 @@ SP_trigger_monsterjump(edict_t *self)

/*
* QUAKED choose_cdtrack (.5 .5 .5) ? NO_LOOP
* Heretic 2: Sets CD track
*
* Variable sized repeatable trigger which chooses a CD track.
* ------KEYS-----------
* style - # of CD track to play
* style: CD Track Id
* NO_LOOP - allows you to set the track to play not to loop
*/
void
Expand Down
Loading

0 comments on commit f520148

Please sign in to comment.