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
+1 -1
View File
@@ -135,4 +135,4 @@ shoulderSH = translateSHz 20
drawEquipment :: Creature -> SPic
{-# INLINE drawEquipment #-}
drawEquipment cr = foldMap (itemEquipPict cr) (invLDT' $ _crInv cr)
drawEquipment cr = foldMap (itemEquipPict cr) (invLDT $ _crInv cr)
+2 -1
View File
@@ -286,7 +286,8 @@ updateAttachedItems itmtree cr =
chainLinkOrientation
chainLinkOrientation
(updateItemWithOrientation cr)
(heldItemRelativeOrient (itmtree ^. ldtValue . _1) cr (0, Q.qID))
--(heldItemRelativeOrient (itmtree ^. ldtValue . _1) cr (0, Q.qID))
(handHandleOrient (LocLDT TopLDT itmtree) cr)
(LocLDT TopLDT itmtree)
-- need to check rotation
+1 -1
View File
@@ -96,7 +96,7 @@ crInAimStance as cr = crIsAiming cr && mitstance == Just as
mitstance = do
i <- cr ^? crManipulation . manObject . imRootSelectedItem
--itm <- invRootTrees' (cr ^. crInv) ^? ix i
itm <- invRootTrees (cr ^. crInv) ^? ix i
itm <- fmap (fmap (\(a,b,_) -> (a,b))) $ invRootTrees (cr ^. crInv) ^? ix i
return $ aimStance itm
--cr ^? crInv . ix i . itUse . heldAim . aimStance
+1 -1
View File
@@ -10,7 +10,7 @@ import Dodge.Data.AimStance
--aStance :: LocationLDT ItemLink CItem -> AimStance
--aStance loc = case loc ^. locLDT . ldtValue . _1 . itType of
--
aimStance :: LDTree ItemLink OItem -> AimStance
aimStance :: LDTree ItemLink CItem -> AimStance
aimStance ldt = itemBaseStance $ ldt ^. ldtValue . _1
+1 -1
View File
@@ -15,7 +15,7 @@ import Dodge.Item.Draw.SPic
import Dodge.Item.HeldOffset
import ShapePicture
itemEquipPict :: Creature -> LDTree ItemLink OItem -> SPic
itemEquipPict :: Creature -> LDTree ItemLink CItem -> SPic
itemEquipPict cr itmtree
| Just i <- itm ^? itLocation . ilInvID
, Just esite <- cr ^? crInv . ix i . itLocation . ilEquipSite . _Just
+3 -3
View File
@@ -21,10 +21,10 @@ import Picture
import Shape
import ShapePicture
itemTreeSPic :: LDTree ItemLink OItem -> SPic
itemTreeSPic (LDT (itm,_,_) l r) = itemSPic itm <> foldMap (itemRotTreeSPic itm) (l <> r)
itemTreeSPic :: LDTree ItemLink CItem -> SPic
itemTreeSPic (LDT (itm,_) l r) = itemSPic itm <> foldMap (itemRotTreeSPic itm) (l <> r)
itemRotTreeSPic :: Item -> (ItemLink, LDTree ItemLink OItem) -> SPic
itemRotTreeSPic :: Item -> (ItemLink, LDTree ItemLink CItem) -> SPic
itemRotTreeSPic par (il, t) = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t
where
(p, q) = orientAttachment par il itm
+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