Add in "linear" lWorld to separate time reversable worlds
This commit is contained in:
@@ -9,9 +9,9 @@ import Control.Lens
|
||||
worldPosToScreenNorm :: Configuration -> World -> Point2 -> Point2
|
||||
worldPosToScreenNorm cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
|
||||
where
|
||||
doTranslate p = p -.- (w ^. cWorld . cwCam . cwcCenter)
|
||||
doZoom p = (w ^. cWorld . cwCam . cwcZoom) *.* p
|
||||
doRotate p = rotateV (negate (w ^. cWorld . cwCam . cwcRot)) p
|
||||
doTranslate p = p -.- (w ^. cWorld . lWorld . cwCam . cwcCenter)
|
||||
doZoom p = (w ^. cWorld . lWorld . cwCam . cwcZoom) *.* p
|
||||
doRotate p = rotateV (negate (w ^. cWorld . lWorld . cwCam . cwcRot)) p
|
||||
|
||||
{- | Transform world coordinates to scaled screen coordinates.
|
||||
- These have to be scaled according to the size of the window to get actual screen positions.
|
||||
@@ -19,9 +19,9 @@ worldPosToScreenNorm cfig w = doWindowScale cfig . doRotate . doZoom . doTransla
|
||||
-}
|
||||
worldPosToScreen :: World -> Point2 -> Point2
|
||||
worldPosToScreen w =
|
||||
rotateV (negate $ w ^. cWorld . cwCam . cwcRot)
|
||||
. ((w ^. cWorld . cwCam . cwcZoom) *.*)
|
||||
. (-.- (w ^. cWorld . cwCam . cwcCenter))
|
||||
rotateV (negate $ w ^. cWorld . lWorld . cwCam . cwcRot)
|
||||
. ((w ^. cWorld . lWorld . cwCam . cwcZoom) *.*)
|
||||
. (-.- (w ^. cWorld . lWorld . cwCam . cwcCenter))
|
||||
|
||||
{- | Transform coordinates from the map position to screen
|
||||
coordinates.
|
||||
@@ -29,9 +29,11 @@ coordinates.
|
||||
cartePosToScreen :: Configuration -> World -> Point2 -> Point2
|
||||
cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
|
||||
where
|
||||
doTranslate p = p -.- _carteCenter (_hud (_cWorld w))
|
||||
doZoom p = _carteZoom (_hud (_cWorld w)) *.* p
|
||||
doRotate p = rotateV (negate $ _carteRot (_hud (_cWorld w))) p
|
||||
doTranslate p = p -.- (w ^. cWorld . lWorld . hud . carteCenter) -- _carteCenter (_hud (_cWorld w))
|
||||
--doZoom p = _carteZoom (_hud (_cWorld w)) *.* p
|
||||
doZoom p = (w ^. cWorld . lWorld . hud . carteZoom) *.* p
|
||||
--doRotate p = rotateV (negate $ _carteRot (_hud (_cWorld w))) p
|
||||
doRotate p = rotateV (negate $ w ^. cWorld . lWorld . hud . carteRot) p
|
||||
|
||||
crToMousePosOffset :: Creature -> World -> (Point2, Float)
|
||||
crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr, 0)
|
||||
@@ -39,11 +41,14 @@ crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr, 0)
|
||||
-- | The mouse position in world coordinates.
|
||||
mouseWorldPos :: World -> Point2
|
||||
mouseWorldPos w =
|
||||
(w ^. cWorld . cwCam . cwcCenter)
|
||||
+.+ (1 / (w ^. cWorld . cwCam . cwcZoom)) *.* rotateV (w ^. cWorld . cwCam . cwcRot) (_mousePos w)
|
||||
(w ^. cWorld . lWorld . cwCam . cwcCenter)
|
||||
+.+ (1 / (w ^. cWorld . lWorld . cwCam . cwcZoom)) *.* rotateV (w ^. cWorld . lWorld . cwCam . cwcRot) (_mousePos w)
|
||||
|
||||
-- | The mouse position in map coordinates
|
||||
mouseCartePos :: World -> Point2
|
||||
mouseCartePos w =
|
||||
_carteCenter (_hud (_cWorld w))
|
||||
+.+ (1 / _carteZoom (_hud (_cWorld w))) *.* rotateV (_carteRot (_hud (_cWorld w))) (_mousePos w)
|
||||
mouseCartePos w = (w ^. cWorld . lWorld . hud . carteCenter)
|
||||
+.+
|
||||
(1 / (w ^. cWorld . lWorld . hud . carteZoom))
|
||||
*.* rotateV (w ^. cWorld . lWorld . hud . carteRot) (_mousePos w)
|
||||
-- _carteCenter (_hud (_cWorld w))
|
||||
-- +.+ (1 / _carteZoom (_hud (_cWorld w))) *.* rotateV (_carteRot (_hud (_cWorld w))) (_mousePos w)
|
||||
|
||||
Reference in New Issue
Block a user