diff --git a/.gitmodules b/.gitmodules index 4d311954..193471cc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "Chipmunk2D"] path = Chipmunk2D - url = git@github.com:viblo/Chipmunk2D.git + url = https://github.com/imMadsen/Chipmunk2D diff --git a/Chipmunk2D b/Chipmunk2D index 7f091aad..401e98e7 160000 --- a/Chipmunk2D +++ b/Chipmunk2D @@ -1 +1 @@ -Subproject commit 7f091aadb1b9e6c0e0a1705c1ed71c1e375eb64d +Subproject commit 401e98e78e1f78e4718d0d2301bcf1ad06b3d035 diff --git a/pymunk/space.py b/pymunk/space.py index a59df1d8..02d7bdcd 100644 --- a/pymunk/space.py +++ b/pymunk/space.py @@ -554,6 +554,19 @@ def use_spatial_hash(self, dim: float, count: int) -> None: """ cp.cpSpaceUseSpatialHash(self._space, dim, count) + + def get_space_hash_indicies(self, hash_indicies_len, l, r, b, t) -> List: + hash_indicies = ffi.new(f'int[{hash_indicies_len}]') + cp.cpSpaceGetSpatialHashIndices(self._space, hash_indicies, l, r, b, t) + return hash_indicies + + def create_space_hash_objects_count(self, hash_indicies_len) -> List: + hash_indicies = ffi.new(f'int[{hash_indicies_len}]') + return hash_indicies + + def get_space_hash_objects_count(self, cell_counts, hash_indicies, hash_indicies_len) -> None: + cp.cpSpaceGetSpatialHashObjectCounts(self._space, cell_counts, hash_indicies, hash_indicies_len) + def step(self, dt: float) -> None: """Update the space for the given time step. diff --git a/pymunk_cffi/chipmunk_cdef.h b/pymunk_cffi/chipmunk_cdef.h index 3e00ecd0..8a04194c 100644 --- a/pymunk_cffi/chipmunk_cdef.h +++ b/pymunk_cffi/chipmunk_cdef.h @@ -1233,6 +1233,12 @@ void cpSpaceReindexShapesForBody(cpSpace *space, cpBody *body); /// Switch the space to use a spatial has as it's spatial index. void cpSpaceUseSpatialHash(cpSpace *space, cpFloat dim, int count); +//MARK: P7 (Crowd Crushing) + +void cpSpaceGetSpatialHashIndices(cpSpace *space, int *hash_indices, int l, int r, int b, int t); + +void cpSpaceGetSpatialHashObjectCounts(cpSpace *space, int *cell_counts, int *hash_indices, int hash_indices_len); + // MARK: Time Stepping /// Step the space forward in time by @c dt.