Ticket #1886: CGameView_without_CJSObject_1.diff
File CGameView_without_CJSObject_1.diff, 3.9 KB (added by , 11 years ago) |
---|
-
GameView.cpp
54 54 #include "ps/World.h" 55 55 #include "renderer/Renderer.h" 56 56 #include "renderer/WaterManager.h" 57 #include "scripting/ScriptableObject.h"58 57 #include "simulation2/Simulation2.h" 59 58 #include "simulation2/components/ICmpPosition.h" 60 59 #include "simulation2/components/ICmpRangeManager.h" … … 148 147 float m_Smoothness; 149 148 }; 150 149 151 class CGameViewImpl : public CJSObject<CGameViewImpl>150 class CGameViewImpl 152 151 { 153 152 NONCOPYABLE(CGameViewImpl); 154 153 public: … … 160 159 TerritoryTexture(*game->GetSimulation2()), 161 160 ViewCamera(), 162 161 CullCamera(), 163 LockCullCamera(false),164 ConstrainCamera(true),165 Culling(true),166 162 FollowEntity(INVALID_ENTITY), 167 163 FollowFirstPerson(false), 168 164 … … 234 230 * 235 231 * Exposed to JS as gameView.lockCullCamera 236 232 */ 237 boolLockCullCamera;233 static bool m_LockCullCamera; 238 234 239 235 /** 240 236 * When @c true, culling is enabled so that only models that have a chance of … … 243 239 * 244 240 * Exposed to JS as gameView.culling 245 241 */ 246 boolCulling;242 static bool m_Culling; 247 243 248 244 /** 249 245 * Whether the camera movement should be constrained by min/max limits 250 246 * and terrain avoidance. 251 247 */ 252 boolConstrainCamera;248 static bool m_ConstrainCamera; 253 249 254 250 /** 255 251 * Cache global lighting environment. This is used to check whether the … … 309 305 CSmoothedValue RotateX; // inclination around x axis (relative to camera) 310 306 CSmoothedValue RotateY; // rotation around y (vertical) axis 311 307 312 static void ScriptingInit(); 308 static void RegisterScriptFunctions(ScriptInterface& scriptInterface); 309 static void SetCulling(ScriptInterface* UNUSED(ScriptInterface), void* UNUSED(cbdata), bool Enabled) { CGameViewImpl::m_Culling = Enabled; } 310 static void LockCullCamera(ScriptInterface* UNUSED(ScriptInterface), void* UNUSED(cbdata), bool Enabled) { CGameViewImpl::m_LockCullCamera = Enabled; } 311 static void ConstrainCamera(ScriptInterface* UNUSED(ScriptInterface), void* UNUSED(cbdata), bool Enabled) { CGameViewImpl::m_ConstrainCamera = Enabled; } 312 313 313 }; 314 314 315 bool CGameViewImpl::m_LockCullCamera = false; 316 bool CGameViewImpl::m_ConstrainCamera = true; 317 bool CGameViewImpl::m_Culling = true; 318 315 319 static void SetupCameraMatrixSmooth(CGameViewImpl* m, CMatrix3D* orientation) 316 320 { 317 321 orientation->SetIdentity(); … … 372 376 return m->ObjectManager; 373 377 } 374 378 375 JSObject* CGameView::GetScript()376 {377 return m->GetScript();378 }379 //JSObject* CGameView::GetScript() 380 //{ 381 // return m->GetScript(); 382 //} 379 383 380 /*static*/ void CGameView::ScriptingInit()381 {382 return CGameViewImpl::ScriptingInit();383 }384 385 384 CCamera* CGameView::GetCamera() 386 385 { 387 386 return &m->ViewCamera; … … 402 401 return m->TerritoryTexture; 403 402 } 404 403 405 406 void CGameViewImpl::ScriptingInit() 404 void CGameViewImpl::RegisterScriptFunctions(ScriptInterface& scriptInterface) 407 405 { 408 AddProperty(L"culling", &CGameViewImpl::Culling); 409 AddProperty(L"lockCullCamera", &CGameViewImpl::LockCullCamera); 410 AddProperty(L"constrainCamera", &CGameViewImpl::ConstrainCamera); 411 412 CJSObject<CGameViewImpl>::ScriptingInit("GameView"); 406 scriptInterface.RegisterFunction<void, bool, &CGameViewImpl::SetCulling>("GameView_SetCulling"); 407 scriptInterface.RegisterFunction<void, bool, &CGameViewImpl::LockCullCamera>("GameView_LockCullCamera"); 408 scriptInterface.RegisterFunction<void, bool, &CGameViewImpl::ConstrainCamera>("GameView_ConstrainCamera"); 413 409 } 414 410 415 411 int CGameView::Initialize() … … 526 522 bounds[1].Y = waterHeight; 527 523 } 528 524 529 if (!m-> Culling || frustum.IsBoxVisible (CVector3D(0,0,0), bounds)) {525 if (!m->m_Culling || frustum.IsBoxVisible (CVector3D(0,0,0), bounds)) { 530 526 //c->Submit(patch); 531 527 532 528 // set the renderstate for this patch … … 577 573 } 578 574 } 579 575 580 m->Game->GetSimulation2()->RenderSubmit(*c, frustum, m-> Culling);576 m->Game->GetSimulation2()->RenderSubmit(*c, frustum, m->m_Culling); 581 577 } 582 578 583 579