Skip to content

feat: 2D support - #32

Merged
nihiL7331 merged 31 commits into
mainfrom
feat/2d-support
Aug 9, 2026
Merged

feat: 2D support#32
nihiL7331 merged 31 commits into
mainfrom
feat/2d-support

Conversation

@nihiL7331

Copy link
Copy Markdown
Owner

This PR implements a macro-based 2D support, stripping out anything from the 3D implementation that isn't needed in 2D.

  • Morton codes get 16 bit per dimension, so the range is far greater for 2D
  • The memory usage is lower, two nodes fit in one cache line
  • There's less recursive calls and traversal (octotree in 3D->quadtree in 2D)

Alongside the 2D implementation, fixed/refactored:

  • multipole array got moved from ps_node_t to ps_context_t matching the local expansion structure,
  • ps_impl_fmm_interaction_pass/ps_impl_fmm_p2p_pass subdivide logic is now size-based to ensure equal division,
  • run_st_vs_mt_test got fixed to match the current approach in ps_calc_forces.

Also added:

  • 2D tests, matching the main_3d.c tests (previously main.c),
  • 2D unary demo, showcasing the 2D capabilities.

Demonstration code might need a rewrite. It's poorly written, and the renderer logic bottlenecks the physics logic. Rewriting the code in something like sokol with pushing the array of particles to the GPU might be the best bet.

@nihiL7331 nihiL7331 self-assigned this Aug 8, 2026
@nihiL7331
nihiL7331 merged commit 8fe8b4e into main Aug 9, 2026
4 checks passed
@nihiL7331
nihiL7331 deleted the feat/2d-support branch August 9, 2026 00:25
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.

1 participant