mirror of
https://github.com/rehlds/reapi.git
synced 2024-12-28 07:35:31 +03:00
GetAttachment/GetBonePosition: Restore preserved animtime/frame after advancing studio entity
This commit is contained in:
parent
592ebca528
commit
8c220a7de5
@ -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);
|
||||
@ -281,7 +295,7 @@ bool GetSequenceInfo2(CBaseEntity *pEntity, int *piFlags, float *pflFrameRate, f
|
||||
*pflFrameRate = 256.0f;
|
||||
*pflGroundSpeed = 0.0f;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
*pflFrameRate = pseqdesc->fps * 256.0f / (pseqdesc->numframes - 1);
|
||||
*pflGroundSpeed = Q_sqrt(pseqdesc->linearmovement[0] * pseqdesc->linearmovement[0] + pseqdesc->linearmovement[1] * pseqdesc->linearmovement[1] + pseqdesc->linearmovement[2] * pseqdesc->linearmovement[2]);
|
||||
|
Loading…
Reference in New Issue
Block a user