Move towards unifying some orientation code

This commit is contained in:
2025-07-05 18:35:18 +01:00
parent 07c6298743
commit 164499fe4e
8 changed files with 57 additions and 53 deletions
+14 -11
View File
@@ -7,8 +7,9 @@ module Dodge.Item.HeldOffset (
heldItemRelativeOrient,
heldItemOrient2D,
heldItemOrient2D',
itemRelativeOrient,
-- itemRelativeOrient,
locOrientation,
handHandleOrient,
) where
import Dodge.Creature.Radius
@@ -71,7 +72,7 @@ heldItemRelativeOrient itm cr (p, q)
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
handleOrient :: LocationLDT ItemLink OItem -> Point3Q
handleOrient :: LocationLDT ItemLink CItem -> Point3Q
handleOrient _ = (V3 (-3) 0 0, Q.qID)
-- note this is relative to the creature
@@ -95,11 +96,12 @@ handOrient cr = case cr ^. crStance . posture of
sLen = _strideLength $ _crStance cr
locOrientation :: LocationLDT ItemLink OItem -> Creature -> Point3Q
locOrientation loc cr =
heldItemRelativeOrient
(locToTop loc ^. locLDT . ldtValue . _1)
cr
locOrientation loc cr = handHandleOrient (fmap (\(x,y,_) -> (x,y)) loc) cr `Q.comp`
(loc ^. locLDT . ldtValue . _3)
-- heldItemRelativeOrient
-- (locToTop loc ^. locLDT . ldtValue . _1)
-- cr
-- (loc ^. locLDT . ldtValue . _3)
aimingWeaponZeroPos :: Creature -> Item -> Point2
aimingWeaponZeroPos cr it = aimStanceHandlePos cr it - handlePos it
@@ -112,14 +114,15 @@ aimStanceHandlePos _ it = case itemBaseStance it of
OneHand -> V2 10 (-2)
TwoHandFlat -> V2 10 0
heldItemOffset :: LocationLDT ItemLink OItem -> Creature -> Point3 -> Point3
heldItemOffset :: LocationLDT ItemLink CItem -> Creature -> Point3 -> Point3
heldItemOffset loc cr p = x + Q.rotate q p
where
(x,q) = handOrient cr (aimStance (loc ^. locLDT))
`Q.comp` handleOrient loc
(x, q) = handHandleOrient loc cr
heldItemOffset' :: Item -> Creature -> Point3 -> Point3
heldItemOffset' itm cr p = fst (heldItemRelativeOrient itm cr (p, Q.qID))
handHandleOrient :: LocationLDT ItemLink CItem -> Creature -> Point3Q
handHandleOrient loc cr =
handOrient cr (aimStance (loc ^. locLDT))
`Q.comp` handleOrient loc
shoulderHeight :: Float
shoulderHeight = 18