0

I'm trying to code the solar system, but pymunk doesn't code for adding gravitational forces between bodies, whilst chipmunk does. One method I can use is trying to manually add it in. I attempted to follow what it said here: http://www.pymunk.org/en/latest/advanced.html, and create a python method. However, it hasn't been working. I also tried to just copy cpDamnpedSpring and translate it to python personally, but that failed, the main problem being my lack of knowledge on C. Specifically, I'm confused what to replace in this:

First we need to check if its included in the cdef definition in pymunk_extension_build.py. If its not just add it.

cpBool cpBodyIsSleeping(const cpBody *body);

Then to make it easy to use we want to create a python method that looks nice:

def is_sleeping(body):
    return cp.cpBodyIsSleeping(body._body)

What should I put inside the brackets, e.g., if I wanted cpDampedSpring?

1 Answers1

0

Lets say you wanted to make your own cpDampedSpring called cpDampedSpring2. The advanced section doesnt really cover this, but on the high level it should be fairly straight forward:

  1. (Checkout pymunk and the chipmunk submodule, verify that you can compile the code python setup.py build_ext --inplace)
  2. First make the new cpDampedSpring2 in Chipmunk. Bascially search the code the make copies of all mentions of cpDampedSpring. :)
  3. Update pymunk_extension_build.py and add the new cpDampedSpring2 there in the same way, (search for cpDampedSpring and copy each mention)
  4. Verify that it can all compile
  5. Do the same search-copy thing in the python code
  6. Verify that it can all compile again, also try to use the new DampedSpring2 from python to make sure its as good as the old one.
  7. Now you do the actual changes you need in cpDampedSpring2.
viblo
  • 4,159
  • 4
  • 20
  • 28