From 84fde2cfe700ae19c8fe6dabbb072765dead2111 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Mon, 18 Nov 2024 01:17:13 +0200 Subject: [PATCH] initial scale --- src/client/cl_entities.c | 2 ++ src/client/cl_parse.c | 12 ++++++++++++ src/client/refresh/files/mesh.c | 16 +++++++++++----- src/client/refresh/gl1/gl1_mesh.c | 2 +- src/client/refresh/gl3/gl3_mesh.c | 6 ++++-- src/client/refresh/gl4/gl4_mesh.c | 6 ++++-- src/client/refresh/ref_shared.h | 2 +- src/client/refresh/soft/sw_alias.c | 2 +- src/client/refresh/vk/vk_main.c | 2 +- src/client/refresh/vk/vk_mesh.c | 2 +- src/client/vid/header/ref.h | 1 + src/common/cmodels.c | 1 + src/common/header/shared.h | 1 + src/common/movemsg.c | 15 +++++++++++++++ src/game/g_misc.c | 12 ++++++++---- 15 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/client/cl_entities.c b/src/client/cl_entities.c index d3cb1d98..555ce7fb 100644 --- a/src/client/cl_entities.c +++ b/src/client/cl_entities.c @@ -198,6 +198,8 @@ CL_AddPacketEntities(frame_t *frame) ent.skin = NULL; ent.model = cl.model_draw[s1->modelindex]; } + /* store scale */ + ent.scale = s1->scale[0]; } /* only used for black hole model right now */ diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c index 0554e728..57c45452 100644 --- a/src/client/cl_parse.c +++ b/src/client/cl_parse.c @@ -143,6 +143,12 @@ 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) + { + /* Always set scale to 1.0f for old clients */ + to->scale[0] = 1.0f; + } + if (IS_QII97_PROTOCOL(cls.serverProtocol)) { if (bits & U_MODEL) @@ -210,6 +216,12 @@ 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) + { + to->scale[0] = MSG_ReadFloat(&net_message); + printf("received scale %f\n", to->scale[0]); + } } else if (bits & U_SKIN8) { diff --git a/src/client/refresh/files/mesh.c b/src/client/refresh/files/mesh.c index e0a7eae0..4d8b0c1f 100644 --- a/src/client/refresh/files/mesh.c +++ b/src/client/refresh/files/mesh.c @@ -95,10 +95,16 @@ 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], float scale) { int i; + /* If scale is undefined, set scale 1.0f */ + if (!scale) + { + scale = 1.0f; + } + if (powerUpEffect) { for (i = 0; i < nverts; i++, v++, ov++, lerp += 4) @@ -111,7 +117,7 @@ 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 * (move[n] + ov->v[n] * backv[n] + v->v[n] * frontv[n]) + normal * POWERSUIT_SCALE; } } @@ -120,9 +126,9 @@ R_LerpVerts(qboolean powerUpEffect, int nverts, { 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]; + lerp[0] = scale * (move[0] + ov->v[0] * backv[0] + v->v[0] * frontv[0]); + lerp[1] = scale * (move[1] + ov->v[1] * backv[1] + v->v[1] * frontv[1]); + lerp[2] = scale * (move[2] + ov->v[2] * backv[2] + v->v[2] * frontv[2]); } } } diff --git a/src/client/refresh/gl1/gl1_mesh.c b/src/client/refresh/gl1/gl1_mesh.c index f39e53a8..b3f51ace 100644 --- a/src/client/refresh/gl1/gl1_mesh.c +++ b/src/client/refresh/gl1/gl1_mesh.c @@ -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); diff --git a/src/client/refresh/gl3/gl3_mesh.c b/src/client/refresh/gl3/gl3_mesh.c index fe690a02..6d0b4744 100644 --- a/src/client/refresh/gl3/gl3_mesh.c +++ b/src/client/refresh/gl3/gl3_mesh.c @@ -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]; diff --git a/src/client/refresh/gl4/gl4_mesh.c b/src/client/refresh/gl4/gl4_mesh.c index cf302431..17577251 100644 --- a/src/client/refresh/gl4/gl4_mesh.c +++ b/src/client/refresh/gl4/gl4_mesh.c @@ -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]; diff --git a/src/client/refresh/ref_shared.h b/src/client/refresh/ref_shared.h index dc09728e..a5edad3a 100644 --- a/src/client/refresh/ref_shared.h +++ b/src/client/refresh/ref_shared.h @@ -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], float scale); extern void R_ConvertNormalMDL(byte in_normal, signed char *normal); extern vec4_t *R_VertBufferRealloc(int num); extern void R_VertBufferInit(void); diff --git a/src/client/refresh/soft/sw_alias.c b/src/client/refresh/soft/sw_alias.c index 32b74797..58fd22da 100644 --- a/src/client/refresh/soft/sw_alias.c +++ b/src/client/refresh/soft/sw_alias.c @@ -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 */ diff --git a/src/client/refresh/vk/vk_main.c b/src/client/refresh/vk/vk_main.c index b87aee21..4c82986f 100644 --- a/src/client/refresh/vk/vk_main.c +++ b/src/client/refresh/vk/vk_main.c @@ -979,7 +979,7 @@ RE_RenderView(refdef_t *fd) R_DrawAlphaSurfaces(); - R_Flash(); + R_Flash(); /* citadel error */ if (r_speeds->value) { diff --git a/src/client/refresh/vk/vk_mesh.c b/src/client/refresh/vk/vk_mesh.c index c0817e28..de92db8d 100644 --- a/src/client/refresh/vk/vk_mesh.c +++ b/src/client/refresh/vk/vk_mesh.c @@ -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, diff --git a/src/client/vid/header/ref.h b/src/client/vid/header/ref.h index 43e0c810..22a88c6f 100644 --- a/src/client/vid/header/ref.h +++ b/src/client/vid/header/ref.h @@ -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 */ + float scale; int lightstyle; /* for flashing entities */ float alpha; /* ignore if RF_TRANSLUCENT isn't set */ diff --git a/src/common/cmodels.c b/src/common/cmodels.c index e235d0bd..0e87dfeb 100644 --- a/src/common/cmodels.c +++ b/src/common/cmodels.c @@ -69,6 +69,7 @@ Mod_LoadVisibility(const char *name, dvis_t **vis, int *numvisibility, if (!l->filelen) { + /* n64jam_chnuckierdbeer */ Com_Printf("%s: Map %s has too small visibility lump\n", __func__, name); *vis = NULL; diff --git a/src/common/header/shared.h b/src/common/header/shared.h index a71da662..14ee4322 100644 --- a/src/common/header/shared.h +++ b/src/common/header/shared.h @@ -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; diff --git a/src/common/movemsg.c b/src/common/movemsg.c index d7dcbc1e..a1ee4db8 100644 --- a/src/common/movemsg.c +++ b/src/common/movemsg.c @@ -505,6 +505,13 @@ MSG_WriteDeltaEntity(entity_state_t *from, } } + /* Scale with skins if force or different */ + if ((protocol == PROTOCOL_VERSION) && + ((to->scale != from->scale) || force)) + { + bits |= (U_SKIN8 | U_SKIN16); + } + if (to->frame != from->frame) { if (to->frame < 256) @@ -720,6 +727,14 @@ 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) + { + to->scale[0] = 1.5f; + MSG_WriteFloat(msg, to->scale[0]); + printf("send scale %f\n", to->scale[0]); + } } else if (bits & U_SKIN8) diff --git a/src/game/g_misc.c b/src/game/g_misc.c index 7b68e195..95abdcdf 100644 --- a/src/game/g_misc.c +++ b/src/game/g_misc.c @@ -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) {