Cleanup, remove old item orientation code

This commit is contained in:
2025-07-06 13:08:13 +01:00
parent 76cb03b07b
commit b6cd988c82
3 changed files with 80 additions and 132 deletions
+10 -16
View File
@@ -309,8 +309,7 @@ updateItemWithOrientation ::
updateItemWithOrientation cr m loc@(LocLDT _ itmtree) w =
case (ci ^. _1 . itType, ci ^. _2) of
(HELD TORCH, _) -> shineTorch cr itmtree m w
--(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr itmtree m w
(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr loc w
(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr loc m w
(TARGETING tt, _) -> updateItemTargeting tt cr itm w
(ARHUD, _) -> drawARHUD loc w
_ -> w
@@ -326,8 +325,8 @@ drawARHUD (LocLDT con _) w = fromMaybe w $ do
<>~ fold
(drawTargetingAR itm w <|> drawMapperAR itm w)
shineTargetLaser :: Creature -> LocationLDT ItemLink CItem -> World -> World
shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
shineTargetLaser :: Creature -> LocationLDT ItemLink CItem -> Point3Q -> World -> World
shineTargetLaser cr loc o w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
guard (crIsAiming cr)
(_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
i <- mag ^. ldtValue . _1 . itConsumables
@@ -352,8 +351,10 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
}
where
itmtree = loc ^. locLDT
(p,q) = heldItemRelativeOrient (locToTop loc ^. locLDT . ldtValue . _1) cr
$ orientLocation (V3 0 0 0,Q.qID) (fmap fst loc) (V3 5 0 0,Q.qID)
--(p,q) = heldItemRelativeOrient (locToTop loc ^. locLDT . ldtValue . _1) cr
-- $ orientLocation (V3 0 0 0,Q.qID) (fmap fst loc) (V3 5 0 0,Q.qID)
(p,q) = o `Q.comp` (V3 5 0 0,Q.qID)
-- $ orientLocation (V3 0 0 0,Q.qID) (fmap fst loc) (V3 5 0 0,Q.qID)
x = 1
isammolink AmmoInLink{} = True
isammolink _ = False
@@ -406,12 +407,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
-- invid = _ilInvID $ _itLocation itm
-- col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
shineTorch ::
Creature ->
LDTree ItemLink CItem ->
(Point3, Q.Quaternion Float) ->
World ->
World
shineTorch :: Creature -> LDTree ItemLink CItem -> Point3Q -> World -> World
shineTorch cr itmtree (p, q) = fromMaybe id $ do
(_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
i <- mag ^. ldtValue . _1 . itConsumables
@@ -419,16 +415,14 @@ shineTorch cr itmtree (p, q) = fromMaybe id $ do
guard $ i >= x
invid <- mag ^? ldtValue . _1 . itLocation . ilInvID
return $
(cWorld . lWorld . lights .:~ LSParam pos'' 250 0.7)
(cWorld . lWorld . lights .:~ LSParam pos 250 0.7)
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itConsumables . _Just -~ x)
where
x = 10
isammolink AmmoInLink{} = True
isammolink _ = False
pos = _crPos cr `v2z` 0 + rotate3 cdir p
pos'' = pos + rotate3 d (V3 8 0 1.5)
pos = _crPos cr `v2z` 0 + rotate3 cdir (p + Q.rotate q (V3 8 0 1.5))
cdir = _crDir cr
d = _crDir cr + argV (Q.qToV2 q)
-- this probably needs to be set to null when dropped as well?
-- does this need to be updated if it is not attached to the used root item?
-44
View File
@@ -4,12 +4,10 @@ module Dodge.Item.HeldOffset (
turretItemOffset,
twoFlatHRot,
heldItemOffset,
heldItemRelativeOrient,
locOrient,
handHandleOrient,
) where
import Dodge.Creature.Radius
import Dodge.Data.AimStance
import Dodge.Data.ComposedItem
import Dodge.Data.Creature
@@ -30,32 +28,6 @@ transToHandle itm = (-.-.- V3 x y 0)
where
V2 x y = handlePos itm
heldItemRelativeOrient :: Item -> Creature -> Point3Q -> Point3Q
heldItemRelativeOrient itm cr (p, q)
| Aiming{} <- _posture (_crStance cr) =
(p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
| TwoHandFlat <- itemBaseStance itm =
( V3 (crRad $ cr ^. crType) 0 handD + rotate3 (twoFlatHRot cr) (transToHandle itm p)
, Q.axisAngle (V3 0 0 1) (twoFlatHRot cr) * q
)
| OneHand <- itemBaseStance itm =
( V3 (crRad (cr ^. crType) * 0.7 + handPos) (crRad (cr ^. crType) * negate 0.7) handD
+ transToHandle itm p
, Q.qID * q
)
| otherwise =
( V3 (crRad $ cr ^. crType) 0 handD
+ rotate3 (strideRot cr + 1.2) (V3 (-8) 0 0 + transToHandle itm p)
, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2) * q
)
where
handD = 15
handPos = case cr ^? crStance . carriage of
Just (Walking x LeftForward) -> f x * 50 -2
_ -> 0 - 2
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
sLen = _strideLength $ _crStance cr
handleOrient :: LocationLDT ItemLink CItem -> Point3Q
handleOrient loc = case loc ^. locLDT . ldtValue . _1 . itType of
HELD FLAMETHROWER -> (V3 (-1) 0 0, Q.qID)
@@ -86,22 +58,6 @@ locOrient 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
-- the position of a weapon handle
aimStanceHandlePos :: Creature -> Item -> Point2
aimStanceHandlePos _ it = case itemBaseStance it of
TwoHandUnder -> V2 (-2) 0
TwoHandOver -> V2 (-7) 0
OneHand -> V2 10 (-2)
TwoHandFlat -> V2 10 0
heldItemOffset :: LocationLDT ItemLink CItem -> Creature -> Point3 -> Point3
heldItemOffset loc cr p = x + Q.rotate q p
where