From 1d7d974d88b13bde77086f8846c5f7fe14887393 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Sun, 30 Jul 2023 15:11:01 +0200 Subject: [PATCH] Store bone positions inside array from StudioRenderModel --- src/globals.c | 3 +++ src/hooks.c | 8 ++++++++ src/include/globals.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/globals.c b/src/globals.c index f8ca6ce..536b5cb 100644 --- a/src/globals.c +++ b/src/globals.c @@ -10,6 +10,9 @@ enum game_id this_game_id = HL; +/* Bone origins of each player, updated in studiorendermodel */ +vec3_t g_bones[64][128]; + void* hw; void** h_client; DECL_INTF(cl_enginefunc_t, engine); diff --git a/src/hooks.c b/src/hooks.c index 1a36830..d52ba95 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -81,6 +81,14 @@ int h_HUD_Redraw(float time, int intermission) { /*----------------------------------------------------------------------------*/ void h_StudioRenderModel(void* this_ptr) { + /* Update bones array */ + cl_entity_t* ent = i_enginestudio->GetCurrentEntity(); + bone_matrix* mat = (bone_matrix*)i_enginestudio->StudioGetBoneTransform(); + for (int i = 0; i < 128; i++) { + const vec3_t bone_orig = matrix_3x4_origin((*mat)[i]); + vec_copy(g_bones[ent->index][i], bone_orig); + } + if (!chams(this_ptr)) ORIGINAL(StudioRenderModel, this_ptr); } diff --git a/src/include/globals.h b/src/include/globals.h index 573a933..cf07481 100644 --- a/src/include/globals.h +++ b/src/include/globals.h @@ -34,6 +34,7 @@ enum game_id { /*----------------------------------------------------------------------------*/ extern game_id this_game_id; +extern vec3_t g_bones[64][128]; extern void* hw; extern void** h_client; /* hClientDLL hander */