Skip to content

Dot32Dev/marching_squares

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

marching_squares

Screenshot 2023-05-29 at 11 22 18

Marching squares implemented in Bevy, with a mesh that updates every frame! Egui is used for an interactive settings menu.

If you would like to try making this yourself...

Rather than trying to read my pile of spaghetti code, I recommend watching this video by The Coding Train. When it comes to implementing Lerping (which is not covered in the video), you can use an inverse lerp function with your two points' values as a and b, and your threshold as the "value" argument. It will return a t value, representing how far along the threshold is between your two values. You can then use this to move mesh points around.

I found this project useful in learning procedural mesh generation in general. The "positions" describe all of the vertices, and the indicies describe which vertices are used to create each triangle. This allows rendering a quad with only 4 vertices instead of 6, for example, as some vertices are reused. When it came to spawning the mesh, I followed this bevy example that spawned a default quad mesh.

If you want to update the mesh, remember to query for a Mesh2dHandle instead of a Handle<Mesh>, this just being an annoying inconsistency between 2D and 3D in Bevy.

About

Marching squares implemented in Bevy, with a mesh that updates every frame

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages