From 129b6ea7f40e28f3a0f06be3c355d45f4eb08b10 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Tue, 19 Nov 2024 00:02:51 +0200 Subject: [PATCH] broken scale --- src/client/cl_entities.c | 3 ++- src/client/cl_parse.c | 18 +++++++++++++++--- src/client/refresh/files/mesh.c | 25 ++++++++++++++++--------- src/client/refresh/gl1/gl1_mesh.c | 9 +++++++++ src/client/refresh/gl3/gl3_mesh.c | 9 +++++++++ src/client/refresh/gl4/gl4_mesh.c | 9 +++++++++ src/client/refresh/ref_shared.h | 2 +- src/client/refresh/soft/sw_alias.c | 17 +++++++++++++++-- src/client/refresh/vk/vk_mesh.c | 9 +++++++++ src/client/vid/header/ref.h | 2 +- src/common/movemsg.c | 12 +++++++++--- 11 files changed, 95 insertions(+), 20 deletions(-) diff --git a/src/client/cl_entities.c b/src/client/cl_entities.c index 555ce7fb..a0e41c8f 100644 --- a/src/client/cl_entities.c +++ b/src/client/cl_entities.c @@ -198,8 +198,9 @@ CL_AddPacketEntities(frame_t *frame) ent.skin = NULL; ent.model = cl.model_draw[s1->modelindex]; } + /* store scale */ - ent.scale = s1->scale[0]; + VectorCopy(s1->scale, ent.scale); } /* only used for black hole model right now */ diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c index 57c45452..2990c1f3 100644 --- a/src/client/cl_parse.c +++ b/src/client/cl_parse.c @@ -145,8 +145,13 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits) if (cls.serverProtocol != PROTOCOL_VERSION) { + int i; + /* Always set scale to 1.0f for old clients */ - to->scale[0] = 1.0f; + for (i = 0; i < 3; i++) + { + to->scale[i] = 1.0f; + } } if (IS_QII97_PROTOCOL(cls.serverProtocol)) @@ -219,8 +224,15 @@ CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits) /* Additional scale with skinnum */ if (cls.serverProtocol == PROTOCOL_VERSION) { - to->scale[0] = MSG_ReadFloat(&net_message); - printf("received scale %f\n", to->scale[0]); + int i; + + for (i = 0; i < 3; i++) + { + to->scale[i] = MSG_ReadFloat(&net_message); + } + + printf("received scale %.2fx%.2fx%.2f\n", + to->scale[0], to->scale[1], to->scale[2]); } } else if (bits & U_SKIN8) diff --git a/src/client/refresh/files/mesh.c b/src/client/refresh/files/mesh.c index 4d8b0c1f..6089f312 100644 --- a/src/client/refresh/files/mesh.c +++ b/src/client/refresh/files/mesh.c @@ -95,18 +95,20 @@ 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], float scale) + const float frontv[3], const float backv[3], const float *scale) { - int i; + vec3_t new_scale = {1.0, 1.0, 1.0}; + scale = new_scale; - /* If scale is undefined, set scale 1.0f */ - if (!scale) + if (!scale[0] || !scale[1] || !scale[2]) { - scale = 1.0f; + printf("model without scale\n"); } if (powerUpEffect) { + int i; + for (i = 0; i < nverts; i++, v++, ov++, lerp += 4) { int n; @@ -117,18 +119,23 @@ R_LerpVerts(qboolean powerUpEffect, int nverts, normal = v->normal[n] / 127.f; - lerp[n] = scale * (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] = 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]); + int n; + + for (n = 0; n < 3; n++) + { + lerp[n] = scale[n] * (move[n] + ov->v[n] * backv[n] + v->v[n] * frontv[n]); + } } } } diff --git a/src/client/refresh/gl1/gl1_mesh.c b/src/client/refresh/gl1/gl1_mesh.c index b3f51ace..c2c42088 100644 --- a/src/client/refresh/gl1/gl1_mesh.c +++ b/src/client/refresh/gl1/gl1_mesh.c @@ -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 */ diff --git a/src/client/refresh/gl3/gl3_mesh.c b/src/client/refresh/gl3/gl3_mesh.c index 6d0b4744..0ff9e889 100644 --- a/src/client/refresh/gl3/gl3_mesh.c +++ b/src/client/refresh/gl3/gl3_mesh.c @@ -548,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; diff --git a/src/client/refresh/gl4/gl4_mesh.c b/src/client/refresh/gl4/gl4_mesh.c index 17577251..a8f789a2 100644 --- a/src/client/refresh/gl4/gl4_mesh.c +++ b/src/client/refresh/gl4/gl4_mesh.c @@ -548,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; diff --git a/src/client/refresh/ref_shared.h b/src/client/refresh/ref_shared.h index a5edad3a..d41392f2 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], float scale); + 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); diff --git a/src/client/refresh/soft/sw_alias.c b/src/client/refresh/soft/sw_alias.c index 58fd22da..185071f5 100644 --- a/src/client/refresh/soft/sw_alias.c +++ b/src/client/refresh/soft/sw_alias.c @@ -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 diff --git a/src/client/refresh/vk/vk_mesh.c b/src/client/refresh/vk/vk_mesh.c index de92db8d..4ba2759c 100644 --- a/src/client/refresh/vk/vk_mesh.c +++ b/src/client/refresh/vk/vk_mesh.c @@ -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 */ diff --git a/src/client/vid/header/ref.h b/src/client/vid/header/ref.h index 22a88c6f..2b7c5e9c 100644 --- a/src/client/vid/header/ref.h +++ b/src/client/vid/header/ref.h @@ -68,7 +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; + vec3_t scale; /* model scale before render */ int lightstyle; /* for flashing entities */ float alpha; /* ignore if RF_TRANSLUCENT isn't set */ diff --git a/src/common/movemsg.c b/src/common/movemsg.c index a1ee4db8..d4b25412 100644 --- a/src/common/movemsg.c +++ b/src/common/movemsg.c @@ -731,9 +731,15 @@ MSG_WriteDeltaEntity(entity_state_t *from, /* 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]); + int i; + + for (i = 0; i < 3; i++) + { + MSG_WriteFloat(msg, to->scale[i]); + } + + printf("send scale %.2fx%.2fx%.2f\n", + to->scale[0], to->scale[1], to->scale[2]); } }