Remove ItemLink from item orientation code
This commit is contained in:
@@ -12,8 +12,8 @@ import Linear
|
||||
import qualified Linear.Quaternion as Q
|
||||
|
||||
data ItemLink
|
||||
= AmmoInLink Int AmmoType
|
||||
| TriggerLink
|
||||
= TriggerLink
|
||||
| AmmoInLink Int AmmoType
|
||||
| AmmoModLink
|
||||
| AmmoTargetingLink
|
||||
| AmmoPayloadLink
|
||||
|
||||
@@ -27,8 +27,8 @@ itemTreeSPic (LDT (itm,_) l r) = itemSPic itm <> foldMap (itemRotTreeSPic itm) (
|
||||
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
|
||||
itm = t ^. ldtValue . _1
|
||||
(p, q) = orientAttachment par itm
|
||||
itm = t ^. ldtValue
|
||||
|
||||
itemSPic :: Item -> SPic
|
||||
itemSPic it = case it ^. itType of
|
||||
|
||||
@@ -21,26 +21,26 @@ orientChild itm = case _itType itm of
|
||||
--r = Q.axisAngle (V3 0 0 1) (-pi/4)
|
||||
r = Q.qID
|
||||
|
||||
orientByLink :: Item -> ItemLink -> Point3Q
|
||||
orientByLink itm lt = case (_itType itm, lt) of
|
||||
(HELD FLAMETHROWER, AmmoInLink{}) -> (V3 4 (-6) 0, Q.qID)
|
||||
(HELD _, AmmoInLink{}) -> (V3 7 (-2) 0, Q.qID)
|
||||
(HELD _, WeaponScopeLink) -> (V3 5 0 5, Q.qID)
|
||||
orientByParentChSF :: Item -> ItemStructuralFunction -> Point3Q
|
||||
orientByParentChSF itm lt = case (_itType itm, lt) of
|
||||
(HELD FLAMETHROWER, AmmoMagSF{}) -> (V3 4 (-6) 0, Q.qID)
|
||||
(HELD _, AmmoMagSF{}) -> (V3 7 (-2) 0, Q.qID)
|
||||
(HELD _, WeaponScopeSF) -> (V3 5 0 5, Q.qID)
|
||||
_ -> (0, Q.qID)
|
||||
|
||||
orientAttachment :: Item -> ItemLink -> Item -> Point3Q
|
||||
orientAttachment par lnk ch = case (_itType par, lnk, _itType ch) of
|
||||
(ATTACH UNDERBARRELSLOT, _, _) -> (V3 (-5) (-8) 0, Q.qID)
|
||||
(_,SFLink LaserWeaponSF,_) -> (V3 2 8 0, Q.qID)
|
||||
orientAttachment :: Item -> CItem -> Point3Q
|
||||
orientAttachment par (ch,chsf) = case (_itType par, chsf) of
|
||||
(ATTACH UNDERBARRELSLOT, _) -> (V3 (-5) (-8) 0, Q.qID)
|
||||
(_,LaserWeaponSF) -> (V3 2 8 0, Q.qID)
|
||||
-- (HELD BURSTRIFLE, _, HELD TORCH) -> (V3 20 0 0, Q.axisAngle (V3 0 0 1) (pi/2))
|
||||
-- (HELD LAUNCHER, _, HELD TORCH) -> (V3 0 20 0, Q.axisAngle (V3 0 0 1) (pi/4))
|
||||
_ -> (t1 + Q.rotate q1 t2, q1 * q2)
|
||||
where
|
||||
(t1, q1) = orientByLink par lnk
|
||||
(t1, q1) = orientByParentChSF par chsf
|
||||
(t2, q2) = orientChild ch
|
||||
|
||||
propagateOrientation :: LDTree ItemLink CItem -> LDTree ItemLink OItem
|
||||
propagateOrientation = ldtStartPropagate g f
|
||||
where
|
||||
g (x,y) = (x,y,(V3 0 0 0,Q.qID))
|
||||
f (x,_,pq) i (y,y1) = (y,y1,Q.comp pq $ orientAttachment x i y)
|
||||
f (x,_,pq) i (y,y1) = (y,y1,Q.comp pq $ orientAttachment x (y,y1))
|
||||
|
||||
Reference in New Issue
Block a user