Skip to content

Commit

Permalink
Fixes issue with stretching non-square sprite textures
Browse files Browse the repository at this point in the history
- previously the raycasted sprite would appear to stretched or compressed
  width if the sprite texture source was not square
  • Loading branch information
harbdog committed Feb 12, 2023
1 parent 2d824d9 commit 9d862c7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ func (c *Camera) castSprite(spriteOrdIndex int) {
spriteTex := sprite.Texture()
spriteTexRect := sprite.TextureRect()
spriteTexWidth, spriteTexHeight := spriteTex.Size()
spriteTexRatioWH := float64(spriteTexWidth) / float64(spriteTexHeight)
spriteIllumination := sprite.Illumination()

//transform sprite with the inverse camera matrix
Expand All @@ -625,7 +626,7 @@ func (c *Camera) castSprite(spriteOrdIndex int) {
spriteScale := sprite.Scale()
spriteAnchor := sprite.VerticalAnchor()

var uDiv float64 = 1 / spriteScale
var uDiv float64 = 1 / (spriteScale * spriteTexRatioWH)
var vDiv float64 = 1 / spriteScale
var vOffset float64 = getAnchorVerticalOffset(spriteAnchor, spriteScale, c.h)

Expand Down

0 comments on commit 9d862c7

Please sign in to comment.