Skip to content

Conversation

@Shatur
Copy link
Contributor

@Shatur Shatur commented Oct 4, 2025

It turns out that we're no longer need to track when the visibility is gained for an entity because it's enough to just check its tick.

This allows us to get rid of the visibility enum entirely and heavily simplify the visibility logic. I added a comment about it and right below we update this tick if the entity is new, so it should be clear from the code.

@Shatur Shatur requested a review from UkoeHB October 4, 2025 20:31
It turns out that we're no longer need to track when the visibility
is gained for an entity because it's enough to just check its tick.

This allows us to get rid of the visibility enum entirely and heavily
simplify the visibility logic.
@Shatur Shatur force-pushed the simplify-visibility branch from 0abce5d to 1a185ba Compare October 4, 2025 20:31
@codecov
Copy link

codecov bot commented Oct 4, 2025

Codecov Report

❌ Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.99%. Comparing base (622b0f3) to head (71e220c).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/server.rs 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #586      +/-   ##
==========================================
- Coverage   78.21%   77.99%   -0.23%     
==========================================
  Files          56       56              
  Lines        3245     3208      -37     
==========================================
- Hits         2538     2502      -36     
+ Misses        707      706       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

src/server.rs Outdated
Comment on lines 713 to 715
// The entity is new for the client if it's mutation tick is not set.
// This value resets when the entity loses visibility or stops being replicated.
let new_entity = entity_cache.mutation_tick.is_none();
Copy link
Collaborator

@UkoeHB UkoeHB Oct 10, 2025

Choose a reason for hiding this comment

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

Move this to a method on the entity cache. gained_visibility. Also this variable should be gained_visibility, not new_entity.

Copy link
Contributor Author

@Shatur Shatur Oct 11, 2025

Choose a reason for hiding this comment

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

I like this! But I'm not sure about gained_visibility. How about is_new_for_client? Because it could be a new entity or an entity that just become visible. I pushed this change, let me know what you think.

src/server.rs Outdated
visibility_state == Visibility::Gained
|| signature.is_added()
|| ticks.mutation_tick(entity).is_none()
signature.is_added() || ticks.mutation_tick(entity).is_none()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
signature.is_added() || ticks.mutation_tick(entity).is_none()
signature.is_added() || ticks.gained_visibility(entity, visibility.is_visible(entity))

Add gained_visibility method to ClientTicks.

@Shatur Shatur merged commit b960ec1 into master Oct 11, 2025
9 checks passed
@Shatur Shatur deleted the simplify-visibility branch October 11, 2025 16:04
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.

3 participants