Clarify number of distortions, play with distorting bullets

This commit is contained in:
2025-11-19 21:49:20 +00:00
parent 610936a5fa
commit 10dbb238c8
7 changed files with 93 additions and 72 deletions
+11 -1
View File
@@ -154,7 +154,17 @@ makeFlak bu _ w = w & cWorld . lWorld . bullets .++~ [f x | x <- xs]
g x v = v +.+ x *.* normalizeV (vNormal v)
hitEffFromBul :: World -> Bullet -> (World, Bullet)
hitEffFromBul w bu = case _buEffect bu of
hitEffFromBul w bu = hitEffFromBul' w' bu
where
w' = w & cWorld . lWorld . distortions .:~ x
x = RadialDistortion (_buPos bu + _buVel bu) (V2 50 0) (V2 0 50)
(v3 & _3 .~ t) (v3 & _3 .~ negate t) v3 1
v3 = V3 (V2 1 0) (V2 0 1) 0
t = vNormal (_buVel bu)
-- (V2 1 0) (V2
hitEffFromBul' :: World -> Bullet -> (World, Bullet)
hitEffFromBul' w bu = case _buEffect bu of
PenetrateBullet -> movePenBullet bu hitstream w
BounceBullet -> fromMaybe (expireAndDamage bu hitstream w) $ do
(hp, crwl) <- hitstream ^? _head
+12 -9
View File
@@ -12,15 +12,18 @@ data Distortion = RadialDistortion
{ _rdPos :: Point2
, _rdDist1 :: Point2
, _rdDist2 :: Point2
, _rdT1R :: Point2
, _rdT2R :: Point2
, _rdT3R :: Point2
, _rdT1G :: Point2
, _rdT2G :: Point2
, _rdT3G :: Point2
, _rdT1B :: Point2
, _rdT2B :: Point2
, _rdT3B :: Point2
, _rdTR :: V3 Point2
, _rdTB :: V3 Point2
, _rdTG :: V3 Point2
-- , _rdT1R :: Point2
-- , _rdT2R :: Point2
-- , _rdT3R :: Point2
-- , _rdT1G :: Point2
-- , _rdT2G :: Point2
-- , _rdT3G :: Point2
-- , _rdT1B :: Point2
-- , _rdT2B :: Point2
-- , _rdT3B :: Point2
, _rdTime :: Int
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
+1 -1
View File
@@ -7,5 +7,5 @@ import Control.Lens
updateDistortion :: Distortion -> Maybe Distortion
updateDistortion rd
| rd ^. rdTime > 0 = Just $ rd & rdTime .~ 1
| rd ^. rdTime > 0 = Just $ rd & rdTime -~ 1
| otherwise = Nothing
+3 -2
View File
@@ -14,14 +14,15 @@ testEvent w = fromMaybe w $ do
t1 = (V2 1 (-1))
t2 = (V2 1 1)
t3 = (V2 distR 0)
v3 = V3 t1 t2 t3
distortionBulge =
RadialDistortion
cpos
(V2 distR 0)
(V2 0 distR)
t1 t2 t3 t1 t2 t3 t1 t2 t3
v3 v3 v3
20
return $ w & cWorld . lWorld . distortions .~ [distortionBulge
, distortionBulge & rdPos +~ 50 & rdT1R +~ V2 (-1) 1
, distortionBulge & rdPos +~ 50 & rdTR . _1 +~ V2 (-1) 1
, distortionBulge & rdPos +~ (-50)
]
+4 -3
View File
@@ -359,7 +359,6 @@ doDrawing' win pdata u = do
glDepthFunc GL_ALWAYS
glBlendFunc GL_ONE GL_ZERO
-- perform distortions
-- this is hideous
case getDistortions cfig w of
[] -> do
glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO
@@ -371,7 +370,7 @@ doDrawing' win pdata u = do
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fbo2 . _1 . unFBO)
withArray (concatMap rdToVec2s rs) $
glNamedBufferSubData (pdata ^. barrelShader . _2 . vboName) 0
(18 * fromIntegral (length rs * sizeOf (0 :: Float)))
(24 * fromIntegral (length rs * sizeOf (0 :: Float)))
glBindTextureUnit 1 $ pdata ^. fboBase . _2 . _1 . unTO
glUseProgram (pdata ^. barrelShader . _1)
glUniform1i 0 (fromIntegral (length rs))
@@ -399,7 +398,9 @@ doDrawing' win pdata u = do
SDL.glSwapWindow win
rdToVec2s :: Distortion -> [Point2]
rdToVec2s (RadialDistortion a b c d e f g h i j k l _) = [a,b,c,d,e,f,g,h,i,j,k,l]
rdToVec2s (RadialDistortion a b c d e f _) = [a,b,c] <> t d <> t e <> t f
where
t (V3 x y z) = [x,y,z]
bufferPerspectiveMatrixUBO :: Config -> Camera -> GLuint -> IO ()
bufferPerspectiveMatrixUBO cfig cam uboid =