Skip to content

Commit 4dd1ac3

Browse files
committed
exported spatial hashing
1 parent 51735b6 commit 4dd1ac3

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Chipmunk2D

Submodule Chipmunk2D deleted from 7f091aa

pymunk/space.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,11 @@ def use_spatial_hash(self, dim: float, count: int) -> None:
554554
"""
555555
cp.cpSpaceUseSpatialHash(self._space, dim, count)
556556

557+
def get_space_hash_objects_per_cell(self) -> List:
558+
cell_counts = ffi.new(f'int[{cp.cpSpaceGetSpatialHashTotalCells(self._space)}]')
559+
cp.cpSpaceGetSpatialHashObjectCounts(self._space, cell_counts)
560+
return cell_counts
561+
557562
def step(self, dt: float) -> None:
558563
"""Update the space for the given time step.
559564

pymunk_cffi/chipmunk_cdef.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,12 @@ void cpSpaceReindexShapesForBody(cpSpace *space, cpBody *body);
12331233
/// Switch the space to use a spatial has as it's spatial index.
12341234
void cpSpaceUseSpatialHash(cpSpace *space, cpFloat dim, int count);
12351235

1236+
// MARK: P7 (Crowd Crushing)
1237+
1238+
int cpSpaceGetSpatialHashTotalCells(cpSpace * space);
1239+
1240+
void cpSpaceGetSpatialHashObjectCounts(cpSpace * space, int *cell_counts);
1241+
12361242
// MARK: Time Stepping
12371243

12381244
/// Step the space forward in time by @c dt.

0 commit comments

Comments
 (0)