[BEHAVIOR] Chipmunk Physics

  • This seems quite nice, and complete. Thank you

  • according to the chipmunk's manual:

    "Kinematic bodies are bodies that are controlled from your code instead of inside the physics engine.

    They arent affected by gravity and they have an infinite amount of mass so they don’t react to collisions or forces with other bodies.

    Kinematic bodies are controlled by setting their velocity, which will cause them to move.

    Good examples of kinematic bodies might include things like moving platforms.

    Objects that are touching or jointed to a kinematic body are never allowed to fall asleep."

    also i havent figured out how to make a player's movement with this, apparently its 2 bodies attached with a pivot joint and a simple motor joint (with a rate of 0) then dynamically adjust the maxForce to the desired friction, i haven't tried it though, i think this should be in their manual since it is such a common thing to attemp

  • OFF TOPIC

    Hmm, R0J0's been quite lately.

    He must either be:

    A. Teaching Chuck Norris how to be a computer ninja, or

    B. Making a paradigm changing plug.

    loller .... btw u know u have more badges then tom and ashley?:)) funny ....

    On topic looks great :X let me try this

  • If no one has already posted benchmarks then here we go:

    These were made using a win7 i5 laptop.

    The test, Box containing small bouncing balls with 100% elasticity... I continued to add balls until the cpu usage fluctuated to greater than 85%

    Box2dWeb: 600

    AMS.JS: 850

    Chipmunk: 1400

    Something to note here which is very important. AMS.JS Keeps low cpu usage and then once you cross a object count it sky rockets to 90-100% . Box2d is much more linear in its object count to cpu usage. Chipmunk starts to use more cpu as the balls settle (which they shouldn't be doing). The settling becomes more pronounced as the object count increases.

  • Chipmunk starts to use more cpu as the balls settle (which they shouldn't be doing). The settling becomes more pronounced as the object count increases.

    Chipmunk's default settings for putting an object to sleep seem too aggressive. I sometimes get floating physics sprites when an object underneath is knocked away, worse for circle collision shapes since their contact area is lower.

    A fix is to adjust idle speed threshold and/or sleep time threshold. Maybe try an idle speed threshold of 0.5s at first. If things are still settling too soon then lower it, or try a sleep time threshold of 2s.

    You can disable sleeping altogether by setting sleep time threshold to 'Infinity'.

  • Chipmunk starts to use more cpu as the balls settle (which they shouldn't be doing). The settling becomes more pronounced as the object count increases.

    That seems strange, I wonder if that has any relation to the memory leak that occurs after a while of leaving the game running.. does the cpu go back down? or does it remain higher?

  • mattb thanks, I need to learn the peculiarities of this engine, but so far I have done little with it.

  • Prominent I am not sure, I didn't run the test very long. Once I managed to reach 85+% I would leave it running for a little bit to make sure it wasn't something else that cause the cpu to spike up. It seems once you reach a high cpu usage, it starts to trend up up until you are at 95-100%. It could be the memory leak, but I thought it was supposed to be a small one. Also... how is there a memory leak? Isn't it written in javascript?

  • ruskul

    From what I've found the js profiler indicates that hundreds of tiny js objects are accumulating over time. For some reason those object's aren't able to be gc'd, presumably because there's some reference to them still somehow. All I can get out of the profiler so far is the type of these objects (mainly array and code objects), but I haven't had any luck figuring out what they are exactly or where they came from. Also the slowdown is presumably due to the added load of the garbage collector to sort though those objects.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • R0j0, how are you profiling the chipmunk performance? I'm quite a newcomer to Chipmunk, but I've been trying to understand its structure... so I ran a test on IE and Chome, and started investigating what could be the reason behind slowdowns... for me the most time is spent on BBTree.prototype.reindexQuery - it feels like almost an infinite nested loop - each prototype.markSubtree contains another prototype.markSubtree inside.

    The tree becomes so nested that it's impossible to show on a screenshot. I'll include few screenshots (on the second screenshot you can see there's some anon_func happening under the Leaf.prototype.markSubtree):

    *EDIT* too little rep to post urls, I hope this works:

    1.

    drive.google.com/file/d/0B3rBbgxb44dscC04UG43WGVWakk/view?usp=sharing

    2.

    drive.google.com/file/d/0B3rBbgxb44dsVnpkX3c4b09VR0E/view?usp=sharing

    3.

    drive.google.com/file/d/0B3rBbgxb44dsYmZ3TEdwQzA2dFU/view?usp=sharing

    In my experience, the runtimes spent on individual Node/Leaf .prototype.markSubtree and Node/Leaf .prototype.markLeafQuery are growing as they nest. Could BBTree.prototype.reindexQuery be the source of the memory leak?

  • striimix

    Those functions are related to the chipmunk.js library's spacial partitioning scheme. It's nested because it's a tree structure and it would make sense that it would be called a lot as it would update as objects move. In my tests it's only taking about 5% of the total time and it's size is remaining constant (251 leaves for 251 objects), so that's not the culprit.

  • R0J0hound , is it better to have one post-collision event, or is it okay to have multiple post-collision events in an event sheet (same object for each event)?

  • It would be the same as for instance a "start of layout" condition. Any way you set it up is fine. no extra calculations are done and c2 just triggers them top down.

  • Thanks R0J0hound for checking into it... in the end, I modified this.idleSpeedThreshold and this.sleepTimeThreshold to suit the game style... and left the game running a 250x250 tile level for 3 hours, the physics seem to go properly to sleep and there's no notable performance issues. I'm really impressed with chipmunk so far =) Can't thank you enough for your hard work (earlier I was looking into matter.js but you really saved a lot dev time for me). I'm working on a ragdoll physics game, and box2D just wasn't diverse enough for my needs (angled gravity etc.)

  • I've been looking at Chipmunk recently and I like what I'm seeing, but I'm having some travel setting up the system that I want. I'm trying to make a realistic mountain bike. Those have suspension that makes navigating little bump and hard drops easier. I've been able to set up the rigid fork on the bottom of the image below, but I want to get it working like the suspended fork at the top.

    I have a sprite that is the frame, one that is the fork and one that is the wheel. With what joints would I connect those to end up with a realistic suspension? Thanks in advance.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)