terrain by lots of cpSegments

Official forum for the Chipmunk2D Physics Library.
Post Reply
jordo1234
Posts: 3
Joined: Sun Feb 28, 2010 3:19 pm
Contact:

terrain by lots of cpSegments

Post by jordo1234 »

I've been banging my head against a wall for a few days... I'm pretty sure I've narrowed down my problem to how my terrain generator works.

Basically, I think I'm trying to do something similar to what slembcke is doing... i think it's pretty similar to the "Zombie Race terrain engine" video posted on here a while ago. Anyways, i think my terrain data is generated fairly similar. Basically it ends up being just lots and lots of cpSegmentShapes... The problem is though, is I can NEVER seem to get a ball or anything rolling 'smoothly' across the terrain if the terrain is made up of really small line segments.

So. say i have a slightly inclined plane of length 10. If i roll a ball up this terrain, it will roll fine. If i however split up the plane into 100 line segments (all would each be length 0.1), the ball will never roll smoothly... It always bounces, and seems to get weird collision angles... (even i have elasticity of both objects zero).. I've tried single balls, 'dirt bike' type arrangements, a test moon buggy with spring shock constraints, etc..

The only thing I can think of whats going on here, is that the ball (or wheels), are colliding with the endpoints of the cpSegments instead of the sides of the cpSegments... It seems I've tried and tweaked everything I can think of, but I just can't get rid of this behavoir. The only thing that seems to work, is just have less cpSegments, but I can't do that because having less cpSegments in my terrain, means that it's less accurate to match the png that it's generated from.

slembcke, feel like sharing any secrets in the "Zombie Race terrain engine"? Did you come accross this behavoir at all? Anyone encounter this behavoir?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: terrain by lots of cpSegments

Post by slembcke »

Yeah, the problem is that you are colliding with the endpoints of the segment shapes. The easiest way to reduce the effect of that is to give your line segments a non-zero radius. Adding a radius of two pixels or so is usually not very visually significant on terrain, but can make the collisions much much smoother.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
jordo1234
Posts: 3
Joined: Sun Feb 28, 2010 3:19 pm
Contact:

Re: terrain by lots of cpSegments

Post by jordo1234 »

thanks for the tip...

i'll play around with the radius like you suggested, see if that helps...
jordo1234
Posts: 3
Joined: Sun Feb 28, 2010 3:19 pm
Contact:

Re: terrain by lots of cpSegments

Post by jordo1234 »

Tried various radius settings on my segment shapes, but nothing really working.

I am using a ton of segments, some even 2-3 pixels in length...

Since the nature of the terrain, essentially one big convex poly, in my case collisions should never be happening on the end points, just the surfaces.

I'm wondering if it's possible to fit the circle<->segment collision logic to this somehow... get me started in the right direction?
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests