lumber,

It's been a minute since I've posted, so here's what you've missed...

lumber,
lumber,

Then I took a week off of work to focus on the editor. I hate UI work and the only way to get past it was to just get in done. The key to getting it done was someone on the discord directing me to a discussion on the github about implementing egui widgets as SystemParams: https://github.com/bevyengine/bevy/discussions/5522

It's a little out-of-date now, but I have a gist for it implemented for bevy 0.10:
https://gist.github.com/dmlary/a40e29de0e9ec78950bb5f352115710a

With this I was able to clean up the UI code and add the functionality I needed.

Showing 3d hex-based map editor. Map is rotated, a mountain tile is placed, cursor moves to the palette and selects a water tile. Places water on map. Then map is moved. Assets from kenney.nl

lumber,

After getting map editing to a happy place, I decided to tackle save/load. Umm, yea, that's awful.

Bevy has a handful of "save the entities & components" capabilities:

Things I learned:

  • reflection is really hard in rust
  • bevy_reflect has a lot of cool changes coming to make it easier
  • A map editor shouldn't use entity/component-based saving
lumber,

Cool things in the works for bevy_reflect that I stumbled across a need for during save/load research:

Literally every place I hit a roadblock, there was an open PR in bevy with a fix. Side-note every one of these PRs is opened by MrGVSV, so they became my absolute favorite person that week.

lumber,

I did this research into reflect internals because I started doing load/save with bevy_save. I was misuing it to generate multiple save files in user-specified locations. It gave me a good jumping off point, but ended up being a dead-end.

bevy_save deserialization is done via reflection. Right now every type (even nested types) must be registered with bevy_reflect for this to work. I also hit some Hash reflect headaches too.

Both of these have open PRs, so they'll be resolved.

lumber,

I also tried to use serde directly with entities. The key roadblocks there:

  • cannot get from bevy::ptr::Ptr to &dyn Serialize
  • no way to get dyn Serialize vtable for an arbitrary type without using nightly

I learned a lot understanding how to even understand & phrase what prevented it.

lumber,

At this point I took a few steps back and reconsidered what I was doing. I realized I shouldn't be saving Components for a map editor. This is a generic editor for the moment so I can learn things. The output should be a fixed format, not whatever trash I happen to have in my components at the time (there's a lot; you'll see).

So I took another approach:
Take the entities in the world and construct an intermediate Map representation, and serialize that.

lumber,

And then my dog died, and that really fucking sucked. Still does. He was a real good pup.
Hard to want to write do anything when you're crying all the time.

adamjcook,

@lumber So sorry for your loss. 😓

lumber,

After three implementations (minimum to make something not cruft) I got saving & loading working. Also got layers working too!

The level editor finally hit a place where it was minimally functional, so I shared the code as reference for how to do a bunch of things in

https://github.com/dmlary/bevy-hex-sandbox

Demo of a 3d hex-based tile editor. Exiting map is moved around, additional tiles are placed, creating paths over a grassy field with mountains, trees, a cabin. Assets from kenney.nl

lumber,

After using the level editor for a while, I realized placing tiles by hand is the absolute worst way to do it, especially when you have to manually rotate & select the proper path piece to place. So I'm working on an entirely different approach for level editing next.

lumber,

But as a break from the tile editing, I decided why not implement an infinite hex-grid shader in ; I'm gonna need it eventually, right 🤷‍♂️.

So I started with looking at bevy_infinite_grid: https://github.com/ForesightMiningSoftwareCorporation/bevy_infinite_grid

Ok, very much in over my head. Went looking for a very dumb example of running a shader in bevy. No uniforms, no craziness, just let me act like this is shadertoy.

lumber,

So has so many wonderful examples, but when you're looking for something simple in rendering, all of the examples tend to look way more complex than what you need. So I decide "naw, none of these are it", so I went and read a bunch of code & examples and wrote my own:

https://gist.github.com/dmlary/3822b5cda70e562a2226b3372c584ed8

Then some of the rendering people in the discord directed me to the post-processing example, and after understanding things I saw it was what I needed. Learning is great! (and updated my gist)

lumber,

As of today I now have an infinite hex grid shader in , with the current cursor position highlighting. Sharing source code because it's always helpful to have an example: https://github.com/dmlary/bevy-hex-grid

Hex-grid outline projected on an xz plane. Camera rotates around. Hex outline at the cursor is highlighted in yellow.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • PowerRangers
  • hgfsjryuu7
  • InstantRegret
  • Youngstown
  • rosin
  • slotface
  • everett
  • mdbf
  • tacticalgear
  • kavyap
  • thenastyranch
  • DreamBathrooms
  • ngwrru68w68
  • magazineikmin
  • Leos
  • vwfavf
  • cisconetworking
  • cubers
  • modclub
  • GTA5RPClips
  • khanakhh
  • Durango
  • osvaldo12
  • normalnudes
  • tester
  • ethstaker
  • anitta
  • provamag3
  • All magazines