Improve debris
This commit is contained in:
@@ -55,15 +55,21 @@ blColor :: Block -> Color
|
||||
blColor _ = orange
|
||||
|
||||
makeBlockDebris :: Block -> World -> World
|
||||
makeBlockDebris bl w = foldl' (flip $ makeDebris (BlockDebris $ blColor bl) mt) w ps
|
||||
makeBlockDebris bl w = foldl' (flip $ makeDebris (blockDebrisType mwl bl) mt) w ps
|
||||
where
|
||||
dsize = debrisSize mt
|
||||
ps = gridInPolygon dsize $ shrinkPolyOnEdges dsize $ reverse (_blFootprint bl)
|
||||
mt = fromMaybe Stone $ do
|
||||
mt = fromMaybe Stone $ mwl ^? _Just . wlMaterial
|
||||
mwl = do
|
||||
wlids <- w ^? cWorld . lWorld . blocks . ix (_blID bl) . blWallIDs
|
||||
(wlid, _) <- IS.minView wlids
|
||||
wl <- w ^? cWorld . lWorld . walls . ix wlid
|
||||
return $ _wlMaterial wl
|
||||
w ^? cWorld . lWorld . walls . ix wlid
|
||||
|
||||
blockDebrisType :: Maybe Wall -> Block -> DebrisType
|
||||
blockDebrisType wl bl = case wl ^? _Just . wlMaterial of
|
||||
Just Glass -> GlassDebris
|
||||
Just Metal -> MetalDebris red
|
||||
_ -> BlockDebris $ blColor bl
|
||||
|
||||
-- makeDebris :: Material -> Color -> Point2 -> World -> World
|
||||
makeDebris :: DebrisType -> Material -> Point2 -> World -> World
|
||||
|
||||
@@ -22,6 +22,7 @@ data DebrisType
|
||||
= Gib { _gibSize :: Float , _gibColor :: Color }
|
||||
| BlockDebris {_bdColor :: Color}
|
||||
| MetalDebris {_bdColor :: Color}
|
||||
| GlassDebris
|
||||
|
||||
data Debris = DebrisChunk
|
||||
{ _dbPos :: Point3
|
||||
|
||||
@@ -22,6 +22,7 @@ debrisSPic db = translateSP (_dbPos db & _z +~ 1) . overPosSP (Q.rotate (_dbRot
|
||||
--MetalDebris c -> noPic . colorSH c $ upperPrismPolySU 1 $ [0, V2 5 0, V2 4 2]
|
||||
MetalDebris c -> noPic . colorSH c $ upperPrismPolySU 1 $ [0, V2 8 0, V2 6 3]
|
||||
--MetalDebris c -> noPic . colorSH c $ upperPrismPolySU 1 $ [0, V2 10 0, V2 8 4]
|
||||
GlassDebris -> noPic . colorSH azure $ upperPrismPoly Small Undesired 1 $ [0, V2 8 0, V2 6 3]
|
||||
|
||||
propSPic :: Prop -> SPic
|
||||
propSPic pr =
|
||||
|
||||
Reference in New Issue
Block a user