Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #263

Closed
wants to merge 5 commits into from
Closed

Test #263

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "Chipmunk2D"]
path = Chipmunk2D
url = git@github.com:viblo/Chipmunk2D.git
url = https://github.com/imMadsen/Chipmunk2D
2 changes: 1 addition & 1 deletion Chipmunk2D
13 changes: 13 additions & 0 deletions pymunk/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 6 additions & 0 deletions pymunk_cffi/chipmunk_cdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading