Hand/handle position refactor
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -95,7 +95,8 @@ crInAimStance as cr = crIsAiming cr && mitstance == Just as
|
||||
where
|
||||
mitstance = do
|
||||
i <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
itm <- invRootTrees' (cr ^. crInv) ^? ix i
|
||||
--itm <- invRootTrees' (cr ^. crInv) ^? ix i
|
||||
itm <- invRootTrees (cr ^. crInv) ^? ix i
|
||||
return $ aimStance itm
|
||||
--cr ^? crInv . ix i . itUse . heldAim . aimStance
|
||||
|
||||
|
||||
@@ -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 CItem -> AimStance
|
||||
aimStance :: LDTree ItemLink OItem -> AimStance
|
||||
aimStance ldt = itemBaseStance $ ldt ^. ldtValue . _1
|
||||
|
||||
|
||||
|
||||
@@ -15,17 +15,18 @@ import Dodge.Item.Draw.SPic
|
||||
import Dodge.Item.HeldOffset
|
||||
import ShapePicture
|
||||
|
||||
itemEquipPict :: Creature -> LDTree ItemLink CItem -> SPic
|
||||
itemEquipPict :: Creature -> LDTree ItemLink OItem -> SPic
|
||||
itemEquipPict cr itmtree
|
||||
| Just i <- itm ^? itLocation . ilInvID
|
||||
, Just esite <- cr ^? crInv . ix i . itLocation . ilEquipSite . _Just
|
||||
, Just attachpos <- equipAttachPos <$> itm ^? itType . ibtEquip
|
||||
= equipPosition esite cr attachpos (itemSPic itm)
|
||||
| itm ^? itLocation . ilInvID == cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
= overPosSP (heldItemOffset itm cr) (itemTreeSPic itmtree)
|
||||
= overPosSP (heldItemOffset loc cr) (itemTreeSPic itmtree)
|
||||
| otherwise = mempty
|
||||
where
|
||||
itm = itmtree ^. ldtValue . _1
|
||||
loc = LocLDT TopLDT itmtree
|
||||
|
||||
equipAttachPos :: EquipItemType -> Point3
|
||||
equipAttachPos = \case
|
||||
|
||||
@@ -21,10 +21,10 @@ import Picture
|
||||
import Shape
|
||||
import ShapePicture
|
||||
|
||||
itemTreeSPic :: LDTree ItemLink CItem -> SPic
|
||||
itemTreeSPic (LDT (itm,_) l r) = itemSPic itm <> foldMap (itemRotTreeSPic itm) (l <> r)
|
||||
itemTreeSPic :: LDTree ItemLink OItem -> SPic
|
||||
itemTreeSPic (LDT (itm,_,_) l r) = itemSPic itm <> foldMap (itemRotTreeSPic itm) (l <> r)
|
||||
|
||||
itemRotTreeSPic :: Item -> (ItemLink, LDTree ItemLink CItem) -> SPic
|
||||
itemRotTreeSPic :: Item -> (ItemLink, LDTree ItemLink OItem) -> SPic
|
||||
itemRotTreeSPic par (il, t) = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t
|
||||
where
|
||||
(p, q) = orientAttachment par il itm
|
||||
|
||||
@@ -72,20 +72,20 @@ heldItemRelativeOrient itm cr (p, q)
|
||||
sLen = _strideLength $ _crStance cr
|
||||
|
||||
handleOrient :: LocationLDT ItemLink OItem -> Point3Q
|
||||
handleOrient _ = (V3 3 0 0, Q.qID)
|
||||
handleOrient _ = (V3 (-3) 0 0, Q.qID)
|
||||
|
||||
-- note this is relative to the creature
|
||||
handOrient :: Creature -> AimStance -> Point3Q
|
||||
handOrient cr = case cr ^. crStance . posture of
|
||||
Aiming -> \case
|
||||
TwoHandUnder -> (V3 1 0 shoulderHeight, Q.qID)
|
||||
TwoHandUnder -> (V3 (-3) 0 shoulderHeight, Q.qID)
|
||||
TwoHandOver -> (V3 0 0 shoulderHeight, Q.qID)
|
||||
OneHand -> (V3 13 (-2) shoulderHeight, Q.qID)
|
||||
TwoHandFlat -> (V3 13 0 shoulderHeight, Q.qID)
|
||||
AtEase -> \case
|
||||
OneHand -> (V3 (10 + walkhandp) (-7) 15, Q.qID)
|
||||
TwoHandFlat -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) $ twoFlatHRot cr)
|
||||
TwoHandUnder -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2))
|
||||
TwoHandUnder -> (V3 7 (-8) 15, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2))
|
||||
TwoHandOver -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2))
|
||||
where
|
||||
walkhandp = case cr ^? crStance . carriage of
|
||||
@@ -112,8 +112,14 @@ aimStanceHandlePos _ it = case itemBaseStance it of
|
||||
OneHand -> V2 10 (-2)
|
||||
TwoHandFlat -> V2 10 0
|
||||
|
||||
heldItemOffset :: Item -> Creature -> Point3 -> Point3
|
||||
heldItemOffset itm cr p = fst (heldItemRelativeOrient itm cr (p, Q.qID))
|
||||
heldItemOffset :: LocationLDT ItemLink OItem -> Creature -> Point3 -> Point3
|
||||
heldItemOffset loc cr p = x + Q.rotate q p
|
||||
where
|
||||
(x,q) = handOrient cr (aimStance (loc ^. locLDT))
|
||||
`Q.comp` handleOrient loc
|
||||
|
||||
heldItemOffset' :: Item -> Creature -> Point3 -> Point3
|
||||
heldItemOffset' itm cr p = fst (heldItemRelativeOrient itm cr (p, Q.qID))
|
||||
|
||||
shoulderHeight :: Float
|
||||
shoulderHeight = 18
|
||||
|
||||
Reference in New Issue
Block a user