2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-01-16 00:28:17 +03:00

GetAttachment/GetBonePosition: Restore preserved animtime/frame after advancing studio entity

This commit is contained in:
s1lentq 2024-08-27 21:15:04 +07:00
parent 592ebca528
commit 8c220a7de5

View File

@ -168,6 +168,9 @@ void GetBonePosition(CBaseEntity *pEntity, int iBone, Vector *pVecOrigin, Vector
if (iBone < 0 || iBone >= pstudiohdr->numbones)
return; // invalid bone
float flFrame = pEdict->v.frame;
float flAnimTime = pEdict->v.animtime;
// force to update frame
StudioFrameAdvanceEnt(pstudiohdr, pEdict);
@ -175,6 +178,10 @@ void GetBonePosition(CBaseEntity *pEntity, int iBone, Vector *pVecOrigin, Vector
GET_BONE_POSITION(pEdict, iBone, vecOrigin, vecAngles);
pEntity->pev->angles.x = -pEntity->pev->angles.x;
// restore the original state for the entity
pEdict->v.frame = flFrame;
pEdict->v.animtime = flAnimTime;
// ReGameDLL already have fixes angles for non-players entities
if (!g_ReGameApi && !pEntity->IsPlayer()) {
FixupAngles(pEdict, vecOrigin);
@ -204,11 +211,18 @@ void GetAttachment(CBaseEntity *pEntity, int iAttachment, Vector *pVecOrigin, Ve
if (iAttachment < 0 || iAttachment >= pstudiohdr->numattachments)
return; // invalid attachment
float flFrame = pEdict->v.frame;
float flAnimTime = pEdict->v.animtime;
// force to update frame
StudioFrameAdvanceEnt(pstudiohdr, pEdict);
GET_ATTACHMENT(pEdict, iAttachment, vecOrigin, vecAngles);
// restore the original state for the entity
pEdict->v.frame = flFrame;
pEdict->v.animtime = flAnimTime;
// ReGameDLL already have fixes angles for non-players entities
if (!g_ReGameApi && !pEntity->IsPlayer()) {
FixupAngles(pEdict, vecOrigin);