cocos2d-objc icon indicating copy to clipboard operation
cocos2d-objc copied to clipboard

CCPhysics area/density properties.

Open slembcke opened this issue 13 years ago • 5 comments

So I commented out these two properties a couple of weeks ago. The problem was that the area of a node can be changed by changing it, or an ancestor's transform. The actual body isn't set up until it enters an active scene. So you could get a non final value or set an incorrect density if not careful with operation order. Secondly, by adding the CCPhysicsShape type and allowing composite bodies, setting the density of a body is somewhat poorly defined.

Both properties seemed pretty useful. I left them out of the alpha to make sure that the issues above were thought through carefully.

I'm sort of changing my mind about this. An overwhelming majority of the time, CCNodes use only rigid transforms (position/rotation) and it wouldn't be an issue in those cases at all. Furthermore, it's not like there aren't other methods such as the bounding box or transform ones that depend on the current node's (and it's ancestor nodes') setup when returning results.

Should I just put the area/density functions back in? Is a comment about this in the documentation sufficient to explain the issue?

edit: Ended the first paragraph with an incomplete sentence. >.>

slembcke avatar Nov 20 '13 20:11 slembcke

Hierarchies tend to be pretty flat too, in addition to not often being scaled. I think just mentioning this in docs should be sufficient.

Already, you can scale physics bodies and their mass isn't affected. So it seems reasonable.

Most of the use of scaling parent nodes is probably for UI sorts of things.

andykorth avatar Nov 20 '13 21:11 andykorth

Seems to me that accessing the area and density are much more important than correctness when scaling. My vote goes to putting them back in.

vlidholt avatar Nov 21 '13 01:11 vlidholt

I can not really grasp what implications this have. What is the difference between mass and density? Never used area. On the other hand, I have used objects scaling extensively ... ie the unsafe resize functions in old chipmunk. Would hate to lose that.

Birkemose avatar Nov 22 '13 09:11 Birkemose

Mass is a...

Density has a...

Sent from my iPad

On Nov 22, 2013, at 5:26 PM, Birkemose [email protected] wrote:

I can not really grasp what implications this have. What is the difference between mass and density? Never used area. On the other hand, I have used objects scaling extensively ... ie the unsafe resize functions in old chipmunk. Would hate to lose that.


Reply to this email directly or view it on GitHub.

dissidently avatar Nov 22 '13 10:11 dissidently

Pushed. I ran into another issue that I'd forgotten about from earlier that I'd been mulling on for a couple of days. I think the code for it had ended up in my git stash a half dozen times. :-\ Found a dumb, but correct solution. (Need to guess the non-rigid part of a node's transform before it's physics body is even active.)

slembcke avatar Dec 12 '13 04:12 slembcke