[v1]Walkmesh implementation

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
KakCAT
Posts: 24
Joined: Mon Apr 14, 2014 2:08 pm

[v1]Walkmesh implementation

Post by KakCAT » Mon Mar 18, 2019 9:18 am

Hi, I need to restrict the player movements to certain regions of my game. Each of my maps will have a 2D walkmesh (zones a player can walk on).

Image

What I'm planning to do is using a [v1] Mesh and create a high wall using the 2D exterior edges of the walk mesh.

Is this the best way to implement this? Is there a recommended height of the wall? I mean, ideally I could do it 100 meters hight but I've read that very big polygons tend to give stability problems when detecting collisions.

Thanks!

ArchieMac
Posts: 1
Joined: Sat Mar 16, 2019 9:35 am

Re: [v1]Walkmesh implementation

Post by ArchieMac » Mon Mar 18, 2019 2:46 pm

Won't the wall that high look really bad?

Norbo
Site Admin
Posts: 4616
Joined: Tue Jul 04, 2006 4:45 am

Re: [v1]Walkmesh implementation

Post by Norbo » Mon Mar 18, 2019 8:47 pm

I'd just recommend trying some extruded triangles of the desired height and seeing if it works well enough. It's true that v1 triangle tests can have some numerical issues in extreme cases (particularly with extreme ratios), but it often works fine.

If it ends up being an issue, you can just subdivide the surface into more triangles to keep them smaller/more regular.

(As always, v2 tends to be more robust in difficult situations.)

KakCAT
Posts: 24
Joined: Mon Apr 14, 2014 2:08 pm

Re: [v1]Walkmesh implementation

Post by KakCAT » Wed Mar 20, 2019 2:05 pm

thanks for the answers!

@Norbo: Yes, that's what I had in mind. I implemented it (with StaticMesh) and seems to work very well for the moment :) A question though: what do you mean by extreme cases? Very big triangles (compared to the colliding objects), or triangles that are big in one dimension but small on other? (i.e. a triangle with base: 1m and altitude 100m)

Also, how big this relation should be to start worrying? (10:1, 100:1, 1000:1)...

@ArchieMac: It's a "physics wall", it's completely invisible to the player, it's not rendered.

Norbo
Site Admin
Posts: 4616
Joined: Tue Jul 04, 2006 4:45 am

Re: [v1]Walkmesh implementation

Post by Norbo » Wed Mar 20, 2019 10:07 pm

A question though: what do you mean by extreme cases? Very big triangles (compared to the colliding objects), or triangles that are big in one dimension but small on other? (i.e. a triangle with base: 1m and altitude 100m)
Both can cause issues, though you'll often see more with sliver-like triangles (1x100). The ideal case is two cubish-shapes of nearly the same size; the further you get from that, the harder it is numerically.
Also, how big this relation should be to start worrying? (10:1, 100:1, 1000:1)...
It depends, but 10:1 is almost always fine. I don't think I've seen any issues at 10:1 without some other weird stuff happening. 100:1 can start getting iffy sometimes, and 1000:1 will often show issues unless the interaction is limited in some way.

Notably, collision with the face of a triangle tends to be very robust- you could create a triangle 10000x10000x10000 and drop a 1x1x1 box on it and it'd probably be fine. That's due to a very simple planar special case. Edges require a lot more numerically detailed work, so tend to show issues more quickly.

Also, v1 is sensitive to absolute scale. The default configuration targets object sizes somewhere in the 0.5 to 10 unit range for ideal behavior. Objects way outside that range can cause issues. The demos ConfigurationHelper.ApplyScale can be used to adjust the relevant settings for larger or smaller sizes.

(And the usual v2 note: v2 is not sensitive to absolute scale and robustly handles much more extreme relative sizes.)

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests