Skip to content

Commit fb0dbbb

Browse files
committed
Fix weapon shadow flickering
1 parent 900c327 commit fb0dbbb

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/xrGame/HudItem.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ void CHudItem::PlaySound(pcstr alias, const Fvector& position, u8 index)
6060
{
6161
m_sounds.PlaySound(alias, position, object().H_Root(), !!GetHUDmode(), false, index);
6262
}
63-
6463
//-Alundaio
64+
6565
void CHudItem::renderable_Render(u32 context_id, IRenderable* root)
6666
{
6767
UpdateXForm();
68-
6968
const bool _hud_render = root && root->renderable_HUD() && GetHUDmode();
7069

7170
if (_hud_render && !IsHidden())

src/xrGame/Weapon.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define ROTATION_TIME 0.25f
3333

3434
BOOL b_toggle_weapon_aim = FALSE;
35+
extern float g_first_person_body_offset;
3536

3637
static class CUIWpnScopeXmlManager : public CUIResetNotifier, public pureAppEnd
3738
{
@@ -187,6 +188,13 @@ void CWeapon::UpdateXForm()
187188
mRes.mulA_43(E->XFORM());
188189
}
189190

191+
if (auto actorOwner = smart_cast<CActor*>(H_Parent()))
192+
if ((psActorFlags.test(AF_FIRST_PERSON_BODY)) && actorOwner->active_cam() == eacFirstEye)
193+
{
194+
Fvector camdir = { actorOwner->cam_Active()->Direction().x, 0.f, actorOwner->cam_Active()->Direction().z }; // ignore Y (vertical) value
195+
mRes.c.add(camdir.normalize().mul(g_first_person_body_offset)); // push model back so it doesn't look weird (default value: -0.75f)
196+
}
197+
190198
UpdatePosition(mRes);
191199
}
192200

@@ -915,17 +923,6 @@ bool CWeapon::need_renderable() { return !(IsZoomed() && ZoomTexture() && !IsRot
915923
extern float g_first_person_body_offset;
916924
void CWeapon::renderable_Render(u32 context_id, IRenderable* root)
917925
{
918-
if (auto actorOwner = smart_cast<CActor*>(H_Parent()))
919-
{
920-
if ((psActorFlags.test(AF_FIRST_PERSON_BODY)) && actorOwner->active_cam() == eacFirstEye)
921-
{
922-
Fvector camdir = { actorOwner->cam_Active()->Direction().x, 0.f, actorOwner->cam_Active()->Direction().z }; // ignore Y (vertical) value
923-
Fmatrix trans = XFORM();
924-
trans.c.add(camdir.normalize().mul(g_first_person_body_offset)); // push model back so it doesn't look weird (default value: -0.75f)
925-
XFORM().translate_over(trans.c); // move our original weapon to where our first person body is, so shadow render in correct place
926-
}
927-
}
928-
929926
ScopeLock lock{ &render_lock };
930927

931928
UpdateXForm();

0 commit comments

Comments
 (0)