Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: [Feature] First Person Body #1396

Open
wants to merge 28 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1500aef
Feature: First Person Body
yohjimane Jul 11, 2023
23b59df
Fix weapon shadow flickering
yohjimane Aug 5, 2023
e1359a7
fix bug no.4 - body position jitter (thx Valerok)
yohjimane Aug 17, 2023
965bb1b
Add render lock mutex for RenderFirstPersonBody func
yohjimane Aug 18, 2023
4df81e1
Fix low sync rate bug
yohjimane Aug 19, 2023
71c7342
separate enabled/active logic into funcs
yohjimane Aug 19, 2023
0daeb22
Revert posOverride from 900c327, offset camera instead of body to res…
yohjimane Aug 20, 2023
9f6e384
Fix camera direction not matching up with head direction for first pe…
yohjimane Aug 20, 2023
a01b022
do not scale matrices down to 0 (thx v2v3v4)
yohjimane Aug 20, 2023
0ada0a0
Fix hiding/showing of bones, show arm bones on death/unarmed state
yohjimane Aug 20, 2023
685fd2e
Port fix from CoC - reuse knife animations for torso unarmed/binocula…
yohjimane Aug 23, 2023
28686ea
Better first person death cam WIP
yohjimane Aug 23, 2023
18ad21c
Hacky fix for camera direction reset on death
yohjimane Aug 23, 2023
73193d7
Fix clipping (thx v2v3v4) and add lerping factor for smoother transit…
yohjimane Aug 24, 2023
fbc34f6
Some improvements to first person body cam
yohjimane Aug 26, 2023
c1cd8b4
Fix torso pitch when holding weapon
yohjimane Aug 26, 2023
fe33f4c
Vanilla refactor, fix uninitialized member bone ids, rename confusing…
yohjimane Aug 27, 2023
5d2fa5f
Separate pitch rotation for head and torso, remove unused wip code
yohjimane Aug 27, 2023
aa97f83
Near perfect match of unarmed head yaw compared to vanilla
yohjimane Aug 27, 2023
b24ee8c
Merge branch 'dev' into feat/first-person-body
Xottab-DUTY Oct 18, 2023
7034b9c
Merge branch 'dev' into feat/first-person-body
Xottab-DUTY Nov 1, 2023
e379c91
Merge branch 'dev' into feat/first-person-body
yohjimane Jun 7, 2024
c61d6c8
* UPD: [xrGame] more accurate calculation of head position
yohjimane Jun 8, 2024
e657dfb
* UPD: [xrGame] better method to apply offsets, only Y offset is nece…
yohjimane Jun 8, 2024
6b2c46e
* FIX: [xrGame] Update firstPersonBodyXform in shedule_Update to fix …
yohjimane Jun 10, 2024
cd7bfa1
Add extra debug stuff for CPHSimpleCharacter
yohjimane Aug 6, 2024
044dbeb
* UPD: [xrGame/xrPhysics] Made actor aabb more accurate for first per…
yohjimane Aug 8, 2024
6abed41
Cleanup previous commit
yohjimane Jan 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Layers/xrRender/FTreeVisual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct FTreeVisual_setup
Fvector4 wave;
Fvector4 wind;

FTreeVisual_setup(): dwFrame(0), scale(0) {}
FTreeVisual_setup(): dwFrame(0), scale(M_MIN_SCALE) {}

void calculate()
{
Expand Down
28 changes: 16 additions & 12 deletions src/Layers/xrRender/SkeletonCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,17 +489,21 @@ void CKinematics::Release()

void CKinematics::LL_SetBoneVisible(u16 bone_id, BOOL val, BOOL bRecursive)
{
VERIFY(bone_id < LL_BoneCount());
u64 mask = u64(1) << bone_id;
visimask.set(mask, val);
if (!visimask.is(mask))
{
bone_instances[bone_id].mTransform.scale(0.f, 0.f, 0.f);
}
else
{
CalculateBones_Invalidate();
}
VERIFY(bone_id < LL_BoneCount());
if (bone_id >= LL_BoneCount())
return;
u64 mask = u64(1) << bone_id;
visimask.set(mask, val);
if (!visimask.is(mask))
{
bone_instances[bone_id].mTransform.scale(M_MIN_SCALE, M_MIN_SCALE, M_MIN_SCALE);
if (LL_GetData(bone_id).GetParentID() < LL_BoneCount() && LL_GetData(bone_id).GetParentID() != BI_NONE)
bone_instances[bone_id].mTransform.c = LL_GetBoneInstance(LL_GetData(bone_id).GetParentID()).mTransform.c;
}
else
{
CalculateBones_Invalidate();
}
bone_instances[bone_id].mRenderTransform.mul_43(
bone_instances[bone_id].mTransform, (*bones)[bone_id]->m2b_transform);
if (bRecursive)
Expand All @@ -525,7 +529,7 @@ void CKinematics::LL_SetBonesVisible(u64 mask)
{
Fmatrix& A = bone_instances[b].mTransform;
Fmatrix& B = bone_instances[b].mRenderTransform;
A.scale(0.f, 0.f, 0.f);
A.scale(M_MIN_SCALE, M_MIN_SCALE, M_MIN_SCALE);
B.mul_43(A, (*bones)[b]->m2b_transform);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRender/r__dsgraph_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ void R_dsgraph_structure::build_subspace()
IGameObject* O = g_pGameLevel->CurrentViewEntity();
if (O)
{
O->RenderFirstPersonBody(context_id, O);
CROS_impl* R = (CROS_impl*)O->ROS();
if (R)
R->update(O);
Expand Down
1 change: 1 addition & 0 deletions src/Layers/xrRender_R2/r2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "Layers/xrRender/SkeletonCustom.h"
#include "Layers/xrRender/dxWallMarkArray.h"
#include "Layers/xrRender/dxUIShader.h"
#include "xrEngine/xr_object.h"

#if defined(USE_DX11)
#include "Layers/xrRenderDX11/3DFluid/dx113DFluidManager.h"
Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,4 +532,6 @@ inline bool _valid(const Fmatrix& m)

extern XRCORE_API Fmatrix Fidentity;

constexpr float M_MIN_SCALE = 0.01f;

#endif
4 changes: 2 additions & 2 deletions src/xrEngine/CameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void CCameraManager::UpdatePPEffectors()
pp_affected.validate("after applying pp");
}

void CCameraManager::ApplyDevice()
void CCameraManager::ApplyDevice(float override_fnear)
{
ZoneScoped;
// Device params
Expand All @@ -326,7 +326,7 @@ void CCameraManager::ApplyDevice()
// projection
Device.fFOV = m_cam_info.fFov;
Device.fASPECT = m_cam_info.fAspect;
Device.mProject.build_projection(deg2rad(m_cam_info.fFov), m_cam_info.fAspect, m_cam_info.fNear, m_cam_info.fFar);
Device.mProject.build_projection(deg2rad(m_cam_info.fFov), m_cam_info.fAspect, !fis_zero(override_fnear) ? override_fnear : m_cam_info.fNear, m_cam_info.fFar);

// Apply offset required for Nvidia Ansel
Device.mProject._31 = -m_cam_info.offsetX;
Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/CameraManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ENGINE_API CCameraManager
float fFAR_Dest, u32 flags);
void UpdateFromCamera(const CCameraBase* C);

void ApplyDevice();
void ApplyDevice(float override_fnear = 0.0f);
static void ResetPP();

CCameraManager(bool bApplyOnUpdate);
Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/xr_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ class XR_NOVTABLE IGameObject
virtual void ShouldProcessOnRender(bool should_process) = 0;
virtual void OnRender() = 0;
#endif
virtual void RenderFirstPersonBody(u32 context_id, IRenderable* root) {};
virtual void reinit() = 0;
virtual void reload(pcstr section) = 0;
// network
Expand Down
Loading
Loading