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
1919float psCamInert = 0 .f;
2020float psCamSlideInert = 0 .25f ;
@@ -63,8 +63,7 @@ CCameraManager::~CCameraManager()
6363CEffectorCam* 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()
9695void 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)
114112ECamEffectorType 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()
126122EEffectorPPType 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)
145139void 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
160152void 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
168159void 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
223213bool 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-
308289void CCameraManager::ApplyDevice (float _viewport_near)
309290{
310291 // Device params
0 commit comments