Skip to content

refactor: use cardinal.EntityID directly in physics2d contact types#890

Merged
AnthonyWadham merged 1 commit intomainfrom
Anthony/fix-physics-entity-casting
Apr 24, 2026
Merged

refactor: use cardinal.EntityID directly in physics2d contact types#890
AnthonyWadham merged 1 commit intomainfrom
Anthony/fix-physics-entity-casting

Conversation

@AnthonyWadham
Copy link
Copy Markdown
Contributor

@AnthonyWadham AnthonyWadham commented Apr 24, 2026

TL;DR

Replace uint64 wire-format conversions for entity IDs with direct cardinal.EntityID usage in the physics2d contact tracking system.

What changed?

ContactPairEntry now stores cardinal.EntityID directly for EntityA and EntityB instead of uint64. The intermediate conversion functions (entityIDFromUint64) and associated bounds-checking logic have been removed, along with the corresponding uint64(...) casts when writing back to the component. lessContactPairByEndpoints now accepts cardinal.EntityID arguments natively, eliminating the explicit casts at call sites.

Why make this change?

The previous approach stored entity IDs as uint64 in the component struct and converted them to cardinal.EntityID (a uint32) at runtime, requiring explicit bounds checks to guard against silent truncation. Since cardinal.EntityID is the canonical type throughout the engine, using it directly removes unnecessary conversions, eliminates the risk of mismatched types, and simplifies the code without any loss of correctness.

Copy link
Copy Markdown
Contributor Author

AnthonyWadham commented Apr 24, 2026


How to use the Graphite Merge Queue

Add the label graphite/merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@AnthonyWadham AnthonyWadham mentioned this pull request Apr 24, 2026
@AnthonyWadham AnthonyWadham changed the base branch from physics-no-lobby to graphite-base/890 April 24, 2026 17:15
@AnthonyWadham AnthonyWadham force-pushed the Anthony/fix-physics-entity-casting branch from 68588cc to 4ec0678 Compare April 24, 2026 17:16
@AnthonyWadham AnthonyWadham changed the base branch from graphite-base/890 to main April 24, 2026 17:16
@AnthonyWadham AnthonyWadham marked this pull request as ready for review April 24, 2026 17:16
@AnthonyWadham AnthonyWadham changed the title fix(physics2d): entity collision type to cardinal id refactor: use cardinal.EntityID directly in physics2d contact types Apr 24, 2026
@AnthonyWadham AnthonyWadham merged commit 1b316ea into main Apr 24, 2026
6 checks passed
@AnthonyWadham AnthonyWadham deleted the Anthony/fix-physics-entity-casting branch April 24, 2026 18:09
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