Add scissor test when creating lightmap

This commit is contained in:
2025-11-14 02:06:51 +00:00
parent c79e5df683
commit 292a1c3f42
5 changed files with 66 additions and 35 deletions
+13 -1
View File
@@ -2,8 +2,12 @@ module Dodge.Base.Coordinate (
worldPosToScreen,
screenToWorldPos,
mouseWorldPos,
worldPosToResOffset,
) where
import Dodge.WindowSize
import Linear
import Dodge.Data.Config
import Control.Lens
import Dodge.Data.Camera
import Dodge.Data.Input
@@ -18,9 +22,17 @@ import Geometry
worldPosToScreen :: Camera -> Point2 -> Point2
worldPosToScreen cam =
rotateV (negate $ cam ^. camRot)
. ((cam ^. camZoom) *.*)
. ((cam ^. camZoom) *^)
. (-.- (cam ^. camCenter))
-- gets the position from the bottom left in "world res" "pixels"
worldPosToResOffset :: Config -> Camera -> Point2 -> Point2
worldPosToResOffset cfig cam p = (worldPosToScreen cam p & each %~ f)
+ 0.5 *^ (uncurry V2 (getWindowSize _gr_world_res cfig::(Int,Int)) & each %~ fromIntegral)
where
f x = applyResFactorF (cfig ^. gr_world_res) x
-- | The mouse position in world coordinates.
mouseWorldPos :: Input -> Camera -> Point2
mouseWorldPos inp cam = screenToWorldPos cam (inp ^. mousePos)