[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Sun Jul 20, 2014 11:30 pm

What is it?
A new physics behavior that uses Chipmunk Physics instead of Box2d. It's built on a JavaScript port found here: https://github.com/josephg/Chipmunk-js which is based on Chipmunk2d 6.1.1.

It differs from C2's physics behavior in a few ways. For instance this behavior works when you manually set positions at runtime and you don't have to wait a tick before adding joints. Also the Warp behavior will work with this one without a hitch. Another difference is when adding joints you use an object uid instead of picking the other object, which simplifies adding joints between instances of the same type.

Features:
* Collision shapes: None, Box, Circle, Polygon and rounded Segments. (Segments can't collide with other segments)
* Support for concave polygons.
* Support for tilemap object.
* Standard object properties: Mass, Elasticity and Friction which can all be set at runtime.
* Collision filtering:
1. Collision groups that allow objects not to collide with other objects in the same non-zero group.
2. Collision layers which is basically 32 different layers, and the object can be in any number of them, and will only collide with objects that share a layer.
* Additional expressions: inertia, center of mass and area.
* Every joint chipmunk2d has to offer is available to use. http://chipmunk-physics.net/release/ChipmunkLatest-Docs/#cpConstraint-Video
* Ability to specify where on the object's the joints are attached.
* Ability to destroy individual joints, get the current impulse applied to a joint, and get the number of joints an instance has.
* Global properties: Damping, Iterations, fixed timestep, and Gravity.
* Ability to set and get: Velocity, angular velocity, force, impulse and torque.
* All actions that set force, impulse, velocity, gravity, etc,... can be set with an xy or an angle and magnitude.
* Force and impulse can be applied to an offset on the object.
* Collision info with the "Post Collision" condition. With it you can get:
1. Kinetic energy of collision.
2. Impact of a collision.
3. UID of other chipmunk object hit
4. Number of contact points and the point, normal and penetration depth of each.
* Closest point and Segment ray casting with expressions to get the point, distance, and normal with ray-cast.
* Utility expressions to convert coordinates from layout (world) to local (relative to the body) and back.
* Ability to set speed limits to objects and force limits to joints.
* Chipmunks automatic object sleeping with actions to manually put to sleep and wake up.
- As well as global properties to set the "idle speed threshold" and the "sleep time", which is the time idle before going to sleep.

Download:
https://app.box.com/s/jt9f8r1mqmq07pbthiydvrgzikp5d29f
To install extract zip file into "C:\Program Files\Construct 2\exporters\html5\behaviors".

Simple joints Example:
https://www.dropbox.com/s/glddumkw3mt64 ... .capx?dl=0

Conditions:
Image
Actions:
Image
Expressions:
Image

-cheers
Last edited by R0J0hound on Wed Mar 22, 2017 3:51 am, edited 38 times in total.
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Sun Jul 20, 2014 11:42 pm

It seems faster than Box2D to set positions, nice
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Mon Jul 21, 2014 12:03 am

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.
Image ImageImage
B
172
S
50
G
183
Posts: 8,439
Reputation: 115,597

Post » Mon Jul 21, 2014 2:31 pm

Looks great , hopefully it will work out , will keep an eye on this .
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Wed Jul 23, 2014 1:16 pm

I will definetely watch out for this ;)
But as soon as this behavior is completed, we definetely need an Performance Comparison.
Keep up the good work R0J0 :)
I definetely see possibilities when we think about Moddability,
with setting an Collision Polygon at runtime.
Looking forward to see this complete and compete.
- Conti
"It's done when it's done"

Shadows of War
Buy on Steam ;)
B
24
S
10
G
7
Posts: 253
Reputation: 4,931

Post » Wed Jul 23, 2014 5:35 pm

Uploaded beta #2.
+ Got circle and polygon collisions working. However concave polys are currently just converted into convex hulls.
+ It works now if the origin is off center.
+ Added joint I forgot (rotary limit joint).

There were a couple issues that came up that took longer to work around than expected. As a side effect body sleeping may not be possible now, but we'll see.

@newt
Don't need to teach a guy that can roundhouse kick his keyboard and get millions of lines of error free code.

@granpa
Thanks.

@Joannesalfa
@SgtConti
I'm not really going for speed, but function. But it could be interesting to benchmark when it's done*.

SgtConi, changing the collision shape at runtime is more along the lines of changing the collision type. ex. None,Box,Circle or Poly. Changing the points of the collision polygon is another deal, which could prove tricky since chipmunk2d only works with convex polygons.
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Thu Jul 24, 2014 11:51 am

@R0J0hound

I assume there will be an option to change Mass at runtime ?
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Thu Jul 24, 2014 12:11 pm

waiting on it :D
~Everyone can make GAMEs~
B
58
S
12
G
1
Posts: 414
Reputation: 5,961

Post » Thu Jul 24, 2014 4:44 pm

spongehammer wrote:@R0J0hound

I assume there will be an option to change Mass at runtime ?

yep
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Sat Aug 09, 2014 5:54 pm

Played around with it a bit, it feels better/funnier than original box2d. Looking forward to it.
B
45
S
11
G
4
Posts: 517
Reputation: 7,398

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest