Minor bugfix
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#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<Drawable*> drawablesPool;
|
||||
std::vector<Node*> nodesPool;
|
||||
std::vector<Drawable> drawablesPool;
|
||||
std::vector<Node> 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<openVulkanoCpp::IGraphicsApp> CubesExampleApp::Create()
|
||||
{
|
||||
return std::make_unique<CubesExampleAppImpl>();
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
#pragma clang diagnostic pop
|
||||
@@ -26,8 +26,8 @@ namespace openVulkanoCpp
|
||||
Utils::Remove(nodes, node);
|
||||
if (nodes.empty())
|
||||
{
|
||||
scene = nullptr;
|
||||
scene->RemoveDrawable(this);
|
||||
scene = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user