diff --git a/rehlds/engine/r_studio.cpp b/rehlds/engine/r_studio.cpp index a6e625b..5ac33f2 100644 --- a/rehlds/engine/r_studio.cpp +++ b/rehlds/engine/r_studio.cpp @@ -59,6 +59,7 @@ r_studiocache_t rgStudioCache[STUDIO_CACHE_SIZE]; int nCurrentHull; int nCurrentPlane; int r_cachecurrent; +int g_studio_numhulls; int studio_hull_hitgroup[STUDIO_NUM_HULLS]; hull_t studio_hull[STUDIO_NUM_HULLS]; @@ -704,6 +705,8 @@ hull_t *R_StudioHull(model_t *pModel, float frame, int sequence, const vec_t *an } *pNumHulls = (bSkipShield == 1) ? pstudiohdr->numhitboxes - 1 : pstudiohdr->numhitboxes; + g_studio_numhulls = *pNumHulls; + if (r_cachestudio.value != 0) { #ifdef SWDS diff --git a/rehlds/engine/studio_rehlds.h b/rehlds/engine/studio_rehlds.h index a52ee38..631fb7f 100644 --- a/rehlds/engine/studio_rehlds.h +++ b/rehlds/engine/studio_rehlds.h @@ -105,3 +105,6 @@ void R_StudioAccumulateBoneVerts(vec_t *mins, vec_t *maxs, int *vertcount, vec_t int R_StudioComputeBounds(unsigned char *pBuffer, float *mins, float *maxs); int R_GetStudioBounds(const char *filename, float *mins, float *maxs); void R_ResetSvBlending(void); + + +extern int g_studio_numhulls; diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 3bb74c7..0cabb1a 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -199,7 +199,7 @@ struct RehldsFuncs_t { void(*MSG_WriteBitVec3Coord)(const float *fa); void(*MSG_EndBitWriting)(sizebuf_t *buf); void*(*SZ_GetSpace)(sizebuf_t *buf, int length); - bool(*GetHitboxCorners)(int hitboxId, float* /* [8*3] */ corners); + bool(*GetHitboxCorners)(int hitboxId, float* /* [8*3] */ corners, int* pGroupId); }; class IRehldsApi { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 7c6da87..7240a2f 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -65,7 +65,11 @@ DLL_FUNCTIONS* EXT_FUNC GetEntityInterface_api() { return &gEntityInterface; } -bool EXT_FUNC GetHitboxCorners(int hitboxId, float* /* [8*3] */ corners) { +bool EXT_FUNC GetHitboxCorners(int hitboxId, float* /* [8*3] */ corners, int* pGroupId) { + if (hitboxId < 0 || hitboxId >= g_studio_numhulls) { + return false; + } + mplane_t* right = &studio_planes[hitboxId * 6 + 0 * 2 + 0]; mplane_t* left = &studio_planes[hitboxId * 6 + 0 * 2 + 1]; mplane_t* rear = &studio_planes[hitboxId * 6 + 1 * 2 + 0]; @@ -108,6 +112,10 @@ bool EXT_FUNC GetHitboxCorners(int hitboxId, float* /* [8*3] */ corners) { return false; corners[7 * 3 + 0] = p[0]; corners[7 * 3 + 1] = p[1]; corners[7 * 3 + 2] = p[2]; + if (pGroupId) { + *pGroupId = studio_hull_hitgroup[hitboxId]; + } + return true; } diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 5362878..ef22f06 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -31,7 +31,7 @@ #include "rehlds_api.h" #include "rehlds_interfaces_impl.h" -extern bool GetHitboxCorners(int hitboxId, float* /* [8*3] */ corners); +extern bool GetHitboxCorners(int hitboxId, float* /* [8*3] */ corners, int* pGroupId); //Steam_NotifyClientConnect typedef IHookChainImpl CRehldsHook_Steam_NotifyClientConnect;