Discussion:
[hlcoders] Solution to laggy first-person spectating
Peter McKeown
2015-05-31 01:21:28 UTC
Permalink
Greetings everyone,

There is a bug with the codebase where in
some situations the first person spectating of other players can become
very laggy, as interpolation for m_angEyeAngles stops.

This bug
is present in TF2's code as well as I've seen it there too. The
issue is that the player's ShouldInterpolate() doesn't take into
account if the local player is spectating this player or not, causing it
to no longer have it's interpolated variables (like m_iv_angEyeAngles)
processed. I've been hunting this bug for a while in my mod and finally
solved it, and I figured I'd share the solution here:

In c_baseplayer.cpp, go to the ShouldInterpolate() function, and add this at the bottom above BaseClass::ShouldInterpolate():

if ( GetLocalPlayer() && GetLocalPlayer()->GetObserverTarget() == this )
return true;

This will fix it. Hope this helps!

Note: I didn't look too much into this, but the spectating of players is done via CalcView which doesn't appear to change what render->GetViewEntity() would return - the entity returned by this always interpolated, which would seem to be the intended way for this to work, but doesn't.

Regards,

Peter
Stephen Swires
2015-05-31 01:25:52 UTC
Permalink
It's not a bug with the code base and that isn't the proper way to fix it.
This is how Valve's games handle it:
https://github.com/ValveSoftware/source-sdk-2013/search?utf8=%E2%9C%93&q=m_iv_angEyeAngles

On Sun, May 31, 2015 at 2:21 AM, Peter McKeown <***@hotmail.com>
wrote:

> Greetings everyone,
>
> There is a bug with the codebase where in some situations the first person
> spectating of other players can become very laggy, as interpolation for
> m_angEyeAngles stops.
>
> This bug is present in TF2's code as well as I've seen it there too. The
> issue is that the player's ShouldInterpolate() doesn't take into account if
> the local player is spectating this player or not, causing it to no longer
> have it's interpolated variables (like m_iv_angEyeAngles) processed. I've
> been hunting this bug for a while in my mod and finally solved it, and I
> figured I'd share the solution here:
>
> In c_baseplayer.cpp, go to the ShouldInterpolate() function, and add this
> at the bottom above BaseClass::ShouldInterpolate():
>
> if ( GetLocalPlayer() && GetLocalPlayer()->GetObserverTarget() == this )
> return true;
>
> This will fix it. Hope this helps!
>
> Note: I didn't look too much into this, but the spectating of players is
> done via CalcView which doesn't appear to change what
> render->GetViewEntity() would return - the entity returned by this always
> interpolated, which would seem to be the intended way for this to work, but
> doesn't.
>
> Regards,
>
> Peter
>
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
>
>
>
Peter McKeown
2015-05-31 01:31:12 UTC
Permalink
I'm not seeing how what you posted is relevant, the declaration of m_angEyeAngles is fine, but no interpolated variables are processed for a spectated player if ShouldInterpolate() returns false, which it does in some cases when spectating a player in first person. I haven't tracked down exactly why since this is a simple fix, most likely their viewmodels (which are visible, the spectator target is not rendered in first person) is chain requiring interpolation and that keeps m_angEyeAngles going.

Date: Sun, 31 May 2015 02:25:52 +0100
From: ***@swires.me
To: ***@list.valvesoftware.com
Subject: Re: [hlcoders] Solution to laggy first-person spectating

It's not a bug with the code base and that isn't the proper way to fix it. This is how Valve's games handle it: https://github.com/ValveSoftware/source-sdk-2013/search?utf8=%E2%9C%93&q=m_iv_angEyeAngles

On Sun, May 31, 2015 at 2:21 AM, Peter McKeown <***@hotmail.com> wrote:



Greetings everyone,

There is a bug with the codebase where in
some situations the first person spectating of other players can become
very laggy, as interpolation for m_angEyeAngles stops.

This bug
is present in TF2's code as well as I've seen it there too. The
issue is that the player's ShouldInterpolate() doesn't take into
account if the local player is spectating this player or not, causing it
to no longer have it's interpolated variables (like m_iv_angEyeAngles)
processed. I've been hunting this bug for a while in my mod and finally
solved it, and I figured I'd share the solution here:

In c_baseplayer.cpp, go to the ShouldInterpolate() function, and add this at the bottom above BaseClass::ShouldInterpolate():

if ( GetLocalPlayer() && GetLocalPlayer()->GetObserverTarget() == this )
return true;

This will fix it. Hope this helps!

Note: I didn't look too much into this, but the spectating of players is done via CalcView which doesn't appear to change what render->GetViewEntity() would return - the entity returned by this always interpolated, which would seem to be the intended way for this to work, but doesn't.

Regards,

Peter



_______________________________________________

To unsubscribe, edit your list preferences, or view the list archives, please visit:

https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders







_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
Stephen Swires
2015-05-31 01:37:01 UTC
Permalink
Your fix is a hack, not a fix, let's get that right for a start. If you
look at the code around it, you'll see that m_iv_angEyeAngles sets up
interpolation on m_angEyeAngles, which is a networked copy of a player's
eye angles which is sent to everyone but the local player. In
C_HL2MPPlayer, the interpolated version is used in ::PreThink and
::EyeAngles also has an override. This makes eye angles in spectator
interpolated (ie. smooth) and is Valve's way of implementing this. You
probably derived from CBasePlayer or CBaseMultiplayerPlayer and didn't set
this up, which again isn't an engine thing.


On Sun, May 31, 2015 at 2:31 AM, Peter McKeown <***@hotmail.com>
wrote:

> I'm not seeing how what you posted is relevant, the declaration of
> m_angEyeAngles is fine, but no interpolated variables are processed for a
> spectated player if ShouldInterpolate() returns false, which it does in
> some cases when spectating a player in first person. I haven't tracked down
> exactly why since this is a simple fix, most likely their viewmodels (which
> are visible, the spectator target is not rendered in first person) is chain
> requiring interpolation and that keeps m_angEyeAngles going.
>
> ------------------------------
> Date: Sun, 31 May 2015 02:25:52 +0100
> From: ***@swires.me
> To: ***@list.valvesoftware.com
> Subject: Re: [hlcoders] Solution to laggy first-person spectating
>
>
> It's not a bug with the code base and that isn't the proper way to fix it.
> This is how Valve's games handle it:
> https://github.com/ValveSoftware/source-sdk-2013/search?utf8=%E2%9C%93&q=m_iv_angEyeAngles
>
> On Sun, May 31, 2015 at 2:21 AM, Peter McKeown <***@hotmail.com>
> wrote:
>
> Greetings everyone,
>
> There is a bug with the codebase where in some situations the first person
> spectating of other players can become very laggy, as interpolation for
> m_angEyeAngles stops.
>
> This bug is present in TF2's code as well as I've seen it there too. The
> issue is that the player's ShouldInterpolate() doesn't take into account if
> the local player is spectating this player or not, causing it to no longer
> have it's interpolated variables (like m_iv_angEyeAngles) processed. I've
> been hunting this bug for a while in my mod and finally solved it, and I
> figured I'd share the solution here:
>
> In c_baseplayer.cpp, go to the ShouldInterpolate() function, and add this
> at the bottom above BaseClass::ShouldInterpolate():
>
> if ( GetLocalPlayer() && GetLocalPlayer()->GetObserverTarget() == this )
> return true;
>
> This will fix it. Hope this helps!
>
> Note: I didn't look too much into this, but the spectating of players is
> done via CalcView which doesn't appear to change what
> render->GetViewEntity() would return - the entity returned by this always
> interpolated, which would seem to be the intended way for this to work, but
> doesn't.
>
> Regards,
>
> Peter
>
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
>
>
>
>
> _______________________________________________ To unsubscribe, edit your
> list preferences, or view the list archives, please visit:
> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
>
>
>
Peter McKeown
2015-05-31 02:01:08 UTC
Permalink
You do not seem to understand what I'm talking about. m_iv_angEyeAngles will not be interpolated if ShouldInterpolate() returns false. Please study carefully how the game's interpolation system works. m_angEyeAngles will not appear smoothly updated to a spectator if m_iv_angEyeAngles is not being interpolated due to ShouldInterpolate() returning false.

Date: Sun, 31 May 2015 02:37:01 +0100
From: ***@swires.me
To: ***@list.valvesoftware.com
Subject: Re: [hlcoders] Solution to laggy first-person spectating

Your fix is a hack, not a fix, let's get that right for a start. If you look at the code around it, you'll see that m_iv_angEyeAngles sets up interpolation on m_angEyeAngles, which is a networked copy of a player's eye angles which is sent to everyone but the local player. In C_HL2MPPlayer, the interpolated version is used in ::PreThink and ::EyeAngles also has an override. This makes eye angles in spectator interpolated (ie. smooth) and is Valve's way of implementing this. You probably derived from CBasePlayer or CBaseMultiplayerPlayer and didn't set this up, which again isn't an engine thing.


On Sun, May 31, 2015 at 2:31 AM, Peter McKeown <***@hotmail.com> wrote:



I'm not seeing how what you posted is relevant, the declaration of m_angEyeAngles is fine, but no interpolated variables are processed for a spectated player if ShouldInterpolate() returns false, which it does in some cases when spectating a player in first person. I haven't tracked down exactly why since this is a simple fix, most likely their viewmodels (which are visible, the spectator target is not rendered in first person) is chain requiring interpolation and that keeps m_angEyeAngles going.

Date: Sun, 31 May 2015 02:25:52 +0100
From: ***@swires.me
To: ***@list.valvesoftware.com
Subject: Re: [hlcoders] Solution to laggy first-person spectating

It's not a bug with the code base and that isn't the proper way to fix it. This is how Valve's games handle it: https://github.com/ValveSoftware/source-sdk-2013/search?utf8=%E2%9C%93&q=m_iv_angEyeAngles

On Sun, May 31, 2015 at 2:21 AM, Peter McKeown <***@hotmail.com> wrote:



Greetings everyone,

There is a bug with the codebase where in
some situations the first person spectating of other players can become
very laggy, as interpolation for m_angEyeAngles stops.

This bug
is present in TF2's code as well as I've seen it there too. The
issue is that the player's ShouldInterpolate() doesn't take into
account if the local player is spectating this player or not, causing it
to no longer have it's interpolated variables (like m_iv_angEyeAngles)
processed. I've been hunting this bug for a while in my mod and finally
solved it, and I figured I'd share the solution here:

In c_baseplayer.cpp, go to the ShouldInterpolate() function, and add this at the bottom above BaseClass::ShouldInterpolate():

if ( GetLocalPlayer() && GetLocalPlayer()->GetObserverTarget() == this )
return true;

This will fix it. Hope this helps!

Note: I didn't look too much into this, but the spectating of players is done via CalcView which doesn't appear to change what render->GetViewEntity() would return - the entity returned by this always interpolated, which would seem to be the intended way for this to work, but doesn't.

Regards,

Peter



_______________________________________________

To unsubscribe, edit your list preferences, or view the list archives, please visit:

https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders







_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders

_______________________________________________

To unsubscribe, edit your list preferences, or view the list archives, please visit:

https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders







_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
Peter McKeown
2015-05-31 01:27:42 UTC
Permalink
Greetings everyone,

There is an intermittent bug with the codebase where in
some situations the first person spectating of other players can become
very laggy, as interpolation for m_angEyeAngles stops. This problem is most easily found when the spectator target's viewmodel is hidden and thus isn't requiring interpolation (meaning there is no reason to interpolate the parent player either).

This bug
is present in TF2's code as well as I've seen it there too. The
issue is that the player's ShouldInterpolate() doesn't take into
account if the local player is spectating this player or not, causing it
to no longer have it's interpolated variables (like m_iv_angEyeAngles)
processed. I've been hunting this bug for a while in my mod and finally
solved it, and I figured I'd share the solution here:

In c_baseplayer.cpp, go to the ShouldInterpolate() function, and add this at the bottom above BaseClass::ShouldInterpolate():

if ( GetLocalPlayer() && GetLocalPlayer()->GetObserverTarget() == this )
return true;

This will fix it. Hope this helps!

Note: I didn't look too much into this, but the spectating of players is done via CalcView which doesn't appear to change what render->GetViewEntity() returns - the entity returned by this always interpolated, which would seem to be the intended way for this to work, but doesn't in practice.

Regards,

Peter
Peter McKeown
2015-05-31 01:32:46 UTC
Permalink
Apologies for the double post, encountered an error in Outlook.

From: ***@hotmail.com
To: ***@list.valvesoftware.com
Date: Sun, 31 May 2015 02:27:42 +0100
Subject: [hlcoders] Solution to laggy first-person spectating







Greetings everyone,

There is an intermittent bug with the codebase where in
some situations the first person spectating of other players can become
very laggy, as interpolation for m_angEyeAngles stops. This problem is most easily found when the spectator target's viewmodel is hidden and thus isn't requiring interpolation (meaning there is no reason to interpolate the parent player either).

This bug
is present in TF2's code as well as I've seen it there too. The
issue is that the player's ShouldInterpolate() doesn't take into
account if the local player is spectating this player or not, causing it
to no longer have it's interpolated variables (like m_iv_angEyeAngles)
processed. I've been hunting this bug for a while in my mod and finally
solved it, and I figured I'd share the solution here:

In c_baseplayer.cpp, go to the ShouldInterpolate() function, and add this at the bottom above BaseClass::ShouldInterpolate():

if ( GetLocalPlayer() && GetLocalPlayer()->GetObserverTarget() == this )
return true;

This will fix it. Hope this helps!

Note: I didn't look too much into this, but the spectating of players is done via CalcView which doesn't appear to change what render->GetViewEntity() returns - the entity returned by this always interpolated, which would seem to be the intended way for this to work, but doesn't in practice.

Regards,

Peter




_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlcoders
Loading...