Skip to content

Commit

Permalink
camera flip for spring camera isnt full 180 degrees if camera is at 0…
Browse files Browse the repository at this point in the history
… rotation (#3359)

* camera flip for spring camera isnt full 180 degrees if camera is at 0
  • Loading branch information
loveridge authored Sep 12, 2024
1 parent 2d0fe27 commit d4dd480
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions luaui/Widgets/camera_flip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ local function cameraFlipHandler()

-- camera is spring cam
-- CardinalLock messes up rotation
local previousLock = Spring.GetConfigInt("CamSpringLockCardinalDirections")
local cardinalLock = Spring.GetConfigInt("CamSpringLockCardinalDirections")
local lockCorrection = 0
if cardinalLock == 1 then
-- This value must be larger than the cardinal lock width of 0.2
lockCorrection = 1/3
end

if previousLock == 1 then
Spring.SetConfigInt("CamSpringLockCardinalDirections", 0)
if camState.ry > 0 then
camState.ry = camState.ry - math.pi - lockCorrection
else
camState.ry = camState.ry + math.pi + lockCorrection
end

camState.ry = camState.ry + math.pi
Spring.SetCameraState(camState, 0)

if previousLock == 1 then
Spring.SetConfigInt("CamSpringLockCardinalDirections", previousLock)
end

return true
end

Expand Down

0 comments on commit d4dd480

Please sign in to comment.