New Project - chipmunk_private.h errors

Official forum for the Chipmunk2D Physics Library.
jcmeyer5
Posts: 89
Joined: Thu Dec 15, 2011 9:18 am
Contact:

New Project - chipmunk_private.h errors

Post by jcmeyer5 »

I just upgraded to cocos2d 2.1b and latest Chipmunk Pro (Trial). I created a stock cocos2d iOS project (no chipmunk). I then dropped in Chipmunk Pro. Build, and all is well (no issues). I then when to ccConfig.h and enabled the CC_ENABLE_CHIPMUNK_INTEGRATION flag (to get the CCPhysicsDebugNode up and running). Now I am getting Semantic issues in several structs - cpConstraint, cpArbiter, cpShape, cpBody, cpSpace. They all have a "No member named xxxxx in struct yyyyy" message, and all point to the chipmunk_private.h file. When I went to look at the errors in, say, cpConstraint, it appears as if the CP_PRIVATE members are causing the issues.

Any advice?
Chipmunk Pro and cocos2D 2.x branch for iOS development
jcmeyer5
Posts: 89
Joined: Thu Dec 15, 2011 9:18 am
Contact:

Re: New Project - chipmunk_private.h errors

Post by jcmeyer5 »

Okay, so if I go into chipmunk.h and set the CP_ALLOW_PRIVATE_ACCESS flag to 1, the errors disappear, but the screen is blank. Plus, I don't think that this is how it is supposed to work (setting the CP_ALLOW_PRIVATE_ACCESS manually in the chipmunk.h file). All I have in the init is the space init, gravity, and a bounding box for the screen.

Code: Select all

-(id) init {
	if( (self=[super init]) ) {
		
		CGSize scrSize = [[CCDirector sharedDirector] winSize];

		self.space = [[ChipmunkSpace alloc] init];
		self.space.gravity = cpv(0,-1000);
		self.space.data = self;

		CGRect rect = CGRectMake(0, 0, scrSize.width, scrSize.height);
		[self.space addBounds:rect 
				 thickness:10 
				elasticity:0.5f 
				  friction:1.0f 
					 layers:CP_ALL_LAYERS 
					  group:CP_NO_GROUP 
			collisionType:nil];

		[self addChild:[CCPhysicsDebugNode debugNodeForChipmunkSpace:self.space]];
		
		[self scheduleUpdate];
		
	}
	return self;
}

-(void) update:(ccTime)dt {
	[self.space step:dt];
}
Chipmunk Pro and cocos2D 2.x branch for iOS development
jcmeyer5
Posts: 89
Joined: Thu Dec 15, 2011 9:18 am
Contact:

Re: New Project - chipmunk_private.h errors

Post by jcmeyer5 »

Okay, more confusion. I made a stock chipmunk-cocos2d project to see how it is set up. In the ccConfig.h file, the CC_ENABLE_CHIPMUNK_INTEGRATION is set to 0, but the project uses CCPhysicsDebugNode.

Is it because I am using Objective Chipmunk?
Chipmunk Pro and cocos2D 2.x branch for iOS development
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: New Project - chipmunk_private.h errors

Post by slembcke »

Oh. Hrm. I think I see what is going on.

The original version of that code was meant to work seamlessly with either Chipmunk or Objective-Chipmunk. When Riq added it with Cocos2D, he added Box2D support to it too and the CC_ENABLE_CHIPMUNK_INTEGRATION stuff. It was never tested again against Objective-Chipmunk and I haven't used the latest beta really.

Making a patch now.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: New Project - chipmunk_private.h errors

Post by slembcke »

Fix pushed here: https://github.com/slembcke/cocos2d-iph ... ntegration
Patch against the mainline develop-v2 branch here: http://files.slembcke.net/temp/objectiv ... tion.patch

Unless you are working off of the git version of Cocos2D (you really might as well if you are using the betas IMO), you'll need to use the patch file. Download it somewhere, then cd to wherever the cocos2d directory in your project is (should be a directory named lib from the templates) and type "patch -p1 -i /path/to/the/patch/file"
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
jcmeyer5
Posts: 89
Joined: Thu Dec 15, 2011 9:18 am
Contact:

Re: New Project - chipmunk_private.h errors

Post by jcmeyer5 »

Gracias!
Chipmunk Pro and cocos2D 2.x branch for iOS development
User avatar
dangermouse
Posts: 2
Joined: Sun Dec 19, 2010 11:44 pm
Contact:

Re: New Project - chipmunk_private.h errors

Post by dangermouse »

Hi,
I am building a project in XCode 4.5.2 using the latest cocos2d from git (branch develop-v2) and the ChipmunkPro-Trial-6.1.2. I enabled chipmunk integration in ccConfig.h:

#define CC_ENABLE_CHIPMUNK_INTEGRATION 1

and I am getting the same compiler errors as described above in the original post for this thread. I downloaded your modified cocos2d from git and replaced the cocos2d in my project with it.

I also downloaded the patch you provided and ran it against your fork of cocos2d - I'm not familiar with 'patch', and I got the following prompt, so I answered no to it and all subsequent prompts and it ignored applying the patches.

Bollo:libs rowland$ patch -p1 -i objective-chipmunk-integration.patch
patching file cocos2d/CCPhysicsDebugNode.h
Reversed (or previously applied) patch detected! Assume -R? [n]

Could anyone help me figure out what's breaking this build?

Thanks a bunch,
Rowland
Thanks,
Rowland
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: New Project - chipmunk_private.h errors

Post by slembcke »

So I had a section in the latest tutorial I wrote about that. I was about to point you to that, but now it's gone. Hrm. It must have gotten merged out when we were doing revisions. I'll have to rewrite that I guess.

Anyway, the patch I made earlier in this thread was rejected by Riq as it caused issues with his Javascript binding generation. He's using a automated tool that parses the headers and it didn't like the forward declarations I used.

Anyway. The workaround for the moment is that you need to import ObjectiveChipmunk.h before cocos2d.h in any .m file. It's a little awkward, but it works. I haven't really been able to find a better solution.

I think I'm going to ask Riq if he'd be Ok with an OBJECTIVE_CHIPMUNK_INTEGRATION enable. I expect he'll go for it considering the CCPhysicsSprite and CCPhysicsDebugNode classes were originally written for use with Objective-Chipmunk example code.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
dangermouse
Posts: 2
Joined: Sun Dec 19, 2010 11:44 pm
Contact:

Re: New Project - chipmunk_private.h errors

Post by dangermouse »

Thanks a bunch, that got me past the compiler errors :) I'll keep an eye out for the patch you mentioned adding to the system.

Rowland Smith
Thanks,
Rowland
theisegeberg
Posts: 6
Joined: Tue Aug 28, 2012 5:32 am
Contact:

Re: New Project - chipmunk_private.h errors

Post by theisegeberg »

I hate to be annoying bumper here.

I've got the paid pro version. I tried to dump in the latest objective chipmunk into cocos2d, and I'm getting the same errors.

Can we get a fix for this that won't break the second we update cocos2d or chipmunk please? :)
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests