Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor trails #59

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SollyBunny
Copy link

@SollyBunny SollyBunny commented Jan 25, 2025

It looks the same to me

  • rainbow / speed
  • different alphas
  • taper alpha

Checklist

  • Tested the change ingame
  • Provided screenshots if it is a visual change
  • Tested in combination with possibly related configuration options
  • Written a unit test (especially base/) or added coverage to integration test
  • Considered possible null pointers and out of bounds array indexing
  • Changed no physics that affect existing maps
  • Tested the change with ASan+UBSan or valgrind's memcheck (optional)

@SollyBunny SollyBunny marked this pull request as draft January 25, 2025 12:27
Squashed commit of the following:

commit e4a72f3
Author: Teero888 <[email protected]>
Date:   Fri Jan 3 00:59:31 2025 +0100

    add speed mode

commit 127a81b
Author: Teero888 <[email protected]>
Date:   Thu Jan 2 23:03:03 2025 +0100

    code review
@SollyBunny SollyBunny marked this pull request as ready for review January 25, 2025 14:03
Comment on lines +115 to +117
if(ClientId == -2)
Alpha *= g_Config.m_ClRaceGhostAlpha / 100.0f;
else if(ClientId < 0 || m_pClient->IsOtherTeam(ClientId))
Alpha *= g_Config.m_ClShowOthersAlpha / 100.0f;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClientId can never be -2 or < 0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future proofing for when ghosts (-2) are added.
I'm not sure what < 0 is, I just copied it from players.cpp

float Alpha = (OtherTeam || ClientId < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f;
if(ClientId == -2) // ghost
	Alpha = g_Config.m_ClRaceGhostAlpha / 100.0f;

src/game/client/components/tclient/trails.cpp Outdated Show resolved Hide resolved
src/game/client/components/tclient/trails.h Show resolved Hide resolved
if(Trail.at(i).TooLong)
const STrailPart &Part = s_Trail.at(i);
const STrailPart &NextPart = s_Trail.at(i + 1);
if(distance(Part.Pos, NextPart.Pos) > 120.0f)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't check this here because the Position at each end get interpolated by intratick so the length between positions can change over a tick, this is a regression from whenever I added TooLong. You can see the bug this causes in this video at 2:21 if you play frame by frame.

https://youtu.be/RMmDPoaCsqI?si=ALEet5Mte_OmXUrb&t=141

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

		if(PredictPlayer)
			Trail.at(0).Pos = GameClient()->m_aClients[ClientId].m_RenderPos;
		else
			Trail.at(0).Pos = mix(PrevServerPos, CurServerPos, Client()->IntraGameTick(g_Config.m_ClDummy));

		for(int i = 0; i < (int)Trail.size() - 1; i++)
		{
			if(distance(Trail.at(i).Pos, Trail.at(i + 1).Pos) > 120.0f)
				Trail.at(i).TooLong = true;
		}

When it's checked here Pos != UnmovedPos, Pos is then not modified at all

TooLong is also not modified and only read in the render part which doesn't modify the trail.

You should be able to do this check at rendering.

As for having a bit of extra trail when you respawn in the video, it's working on my machine™

Copy link
Owner

@sjrc6 sjrc6 Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bug doesn't replicate, even though I'm pretty sure it should but I don't care why so good enough.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

120 is actually a bit small, when youre falling really fast some bits get chopped

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw 600 somewhere i think thats more sensible

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be changed to difference between segments, so if your speed increases by >120 in a single tick it cuts

* Changed mode to 1 indexed
* Change mode selection to dropdown
* Only show trail color for solid mode
* Other refactoring
@SollyBunny SollyBunny force-pushed the tater_refactor_trails_2 branch from 5df8aef to 34cd259 Compare January 26, 2025 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants