move matrix transposition into poke definition
This commit is contained in:
parent
455124021f
commit
82962d3350
3 changed files with 11 additions and 10 deletions
|
@ -224,7 +224,7 @@ recordCommandBuffer
|
||||||
|
|
||||||
let constants = MeshPushConstants
|
let constants = MeshPushConstants
|
||||||
{ meshPushData = V4 0 0 0 0
|
{ meshPushData = V4 0 0 0 0
|
||||||
, meshRenderMatrix = transpose modelMatrix
|
, meshRenderMatrix = modelMatrix
|
||||||
}
|
}
|
||||||
mesh = meshMap M.! meshID
|
mesh = meshMap M.! meshID
|
||||||
material = materialMap M.! materialID
|
material = materialMap M.! materialID
|
||||||
|
@ -323,7 +323,7 @@ pokeData frame frameNumber sceneParameters cameraParameters = do
|
||||||
V.mapM_
|
V.mapM_
|
||||||
(\(index, obj) -> do
|
(\(index, obj) -> do
|
||||||
|
|
||||||
let modelMatrix = GPUObjectData (transpose $ objectMatrix obj)
|
let modelMatrix = GPUObjectData (objectMatrix obj)
|
||||||
|
|
||||||
liftIO $ poke
|
liftIO $ poke
|
||||||
(castPtr objectPointer `plusPtr` (index * sizeOf (undefined :: GPUObjectData)))
|
(castPtr objectPointer `plusPtr` (index * sizeOf (undefined :: GPUObjectData)))
|
||||||
|
|
|
@ -68,9 +68,9 @@ drawFrame engineData frameNumber = do
|
||||||
0.1
|
0.1
|
||||||
200
|
200
|
||||||
cameraData = GPUCameraData
|
cameraData = GPUCameraData
|
||||||
{ view = transpose camView
|
{ view = camView
|
||||||
, projection = transpose camProjection
|
, projection = camProjection
|
||||||
, viewProjection = transpose $ camProjection !*! camView
|
, viewProjection = camProjection !*! camView
|
||||||
}
|
}
|
||||||
|
|
||||||
pokeData
|
pokeData
|
||||||
|
|
11
src/Types.hs
11
src/Types.hs
|
@ -220,7 +220,7 @@ instance Storable GPUObjectData where
|
||||||
GPUObjectData <$> peek (castPtr ptr)
|
GPUObjectData <$> peek (castPtr ptr)
|
||||||
|
|
||||||
poke ptr (GPUObjectData modelMatrix) =
|
poke ptr (GPUObjectData modelMatrix) =
|
||||||
poke (castPtr ptr) modelMatrix
|
poke (castPtr ptr) $ transpose modelMatrix
|
||||||
|
|
||||||
data GPUCameraData = GPUCameraData
|
data GPUCameraData = GPUCameraData
|
||||||
{ view :: M44 Float
|
{ view :: M44 Float
|
||||||
|
@ -231,7 +231,7 @@ data GPUCameraData = GPUCameraData
|
||||||
instance Storable GPUCameraData where
|
instance Storable GPUCameraData where
|
||||||
|
|
||||||
sizeOf _ =
|
sizeOf _ =
|
||||||
3* sizeOf (undefined :: M44 Float)
|
3 * sizeOf (undefined :: M44 Float)
|
||||||
|
|
||||||
alignment _ = 0
|
alignment _ = 0
|
||||||
|
|
||||||
|
@ -242,9 +242,10 @@ instance Storable GPUCameraData where
|
||||||
return $ GPUCameraData v p vp
|
return $ GPUCameraData v p vp
|
||||||
|
|
||||||
poke ptr (GPUCameraData pview pprojection pviewProjection) = do
|
poke ptr (GPUCameraData pview pprojection pviewProjection) = do
|
||||||
poke (castPtr ptr) pview
|
poke (castPtr ptr) $ transpose pview
|
||||||
poke (castPtr ptr `plusPtr` sizeOf pview) pprojection
|
poke (castPtr ptr `plusPtr` sizeOf pview) $ transpose pprojection
|
||||||
poke (castPtr ptr `plusPtr` sizeOf pview `plusPtr` sizeOf pprojection) pviewProjection
|
poke (castPtr ptr `plusPtr` sizeOf pview `plusPtr` sizeOf pprojection) $
|
||||||
|
transpose pviewProjection
|
||||||
|
|
||||||
data GPUSceneData = GPUSceneData
|
data GPUSceneData = GPUSceneData
|
||||||
{ fogColor :: V4 Float
|
{ fogColor :: V4 Float
|
||||||
|
|
Loading…
Reference in a new issue