How many shapes are surrounding another?

Official forum for the Chipmunk2D Physics Library.

How many shapes are surrounding another?

Postby lautarov » Mon Apr 24, 2017 5:57 pm

Hi there! I started using chipmunk some weeks ago and I'm stuck with something that may be simple, but I can't solve it.
I want to know how many shapes are sorrounding another one (let's call it shapeA) within a certain distance.
My idea was to get the position of the body associated with shapeA (no problem with that) and then use cpSpacePointQuery, because it should call a func for each shape found along within a given distance. Then I can count how many times this func was called by cpSpacePointQuery.

But it didn't work, the program collapse when running with a segmentation fault (core dumped). When I build I don't receive errors nor warnings, and when I debug it says "#0 0x43421b cpSpatialIndexQuery(index=0x65b000, obj=0x7fffffffddb0, bb=..., func=0x434350 <NearestPointQuery>, data=0x0) (../include/chipmunk/cpSpatialIndex.h:210)

I haven't found an example of cpSpacePointQuery and I must be misunderstanding the headers. I've really checked the pointers declarations and initializations. Is it too much to ask a little example code for this? may be it's faster if I check the example and compare with my program.

Thank you!
Posts: 1
Joined: Fri Apr 21, 2017 12:52 pm

Re: How many shapes are surrounding another?

Postby viblo » Sat May 20, 2017 5:36 am

Maybe you can try to make a simple example and paste here? Then its easier for us to see if/what is wrong. Unfortunately I mostly write python and use Chipmunk through the pymunk python library, so I dont have a ready example in C to show you.. But I know that its possible to make it work :) - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
Posts: 202
Joined: Tue Aug 21, 2007 3:12 pm

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest