diff --git a/data/texture/charMap.png b/data/texture/charMap.png index 660d71aee..115dafb7c 100644 Binary files a/data/texture/charMap.png and b/data/texture/charMap.png differ diff --git a/shader/lighting/cap.geom b/shader/lighting/cap.geom index 8ad0b4ff7..63d4c521c 100644 --- a/shader/lighting/cap.geom +++ b/shader/lighting/cap.geom @@ -18,24 +18,19 @@ void main() vec4 p0 = gl_in[0].gl_Position ; vec4 p1 = gl_in[1].gl_Position ; vec4 p2 = gl_in[2].gl_Position ; - if ( //dot( p0.xyz - vec3 (0,0,1), cross( p0.xyz - p1.xyz, p1.xyz - p2.xyz)) < 0 - // && + if ( //if Light Source is below all vertices, draw cap + // TODO think about when LS is beside the object ( p0.z - lightPos.z > 0 ) && ( p1.z - lightPos.z > 0 ) && ( p2.z - lightPos.z > 0 ) ) { - // front cap + // the front cap vec4 v1 = vec4 (0,0,1,0) ; gl_Position = theMat * projNear(p0); EmitVertex(); gl_Position = theMat * projNear(p1); EmitVertex(); gl_Position = theMat * projNear(p2); EmitVertex(); EndPrimitive(); - // if light points downwards onto surface, draw back cap too - if (dot ( p0.xyz - lightPos, vec3 ( 0,0,1) ) > 0) - { - } - else {} } else {} } diff --git a/shader/lighting/lineShadow.geom b/shader/lighting/lineShadow.geom index fd49b139b..5ad1eeab2 100644 --- a/shader/lighting/lineShadow.geom +++ b/shader/lighting/lineShadow.geom @@ -3,7 +3,8 @@ layout (lines_adjacency) in; layout (triangle_strip, max_vertices = 4) out; layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; uniform vec3 lightPos; -vec4 shift (vec4 p) { return (vec4 (p.xyz + (100000*(p.xyz-lightPos)), 1));} +//vec4 shift (vec4 p) { return (vec4 (p.xyz + (100000*(p.xyz-lightPos)), 1));} +vec4 shift (vec4 p) { return (vec4 (p.xyz + (1000*(p.xyz-lightPos)), 1));} // copied from lighting/cap.geom, should not be changed on its own vec4 projNear (vec4 pos) { @@ -34,7 +35,7 @@ void main() //vec3 n2 = n0 + n1; // assumes the summands are normalized vec3 lightDir = p0.xyz - lightPos.xyz; // first test if the edge is part of the silhouette - // that is, if the normals of the faces connected by the edge point in + // that is, if the normals of the faces connected by the edge point are in // "different directions" wrt the light direction if ( dot(n0 , lightDir) * dot(n1 , lightDir) <= 0 ) // using <= rather than < seems to get rid of overlapping shadow diff --git a/src/Dodge/Base/Collide.hs b/src/Dodge/Base/Collide.hs index 66b887ac8..49a5a0ea1 100644 --- a/src/Dodge/Base/Collide.hs +++ b/src/Dodge/Base/Collide.hs @@ -130,7 +130,7 @@ visibleWalls sp ep = allVisibleWalls :: World -> [(Point2, Wall)] {-# INLINE allVisibleWalls #-} -allVisibleWalls w = concatMap (flip (visibleWalls vPos) w . (+.+ vPos)) $ nRays 20 +allVisibleWalls w = concatMap (flip (visibleWalls vPos) w . (+.+ vPos)) $ nRays 15 where vPos = w ^. cWorld . camPos . camViewFrom diff --git a/src/Dodge/Block.hs b/src/Dodge/Block.hs index 048cfd98c..d49c7ce48 100644 --- a/src/Dodge/Block.hs +++ b/src/Dodge/Block.hs @@ -73,7 +73,8 @@ maybeClearPath :: World -> PathEdgeNodes -> World maybeClearPath w (PathEdgeNodes x y pe) | not . null $ overlapSegWalls (_peStart pe) (_peEnd pe) $ wlsNearSeg (_peStart pe) (_peEnd pe) w = w - | otherwise = w & cWorld . lWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles .~ mempty) . FGL.delEdge (x, y) + | otherwise = w + & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles .~ mempty) . FGL.delEdge (x, y) destroyDoor :: Door -> World -> World destroyDoor dr w = diff --git a/src/Dodge/Creature/ChaseCrit.hs b/src/Dodge/Creature/ChaseCrit.hs index 6afc107a9..f8ea54893 100644 --- a/src/Dodge/Creature/ChaseCrit.hs +++ b/src/Dodge/Creature/ChaseCrit.hs @@ -54,4 +54,4 @@ chaseCrit = 0 , _crMvType = defaultChaseMvType } - & crType . humanoidAI .~ ChaseAI +-- & crType . humanoidAI .~ ChaseAI diff --git a/src/Dodge/Data/CWorld.hs b/src/Dodge/Data/CWorld.hs index a14ce5880..529d9429d 100644 --- a/src/Dodge/Data/CWorld.hs +++ b/src/Dodge/Data/CWorld.hs @@ -19,6 +19,7 @@ import Dodge.GameRoom import Geometry.ConvexPoly import Dodge.Data.CamPos import qualified Data.IntSet as IS +import Data.Graph.Inductive data CWorld = CWorld { _lWorld :: LWorld @@ -29,6 +30,7 @@ data CWorld = CWorld , _timeFlow :: TimeFlowStatus , _seenWalls :: IS.IntSet , _floorTiles :: [(Point3, Point3)] + , _pathGraph :: Gr Point2 PathEdge } data TimeFlowStatus diff --git a/src/Dodge/Data/LWorld.hs b/src/Dodge/Data/LWorld.hs index 71324355e..bd11227bc 100644 --- a/src/Dodge/Data/LWorld.hs +++ b/src/Dodge/Data/LWorld.hs @@ -50,7 +50,6 @@ module Dodge.Data.LWorld ( import Control.Lens import Data.Aeson import Data.Aeson.TH -import Data.Graph.Inductive import Dodge.Data.Beam import Dodge.Data.Block import Dodge.Data.Bounds @@ -138,7 +137,6 @@ data LWorld = LWorld , _decorations :: IM.IntMap Picture , _foregroundShapes :: IM.IntMap ForegroundShape , _corpses :: IM.IntMap Corpse - , _pathGraph :: Gr Point2 PathEdge , _lightSources :: IM.IntMap LightSource , _tempLightSources :: [TempLightSource] , _seenLocations :: IM.IntMap (WdP2, String) diff --git a/src/Dodge/Default/World.hs b/src/Dodge/Default/World.hs index 49e8876bf..7ee9fe939 100644 --- a/src/Dodge/Default/World.hs +++ b/src/Dodge/Default/World.hs @@ -84,6 +84,8 @@ defaultCWorld = , _timeFlow = NormalTimeFlow , _seenWalls = mempty , _floorTiles = mempty + --, _pathGraph = mempty + , _pathGraph = Data.Graph.Inductive.Graph.empty } defaultLWorld :: LWorld @@ -130,7 +132,6 @@ defaultLWorld = , _buttons = IM.empty , _corpses = IM.empty , _decorations = IM.empty - , _pathGraph = Data.Graph.Inductive.Graph.empty , _lightSources = IM.empty , _tempLightSources = [] , _seenLocations = diff --git a/src/Dodge/Layout.hs b/src/Dodge/Layout.hs index f27791d34..650e4ea07 100644 --- a/src/Dodge/Layout.hs +++ b/src/Dodge/Layout.hs @@ -3,6 +3,7 @@ module Dodge.Layout ( generateLevelFromRoomList, ) where +import Dodge.Path.Translate import qualified Control.Foldl as L import Control.Lens import Data.Foldable @@ -44,7 +45,7 @@ generateLevelFromRoomList gr' w = . worldToGenWorld rs' $ w & cWorld . lWorld . walls .~ wallsFromRooms rs & cWorld . cwGen . cwgGameRooms .~ gameRoomsFromRooms (IM.elems rs') - & cWorld . lWorld . pathGraph .~ path + & cWorld . pathGraph .~ path & pnZoning .~ foldl' (flip zonePn) mempty (labNodes path) & peZoning .~ foldl' (flip zonePe) mempty (map fromEdgeTuple $ labEdges path) where @@ -54,8 +55,6 @@ generateLevelFromRoomList gr' w = rs = map doRoomShift $ IM.elems rs' rs' = mapM shuffleRoomPos gr' & evalState $ _randGen w -fromEdgeTuple :: (Int, Int, PathEdge) -> PathEdgeNodes -fromEdgeTuple (a, b, pe) = PathEdgeNodes a b pe randomCompass :: World -> World randomCompass w = w & cWorld . camPos . camRot .~ (takeOne [0, 0.5 * pi, pi, 1.5 * pi] & evalState $ _randGen w) diff --git a/src/Dodge/Path.hs b/src/Dodge/Path.hs index 4e59b55cd..5bd8e49ed 100644 --- a/src/Dodge/Path.hs +++ b/src/Dodge/Path.hs @@ -30,14 +30,14 @@ import Data.Bifunctor getNodePos :: Int -> World -> Maybe Point2 --getNodePos i w = _pathGraph (_cWorld w) `lab` i -getNodePos i w = (w ^. cWorld . lWorld . pathGraph) `lab` i +getNodePos i w = (w ^. cWorld . pathGraph) `lab` i makePathBetween :: Point2 -> Point2 -> World -> Maybe [Int] makePathBetween a b w = do -- join $ sp <$> a' <*> b' <*> return (_pathGraph w) na <- walkableNodeNear w a nb <- walkableNodeNear w b - sp na nb (second _peDist (efilter (not . pathEdgeObstructed . (^. _3)) $ w ^. cWorld . lWorld . pathGraph)) + sp na nb (second _peDist (efilter (not . pathEdgeObstructed . (^. _3)) $ w ^. cWorld . pathGraph)) --_pathGraph (_cWorld w))) pathEdgeObstructed :: PathEdge -> Bool @@ -53,13 +53,13 @@ walkableNodeNear w p = fmap fst . find (flip (isWalkable p) w . snd) $ nodesNear makePathBetweenPs :: Point2 -> Point2 -> World -> Maybe [Point2] --makePathBetweenPs a b w = mapMaybe (lab $ _pathGraph (_cWorld w)) <$> makePathBetween a b w -makePathBetweenPs a b w = mapMaybe (lab $ w ^. cWorld . lWorld . pathGraph) <$> makePathBetween a b w +makePathBetweenPs a b w = mapMaybe (lab $ w ^. cWorld . pathGraph) <$> makePathBetween a b w bfsNodePoints :: Int -> World -> [Point2] bfsNodePoints n w = mapMaybe (lab g) $ bfs n g where --g = _pathGraph (_cWorld w) - g = w ^. cWorld . lWorld . pathGraph + g = w ^. cWorld . pathGraph pointTowardsImpulse :: Point2 -> Point2 -> World -> Maybe Point2 pointTowardsImpulse a b w = (find (flip (isWalkable a) w) . reverse) =<< makePathBetweenPs a b w @@ -138,7 +138,7 @@ addEdges nodemap gr = foldl' f (mempty, gr) obstructPathsCrossing :: EdgeObstacle -> Point2 -> Point2 -> World -> (World, Set PathEdgeNodes) obstructPathsCrossing obstacletype sp' ep w = - ( w & cWorld . lWorld . pathGraph %~ updateedges + ( w & cWorld . pathGraph %~ updateedges , es ) where diff --git a/src/Dodge/Placement/PlaceSpot/TriggerDoor.hs b/src/Dodge/Placement/PlaceSpot/TriggerDoor.hs index ba39a8483..4c498e58b 100644 --- a/src/Dodge/Placement/PlaceSpot/TriggerDoor.hs +++ b/src/Dodge/Placement/PlaceSpot/TriggerDoor.hs @@ -71,9 +71,9 @@ maybeClearDoorPaths eo es w = foldl' (maybeClearDoorPath eo) w es maybeClearDoorPath :: EdgeObstacle -> World -> PathEdgeNodes -> World maybeClearDoorPath eo w (PathEdgeNodes x y pe) | not . null $ overlapSegWalls (_peStart pe) (_peEnd pe) $ wlsNearSeg (_peStart pe) (_peEnd pe) w = - w & cWorld . lWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo ?~ ()) . FGL.delEdge (x, y) + w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo ?~ ()) . FGL.delEdge (x, y) | otherwise = - w & cWorld . lWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo .~ Nothing) . FGL.delEdge (x, y) + w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo .~ Nothing) . FGL.delEdge (x, y) plSlideDoor :: Door -> diff --git a/src/Dodge/Render/ShapePicture.hs b/src/Dodge/Render/ShapePicture.hs index bfed70fbe..e5c8d0824 100644 --- a/src/Dodge/Render/ShapePicture.hs +++ b/src/Dodge/Render/ShapePicture.hs @@ -463,7 +463,7 @@ drawPathing cfig w = <> foldMap dispInc (graphToIncidence gr) where dispInc (p, n) = setDepth 2 . uncurryV translate p . scale 0.1 0.1 $ text $ show n - gr = w ^. cWorld . lWorld . pathGraph + gr = w ^. cWorld . pathGraph crDisplayInfo :: Configuration -> CamPos -> Creature -> Maybe (Point2, [String]) crDisplayInfo cfig cam cr diff --git a/src/Dodge/Save.hs b/src/Dodge/Save.hs index a6384a5d6..32ae00ad2 100644 --- a/src/Dodge/Save.hs +++ b/src/Dodge/Save.hs @@ -8,6 +8,8 @@ module Dodge.Save ( reloadLevelStart, ) where + +import Dodge.Path.Translate import Data.Graph.Inductive (labEdges, labNodes) import Dodge.Zoning.Pathing import Data.Foldable @@ -53,11 +55,9 @@ readSaveSlot ss = do & uvScreenLayers .~ [] else putStrLn "loadSaveSlot failed to find saved file" >> return removescreenlayers where - path uv = uv ^. uvWorld . cWorld . lWorld . pathGraph + path uv = uv ^. uvWorld . cWorld . pathGraph removescreenlayers = Just . (uvScreenLayers .~ []) -fromEdgeTuple :: (Int, Int, PathEdge) -> PathEdgeNodes -fromEdgeTuple (a, b, pe) = PathEdgeNodes a b pe saveSlotPath :: SaveSlot -> String saveSlotPath (SaveSlotNum i) = "saveSlot/" ++ show i diff --git a/src/Shader/Poke.hs b/src/Shader/Poke.hs index ff5979d8c..e10886f2d 100644 --- a/src/Shader/Poke.hs +++ b/src/Shader/Poke.hs @@ -165,7 +165,7 @@ pokeJustV :: Ptr Float -> Int -> ShapeV -> IO Int ---{-# INLINE pokeJustV #-} +{-# INLINE pokeJustV #-} pokeJustV ptr nv sh = do -- pokeArray (advancePtr ptr (off 0)) [a,b,c,d,e,f,g] pokeElemOff ptr (off 0) a