EmiOnGit / warbler_grass

A bevy plugin for creating 3d grass in your game
Apache License 2.0
137 stars 11 forks source link

Fix grass never spawning if cache started out empty #28

Closed janhohenheim closed 1 year ago

janhohenheim commented 1 year ago

Discovered this one while lazily loading grass from a tag I put on a GLTF.

EmiOnGit commented 1 year ago

@janhohenheim Can you explain the solution? I currently don't see what the problem was

janhohenheim commented 1 year ago

In my use case, the grass is spawned at some random point during the game. So, before that, for instance_data in cache.values_mut() ran a noop and instance_data.uniform_bindgroup was left at None. Later on, this is not updated because of the early return, so it stayed at None forever. This change makes sure that the last_texture_id stays at None until we actually spawned anything, so that the early return cannot be triggered.

EmiOnGit commented 1 year ago

Ok sure thanks. Seems a bit hacky but totally fine for now