Rearrange how we execute and time our player animation logic
This commit is contained in:
parent
94762dfa89
commit
44ab18793c
13 changed files with 37 additions and 111 deletions
|
@ -24,3 +24,8 @@ ClientGame_EntityUpdate(float id, float new)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ClientGame_EntityRemove(void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -74,7 +74,6 @@ GameRules::LevelNewParms(void)
|
|||
void
|
||||
GameRules::PlayerPostFrame(base_player pl)
|
||||
{
|
||||
Animation_PlayerUpdate();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -13,6 +13,3 @@
|
|||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
void Animation_PlayerTop(float);
|
||||
void Animation_PlayerTopTemp(float, float);
|
||||
|
|
|
@ -14,6 +14,11 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
void
|
||||
Animation_TimerUpdate(player pl)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Animation_PlayerUpdate
|
||||
|
@ -23,25 +28,7 @@ depending on what the player is doing
|
|||
=================
|
||||
*/
|
||||
void
|
||||
Animation_PlayerUpdate(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Animation_PlayerTop
|
||||
|
||||
Changes the animation sequence for the upper body part
|
||||
=================
|
||||
*/
|
||||
void
|
||||
Animation_PlayerTop(float fFrame)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Animation_PlayerTopTemp(float fFrame, float fTime)
|
||||
Animation_PlayerUpdate(player pl)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ class player:base_player
|
|||
int p_model_bone;
|
||||
float lastweapon;
|
||||
|
||||
virtual void(void) gun_offset;
|
||||
virtual void(void) draw;
|
||||
virtual float() predraw;
|
||||
virtual void(void) postdraw;
|
||||
|
|
|
@ -129,6 +129,7 @@ struct
|
|||
void(void) m_pEventCall;
|
||||
float m_flEventTime;
|
||||
float m_flEventFrame;
|
||||
float m_flEventMdl;
|
||||
|
||||
int m_iLastWeapon;
|
||||
int m_iOldWeapon;
|
||||
|
|
|
@ -1043,6 +1043,21 @@ CSQC_WorldLoaded(void)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CSQC_Ent_Remove
|
||||
|
||||
Whenever an entity gets removed from the server and will no longer
|
||||
receive entity updates.
|
||||
=================
|
||||
*/
|
||||
void
|
||||
CSQC_Ent_Remove(void)
|
||||
{
|
||||
ClientGame_EntityRemove();
|
||||
remove(self);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CSQC_Shutdown
|
||||
|
|
|
@ -124,6 +124,8 @@ Event_Callback(float mtime, __inout float btime)
|
|||
|
||||
if (pSeat->m_flEventFrame != pSeat->m_eViewModel.frame)
|
||||
return;
|
||||
if (pSeat->m_flEventMdl != pSeat->m_eViewModel.modelindex)
|
||||
return;
|
||||
|
||||
/* only play once */
|
||||
if (mtime == btime)
|
||||
|
|
|
@ -14,94 +14,11 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
.float subblend2frac; // Up/Down
|
||||
|
||||
void
|
||||
player::gun_offset(void)
|
||||
{
|
||||
vector v1, v2;
|
||||
/* Set it to something consistent */
|
||||
this.p_model.angles = this.angles;
|
||||
|
||||
/* Updates the v_ globals for the player hand bone angle */
|
||||
gettaginfo(this, this.p_hand_bone);
|
||||
|
||||
/* Create angles from the v_ matrix */
|
||||
v1 = vectoangles(v_right, v_up);
|
||||
|
||||
/* Updates the v_ globals for the weapon hand bone angle */
|
||||
gettaginfo(this.p_model, this.p_model_bone);
|
||||
v2 = vectoangles(v_right, v_up);
|
||||
|
||||
/* The difference is applied */
|
||||
this.p_model.angles = this.angles + (v1 - v2);
|
||||
|
||||
/* Fix the origin */
|
||||
setorigin(this.p_model, this.origin);
|
||||
vector ofs = gettaginfo(this.p_model, this.p_model_bone) - gettaginfo(this, this.p_hand_bone);
|
||||
setorigin(this.p_model, this.origin - ofs);
|
||||
}
|
||||
|
||||
string Weapons_GetPlayermodel(int);
|
||||
|
||||
void
|
||||
player::draw(void)
|
||||
{
|
||||
if (!this.p_model) {
|
||||
this.p_model = spawn();
|
||||
this.p_model.classname = "pmodel";
|
||||
this.p_model.owner = this;
|
||||
}
|
||||
|
||||
this.subblendfrac =
|
||||
this.subblend2frac = (this.pitch / 90);
|
||||
|
||||
Animation_PlayerUpdate();
|
||||
|
||||
makevectors([0, this.angles[1], 0]);
|
||||
float fDirection = dotproduct(this.velocity, v_forward);
|
||||
|
||||
if (fDirection < 0) {
|
||||
this.baseframe1time -= clframetime;
|
||||
this.baseframe2time -= clframetime;
|
||||
this.frame2time -= clframetime;
|
||||
this.frame1time -= clframetime;
|
||||
} else {
|
||||
this.baseframe1time += clframetime;
|
||||
this.baseframe2time += clframetime;
|
||||
this.frame2time += clframetime;
|
||||
this.frame1time += clframetime;
|
||||
}
|
||||
this.bonecontrol5 = getplayerkeyfloat(this.entnum - 1, "voiploudness");
|
||||
|
||||
makevectors([0, this.angles[1], 0]);
|
||||
float fCorrect = dotproduct(this.velocity, v_right) * 0.25f;
|
||||
|
||||
#ifdef CSTRIKE
|
||||
/* hack, we can't play the animations in reverse the normal way */
|
||||
if (this.frame1time < 0.0f) {
|
||||
this.frame1time = 10.0f;
|
||||
}
|
||||
|
||||
this.subblendfrac = -fCorrect * 0.05f;
|
||||
//this.subblend2frac *= -0.1f;
|
||||
this.angles[1] -= fCorrect;
|
||||
#else
|
||||
/* hack, we can't play the animations in reverse the normal way */
|
||||
if (this.baseframe1time < 0.0f) {
|
||||
this.baseframe1time = 10.0f;
|
||||
}
|
||||
|
||||
/* Turn torso */
|
||||
this.bonecontrol1 = fCorrect;
|
||||
this.bonecontrol2 = this.bonecontrol1 * 0.5;
|
||||
this.bonecontrol3 = this.bonecontrol2 * 0.5;
|
||||
this.bonecontrol4 = this.bonecontrol3 * 0.5;
|
||||
|
||||
/* Correct the legs */
|
||||
this.angles[1] -= fCorrect;
|
||||
#endif
|
||||
|
||||
if (cvar("bonetest") == 1) {
|
||||
this.bonecontrol1 = cvar("bonecontrol1");
|
||||
this.bonecontrol2 = cvar("bonecontrol2");
|
||||
|
@ -120,18 +37,15 @@ player::predraw(void)
|
|||
{
|
||||
/* Run animations regardless of rendering the player */
|
||||
draw();
|
||||
gun_offset();
|
||||
effects &= ~EF_NOSHADOW;
|
||||
|
||||
if (autocvar_cl_thirdperson == TRUE || this.entnum != player_localentnum) {
|
||||
Voice_Draw3D(this);
|
||||
Player_PreDraw(this, TRUE);
|
||||
addentity(this);
|
||||
addentity(this.p_model);
|
||||
} else {
|
||||
Player_PreDraw(this, FALSE);
|
||||
removeentity(this);
|
||||
removeentity(this.p_model);
|
||||
}
|
||||
return PREDRAW_NEXT;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ Propagate our pmove state to whatever the current frame before its stomped on
|
|||
*/
|
||||
void
|
||||
Predict_SpectatorPreFrame(spectator pl)
|
||||
{
|
||||
{
|
||||
pl.PreFrame();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ View_AddEvent(void(void) pCallback, float flTime)
|
|||
pSeat->m_pEventCall = pCallback;
|
||||
pSeat->m_flEventTime = flTime;
|
||||
pSeat->m_flEventFrame = pSeat->m_eViewModel.frame;
|
||||
pSeat->m_flEventMdl = pSeat->m_eViewModel.modelindex;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -107,6 +107,8 @@ Materials_FixName(string tex_name)
|
|||
/* also not allowed */
|
||||
if (str2chr(tex_name, 0) == '~')
|
||||
tex_name = substring(tex_name, 1, -1);
|
||||
else if (str2chr(tex_name, 0) == '{')
|
||||
tex_name = substring(tex_name, 1, -1);
|
||||
|
||||
/* limit to 12 chars! */
|
||||
tex_name = substring(tex_name, 0, 12);
|
||||
|
|
|
@ -758,6 +758,10 @@ PMove_Run(void)
|
|||
pl.punchangle[1] *= punch;
|
||||
pl.punchangle[2] *= punch;
|
||||
|
||||
/* player animation code */
|
||||
Animation_TimerUpdate(pl);
|
||||
Animation_PlayerUpdate(pl);
|
||||
|
||||
/* allow vehicles to prevent weapon logic from happening */
|
||||
#ifdef SERVER
|
||||
Vehicle_Input();
|
||||
|
|
Loading…
Reference in a new issue