mirror of
https://github.com/rehlds/reapi.git
synced 2024-12-28 15:45: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)
|
if (iBone < 0 || iBone >= pstudiohdr->numbones)
|
||||||
return; // invalid bone
|
return; // invalid bone
|
||||||
|
|
||||||
|
float flFrame = pEdict->v.frame;
|
||||||
|
float flAnimTime = pEdict->v.animtime;
|
||||||
|
|
||||||
// force to update frame
|
// force to update frame
|
||||||
StudioFrameAdvanceEnt(pstudiohdr, pEdict);
|
StudioFrameAdvanceEnt(pstudiohdr, pEdict);
|
||||||
|
|
||||||
@ -175,6 +178,10 @@ void GetBonePosition(CBaseEntity *pEntity, int iBone, Vector *pVecOrigin, Vector
|
|||||||
GET_BONE_POSITION(pEdict, iBone, vecOrigin, vecAngles);
|
GET_BONE_POSITION(pEdict, iBone, vecOrigin, vecAngles);
|
||||||
pEntity->pev->angles.x = -pEntity->pev->angles.x;
|
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
|
// ReGameDLL already have fixes angles for non-players entities
|
||||||
if (!g_ReGameApi && !pEntity->IsPlayer()) {
|
if (!g_ReGameApi && !pEntity->IsPlayer()) {
|
||||||
FixupAngles(pEdict, vecOrigin);
|
FixupAngles(pEdict, vecOrigin);
|
||||||
@ -204,11 +211,18 @@ void GetAttachment(CBaseEntity *pEntity, int iAttachment, Vector *pVecOrigin, Ve
|
|||||||
if (iAttachment < 0 || iAttachment >= pstudiohdr->numattachments)
|
if (iAttachment < 0 || iAttachment >= pstudiohdr->numattachments)
|
||||||
return; // invalid attachment
|
return; // invalid attachment
|
||||||
|
|
||||||
|
float flFrame = pEdict->v.frame;
|
||||||
|
float flAnimTime = pEdict->v.animtime;
|
||||||
|
|
||||||
// force to update frame
|
// force to update frame
|
||||||
StudioFrameAdvanceEnt(pstudiohdr, pEdict);
|
StudioFrameAdvanceEnt(pstudiohdr, pEdict);
|
||||||
|
|
||||||
GET_ATTACHMENT(pEdict, iAttachment, vecOrigin, vecAngles);
|
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
|
// ReGameDLL already have fixes angles for non-players entities
|
||||||
if (!g_ReGameApi && !pEntity->IsPlayer()) {
|
if (!g_ReGameApi && !pEntity->IsPlayer()) {
|
||||||
FixupAngles(pEdict, vecOrigin);
|
FixupAngles(pEdict, vecOrigin);
|
||||||
@ -281,7 +295,7 @@ bool GetSequenceInfo2(CBaseEntity *pEntity, int *piFlags, float *pflFrameRate, f
|
|||||||
*pflFrameRate = 256.0f;
|
*pflFrameRate = 256.0f;
|
||||||
*pflGroundSpeed = 0.0f;
|
*pflGroundSpeed = 0.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*pflFrameRate = pseqdesc->fps * 256.0f / (pseqdesc->numframes - 1);
|
*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]);
|
*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