@@ -46,11 +46,7 @@ Cluster::~Cluster()
4646int Cluster::run (int argc, char * argv[])
4747{
4848 config->readArgv (argc, argv);
49- return Application::run (argc, argv, config->renderer , BGFX_PCI_ID_NONE, 0 , &callbacks, nullptr );
50- }
5149
52- void Cluster::initialize (int _argc, char * _argv[])
53- {
5450 if (config->writeLog )
5551 {
5652 // _mt (thread safe) necessary because of flush_every
@@ -64,6 +60,11 @@ void Cluster::initialize(int _argc, char* _argv[])
6460 Log->set_level (spdlog::level::trace);
6561 spdlog::flush_every (std::chrono::seconds (2 ));
6662
63+ return Application::run (argc, argv, config->renderer , BGFX_PCI_ID_NONE, 0 , &callbacks, nullptr );
64+ }
65+
66+ void Cluster::initialize (int _argc, char * _argv[])
67+ {
6768 if (!ForwardRenderer::supported ())
6869 {
6970 Log->error (" Forward renderer not supported on this hardware" );
@@ -102,24 +103,25 @@ void Cluster::initialize(int _argc, char* _argv[])
102103 ui->initialize ();
103104
104105 Scene::init ();
105- // TODO multithreaded
106- // textures still have to be loaded from main thread
107- // keep list and load one texture every X frames
106+
108107 if (!scene->load (config->sceneFile ))
109108 {
110109 Log->error (" Loading scene model failed" );
111110 close ();
112111 return ;
113112 }
114113
115- // Sponza
116- // debug camera + lights
117- scene->camera .lookAt ({ -7 .0f , 2 .0f , 0 .0f }, scene->center , glm::vec3 (0 .0f , 1 .0f , 0 .0f ));
118- scene->pointLights .lights = { // pos, power
119- { { -5 .0f , 0 .3f , 0 .0f }, { 100 .0f , 100 .0f , 100 .0f } },
120- { { 0 .0f , 0 .3f , 0 .0f }, { 100 .0f , 100 .0f , 100 .0f } },
121- { { 5 .0f , 0 .3f , 0 .0f }, { 100 .0f , 100 .0f , 100 .0f } }
122- };
114+ // Sponza debug camera + lights
115+ if (!config->customScene )
116+ {
117+ scene->camera .lookAt ({ -7 .0f , 2 .0f , 0 .0f }, scene->center , glm::vec3 (0 .0f , 1 .0f , 0 .0f ));
118+ scene->pointLights .lights = { // pos, power
119+ { { -5 .0f , 0 .3f , 0 .0f }, { 100 .0f , 100 .0f , 100 .0f } },
120+ { { 0 .0f , 0 .3f , 0 .0f }, { 100 .0f , 100 .0f , 100 .0f } },
121+ { { 5 .0f , 0 .3f , 0 .0f }, { 100 .0f , 100 .0f , 100 .0f } }
122+ };
123+ }
124+
123125 scene->pointLights .update ();
124126 config->lights = (int )scene->pointLights .lights .size ();
125127
@@ -190,7 +192,7 @@ void Cluster::onScroll(double xoffset, double yoffset)
190192void Cluster::update (float dt)
191193{
192194 float velocity = scene->diagonal / 5 .0f ; // m/s
193- // TODO faster with Shift
195+ // TODO move faster with Shift
194196 // need to cache mods & GLFW_MOD_SHIFT in onKey
195197 if (isKeyDown (GLFW_KEY_W))
196198 scene->camera .move (scene->camera .forward () * velocity * dt);
@@ -226,11 +228,6 @@ void Cluster::update(float dt)
226228
227229int Cluster::shutdown ()
228230{
229- // TODO
230- // not all resources are freed
231- // e.g. Renderer::blitSampler has count 3 on shutdown
232- // might be because of threaded renderer or command buffer taking a while
233-
234231 ui->shutdown ();
235232 renderer->shutdown ();
236233 scene->clear ();
@@ -404,9 +401,12 @@ void Cluster::generateLights(unsigned int count)
404401
405402 for (size_t i = keep; i < count; i++)
406403 {
407- glm::vec3 position = glm::vec3 (dist (mt), dist (mt), dist (mt)) * scale - (scale * 0 .5f );
408- // position += scene->center; // not Sponza
409- position.y = glm::abs (position.y ); // Sponza
404+ glm::vec3 position = scene->center ;
405+ position += glm::vec3 (dist (mt), dist (mt), dist (mt)) * scale - (scale * 0 .5f );
406+
407+ if (!config->customScene ) // Sponza, no lights under the floor
408+ position.y = glm::abs (position.y );
409+
410410 glm::vec3 color = glm::vec3 (dist (mt), dist (mt), dist (mt));
411411 glm::vec3 power = color * (dist (mt) * (POWER_MAX - POWER_MIN) + POWER_MIN);
412412 lights[i] = { position, power };
0 commit comments