Jump to content
  • Advertisement
  • entries
  • comments
  • views

Edge Clipping

Sign in to follow this  


Well, that was all a bit hardcore. Decided that the only way I could get edge walking working the way I wanted was to preprocess the edges to turn this:


Into this:


I was going just add the edges manually in the editor, but I thought this would get awkward so wanted to have a way to have it sorted automatically and now we have. Its run in the game as a preprocessing step although I might move it out at some point.

The idea is that each shape maintains a list of edges, with start, end and normal for use in the edge walking system. The preprocess starts by setting the edges around the top of each shape so you get the first image.

The challenge then is to convert these edges so that where two edges are coincident, they get clipped out. My algorithm runs through each edge, uses the physics broadphase to get all the shapes that are potentially colliding then compares each edge on that shape to the current edge. Getting a t >= 0 <= 1 value, it then generates a clip-list for the segment, with each item in the list representing a range of the segment that is coincident with another edge.

Then it is a simple (ha ha ha) process of inverting the range, and generating a new edge list for the sections of the original segment that are not covered by the clip list.

So now, you can walk up to any edges but not walk off them, a la Tomb Raider 1. Phew.

Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!