bevy_tilemap icon indicating copy to clipboard operation
bevy_tilemap copied to clipboard

Handle zoom?

Open mattdm opened this issue 3 years ago • 8 comments

What problem does this solve or what need does it fill?

It'd be very nice for tilemap to handle (arbitrary, smooth) map zoom in addition to panning.

Describe the solution would you like?

As I see in the examples, panning is accomplished by manipulating the 2d camera translation directly. It happens that zoom in 2d works by scaling everything rather than moving the camera. It would be nice (but not essential) for this to all be accomplished in one interface.

(Super awesome bonus: smooth pan/zoom where you give target values and a system updates them over a number of frames.)

Describe the alternative(s) you've considered?

Coding it all myself rather than working on my actual game stuff. :)

mattdm avatar Mar 14 '21 23:03 mattdm

Also, related #95 — the "what was clicked" code could/should be zoom aware.

mattdm avatar Mar 14 '21 23:03 mattdm

Bevy's main branch now has a scale property on OrthographicProjection so you can zoom in using the camera. I believe that should solve both problems.

irate-devil avatar Mar 17 '21 18:03 irate-devil

Awesome, yeah, I was certain it was related to Bevy itself, not the Tilemap. Can only do as much as the base lib can do. Thanks for the heads up @Devil-Ira

joshuajbouw avatar Mar 18 '21 04:03 joshuajbouw

@joshuajbouw Just checking that the rendering / chunking functions don't make assumptions based on camera zoom. If that is all handled, then cool. :)

mattdm avatar Mar 20 '21 16:03 mattdm

Hm, that I would need to double check.

joshuajbouw avatar Mar 21 '21 05:03 joshuajbouw

I attempted to use the OrthographicPorjection's scale property to zoom in/out, but you get weird lines. Example: island

Its possibly related to having precision errors, or some sort of filtering issue. Camera code found here: https://github.com/StarArawn/bevy_roguelike_prototype/blob/main/src/game/camera/input.rs

StarArawn avatar Apr 10 '21 11:04 StarArawn

Using the following code helps a little bit however I still get lines:

let atlas_texture = textures.get_mut(tilemap_atlas_handle.clone()).unwrap();
atlas_texture.sampler.min_filter = bevy::render::texture::FilterMode::Nearest;

island2

StarArawn avatar Apr 10 '21 12:04 StarArawn

I have a PR open that fixes the line issue: https://github.com/joshuajbouw/bevy_tilemap/pull/153

StarArawn avatar Apr 15 '21 22:04 StarArawn