[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Fri Feb 13, 2015 4:15 pm

ruskul wrote: 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?
B
45
S
21
G
65
Posts: 1,115
Reputation: 38,221

Post » Sat Feb 14, 2015 5:43 pm

@mattb thanks, I need to learn the peculiarities of this engine, but so far I have done little with it.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Sat Feb 14, 2015 5:47 pm

@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?
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Sat Feb 14, 2015 7:13 pm

@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.
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

Post » Sun Feb 15, 2015 10:15 am

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?
B
14
S
3
G
1
Posts: 78
Reputation: 1,037

Post » Tue Feb 17, 2015 5:06 am

@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.
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

Post » Tue Feb 17, 2015 8:47 am

@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)?
B
45
S
21
G
65
Posts: 1,115
Reputation: 38,221

Post » Tue Feb 17, 2015 8:56 am

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.
B
92
S
32
G
109
Posts: 5,291
Reputation: 70,993

Post » Tue Feb 17, 2015 1:34 pm

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.)
B
14
S
3
G
1
Posts: 78
Reputation: 1,037

Post » Wed Feb 18, 2015 12:23 am

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.

Image
B
10
S
2
G
1
Posts: 49
Reputation: 693

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: Apollo14 and 2 guests