refactor(spx): centralize coordinate conversion - #327
Merged
joeykchen merged 1 commit intoJul 31, 2026
Conversation
There was a problem hiding this comment.
Review: refactor(spx): centralize coordinate conversion
Solid, well-scoped refactor. Centralizing the Y-axis flip into spx_to_godot_vec2 / godot_to_spx_vec2 and applying it at the manager API boundary removes a lot of error-prone scattered y = -y / flip_y() code, and the get/set pairs are now symmetric. The RenderRoot restructuring and the two new unit-test headers are good additions. The security pass found no memory-safety issues (null-guards, batch-buffer bounds checks, and reparent lifecycle all hold up).
One finding is worth confirming before merge because it is a semantic change hiding inside a "refactor", plus a few smaller items — see inline comments.
Summary of findings
- Collider/trigger center & polygon-vertex Y-flip changed (see inline on
spx_sprite_collision.cpp). This is the main item: several shape setters now flip the center Y (and collider-polygon vertices) where the base code did not. The old code was internally inconsistent, so the new unified behavior may well be the intended fix — but it is not a no-op and can vertically mirror collider/trigger offsets in existing SPX content. Please confirm it is intentional, document it, and ideally add a test asserting center placement per shape type. set_render_offsetre-positions RenderRoot on every batch update (inline onspx_sprite_render.cpp) — a change-guard would avoid redundant transform-dirty propagation (and the dynamic-frame-offset recompute) on the per-sprite batch hot path.godot_to_spx_vec2is an undocumented alias ofspx_to_godot_vec2(inline onspx_coordinate.h).get_rect()null-render_rootfallback silently returns a differently-origined rect (inline onspx_sprite_texture.cpp).
Additional (no inline location):
- Naming inconsistency:
SpxSpriterenamedpivot_offset/set_pivot→render_offset/set_render_offset, but the sibling classesSpxRenderSprite/SpxStaticSprite(andspx_scene_mgr.cpp:225, thegdextension_spx_extbindings) still usepivot/pivot_offsetfor the same concept. Functionally fine (separate code path), but a follow-up to unify the vocabulary — or a short comment noting the intentional divergence — would help readability.
nighca
approved these changes
Jul 31, 2026
joeykchen
force-pushed
the
refactor/spx-coordinate-system
branch
from
July 31, 2026 09:38
c38baec to
51b6f38
Compare
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
goplus/spx#1702
goplus/spx#1703