Adjust sprite hide bounds for aspect ratio
parent
b848515420
commit
0b3f9fdd9e
|
@ -207,8 +207,8 @@ impl GPUState {
|
|||
|
||||
// Game coordinates (relative to camera) of ne and sw corners of screen.
|
||||
// Used to skip off-screen sprites.
|
||||
let clip_ne = Point2::from((-1.0, 1.0)) * game.camera.zoom;
|
||||
let clip_sw = Point2::from((1.0, -1.0)) * game.camera.zoom;
|
||||
let clip_ne = Point2::from((-self.window_aspect, 1.0)) * game.camera.zoom;
|
||||
let clip_sw = Point2::from((self.window_aspect, -1.0)) * game.camera.zoom;
|
||||
|
||||
for s in game.sprites() {
|
||||
// Parallax is computed here, so we can check if this sprite is visible.
|
||||
|
@ -216,11 +216,7 @@ impl GPUState {
|
|||
let texture = self.texture_array.get_texture(&s.name[..]);
|
||||
|
||||
// Game dimensions of this sprite post-scale.
|
||||
//
|
||||
// We only need height / 2 to check if we're on the screen,
|
||||
// but we omit the division.
|
||||
// This gives us a small margin, and lets us re-use the value
|
||||
// without an extra multiply.
|
||||
// Don't divide by 2, we use this later.
|
||||
let height = s.height * s.scale;
|
||||
let width = height * texture.aspect;
|
||||
|
||||
|
@ -234,13 +230,6 @@ impl GPUState {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Compute the values we need to draw
|
||||
// scale: combines texture scale and zoom scale.
|
||||
// screen_pos: position of this sprite in screen coordinates
|
||||
//
|
||||
// We can't use screen_pos to exclude off-screen sprites because
|
||||
// it can't account for height and width.
|
||||
|
||||
instances.push(SpriteInstance {
|
||||
position: pos.into(),
|
||||
aspect: texture.aspect,
|
||||
|
|
Loading…
Reference in New Issue