renders: Add initial scale logic in renders

Based on rerelease code.

Checked with monster_boss2 on mgu1m3 map.
This commit is contained in:
Denis Pauk 2024-11-19 00:19:29 +02:00
parent ddda42244d
commit e0ea452e9a
18 changed files with 173 additions and 24 deletions

View file

@ -198,6 +198,9 @@ CL_AddPacketEntities(frame_t *frame)
ent.skin = NULL;
ent.model = cl.model_draw[s1->modelindex];
}
/* store scale */
VectorCopy(s1->scale, ent.scale);
}
/* only used for black hole model right now */

View file

@ -143,6 +143,17 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits)
VectorCopy(from->origin, to->old_origin);
to->number = number;
if (cls.serverProtocol != PROTOCOL_VERSION)
{
int i;
/* Always set scale to 1.0f for old clients */
for (i = 0; i < 3; i++)
{
to->scale[i] = 1.0f;
}
}
if (IS_QII97_PROTOCOL(cls.serverProtocol))
{
if (bits & U_MODEL)
@ -210,6 +221,16 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits)
if ((bits & U_SKIN8) && (bits & U_SKIN16))
{
to->skinnum = MSG_ReadLong(&net_message);
/* Additional scale with skinnum */
if (cls.serverProtocol == PROTOCOL_VERSION)
{
int i;
for (i = 0; i < 3; i++)
{
to->scale[i] = MSG_ReadFloat(&net_message);
}
}
}
else if (bits & U_SKIN8)
{

View file

@ -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;
@ -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]);
}
}
}
}

View file

@ -174,7 +174,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);
@ -338,6 +338,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 */

View file

@ -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(gl3_alias_vtx_t) == 9 * sizeof(GLfloat), "invalid gl3_alias_vtx_t size");
@ -469,7 +470,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];
@ -546,6 +548,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;

View file

@ -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");
@ -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];
@ -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;

View file

@ -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);

View file

@ -457,7 +457,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 */
@ -795,17 +795,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;
}
@ -821,6 +825,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

View file

@ -359,7 +359,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,
@ -527,6 +527,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 */

View file

@ -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 */

View file

@ -1222,6 +1222,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;
} entity_state_t;

View file

@ -505,6 +505,15 @@ MSG_WriteDeltaEntity(entity_state_t *from,
}
}
/* Scale with skins if force or different */
if ((protocol == PROTOCOL_VERSION) &&
((to->scale[0] != from->scale[0]) ||
(to->scale[1] != from->scale[1]) ||
(to->scale[2] != from->scale[2])))
{
bits |= (U_SKIN8 | U_SKIN16);
}
if (to->frame != from->frame)
{
if (to->frame < 256)
@ -720,6 +729,17 @@ MSG_WriteDeltaEntity(entity_state_t *from,
if ((bits & U_SKIN8) && (bits & U_SKIN16)) /*used for laser colors */
{
MSG_WriteLong(msg, to->skinnum);
/* Send scale */
if (protocol == PROTOCOL_VERSION)
{
int i;
for (i = 0; i < 3; i++)
{
MSG_WriteFloat(msg, to->scale[i]);
}
}
}
else if (bits & U_SKIN8)

View file

@ -39,7 +39,7 @@ env_fire_think(edict_t *self)
/*
* QUAKED env_fire (.3 .3 1.0) (-8 -8 -8) (8 8 8)
* Flame effect. Does not emit light
* Heretic 2: Flame effect. Does not emit light.
*/
void
SP_env_fire(edict_t *self)

View file

@ -3297,13 +3297,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)
{

View file

@ -1073,6 +1073,9 @@ monster_death_use(edict_t *self)
qboolean
monster_start(edict_t *self)
{
float scale;
int i;
if (!self)
{
return false;
@ -1129,6 +1132,37 @@ monster_start(edict_t *self)
self->monsterinfo.checkattack = M_CheckAttack;
}
scale = 0;
for (i = 0; i < 3; i++)
{
if (!self->s.scale[i])
{
/* fix empty scale */
self->s.scale[i] = 1.0f;
}
scale += self->s.scale[i];
}
scale /= 3;
/* non default scale */
if (scale != 1.0)
{
int i;
self->monsterinfo.scale *= scale;
self->mass *= scale;
for (i = 0; i < 3; i++)
{
self->mins[i] *= self->s.scale[i];
self->maxs[i] *= self->s.scale[i];
}
}
VectorCopy(self->s.origin, self->s.old_origin);
if (st.item)

View file

@ -30,6 +30,7 @@
/*
* QUAKED object_flame1 (1 .5 .5) (-3 -3 -6) (3 3 11)
*
* Dawn of Darkness:
* "sounds"
* 0) no sound (default)
* 1) sound torch
@ -70,6 +71,7 @@ SP_object_flame1(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
@ -112,7 +114,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

View file

@ -2120,6 +2120,7 @@ DynamicSpawnInit(void)
if (*curr && *curr != '\n' && *curr != '\r' && *curr != ',')
{
char *line, scale[MAX_QPATH];
int i;
line = curr;
line = DynamicStringParse(line, dynamicentities[curr_pos].classname, MAX_QPATH, ',');
@ -2181,6 +2182,10 @@ DynamicSpawnInit(void)
* max attenuation
*/
for (i = 0; i < 3; i++)
{
dynamicentities[curr_pos].scale[i] = 1.0f;
}
/* Fix path */
Q_replacebackslash(dynamicentities[curr_pos].model_path);

View file

@ -1127,7 +1127,7 @@ SP_trigger_monsterjump(edict_t *self)
/*
* QUAKED choose_cdtrack (.5 .5 .5) ?
* Sets CD track
* HEretic 2: Sets CD track
*
* style: CD Track Id
*/