move matrix transposition into poke definition

This commit is contained in:
nek0 2023-05-14 10:18:09 +02:00
parent 455124021f
commit 82962d3350
3 changed files with 11 additions and 10 deletions

View file

@ -224,7 +224,7 @@ recordCommandBuffer
let constants = MeshPushConstants
{ meshPushData = V4 0 0 0 0
, meshRenderMatrix = transpose modelMatrix
, meshRenderMatrix = modelMatrix
}
mesh = meshMap M.! meshID
material = materialMap M.! materialID
@ -323,7 +323,7 @@ pokeData frame frameNumber sceneParameters cameraParameters = do
V.mapM_
(\(index, obj) -> do
let modelMatrix = GPUObjectData (transpose $ objectMatrix obj)
let modelMatrix = GPUObjectData (objectMatrix obj)
liftIO $ poke
(castPtr objectPointer `plusPtr` (index * sizeOf (undefined :: GPUObjectData)))

View file

@ -68,9 +68,9 @@ drawFrame engineData frameNumber = do
0.1
200
cameraData = GPUCameraData
{ view = transpose camView
, projection = transpose camProjection
, viewProjection = transpose $ camProjection !*! camView
{ view = camView
, projection = camProjection
, viewProjection = camProjection !*! camView
}
pokeData

View file

@ -220,7 +220,7 @@ instance Storable GPUObjectData where
GPUObjectData <$> peek (castPtr ptr)
poke ptr (GPUObjectData modelMatrix) =
poke (castPtr ptr) modelMatrix
poke (castPtr ptr) $ transpose modelMatrix
data GPUCameraData = GPUCameraData
{ view :: M44 Float
@ -231,7 +231,7 @@ data GPUCameraData = GPUCameraData
instance Storable GPUCameraData where
sizeOf _ =
3* sizeOf (undefined :: M44 Float)
3 * sizeOf (undefined :: M44 Float)
alignment _ = 0
@ -242,9 +242,10 @@ instance Storable GPUCameraData where
return $ GPUCameraData v p vp
poke ptr (GPUCameraData pview pprojection pviewProjection) = do
poke (castPtr ptr) pview
poke (castPtr ptr `plusPtr` sizeOf pview) pprojection
poke (castPtr ptr `plusPtr` sizeOf pview `plusPtr` sizeOf pprojection) pviewProjection
poke (castPtr ptr) $ transpose pview
poke (castPtr ptr `plusPtr` sizeOf pview) $ transpose pprojection
poke (castPtr ptr `plusPtr` sizeOf pview `plusPtr` sizeOf pprojection) $
transpose pviewProjection
data GPUSceneData = GPUSceneData
{ fogColor :: V4 Float