@@ -1034,8 +1034,21 @@ float CActor::currentFOV()
1034
1034
}
1035
1035
}
1036
1036
1037
+ extern float g_first_person_body_offset;
1037
1038
void CActor::UpdateCL ()
1038
1039
{
1040
+ if (m_firstPersonBody)
1041
+ {
1042
+ // adjust body position
1043
+ Fvector camdir = { cam_Active ()->Direction ().x , 0 .f , cam_Active ()->Direction ().z }; // ignore Y (vertical) value
1044
+ firstPersonBodyXform.set (XFORM ());
1045
+ firstPersonBodyXform.c .add (camdir.normalize ().mul (g_first_person_body_offset)); // push model back so it doesn't look weird (default value: -0.75f)
1046
+ // Update head position
1047
+ IKinematics* realBodyK = Visual ()->dcast_PKinematics ();
1048
+ headPosition.set (firstPersonBodyXform);
1049
+ headPosition.mulB_43 (realBodyK->LL_GetTransform (realBodyK->LL_BoneID (" bip01_head" )));
1050
+ }
1051
+
1039
1052
if (g_Alive () && Level ().CurrentViewEntity () == this )
1040
1053
{
1041
1054
if (CurrentGameUI () && !CurrentGameUI ()->TopInputReceiver () && !m_holder)
@@ -1515,6 +1528,8 @@ void CActor::shedule_Update(u32 DT)
1515
1528
#include " debug_renderer.h"
1516
1529
void CActor::renderable_Render (u32 context_id, IRenderable* root)
1517
1530
{
1531
+ if (m_firstPersonBody)
1532
+ XFORM ().translate_over (firstPersonBodyXform.c ); // move our original body to where our first person body is, so shadow renders in correct place
1518
1533
VERIFY (_valid (XFORM ()));
1519
1534
inherited::renderable_Render (context_id, root);
1520
1535
CInventoryOwner::renderable_Render (context_id, root);
@@ -1528,7 +1543,6 @@ bool CActor::renderable_ShadowGenerate()
1528
1543
return inherited::renderable_ShadowGenerate ();
1529
1544
}
1530
1545
1531
- extern float g_first_person_body_offset;
1532
1546
void CActor::RenderFirstPersonBody (u32 context_id, IRenderable* root)
1533
1547
{
1534
1548
if (!(psActorFlags.test (AF_FIRST_PERSON_BODY) && cam_active == eacFirstEye))
@@ -1544,14 +1558,8 @@ void CActor::RenderFirstPersonBody(u32 context_id, IRenderable* root)
1544
1558
IKinematics* kinematics = m_firstPersonBody->dcast_PKinematics ();
1545
1559
IKinematics* realBodyK = Visual ()->dcast_PKinematics ();
1546
1560
1547
- // adjust body position
1548
- Fvector camdir = { cam_Active ()->Direction ().x , 0 .f , cam_Active ()->Direction ().z }; // ignore Y (vertical) value
1549
- Fmatrix trans = XFORM ();
1550
- trans.c .add (camdir.normalize ().mul (g_first_person_body_offset)); // push model back so it doesn't look weird (default value: -0.75f)
1551
- XFORM ().translate_over (trans.c ); // move our original body to where our first person body is, so shadow renders in correct place
1552
-
1553
1561
// Add body to render
1554
- GEnv.Render ->add_Visual (context_id, root, m_firstPersonBody, trans );
1562
+ GEnv.Render ->add_Visual (context_id, root, m_firstPersonBody, firstPersonBodyXform );
1555
1563
m_firstPersonBody->getVisData ().hom_frame = Device.dwFrame ;
1556
1564
1557
1565
// Copy transforms from actual body visual, excluding bones we don't want to animate
@@ -1561,27 +1569,22 @@ void CActor::RenderFirstPersonBody(u32 context_id, IRenderable* root)
1561
1569
if (m_firstPersonBodyBonesToIgnoreAnims[i])
1562
1570
continue ;
1563
1571
1564
- kinematics->LL_GetTransform (i).set (realBodyK->LL_GetTransform (i));
1565
1572
kinematics->LL_GetTransform_R (i).set (realBodyK->LL_GetTransform_R (i));
1566
1573
}
1567
1574
1568
1575
// Hide bones
1569
1576
for (auto [boneId, vis] : m_firstPersonBodyBonesToHide)
1570
1577
kinematics->LL_SetBoneVisible (boneId, !vis, true );
1571
1578
1572
- // Update head position
1573
- headPosition.set (trans);
1574
- headPosition.mulB_43 (realBodyK->LL_GetTransform (realBodyK->LL_BoneID (" bip01_head" )));
1575
-
1576
1579
#ifdef DEBUG
1577
1580
Fvector ypr;
1578
- trans .getHPB (ypr);
1581
+ firstPersonBodyXform .getHPB (ypr);
1579
1582
string1024 text;
1580
1583
CGameFont* F = UI ().Font ().pFontArial14 ;
1581
1584
F->SetAligment (CGameFont::alLeft);
1582
1585
F->OutSetI (-.9 , 0 );
1583
1586
F->SetColor (color_rgba (255 , 0 , 0 , 255 ));
1584
- xr_sprintf (text, " first person body position [%3.3f %3.3f %3.3f]" , trans .c .x , trans .c .y , trans .c .z );
1587
+ xr_sprintf (text, " first person body position [%3.3f %3.3f %3.3f]" , firstPersonBodyXform .c .x , firstPersonBodyXform .c .y , firstPersonBodyXform .c .z );
1585
1588
F->OutNext (text);
1586
1589
xr_sprintf (text, " head position [%3.3f %3.3f %3.3f]" , headPosition.c .x , headPosition.c .y , headPosition.c .z );
1587
1590
F->OutNext (text);
0 commit comments