diff --git a/openVulkanoCpp/ExampleApps/CubesExampleApp.cpp b/openVulkanoCpp/ExampleApps/CubesExampleApp.cpp index 41de265..204a3ce 100644 --- a/openVulkanoCpp/ExampleApps/CubesExampleApp.cpp +++ b/openVulkanoCpp/ExampleApps/CubesExampleApp.cpp @@ -12,6 +12,10 @@ #include #include +#pragma clang diagnostic push +#pragma ide diagnostic ignored "cert-msc50-cpp" +#pragma ide diagnostic ignored "cppcoreguidelines-narrowing-conversions" + using namespace openVulkanoCpp::Scene; using namespace openVulkanoCpp::Input; @@ -23,8 +27,8 @@ class CubesExampleAppImpl final : public CubesExampleApp PerspectiveCamera cam; Material mat; Shader shader; - std::vector drawablesPool; - std::vector nodesPool; + std::vector drawablesPool; + std::vector nodesPool; InputAction* actionForward; InputAction* actionSide; @@ -38,7 +42,7 @@ public: void Init() override { - std::srand(1); + std::srand(1); // Fix seed for random numbers scene.Init(); cam.Init(70, 16, 9, 0.1f, 100); scene.SetCamera(&cam); @@ -49,18 +53,16 @@ public: { Geometry* geo = new Geometry(); geo->InitCube(std::rand() % 1000 / 1000.0f + 0.01f, std::rand() % 1000 / 1000.0f + 0.01f, std::rand() % 1000 / 1000.0f + 0.01f, glm::vec4((std::rand() % 255) / 255.0f, (std::rand() % 255) / 255.0f, (std::rand() % 255) / 255.0f, 1)); - drawablesPool[i] = new Drawable(); - drawablesPool[i]->Init(geo, &mat); + drawablesPool[i].Init(geo, &mat); } nodesPool.resize(OBJECTS); for(int i = 0; i < OBJECTS; i++) { - nodesPool[i] = new Node(); - nodesPool[i]->Init(); - scene.GetRoot()->AddChild(nodesPool[i]); - if (i < DYNAMIC) nodesPool[i]->SetUpdateFrequency(UpdateFrequency::Always); - nodesPool[i]->AddDrawable(drawablesPool[std::rand() % GEOS]); - nodesPool[i]->SetMatrix(glm::translate(glm::mat4x4(1), glm::vec3((std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5))); + nodesPool[i].Init(); + scene.GetRoot()->AddChild(&nodesPool[i]); + if (i < DYNAMIC) nodesPool[i].SetUpdateFrequency(UpdateFrequency::Always); + nodesPool[i].AddDrawable(&drawablesPool[std::rand() % GEOS]); + nodesPool[i].SetMatrix(glm::translate(glm::mat4x4(1), glm::vec3((std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5))); } scene.shader = &shader; @@ -92,7 +94,7 @@ public: { for(int i = 0; i < DYNAMIC; i++) { - nodesPool[i]->SetMatrix(glm::translate(glm::mat4x4(1), glm::vec3((std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5))); + nodesPool[i].SetMatrix(glm::translate(glm::mat4x4(1), glm::vec3((std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5, (std::rand() % 10000) / 1000.0f - 5))); } auto input = InputManager::GetInstace(); @@ -124,3 +126,6 @@ std::unique_ptr CubesExampleApp::Create() { return std::make_unique(); } + +#pragma clang diagnostic pop +#pragma clang diagnostic pop \ No newline at end of file diff --git a/openVulkanoCpp/Scene/Drawable.cpp b/openVulkanoCpp/Scene/Drawable.cpp index 5c9d111..d612942 100644 --- a/openVulkanoCpp/Scene/Drawable.cpp +++ b/openVulkanoCpp/Scene/Drawable.cpp @@ -26,8 +26,8 @@ namespace openVulkanoCpp Utils::Remove(nodes, node); if (nodes.empty()) { - scene = nullptr; scene->RemoveDrawable(this); + scene = nullptr; } } } diff --git a/openVulkanoCpp/main.cpp b/openVulkanoCpp/main.cpp index 3da0eb9..26965bd 100644 --- a/openVulkanoCpp/main.cpp +++ b/openVulkanoCpp/main.cpp @@ -11,7 +11,7 @@ int main(int argc, char** argv) { const auto cubesApp = CubesExampleApp::Create(); - int threads = 2; + int threads = 4; openVulkanoCpp::EngineConfiguration::GetEngineConfiguration()->SetNumThreads(threads); openVulkanoCpp::IGraphicsAppManager* manager = new openVulkanoCpp::GraphicsAppManager(cubesApp.get()); manager->Run();