From 79e5283df695b5970aee20bb23e70c0036c46a45 Mon Sep 17 00:00:00 2001 From: xrSimpodin <16670637+xrSimpodin@users.noreply.github.com> Date: Mon, 11 Mar 2024 21:32:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B8=20=D1=83=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ogsr_engine/xrGame/ShootingObject.cpp | 2 +- ogsr_engine/xrGame/ShootingObject.h | 3 +- ogsr_engine/xrGame/Weapon.cpp | 42 +++++++------------ ogsr_engine/xrGame/Weapon.h | 3 +- .../xrGame/ai/stalker/ai_stalker_fire.cpp | 4 +- 5 files changed, 20 insertions(+), 34 deletions(-) diff --git a/ogsr_engine/xrGame/ShootingObject.cpp b/ogsr_engine/xrGame/ShootingObject.cpp index 58157b1894..4aa3006041 100644 --- a/ogsr_engine/xrGame/ShootingObject.cpp +++ b/ogsr_engine/xrGame/ShootingObject.cpp @@ -433,7 +433,7 @@ void CShootingObject::FireBullet(const Fvector& pos, const Fvector& shot_dir, fl bool aim_bullet; if (m_bUseAimBullet) { - if (ParentMayHaveAimBullet()) + if (ParentIsActor()) { if (m_fPredBulletTime == 0.0) { diff --git a/ogsr_engine/xrGame/ShootingObject.h b/ogsr_engine/xrGame/ShootingObject.h index c15eb42727..486d458808 100644 --- a/ogsr_engine/xrGame/ShootingObject.h +++ b/ogsr_engine/xrGame/ShootingObject.h @@ -48,8 +48,7 @@ class CShootingObject public: IC BOOL IsWorking() const { return bWorking; } - virtual BOOL ParentMayHaveAimBullet() { return FALSE; } - virtual BOOL ParentIsActor() { return FALSE; } + virtual bool ParentIsActor() const { return false; } protected: // Weapon fires now diff --git a/ogsr_engine/xrGame/Weapon.cpp b/ogsr_engine/xrGame/Weapon.cpp index d6e923e31e..28c569142a 100644 --- a/ogsr_engine/xrGame/Weapon.cpp +++ b/ogsr_engine/xrGame/Weapon.cpp @@ -96,9 +96,6 @@ void CWeapon::UpdateXForm() { dwXF_Frame = Device.dwFrame; - if (0 == H_Parent()) - return; - // Get access to entity and its visual CEntityAlive* E = smart_cast(H_Parent()); @@ -112,7 +109,6 @@ void CWeapon::UpdateXForm() if (parent->attached(this)) return; - R_ASSERT(E); IKinematics* V = smart_cast(E->Visual()); VERIFY(V); @@ -128,12 +124,19 @@ void CWeapon::UpdateXForm() if (boneL == BI_NONE || boneR == BI_NONE) return; - // от mortan: - // https://www.gameru.net/forum/index.php?s=&showtopic=23443&view=findpost&p=1677678 - V->CalculateBones_Invalidate(); - V->CalculateBones(true); // V->CalculateBones (); - Fmatrix& mL = V->LL_GetTransform(u16(boneL)); - Fmatrix& mR = V->LL_GetTransform(u16(boneR)); + if (auto pActor = smart_cast(H_Parent()); pActor && pActor->cam_Active() != pActor->cam_FirstEye()) + { + // https://www.gameru.net/forum/index.php?s=&showtopic=23443&view=findpost&p=1677678 + V->CalculateBones_Invalidate(); + V->CalculateBones(true); + } + else + { + V->CalculateBones(); + } + + const Fmatrix& mL = V->LL_GetTransform(u16(boneL)); + const Fmatrix& mR = V->LL_GetTransform(u16(boneR)); // Calculate Fmatrix mRes; Fvector R, D, N; @@ -2041,24 +2044,9 @@ float CWeapon::GetConditionToShow() const return (GetCondition()); // powf(GetCondition(),4.0f)); } -BOOL CWeapon::ParentMayHaveAimBullet() +bool CWeapon::ParentIsActor() const { - CObject* O = H_Parent(); - if (!O) - return FALSE; - CEntityAlive* EA = smart_cast(O); - return EA->cast_actor() != 0; -} - -BOOL CWeapon::ParentIsActor() -{ - CObject* O = H_Parent(); - if (!O) - return FALSE; - CEntityAlive* EA = smart_cast(O); - if (!EA) - return FALSE; - return EA->cast_actor() != 0; + return smart_cast(H_Parent()) != nullptr; } const float& CWeapon::hit_probability() const diff --git a/ogsr_engine/xrGame/Weapon.h b/ogsr_engine/xrGame/Weapon.h index a9722a1182..52c170bdea 100644 --- a/ogsr_engine/xrGame/Weapon.h +++ b/ogsr_engine/xrGame/Weapon.h @@ -552,8 +552,7 @@ class CWeapon : public CHudItemObject, public CShootingObject virtual bool use_crosshair() const { return true; } bool show_crosshair(); bool show_indicators(); - virtual BOOL ParentMayHaveAimBullet(); - virtual BOOL ParentIsActor(); + virtual bool ParentIsActor() const override; private: float m_hit_probability[egdCount]; diff --git a/ogsr_engine/xrGame/ai/stalker/ai_stalker_fire.cpp b/ogsr_engine/xrGame/ai/stalker/ai_stalker_fire.cpp index 97c04db90f..727141e2c5 100644 --- a/ogsr_engine/xrGame/ai/stalker/ai_stalker_fire.cpp +++ b/ogsr_engine/xrGame/ai/stalker/ai_stalker_fire.cpp @@ -674,10 +674,10 @@ float CAI_Stalker::pick_distance() void CAI_Stalker::update_can_kill_info() { - if (m_pick_frame_id == Device.dwFrame) + if (m_pick_frame_id > Device.dwFrame) return; - m_pick_frame_id = Device.dwFrame; + m_pick_frame_id = Device.dwFrame + 10; m_can_kill_member = false; m_can_kill_enemy = false;