Skip to content

Commit

Permalink
+Actor shadow added
Browse files Browse the repository at this point in the history
+SE_NEAR changed from 9 to 20
+zoom_dof enabled
+reload_dof and reload_empty_dof added
  • Loading branch information
CasualDev242 authored and Xottab-DUTY committed Aug 18, 2017
1 parent cee6a56 commit 044d383
Show file tree
Hide file tree
Showing 21 changed files with 116 additions and 28 deletions.
5 changes: 5 additions & 0 deletions src/Layers/xrRender/r__dsgraph_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,11 @@ void D3DXRenderBase::r_dsgraph_render_subspace(IRender_Sector* _sector, CFrustum
}
}

#if RENDER != R_R1
if (g_pGameLevel && (phase == RImplementation.PHASE_SMAP) && ps_actor_shadow_flags.test(RFLAG_ACTOR_SHADOW))
g_hud->Render_Actor_Shadow(); // Actor Shadow
#endif

// Restore
ViewBase = ViewSave;
View = nullptr;
Expand Down
4 changes: 4 additions & 0 deletions src/Layers/xrRender/xrRender_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ xr_token ext_quality_token[] = {{"qt_off", 0}, {"qt_low", 1}, {"qt_medium", 2},
{"qt_high", 3}, {"qt_extreme", 4}, {nullptr, 0}};
//-AVO

Flags32 ps_actor_shadow_flags = { 0 };

//- Mad Max
float ps_r2_gloss_factor = 4.0f;
//- Mad Max
Expand Down Expand Up @@ -750,6 +752,8 @@ void xrRender_initconsole()
CMD4(CCC_Float, "r2_zfill_depth", &ps_r2_zfill, .001f, .5f);
CMD3(CCC_Mask, "r2_allow_r1_lights", &ps_r2_ls_flags, R2FLAG_R1LIGHTS);

CMD3(CCC_Mask, "r__actor_shadow", &ps_actor_shadow_flags, RFLAG_ACTOR_SHADOW); //Swartz

//- Mad Max
CMD4(CCC_Float, "r2_gloss_factor", &ps_r2_gloss_factor, .0f, 10.f);
//- Mad Max
Expand Down
7 changes: 7 additions & 0 deletions src/Layers/xrRender/xrRender_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ enum
R2FLAGEXT_SUN_OLD = (1 << 9),
};

extern ECORE_API Flags32 ps_actor_shadow_flags;

enum
{
RFLAG_ACTOR_SHADOW = (1 << 0),
};

extern void xrRender_initconsole();
extern BOOL xrRender_test_hw();
extern void xrRender_apply_tf();
Expand Down
2 changes: 2 additions & 0 deletions src/Layers/xrRenderPC_R1/FStaticRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ class CRender : public D3DXRenderBase
virtual void rmFar() override;
virtual void rmNormal() override;

u32 active_phase() override { return phase; }

// Constructor/destructor/loader
CRender();
virtual ~CRender();
Expand Down
2 changes: 2 additions & 0 deletions src/Layers/xrRenderPC_R2/r2.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ class CRender : public D3DXRenderBase
virtual void rmFar();
virtual void rmNormal();

u32 active_phase() override { return phase; }

// Constructor/destructor/loader
CRender();
virtual ~CRender();
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R2/r2_R_sun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ void CRender::init_cacades()
float fBias = -0.0000025f;
// float size = MAP_SIZE_START;
m_sun_cascades[0].reset_chain = true;
m_sun_cascades[0].size = 9;
m_sun_cascades[0].size = 20;
m_sun_cascades[0].bias = m_sun_cascades[0].size * fBias;

m_sun_cascades[1].size = 40;
Expand Down
2 changes: 2 additions & 0 deletions src/Layers/xrRenderPC_R3/r3.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ class CRender : public D3DXRenderBase
virtual void rmFar();
virtual void rmNormal();

u32 active_phase() override { return phase; }

// Constructor/destructor/loader
CRender();
virtual ~CRender();
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R3/r3_R_sun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ void CRender::init_cacades()
float fBias = -0.0000025f;
// float size = MAP_SIZE_START;
m_sun_cascades[0].reset_chain = true;
m_sun_cascades[0].size = 9;
m_sun_cascades[0].size = 20;
m_sun_cascades[0].bias = m_sun_cascades[0].size * fBias;

m_sun_cascades[1].size = 40;
Expand Down
2 changes: 2 additions & 0 deletions src/Layers/xrRenderPC_R4/r4.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ class CRender : public D3DXRenderBase
virtual void rmFar();
virtual void rmNormal();

u32 active_phase() override { return phase; }

// Constructor/destructor/loader
CRender();
virtual ~CRender();
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R4/r4_R_sun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ void CRender::init_cacades()
float fBias = -0.0000025f;
// float size = MAP_SIZE_START;
m_sun_cascades[0].reset_chain = true;
m_sun_cascades[0].size = 9;
m_sun_cascades[0].size = 20;
m_sun_cascades[0].bias = m_sun_cascades[0].size * fBias;

m_sun_cascades[1].size = 40;
Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/CustomHUD.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ENGINE_API CCustomHUD : public FactoryObjectBase, public IEventReceiver, p

virtual void Render_First() { ; }
virtual void Render_Last() { ; }
virtual void Render_Actor_Shadow() {}
BENCH_SEC_SCRAMBLEVTBL1

virtual void OnFrame() { ; }
Expand Down
1 change: 1 addition & 0 deletions src/xrEngine/Render.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ class ENGINE_API IRender
virtual void rmFar() = 0;
virtual void rmNormal() = 0;
virtual u32 memory_usage() = 0;
virtual u32 active_phase () = 0;

// Constructor/destructor
virtual ~IRender() {}
Expand Down
19 changes: 15 additions & 4 deletions src/xrGame/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1378,11 +1378,22 @@ void CActor::renderable_Render()
{
VERIFY(_valid(XFORM()));
inherited::renderable_Render();
if (1 /*!HUDview()*/)
{

if ((cam_active == eacFirstEye && // first eye cam
GlobalEnv.Render->get_generation() == GlobalEnv.Render->GENERATION_R2 && // R2
GlobalEnv.Render->active_phase() == 1) // shadow map rendering on R2
||
!(IsFocused() && cam_active == eacFirstEye &&
(!m_holder || (m_holder && m_holder->allowWeapon() && m_holder->HUDView())))
)
CInventoryOwner::renderable_Render();
}
VERIFY(_valid(XFORM()));


//if (1 /*!HUDview()*/)
//{
// CInventoryOwner::renderable_Render();
//}
//VERIFY(_valid(XFORM()));
}

BOOL CActor::renderable_ShadowGenerate()
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ class CActor : public CEntityAlive,
}
IC CCameraBase* cam_Active() { return cameras[cam_active]; }
IC CCameraBase* cam_FirstEye() { return cameras[eacFirstEye]; }

EActorCameras active_cam() const { return cam_active; } // KD: we need to know which cam is active outside actor methods

protected:
virtual void cam_Set(EActorCameras style);
void cam_Update(float dt, float fFOV);
Expand Down
17 changes: 17 additions & 0 deletions src/xrGame/HUDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,23 @@ void CHUDManager::Render_Last()
GlobalEnv.Render->set_HUD(FALSE);
}

void CHUDManager::Render_Actor_Shadow() // added by KD
{
if (pUIGame == nullptr) return;

auto object = g_pGameLevel->CurrentViewEntity();
if (object == nullptr) return;

auto actor = smart_cast<CActor*>(object);
if (!actor) return;

// KD: we need to render actor shadow only in first eye cam mode because
// in other modes actor model already in scene graph and renders well
if (actor->active_cam() != eacFirstEye) return;
GlobalEnv.Render->set_Object(object->H_Root());
object->renderable_Render();
}

#include "player_hud.h"
bool CHUDManager::RenderActiveItemUIQuery()
{
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/HUDManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class CHUDManager : public CCustomHUD
virtual void Render_Last();
virtual void OnFrame();

void Render_Actor_Shadow() override; // added by KD

virtual void RenderUI();

//. CUI* GetUI (){return pUI;}
Expand Down
45 changes: 28 additions & 17 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,11 @@ void CWeapon::Load(LPCSTR section)

Fvector def_dof;
def_dof.set(-1, -1, -1);
// m_zoom_params.m_ZoomDof = READ_IF_EXISTS(pSettings, r_fvector3, section, "zoom_dof",
// Fvector().set(-1,-1,-1));
// m_zoom_params.m_bZoomDofEnabled = !def_dof.similar(m_zoom_params.m_ZoomDof);
m_zoom_params.m_ZoomDof = READ_IF_EXISTS(pSettings, r_fvector3, section, "zoom_dof",Fvector().set(-1, -1, -1));
m_zoom_params.m_bZoomDofEnabled = !def_dof.similar(m_zoom_params.m_ZoomDof);

// m_zoom_params.m_ReloadDof = READ_IF_EXISTS(pSettings, r_fvector4, section, "reload_dof",
// Fvector4().set(-1,-1,-1,-1));
m_zoom_params.m_ReloadDof = READ_IF_EXISTS(pSettings, r_fvector4, section, "reload_dof",Fvector4().set(-1, -1, -1, -1));
m_zoom_params.m_ReloadEmptyDof = READ_IF_EXISTS(pSettings, r_fvector4, section, "reload_empty_dof", Fvector4().set(-1, -1, -1, -1));

m_bHasTracers = !!READ_IF_EXISTS(pSettings, r_bool, section, "tracers", true);
m_u8TracerColorID = READ_IF_EXISTS(pSettings, r_u8, section, "tracers_color_ID", u8(-1));
Expand Down Expand Up @@ -1340,8 +1339,8 @@ void CWeapon::OnZoomIn()

EnableHudInertion(FALSE);

// if(m_zoom_params.m_bZoomDofEnabled && !IsScopeAttached())
// GamePersistent().SetEffectorDOF (m_zoom_params.m_ZoomDof);
if (m_zoom_params.m_bZoomDofEnabled && !IsScopeAttached())
GamePersistent().SetEffectorDOF(m_zoom_params.m_ZoomDof);

if (GetHUDmode())
GamePersistent().SetPickableEffectorDOF(true);
Expand Down Expand Up @@ -1370,7 +1369,7 @@ void CWeapon::OnZoomOut()
m_zoom_params.m_fCurrentZoomFactor = g_fov;
EnableHudInertion(TRUE);

// GamePersistent().RestoreEffectorDOF ();
GamePersistent().RestoreEffectorDOF();

if (GetHUDmode())
GamePersistent().SetPickableEffectorDOF(false);
Expand Down Expand Up @@ -1827,15 +1826,27 @@ void CWeapon::OnStateSwitch(u32 S, u32 oldState)
inherited::OnStateSwitch(S, oldState);
m_BriefInfo_CalcFrame = 0;

// if(GetState()==eReload)
//{
// if(H_Parent()==Level().CurrentEntity() && !fsimilar(m_zoom_params.m_ReloadDof.w,-1.0f))
// {
// CActor* current_actor = smart_cast<CActor*>(H_Parent());
// if (current_actor)
// current_actor->Cameras().AddCamEffector(new CEffectorDOF(m_zoom_params.m_ReloadDof) );
// }
//}
if (GetState() == eReload)
{
if (iAmmoElapsed == 0)
{
if (H_Parent() == Level().CurrentEntity() && !fsimilar(m_zoom_params.m_ReloadEmptyDof.w, -1.0f))
{
CActor* current_actor = smart_cast<CActor*>(H_Parent());
if (current_actor)
current_actor->Cameras().AddCamEffector(new CEffectorDOF(m_zoom_params.m_ReloadEmptyDof));
}
}
else
{
if (H_Parent() == Level().CurrentEntity() && !fsimilar(m_zoom_params.m_ReloadDof.w, -1.0f))
{
CActor* current_actor = smart_cast<CActor*>(H_Parent());
if (current_actor)
current_actor->Cameras().AddCamEffector(new CEffectorDOF(m_zoom_params.m_ReloadDof));
}
}
}
}

void CWeapon::OnAnimationEnd(u32 state) { inherited::OnAnimationEnd(state); }
Expand Down
7 changes: 4 additions & 3 deletions src/xrGame/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class CWeapon : public CHudItemObject, public CShootingObject
{
bool m_bZoomEnabled; //разрешение режима приближения
bool m_bHideCrosshairInZoom;
// bool m_bZoomDofEnabled;
bool m_bZoomDofEnabled;

bool m_bIsZoomModeNow; //когда режим приближения включен
float m_fCurrentZoomFactor; //текущий фактор приближения
Expand All @@ -201,8 +201,9 @@ class CWeapon : public CHudItemObject, public CShootingObject

float m_fZoomRotationFactor;

// Fvector m_ZoomDof;
// Fvector4 m_ReloadDof;
Fvector m_ZoomDof;
Fvector4 m_ReloadDof;
Fvector4 m_ReloadEmptyDof;
bool m_bUseDynamicZoom;
shared_str m_sUseZoomPostprocess;
shared_str m_sUseBinocularVision;
Expand Down
15 changes: 15 additions & 0 deletions src/xrGame/script_game_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,18 @@ LPCSTR CScriptGameObject::get_smart_cover_description() const

void CScriptGameObject::set_visual_name(LPCSTR visual) { object().cNameVisual_set(visual); }
LPCSTR CScriptGameObject::get_visual_name() const { return object().cNameVisual().c_str(); }

bool CScriptGameObject::IsActorOutdoors() const
{
// Check to make sure all the params are available (we're in game and such).
if (!g_pGameLevel)
return false;

auto e = g_pGameLevel->CurrentViewEntity();
if (!e || !e->renderable_ROS())
return false;

// Now do the real check! This is a copy out of another section of code that is also hard coded.
// I don't know what the proper limit for this is supposed to be, but this seems good enough.
return e->renderable_ROS()->get_luminocity_hemi() > 0.05f;
}
1 change: 1 addition & 0 deletions src/xrGame/script_game_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ class CScriptGameObject
bool isTorch() const;
bool isWeaponGL() const;
bool isInventoryBox() const;
bool IsActorOutdoors() const;
//end AVO

doors::door* m_door;
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/script_game_object_script3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ class_<CScriptGameObject>& script_register_game_object2(class_<CScriptGameObject
.def("start_particles", &CScriptGameObject::start_particles)
.def("stop_particles", &CScriptGameObject::stop_particles)

//AVO: functions for object testing
//AVO: additional functions
.def("is_actor_outdoors", &CScriptGameObject::IsActorOutdoors)
.def("is_game_object", &CScriptGameObject::isGameObject)
//.def("is_car", &CScriptGameObject::isCar)
.def("is_helicopter", &CScriptGameObject::isHeli)
Expand Down

0 comments on commit 044d383

Please sign in to comment.