Zoom Progress: Actor/Link Tool Hitboxes

* When the Actor Tool or Link Tool is active, mouse-over hitboxes on the
  level's actors now works correctly while zoomed and scrolling in the
  level.
* Regression: Level chunks don't appear outside a certain range from
  origin while zoomed in.
* Regression: Actors don't draw their sprite while zoomed in, but do
  when zoomed out.
zoom-hell
Noah 2021-09-12 14:42:39 -07:00
parent 731d142dd6
commit 6f5bd910c8
2 changed files with 29 additions and 13 deletions

View File

@ -304,9 +304,20 @@ func (w *Canvas) loopEditable(ev *event.State) error {
var deleteActors = []*level.Actor{}
for _, actor := range w.actors {
// Compute the bounding box on screen where this doodad
// visually appears.
var scrollBias = render.Point{
X: w.Scroll.X,
Y: w.Scroll.Y,
}
if w.Zoom != 0 {
scrollBias.X = w.ZoomDivide(scrollBias.X)
scrollBias.Y = w.ZoomDivide(scrollBias.Y)
}
box := render.Rect{
X: actor.Actor.Point.X - P.X - w.Scroll.X,
Y: actor.Actor.Point.Y - P.Y - w.Scroll.Y,
X: actor.Actor.Point.X - P.X - scrollBias.X,
Y: actor.Actor.Point.Y - P.Y - scrollBias.Y,
W: actor.Canvas.Size().W,
H: actor.Canvas.Size().H,
}
@ -356,9 +367,19 @@ func (w *Canvas) loopEditable(ev *event.State) error {
continue
}
// Compute the bounding box on screen where this doodad
// visually appears.
var scrollBias = render.Point{
X: w.Scroll.X,
Y: w.Scroll.Y,
}
if w.Zoom != 0 {
scrollBias.X = w.ZoomDivide(scrollBias.X)
scrollBias.Y = w.ZoomDivide(scrollBias.Y)
}
box := render.Rect{
X: actor.Actor.Point.X - P.X - w.Scroll.X,
Y: actor.Actor.Point.Y - P.Y - w.Scroll.Y,
X: actor.Actor.Point.X - P.X - scrollBias.X,
Y: actor.Actor.Point.Y - P.Y - scrollBias.Y,
W: actor.Canvas.Size().W,
H: actor.Canvas.Size().H,
}

View File

@ -69,15 +69,10 @@ func (w *Canvas) Present(e render.Engine, p render.Point) {
// (0, 0) = (0,0, 127,127) chunk A
// (1, 0) = (128,128, 255,255) chunk B
// At 2x zoom, Chunk A is still half on screen at -128 scroll
if w.Zoom > 0 {
// Since disappearing chunks happens on Zoom In the most?
// Grow the viewport's X and Y offsets back the other
// way, so chunks sliding off the screen don't unload early.
// This kinda thing makes no difference at all?
// var orig = Viewport
// Viewport.X = w.ZoomDivide(w.chunks.Size)
// Viewport.Y = w.ZoomDivide(w.chunks.Size)
}
// if w.Zoom > 0 {
// Viewport.X = w.ZoomDivide(w.chunks.Size)
// Viewport.Y = w.ZoomDivide(w.chunks.Size)
// }
// Get the chunks in the viewport and cache their textures.
for coord := range w.chunks.IterViewportChunks(Viewport) {