Weird issue with gravity in VelocityFunc (chipmunk 4.1.0)

Discuss new features and future development.

Weird issue with gravity in VelocityFunc (chipmunk 4.1.0)

Postby cheery » Wed Jun 24, 2009 5:07 pm

I wrote new wrappers for chipmunk. Though now when I'm writing examples to show usage, features and to test everything works just fine... well you get the idea.

Why I wrote a wrapper since there were already pymunk for python? I started playing out with pymunk first, but after a long I wanted some convenience (in form of fixed bugs). I Decided to modify pymunk just a bit to add that convenience. My face was about :shock: when I looked inside that thing. It was all unclear mess with lots of unused or broken code. After modifying it a bit I concluded that it'd be much more convenient to just do it again from scratch by looking pieces from here and there. It's not perfect (probably right now has lots of broken features [haven't tested them! :D ]), and in amount of features I dropped to a certain subset I saw fit (after I'll get everything working and have a fine documentation, I'll start considering which to drop and pick up.

After I got the velocity function setters to action, I hit this weird thing: gravity vector coming to the velocity updater is zero! It doesn't harm my bindings though, since I don't necessarily need the gravity variable through the velocity updater. Here's some code from my examples:
Code: Select all
poly.collided = 0.0

@pendulum.set_velocity_func
def pendulum_update_velocity(body, gravity, damping, dt):
    damping *= 0.95
    body.reset_forces()
    if poly.collided > 0.0:
        n = body.local_to_world(Vec2d(-10000.0, 0)) * poly.collided
        body.apply_force(n*body.m, Vec2d(0, 0))
        poly.collided -= dt
    body.v = body.v*damping + (grav + body.f * body.m_inv) * dt
    body.w = body.w*damping + body.t * body.i_inv * dt

@space.collision_pair(0, 1)
def hammer_pack(something, hammer, contacts):
    hammer.collided = 0.5
    return True


This thing accelerates pendulum for a small moment every time when a ball hits it. It is the first dumb thing that I had to try, anyway, I can get gravity directly from the space object, so I could just ignore the gravity variable in the velocity updater. Though I'd like to get it working. Ideas? Anyone?

The mercurial repository is there if you want to look in: http://bitbucket.org/cheery/ctypes-chipmunk/
cheery
 
Posts: 2
Joined: Wed Jun 24, 2009 4:36 pm

Return to Features/Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron