2
2
//
3
3
// ////////////////////////////////////////////////////////////////////
4
4
5
- #include " stdafx.h"
6
5
#include " IGame_Level.h"
7
6
#include " IGame_Persistent.h"
7
+ #include " stdafx.h"
8
8
9
- #include " Environment.h"
10
9
#include " CameraBase.h"
11
10
#include " CameraManager.h"
12
11
#include " Effector.h"
13
12
#include " EffectorPP.h"
13
+ #include " Environment.h"
14
14
15
- #include " x_ray.h"
16
15
#include " GameFont.h"
17
16
#include " Render.h"
17
+ #include " x_ray.h"
18
18
19
19
float psCamInert = 0 .f;
20
20
float psCamSlideInert = 0 .25f ;
@@ -63,8 +63,7 @@ CCameraManager::~CCameraManager()
63
63
CEffectorCam* CCameraManager::GetCamEffector (ECamEffectorType type)
64
64
{
65
65
for (EffectorCamIt it = m_EffectorsCam.begin (); it != m_EffectorsCam.end (); it++)
66
- if ((*it)->eType == type)
67
- {
66
+ if ((*it)->eType == type) {
68
67
return *it;
69
68
}
70
69
return 0 ;
@@ -96,8 +95,7 @@ void CCameraManager::UpdateDeffered()
96
95
void CCameraManager::RemoveCamEffector (ECamEffectorType type)
97
96
{
98
97
for (EffectorCamIt it = m_EffectorsCam.begin (); it != m_EffectorsCam.end (); it++)
99
- if ((*it)->eType == type)
100
- {
98
+ if ((*it)->eType == type) {
101
99
OnEffectorReleased (*it);
102
100
m_EffectorsCam.erase (it);
103
101
return ;
@@ -114,9 +112,7 @@ CEffectorPP* CCameraManager::GetPPEffector(EEffectorPPType type)
114
112
ECamEffectorType CCameraManager::RequestCamEffectorId ()
115
113
{
116
114
ECamEffectorType index = (ECamEffectorType)effCustomEffectorStartID;
117
- for (;
118
- GetCamEffector (index);
119
- index = (ECamEffectorType)(index + 1 ))
115
+ for (; GetCamEffector (index); index = (ECamEffectorType)(index + 1 ))
120
116
{
121
117
;
122
118
}
@@ -126,9 +122,7 @@ ECamEffectorType CCameraManager::RequestCamEffectorId()
126
122
EEffectorPPType CCameraManager::RequestPPEffectorId ()
127
123
{
128
124
EEffectorPPType index = (EEffectorPPType)effCustomEffectorStartID;
129
- for (;
130
- GetPPEffector (index);
131
- index = (EEffectorPPType)(index + 1 ))
125
+ for (; GetPPEffector (index); index = (EEffectorPPType)(index + 1 ))
132
126
{
133
127
;
134
128
}
@@ -145,10 +139,8 @@ CEffectorPP* CCameraManager::AddPPEffector(CEffectorPP* ef)
145
139
void CCameraManager::RemovePPEffector (EEffectorPPType type)
146
140
{
147
141
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 ()) {
152
144
OnEffectorReleased (*it);
153
145
// xr_delete (*it);
154
146
}
@@ -159,33 +151,32 @@ void CCameraManager::RemovePPEffector(EEffectorPPType type)
159
151
160
152
void CCameraManager::OnEffectorReleased (SBaseEffector* e)
161
153
{
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 ();
164
155
165
156
xr_delete (e);
166
157
}
167
158
168
159
void CCameraManager::UpdateFromCamera (const CCameraBase* C)
169
160
{
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 );
171
163
}
172
164
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)
174
167
{
175
168
#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 !!!
179
171
dbg_upd_frame = Device.dwFrame ;
180
172
}
181
- #endif // DEBUG
173
+ #endif // DEBUG
182
174
// camera
183
- if (flags& CCameraBase::flPositionRigid)
175
+ if (flags & CCameraBase::flPositionRigid)
184
176
m_cam_info.p .set (P);
185
177
else
186
178
m_cam_info.p .inertion (P, psCamInert);
187
- if (flags&CCameraBase::flDirectionRigid)
188
- {
179
+ if (flags & CCameraBase::flDirectionRigid) {
189
180
m_cam_info.d .set (D);
190
181
m_cam_info.n .set (N);
191
182
}
@@ -205,32 +196,29 @@ void CCameraManager::Update(const Fvector& P, const Fvector& D, const Fvector& N
205
196
float src = 10 * Device.fTimeDelta ;
206
197
clamp (src, 0 .f , 1 .f );
207
198
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;
211
202
m_cam_info.dont_apply = false ;
212
203
213
204
UpdateCamEffectors ();
214
205
215
206
UpdatePPEffectors ();
216
207
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);
219
209
220
210
UpdateDeffered ();
221
211
}
222
212
223
213
bool CCameraManager::ProcessCameraEffector (CEffectorCam* eff)
224
214
{
225
215
bool res = false ;
226
- if (eff->Valid () && eff->ProcessCam (m_cam_info))
227
- {
216
+ if (eff->Valid () && eff->ProcessCam (m_cam_info)) {
228
217
res = true ;
229
218
}
230
219
else
231
220
{
232
- if (eff->AllowProcessingIfInvalid ())
233
- {
221
+ if (eff->AllowProcessingIfInvalid ()) {
234
222
eff->ProcessIfInvalid (m_cam_info);
235
223
res = true ;
236
224
}
@@ -261,25 +249,21 @@ void CCameraManager::UpdatePPEffectors()
261
249
pp_affected.validate (" before applying pp" );
262
250
263
251
int _count = 0 ;
264
- if (m_EffectorsPP.size ())
265
- {
252
+ if (m_EffectorsPP.size ()) {
266
253
bool b = false ;
267
254
pp_affected = pp_identity;
268
255
for (int i = m_EffectorsPP.size () - 1 ; i >= 0 ; --i)
269
256
{
270
257
CEffectorPP* eff = m_EffectorsPP[i];
271
258
SPPInfo l_PPInf = pp_zero;
272
- if (eff->Valid () && eff->Process (l_PPInf))
273
- {
259
+ if (eff->Valid () && eff->Process (l_PPInf)) {
274
260
++_count;
275
- if (!b)
276
- {
261
+ if (!b) {
277
262
pp_affected.add (l_PPInf);
278
263
pp_affected.sub (pp_identity);
279
264
pp_affected.validate (" in cycle" );
280
265
}
281
- if (!eff->bOverlap )
282
- {
266
+ if (!eff->bOverlap ) {
283
267
b = true ;
284
268
pp_affected = l_PPInf;
285
269
}
@@ -297,14 +281,11 @@ void CCameraManager::UpdatePPEffectors()
297
281
pp_affected = pp_identity;
298
282
}
299
283
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 ;
302
285
303
286
pp_affected.validate (" after applying pp" );
304
287
}
305
288
306
-
307
-
308
289
void CCameraManager::ApplyDevice (float _viewport_near)
309
290
{
310
291
// Device params
0 commit comments