Skip to content

Commit

Permalink
Improve hud adjust functional
Browse files Browse the repository at this point in the history
  • Loading branch information
Hozar2002 authored and Shtrecker committed Nov 30, 2024
1 parent 010de06 commit ca723d4
Show file tree
Hide file tree
Showing 7 changed files with 454 additions and 432 deletions.
65 changes: 45 additions & 20 deletions src/xrGame/HudItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
#include "HUDAnimItem.h"
#include "ActorEffector.h"

#ifdef DEBUG_DRAW
extern u32 hud_adj_mode;
#include "debug_renderer.h"
#endif

ENGINE_API extern float psHUD_FOV_def;

CHudItem::CHudItem()
Expand Down Expand Up @@ -145,29 +150,24 @@ void CHudItem::PlaySound(LPCSTR alias, const Fvector& position, bool allowOverla
m_sounds.PlaySound(alias, position, object().H_Root(), !!GetHUDmode(), false, allowOverlap, m_started_rnd_anim_idx);
}

void CHudItem::renderable_Render()
void CHudItem::renderable_Render()
{
UpdateXForm ();
BOOL _hud_render = ::Render->get_HUD() && GetHUDmode();

if(_hud_render && !IsHidden())
{
UpdateXForm();
BOOL _hud_render = ::Render->get_HUD() && GetHUDmode();

if(_hud_render && !IsHidden()) {
}
else
{
if (!object().H_Parent() || (!_hud_render && !IsHidden()))
{
on_renderable_Render ();
debug_draw_firedeps ();
}else
if (object().H_Parent())
{
CInventoryOwner *owner = smart_cast<CInventoryOwner*>(object().H_Parent());
VERIFY (owner);
CInventoryItem *self = smart_cast<CInventoryItem*>(this);
if (owner->attached(self) ||
(item().BaseSlot() == INV_SLOT_3 /*|| item().BaseSlot() == INV_SLOT_2*/))
else {
if(!object().H_Parent() || (!_hud_render && !IsHidden())) {
on_renderable_Render();
}
else if(object().H_Parent()) {
CInventoryOwner* owner = smart_cast<CInventoryOwner*>(object().H_Parent());
VERIFY(owner);
CInventoryItem* self = smart_cast<CInventoryItem*>(this);
if(owner->attached(self) || item().BaseSlot() == INV_SLOT_3) {
on_renderable_Render();
}
}
}
}
Expand Down Expand Up @@ -1131,6 +1131,31 @@ bool CHudItem::isSuicideByAnimation(void) const
return m_bSuicideByAnimation;
}

void CHudItem::debug_draw_firedeps() {
#if 0 //def DEBUG_DRAW
if(hud_adj_mode != 3 && hud_adj_mode != 4) {
return;
}

auto xf = object().XFORM();
auto model = object().Visual();

if(GetHUDmode()) {
xf = HudItemData()->m_item_transform;
model = HudItemData()->m_model->dcast_RenderVisual();
}

vis_data data = model->getVisData();
Fvector center = {}, halfsize = {};

data.box.get_CD(center, halfsize);
xf.transform_tiny(center);
xf.c.set(center);

Level().debug_renderer().draw_obb(xf, halfsize, color_xrgb(255, 0, 255));
#endif
}

void CHudItem::SetModelBoneStatus(const char* bone, BOOL show) const {
if (HudItemData())
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/HudItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class CHudItem :public CHUDState
void SetAnimationCallback(TAnimationEffector callback) { lock_time_callback = callback; }

virtual void on_renderable_Render () = 0;
virtual void debug_draw_firedeps () {};
virtual void debug_draw_firedeps ();

virtual CHudItem* cast_hud_item () { return this; }
};
Expand Down
7 changes: 5 additions & 2 deletions src/xrGame/UIGameSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ void CUIGameSP::OnFrame()
m_game_objective = nullptr;
}
}

#ifndef MASTER_GOLD
hud_draw_adjust_mode();
attach_draw_adjust_mode();
#endif
}

bool CUIGameSP::IR_UIOnKeyboardPress(int dik)
Expand Down Expand Up @@ -144,8 +149,6 @@ bool CUIGameSP::IR_UIOnKeyboardPress(int dik)
void CUIGameSP::Render()
{
inherited::Render();
hud_draw_adjust_mode();
attach_draw_adjust_mode();
}
#endif

Expand Down
56 changes: 39 additions & 17 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3996,29 +3996,51 @@ const bool CWeapon::ParentIsActor() const
return Parent != nullptr && smart_cast<CActor*>(Parent) != nullptr;
}

void CWeapon::debug_draw_firedeps()
{
#ifdef DEBUG
if(hud_adj_mode==5||hud_adj_mode==6||hud_adj_mode==7)
{
CDebugRenderer &render = Level().debug_renderer();
extern void TransformToHudTemp(Fvector&);

if (hud_adj_mode == 5)
render.draw_aabb(get_LastFP(), 0.005f, 0.005f, 0.005f, color_xrgb(255, 0, 0));
void CWeapon::debug_draw_firedeps() {
inherited::debug_draw_firedeps();

if (hud_adj_mode == 6)
render.draw_aabb(get_LastFP2(), 0.005f, 0.005f, 0.005f, color_xrgb(0, 0, 255));
#ifdef DEBUG_DRAW
Fmatrix xf = GetHUDmode() ? HudItemData()->m_item_transform : XFORM();
u32 color = 0;

if (hud_adj_mode == 7)
render.draw_aabb(get_LastSP(), 0.005f, 0.005f, 0.005f, color_xrgb(0, 255, 0));
switch(hud_adj_mode)
{
case 3:
case 4:
case 5:
{
xf.c = get_LastFP();
color = color_xrgb(255, 0, 0);
}
break;
case 6:
{
xf.c = get_LastFP2();
color = color_xrgb(0, 0, 255);
}
break;
case 7:
{
xf.c = get_LastSP();
color = color_xrgb(0, 255, 0);
}
break;
default:
{
return;
}
}
#endif // DEBUG

Level().debug_renderer().draw_obb(xf, {0.008f, 0.008f, 0.008f}, color);
#endif
}

const float &CWeapon::hit_probability () const
{
VERIFY ((g_SingleGameDifficulty >= egdNovice) && (g_SingleGameDifficulty <= egdMaster));
return (m_hit_probability[egdNovice]);

const float& CWeapon::hit_probability() const {
VERIFY((g_SingleGameDifficulty >= egdNovice) && (g_SingleGameDifficulty <= egdMaster));
return (m_hit_probability[egdNovice]);
}

BOOL EnableDof = true;
Expand Down
Loading

0 comments on commit ca723d4

Please sign in to comment.