kivent icon indicating copy to clipboard operation
kivent copied to clipboard

Moment of a Body is calculated automatically from component shapes

Open inclement opened this issue 9 years ago • 3 comments

It is impossible to set a manual value for the moment, including (for example) the 'INF' string to set infinite moment.

inclement avatar Jan 10 '15 01:01 inclement

Yes - though you may have to use 0 instead of 'INF'. In the shapes creation dict takes a mass value, as here: https://github.com/chozabu/KivEntEd/blob/master/main.py#L192 (wow, I need to tidy up that code) IIRC a shapes mass is separate to its bodys mass and only used for its moment calculation. You should also be able to set the moment on the shape separately after creation.

Relevant section of KivEnt code is here: https://github.com/Kovak/KivEnt/blob/new_rendering/modules/cymunk/kivent_cymunk/physics.pyx#L250

chozabu avatar Jan 10 '15 02:01 chozabu

The problem is that the KivEnt code only allows a numeric moment based on the mass of the shape. I don't think passing 0 does anything special, it just leads to a moment of 0 being passed to the body (seems to just break the physics if I try it, I guess because the moment is too low to be sensible), and it isn't possible to pass 'INF' because the variable is cython-typed as a float.

inclement avatar Jan 10 '15 03:01 inclement

I see what you mean. seems you an set it after creation with body.moment=float('inf')

would be good to have this in KivEnt somehow - perhaps a flag in the bodys dict

chozabu avatar Jan 10 '15 03:01 chozabu