Cant remove static shape

Official forum for the Chipmunk2D Physics Library.
Post Reply
wonza
Posts: 4
Joined: Tue Jul 28, 2009 2:02 am
Contact:

Cant remove static shape

Post by wonza »

I have some code similar to the moon buggy example where I'm adding/removing sections of land. It all works well until I revisit land I've been to before (as its randomly recreated again). The problem is that the old shapes seem to still be there.

Here's a section of the relevant code:

Code: Select all

struct Segment {
    float *points;
    cpShape *myshape[65];
};
typedef struct Segment Segment;

	for (int s = midPoint-1; s <= midPoint+1 ; s++) {
		for (int p = 0; p < noOfPointsPerSegment; p++) {
			cpSpaceRemoveStaticShape(space, landSegments[s].myshape[p]);
			cpVect b = cpv(d*50.0f, landSegments[s].points[p]*80.0f);
			landSegments[s].myshape[p] = cpSegmentShapeNew(staticBody, a, b, 0.0f);
			landSegments[s].myshape[p]->u = 1.0;
			cpSpaceAddStaticShape(space, landSegments[s].myshape[p]);
			a = b;
			d++;
		}
	}

	cpSpaceRehashStatic(space);

I'm really struggling with this one :( , so any help would be really appreciated! :)
wonza
Posts: 4
Joined: Tue Jul 28, 2009 2:02 am
Contact:

Re: Cant remove static shape

Post by wonza »

Typically, I went to bed and two mins later I solved it :)
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests