Skip to content

Commit eea17cc

Browse files
committed
Reformat: xrEngine
1 parent ed510c6 commit eea17cc

File tree

211 files changed

+4792
-7407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+4792
-7407
lines changed

src/xrEngine/CameraBase.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//
33
//////////////////////////////////////////////////////////////////////
44

5-
#include "stdafx.h"
65
#include "IGame_Level.h"
6+
#include "stdafx.h"
77

88
#include "CameraBase.h"
99

@@ -42,8 +42,8 @@ void CCameraBase::Load(LPCSTR section)
4242
bClampPitch = (0 != lim_pitch[0]) || (0 != lim_pitch[1]);
4343
bClampYaw = (0 != lim_yaw[0]) || (0 != lim_yaw[1]);
4444

45-
if (bClampPitch) pitch = (lim_pitch[0] + lim_pitch[1])*0.5f;
46-
if (bClampYaw) yaw = (lim_yaw[0] + lim_yaw[1])*0.5f;
45+
if (bClampPitch) pitch = (lim_pitch[0] + lim_pitch[1]) * 0.5f;
46+
if (bClampYaw) yaw = (lim_yaw[0] + lim_yaw[1]) * 0.5f;
4747
}
4848

4949
IC float AClamp(Fvector2& l, float v)
@@ -53,8 +53,7 @@ IC float AClamp(Fvector2& l, float v)
5353

5454
float CCameraBase::CheckLimYaw()
5555
{
56-
if (bClampYaw)
57-
{
56+
if (bClampYaw) {
5857
return AClamp(lim_yaw, yaw);
5958
}
6059
else
@@ -63,8 +62,7 @@ float CCameraBase::CheckLimYaw()
6362

6463
float CCameraBase::CheckLimPitch()
6564
{
66-
if (bClampYaw)
67-
{
65+
if (bClampYaw) {
6866
return AClamp(lim_pitch, pitch);
6967
}
7068
else
@@ -73,8 +71,7 @@ float CCameraBase::CheckLimPitch()
7371

7472
float CCameraBase::CheckLimRoll()
7573
{
76-
if (bClampYaw)
77-
{
74+
if (bClampYaw) {
7875
return AClamp(lim_roll, roll);
7976
}
8077
else

src/xrEngine/CameraBase.h

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,44 +44,61 @@ class ENGINE_API CCameraBase
4444
IC Fvector Right() const { return Fvector().crossproduct(vNormal, vDirection); }
4545
IC float Fov() const { return f_fov; }
4646
IC float Aspect() const { return f_aspect; }
47-
4847
int tag;
48+
4949
public:
5050
CCameraBase(IGameObject* p, u32 flags);
5151
virtual ~CCameraBase();
5252
virtual void Load(LPCSTR section);
53-
void SetParent(IGameObject* p) { parent = p; VERIFY(p); }
53+
void SetParent(IGameObject* p)
54+
{
55+
parent = p;
56+
VERIFY(p);
57+
}
5458
virtual void OnActivate(CCameraBase* old_cam) { ; }
5559
virtual void OnDeactivate() { ; }
5660
virtual void Move(int cmd, float val = 0, float factor = 1.0f) { ; }
5761
virtual void Update(Fvector& point, Fvector& noise_angle) { ; }
58-
virtual void Get(Fvector& P, Fvector& D, Fvector& N) { P.set(vPosition); D.set(vDirection); N.set(vNormal); }
59-
virtual void Set(const Fvector& P, const Fvector& D, const Fvector& N) { vPosition.set(P); vDirection.set(D); vNormal.set(N); }
60-
virtual void Set(float Y, float P, float R) { yaw = Y; pitch = P; roll = R; }
62+
virtual void Get(Fvector& P, Fvector& D, Fvector& N)
63+
{
64+
P.set(vPosition);
65+
D.set(vDirection);
66+
N.set(vNormal);
67+
}
68+
virtual void Set(const Fvector& P, const Fvector& D, const Fvector& N)
69+
{
70+
vPosition.set(P);
71+
vDirection.set(D);
72+
vNormal.set(N);
73+
}
74+
virtual void Set(float Y, float P, float R)
75+
{
76+
yaw = Y;
77+
pitch = P;
78+
roll = R;
79+
}
6180

6281
virtual float GetWorldYaw() { return 0; };
6382
virtual float GetWorldPitch() { return 0; };
64-
6583
virtual float CheckLimYaw();
6684
virtual float CheckLimPitch();
6785
virtual float CheckLimRoll();
6886
};
6987

70-
71-
template<typename T>
88+
template <typename T>
7289
IC void tviewport_size(CRenderDeviceBase& D, float _viewport_near, const T& cam_info, float& h_w, float& h_h)
7390
{
74-
h_h = _viewport_near*tan(deg2rad(cam_info.Fov()) / 2.f);
91+
h_h = _viewport_near * tan(deg2rad(cam_info.Fov()) / 2.f);
7592
VERIFY2(_valid(h_h), make_string("invalide viewporrt params fov: %f ", cam_info.Fov()));
76-
float aspect = D.fASPECT;//cam_info.Aspect();
93+
float aspect = D.fASPECT; // cam_info.Aspect();
7794
VERIFY(aspect > EPS);
7895
h_w = h_h / aspect;
7996
}
8097

81-
template<typename T>
98+
template <typename T>
8299
IC void viewport_size(float _viewport_near, const T& cam_info, float& h_w, float& h_h)
83100
{
84101
tviewport_size<T>(Device, _viewport_near, cam_info, h_w, h_h);
85102
}
86103

87-
#endif // !defined(AFX_CAMERABASE_H__B11F8AE1_1213_11D4_B4E3_4854E82A090D__INCLUDED_)
104+
#endif // !defined(AFX_CAMERABASE_H__B11F8AE1_1213_11D4_B4E3_4854E82A090D__INCLUDED_)

src/xrEngine/CameraDebug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//////////////////////////////////////////////////////////////////////
44

55
#pragma once
6-
# error using of unused old header
6+
#error using of unused old header
77

88
/*
99
#include "CameraBase.h"

src/xrEngine/CameraDefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct ENGINE_API SCamEffectorInfo
2222
bool dont_apply;
2323
bool affected_on_hud;
2424
SCamEffectorInfo();
25-
SCamEffectorInfo& operator = (const SCamEffectorInfo& other)
25+
SCamEffectorInfo& operator=(const SCamEffectorInfo& other)
2626
{
2727
p = other.p;
2828
d = other.d;

src/xrEngine/CameraManager.cpp

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
//
33
//////////////////////////////////////////////////////////////////////
44

5-
#include "stdafx.h"
65
#include "IGame_Level.h"
76
#include "IGame_Persistent.h"
7+
#include "stdafx.h"
88

9-
#include "Environment.h"
109
#include "CameraBase.h"
1110
#include "CameraManager.h"
1211
#include "Effector.h"
1312
#include "EffectorPP.h"
13+
#include "Environment.h"
1414

15-
#include "x_ray.h"
1615
#include "GameFont.h"
1716
#include "Render.h"
17+
#include "x_ray.h"
1818

1919
float psCamInert = 0.f;
2020
float psCamSlideInert = 0.25f;
@@ -63,8 +63,7 @@ CCameraManager::~CCameraManager()
6363
CEffectorCam* CCameraManager::GetCamEffector(ECamEffectorType type)
6464
{
6565
for (EffectorCamIt it = m_EffectorsCam.begin(); it != m_EffectorsCam.end(); it++)
66-
if ((*it)->eType == type)
67-
{
66+
if ((*it)->eType == type) {
6867
return *it;
6968
}
7069
return 0;
@@ -96,8 +95,7 @@ void CCameraManager::UpdateDeffered()
9695
void CCameraManager::RemoveCamEffector(ECamEffectorType type)
9796
{
9897
for (EffectorCamIt it = m_EffectorsCam.begin(); it != m_EffectorsCam.end(); it++)
99-
if ((*it)->eType == type)
100-
{
98+
if ((*it)->eType == type) {
10199
OnEffectorReleased(*it);
102100
m_EffectorsCam.erase(it);
103101
return;
@@ -114,9 +112,7 @@ CEffectorPP* CCameraManager::GetPPEffector(EEffectorPPType type)
114112
ECamEffectorType CCameraManager::RequestCamEffectorId()
115113
{
116114
ECamEffectorType index = (ECamEffectorType)effCustomEffectorStartID;
117-
for (;
118-
GetCamEffector(index);
119-
index = (ECamEffectorType)(index + 1))
115+
for (; GetCamEffector(index); index = (ECamEffectorType)(index + 1))
120116
{
121117
;
122118
}
@@ -126,9 +122,7 @@ ECamEffectorType CCameraManager::RequestCamEffectorId()
126122
EEffectorPPType CCameraManager::RequestPPEffectorId()
127123
{
128124
EEffectorPPType index = (EEffectorPPType)effCustomEffectorStartID;
129-
for (;
130-
GetPPEffector(index);
131-
index = (EEffectorPPType)(index + 1))
125+
for (; GetPPEffector(index); index = (EEffectorPPType)(index + 1))
132126
{
133127
;
134128
}
@@ -145,10 +139,8 @@ CEffectorPP* CCameraManager::AddPPEffector(CEffectorPP* ef)
145139
void CCameraManager::RemovePPEffector(EEffectorPPType type)
146140
{
147141
for (EffectorPPIt it = m_EffectorsPP.begin(); it != m_EffectorsPP.end(); it++)
148-
if ((*it)->Type() == type)
149-
{
150-
if ((*it)->FreeOnRemove())
151-
{
142+
if ((*it)->Type() == type) {
143+
if ((*it)->FreeOnRemove()) {
152144
OnEffectorReleased(*it);
153145
// xr_delete (*it);
154146
}
@@ -159,33 +151,32 @@ void CCameraManager::RemovePPEffector(EEffectorPPType type)
159151

160152
void CCameraManager::OnEffectorReleased(SBaseEffector* e)
161153
{
162-
if (!e->m_on_b_remove_callback.empty())
163-
e->m_on_b_remove_callback();
154+
if (!e->m_on_b_remove_callback.empty()) e->m_on_b_remove_callback();
164155

165156
xr_delete(e);
166157
}
167158

168159
void CCameraManager::UpdateFromCamera(const CCameraBase* C)
169160
{
170-
Update(C->vPosition, C->vDirection, C->vNormal, C->f_fov, C->f_aspect, g_pGamePersistent->Environment().CurrentEnv->far_plane, C->m_Flags.flags);
161+
Update(C->vPosition, C->vDirection, C->vNormal, C->f_fov, C->f_aspect,
162+
g_pGamePersistent->Environment().CurrentEnv->far_plane, C->m_Flags.flags);
171163
}
172164

173-
void CCameraManager::Update(const Fvector& P, const Fvector& D, const Fvector& N, float fFOV_Dest, float fASPECT_Dest, float fFAR_Dest, u32 flags)
165+
void CCameraManager::Update(const Fvector& P, const Fvector& D, const Fvector& N, float fFOV_Dest, float fASPECT_Dest,
166+
float fFAR_Dest, u32 flags)
174167
{
175168
#ifdef DEBUG
176-
if (!Device.Paused())
177-
{
178-
VERIFY(dbg_upd_frame != Device.dwFrame);// already updated !!!
169+
if (!Device.Paused()) {
170+
VERIFY(dbg_upd_frame != Device.dwFrame); // already updated !!!
179171
dbg_upd_frame = Device.dwFrame;
180172
}
181-
#endif // DEBUG
173+
#endif // DEBUG
182174
// camera
183-
if (flags&CCameraBase::flPositionRigid)
175+
if (flags & CCameraBase::flPositionRigid)
184176
m_cam_info.p.set(P);
185177
else
186178
m_cam_info.p.inertion(P, psCamInert);
187-
if (flags&CCameraBase::flDirectionRigid)
188-
{
179+
if (flags & CCameraBase::flDirectionRigid) {
189180
m_cam_info.d.set(D);
190181
m_cam_info.n.set(N);
191182
}
@@ -205,32 +196,29 @@ void CCameraManager::Update(const Fvector& P, const Fvector& D, const Fvector& N
205196
float src = 10 * Device.fTimeDelta;
206197
clamp(src, 0.f, 1.f);
207198
float dst = 1 - src;
208-
m_cam_info.fFov = m_cam_info.fFov*dst + fFOV_Dest*src;
209-
m_cam_info.fFar = m_cam_info.fFar*dst + fFAR_Dest*src;
210-
m_cam_info.fAspect = m_cam_info.fAspect*dst + (fASPECT_Dest*aspect)*src;
199+
m_cam_info.fFov = m_cam_info.fFov * dst + fFOV_Dest * src;
200+
m_cam_info.fFar = m_cam_info.fFar * dst + fFAR_Dest * src;
201+
m_cam_info.fAspect = m_cam_info.fAspect * dst + (fASPECT_Dest * aspect) * src;
211202
m_cam_info.dont_apply = false;
212203

213204
UpdateCamEffectors();
214205

215206
UpdatePPEffectors();
216207

217-
if (false == m_cam_info.dont_apply && m_bAutoApply)
218-
ApplyDevice(VIEWPORT_NEAR);
208+
if (false == m_cam_info.dont_apply && m_bAutoApply) ApplyDevice(VIEWPORT_NEAR);
219209

220210
UpdateDeffered();
221211
}
222212

223213
bool CCameraManager::ProcessCameraEffector(CEffectorCam* eff)
224214
{
225215
bool res = false;
226-
if (eff->Valid() && eff->ProcessCam(m_cam_info))
227-
{
216+
if (eff->Valid() && eff->ProcessCam(m_cam_info)) {
228217
res = true;
229218
}
230219
else
231220
{
232-
if (eff->AllowProcessingIfInvalid())
233-
{
221+
if (eff->AllowProcessingIfInvalid()) {
234222
eff->ProcessIfInvalid(m_cam_info);
235223
res = true;
236224
}
@@ -261,25 +249,21 @@ void CCameraManager::UpdatePPEffectors()
261249
pp_affected.validate("before applying pp");
262250

263251
int _count = 0;
264-
if (m_EffectorsPP.size())
265-
{
252+
if (m_EffectorsPP.size()) {
266253
bool b = false;
267254
pp_affected = pp_identity;
268255
for (int i = m_EffectorsPP.size() - 1; i >= 0; --i)
269256
{
270257
CEffectorPP* eff = m_EffectorsPP[i];
271258
SPPInfo l_PPInf = pp_zero;
272-
if (eff->Valid() && eff->Process(l_PPInf))
273-
{
259+
if (eff->Valid() && eff->Process(l_PPInf)) {
274260
++_count;
275-
if (!b)
276-
{
261+
if (!b) {
277262
pp_affected.add(l_PPInf);
278263
pp_affected.sub(pp_identity);
279264
pp_affected.validate("in cycle");
280265
}
281-
if (!eff->bOverlap)
282-
{
266+
if (!eff->bOverlap) {
283267
b = true;
284268
pp_affected = l_PPInf;
285269
}
@@ -297,14 +281,11 @@ void CCameraManager::UpdatePPEffectors()
297281
pp_affected = pp_identity;
298282
}
299283

300-
if (!positive(pp_affected.noise.grain))
301-
pp_affected.noise.grain = pp_identity.noise.grain;
284+
if (!positive(pp_affected.noise.grain)) pp_affected.noise.grain = pp_identity.noise.grain;
302285

303286
pp_affected.validate("after applying pp");
304287
}
305288

306-
307-
308289
void CCameraManager::ApplyDevice(float _viewport_near)
309290
{
310291
// Device params

src/xrEngine/CameraManager.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ENGINE_API CCameraManager
2929
virtual void UpdatePPEffectors();
3030
virtual bool ProcessCameraEffector(CEffectorCam* eff);
3131
void OnEffectorReleased(SBaseEffector* e);
32+
3233
public:
3334
#ifdef DEBUG
3435
u32 dbg_upd_frame;
@@ -54,9 +55,9 @@ class ENGINE_API CCameraManager
5455
IC Fvector Right() const { return m_cam_info.r; }
5556
IC float Fov() const { return m_cam_info.fFov; }
5657
IC float Aspect() const { return m_cam_info.fAspect; }
57-
5858
IC void camera_Matrix(Fmatrix& M) { M.set(m_cam_info.r, m_cam_info.n, m_cam_info.d, m_cam_info.p); }
59-
void Update(const Fvector& P, const Fvector& D, const Fvector& N, float fFOV_Dest, float fASPECT_Dest, float fFAR_Dest, u32 flags);
59+
void Update(const Fvector& P, const Fvector& D, const Fvector& N, float fFOV_Dest, float fASPECT_Dest,
60+
float fFAR_Dest, u32 flags);
6061
void UpdateFromCamera(const CCameraBase* C);
6162

6263
void ApplyDevice(float _viewport_near);

src/xrEngine/CustomHUD.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#include "stdafx.h"
21
#include "CustomHUD.h"
2+
#include "stdafx.h"
33

4-
Flags32 psHUD_Flags = {HUD_CROSSHAIR_RT | HUD_WEAPON_RT | HUD_WEAPON_RT2 | HUD_CROSSHAIR_DYNAMIC | HUD_CROSSHAIR_RT2 | HUD_DRAW_RT | HUD_DRAW_RT2};
4+
Flags32 psHUD_Flags = {HUD_CROSSHAIR_RT | HUD_WEAPON_RT | HUD_WEAPON_RT2 | HUD_CROSSHAIR_DYNAMIC | HUD_CROSSHAIR_RT2 |
5+
HUD_DRAW_RT | HUD_DRAW_RT2};
56

67
ENGINE_API CCustomHUD* g_hud = NULL;
78

@@ -16,4 +17,3 @@ CCustomHUD::~CCustomHUD()
1617
g_hud = NULL;
1718
Device.seqResolutionChanged.Remove(this);
1819
}
19-

0 commit comments

Comments
 (0)