Skip to content

Commit

Permalink
Fix cutscene hands dissapearing if too far from start
Browse files Browse the repository at this point in the history
  • Loading branch information
mnelenpridumivat committed Dec 29, 2024
1 parent bb73e1a commit 916132a
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 50 deletions.
1 change: 1 addition & 0 deletions src/Editors/xrECore/Editor/ExportSkeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,7 @@ bool CExportSkeleton::ExportMotionKeys(IWriter& F)
// free temp storage
for (int itm_idx=0; itm_idx<b_lst.size(); ++itm_idx)
{

bm_item& BM = items[itm_idx];
// check T
R_ASSERT (dwLen);
Expand Down
14 changes: 7 additions & 7 deletions src/Layers/xrRender/r__dsgraph_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ICF float CalcSSA (float& distSQ, Fvector& C, float R)
return R/distSQ;
}

void R_dsgraph_structure::r_dsgraph_insert_dynamic (dxRender_Visual *pVisual, Fvector& Center)
void R_dsgraph_structure::r_dsgraph_insert_dynamic (dxRender_Visual *pVisual, Fvector& Center, bool Force)
{
CRender& RI = RImplementation;

Expand All @@ -46,7 +46,7 @@ void R_dsgraph_structure::r_dsgraph_insert_dynamic (dxRender_Visual *pVisual, Fv

float distSQ ;
float SSA = CalcSSA (distSQ,Center,pVisual);
if (SSA<=r_ssaDISCARD) return;
if (SSA<=r_ssaDISCARD && !Force) return;

// Distortive geometry should be marked and R2 special-cases it
// a) Allow to optimize RT order
Expand Down Expand Up @@ -883,7 +883,7 @@ IC bool IsValuableToRender(dxRender_Visual* pVisual, bool isStatic, bool sm,
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void CRender::add_leafs_Dynamic (dxRender_Visual *pVisual, bool ignore)
void CRender::add_leafs_Dynamic (dxRender_Visual *pVisual, bool ignore, bool Force)
{
PROF_EVENT("add_leafs_Dynamic")
if (0==pVisual) return;
Expand Down Expand Up @@ -938,7 +938,7 @@ void CRender::add_leafs_Dynamic (dxRender_Visual *pVisual, bool ignore)
#endif
I = pV->children.begin ();
E = pV->children.end ();
for (; I!=E; I++) add_leafs_Dynamic (*I, ignore);
for (; I!=E; I++) add_leafs_Dynamic (*I, ignore, Force);
}
}
return;
Expand All @@ -948,7 +948,7 @@ void CRender::add_leafs_Dynamic (dxRender_Visual *pVisual, bool ignore)
// Calculate distance to it's center
Fvector Tpos;
val_pTransform->transform_tiny (Tpos, pVisual->vis.sphere.P);
r_dsgraph_insert_dynamic (pVisual,Tpos);
r_dsgraph_insert_dynamic (pVisual,Tpos, Force);
}
return;
}
Expand Down Expand Up @@ -1046,7 +1046,7 @@ void CRender::add_leafs_Static(dxRender_Visual *pVisual)
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL CRender::add_Dynamic(dxRender_Visual *pVisual, u32 planes)
BOOL CRender::add_Dynamic(dxRender_Visual *pVisual, u32 planes, bool Force)
{
PROF_EVENT("add_Dynamic")
if (!pVisual->_ignore_optimization &&
Expand Down Expand Up @@ -1124,7 +1124,7 @@ BOOL CRender::add_Dynamic(dxRender_Visual *pVisual, u32 planes)
#endif
I = pV->children.begin ();
E = pV->children.end ();
for (; I!=E; I++) add_leafs_Dynamic (*I);
for (; I!=E; I++) add_leafs_Dynamic (*I, false, Force);
}
/*
I = pV->children.begin ();
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/r__dsgraph_structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class R_dsgraph_structure : public IRender_interface, public pureFrame

void r_pmask (bool _1, bool _2, bool _wm=false) { pmask[0]=_1; pmask[1]=_2; pmask_wmark = _wm; }

void r_dsgraph_insert_dynamic (dxRender_Visual *pVisual, Fvector& Center);
void r_dsgraph_insert_dynamic (dxRender_Visual *pVisual, Fvector& Center, bool Force = false);
void r_dsgraph_insert_static (dxRender_Visual *pVisual);

void r_dsgraph_render_landscape (u32 pass, bool bClear);
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_R1/FStaticRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ BOOL CRender::occ_visible (vis_data& P) { return HOM.visible(P); }
BOOL CRender::occ_visible (sPoly& P) { return HOM.visible(P); }
BOOL CRender::occ_visible (Fbox& P) { return HOM.visible(P); }
ENGINE_API extern BOOL g_bRendering;
void CRender::add_Visual (IRenderVisual* V, bool ignore_opt)
void CRender::add_Visual (IRenderVisual* V, bool ignore_opt, bool Force)
{
VERIFY (g_bRendering);
add_leafs_Dynamic ((dxRender_Visual*)V, ignore_opt);
add_leafs_Dynamic ((dxRender_Visual*)V, ignore_opt, Force);
}
void CRender::add_Geometry (IRenderVisual* V ){ add_Static((dxRender_Visual*)V,View->getMask()); }
void CRender::add_StaticWallmark (ref_shader& S, const Fvector& P, float s, CDB::TRI* T, Fvector* verts)
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRenderPC_R1/FStaticRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ class CRender : public R_dsgraph_structure
void LoadSectors (IReader *fs);
void LoadSWIs (CStreamReader *fs);

BOOL add_Dynamic (dxRender_Visual *pVisual, u32 planes); // normal processing
BOOL add_Dynamic (dxRender_Visual *pVisual, u32 planes, bool Force = false); // normal processing
void add_Static (dxRender_Visual *pVisual, u32 planes);
void add_leafs_Dynamic (dxRender_Visual *pVisual, bool ignore = false); // if detected node's full visibility
void add_leafs_Dynamic (dxRender_Visual *pVisual, bool ignore = false, bool Force = false); // if detected node's full visibility
void add_leafs_Static (dxRender_Visual *pVisual); // if detected node's full visibility

public:
Expand Down Expand Up @@ -158,7 +158,7 @@ class CRender : public R_dsgraph_structure
virtual void flush ();
virtual void set_Object (IRenderable* O );
virtual void add_Occluder (Fbox2& bb_screenspace ); // mask screen region as oclluded
virtual void add_Visual (IRenderVisual* V, bool ignore_opt = false); // add visual leaf (no culling performed at all)
virtual void add_Visual (IRenderVisual* V, bool ignore_opt = false, bool Force = false); // add visual leaf (no culling performed at all)
virtual void add_Geometry (IRenderVisual* V ); // add visual(s) (all culling performed)

// wallmarks
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R2/r2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ BOOL CRender::occ_visible (vis_data& P) { return HOM.visible(P); }
BOOL CRender::occ_visible (sPoly& P) { return HOM.visible(P); }
BOOL CRender::occ_visible (Fbox& P) { return HOM.visible(P); }

void CRender::add_Visual (IRenderVisual* V, bool ignore_opt) { add_leafs_Dynamic((dxRender_Visual*)V, ignore_opt); }
void CRender::add_Visual (IRenderVisual* V, bool ignore_opt, bool Force) { add_leafs_Dynamic((dxRender_Visual*)V, ignore_opt, Force); }
void CRender::add_Geometry (IRenderVisual* V ) { add_Static((dxRender_Visual*)V,View->getMask()); }
void CRender::add_StaticWallmark (ref_shader& S, const Fvector& P, float s, CDB::TRI* T, Fvector* verts)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRenderPC_R2/r2.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class CRender : public R_dsgraph_structure
void LoadSectors (IReader *fs);
void LoadSWIs (CStreamReader *fs);

BOOL add_Dynamic (dxRender_Visual*pVisual, u32 planes); // normal processing
BOOL add_Dynamic (dxRender_Visual*pVisual, u32 planes, bool Force = false); // normal processing
void add_Static (dxRender_Visual*pVisual, u32 planes);
void add_leafs_Dynamic (dxRender_Visual*pVisual, bool ignore = false); // if detected node's full visibility
void add_leafs_Dynamic (dxRender_Visual*pVisual, bool ignore = false, bool Force = false); // if detected node's full visibility
void add_leafs_Static (dxRender_Visual*pVisual); // if detected node's full visibility

public:
Expand Down Expand Up @@ -245,7 +245,7 @@ class CRender : public R_dsgraph_structure
virtual void flush ();
virtual void set_Object (IRenderable* O );
virtual void add_Occluder (Fbox2& bb_screenspace ); // mask screen region as oclluded
virtual void add_Visual (IRenderVisual* V, bool ignore_opt = false); // add visual leaf (no culling performed at all)
virtual void add_Visual (IRenderVisual* V, bool ignore_opt = false, bool Force = false); // add visual leaf (no culling performed at all)
virtual void add_Geometry (IRenderVisual* V ); // add visual(s) (all culling performed)

// wallmarks
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_R4/r4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ BOOL CRender::occ_visible(Fbox& P) {
return HOM.visible(P);
}

void CRender::add_Visual(IRenderVisual* V, bool ignore_opt) {
add_leafs_Dynamic((dxRender_Visual*)V, ignore_opt);
void CRender::add_Visual(IRenderVisual* V, bool ignore_opt, bool Force) {
add_leafs_Dynamic((dxRender_Visual*)V, ignore_opt, Force);
}
void CRender::add_Geometry(IRenderVisual* V) {
add_Static((dxRender_Visual*)V, View->getMask());
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRenderPC_R4/r4.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class CRender : public R_dsgraph_structure
void LoadSWIs (CStreamReader *fs);
void Load3DFluid ();

BOOL add_Dynamic (dxRender_Visual*pVisual, u32 planes); // normal processing
BOOL add_Dynamic (dxRender_Visual*pVisual, u32 planes, bool Force = false); // normal processing
void add_Static (dxRender_Visual*pVisual, u32 planes);
void add_leafs_Dynamic (dxRender_Visual*pVisual, bool ignore = false); // if detected node's full visibility
void add_leafs_Dynamic (dxRender_Visual*pVisual, bool ignore = false, bool Force = false); // if detected node's full visibility
void add_leafs_Static (dxRender_Visual*pVisual); // if detected node's full visibility

public:
Expand Down Expand Up @@ -260,7 +260,7 @@ class CRender : public R_dsgraph_structure
virtual void flush ();
virtual void set_Object (IRenderable* O );
virtual void add_Occluder (Fbox2& bb_screenspace ); // mask screen region as oclluded
virtual void add_Visual (IRenderVisual* V, bool ignore_opt = false); // add visual leaf (no culling performed at all)
virtual void add_Visual (IRenderVisual* V, bool ignore_opt = false, bool Force = false); // add visual leaf (no culling performed at all)
virtual void add_Geometry (IRenderVisual* V ); // add visual(s) (all culling performed)

// wallmarks
Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/Render.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class ENGINE_API IRender_interface
virtual void flush () {};
virtual void set_Object (IRenderable* O ) {};
virtual void add_Occluder (Fbox2& bb_screenspace ) {}; // mask screen region as oclluded (-1..1, -1..1)
virtual void add_Visual (IRenderVisual* V, bool ignore_opt = false) {}; // add visual leaf (no culling performed at all)
virtual void add_Visual (IRenderVisual* V, bool ignore_opt = false, bool Force = false) {}; // add visual leaf (no culling performed at all)
virtual void add_Geometry (IRenderVisual* V ) {}; // add visual(s) (all culling performed)
virtual void add_StaticWallmark (const wm_shader& S, const Fvector& P, float s, CDB::TRI* T, Fvector* V) {};

Expand Down
1 change: 0 additions & 1 deletion src/xrGame/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,6 @@ void CActor::OnHUDDraw (CCustomHUD* Z)
if(auto pGameObject = smart_cast<CGameObject*>(Holder())) {
pGameObject->OnHUDDraw(Z);
}
CCutsceneManager::GetInstance().Update();
#if 0//ndef NDEBUG
if (Level().CurrentControlEntity() == this && g_ShowAnimationInfo)
{
Expand Down
28 changes: 3 additions & 25 deletions src/xrGame/CutsceneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ void CCutsceneManager::PlayCutscene(LPCSTR section)

R_ASSERT3(M2.valid(), "model has no motion [idle] ", pSettings->r_string(section, "anim"));

//u16 root_id = Self.HudModelKinematics->LL_GetBoneRoot();
//CBoneInstance& root_binst = Self.HudModelKinematics->LL_GetBoneInstance(root_id);
//root_binst.set_callback_overwrite(true);
//root_binst.mTransform.identity();

u16 pc = Self.HudModelKinematicsAnimated->partitions().count();
for (u16 pid = 0; pid < pc; ++pid)
{
Expand All @@ -54,27 +49,10 @@ void CCutsceneManager::Update()
::Render->set_HUD(false);
Fmatrix m_transform;
m_transform.identity();
//m_transform.i = Device.vCameraRight;
//m_transform.j = Device.vCameraTop;// -Device.vCameraDirection;//Device.vCameraTop;
//m_transform.k = Device.vCameraDirection;// Device.vCameraTop; //Device.vCameraDirection;
//m_transform.c = Device.vCameraPosition;
//::Render->set_Transform(&m_transform);
//Actor()->Cameras().hud_camera_Matrix(m_transform);
//auto Pos = m_transform.c;
//m_transform.rotateX(90);
//m_transform.c.y += 100;
//m_transform = HudModelKinematics->LL_GetTransform(HudModelKinematics->LL_GetBoneRoot());
//m_transform.build_camera_dir(Device.vCameraPosition, Device.vCameraDirection, Device.vCameraTop);
::Render->set_Transform(&m_transform);
HudModelKinematics->CalculateBones(true);
::Render->add_Visual(HudModel, true);

::Render->set_Transform(&m_transform);
::Render->add_Visual(HudModel, true, true);
::Render->set_HUD(bHud);
for (u16 i = 0; i < HudModelKinematics->LL_BoneCount(); ++i) {
Fmatrix l_ball = HudModelKinematics->LL_GetTransform(i);
auto Pos = l_ball.c;
l_ball.scale(0.01, 0.01, 0.01);
l_ball.c = Pos;
Level().debug_renderer().draw_ellipse(l_ball, color_xrgb(0, 255, 255));
}
}
}
6 changes: 5 additions & 1 deletion src/xrGame/HUDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "PHDebug.h"
#endif
#include "../../xrUI/UIFontDefines.h"
#include <CutsceneManager.h>

extern CUIGameCustom* CurrentGameUI() {return HUD().GetGameUI();}

Expand Down Expand Up @@ -90,12 +91,15 @@ bool need_render_hud()

void CHUDManager::Render_Last()
{
CObject* O = g_pGameLevel->CurrentViewEntity();
::Render->set_Object(O->H_Root());
CCutsceneManager::GetInstance().Update();

if (!psHUD_Flags.is(HUD_WEAPON|HUD_WEAPON_RT|HUD_WEAPON_RT2|HUD_DRAW_RT2))return;
if (0==pUIGame) return;

if(!need_render_hud()) return;

CObject* O = g_pGameLevel->CurrentViewEntity();
// hud itself
::Render->set_HUD (TRUE);
::Render->set_Object (O->H_Root());
Expand Down

0 comments on commit 916132a

Please sign in to comment.