Skip to content

Rework neighbors API - #253

Open
tychedelia wants to merge 1 commit into
python-particle-apifrom
neighbor-lists
Open

tychedelia wants to merge 1 commit into
python-particle-apifrom
neighbor-lists

Conversation

@tychedelia

@tychedelia tychedelia commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Neighbor lists as per-particle attributes, like TouchDesigner's Neighbor POP.

  • FIND_NEIGHBORS searches the grid once and writes neighbors (up to max indices, default 64) and neighbor_count onto each particle. Past max it keeps a spread sample rather than the nearest.
  • NEIGHBOR reads those lists, so several reductions share one search (flocking does five). New: relative=True for a_j - a_i, and an INVERSE_SQUARE falloff. Particles never count themselves. grid= still does an exact search.
  • Custom kernels just declare neighbors and neighbor_count, and apply binds them by name like position.
  p.apply(FIND_NEIGHBORS, grid=grid, radius=2.5)
  p.apply(NEIGHBOR, "velocity", out="alignment", op=SUM)
  p.apply(NEIGHBOR, "position", out="separation", op=SUM, relative=True, radius=1.2, falloff=INVERSE_SQUARE)

Also adds processing_particles_find_neighbors to the FFI.

@tychedelia
tychedelia added this pull request to stack #256 September 29, 2026 04:50
@tychedelia
tychedelia removed this pull request from stack #256 September 29, 2026 05:06
@tychedelia
tychedelia added this pull request to stack #258 September 29, 2026 05:06
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Visual regression: no changes across 43 cases

baseline f4e69a80d4 · adapter llvmpipe (LLVM 20.1.2, 256 bits) (Vulkan, Mesa 25.2.8-0ubuntu0.24.04.2 (LLVM 20.1.2))

Open the visual report · workflow run

This branch has not been deployed

No deployments
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