[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - cpBody function no const cpBody *

cpBody function no const cpBody *

Discuss any Chipmunk bugs here.

cpBody function no const cpBody *

Postby pat » Sun Aug 29, 2010 2:12 pm

User avatar
pat
 
Posts: 53
Joined: Tue Jul 20, 2010 7:55 pm

Re: cpBody function no const cpBody *

Postby slembcke » Sun Aug 29, 2010 9:03 pm

Just inconsistencies I guess. I don't often think to add const. I did with the vector operator functions because I wanted to ensure that they got optimized well. Is there any particular reason you are defining them as const to begin with?

In general things like shapes and bodies are not constant. Tagging getter functions maybe makes sense, but you can't do much with a read only shape or body.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: cpBody function no const cpBody *

Postby pat » Mon Aug 30, 2010 7:05 am

yea i figured optimization could be a reason for it, though i'm not sure that it would make a difference since its pointers, with the cpBodyL2W/W2L functions those cpv calls take const cpVect's (which i wouldnt think would matter in the long run since its still doing a copy).

Like i'm working on a world editor and stuff like plotting shapes i ushaully keep the body constant incase the project gets more of a team and people think they should be playing with other stuff besides whats not constant (which is really th only reason for const i'd say).

The other times when i'll use const is so that the person writing code with my code knows that that value that there sending is not going to be modified, Which i think would be a good thing in chipmunk to do for people who are new to game programming and don't know what is actually gonna be modifying stuff and not. Its pretty standard to do this with c++, i'd imagine the same with c but i don't really have the background to say that.
User avatar
pat
 
Posts: 53
Joined: Tue Jul 20, 2010 7:55 pm

Re: cpBody function no const cpBody *

Postby slembcke » Mon Aug 30, 2010 10:53 am

Well, I added const to static inline functions and macro templated functions in the headers. I think that should cover most of the cases that you were talking about. I'll have to make a deeper inspection later if I want to get all of them.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: cpBody function no const cpBody *

Postby pat » Mon Aug 30, 2010 11:48 am

Sweet, thats great. I think that should cover most everything
User avatar
pat
 
Posts: 53
Joined: Tue Jul 20, 2010 7:55 pm

Re: cpBody function no const cpBody *

Postby BLWNKL » Thu Sep 02, 2010 7:52 pm

Hi all...
In trying to learn how to use cpBodyLocal2World, I discovered that the object (sprite) I wish to use as the "target" of a projectile actually has no cpBody (since it's not included in the space because I don't want it to actually participate in collisions per se). A good way to think of this is as "an aiming point" in the space.
So I'm wondering if (based on the discussions in this thread about const cpBody objects) this approach makes sense? Or is there a better way to accomplish what I describe?
BTW, I'm struggling with the notion of "world coordinates". Are they different from the iPhone view coordinate system, where 0,0 is upper left?
Thanks in advance for any thoughts you may share.
BLWNKL
 
Posts: 3
Joined: Sat Jun 05, 2010 10:13 am

Re: cpBody function no const cpBody *

Postby ShiftZ » Fri Sep 03, 2010 5:51 am

BLWNKL
There is no such things as iPhone coordinate system, and cpBodyLocal2World doesnt concerned with screen coords. You have to have somekind of Viewport object, whitch can translate from screen coordinates to world coordinates and back taking in a count camera position, gl projection matrix ect.
ShiftZ
 
Posts: 114
Joined: Sat Mar 07, 2009 7:23 am


Return to Bugs

Who is online

Users browsing this forum: No registered users and 2 guests

cron