module Resource.Mesh.Utils where import RIO import RIO.List.Partial (maximum) import Geomancy (Transform, Vec4, vec4) import Geomancy.Transform qualified as Transform import Resource.Mesh.Types (AxisAligned(..), Measurements(..), middleAa, sizeAa) aabbTranslate :: AxisAligned Measurements -> Transform aabbTranslate :: AxisAligned Measurements -> Transform aabbTranslate AxisAligned Measurements measurements = Float -> Float -> Float -> Transform Transform.translate Float aaX Float aaY Float aaZ where AxisAligned{Float $sel:aaZ:AxisAligned :: forall a. AxisAligned a -> a $sel:aaY:AxisAligned :: forall a. AxisAligned a -> a $sel:aaX:AxisAligned :: forall a. AxisAligned a -> a aaZ :: Float aaY :: Float aaX :: Float ..} = AxisAligned Measurements -> AxisAligned Float middleAa AxisAligned Measurements measurements aabbScale :: AxisAligned Measurements -> Transform aabbScale :: AxisAligned Measurements -> Transform aabbScale AxisAligned Measurements measurements = Float -> Float -> Float -> Transform Transform.scale3 Float aaX Float aaY Float aaZ where AxisAligned{Float aaZ :: Float aaY :: Float aaX :: Float $sel:aaZ:AxisAligned :: forall a. AxisAligned a -> a $sel:aaY:AxisAligned :: forall a. AxisAligned a -> a $sel:aaX:AxisAligned :: forall a. AxisAligned a -> a ..} = AxisAligned Measurements -> AxisAligned Float sizeAa AxisAligned Measurements measurements boundingSphere :: AxisAligned Measurements -> Vec4 boundingSphere :: AxisAligned Measurements -> Vec4 boundingSphere AxisAligned Measurements measurements = Float -> Float -> Float -> Float -> Vec4 vec4 Float aaX Float aaY Float aaZ Float radius where AxisAligned{Float aaZ :: Float aaY :: Float aaX :: Float $sel:aaZ:AxisAligned :: forall a. AxisAligned a -> a $sel:aaY:AxisAligned :: forall a. AxisAligned a -> a $sel:aaX:AxisAligned :: forall a. AxisAligned a -> a ..} = AxisAligned Measurements -> AxisAligned Float middleAa AxisAligned Measurements measurements radius :: Float radius = AxisAligned Float -> Float forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a maximum ((Measurements -> Float) -> AxisAligned Measurements -> AxisAligned Float forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap Measurements -> Float mMax AxisAligned Measurements measurements)