From db3def8a9aa164dad5ec2f2a2ce3227c339eeb2d Mon Sep 17 00:00:00 2001 From: Patricio Gonzalez Vivo Date: Wed, 29 Nov 2023 07:50:34 -0500 Subject: [PATCH] add cylinder mesh --- deps/vera | 2 +- src/core/sandbox.cpp | 6 ++++-- src/main.cpp | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/deps/vera b/deps/vera index 3b00d569..1ffd929c 160000 --- a/deps/vera +++ b/deps/vera @@ -1 +1 @@ -Subproject commit 3b00d5695d16d3d71b6a3c343f0eaf2e47f3370c +Subproject commit 1ffd929cfadf7811fd397b6fd68279f6a0428427 diff --git a/src/core/sandbox.cpp b/src/core/sandbox.cpp index 43597682..3aa19b4c 100644 --- a/src/core/sandbox.cpp +++ b/src/core/sandbox.cpp @@ -1155,8 +1155,10 @@ void Sandbox::loadAssets(WatchFileList &_files) { uniforms.activeCamera->orbit(m_camera_elevation, m_camera_azimuth, m_sceneRender.getArea() * 8.5); if (lenticular.size() == 0) { - if (quilt_tile >= 0) - vera::setWindowSize(vera::getQuiltWidth()/vera::getQuiltColumns(), vera::getQuiltHeight()/vera::getQuiltRows()); + if (quilt_tile >= 0) { + vera::setWindowSize(vera::getQuiltWidth()/vera::getQuiltColumns(), + vera::getQuiltHeight()/vera::getQuiltRows()); + } else vera::setWindowSize(vera::getQuiltWidth(), vera::getQuiltHeight()); } diff --git a/src/main.cpp b/src/main.cpp index b735ed4d..b60e422e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1862,6 +1862,40 @@ void commandsInit() { return true; }, "icosphere[,]", "add icosphere mesh")); + + commands.push_back(Command("cylinder", [&](const std::string & line) { + std::vector values = vera::split(line,','); + int resolutionR = 16; + int resolutionH = 3; + int resolutionC = 1; + + if (values.size() > 1) { + resolutionR = vera::toInt(values[1]); + } + if (values.size() > 2) { + resolutionH = vera::toInt(values[2]); + } + if (values.size() > 3) { + resolutionC = vera::toInt(values[3]); + } + + sandbox.loadModel( new vera::Model("c", vera::cylinderMesh(1.0, 1.0, resolutionR, resolutionH, resolutionC, resolutionC != 0) ) ); + + #if defined(__EMSCRIPTEN__) + // Commands are parse in the main GL loop in EMSCRIPTEN, + // there is no risk to reload shaders outside main GL thread + sandbox.resetShaders(files); + #else + // Reloading shaders can't be done directly on multi-thread (event thread) + // to solve that, we trigger reloading by flagging changes on all files + // witch signal the main GL thread to reload assets + for (size_t i = 0; i < files.size(); i++) + files[i].lastChange = 0; + #endif + + return true; + }, "cylinder[,,]]", "add cylinder mesh")); + commands.push_back(Command("wait", [&](const std::string& _line){ std::vector values = vera::split(_line,','); if (values.size() == 2) {