diff --git a/3rdparty/longeronpp b/3rdparty/longeronpp index 60daa614..1f8b0715 160000 --- a/3rdparty/longeronpp +++ b/3rdparty/longeronpp @@ -1 +1 @@ -Subproject commit 60daa614f266538816641332040df6f11c60ac2c +Subproject commit 1f8b0715fd4e7bb36811acd2636539c9f9e43f88 diff --git a/src/adera/SysExhaustPlume.h b/src/adera/SysExhaustPlume.h index 8da77974..5f6aeeac 100644 --- a/src/adera/SysExhaustPlume.h +++ b/src/adera/SysExhaustPlume.h @@ -25,8 +25,6 @@ #pragma once #include // for PlumeEffectData -#include // for ActiveEnt - #include // for null, null_t namespace osp { namespace active { class ActiveScene; } } @@ -36,7 +34,6 @@ namespace adera::active struct ACompExhaustPlume { - osp::active::ActiveEnt m_parentMCompRocket{entt::null}; PlumeEffectData m_effect; float m_time{0.0f}; diff --git a/src/test_application/VehicleBuilder.cpp b/src/adera/activescene/VehicleBuilder.cpp similarity index 98% rename from src/test_application/VehicleBuilder.cpp rename to src/adera/activescene/VehicleBuilder.cpp index 709926f9..62e6bbbe 100644 --- a/src/test_application/VehicleBuilder.cpp +++ b/src/adera/activescene/VehicleBuilder.cpp @@ -24,11 +24,11 @@ */ #include "VehicleBuilder.h" -#include -#include -#include +#include +#include +#include -namespace testapp +namespace adera { using osp::restypes::gc_importer; diff --git a/src/test_application/VehicleBuilder.h b/src/adera/activescene/VehicleBuilder.h similarity index 98% rename from src/test_application/VehicleBuilder.h rename to src/adera/activescene/VehicleBuilder.h index ec9774ea..a3cd118e 100644 --- a/src/test_application/VehicleBuilder.h +++ b/src/adera/activescene/VehicleBuilder.h @@ -24,9 +24,8 @@ */ #pragma once -#include -#include -#include +#include +#include #include #include @@ -41,7 +40,7 @@ #include #include -namespace testapp +namespace adera { using osp::active::PartId; diff --git a/src/test_application/activescenes/CameraController.cpp b/src/adera/drawing/CameraController.cpp similarity index 98% rename from src/test_application/activescenes/CameraController.cpp rename to src/adera/drawing/CameraController.cpp index edda8e00..3418e1a9 100644 --- a/src/test_application/activescenes/CameraController.cpp +++ b/src/adera/drawing/CameraController.cpp @@ -26,13 +26,13 @@ #include -#include +#include // for the 0xrrggbb_rgbf and angle literals using namespace Magnum::Math::Literals; -using testapp::SysCameraController; -using testapp::ACtxCameraController; +using adera::SysCameraController; +using adera::ACtxCameraController; using Magnum::Rad; diff --git a/src/test_application/activescenes/CameraController.h b/src/adera/drawing/CameraController.h similarity index 96% rename from src/test_application/activescenes/CameraController.h rename to src/adera/drawing/CameraController.h index 4e7d2aa1..c5fde136 100644 --- a/src/test_application/activescenes/CameraController.h +++ b/src/adera/drawing/CameraController.h @@ -24,14 +24,13 @@ */ #pragma once -#include - -#include -#include +#include +#include +#include #include -namespace testapp +namespace adera { struct ACtxCameraController diff --git a/src/osp/Shaders/Flat.cpp b/src/adera/drawing_gl/flat_shader.cpp similarity index 95% rename from src/osp/Shaders/Flat.cpp rename to src/adera/drawing_gl/flat_shader.cpp index 6396b340..44b4b98c 100644 --- a/src/osp/Shaders/Flat.cpp +++ b/src/adera/drawing_gl/flat_shader.cpp @@ -22,13 +22,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "Flat.h" +#include "flat_shader.h" using namespace osp; -using namespace osp::active; -using namespace osp::shader; +using namespace osp::draw; -void shader::draw_ent_flat( +void adera::shader::draw_ent_flat( DrawEnt ent, ViewProjMatrix const& viewProj, EntityToDraw::UserData_t userData) noexcept diff --git a/src/osp/Shaders/Flat.h b/src/adera/drawing_gl/flat_shader.h similarity index 57% rename from src/osp/Shaders/Flat.h rename to src/adera/drawing_gl/flat_shader.h index 437e487d..be22dc49 100644 --- a/src/osp/Shaders/Flat.h +++ b/src/adera/drawing_gl/flat_shader.h @@ -24,12 +24,11 @@ */ #pragma once - -#include +#include #include -namespace osp::shader +namespace adera::shader { using FlatGL3D = Magnum::Shaders::FlatGL3D; @@ -40,19 +39,19 @@ struct ACtxDrawFlat FlatGL3D shaderUntextured {Corrade::NoCreate}; FlatGL3D shaderDiffuse {Corrade::NoCreate}; - active::DrawTransforms_t *pDrawTf {nullptr}; - active::DrawEntColors_t *pColor {nullptr}; - active::TexGlEntStorage_t *pDiffuseTexId {nullptr}; - active::MeshGlEntStorage_t *pMeshId {nullptr}; + osp::draw::DrawTransforms_t *pDrawTf {nullptr}; + osp::draw::DrawEntColors_t *pColor {nullptr}; + osp::draw::TexGlEntStorage_t *pDiffuseTexId {nullptr}; + osp::draw::MeshGlEntStorage_t *pMeshId {nullptr}; - active::TexGlStorage_t *pTexGl {nullptr}; - active::MeshGlStorage_t *pMeshGl {nullptr}; + osp::draw::TexGlStorage_t *pTexGl {nullptr}; + osp::draw::MeshGlStorage_t *pMeshGl {nullptr}; - active::MaterialId materialId { lgrn::id_null() }; + osp::draw::MaterialId materialId { lgrn::id_null() }; - constexpr void assign_pointers(active::ACtxSceneRender& rScnRender, - active::ACtxSceneRenderGL& rScnRenderGl, - active::RenderGL& rRenderGl) noexcept + constexpr void assign_pointers(osp::draw::ACtxSceneRender& rScnRender, + osp::draw::ACtxSceneRenderGL& rScnRenderGl, + osp::draw::RenderGL& rRenderGl) noexcept { pDrawTf = &rScnRender .m_drawTransform; pColor = &rScnRender .m_color; @@ -64,29 +63,28 @@ struct ACtxDrawFlat }; void draw_ent_flat( - active::DrawEnt ent, - active::ViewProjMatrix const& viewProj, - active::EntityToDraw::UserData_t userData) noexcept; + osp::draw::DrawEnt ent, + osp::draw::ViewProjMatrix const& viewProj, + osp::draw::EntityToDraw::UserData_t userData) noexcept; struct ArgsForSyncDrawEntFlat { - active::DrawEntSet_t const& hasMaterial; - active::RenderGroup::Storage_t *const pStorageOpaque; - active::RenderGroup::Storage_t *const pStorageTransparent; - active::DrawEntSet_t const& opaque; - active::DrawEntSet_t const& transparent; - active::TexGlEntStorage_t const& diffuse; - ACtxDrawFlat& rData; + osp::draw::DrawEntSet_t const& hasMaterial; + osp::draw::RenderGroup::DrawEnts_t *const pStorageOpaque; + osp::draw::RenderGroup::DrawEnts_t *const pStorageTransparent; + osp::draw::DrawEntSet_t const& opaque; + osp::draw::DrawEntSet_t const& transparent; + osp::draw::TexGlEntStorage_t const& diffuse; + ACtxDrawFlat& rData; }; -inline void sync_drawent_flat(active::DrawEnt ent, ArgsForSyncDrawEntFlat const args) +inline void sync_drawent_flat(osp::draw::DrawEnt ent, ArgsForSyncDrawEntFlat const args) { - using namespace osp::active; - auto const entInt = std::size_t(ent); bool const hasMaterial = args.hasMaterial.test(entInt); - bool const hasTexture = (args.diffuse.size() > std::size_t(ent)) && (args.diffuse[ent].m_glId != lgrn::id_null()); + bool const hasTexture = (args.diffuse.size() > std::size_t(ent)) + && (args.diffuse[ent].m_glId != lgrn::id_null()); FlatGL3D *pShader = hasTexture ? &args.rData.shaderDiffuse @@ -95,19 +93,19 @@ inline void sync_drawent_flat(active::DrawEnt ent, ArgsForSyncDrawEntFlat const if (args.pStorageTransparent != nullptr) { auto value = (hasMaterial && args.transparent.test(entInt)) - ? std::make_optional(EntityToDraw{&draw_ent_flat, {&args.rData, pShader}}) + ? std::make_optional(osp::draw::EntityToDraw{&draw_ent_flat, {&args.rData, pShader}}) : std::nullopt; - storage_assign(*args.pStorageTransparent, ent, std::move(value)); + osp::storage_assign(*args.pStorageTransparent, ent, std::move(value)); } if (args.pStorageOpaque != nullptr) { auto value = (hasMaterial && args.opaque.test(entInt)) - ? std::make_optional(EntityToDraw{&draw_ent_flat, {&args.rData, pShader}}) + ? std::make_optional(osp::draw::EntityToDraw{&draw_ent_flat, {&args.rData, pShader}}) : std::nullopt; - storage_assign(*args.pStorageOpaque, ent, std::move(value)); + osp::storage_assign(*args.pStorageOpaque, ent, std::move(value)); } } @@ -117,7 +115,7 @@ void sync_drawent_flat( ITB_T const& last, ArgsForSyncDrawEntFlat const args) { - std::for_each(first, last, [&args] (active::DrawEnt const ent) + std::for_each(first, last, [&args] (osp::draw::DrawEnt const ent) { sync_drawent_flat(ent, args); }); diff --git a/src/osp/Shaders/Phong.cpp b/src/adera/drawing_gl/phong_shader.cpp similarity index 97% rename from src/osp/Shaders/Phong.cpp rename to src/adera/drawing_gl/phong_shader.cpp index f81ccd0a..1927c9bc 100644 --- a/src/osp/Shaders/Phong.cpp +++ b/src/adera/drawing_gl/phong_shader.cpp @@ -22,16 +22,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "Phong.h" +#include "phong_shader.h" // for the 0xrrggbb_rgbf and angle literals using namespace Magnum::Math::Literals; using namespace osp; -using namespace osp::active; -using namespace osp::shader; +using namespace osp::draw; -void shader::draw_ent_phong( +void adera::shader::draw_ent_phong( DrawEnt ent, ViewProjMatrix const& viewProj, EntityToDraw::UserData_t userData) noexcept diff --git a/src/osp/Shaders/Phong.h b/src/adera/drawing_gl/phong_shader.h similarity index 59% rename from src/osp/Shaders/Phong.h rename to src/adera/drawing_gl/phong_shader.h index 43e6323c..d067fad4 100644 --- a/src/osp/Shaders/Phong.h +++ b/src/adera/drawing_gl/phong_shader.h @@ -24,13 +24,11 @@ */ #pragma once -#include +#include #include -#include - -namespace osp::shader +namespace adera::shader { using PhongGL = Magnum::Shaders::PhongGL; @@ -43,19 +41,19 @@ struct ACtxDrawPhong PhongGL shaderUntextured {Corrade::NoCreate}; PhongGL shaderDiffuse {Corrade::NoCreate}; - active::DrawTransforms_t *pDrawTf {nullptr}; - active::DrawEntColors_t *pColor {nullptr}; - active::TexGlEntStorage_t *pDiffuseTexId {nullptr}; - active::MeshGlEntStorage_t *pMeshId {nullptr}; + osp::draw::DrawTransforms_t *pDrawTf {nullptr}; + osp::draw::DrawEntColors_t *pColor {nullptr}; + osp::draw::TexGlEntStorage_t *pDiffuseTexId {nullptr}; + osp::draw::MeshGlEntStorage_t *pMeshId {nullptr}; - active::TexGlStorage_t *pTexGl {nullptr}; - active::MeshGlStorage_t *pMeshGl {nullptr}; + osp::draw::TexGlStorage_t *pTexGl {nullptr}; + osp::draw::MeshGlStorage_t *pMeshGl {nullptr}; - active::MaterialId materialId { lgrn::id_null() }; + osp::draw::MaterialId materialId { lgrn::id_null() }; - constexpr void assign_pointers(active::ACtxSceneRender& rScnRender, - active::ACtxSceneRenderGL& rScnRenderGl, - active::RenderGL& rRenderGl) noexcept + constexpr void assign_pointers(osp::draw::ACtxSceneRender& rScnRender, + osp::draw::ACtxSceneRenderGL& rScnRenderGl, + osp::draw::RenderGL& rRenderGl) noexcept { pDrawTf = &rScnRender .m_drawTransform; pColor = &rScnRender .m_color; @@ -67,29 +65,27 @@ struct ACtxDrawPhong }; void draw_ent_phong( - active::DrawEnt ent, - active::ViewProjMatrix const& viewProj, - active::EntityToDraw::UserData_t userData) noexcept; + osp::draw::DrawEnt ent, + osp::draw::ViewProjMatrix const& viewProj, + osp::draw::EntityToDraw::UserData_t userData) noexcept; struct ArgsForSyncDrawEntPhong { - active::DrawEntSet_t const& hasMaterial; - active::RenderGroup::Storage_t *const pStorageOpaque {nullptr}; - active::RenderGroup::Storage_t *const pStorageTransparent {nullptr}; - active::DrawEntSet_t const& opaque; - active::DrawEntSet_t const& transparent; - active::TexGlEntStorage_t const& diffuse; - ACtxDrawPhong& rData; + osp::draw::DrawEntSet_t const& hasMaterial; + osp::draw::RenderGroup::DrawEnts_t *const pStorageOpaque; + osp::draw::RenderGroup::DrawEnts_t *const pStorageTransparent; + osp::draw::DrawEntSet_t const& opaque; + osp::draw::DrawEntSet_t const& transparent; + osp::draw::TexGlEntStorage_t const& diffuse; + ACtxDrawPhong& rData; }; -inline void sync_drawent_phong(active::DrawEnt ent, ArgsForSyncDrawEntPhong const args) +inline void sync_drawent_phong(osp::draw::DrawEnt ent, ArgsForSyncDrawEntPhong const args) { - using namespace active; - auto const entInt = std::size_t(ent); bool const hasMaterial = args.hasMaterial.test(entInt); - bool const hasTexture = (args.diffuse.size() > std::size_t(ent)) && (args.diffuse[ent].m_glId != lgrn::id_null()); + bool const hasTexture = (args.diffuse.size() > std::size_t(ent)) && (args.diffuse[ent].m_glId != lgrn::id_null()); PhongGL *pShader = hasTexture ? &args.rData.shaderDiffuse @@ -98,19 +94,19 @@ inline void sync_drawent_phong(active::DrawEnt ent, ArgsForSyncDrawEntPhong cons if (args.pStorageTransparent != nullptr) { auto value = (hasMaterial && args.transparent.test(entInt)) - ? std::make_optional(EntityToDraw{&draw_ent_phong, {&args.rData, pShader}}) + ? std::make_optional(osp::draw::EntityToDraw{&draw_ent_phong, {&args.rData, pShader}}) : std::nullopt; - storage_assign(*args.pStorageTransparent, ent, std::move(value)); + osp::storage_assign(*args.pStorageTransparent, ent, std::move(value)); } if (args.pStorageOpaque != nullptr) { auto value = (hasMaterial && args.opaque.test(entInt)) - ? std::make_optional(EntityToDraw{&draw_ent_phong, {&args.rData, pShader}}) + ? std::make_optional(osp::draw::EntityToDraw{&draw_ent_phong, {&args.rData, pShader}}) : std::nullopt; - storage_assign(*args.pStorageOpaque, ent, std::move(value)); + osp::storage_assign(*args.pStorageOpaque, ent, std::move(value)); } } @@ -120,7 +116,7 @@ void sync_drawent_phong( ITB_T const& last, ArgsForSyncDrawEntPhong const args) { - std::for_each(first, last, [&args] (active::DrawEnt const ent) + std::for_each(first, last, [&args] (osp::draw::DrawEnt const ent) { sync_drawent_phong(ent, args); }); diff --git a/src/adera/Shaders/PlumeShader.cpp b/src/adera/drawing_gl/plume_shader.cpp similarity index 98% rename from src/adera/Shaders/PlumeShader.cpp rename to src/adera/drawing_gl/plume_shader.cpp index 7b885820..0c122f6f 100644 --- a/src/adera/Shaders/PlumeShader.cpp +++ b/src/adera/drawing_gl/plume_shader.cpp @@ -22,7 +22,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "PlumeShader.h" // IWYU pragma: associated +#include "plume_shader.h" // IWYU pragma: associated + +#if 0 #include // for PlumeEffectData #include // for ACompExhaustPlume @@ -197,3 +199,5 @@ PlumeShader& PlumeShader::setPower(const float power) setUniform(static_cast(UniformPos::Power), power); return *this; } + +#endif diff --git a/src/adera/Shaders/PlumeShader.h b/src/adera/drawing_gl/plume_shader.h similarity index 99% rename from src/adera/Shaders/PlumeShader.h rename to src/adera/drawing_gl/plume_shader.h index ae473be9..0a69f7d6 100644 --- a/src/adera/Shaders/PlumeShader.h +++ b/src/adera/drawing_gl/plume_shader.h @@ -24,6 +24,8 @@ */ #pragma once +#if 0 + #include "../SysExhaustPlume.h" #include @@ -142,3 +144,5 @@ struct ACtxPlumeData }; } // namespace adera::shader + +#endif diff --git a/src/osp/Shaders/MeshVisualizer.cpp b/src/adera/drawing_gl/visualizer_shader.cpp similarity index 95% rename from src/osp/Shaders/MeshVisualizer.cpp rename to src/adera/drawing_gl/visualizer_shader.cpp index c6005301..114099bc 100644 --- a/src/osp/Shaders/MeshVisualizer.cpp +++ b/src/adera/drawing_gl/visualizer_shader.cpp @@ -23,7 +23,7 @@ * SOFTWARE. */ -#include "MeshVisualizer.h" +#include "visualizer_shader.h" #include #include @@ -32,10 +32,9 @@ using namespace Magnum::Math::Literals; using namespace osp; -using namespace osp::active; -using namespace osp::shader; +using namespace osp::draw; -void shader::draw_ent_visualizer( +void adera::shader::draw_ent_visualizer( DrawEnt ent, ViewProjMatrix const& viewProj, EntityToDraw::UserData_t userData) noexcept diff --git a/src/osp/Shaders/MeshVisualizer.h b/src/adera/drawing_gl/visualizer_shader.h similarity index 66% rename from src/osp/Shaders/MeshVisualizer.h rename to src/adera/drawing_gl/visualizer_shader.h index 76f1610d..b9ae51bf 100644 --- a/src/osp/Shaders/MeshVisualizer.h +++ b/src/adera/drawing_gl/visualizer_shader.h @@ -24,11 +24,11 @@ */ #pragma once -#include +#include #include -namespace osp::shader +namespace adera::shader { using MeshVisualizer = Magnum::Shaders::MeshVisualizerGL3D; @@ -37,17 +37,17 @@ struct ACtxDrawMeshVisualizer { MeshVisualizer m_shader{Corrade::NoCreate}; - osp::active::DrawTransforms_t *m_pDrawTf{nullptr}; - osp::active::MeshGlEntStorage_t *m_pMeshId{nullptr}; - osp::active::MeshGlStorage_t *m_pMeshGl{nullptr}; + osp::draw::DrawTransforms_t *m_pDrawTf{nullptr}; + osp::draw::MeshGlEntStorage_t *m_pMeshId{nullptr}; + osp::draw::MeshGlStorage_t *m_pMeshGl{nullptr}; - osp::active::MaterialId m_materialId { lgrn::id_null() }; + osp::draw::MaterialId m_materialId { lgrn::id_null() }; bool m_wireframeOnly{false}; -constexpr void assign_pointers(active::ACtxSceneRender& rScnRender, - active::ACtxSceneRenderGL& rScnRenderGl, - active::RenderGL& rRenderGl) noexcept +constexpr void assign_pointers(osp::draw::ACtxSceneRender& rScnRender, + osp::draw::ACtxSceneRenderGL& rScnRenderGl, + osp::draw::RenderGL& rRenderGl) noexcept { m_pDrawTf = &rScnRender.m_drawTransform; m_pMeshId = &rScnRenderGl.m_meshId; @@ -56,24 +56,22 @@ constexpr void assign_pointers(active::ACtxSceneRender& rScnRender, }; void draw_ent_visualizer( - active::DrawEnt ent, - active::ViewProjMatrix const& viewProj, - active::EntityToDraw::UserData_t userData) noexcept; + osp::draw::DrawEnt ent, + osp::draw::ViewProjMatrix const& viewProj, + osp::draw::EntityToDraw::UserData_t userData) noexcept; inline void sync_drawent_visualizer( - active::DrawEnt const ent, - active::DrawEntSet_t const& hasMaterial, - active::RenderGroup::Storage_t& rStorage, + osp::draw::DrawEnt const ent, + osp::draw::DrawEntSet_t const& hasMaterial, + osp::draw::RenderGroup::DrawEnts_t& rStorage, ACtxDrawMeshVisualizer& rData) { - using namespace active; - bool alreadyAdded = rStorage.contains(ent); if (hasMaterial.test(std::size_t(ent))) { if ( ! alreadyAdded) { - rStorage.emplace( ent, EntityToDraw{&draw_ent_visualizer, {&rData} } ); + rStorage.emplace( ent, osp::draw::EntityToDraw{&draw_ent_visualizer, {&rData} } ); } } else @@ -88,11 +86,11 @@ template static void sync_drawent_visualizer( ITA_T const& first, ITB_T const& last, - active::DrawEntSet_t const& hasMaterial, - active::RenderGroup::Storage_t& rStorage, + osp::draw::DrawEntSet_t const& hasMaterial, + osp::draw::RenderGroup::DrawEnts_t& rStorage, ACtxDrawMeshVisualizer& rData) { - std::for_each(first, last, [&] (active::DrawEnt const ent) + std::for_each(first, last, [&] (osp::draw::DrawEnt const ent) { sync_drawent_visualizer(ent, hasMaterial, rStorage, rData); }); diff --git a/src/adera/machines/links.h b/src/adera/machines/links.h index aa70da3b..557c0020 100644 --- a/src/adera/machines/links.h +++ b/src/adera/machines/links.h @@ -24,6 +24,8 @@ */ #pragma once +#include + #include #include diff --git a/src/osp/activescene/active_ent.h b/src/osp/activescene/active_ent.h new file mode 100644 index 00000000..9d65eaf6 --- /dev/null +++ b/src/osp/activescene/active_ent.h @@ -0,0 +1,34 @@ +/** + * Open Space Program + * Copyright © 2019-2023 Open Space Program Project + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#pragma once + +#include "../core/strong_id.h" + +namespace osp::active +{ + +using ActiveEnt = StrongId; + +} // namespace osp::active diff --git a/src/osp/Active/basic.h b/src/osp/activescene/basic.h similarity index 87% rename from src/osp/Active/basic.h rename to src/osp/activescene/basic.h index 430d7e92..b4901cdb 100644 --- a/src/osp/Active/basic.h +++ b/src/osp/activescene/basic.h @@ -24,16 +24,23 @@ */ #pragma once -#include "../types.h" -#include "activetypes.h" +#include "active_ent.h" + +#include "../core/bitvector.h" +#include "../core/math_types.h" +#include "../core/storage.h" #include +#include // for lgrn::IdRegistryStl #include namespace osp::active { +using ActiveEntVec_t = std::vector; +using ActiveEntSet_t = BitVector_t; + /** * @brief Component for transformation (in meters) */ @@ -75,6 +82,8 @@ struct ACtxSceneGraph } }; +using ACompTransformStorage_t = Storage_t; + /** * @brief Storage for basic components */ @@ -83,7 +92,7 @@ struct ACtxBasic lgrn::IdRegistryStl m_activeIds; ACtxSceneGraph m_scnGraph; - acomp_storage_t m_transform; + ACompTransformStorage_t m_transform; }; template diff --git a/src/osp/Active/SysSceneGraph.cpp b/src/osp/activescene/basic_fn.cpp similarity index 99% rename from src/osp/Active/SysSceneGraph.cpp rename to src/osp/activescene/basic_fn.cpp index 2a46f40b..edcc3fea 100644 --- a/src/osp/Active/SysSceneGraph.cpp +++ b/src/osp/activescene/basic_fn.cpp @@ -22,9 +22,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "SysSceneGraph.h" +#include "basic_fn.h" -#include #include #include diff --git a/src/osp/Active/SysSceneGraph.h b/src/osp/activescene/basic_fn.h similarity index 97% rename from src/osp/Active/SysSceneGraph.h rename to src/osp/activescene/basic_fn.h index 6ce9f15b..8c02bf77 100644 --- a/src/osp/Active/SysSceneGraph.h +++ b/src/osp/activescene/basic_fn.h @@ -25,7 +25,9 @@ #pragma once #include "basic.h" -#include "activetypes.h" + +#include "../core/array_view.h" +#include "../core/copymove_macros.h" #include #include @@ -42,14 +44,13 @@ namespace osp::active class SubtreeBuilder { public: - constexpr SubtreeBuilder(ACtxSceneGraph& rScnGraph, ActiveEnt root, TreePos_t first, TreePos_t last) + constexpr SubtreeBuilder(ACtxSceneGraph& rScnGraph, ActiveEnt root, TreePos_t first, TreePos_t last) noexcept : m_rScnGraph{rScnGraph} , m_root{root} , m_first{first} , m_last{last} { } - constexpr SubtreeBuilder(SubtreeBuilder&& move) = default; - SubtreeBuilder(SubtreeBuilder const& copy) = delete; + OSP_MOVE_ONLY_CTOR_CONSTEXPR_NOEXCEPT(SubtreeBuilder) ~SubtreeBuilder() { assert(m_first == m_last); } /** diff --git a/src/osp/Active/physics.h b/src/osp/activescene/physics.h similarity index 86% rename from src/osp/Active/physics.h rename to src/osp/activescene/physics.h index c6bf314f..6db4a88c 100644 --- a/src/osp/Active/physics.h +++ b/src/osp/activescene/physics.h @@ -24,11 +24,10 @@ */ #pragma once -#include "activetypes.h" +#include "basic.h" -#include "../CommonPhysics.h" -#include "../keyed_vector.h" -#include "../types.h" +#include "../core/keyed_vector.h" +#include "../scientific/shapes.h" namespace osp::active { @@ -48,14 +47,10 @@ struct ACompMass */ struct ACtxPhysics { - KeyedVec m_shape; - ActiveEntSet_t m_hasColliders; - - acomp_storage_t m_mass; - - + KeyedVec m_shape; + ActiveEntSet_t m_hasColliders; + Storage_t m_mass; Vector3 m_originTranslate; - ActiveEntVec_t m_colliderDirty; std::vector< std::pair > m_setVelocity; diff --git a/src/osp/Active/SysPhysics.cpp b/src/osp/activescene/physics_fn.cpp similarity index 62% rename from src/osp/Active/SysPhysics.cpp rename to src/osp/activescene/physics_fn.cpp index b483039f..7e63dc46 100644 --- a/src/osp/Active/SysPhysics.cpp +++ b/src/osp/activescene/physics_fn.cpp @@ -1,11 +1,35 @@ -#include "SysPhysics.h" -#include "SysSceneGraph.h" +/** + * Open Space Program + * Copyright © 2019-2023 Open Space Program Project + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "physics_fn.h" +#include "basic_fn.h" using namespace osp; using namespace osp::active; void SysPhysics::calculate_subtree_mass_center( - acomp_storage_t const& rTf, + ACompTransformStorage_t const& rTf, ACtxPhysics& rCtxPhys, ACtxSceneGraph& rScnGraph, ActiveEnt root, @@ -39,7 +63,7 @@ void SysPhysics::calculate_subtree_mass_center( void SysPhysics::calculate_subtree_mass_inertia( - acomp_storage_t const& rTf, + ACompTransformStorage_t const& rTf, ACtxPhysics& rCtxPhys, ACtxSceneGraph& rScnGraph, ActiveEnt root, @@ -61,7 +85,7 @@ void SysPhysics::calculate_subtree_mass_inertia( Vector3 const offset = childTf.translation() + childMass.m_offset * childTf.scaling(); - rInertiaTensor += phys::transform_inertia_tensor(inertiaTensor, childMass.m_mass, offset, childTf.rotation()); + rInertiaTensor += transform_inertia_tensor(inertiaTensor, childMass.m_mass, offset, childTf.rotation()); } if (rCtxPhys.m_hasColliders.test(std::size_t(child))) diff --git a/src/osp/Active/SysPhysics.h b/src/osp/activescene/physics_fn.h similarity index 95% rename from src/osp/Active/SysPhysics.h rename to src/osp/activescene/physics_fn.h index bb9556e1..55d7fc59 100644 --- a/src/osp/Active/SysPhysics.h +++ b/src/osp/activescene/physics_fn.h @@ -37,7 +37,7 @@ class SysPhysics public: static void calculate_subtree_mass_center( - acomp_storage_t const& rTf, + ACompTransformStorage_t const& rTf, ACtxPhysics& rCtxPhys, ACtxSceneGraph& rScnGraph, ActiveEnt root, @@ -46,7 +46,7 @@ class SysPhysics Matrix4 const& currentTf = {}); static void calculate_subtree_mass_inertia( - acomp_storage_t const& rTf, + ACompTransformStorage_t const& rTf, ACtxPhysics& rCtxPhys, ACtxSceneGraph& rScnGraph, ActiveEnt root, diff --git a/src/osp/Active/SysPrefabInit.cpp b/src/osp/activescene/prefab_fn.cpp similarity index 96% rename from src/osp/Active/SysPrefabInit.cpp rename to src/osp/activescene/prefab_fn.cpp index 34db2b2f..c33e6031 100644 --- a/src/osp/Active/SysPrefabInit.cpp +++ b/src/osp/activescene/prefab_fn.cpp @@ -22,13 +22,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "SysPrefabInit.h" -#include "SysRender.h" -#include "SysSceneGraph.h" -#include "SysSceneGraph.h" +#include "prefab_fn.h" +#include "basic_fn.h" -#include -#include +#include "../core/Resources.h" +#include "../vehicles/ImporterData.h" #include #include @@ -37,8 +35,6 @@ using Corrade::Containers::ArrayView; using osp::restypes::gc_importer; -using osp::phys::EShape; - namespace osp::active { @@ -84,7 +80,7 @@ void SysPrefabInit::add_to_subtree( void SysPrefabInit::init_transforms( ACtxPrefabInit const& rPrefabInit, Resources const& rResources, - acomp_storage_t& rTransform) noexcept + ACompTransformStorage_t& rTransform) noexcept { auto itPfEnts = std::begin(rPrefabInit.m_ents); @@ -299,7 +295,7 @@ void SysPrefabInit::init_physics( if (mass != 0.0f) { Vector3 const scale = rImportData.m_objTransforms[objectId].scaling(); - Vector3 const inertia = phys::collider_inertia_tensor(shape, scale, mass); + Vector3 const inertia = collider_inertia_tensor(shape, scale, mass); Vector3 const offset{0.0f, 0.0f, 0.0f}; rCtxPhys.m_mass.emplace( ent, ACompMass{ offset, inertia, mass } ); diff --git a/src/osp/Active/SysPrefabInit.h b/src/osp/activescene/prefab_fn.h similarity index 83% rename from src/osp/Active/SysPrefabInit.h rename to src/osp/activescene/prefab_fn.h index bbe1a19e..6dfdb1b5 100644 --- a/src/osp/Active/SysPrefabInit.h +++ b/src/osp/activescene/prefab_fn.h @@ -24,14 +24,11 @@ */ #pragma once -#include "activetypes.h" -#include "basic.h" -#include "drawing.h" +#include "basic_fn.h" #include "physics.h" -#include "SysSceneGraph.h" -#include "../types.h" -#include "../Resource/resourcetypes.h" +#include "../core/resourcetypes.h" +#include "../vehicles/prefabs.h" #include @@ -85,14 +82,7 @@ class SysPrefabInit static void init_transforms( ACtxPrefabInit const& rPrefabInit, Resources const& rResources, - acomp_storage_t& rTransform) noexcept; - - static void init_drawing( - ACtxPrefabInit const& rPrefabInit, - Resources& rResources, - ACtxDrawing& rDrawing, - ACtxDrawingRes& rCtxDrawRes, - std::optional material) noexcept; + ACompTransformStorage_t& rTransform) noexcept; static void init_physics( ACtxPrefabInit const& rPrefabInit, diff --git a/src/osp/Active/parts.h b/src/osp/activescene/vehicles.h similarity index 96% rename from src/osp/Active/parts.h rename to src/osp/activescene/vehicles.h index 14b45393..784d93f5 100644 --- a/src/osp/Active/parts.h +++ b/src/osp/activescene/vehicles.h @@ -24,13 +24,12 @@ */ #pragma once -#include "activetypes.h" - -#include "../Resource/resourcetypes.h" -#include "../types.h" -#include "../id_map.h" +#include "active_ent.h" +#include "../core/array_view.h" +#include "../core/math_types.h" #include "../link/machines.h" +#include "../vehicles/prefabs.h" #include #include diff --git a/src/osp/Resource/resources.cpp b/src/osp/core/Resources.cpp similarity index 99% rename from src/osp/Resource/resources.cpp rename to src/osp/core/Resources.cpp index beb7ede8..65119e21 100644 --- a/src/osp/Resource/resources.cpp +++ b/src/osp/core/Resources.cpp @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "resources.h" +#include "Resources.h" using namespace osp; @@ -113,5 +113,3 @@ PkgId Resources::pkg_create() m_pkgData[std::size_t(newPkgId)].m_resTypeOwn.resize(m_perResType.size()); return newPkgId; } - - diff --git a/src/osp/Resource/resources.h b/src/osp/core/Resources.h similarity index 99% rename from src/osp/Resource/resources.h rename to src/osp/core/Resources.h index f09493a0..20dae9bd 100644 --- a/src/osp/Resource/resources.h +++ b/src/osp/core/Resources.h @@ -24,7 +24,7 @@ */ #pragma once -#include "../shared_string.h" +#include "shared_string.h" #include "resourcetypes.h" #include diff --git a/src/osp/core/array_view.h b/src/osp/core/array_view.h new file mode 100644 index 00000000..cb0bda52 --- /dev/null +++ b/src/osp/core/array_view.h @@ -0,0 +1,37 @@ +/** + * Open Space Program + * Copyright © 2019-2023 Open Space Program Project + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#pragma once + +// IWYU pragma: begin_exports +#include +// IWYU pragma: end_exports + +namespace osp +{ + +using Corrade::Containers::ArrayView; +using Corrade::Containers::arrayView; + +} // namespace osp diff --git a/src/osp/bitvector.h b/src/osp/core/bitvector.h similarity index 100% rename from src/osp/bitvector.h rename to src/osp/core/bitvector.h diff --git a/src/osp/core/copymove_macros.h b/src/osp/core/copymove_macros.h new file mode 100644 index 00000000..16b18abd --- /dev/null +++ b/src/osp/core/copymove_macros.h @@ -0,0 +1,57 @@ +/** + * Open Space Program + * Copyright © 2019-2023 Open Space Program Project + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#pragma once + +#define OSP_MOVE_COPY_CTOR_ASSIGN(type) \ + Type (Type const& copy) = default; \ + Type (Type&& move) = default; \ + Type& operator= (Type const& copy) = default; \ + Type& operator= (Type&& move) = default; + +#define OSP_MOVE_ONLY_CTOR_ASSIGN(Type) \ + Type (Type const& copy) = delete; \ + Type (Type&& move) = default; \ + Type& operator= (Type const& copy) = delete; \ + Type& operator= (Type&& move) = default; + +#define OSP_MOVE_ONLY_CTOR(Type) \ + Type (Type const& copy) = delete; \ + Type (Type&& move) = default; + +#define OSP_MOVE_COPY_CTOR_ASSIGN_CONSTEXPR_NOEXCEPT(Type) \ + constexpr Type (Type const& copy) noexcept = default; \ + constexpr Type (Type&& move) noexcept = default; \ + constexpr Type& operator= (Type const& copy) noexcept = default; \ + constexpr Type& operator= (Type&& move) noexcept = default; + +#define OSP_MOVE_ONLY_CTOR_ASSIGN_CONSTEXPR_NOEXCEPT(Type) \ + constexpr Type (Type const& copy) noexcept = delete; \ + constexpr Type (Type&& move) noexcept = default; \ + constexpr Type& operator= (Type const& copy) noexcept = delete; \ + constexpr Type& operator= (Type&& move) noexcept = default; + +#define OSP_MOVE_ONLY_CTOR_CONSTEXPR_NOEXCEPT(Type) \ + constexpr Type (Type const& copy) noexcept = delete; \ + constexpr Type (Type&& move) noexcept = default; diff --git a/src/osp/global_id.h b/src/osp/core/global_id.h similarity index 100% rename from src/osp/global_id.h rename to src/osp/core/global_id.h diff --git a/src/osp/id_map.h b/src/osp/core/id_map.h similarity index 100% rename from src/osp/id_map.h rename to src/osp/core/id_map.h diff --git a/src/osp/keyed_vector.h b/src/osp/core/keyed_vector.h similarity index 100% rename from src/osp/keyed_vector.h rename to src/osp/core/keyed_vector.h diff --git a/src/osp/CommonMath.h b/src/osp/core/math_2pow.h similarity index 100% rename from src/osp/CommonMath.h rename to src/osp/core/math_2pow.h diff --git a/src/osp/types.h b/src/osp/core/math_types.h similarity index 95% rename from src/osp/types.h rename to src/osp/core/math_types.h index bd011ffe..b98e1676 100644 --- a/src/osp/types.h +++ b/src/osp/core/math_types.h @@ -37,16 +37,11 @@ #include #include - -#include // IWYU pragma: end_exports namespace osp { -using Corrade::Containers::ArrayView; -using Corrade::Containers::arrayView; - using Matrix3 = Magnum::Math::Matrix3; using Matrix4 = Magnum::Math::Matrix4; @@ -67,4 +62,4 @@ using Rad = Magnum::Math::Rad; using Radd = Magnum::Math::Rad; using Deg = Magnum::Math::Deg; -} +} // namespace osp diff --git a/src/osp/Resource/resourcetypes.h b/src/osp/core/resourcetypes.h similarity index 85% rename from src/osp/Resource/resourcetypes.h rename to src/osp/core/resourcetypes.h index 7e2db363..4c5c1829 100644 --- a/src/osp/Resource/resourcetypes.h +++ b/src/osp/core/resourcetypes.h @@ -24,8 +24,9 @@ */ #pragma once +#include "global_id.h" + #include -#include "../global_id.h" #include #include @@ -101,29 +102,6 @@ class Resources; using ResIdOwner_t = lgrn::IdOwner; - -// Resource Type Ids - using ResTypeIdReg_t = GlobalIdReg; -namespace restypes -{ - -inline ResTypeId const gc_image = ResTypeIdReg_t::create(); -inline ResTypeId const gc_texture = ResTypeIdReg_t::create(); -inline ResTypeId const gc_mesh = ResTypeIdReg_t::create(); -inline ResTypeId const gc_importer = ResTypeIdReg_t::create(); - -} // namespace restypes - - -using ObjId = int32_t; -using PrefabId = uint32_t; - -struct PrefabPair -{ - ResIdOwner_t m_importer; - PrefabId m_prefabId; -}; - } // namespace osp diff --git a/src/osp/shared_string.h b/src/osp/core/shared_string.h similarity index 100% rename from src/osp/shared_string.h rename to src/osp/core/shared_string.h diff --git a/src/osp/Active/activetypes.h b/src/osp/core/storage.h similarity index 65% rename from src/osp/Active/activetypes.h rename to src/osp/core/storage.h index c8e417e9..6d42a69a 100644 --- a/src/osp/Active/activetypes.h +++ b/src/osp/core/storage.h @@ -1,6 +1,6 @@ /** * Open Space Program - * Copyright © 2019-2020 Open Space Program Project + * Copyright © 2019-2023 Open Space Program Project * * MIT License * @@ -24,46 +24,18 @@ */ #pragma once -#include "../bitvector.h" // for osp::BitVector_t - // IWYU pragma: begin_exports - -#include // for entt::id_type #include // for basic_view #include // for entt::basic_storage -#include // for entt::sparse_set - // IWYU pragma: end_exports -#include // for lgrn::IdRegistryStl -#include // for lgrn::BitView - #include -#include -namespace osp::active +namespace osp { -enum class ActiveEnt: uint32_t { }; - -using ActiveEntVec_t = std::vector; -using ActiveEntSet_t = BitVector_t; - -using active_sparse_set_t = entt::basic_sparse_set; - -template -using acomp_storage_t = typename entt::basic_storage; - -//----------------------------------------------------------------------------- - -enum class DrawEnt : uint32_t { }; - -using DrawEntVec_t = std::vector; -using DrawEntSet_t = BitVector_t; - - -enum class MaterialId : uint32_t { }; - +template +using Storage_t = typename entt::basic_storage; /** * @brief Emplace, Reassign, or Remove a value from an entt::basic_storage @@ -88,6 +60,4 @@ void storage_assign(entt::basic_storage &rStorage, ENT_T const en } } - -} // namespace osp::active - +} // namespace osp diff --git a/src/osp/string_concat.h b/src/osp/core/string_concat.h similarity index 100% rename from src/osp/string_concat.h rename to src/osp/core/string_concat.h diff --git a/src/osp/core/strong_id.h b/src/osp/core/strong_id.h new file mode 100644 index 00000000..954ee4a1 --- /dev/null +++ b/src/osp/core/strong_id.h @@ -0,0 +1,90 @@ +/** + * Open Space Program + * Copyright © 2019-2023 Open Space Program Project + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#pragma once + +#include "copymove_macros.h" + +#include +#include // light-ish header that happens to include std::hash + +#include + +namespace osp +{ + +/** + * @brief Integer wrapper intended for identifiers usable as container indices/keys + * + * Default-initialized to null (max int value) + * + * @tparam INT_T Wrapped integer type, usually unsigned + * @tparam DUMMY_T Dummy used to make separate unique types, avoids needing inheritance + */ +template +struct StrongId +{ + using entity_type = INT_T; // Name used for entt compatibility + + constexpr StrongId() noexcept = default; + constexpr StrongId(StrongId const& copy) noexcept + : m_value{copy.m_value} + { }; + constexpr explicit StrongId(INT_T const value) noexcept + : m_value{value} + { }; + + constexpr explicit operator std::size_t() const noexcept + { + return m_value; + } + + constexpr explicit operator INT_T() const noexcept + { + return m_value; + } + + constexpr auto operator<=>(StrongId const&) const = default; + + INT_T m_value{ lgrn::id_null() }; +}; + +} // namespace osp + +// std::hash support for unordered containers +template +struct std::hash> { + constexpr auto operator() (osp::StrongId const& key) const + { + return key.m_value; + } +}; + +// Longeron++ underlying_int_type +template +struct lgrn::underlying_int_type< TYPE_T, std::enable_if_t< std::is_integral_v > > +{ + using type = typename TYPE_T::entity_type; +}; + diff --git a/src/osp/unpack.h b/src/osp/core/unpack.h similarity index 98% rename from src/osp/unpack.h rename to src/osp/core/unpack.h index 26c7fb3a..4c893914 100644 --- a/src/osp/unpack.h +++ b/src/osp/core/unpack.h @@ -52,6 +52,4 @@ constexpr auto& resize_then_unpack(CONTAINER_T &rIn) return unpack(rIn); } - -} - +} // namespace osp diff --git a/src/osp/drawing/draw_ent.h b/src/osp/drawing/draw_ent.h new file mode 100644 index 00000000..1b9e8b01 --- /dev/null +++ b/src/osp/drawing/draw_ent.h @@ -0,0 +1,36 @@ +/** + * Open Space Program + * Copyright © 2019-2023 Open Space Program Project + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#pragma once + +#include "../core/strong_id.h" + +namespace osp::draw +{ + +using DrawEnt = StrongId; + +using MaterialId = StrongId; + +} // namespace osp::draw diff --git a/src/osp/Active/drawing.h b/src/osp/drawing/drawing.h similarity index 83% rename from src/osp/Active/drawing.h rename to src/osp/drawing/drawing.h index 0ef4eb0f..bc70702b 100644 --- a/src/osp/Active/drawing.h +++ b/src/osp/drawing/drawing.h @@ -24,23 +24,30 @@ */ #pragma once -#include "activetypes.h" +#include "draw_ent.h" -#include "../bitvector.h" -#include "../id_map.h" -#include "../keyed_vector.h" -#include "../types.h" +#include "../core/bitvector.h" +#include "../core/copymove_macros.h" +#include "../core/id_map.h" +#include "../core/keyed_vector.h" +#include "../core/math_types.h" +#include "../core/resourcetypes.h" +#include "../core/storage.h" -#include "../Resource/resourcetypes.h" +#include "../activescene/active_ent.h" #include #include #include +#include // for lgrn::IdRegistryStl -namespace osp::active +namespace osp::draw { +using DrawEntVec_t = std::vector; +using DrawEntSet_t = BitVector_t; + struct Material { DrawEntSet_t m_ents; @@ -82,15 +89,16 @@ struct ACtxDrawing TexRefCount_t m_texRefCounts; }; +// Note: IdOwner members below are move-only. Move constructors need to be defined for the structs +// (can use OSP_MOVE_ONLY_CTOR_ASSIGN) or else there will be huge compiler errors somehow. + /** * @brief Associates mesh/texture resources Ids from ACtxDrawing with Resources */ struct ACtxDrawingRes { - // Required for std::is_copy_assignable to work properly inside of entt::any ACtxDrawingRes() = default; - ACtxDrawingRes(ACtxDrawingRes const& copy) = delete; - ACtxDrawingRes(ACtxDrawingRes&& move) = default; + OSP_MOVE_ONLY_CTOR_ASSIGN(ACtxDrawingRes); // Associate Texture Ids with resources IdMap_t m_resToTex; @@ -107,10 +115,8 @@ using DrawTransforms_t = KeyedVec; struct ACtxSceneRender { - // Required for std::is_copy_assignable to work properly inside of entt::any ACtxSceneRender() = default; - ACtxSceneRender(ACtxSceneRender const& copy) = delete; - ACtxSceneRender(ACtxSceneRender&& move) = default; + OSP_MOVE_ONLY_CTOR_ASSIGN(ACtxSceneRender); void resize_draw() { @@ -145,7 +151,7 @@ struct ACtxSceneRender DrawEntColors_t m_color; DrawEntSet_t m_needDrawTf; - KeyedVec m_activeToDraw; + KeyedVec m_activeToDraw; DrawTransforms_t m_drawTransform; @@ -164,10 +170,10 @@ struct Camera { Matrix4 m_transform; - float m_near{0.25f}; - float m_far{1024.0f}; - float m_aspectRatio{1.0f}; - Deg m_fov{45.0f}; + float m_near { 0.25f }; + float m_far { 1024.0f }; + float m_aspectRatio { 1.0f }; + Deg m_fov { 45.0f }; constexpr void set_aspect_ratio(Vector2 const viewport) noexcept { @@ -180,5 +186,5 @@ struct Camera } }; -} // namespace osp::active +} // namespace osp::draw diff --git a/src/osp/Active/SysRender.cpp b/src/osp/drawing/drawing_fn.cpp similarity index 95% rename from src/osp/Active/SysRender.cpp rename to src/osp/drawing/drawing_fn.cpp index 5c97a91b..74c2d4a4 100644 --- a/src/osp/Active/SysRender.cpp +++ b/src/osp/drawing/drawing_fn.cpp @@ -22,14 +22,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "SysRender.h" -#include "SysSceneGraph.h" +#include "drawing_fn.h" +#include "own_restypes.h" - -#include "../Resource/resources.h" +#include "../activescene/basic_fn.h" +#include "../core/Resources.h" using namespace osp; using namespace osp::active; +using namespace osp::draw; MeshId SysRender::own_mesh_resource(ACtxDrawing& rCtxDrawing, ACtxDrawingRes& rCtxDrawingRes, Resources &rResources, ResId const resId) { @@ -90,7 +91,7 @@ void SysRender::clear_resource_owners(ACtxDrawingRes& rCtxDrawingRes, Resources void SysRender::update_draw_transforms_recurse( ACtxSceneGraph const& rScnGraph, KeyedVec const& activeToDraw, - acomp_storage_t const& rTf, + active::ACompTransformStorage_t const& rTf, DrawTransforms_t& rDrawTf, ActiveEntSet_t const& needDrawTf, ActiveEnt ent, diff --git a/src/osp/Active/SysRender.h b/src/osp/drawing/drawing_fn.h similarity index 82% rename from src/osp/Active/SysRender.h rename to src/osp/drawing/drawing_fn.h index f6a5ecdc..a52217b3 100644 --- a/src/osp/Active/SysRender.h +++ b/src/osp/drawing/drawing_fn.h @@ -25,11 +25,12 @@ #pragma once #include "drawing.h" -#include "basic.h" + +#include "../activescene/basic.h" #include -namespace osp::active +namespace osp::draw { /** @@ -89,8 +90,7 @@ struct EntityToDraw */ struct RenderGroup { - using Storage_t = entt::basic_storage; - using ArrayView_t = Corrade::Containers::ArrayView; + using DrawEnts_t = Storage_t; /** * @return Iterable view for stored entities @@ -108,7 +108,7 @@ struct RenderGroup return entt::basic_view{m_entities}; } - Storage_t m_entities; + DrawEnts_t m_entities; }; // struct RenderGroup @@ -153,18 +153,13 @@ class SysRender ACtxDrawingRes& rCtxDrawingRes, Resources& rResources); - - template - static void assure_draw_transforms( - acomp_storage_t& rDrawTf, ITA_T first, ITB_T const& last); - template static void update_draw_transforms( - ACtxSceneGraph const& rScnGraph, - KeyedVec const& activeToDraw, - acomp_storage_t const& transform, + active::ACtxSceneGraph const& rScnGraph, + KeyedVec const& activeToDraw, + active::ACompTransformStorage_t const& transform, DrawTransforms_t& rDrawTf, - ActiveEntSet_t const& useDrawTf, + active::ActiveEntSet_t const& useDrawTf, IT_T first, ITB_T const& last); @@ -185,38 +180,24 @@ class SysRender private: static void update_draw_transforms_recurse( - ACtxSceneGraph const& rScnGraph, - KeyedVec const& activeToDraw, - acomp_storage_t const& rTf, + active::ACtxSceneGraph const& rScnGraph, + KeyedVec const& activeToDraw, + active::ACompTransformStorage_t const& rTf, DrawTransforms_t& rDrawTf, - ActiveEntSet_t const& useDrawTf, - ActiveEnt ent, + active::ActiveEntSet_t const& useDrawTf, + active::ActiveEnt ent, Matrix4 const& parentTf, bool root); }; // class SysRender -template -void SysRender::assure_draw_transforms( - acomp_storage_t& rDrawTf, ITA_T first, ITB_T const& last) -{ - while (first != last) - { - if ( ! rDrawTf.contains(*first)) - { - rDrawTf.emplace(*first); - } - std::advance(first, 1); - } -} - template void SysRender::update_draw_transforms( - ACtxSceneGraph const& rScnGraph, - KeyedVec const& activeToDraw, - acomp_storage_t const& rTf, + active::ACtxSceneGraph const& rScnGraph, + KeyedVec const& activeToDraw, + active::ACompTransformStorage_t const& rTf, DrawTransforms_t& rDrawTf, - ActiveEntSet_t const& needDrawTf, + active::ActiveEntSet_t const& needDrawTf, IT_T first, ITB_T const& last) { @@ -263,6 +244,4 @@ constexpr decltype(auto) SysRender::gen_drawable_mesh_adder(ACtxDrawing& rDrawin }; } - - -} // namespace osp::active +} // namespace osp::draw diff --git a/src/adera/wiretypes.h b/src/osp/drawing/own_restypes.h similarity index 53% rename from src/adera/wiretypes.h rename to src/osp/drawing/own_restypes.h index 1ae17bbd..938d82fd 100644 --- a/src/adera/wiretypes.h +++ b/src/osp/drawing/own_restypes.h @@ -1,6 +1,6 @@ /** * Open Space Program - * Copyright © 2019-2020 Open Space Program Project + * Copyright © 2019-2023 Open Space Program Project * * MIT License * @@ -24,46 +24,20 @@ */ #pragma once -#include +#include "../core/resourcetypes.h" -namespace adera::wire +namespace osp { - /** - * Rotation command with pitch, yaw and roll components - */ - struct AttitudeControl - { - AttitudeControl() = default; - constexpr AttitudeControl(osp::Vector3 value) noexcept : m_attitude(value) { } - // each (-1.0 .. 1.0) - // pitch, yaw, roll - osp::Vector3 m_attitude; - - friend bool operator==(AttitudeControl const& lhs, AttitudeControl const& rhs) noexcept = default; - }; - - /** - * A percentage for something like throttle - */ - struct Percent - { - Percent() = default; - constexpr Percent(float value) noexcept : m_percent(value) { } - - float m_percent; - - friend constexpr bool operator==(Percent const& lhs, Percent const& rhs) noexcept = default; - }; +namespace restypes +{ - /** - * Boolean signal for logic gates - */ - struct Logic - { - bool m_value; - }; +inline ResTypeId const gc_image = ResTypeIdReg_t::create(); +inline ResTypeId const gc_texture = ResTypeIdReg_t::create(); +inline ResTypeId const gc_mesh = ResTypeIdReg_t::create(); -} // namespace wiretype +} // namespace restypes +struct TextureImgSource : public ResIdOwner_t { }; +} // namespace osp diff --git a/src/osp/Shaders/FullscreenTriShader.cpp b/src/osp/drawing_gl/FullscreenTriShader.cpp similarity index 96% rename from src/osp/Shaders/FullscreenTriShader.cpp rename to src/osp/drawing_gl/FullscreenTriShader.cpp index 71f0050d..50f82780 100644 --- a/src/osp/Shaders/FullscreenTriShader.cpp +++ b/src/osp/drawing_gl/FullscreenTriShader.cpp @@ -22,7 +22,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include +#include "FullscreenTriShader.h" + #include #include #include @@ -31,7 +32,7 @@ #include // for Containers::Iterable #include -using namespace osp::active; +using namespace osp; using namespace Magnum; FullscreenTriShader::FullscreenTriShader() diff --git a/src/osp/Shaders/FullscreenTriShader.h b/src/osp/drawing_gl/FullscreenTriShader.h similarity index 97% rename from src/osp/Shaders/FullscreenTriShader.h rename to src/osp/drawing_gl/FullscreenTriShader.h index c08505eb..baca9e3a 100644 --- a/src/osp/Shaders/FullscreenTriShader.h +++ b/src/osp/drawing_gl/FullscreenTriShader.h @@ -27,7 +27,7 @@ #include #include -namespace osp::active +namespace osp { class FullscreenTriShader : public Magnum::GL::AbstractShaderProgram @@ -74,4 +74,4 @@ class FullscreenTriShader : public Magnum::GL::AbstractShaderProgram FullscreenTriShader& set_framebuffer(Magnum::GL::Texture2D& rTex); }; -} // namespace osp::active +} // namespace osp diff --git a/src/osp/Active/opengl/SysRenderGL.cpp b/src/osp/drawing_gl/rendergl.cpp similarity index 97% rename from src/osp/Active/opengl/SysRenderGL.cpp rename to src/osp/drawing_gl/rendergl.cpp index f198cc05..bba5fa90 100644 --- a/src/osp/Active/opengl/SysRenderGL.cpp +++ b/src/osp/drawing_gl/rendergl.cpp @@ -23,14 +23,12 @@ * SOFTWARE. */ -#include "SysRenderGL.h" +#include "rendergl.h" +#include "FullscreenTriShader.h" -#include "../../Shaders/FullscreenTriShader.h" - -#include "../../Resource/resources.h" -#include "../../Resource/ImporterData.h" - -#include "../../logging.h" +#include "../core/Resources.h" +#include "../drawing/own_restypes.h" +#include "../util/logging.h" #include @@ -58,11 +56,11 @@ using Magnum::GL::Texture2D; using osp::ResId; -using osp::active::SysRenderGL; -using osp::active::RenderGL; +using osp::draw::SysRenderGL; +using osp::draw::RenderGL; -using osp::active::TexGlId; -using osp::active::MeshGlId; +using osp::draw::TexGlId; +using osp::draw::MeshGlId; void SysRenderGL::setup_context(RenderGL& rCtxGl) { diff --git a/src/osp/Active/opengl/SysRenderGL.h b/src/osp/drawing_gl/rendergl.h similarity index 96% rename from src/osp/Active/opengl/SysRenderGL.h rename to src/osp/drawing_gl/rendergl.h index eeb6d2dc..d42969eb 100644 --- a/src/osp/Active/opengl/SysRenderGL.h +++ b/src/osp/drawing_gl/rendergl.h @@ -24,9 +24,9 @@ */ #pragma once -#include "../SysRender.h" -#include "../../id_map.h" -#include "../../Shaders/FullscreenTriShader.h" +#include "FullscreenTriShader.h" + +#include "../drawing/drawing_fn.h" #include #include @@ -38,14 +38,14 @@ #include -namespace osp::active +namespace osp::draw { enum class TexGlId : uint32_t { }; enum class MeshGlId : uint32_t { }; -using TexGlStorage_t = entt::basic_storage; -using MeshGlStorage_t = entt::basic_storage; +using TexGlStorage_t = Storage_t; +using MeshGlStorage_t = Storage_t; /** * @brief Main renderer state and essential GL resources @@ -253,6 +253,4 @@ class SysRenderGL }; - - -} +} // namespace osp::draw diff --git a/src/osp/link/machines.h b/src/osp/link/machines.h index 629208a8..dc19111b 100644 --- a/src/osp/link/machines.h +++ b/src/osp/link/machines.h @@ -24,9 +24,9 @@ */ #pragma once -#include "../global_id.h" -#include "../bitvector.h" -#include "../types.h" +#include "../core/global_id.h" +#include "../core/bitvector.h" +#include "../core/array_view.h" #include #include diff --git a/src/osp/PhysicsConstants.h b/src/osp/scientific/constants.h similarity index 100% rename from src/osp/PhysicsConstants.h rename to src/osp/scientific/constants.h diff --git a/src/osp/CommonPhysics.cpp b/src/osp/scientific/shapes.cpp similarity index 89% rename from src/osp/CommonPhysics.cpp rename to src/osp/scientific/shapes.cpp index fa0aab9a..2ebc5ea6 100644 --- a/src/osp/CommonPhysics.cpp +++ b/src/osp/scientific/shapes.cpp @@ -23,14 +23,11 @@ * SOFTWARE. */ -#include "CommonPhysics.h" - - -#include +#include "shapes.h" #include -namespace osp::phys +namespace osp { float shape_volume(EShape shape, Vector3 scale) @@ -50,8 +47,6 @@ float shape_volume(EShape shape, Vector3 scale) // Default radius: 1, default height: 2 return sc_pi * scale.x() * scale.x() * 2.0f*scale.z(); default: - SPDLOG_LOGGER_ERROR(spdlog::get("application"), "Unsupported shape for volume calc"); - assert(false); return 0.0f; } } @@ -98,11 +93,8 @@ Vector3 collider_inertia_tensor(EShape shape, Vector3 scale, float mass) case EShape::Capsule: default: - SPDLOG_LOGGER_ERROR(spdlog::get("application"), - "ERROR: unknown collision shape"); - assert(false); return Vector3{0.0f}; } } -} // namespace osp::phys +} // namespace osp diff --git a/src/osp/CommonPhysics.h b/src/osp/scientific/shapes.h similarity index 98% rename from src/osp/CommonPhysics.h rename to src/osp/scientific/shapes.h index c04fb420..034a1d05 100644 --- a/src/osp/CommonPhysics.h +++ b/src/osp/scientific/shapes.h @@ -24,9 +24,9 @@ */ #pragma once -#include "types.h" +#include "../core/math_types.h" -namespace osp::phys +namespace osp { /** @@ -165,4 +165,4 @@ constexpr Vector3 ellipsoid_inertia_tensor(const Vector3 semiaxes, float mass) n return Vector3{c*xx, c*yy, c*zz}; } -} // namespace osp::phys +} // namespace osp diff --git a/src/osp/tasks/builder.h b/src/osp/tasks/builder.h index 3bd2a794..36104091 100644 --- a/src/osp/tasks/builder.h +++ b/src/osp/tasks/builder.h @@ -25,7 +25,6 @@ #pragma once #include "tasks.h" -#include "../types.h" #include #include diff --git a/src/osp/tasks/execute.h b/src/osp/tasks/execute.h index c79400cb..4ea5c242 100644 --- a/src/osp/tasks/execute.h +++ b/src/osp/tasks/execute.h @@ -27,7 +27,7 @@ #include "tasks.h" #include "worker.h" -#include "../bitvector.h" +#include "../core/bitvector.h" #include diff --git a/src/osp/tasks/tasks.cpp b/src/osp/tasks/tasks.cpp index 535c4437..e0933010 100644 --- a/src/osp/tasks/tasks.cpp +++ b/src/osp/tasks/tasks.cpp @@ -24,7 +24,7 @@ */ #include "tasks.h" -#include "../bitvector.h" +#include "../core/bitvector.h" #include diff --git a/src/osp/tasks/tasks.h b/src/osp/tasks/tasks.h index 957f262a..2fd9a838 100644 --- a/src/osp/tasks/tasks.h +++ b/src/osp/tasks/tasks.h @@ -24,8 +24,8 @@ */ #pragma once -#include "../keyed_vector.h" -#include "../types.h" +#include "../core/array_view.h" +#include "../core/keyed_vector.h" #include #include diff --git a/src/osp/tasks/top_session.h b/src/osp/tasks/top_session.h index 0a882099..855b1b20 100644 --- a/src/osp/tasks/top_session.h +++ b/src/osp/tasks/top_session.h @@ -27,6 +27,8 @@ #include "tasks.h" #include "top_utils.h" +#include "../core/unpack.h" + #include #include @@ -35,8 +37,6 @@ #include #include -#include - #define OSP_AUX_DCDI_C(session, topData, count, ...) \ session.m_data.resize(count); \ osp::top_reserve(topData, 0, session.m_data.begin(), session.m_data.end()); \ @@ -57,8 +57,6 @@ #define OSP_DECLARE_GET_DATA_IDS(session, arglist) OSP_AUX_DGDI_A(session, arglist); - - namespace osp { diff --git a/src/osp/tasks/top_worker.h b/src/osp/tasks/top_worker.h index 8b647f8b..952dba4c 100644 --- a/src/osp/tasks/top_worker.h +++ b/src/osp/tasks/top_worker.h @@ -26,7 +26,7 @@ #include "worker.h" -#include "../types.h" +#include "../core/array_view.h" #include diff --git a/src/osp/universe/coordinates.h b/src/osp/universe/coordinates.h index 7e9ab72e..52c9c038 100644 --- a/src/osp/universe/coordinates.h +++ b/src/osp/universe/coordinates.h @@ -25,8 +25,8 @@ #pragma once #include "universe.h" -#include "../types.h" -#include "../CommonMath.h" + +#include "../core/math_2pow.h" namespace osp::universe { diff --git a/src/osp/universe/universe.h b/src/osp/universe/universe.h index d4c3c1d3..a1e781e6 100644 --- a/src/osp/universe/universe.h +++ b/src/osp/universe/universe.h @@ -24,7 +24,7 @@ */ #pragma once -#include "../types.h" +#include "../core/math_types.h" #include "universetypes.h" #include diff --git a/src/osp/UserInputHandler.cpp b/src/osp/util/UserInputHandler.cpp similarity index 99% rename from src/osp/UserInputHandler.cpp rename to src/osp/util/UserInputHandler.cpp index 38c475ac..ce5d9288 100644 --- a/src/osp/UserInputHandler.cpp +++ b/src/osp/util/UserInputHandler.cpp @@ -23,7 +23,8 @@ * SOFTWARE. */ #include "UserInputHandler.h" -#include "string_concat.h" + +#include "../core/string_concat.h" #include "logging.h" #include diff --git a/src/osp/UserInputHandler.h b/src/osp/util/UserInputHandler.h similarity index 99% rename from src/osp/UserInputHandler.h rename to src/osp/util/UserInputHandler.h index f1663d78..035c393e 100644 --- a/src/osp/UserInputHandler.h +++ b/src/osp/util/UserInputHandler.h @@ -24,6 +24,9 @@ */ #pragma once +#include "../core/array_view.h" +#include "../core/math_types.h" + #include #include #include @@ -32,8 +35,6 @@ #include #include -#include "types.h" - namespace osp::input { diff --git a/src/osp/logging.h b/src/osp/util/logging.h similarity index 100% rename from src/osp/logging.h rename to src/osp/util/logging.h diff --git a/src/osp/Resource/ImporterData.h b/src/osp/vehicles/ImporterData.h similarity index 94% rename from src/osp/Resource/ImporterData.h rename to src/osp/vehicles/ImporterData.h index 5d50e761..85c7513b 100644 --- a/src/osp/Resource/ImporterData.h +++ b/src/osp/vehicles/ImporterData.h @@ -24,9 +24,11 @@ */ #pragma once -#include "../types.h" -#include "../CommonPhysics.h" -#include "resourcetypes.h" +#include "prefabs.h" + +#include "../core/resourcetypes.h" +#include "../scientific/shapes.h" + #include #include @@ -42,8 +44,6 @@ namespace osp { -struct TextureImgSource : public ResIdOwner_t { }; - /** * @brief Describes a set of scene graphs that share data with each other * @@ -92,7 +92,7 @@ struct Prefabs // Points to ImporterData::m_objNames std::vector m_prefabNames; - std::vector m_objShape; + std::vector m_objShape; std::vector m_objMass; }; diff --git a/src/osp/Resource/blueprints.h b/src/osp/vehicles/blueprints.h similarity index 98% rename from src/osp/Resource/blueprints.h rename to src/osp/vehicles/blueprints.h index a71ea915..9baab6a9 100644 --- a/src/osp/Resource/blueprints.h +++ b/src/osp/vehicles/blueprints.h @@ -24,13 +24,13 @@ */ #pragma once -#include "../types.h" - -#include "resources.h" +#include "../core/math_types.h" +#include "../core/resourcetypes.h" namespace osp { + struct BlueprintMachine { //NodeMap_t m_config; diff --git a/src/osp/Resource/load_tinygltf.cpp b/src/osp/vehicles/load_tinygltf.cpp similarity index 98% rename from src/osp/Resource/load_tinygltf.cpp rename to src/osp/vehicles/load_tinygltf.cpp index 3de1dbec..b8074214 100644 --- a/src/osp/Resource/load_tinygltf.cpp +++ b/src/osp/vehicles/load_tinygltf.cpp @@ -24,12 +24,11 @@ */ #include "load_tinygltf.h" - #include "ImporterData.h" -#include "resources.h" -#include "../logging.h" -#include "../string_concat.h" +#include "../core/Resources.h" +#include "../drawing/own_restypes.h" +#include "../util/logging.h" #include #include @@ -351,10 +350,8 @@ ResId osp::load_tinygltf_file(std::string_view filepath, Resources &rResources, return res; } -static phys::EShape shape_from_name(std::string_view name) noexcept +static EShape shape_from_name(std::string_view name) noexcept { - using phys::EShape; - if (name == "cube") { return EShape::Box; } else if (name == "cylinder") { return EShape::Cylinder; } @@ -389,7 +386,7 @@ void osp::assigns_prefabs_tinygltf(Resources &rResources, ResId importer) int const objCount = pImportData->m_objParents.size(); rPrefabs.m_objMass .resize(objCount, 0.0f); - rPrefabs.m_objShape .resize(objCount, phys::EShape::None); + rPrefabs.m_objShape .resize(objCount, EShape::None); rPrefabs.m_prefabs .data_reserve(objCount); rPrefabs.m_prefabs .ids_reserve(topLevelSpan.size()); diff --git a/src/osp/Resource/load_tinygltf.h b/src/osp/vehicles/load_tinygltf.h similarity index 97% rename from src/osp/Resource/load_tinygltf.h rename to src/osp/vehicles/load_tinygltf.h index 79cc1192..ec015ecd 100644 --- a/src/osp/Resource/load_tinygltf.h +++ b/src/osp/vehicles/load_tinygltf.h @@ -24,7 +24,7 @@ */ #pragma once -#include "resourcetypes.h" +#include "../core/resourcetypes.h" #include diff --git a/src/test_application/executor.h b/src/osp/vehicles/prefabs.h similarity index 67% rename from src/test_application/executor.h rename to src/osp/vehicles/prefabs.h index 9099b50d..116047f0 100644 --- a/src/test_application/executor.h +++ b/src/osp/vehicles/prefabs.h @@ -24,31 +24,27 @@ */ #pragma once -#include "testapp.h" +#include "../core/math_types.h" +#include "../core/resourcetypes.h" -#include - -#include - -namespace testapp +namespace osp { -struct SingleThreadedExecutor final : public IExecutor +namespace restypes { - void load(TestAppTasks& rAppTasks) override; - - void run(TestAppTasks& rAppTasks, osp::PipelineId pipeline) override; - void signal(TestAppTasks& rAppTasks, osp::PipelineId pipeline) override; +inline ResTypeId const gc_importer = ResTypeIdReg_t::create(); - void wait(TestAppTasks& rAppTasks) override; +} // namespace restypes - bool is_running(TestAppTasks const& rAppTasks) override; - osp::ExecContext m_execContext; +using ObjId = int32_t; +using PrefabId = uint32_t; - std::shared_ptr m_log; +struct PrefabPair +{ + ResIdOwner_t m_importer; + PrefabId m_prefabId; }; -} // namespace testapp - +} // namespace osp diff --git a/src/newtondynamics_physics/factors.h b/src/ospnewton/activescene/forcefactors.h similarity index 100% rename from src/newtondynamics_physics/factors.h rename to src/ospnewton/activescene/forcefactors.h diff --git a/src/newtondynamics_physics/ospnewton.h b/src/ospnewton/activescene/newtoninteg.h similarity index 88% rename from src/newtondynamics_physics/ospnewton.h rename to src/ospnewton/activescene/newtoninteg.h index ae267255..fb288d5c 100644 --- a/src/newtondynamics_physics/ospnewton.h +++ b/src/ospnewton/activescene/newtoninteg.h @@ -24,12 +24,11 @@ */ #pragma once -#include "factors.h" +#include "forcefactors.h" -#include -#include -#include -#include +#include +#include +#include #include @@ -59,6 +58,7 @@ using NwtColliderPtr_t = std::unique_ptr; /** * @brief Represents an instance of a Newton physics world in the scane @@ -88,7 +88,7 @@ struct ACtxNwtWorld // note: important that m_nwtBodies and m_nwtColliders are destructed // before m_nwtWorld - std::unique_ptr m_world; + std::unique_ptr m_world; lgrn::IdRegistryStl m_bodyIds; std::vector m_bodyPtrs; @@ -100,9 +100,9 @@ struct ACtxNwtWorld std::vector m_factors; - osp::active::acomp_storage_t m_colliders; + ColliderStorage_t m_colliders; - osp::active::acomp_storage_t *m_pTransform; + osp::active::ACompTransformStorage_t *m_pTransform; }; diff --git a/src/newtondynamics_physics/SysNewton.cpp b/src/ospnewton/activescene/newtoninteg_fn.cpp similarity index 89% rename from src/newtondynamics_physics/SysNewton.cpp rename to src/ospnewton/activescene/newtoninteg_fn.cpp index 0866b8a0..ee7e640c 100644 --- a/src/newtondynamics_physics/SysNewton.cpp +++ b/src/ospnewton/activescene/newtoninteg_fn.cpp @@ -23,22 +23,9 @@ * SOFTWARE. */ -#include "SysNewton.h" // IWYU pragma: associated -#include "ospnewton.h" +#include "newtoninteg_fn.h" // IWYU pragma: associated -#include // for ACompHierarchy -#include // for ACompRigidBody -#include // for SysPhysics -#include // for SysSceneGraph -#include // for ActiveReg_t - -#include - -#include // for Matrix4, Vector3 -#include // for ECollisionShape - -#include // for entt::sink -#include // for entt::null, entt::null_t +#include #include // for NewtonBodySetCollision @@ -53,13 +40,10 @@ using namespace ospnewton; // for the 0xrrggbb_rgbf and angle literals using namespace Magnum::Math::Literals; -using osp::phys::EShape; - -using osp::active::acomp_storage_t; +using osp::EShape; using osp::active::ActiveEnt; using osp::active::ACtxPhysics; -using osp::active::SysPhysics; using osp::active::SysSceneGraph; using osp::Matrix3; @@ -137,7 +121,7 @@ NwtColliderPtr_t SysNewton::create_primative( void SysNewton::orient_collision( NewtonCollision const* pCollision, - osp::phys::EShape shape, + osp::EShape shape, osp::Vector3 const& translation, osp::Matrix3 const& rotation, osp::Vector3 const& scale) @@ -185,11 +169,11 @@ void SysNewton::update_translate(ACtxPhysics& rCtxPhys, ACtxNwtWorld& rCtxWorld) using Corrade::Containers::ArrayView; void SysNewton::update_world( - ACtxPhysics& rCtxPhys, - ACtxNwtWorld& rCtxWorld, - float timestep, - ACtxSceneGraph const& rScnGraph, - acomp_storage_t& rTf) noexcept + ACtxPhysics& rCtxPhys, + ACtxNwtWorld& rCtxWorld, + float timestep, + ACtxSceneGraph const& rScnGraph, + ACompTransformStorage_t& rTf) noexcept { NewtonWorld const* pNwtWorld = rCtxWorld.m_world.get(); @@ -228,7 +212,7 @@ void SysNewton::find_colliders_recurse( ACtxPhysics const& rCtxPhys, ACtxNwtWorld& rCtxWorld, ACtxSceneGraph const& rScnGraph, - acomp_storage_t const& rTf, + ACompTransformStorage_t const& rTf, ActiveEnt ent, Matrix4 const& transform, NewtonCollision* pCompound) noexcept diff --git a/src/newtondynamics_physics/SysNewton.h b/src/ospnewton/activescene/newtoninteg_fn.h similarity index 88% rename from src/newtondynamics_physics/SysNewton.h rename to src/ospnewton/activescene/newtoninteg_fn.h index eccce70e..641d6a47 100644 --- a/src/newtondynamics_physics/SysNewton.h +++ b/src/ospnewton/activescene/newtoninteg_fn.h @@ -24,13 +24,10 @@ */ #pragma once -#include "ospnewton.h" +#include "newtoninteg.h" -#include // for ACompShape -#include // for ActiveEnt, ActiveReg_t, basic_sp... - -#include // for Vector3, Matrix4 -#include // for ECollisionShape, ECollisionShape... +#include +#include #include @@ -45,13 +42,11 @@ namespace ospnewton class SysNewton { - template - using acomp_storage_t = osp::active::acomp_storage_t; - using ActiveEnt = osp::active::ActiveEnt; using ACtxPhysics = osp::active::ACtxPhysics; using ACtxSceneGraph = osp::active::ACtxSceneGraph; using ACompTransform = osp::active::ACompTransform; + using ACompTransformStorage_t = osp::active::ACompTransformStorage_t; public: using NwtThreadIndex_t = int; @@ -64,12 +59,12 @@ class SysNewton [[nodiscard]] static NwtColliderPtr_t create_primative( ACtxNwtWorld& rCtxWorld, - osp::phys::EShape shape); + osp::EShape shape); static void orient_collision( NewtonCollision const* pCollision, - osp::phys::EShape shape, + osp::EShape shape, osp::Vector3 const& translation, osp::Matrix3 const& rotation, osp::Vector3 const& scale); @@ -109,11 +104,11 @@ class SysNewton * @param rTfMutable [ref] Flags for mutable transforms */ static void update_world( - ACtxPhysics& rCtxPhys, - ACtxNwtWorld& rCtxWorld, - float timestep, - ACtxSceneGraph const& rScnGraph, - acomp_storage_t& rTf) noexcept; + ACtxPhysics& rCtxPhys, + ACtxNwtWorld& rCtxWorld, + float timestep, + ACtxSceneGraph const& rScnGraph, + osp::active::ACompTransformStorage_t& rTf) noexcept; static void remove_components( ACtxNwtWorld& rCtxWorld, ActiveEnt ent) noexcept; @@ -162,7 +157,7 @@ class SysNewton ACtxPhysics const& rCtxPhys, ACtxNwtWorld& rCtxWorld, ACtxSceneGraph const& rScnGraph, - acomp_storage_t const& rTf, + ACompTransformStorage_t const& rTf, ActiveEnt ent, osp::Matrix4 const& transform, NewtonCollision* pCompound) noexcept; diff --git a/src/planet-a/SubdivTriangleMesh.h b/src/planet-a/SubdivTriangleMesh.h index f9366aa2..bdf63081 100644 --- a/src/planet-a/SubdivTriangleMesh.h +++ b/src/planet-a/SubdivTriangleMesh.h @@ -26,7 +26,7 @@ #include "SubdivSkeleton.h" -#include +#include #include #include diff --git a/src/planet-a/icosahedron.h b/src/planet-a/icosahedron.h index 2cdea2c3..247116fd 100644 --- a/src/planet-a/icosahedron.h +++ b/src/planet-a/icosahedron.h @@ -26,7 +26,7 @@ #include "SubdivSkeleton.h" -#include +#include #include diff --git a/src/test_application/activescenes/scene_common.cpp b/src/test_application/activescenes/scene_common.cpp deleted file mode 100644 index afa81cc7..00000000 --- a/src/test_application/activescenes/scene_common.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/** - * Open Space Program - * Copyright © 2019-2022 Open Space Program Project - * - * MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "scene_common.h" -#include "scenarios.h" - -#include -#include - -#include -#include - -#include - -#include - -using namespace osp; -using namespace osp::active; - -namespace testapp::scenes -{ - -Session setup_scene( - TopTaskBuilder& rBuilder, - ArrayView const topData, - Session const& application) -{ - OSP_DECLARE_GET_DATA_IDS(application, TESTAPP_DATA_APPLICATION); - auto const tgApp = application.get_pipelines< PlApplication >(); - - osp::Session out; - OSP_DECLARE_CREATE_DATA_IDS(out, topData, TESTAPP_DATA_SCENE); - - top_emplace< float >(topData, idDeltaTimeIn, 1.0f / 60.0f); - - auto const plScn = out.create_pipelines(rBuilder); - - rBuilder.pipeline(plScn.update).parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); - - rBuilder.task() - .name ("Schedule Scene update") - .schedules ({plScn.update(Schedule)}) - .push_to (out.m_tasks) - .args ({ idMainLoopCtrl}) - .func([] (MainLoopControl const& rMainLoopCtrl) noexcept -> osp::TaskActions - { - return rMainLoopCtrl.doUpdate ? osp::TaskActions{} : osp::TaskAction::Cancel; - }); - - return out; -} - -Session setup_common_scene( - TopTaskBuilder& rBuilder, - ArrayView const topData, - Session const& scene, - Session const& application, - PkgId const pkg) -{ - OSP_DECLARE_GET_DATA_IDS(application, TESTAPP_DATA_APPLICATION); - - auto const tgScn = scene.get_pipelines(); - auto &rResources = top_get< Resources > (topData, idResources); - - Session out; - OSP_DECLARE_CREATE_DATA_IDS(out, topData, TESTAPP_DATA_COMMON_SCENE); - auto const tgCS = out.create_pipelines(rBuilder); - - out.m_cleanup = tgScn.cleanup; - - /* unused */ top_emplace< ActiveEntVec_t > (topData, idActiveEntDel); - /* unused */ top_emplace< DrawEntVec_t > (topData, idDrawEntDel); - auto &rBasic = top_emplace< ACtxBasic > (topData, idBasic); - auto &rDrawing = top_emplace< ACtxDrawing > (topData, idDrawing); - auto &rDrawingRes = top_emplace< ACtxDrawingRes > (topData, idDrawingRes); - auto &rNMesh = top_emplace< NamedMeshes > (topData, idNMesh); - - rBuilder.pipeline(tgCS.activeEnt) .parent(tgScn.update); - rBuilder.pipeline(tgCS.activeEntResized) .parent(tgScn.update); - rBuilder.pipeline(tgCS.activeEntDelete) .parent(tgScn.update); - rBuilder.pipeline(tgCS.transform) .parent(tgScn.update); - rBuilder.pipeline(tgCS.hierarchy) .parent(tgScn.update); - - - - rBuilder.task() - .name ("Cancel entity delete tasks stuff if no entities were deleted") - .run_on ({tgCS.activeEntDelete(Schedule_)}) - .push_to (out.m_tasks) - .args ({ idBasic, idActiveEntDel }) - .func([] (ACtxBasic& rBasic, ActiveEntVec_t const& rActiveEntDel) noexcept - { - return rActiveEntDel.empty() ? TaskAction::Cancel : TaskActions{}; - }); - - rBuilder.task() - .name ("Delete ActiveEnt IDs") - .run_on ({tgCS.activeEntDelete(EStgIntr::UseOrRun)}) - .sync_with ({tgCS.activeEnt(Delete)}) - .push_to (out.m_tasks) - .args ({ idBasic, idActiveEntDel }) - .func([] (ACtxBasic& rBasic, ActiveEntVec_t const& rActiveEntDel) noexcept - { - for (ActiveEnt const ent : rActiveEntDel) - { - if (rBasic.m_activeIds.exists(ent)) - { - rBasic.m_activeIds.remove(ent); - } - } - }); - - rBuilder.task() - .name ("Delete basic components") - .run_on ({tgCS.activeEntDelete(UseOrRun)}) - .sync_with ({tgCS.transform(Delete)}) - .push_to (out.m_tasks) - .args ({ idBasic, idActiveEntDel }) - .func([] (ACtxBasic& rBasic, ActiveEntVec_t const& rActiveEntDel) noexcept - { - update_delete_basic(rBasic, rActiveEntDel.cbegin(), rActiveEntDel.cend()); - }); - - rBuilder.task() - .name ("Clear ActiveEnt delete vector once we're done with it") - .run_on ({tgCS.activeEntDelete(Clear)}) - .push_to (out.m_tasks) - .args ({ idActiveEntDel }) - .func([] (ActiveEntVec_t& idActiveEntDel) noexcept - { - idActiveEntDel.clear(); - }); - - - // Clean up tasks - - rBuilder.task() - .name ("Clean up resource owners") - .run_on ({tgScn.cleanup(Run_)}) - .push_to (out.m_tasks) - .args ({ idDrawing, idDrawingRes, idResources}) - .func([] (ACtxDrawing& rDrawing, ACtxDrawingRes& rDrawingRes, Resources& rResources) noexcept - { - SysRender::clear_resource_owners(rDrawingRes, rResources); - }); - - rBuilder.task() - .name ("Clean up NamedMeshes mesh and texture owners") - .run_on ({tgScn.cleanup(Run_)}) - .push_to (out.m_tasks) - .args ({ idDrawing, idNMesh }) - .func([] (ACtxDrawing& rDrawing, NamedMeshes& rNMesh) noexcept - { - for ([[maybe_unused]] auto && [_, rOwner] : std::exchange(rNMesh.m_shapeToMesh, {})) - { - rDrawing.m_meshRefCounts.ref_release(std::move(rOwner)); - } - - for ([[maybe_unused]] auto && [_, rOwner] : std::exchange(rNMesh.m_namedMeshs, {})) - { - rDrawing.m_meshRefCounts.ref_release(std::move(rOwner)); - } - }); - - // Convenient functor to get a reference-counted mesh owner - auto const quick_add_mesh = SysRender::gen_drawable_mesh_adder(rDrawing, rDrawingRes, rResources, pkg); - - // Acquire mesh resources from Package - using osp::phys::EShape; - rNMesh.m_shapeToMesh.emplace(EShape::Box, quick_add_mesh("cube")); - rNMesh.m_shapeToMesh.emplace(EShape::Cylinder, quick_add_mesh("cylinder")); - rNMesh.m_shapeToMesh.emplace(EShape::Sphere, quick_add_mesh("sphere")); - rNMesh.m_namedMeshs.emplace("floor", quick_add_mesh("grid64solid")); - - return out; -} - -} // namespace testapp::scenes diff --git a/src/test_application/executor.cpp b/src/test_application/executor.cpp deleted file mode 100644 index 09ae3128..00000000 --- a/src/test_application/executor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Open Space Program - * Copyright © 2019-2023 Open Space Program Project - * - * MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "executor.h" - -#include - -#include - -namespace testapp -{ - -void SingleThreadedExecutor::load(TestAppTasks& rAppTasks) -{ - osp::exec_conform(rAppTasks.m_tasks, m_execContext); - m_execContext.doLogging = m_log != nullptr; -} - -void SingleThreadedExecutor::run(TestAppTasks& rAppTasks, osp::PipelineId pipeline) -{ - osp::exec_request_run(m_execContext, pipeline); -} - -void SingleThreadedExecutor::signal(TestAppTasks& rAppTasks, osp::PipelineId pipeline) -{ - osp::exec_signal(m_execContext, pipeline); -} - -void SingleThreadedExecutor::wait(TestAppTasks& rAppTasks) -{ - if (m_log != nullptr) - { - m_log->info("\n>>>>>>>>>> Previous State Changes\n{}\n>>>>>>>>>> Current State\n{}\n", - osp::TopExecWriteLog {rAppTasks.m_tasks, rAppTasks.m_taskData, rAppTasks.m_graph, m_execContext}, - osp::TopExecWriteState{rAppTasks.m_tasks, rAppTasks.m_taskData, rAppTasks.m_graph, m_execContext} ); - m_execContext.logMsg.clear(); - } - - osp::exec_update(rAppTasks.m_tasks, rAppTasks.m_graph, m_execContext); - osp::top_run_blocking(rAppTasks.m_tasks, rAppTasks.m_graph, rAppTasks.m_taskData, rAppTasks.m_topData, m_execContext); - - if (m_log != nullptr) - { - m_log->info("\n>>>>>>>>>> New State Changes\n{}", - osp::TopExecWriteLog{rAppTasks.m_tasks, rAppTasks.m_taskData, rAppTasks.m_graph, m_execContext} ); - m_execContext.logMsg.clear(); - } -} - -bool SingleThreadedExecutor::is_running(TestAppTasks const& appTasks) -{ - return m_execContext.hasRequestRun || (m_execContext.pipelinesRunning != 0); -} - -} // namespace testapp diff --git a/src/test_application/MagnumApplication.cpp b/src/testapp/MagnumApplication.cpp similarity index 99% rename from src/test_application/MagnumApplication.cpp rename to src/testapp/MagnumApplication.cpp index f3988032..a579b4ac 100644 --- a/src/test_application/MagnumApplication.cpp +++ b/src/testapp/MagnumApplication.cpp @@ -24,7 +24,6 @@ */ #include "MagnumApplication.h" -#include "osp/types.h" #include #include diff --git a/src/test_application/MagnumApplication.h b/src/testapp/MagnumApplication.h similarity index 97% rename from src/test_application/MagnumApplication.h rename to src/testapp/MagnumApplication.h index 05adeb4e..c4f01318 100644 --- a/src/test_application/MagnumApplication.h +++ b/src/testapp/MagnumApplication.h @@ -24,10 +24,9 @@ */ #pragma once -#include "activescenes/scenarios.h" +#include "scenarios.h" -#include -#include +#include #include diff --git a/src/test_application/README.md b/src/testapp/README.md similarity index 100% rename from src/test_application/README.md rename to src/testapp/README.md diff --git a/src/test_application/activescenes/scenarios_enginetest.cpp b/src/testapp/enginetest.cpp similarity index 88% rename from src/test_application/activescenes/scenarios_enginetest.cpp rename to src/testapp/enginetest.cpp index fb9c193d..8cb7664a 100644 --- a/src/test_application/activescenes/scenarios_enginetest.cpp +++ b/src/testapp/enginetest.cpp @@ -22,21 +22,17 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "CameraController.h" +#include "MagnumApplication.h" -#include "../MagnumApplication.h" +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include - -#include - -#include - -#include +#include +#include #include #include @@ -45,13 +41,15 @@ #include +using Magnum::Trade::ImageData2D; +using Magnum::Trade::MeshData; +using adera::ACtxCameraController; +using adera::SysCameraController; using osp::active::ActiveEnt; -using osp::active::RenderGL; +using osp::draw::DrawEnt; +using osp::draw::RenderGL; using osp::input::UserInputHandler; -using Magnum::Trade::MeshData; -using Magnum::Trade::ImageData2D; - // for the 0xrrggbb_rgbf and angle literals using namespace Magnum::Math::Literals; @@ -71,18 +69,24 @@ struct EngineTestScene // Global Resources, owned by the top-level application // Note that multiple scenes are intended to be supported - osp::Resources *m_pResources; + osp::Resources *m_pResources; - // ID registry generates entity IDs, and keeps track of which ones exist + // Tracks used/free unique 'Active Entity' IDs, starts from zero and counts up lgrn::IdRegistryStl m_activeIds; // Supports transforms, hierarchy, cameras, and other components assignable // to ActiveEnts osp::active::ACtxBasic m_basic; - // Support for 'scene-space' meshes and textures, drawing components for - // ActiveEnt such as visible, opaque, and diffuse texture. - osp::active::ACtxDrawing m_drawing; + // The rotating cube + ActiveEnt m_cube{lgrn::id_null()}; + + + // Everything below is for rendering + + // Support for meshes and textures. This is intended to be shared across multiple scenes, but + // there is only one scene. + osp::draw::ACtxDrawing m_drawing; // Support for associating scene-space meshes/textures with Resources // Meshes/textures can span 3 different spaces, with their own ID types: @@ -90,17 +94,13 @@ struct EngineTestScene // * Renderer (MeshGlId/TexGlId) Shared between scenes, used by GPU // * Scene (MeshId/TexId) Local to one scene // ACtxDrawingRes is a two-way mapping between MeshId/TexId <--> ResId - osp::active::ACtxDrawingRes m_drawingRes; + osp::draw::ACtxDrawingRes m_drawingRes; - // The rotating cube - ActiveEnt m_cube{lgrn::id_null()}; - - // Set of ActiveEnts that are assigned a Phong material - osp::active::ActiveEntSet_t m_matPhong; - std::vector m_matPhongDirty; + // Set of DrawEnts that are assigned a Phong material + osp::draw::DrawEntSet_t m_matPhong; + std::vector m_matPhongDirty; - // This should be part of the renderer but who cares lol! - osp::active::ACtxSceneRender m_scnRdr; + osp::draw::ACtxSceneRender m_scnRdr; }; EngineTestScene::~EngineTestScene() @@ -113,13 +113,14 @@ EngineTestScene::~EngineTestScene() // single integer internally. // Cleanup must be manual, but this has the advantage of having no side // effects, and practically zero runtime overhead. - osp::active::SysRender::clear_owners(m_scnRdr, m_drawing); - osp::active::SysRender::clear_resource_owners(m_drawingRes, *m_pResources); + osp::draw::SysRender::clear_owners(m_scnRdr, m_drawing); + osp::draw::SysRender::clear_resource_owners(m_drawingRes, *m_pResources); } entt::any setup_scene(osp::Resources& rResources, osp::PkgId const pkg) { using namespace osp::active; + using namespace osp::draw; entt::any sceneAny = entt::make_any(); auto &rScene = entt::any_cast(sceneAny); @@ -207,18 +208,18 @@ struct EngineTestRenderer // Support for assigning render-space GL meshes/textures and transforms // for ActiveEnts - osp::active::ACtxSceneRenderGL m_sceneRenderGL{}; + osp::draw::ACtxSceneRenderGL m_sceneRenderGL{}; // Pre-built easy camera controls - osp::active::Camera m_cam; + osp::draw::Camera m_cam; ACtxCameraController m_camCtrl; // Phong shaders and their required data - osp::shader::ACtxDrawPhong m_phong{}; + adera::shader::ACtxDrawPhong m_phong{}; // An ordered set of entities and draw function pointers intended to be // forward-rendered - osp::active::RenderGroup m_groupFwdOpaque; + osp::draw::RenderGroup m_groupFwdOpaque; }; /** @@ -232,8 +233,8 @@ void sync_test_scene( RenderGL& rRenderGl, EngineTestScene& rScene, EngineTestRenderer& rRenderer) { - using namespace osp::active; - using namespace osp::shader; + using namespace osp::draw; + using namespace adera::shader; rScene.m_scnRdr.m_drawTransform .resize(rScene.m_scnRdr.m_drawIds.capacity()); rRenderer.m_sceneRenderGL.m_diffuseTexId.resize(rScene.m_scnRdr.m_drawIds.capacity()); @@ -297,7 +298,7 @@ void render_test_scene( RenderGL& rRenderGl, EngineTestScene const& rScene, EngineTestRenderer& rRenderer) { - using namespace osp::active; + using namespace osp::draw; using Magnum::GL::Framebuffer; using Magnum::GL::FramebufferClear; using Magnum::GL::Texture2D; @@ -352,7 +353,7 @@ class EngineTestApp : public IOspApplication void exit(MagnumApplication& rApp) override { - osp::active::SysRenderGL::clear_resource_owners(m_rRenderGl, *m_rScene.m_pResources); + osp::draw::SysRenderGL::clear_resource_owners(m_rRenderGl, *m_rScene.m_pResources); m_rRenderGl = {}; // clear all GPU resources } @@ -365,7 +366,8 @@ class EngineTestApp : public IOspApplication MagnumApplication::AppPtr_t generate_draw_func(EngineTestScene& rScene, MagnumApplication &rApp, RenderGL& rRenderGl, UserInputHandler& rUserInput) { using namespace osp::active; - using namespace osp::shader; + using namespace osp::draw; + using namespace adera::shader; auto pApp = std::make_unique(EngineTestRenderer{rUserInput}, rScene, rRenderGl); diff --git a/src/test_application/activescenes/scenarios_enginetest.h b/src/testapp/enginetest.h similarity index 91% rename from src/test_application/activescenes/scenarios_enginetest.h rename to src/testapp/enginetest.h index b3e48083..c1a29461 100644 --- a/src/test_application/activescenes/scenarios_enginetest.h +++ b/src/testapp/enginetest.h @@ -24,9 +24,9 @@ */ #pragma once -#include "../MagnumApplication.h" +#include "MagnumApplication.h" -#include +#include namespace testapp::enginetest { @@ -54,7 +54,7 @@ entt::any setup_scene(osp::Resources& rResources, osp::PkgId pkg); * * @return MagnumApplication draw function */ -MagnumApplication::AppPtr_t generate_draw_func(EngineTestScene& rScene, MagnumApplication& rApp, osp::active::RenderGL& rRenderGl, osp::input::UserInputHandler& rUserInput); +MagnumApplication::AppPtr_t generate_draw_func(EngineTestScene& rScene, MagnumApplication& rApp, osp::draw::RenderGL& rRenderGl, osp::input::UserInputHandler& rUserInput); } // namespace testapp::enginetest diff --git a/src/test_application/activescenes/identifiers.h b/src/testapp/identifiers.h similarity index 100% rename from src/test_application/activescenes/identifiers.h rename to src/testapp/identifiers.h diff --git a/src/test_application/main.cpp b/src/testapp/main.cpp similarity index 97% rename from src/test_application/main.cpp rename to src/testapp/main.cpp index ec16c614..97b61b6e 100644 --- a/src/test_application/main.cpp +++ b/src/testapp/main.cpp @@ -23,21 +23,20 @@ * SOFTWARE. */ #include "MagnumApplication.h" -#include "executor.h" #include "testapp.h" -#include "activescenes/scenarios.h" -#include "activescenes/identifiers.h" -#include "activescenes/scene_renderer.h" - -#include -#include -#include +#include "scenarios.h" +#include "identifiers.h" +#include "sessions/common.h" +#include "sessions/magnum.h" +#include +#include +#include #include - -#include -#include +#include +#include +#include #include #include diff --git a/src/test_application/activescenes/scenarios.cpp b/src/testapp/scenarios.cpp similarity index 96% rename from src/test_application/activescenes/scenarios.cpp rename to src/testapp/scenarios.cpp index 038110a9..ae0034fb 100644 --- a/src/test_application/activescenes/scenarios.cpp +++ b/src/testapp/scenarios.cpp @@ -24,28 +24,24 @@ */ #include "scenarios.h" -#include "scenarios_enginetest.h" +#include "enginetest.h" #include "identifiers.h" -#include "scene_common.h" -#include "scene_physics.h" -#include "scene_misc.h" -#include "scene_newton.h" -#include "scene_renderer.h" -#include "scene_universe.h" -#include "scene_vehicles.h" +#include "sessions/common.h" +#include "sessions/physics.h" +#include "sessions/misc.h" +#include "sessions/newton.h" +#include "sessions/magnum.h" +#include "sessions/universe.h" +//#include "sessions/vehicles.h" -#include "../MagnumApplication.h" -#include "../VehicleBuilder.h" - -#include -#include -#include -#include +#include "MagnumApplication.h" +//#include "../VehicleBuilder.h" +#include +#include #include - -#include +#include #include @@ -56,9 +52,9 @@ using namespace osp; namespace testapp { -static constexpr auto sc_matVisualizer = active::MaterialId(0); -static constexpr auto sc_matFlat = active::MaterialId(1); -static constexpr auto sc_matPhong = active::MaterialId(2); +static constexpr auto sc_matVisualizer = draw::MaterialId(0); +static constexpr auto sc_matFlat = draw::MaterialId(1); +static constexpr auto sc_matPhong = draw::MaterialId(2); static constexpr int sc_materialCount = 4; struct MainLoopSignals @@ -165,7 +161,7 @@ static void setup_magnum_draw(TestApp& rTestApp, Session const& scene, Session c auto &rMainLoopCtrl = top_get (rTestApp.m_topData, idMainLoopCtrl); auto &rActiveApp = top_get(rTestApp.m_topData, idActiveApp); - auto &rCamera = top_get (rTestApp.m_topData, idCamera); + auto &rCamera = top_get (rTestApp.m_topData, idCamera); rCamera.set_aspect_ratio(Vector2{Magnum::GL::defaultFramebuffer.viewport().size()}); @@ -216,7 +212,7 @@ static ScenarioMap_t make_scenarios() OSP_DECLARE_GET_DATA_IDS(rTestApp.m_magnum, TESTAPP_DATA_MAGNUM); OSP_DECLARE_GET_DATA_IDS(rTestApp.m_windowApp, TESTAPP_DATA_WINDOW_APP); auto &rActiveApp = top_get< MagnumApplication > (rTestApp.m_topData, idActiveApp); - auto &rRenderGl = top_get< active::RenderGL > (rTestApp.m_topData, idRenderGl); + auto &rRenderGl = top_get< draw::RenderGL > (rTestApp.m_topData, idRenderGl); auto &rUserInput = top_get< input::UserInputHandler >(rTestApp.m_topData, idUserInput); // Renderer state is stored as lambda capture diff --git a/src/test_application/activescenes/scenarios.h b/src/testapp/scenarios.h similarity index 98% rename from src/test_application/activescenes/scenarios.h rename to src/testapp/scenarios.h index 8a8eb8af..932f77a8 100644 --- a/src/test_application/activescenes/scenarios.h +++ b/src/testapp/scenarios.h @@ -25,8 +25,7 @@ #pragma once #include "identifiers.h" - -#include "../testapp.h" +#include "testapp.h" // IWYU pragma: begin_exports #include diff --git a/src/testapp/sessions/common.cpp b/src/testapp/sessions/common.cpp new file mode 100644 index 00000000..5ec59025 --- /dev/null +++ b/src/testapp/sessions/common.cpp @@ -0,0 +1,449 @@ +/** + * Open Space Program + * Copyright © 2019-2022 Open Space Program Project + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#include "common.h" +#include "../scenarios.h" + +#include +#include +#include +#include +#include +#include + +using namespace adera; +using namespace osp; +using namespace osp::active; +using namespace osp::draw; + +namespace testapp::scenes +{ + +Session setup_scene( + TopTaskBuilder& rBuilder, + ArrayView const topData, + Session const& application) +{ + OSP_DECLARE_GET_DATA_IDS(application, TESTAPP_DATA_APPLICATION); + auto const tgApp = application.get_pipelines< PlApplication >(); + + osp::Session out; + OSP_DECLARE_CREATE_DATA_IDS(out, topData, TESTAPP_DATA_SCENE); + + top_emplace< float >(topData, idDeltaTimeIn, 1.0f / 60.0f); + + auto const plScn = out.create_pipelines(rBuilder); + + rBuilder.pipeline(plScn.update).parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); + + rBuilder.task() + .name ("Schedule Scene update") + .schedules ({plScn.update(Schedule)}) + .push_to (out.m_tasks) + .args ({ idMainLoopCtrl}) + .func([] (MainLoopControl const& rMainLoopCtrl) noexcept -> osp::TaskActions + { + return rMainLoopCtrl.doUpdate ? osp::TaskActions{} : osp::TaskAction::Cancel; + }); + + return out; +} // setup_scene + + + + +Session setup_common_scene( + TopTaskBuilder& rBuilder, + ArrayView const topData, + Session const& scene, + Session const& application, + PkgId const pkg) +{ + OSP_DECLARE_GET_DATA_IDS(application, TESTAPP_DATA_APPLICATION); + + auto const tgScn = scene.get_pipelines(); + auto &rResources = top_get< Resources > (topData, idResources); + + Session out; + OSP_DECLARE_CREATE_DATA_IDS(out, topData, TESTAPP_DATA_COMMON_SCENE); + auto const tgCS = out.create_pipelines(rBuilder); + + out.m_cleanup = tgScn.cleanup; + + /* unused */ top_emplace< ActiveEntVec_t > (topData, idActiveEntDel); + /* unused */ top_emplace< DrawEntVec_t > (topData, idDrawEntDel); + auto &rBasic = top_emplace< ACtxBasic > (topData, idBasic); + auto &rDrawing = top_emplace< ACtxDrawing > (topData, idDrawing); + auto &rDrawingRes = top_emplace< ACtxDrawingRes > (topData, idDrawingRes); + auto &rNMesh = top_emplace< NamedMeshes > (topData, idNMesh); + + rBuilder.pipeline(tgCS.activeEnt) .parent(tgScn.update); + rBuilder.pipeline(tgCS.activeEntResized) .parent(tgScn.update); + rBuilder.pipeline(tgCS.activeEntDelete) .parent(tgScn.update); + rBuilder.pipeline(tgCS.transform) .parent(tgScn.update); + rBuilder.pipeline(tgCS.hierarchy) .parent(tgScn.update); + + + + rBuilder.task() + .name ("Cancel entity delete tasks stuff if no entities were deleted") + .run_on ({tgCS.activeEntDelete(Schedule_)}) + .push_to (out.m_tasks) + .args ({ idBasic, idActiveEntDel }) + .func([] (ACtxBasic& rBasic, ActiveEntVec_t const& rActiveEntDel) noexcept + { + return rActiveEntDel.empty() ? TaskAction::Cancel : TaskActions{}; + }); + + rBuilder.task() + .name ("Delete ActiveEnt IDs") + .run_on ({tgCS.activeEntDelete(EStgIntr::UseOrRun)}) + .sync_with ({tgCS.activeEnt(Delete)}) + .push_to (out.m_tasks) + .args ({ idBasic, idActiveEntDel }) + .func([] (ACtxBasic& rBasic, ActiveEntVec_t const& rActiveEntDel) noexcept + { + for (ActiveEnt const ent : rActiveEntDel) + { + if (rBasic.m_activeIds.exists(ent)) + { + rBasic.m_activeIds.remove(ent); + } + } + }); + + rBuilder.task() + .name ("Delete basic components") + .run_on ({tgCS.activeEntDelete(UseOrRun)}) + .sync_with ({tgCS.transform(Delete)}) + .push_to (out.m_tasks) + .args ({ idBasic, idActiveEntDel }) + .func([] (ACtxBasic& rBasic, ActiveEntVec_t const& rActiveEntDel) noexcept + { + update_delete_basic(rBasic, rActiveEntDel.cbegin(), rActiveEntDel.cend()); + }); + + rBuilder.task() + .name ("Clear ActiveEnt delete vector once we're done with it") + .run_on ({tgCS.activeEntDelete(Clear)}) + .push_to (out.m_tasks) + .args ({ idActiveEntDel }) + .func([] (ActiveEntVec_t& idActiveEntDel) noexcept + { + idActiveEntDel.clear(); + }); + + + // Clean up tasks + + rBuilder.task() + .name ("Clean up resource owners") + .run_on ({tgScn.cleanup(Run_)}) + .push_to (out.m_tasks) + .args ({ idDrawing, idDrawingRes, idResources}) + .func([] (ACtxDrawing& rDrawing, ACtxDrawingRes& rDrawingRes, Resources& rResources) noexcept + { + SysRender::clear_resource_owners(rDrawingRes, rResources); + }); + + rBuilder.task() + .name ("Clean up NamedMeshes mesh and texture owners") + .run_on ({tgScn.cleanup(Run_)}) + .push_to (out.m_tasks) + .args ({ idDrawing, idNMesh }) + .func([] (ACtxDrawing& rDrawing, NamedMeshes& rNMesh) noexcept + { + for ([[maybe_unused]] auto && [_, rOwner] : std::exchange(rNMesh.m_shapeToMesh, {})) + { + rDrawing.m_meshRefCounts.ref_release(std::move(rOwner)); + } + + for ([[maybe_unused]] auto && [_, rOwner] : std::exchange(rNMesh.m_namedMeshs, {})) + { + rDrawing.m_meshRefCounts.ref_release(std::move(rOwner)); + } + }); + + // Convenient functor to get a reference-counted mesh owner + auto const quick_add_mesh = SysRender::gen_drawable_mesh_adder(rDrawing, rDrawingRes, rResources, pkg); + + // Acquire mesh resources from Package + rNMesh.m_shapeToMesh.emplace(EShape::Box, quick_add_mesh("cube")); + rNMesh.m_shapeToMesh.emplace(EShape::Cylinder, quick_add_mesh("cylinder")); + rNMesh.m_shapeToMesh.emplace(EShape::Sphere, quick_add_mesh("sphere")); + rNMesh.m_namedMeshs.emplace("floor", quick_add_mesh("grid64solid")); + + return out; +} // setup_common_scene + + + + +Session setup_window_app( + TopTaskBuilder& rBuilder, + ArrayView const topData, + Session const& application) +{ + OSP_DECLARE_GET_DATA_IDS(application, TESTAPP_DATA_APPLICATION); + auto const tgApp = application .get_pipelines< PlApplication >(); + + Session out; + OSP_DECLARE_CREATE_DATA_IDS(out, topData, TESTAPP_DATA_WINDOW_APP); + auto const tgWin = out.create_pipelines(rBuilder); + + rBuilder.pipeline(tgWin.inputs).parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); + rBuilder.pipeline(tgWin.sync) .parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); + rBuilder.pipeline(tgWin.resync).parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); + + auto &rUserInput = top_emplace(topData, idUserInput, 12); + + out.m_cleanup = tgWin.cleanup; + + rBuilder.task() + .name ("Schedule GL Resync") + .schedules ({tgWin.resync(Schedule)}) + .push_to (out.m_tasks) + .args ({ idMainLoopCtrl}) + .func([] (MainLoopControl const& rMainLoopCtrl) noexcept -> osp::TaskActions + { + return rMainLoopCtrl.doResync ? osp::TaskActions{} : osp::TaskAction::Cancel; + }); + + return out; +} // setup_window_app + + + + +Session setup_scene_renderer( + TopTaskBuilder& rBuilder, + ArrayView const topData, + Session const& application, + Session const& windowApp, + Session const& commonScene) +{ + OSP_DECLARE_GET_DATA_IDS(windowApp, TESTAPP_DATA_WINDOW_APP); + OSP_DECLARE_GET_DATA_IDS(commonScene, TESTAPP_DATA_COMMON_SCENE); + auto const tgApp = application .get_pipelines< PlApplication >(); + auto const tgWin = windowApp .get_pipelines< PlWindowApp >(); + auto const tgCS = commonScene .get_pipelines< PlCommonScene >(); + + + Session out; + OSP_DECLARE_CREATE_DATA_IDS(out, topData, TESTAPP_DATA_SCENE_RENDERER); + auto const tgScnRdr = out.create_pipelines(rBuilder); + + rBuilder.pipeline(tgScnRdr.render).parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); + + rBuilder.pipeline(tgScnRdr.drawEnt) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.drawEntResized) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.drawEntDelete) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.entMesh) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.entTexture) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.entTextureDirty) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.entMeshDirty) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.drawTransforms) .parent(tgScnRdr.render); + rBuilder.pipeline(tgScnRdr.material) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.materialDirty) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.group) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.groupEnts) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.entMesh) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.entTexture) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.mesh) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.texture) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.meshResDirty) .parent(tgWin.sync); + rBuilder.pipeline(tgScnRdr.textureResDirty) .parent(tgWin.sync); + + auto &rScnRender = osp::top_emplace(topData, idScnRender); + + rBuilder.task() + .name ("Resize ACtxSceneRender containers to fit all DrawEnts") + .run_on ({tgScnRdr.drawEntResized(Run)}) + .sync_with ({tgScnRdr.entMesh(New), tgScnRdr.entTexture(New)}) + .push_to (out.m_tasks) + .args ({idScnRender}) + .func ([] (ACtxSceneRender& rScnRender) noexcept + { + rScnRender.resize_draw(); + }); + + rBuilder.task() + .name ("Resize ACtxSceneRender to fit ActiveEnts") + .run_on ({tgCS.activeEntResized(Run)}) + .push_to (out.m_tasks) + .args ({ idBasic, idScnRender}) + .func([] (ACtxBasic const &rBasic, ACtxSceneRender& rScnRender) noexcept + { + rScnRender.resize_active(rBasic.m_activeIds.capacity()); + }); + + // Duplicate task needed for resync to account for existing ActiveEnts when the renderer opens, + // as activeEntResized doesn't run during resync + rBuilder.task() + .name ("Resync ACtxSceneRender to fit ActiveEnts") + .run_on ({tgWin.resync(Run)}) + .sync_with ({tgCS.activeEntResized(Run)}) + .push_to (out.m_tasks) + .args ({ idBasic, idScnRender}) + .func([] (ACtxBasic const &rBasic, ACtxSceneRender& rScnRender) noexcept + { + rScnRender.resize_active(rBasic.m_activeIds.capacity()); + }); + + rBuilder.task() + .name ("Schedule Assign GL textures") + .schedules ({tgScnRdr.entTextureDirty(Schedule_)}) + .sync_with ({tgScnRdr.texture(Ready), tgScnRdr.entTexture(Ready)}) + .push_to (out.m_tasks) + .args ({ idScnRender }) + .func([] (ACtxSceneRender& rScnRender) noexcept -> TaskActions + { + return rScnRender.m_diffuseDirty.empty() ? TaskAction::Cancel : TaskActions{}; + }); + + rBuilder.task() + .name ("Schedule Assign GL meshes") + .schedules ({tgScnRdr.entMeshDirty(Schedule_)}) + .sync_with ({tgScnRdr.mesh(Ready), tgScnRdr.entMesh(Ready)}) + .push_to (out.m_tasks) + .args ({ idScnRender }) + .func([] (ACtxSceneRender& rScnRender) noexcept -> TaskActions + { + return rScnRender.m_meshDirty.empty() ? TaskAction::Cancel : TaskActions{}; + }); + + rBuilder.task() + .name ("Delete DrawEntity of deleted ActiveEnts") + .run_on ({tgCS.activeEntDelete(UseOrRun)}) + .sync_with ({tgScnRdr.drawEntDelete(Modify_)}) + .push_to (out.m_tasks) + .args ({ idScnRender, idActiveEntDel, idDrawEntDel }) + .func([] (ACtxSceneRender& rScnRender, ActiveEntVec_t const& rActiveEntDel, DrawEntVec_t& rDrawEntDel) noexcept + { + for (ActiveEnt const ent : rActiveEntDel) + { + if (rScnRender.m_activeToDraw.size() < std::size_t(ent)) + { + continue; + } + DrawEnt const drawEnt = std::exchange(rScnRender.m_activeToDraw[ent], lgrn::id_null()); + if (drawEnt != lgrn::id_null()) + { + rDrawEntDel.push_back(drawEnt); + } + } + }); + + rBuilder.task() + .name ("Delete drawing components") + .run_on ({tgScnRdr.drawEntDelete(UseOrRun)}) + .sync_with ({tgScnRdr.entTexture(Delete), tgScnRdr.entMesh(Delete)}) + .push_to (out.m_tasks) + .args ({ idDrawing, idScnRender, idDrawEntDel }) + .func([] (ACtxDrawing& rDrawing, ACtxSceneRender& rScnRender, DrawEntVec_t const& rDrawEntDel) noexcept + { + SysRender::update_delete_drawing(rScnRender, rDrawing, rDrawEntDel.cbegin(), rDrawEntDel.cend()); + }); + + rBuilder.task() + .name ("Delete DrawEntity IDs") + .run_on ({tgScnRdr.drawEntDelete(UseOrRun)}) + .sync_with ({tgScnRdr.drawEnt(Delete)}) + .push_to (out.m_tasks) + .args ({ idScnRender, idDrawEntDel }) + .func([] (ACtxSceneRender& rScnRender, DrawEntVec_t const& rDrawEntDel) noexcept + { + for (DrawEnt const drawEnt : rDrawEntDel) + { + if (rScnRender.m_drawIds.exists(drawEnt)) + { + rScnRender.m_drawIds.remove(drawEnt); + } + } + }); + + rBuilder.task() + .name ("Delete DrawEnt from materials") + .run_on ({tgScnRdr.drawEntDelete(UseOrRun)}) + .sync_with ({tgScnRdr.material(Delete)}) + .push_to (out.m_tasks) + .args ({ idScnRender, idDrawEntDel }) + .func([] (ACtxSceneRender& rScnRender, DrawEntVec_t const& rDrawEntDel) noexcept + { + for (DrawEnt const ent : rDrawEntDel) + { + for (Material &rMat : rScnRender.m_materials) + { + if (std::size_t(ent) < rMat.m_ents.size()) + { + rMat.m_ents.reset(std::size_t(ent)); + } + } + } + }); + + rBuilder.task() + .name ("Clear DrawEnt delete vector once we're done with it") + .run_on ({tgScnRdr.drawEntDelete(Clear)}) + .push_to (out.m_tasks) + .args ({ idDrawEntDel }) + .func([] (DrawEntVec_t& rDrawEntDel) noexcept + { + rDrawEntDel.clear(); + }); + + rBuilder.task() + .name ("Clear dirty DrawEnt's textures once we're done with it") + .run_on ({tgScnRdr.entMeshDirty(Clear)}) + .push_to (out.m_tasks) + .args ({ idScnRender}) + .func([] (ACtxSceneRender& rScnRender) noexcept + { + rScnRender.m_meshDirty.clear(); + }); + + rBuilder.task() + .name ("Clear dirty DrawEnt's textures once we're done with it") + .run_on ({tgScnRdr.entTextureDirty(Clear)}) + .push_to (out.m_tasks) + .args ({ idScnRender}) + .func([] (ACtxSceneRender& rScnRender) noexcept + { + rScnRender.m_diffuseDirty.clear(); + }); + + rBuilder.task() + .name ("Clean up scene owners") + .run_on ({tgWin.cleanup(Run_)}) + .push_to (out.m_tasks) + .args ({ idDrawing, idScnRender}) + .func([] (ACtxDrawing& rDrawing, ACtxSceneRender& rScnRender) noexcept + { + SysRender::clear_owners(rScnRender, rDrawing); + }); + + return out; +} // setup_scene_renderer + +} // namespace testapp::scenes diff --git a/src/test_application/activescenes/scene_common.h b/src/testapp/sessions/common.h similarity index 67% rename from src/test_application/activescenes/scene_common.h rename to src/testapp/sessions/common.h index 7dd2331c..c67f95b6 100644 --- a/src/test_application/activescenes/scene_common.h +++ b/src/testapp/sessions/common.h @@ -24,11 +24,12 @@ */ #pragma once -#include "scenarios.h" +#include "../scenarios.h" -#include -#include -#include +#include +#include +#include +#include #include @@ -37,15 +38,11 @@ namespace testapp::scenes struct NamedMeshes { - // Required for std::is_copy_assignable to work properly inside of entt::any NamedMeshes() = default; - NamedMeshes(NamedMeshes const& copy) = delete; - NamedMeshes(NamedMeshes&& move) = default; + OSP_MOVE_ONLY_CTOR_ASSIGN(NamedMeshes) // Huge compile errors without this. MeshIdOwner_t is move-only. - entt::dense_map m_shapeToMesh; - entt::dense_map m_namedMeshs; + entt::dense_map m_shapeToMesh; + entt::dense_map m_namedMeshs; }; osp::Session setup_scene( @@ -63,5 +60,17 @@ osp::Session setup_common_scene( osp::Session const& application, osp::PkgId pkg); +osp::Session setup_window_app( + osp::TopTaskBuilder& rBuilder, + osp::ArrayView topData, + osp::Session const& application); + +osp::Session setup_scene_renderer( + osp::TopTaskBuilder& rBuilder, + osp::ArrayView topData, + osp::Session const& application, + osp::Session const& windowApp, + osp::Session const& commonScene); + -} +} // namespace testapp::scenes diff --git a/src/test_application/activescenes/scene_renderer.cpp b/src/testapp/sessions/magnum.cpp similarity index 58% rename from src/test_application/activescenes/scene_renderer.cpp rename to src/testapp/sessions/magnum.cpp index 1ba6f582..111ffc35 100644 --- a/src/test_application/activescenes/scene_renderer.cpp +++ b/src/testapp/sessions/magnum.cpp @@ -22,38 +22,36 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "scene_renderer.h" -#include "scene_common.h" -#include "scenarios.h" -#include "identifiers.h" -#include "CameraController.h" +#include "magnum.h" +#include "common.h" #include "../MagnumApplication.h" #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include -#include // for the 0xrrggbb_rgbf and angle literals using namespace Magnum::Math::Literals; -using namespace osp; -using namespace osp::shader; +using namespace adera; +using namespace adera::shader; using namespace osp::active; +using namespace osp::draw; using namespace osp::universe; +using namespace osp; using osp::input::UserInputHandler; @@ -62,249 +60,6 @@ using Magnum::GL::Mesh; namespace testapp::scenes { -Session setup_window_app( - TopTaskBuilder& rBuilder, - ArrayView const topData, - Session const& application) -{ - OSP_DECLARE_GET_DATA_IDS(application, TESTAPP_DATA_APPLICATION); - auto const tgApp = application .get_pipelines< PlApplication >(); - - Session out; - OSP_DECLARE_CREATE_DATA_IDS(out, topData, TESTAPP_DATA_WINDOW_APP); - auto const tgWin = out.create_pipelines(rBuilder); - - rBuilder.pipeline(tgWin.inputs).parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); - rBuilder.pipeline(tgWin.sync) .parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); - rBuilder.pipeline(tgWin.resync).parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); - - auto &rUserInput = osp::top_emplace(topData, idUserInput, 12); - config_controls(rUserInput); - - out.m_cleanup = tgWin.cleanup; - - rBuilder.task() - .name ("Schedule GL Resync") - .schedules ({tgWin.resync(Schedule)}) - .push_to (out.m_tasks) - .args ({ idMainLoopCtrl}) - .func([] (MainLoopControl const& rMainLoopCtrl) noexcept -> osp::TaskActions - { - return rMainLoopCtrl.doResync ? osp::TaskActions{} : osp::TaskAction::Cancel; - }); - - return out; -} - -Session setup_scene_renderer( - TopTaskBuilder& rBuilder, - ArrayView const topData, - Session const& application, - Session const& windowApp, - Session const& commonScene) -{ - OSP_DECLARE_GET_DATA_IDS(windowApp, TESTAPP_DATA_WINDOW_APP); - OSP_DECLARE_GET_DATA_IDS(commonScene, TESTAPP_DATA_COMMON_SCENE); - auto const tgApp = application .get_pipelines< PlApplication >(); - auto const tgWin = windowApp .get_pipelines< PlWindowApp >(); - auto const tgCS = commonScene .get_pipelines< PlCommonScene >(); - - - Session out; - OSP_DECLARE_CREATE_DATA_IDS(out, topData, TESTAPP_DATA_SCENE_RENDERER); - auto const tgScnRdr = out.create_pipelines(rBuilder); - - rBuilder.pipeline(tgScnRdr.render).parent(tgApp.mainLoop).wait_for_signal(ModifyOrSignal); - - rBuilder.pipeline(tgScnRdr.drawEnt) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.drawEntResized) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.drawEntDelete) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.entMesh) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.entTexture) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.entTextureDirty) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.entMeshDirty) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.drawTransforms) .parent(tgScnRdr.render); - rBuilder.pipeline(tgScnRdr.material) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.materialDirty) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.group) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.groupEnts) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.entMesh) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.entTexture) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.mesh) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.texture) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.meshResDirty) .parent(tgWin.sync); - rBuilder.pipeline(tgScnRdr.textureResDirty) .parent(tgWin.sync); - - auto &rScnRender = osp::top_emplace(topData, idScnRender); - - rBuilder.task() - .name ("Resize ACtxSceneRender containers to fit all DrawEnts") - .run_on ({tgScnRdr.drawEntResized(Run)}) - .sync_with ({tgScnRdr.entMesh(New), tgScnRdr.entTexture(New)}) - .push_to (out.m_tasks) - .args ({idScnRender}) - .func ([] (ACtxSceneRender& rScnRender) noexcept - { - rScnRender.resize_draw(); - }); - - rBuilder.task() - .name ("Resize ACtxSceneRender to fit ActiveEnts") - .run_on ({tgCS.activeEntResized(Run)}) - .push_to (out.m_tasks) - .args ({ idBasic, idScnRender}) - .func([] (ACtxBasic const &rBasic, ACtxSceneRender& rScnRender) noexcept - { - rScnRender.resize_active(rBasic.m_activeIds.capacity()); - }); - - // Duplicate task needed for resync to account for existing ActiveEnts when the renderer opens, - // as activeEntResized doesn't run during resync - rBuilder.task() - .name ("Resync ACtxSceneRender to fit ActiveEnts") - .run_on ({tgWin.resync(Run)}) - .sync_with ({tgCS.activeEntResized(Run)}) - .push_to (out.m_tasks) - .args ({ idBasic, idScnRender}) - .func([] (ACtxBasic const &rBasic, ACtxSceneRender& rScnRender) noexcept - { - rScnRender.resize_active(rBasic.m_activeIds.capacity()); - }); - - rBuilder.task() - .name ("Schedule Assign GL textures") - .schedules ({tgScnRdr.entTextureDirty(Schedule_)}) - .sync_with ({tgScnRdr.texture(Ready), tgScnRdr.entTexture(Ready)}) - .push_to (out.m_tasks) - .args ({ idScnRender }) - .func([] (ACtxSceneRender& rScnRender) noexcept -> TaskActions - { - return rScnRender.m_diffuseDirty.empty() ? TaskAction::Cancel : TaskActions{}; - }); - - rBuilder.task() - .name ("Schedule Assign GL meshes") - .schedules ({tgScnRdr.entMeshDirty(Schedule_)}) - .sync_with ({tgScnRdr.mesh(Ready), tgScnRdr.entMesh(Ready)}) - .push_to (out.m_tasks) - .args ({ idScnRender }) - .func([] (ACtxSceneRender& rScnRender) noexcept -> TaskActions - { - return rScnRender.m_meshDirty.empty() ? TaskAction::Cancel : TaskActions{}; - }); - - rBuilder.task() - .name ("Delete DrawEntity of deleted ActiveEnts") - .run_on ({tgCS.activeEntDelete(UseOrRun)}) - .sync_with ({tgScnRdr.drawEntDelete(Modify_)}) - .push_to (out.m_tasks) - .args ({ idScnRender, idActiveEntDel, idDrawEntDel }) - .func([] (ACtxSceneRender& rScnRender, ActiveEntVec_t const& rActiveEntDel, DrawEntVec_t& rDrawEntDel) noexcept - { - for (ActiveEnt const ent : rActiveEntDel) - { - if (rScnRender.m_activeToDraw.size() < std::size_t(ent)) - { - continue; - } - DrawEnt const drawEnt = std::exchange(rScnRender.m_activeToDraw[ent], lgrn::id_null()); - if (drawEnt != lgrn::id_null()) - { - rDrawEntDel.push_back(drawEnt); - } - } - }); - - rBuilder.task() - .name ("Delete drawing components") - .run_on ({tgScnRdr.drawEntDelete(UseOrRun)}) - .sync_with ({tgScnRdr.entTexture(Delete), tgScnRdr.entMesh(Delete)}) - .push_to (out.m_tasks) - .args ({ idDrawing, idScnRender, idDrawEntDel }) - .func([] (ACtxDrawing& rDrawing, ACtxSceneRender& rScnRender, DrawEntVec_t const& rDrawEntDel) noexcept - { - SysRender::update_delete_drawing(rScnRender, rDrawing, rDrawEntDel.cbegin(), rDrawEntDel.cend()); - }); - - rBuilder.task() - .name ("Delete DrawEntity IDs") - .run_on ({tgScnRdr.drawEntDelete(UseOrRun)}) - .sync_with ({tgScnRdr.drawEnt(Delete)}) - .push_to (out.m_tasks) - .args ({ idScnRender, idDrawEntDel }) - .func([] (ACtxSceneRender& rScnRender, DrawEntVec_t const& rDrawEntDel) noexcept - { - for (DrawEnt const drawEnt : rDrawEntDel) - { - if (rScnRender.m_drawIds.exists(drawEnt)) - { - rScnRender.m_drawIds.remove(drawEnt); - } - } - }); - - rBuilder.task() - .name ("Delete DrawEnt from materials") - .run_on ({tgScnRdr.drawEntDelete(UseOrRun)}) - .sync_with ({tgScnRdr.material(Delete)}) - .push_to (out.m_tasks) - .args ({ idScnRender, idDrawEntDel }) - .func([] (ACtxSceneRender& rScnRender, DrawEntVec_t const& rDrawEntDel) noexcept - { - for (DrawEnt const ent : rDrawEntDel) - { - for (Material &rMat : rScnRender.m_materials) - { - if (std::size_t(ent) < rMat.m_ents.size()) - { - rMat.m_ents.reset(std::size_t(ent)); - } - } - } - }); - - rBuilder.task() - .name ("Clear DrawEnt delete vector once we're done with it") - .run_on ({tgScnRdr.drawEntDelete(Clear)}) - .push_to (out.m_tasks) - .args ({ idDrawEntDel }) - .func([] (DrawEntVec_t& rDrawEntDel) noexcept - { - rDrawEntDel.clear(); - }); - - rBuilder.task() - .name ("Clear dirty DrawEnt's textures once we're done with it") - .run_on ({tgScnRdr.entMeshDirty(Clear)}) - .push_to (out.m_tasks) - .args ({ idScnRender}) - .func([] (ACtxSceneRender& rScnRender) noexcept - { - rScnRender.m_meshDirty.clear(); - }); - - rBuilder.task() - .name ("Clear dirty DrawEnt's textures once we're done with it") - .run_on ({tgScnRdr.entTextureDirty(Clear)}) - .push_to (out.m_tasks) - .args ({ idScnRender}) - .func([] (ACtxSceneRender& rScnRender) noexcept - { - rScnRender.m_diffuseDirty.clear(); - }); - - rBuilder.task() - .name ("Clean up scene owners") - .run_on ({tgWin.cleanup(Run_)}) - .push_to (out.m_tasks) - .args ({ idDrawing, idScnRender}) - .func([] (ACtxDrawing& rDrawing, ACtxSceneRender& rScnRender) noexcept - { - SysRender::clear_owners(rScnRender, rDrawing); - }); - - return out; -} Session setup_magnum( TopTaskBuilder& rBuilder, @@ -318,6 +73,7 @@ Session setup_magnum( auto const tgWin = windowApp .get_pipelines< PlWindowApp >(); auto& rUserInput = top_get(topData, idUserInput); + config_controls(rUserInput); Session out; OSP_DECLARE_CREATE_DATA_IDS(out, topData, TESTAPP_DATA_MAGNUM); @@ -356,7 +112,9 @@ Session setup_magnum( }); return out; -} +} // setup_magnum + + Session setup_magnum_scene( @@ -574,7 +332,10 @@ Session setup_magnum_scene( }); return out; -} +} // setup_magnum_scene + + + Session setup_shader_visualizer( TopTaskBuilder& rBuilder, @@ -641,7 +402,9 @@ Session setup_shader_visualizer( }); return out; -} +} // setup_shader_visualizer + + Session setup_shader_flat( @@ -723,7 +486,9 @@ Session setup_shader_flat( }); return out; -} +} // setup_shader_flat + + Session setup_shader_phong( @@ -805,58 +570,9 @@ Session setup_shader_phong( }); return out; -} +} // setup_shader_phong -Session setup_cursor( - TopTaskBuilder& rBuilder, - ArrayView const topData, - Session const& application, - Session const& sceneRenderer, - Session const& cameraCtrl, - Session const& commonScene, - MaterialId const material, - PkgId const pkg) -{ - OSP_DECLARE_GET_DATA_IDS(application, TESTAPP_DATA_APPLICATION); - OSP_DECLARE_GET_DATA_IDS(sceneRenderer, TESTAPP_DATA_SCENE_RENDERER); - OSP_DECLARE_GET_DATA_IDS(commonScene, TESTAPP_DATA_COMMON_SCENE); - OSP_DECLARE_GET_DATA_IDS(cameraCtrl, TESTAPP_DATA_CAMERA_CTRL); - auto const tgCmCt = cameraCtrl .get_pipelines(); - auto const tgScnRdr = sceneRenderer .get_pipelines(); - - auto &rResources = top_get< Resources > (topData, idResources); - auto &rScnRender = top_get< ACtxSceneRender > (topData, idScnRender); - auto &rDrawing = top_get< ACtxDrawing > (topData, idDrawing); - auto &rDrawingRes = top_get< ACtxDrawingRes > (topData, idDrawingRes); - - Session out; - auto const [idCursorEnt] = out.acquire_data<1>(topData); - - auto const cursorEnt = top_emplace(topData, idCursorEnt, rScnRender.m_drawIds.create()); - rScnRender.resize_draw(); - - rScnRender.m_mesh[cursorEnt] = SysRender::add_drawable_mesh(rDrawing, rDrawingRes, rResources, pkg, "cubewire"); - rScnRender.m_color[cursorEnt] = { 0.0f, 1.0f, 0.0f, 1.0f }; - rScnRender.m_visible.set(std::size_t(cursorEnt)); - rScnRender.m_opaque.set(std::size_t(cursorEnt)); - - Material &rMat = rScnRender.m_materials[material]; - rMat.m_ents.set(std::size_t(cursorEnt)); - - rBuilder.task() - .name ("Move cursor") - .run_on ({tgScnRdr.render(Run)}) - .sync_with ({tgCmCt.camCtrl(Ready), tgScnRdr.drawTransforms(Modify_), tgScnRdr.drawEntResized(Done)}) - .push_to (out.m_tasks) - .args ({ idCursorEnt, idCamCtrl, idScnRender }) - .func([] (DrawEnt const cursorEnt, ACtxCameraController const& rCamCtrl, ACtxSceneRender& rScnRender) noexcept - { - rScnRender.m_drawTransform[cursorEnt] = Matrix4::translation(rCamCtrl.m_target.value()); - }); - - return out; -} #if 0 @@ -1018,226 +734,4 @@ Session setup_thrust_indicators( #endif -struct PlanetDraw -{ - DrawEntVec_t drawEnts; - std::array axis; - DrawEnt attractor; - MaterialId matPlanets; - MaterialId matAxis; -}; - -Session setup_testplanets_draw( - TopTaskBuilder& rBuilder, - ArrayView const topData, - Session const& windowApp, - Session const& sceneRenderer, - Session const& cameraCtrl, - Session const& commonScene, - Session const& uniCore, - Session const& uniScnFrame, - Session const& uniTestPlanets, - MaterialId const matPlanets, - MaterialId const matAxis) -{ - OSP_DECLARE_GET_DATA_IDS(commonScene, TESTAPP_DATA_COMMON_SCENE); - OSP_DECLARE_GET_DATA_IDS(sceneRenderer, TESTAPP_DATA_SCENE_RENDERER); - OSP_DECLARE_GET_DATA_IDS(cameraCtrl, TESTAPP_DATA_CAMERA_CTRL); - OSP_DECLARE_GET_DATA_IDS(uniCore, TESTAPP_DATA_UNI_CORE); - OSP_DECLARE_GET_DATA_IDS(uniScnFrame, TESTAPP_DATA_UNI_SCENEFRAME); - OSP_DECLARE_GET_DATA_IDS(uniTestPlanets, TESTAPP_DATA_UNI_PLANETS); - - auto const tgWin = windowApp .get_pipelines(); - auto const tgScnRdr = sceneRenderer .get_pipelines(); - auto const tgCmCt = cameraCtrl .get_pipelines(); - auto const tgUCore = uniCore .get_pipelines(); - auto const tgUSFrm = uniScnFrame .get_pipelines(); - - Session out; - - auto const [idPlanetDraw] = out.acquire_data<1>(topData); - - auto &rPlanetDraw = top_emplace(topData, idPlanetDraw); - - rPlanetDraw.matPlanets = matPlanets; - rPlanetDraw.matAxis = matAxis; - - rBuilder.task() - .name ("Position SceneFrame center to Camera Controller target") - .run_on ({tgWin.inputs(Run)}) - .sync_with ({tgCmCt.camCtrl(Ready), tgUSFrm.sceneFrame(Modify)}) - .push_to (out.m_tasks) - .args ({ idCamCtrl, idScnFrame }) - .func([] (ACtxCameraController& rCamCtrl, SceneFrame& rScnFrame) noexcept - { - if ( ! rCamCtrl.m_target.has_value()) - { - return; - } - Vector3 &rCamPl = rCamCtrl.m_target.value(); - - // check origin translation - // ADL used for Magnum::Math::sign/floor/abs - float const maxDist = 512.0f; - Vector3 const translate = sign(rCamPl) * floor(abs(rCamPl) / maxDist) * maxDist; - - if ( ! translate.isZero()) - { - rCamCtrl.m_transform.translation() -= translate; - rCamPl -= translate; - - // a bit janky to modify universe stuff directly here, but it works lol - Vector3 const rotated = Quaternion(rScnFrame.m_rotation).transformVector(translate); - rScnFrame.m_position += Vector3g(math::mul_2pow(rotated, rScnFrame.m_precision)); - } - - rScnFrame.m_scenePosition = Vector3g(math::mul_2pow(rCamCtrl.m_target.value(), rScnFrame.m_precision)); - - }); - - rBuilder.task() - .name ("Resync test planets, create DrawEnts") - .run_on ({tgWin.resync(Run)}) - .sync_with ({tgScnRdr.drawEntResized(ModifyOrSignal)}) - .push_to (out.m_tasks) - .args ({ idScnRender, idPlanetDraw, idUniverse, idPlanetMainSpace}) - .func([] (ACtxSceneRender& rScnRender, PlanetDraw& rPlanetDraw, Universe& rUniverse, CoSpaceId const planetMainSpace) noexcept - { - CoSpaceCommon &rMainSpace = rUniverse.m_coordCommon[planetMainSpace]; - - rPlanetDraw.drawEnts.resize(rMainSpace.m_satCount, lgrn::id_null()); - - rScnRender.m_drawIds.create(rPlanetDraw.drawEnts .begin(), rPlanetDraw.drawEnts .end()); - rScnRender.m_drawIds.create(rPlanetDraw.axis .begin(), rPlanetDraw.axis .end()); - rPlanetDraw.attractor = rScnRender.m_drawIds.create(); - }); - - rBuilder.task() - .name ("Resync test planets, add mesh and material") - .run_on ({tgWin.resync(Run)}) - .sync_with ({tgScnRdr.drawEntResized(Done), tgScnRdr.materialDirty(Modify_), tgScnRdr.entMeshDirty(Modify_)}) - .push_to (out.m_tasks) - .args ({ idDrawing, idScnRender, idNMesh, idPlanetDraw, idUniverse, idPlanetMainSpace}) - .func([] (ACtxDrawing& rDrawing, ACtxSceneRender& rScnRender, NamedMeshes& rNMesh, PlanetDraw& rPlanetDraw, Universe& rUniverse, CoSpaceId const planetMainSpace) noexcept - { - CoSpaceCommon &rMainSpace = rUniverse.m_coordCommon[planetMainSpace]; - - Material &rMatPlanet = rScnRender.m_materials[rPlanetDraw.matPlanets]; - Material &rMatAxis = rScnRender.m_materials[rPlanetDraw.matAxis]; - - MeshId const sphereMeshId = rNMesh.m_shapeToMesh.at(phys::EShape::Sphere); - MeshId const cubeMeshId = rNMesh.m_shapeToMesh.at(phys::EShape::Box); - - for (std::size_t i = 0; i < rMainSpace.m_satCount; ++i) - { - DrawEnt const drawEnt = rPlanetDraw.drawEnts[i]; - - rScnRender.m_mesh[drawEnt] = rDrawing.m_meshRefCounts.ref_add(sphereMeshId); - rScnRender.m_meshDirty.push_back(drawEnt); - rScnRender.m_visible.set(std::size_t(drawEnt)); - rScnRender.m_opaque.set(std::size_t(drawEnt)); - rMatPlanet.m_ents.set(std::size_t(drawEnt)); - rMatPlanet.m_dirty.push_back(drawEnt); - } - - rScnRender.m_mesh[rPlanetDraw.attractor] = rDrawing.m_meshRefCounts.ref_add(sphereMeshId); - rScnRender.m_meshDirty.push_back(rPlanetDraw.attractor); - rScnRender.m_visible.set(std::size_t(rPlanetDraw.attractor)); - rScnRender.m_opaque.set(std::size_t(rPlanetDraw.attractor)); - rMatPlanet.m_ents.set(std::size_t(rPlanetDraw.attractor)); - rMatPlanet.m_dirty.push_back(rPlanetDraw.attractor); - - for (DrawEnt const drawEnt : rPlanetDraw.axis) - { - rScnRender.m_mesh[drawEnt] = rDrawing.m_meshRefCounts.ref_add(cubeMeshId); - rScnRender.m_meshDirty.push_back(drawEnt); - rScnRender.m_visible.set(std::size_t(drawEnt)); - rScnRender.m_opaque.set(std::size_t(drawEnt)); - rMatAxis.m_ents.set(std::size_t(drawEnt)); - rMatAxis.m_dirty.push_back(drawEnt); - } - - rScnRender.m_color[rPlanetDraw.axis[0]] = {1.0f, 0.0f, 0.0f, 1.0f}; - rScnRender.m_color[rPlanetDraw.axis[1]] = {0.0f, 1.0f, 0.0f, 1.0f}; - rScnRender.m_color[rPlanetDraw.axis[2]] = {0.0f, 0.0f, 1.0f, 1.0f}; - }); - - rBuilder.task() - .name ("Reposition test planet DrawEnts") - .run_on ({tgScnRdr.render(Run)}) - .sync_with ({tgScnRdr.drawTransforms(Modify_), tgScnRdr.drawEntResized(Done), tgCmCt.camCtrl(Ready), tgUSFrm.sceneFrame(Modify)}) - .push_to (out.m_tasks) - .args ({ idDrawing, idScnRender, idPlanetDraw, idUniverse, idScnFrame, idPlanetMainSpace}) - .func([] (ACtxDrawing& rDrawing, ACtxSceneRender& rScnRender, PlanetDraw& rPlanetDraw, Universe& rUniverse, SceneFrame const& rScnFrame, CoSpaceId const planetMainSpace) noexcept - { - - CoSpaceCommon &rMainSpace = rUniverse.m_coordCommon[planetMainSpace]; - auto const [x, y, z] = sat_views(rMainSpace.m_satPositions, rMainSpace.m_data, rMainSpace.m_satCount); - auto const [qx, qy, qz, qw] = sat_views(rMainSpace.m_satRotations, rMainSpace.m_data, rMainSpace.m_satCount); - - // Calculate transform from universe to area/local-space for rendering. - // This can be generalized by finding a common ancestor within the tree - // of coordinate spaces. Since there's only two possibilities, an if - // statement works. - CoordTransformer mainToArea; - if (rScnFrame.m_parent == planetMainSpace) - { - mainToArea = coord_parent_to_child(rMainSpace, rScnFrame); - } - else - { - CoSpaceId const landedId = rScnFrame.m_parent; - CoSpaceCommon &rLanded = rUniverse.m_coordCommon[landedId]; - - CoSpaceTransform const landedTf = coord_get_transform(rLanded, rLanded, x, y, z, qx, qy, qz, qw); - CoordTransformer const mainToLanded = coord_parent_to_child(rMainSpace, landedTf); - CoordTransformer const landedToArea = coord_parent_to_child(landedTf, rScnFrame); - - mainToArea = coord_composite(landedToArea, mainToLanded); - } - Quaternion const mainToAreaRot{mainToArea.rotation()}; - - float const scale = math::mul_2pow(1.0f, -rMainSpace.m_precision); - - Vector3 const attractorPos = Vector3(mainToArea.transform_position({0, 0, 0})) * scale; - - // Attractor - rScnRender.m_drawTransform[rPlanetDraw.attractor] - = Matrix4::translation(attractorPos) - * Matrix4{mainToAreaRot.toMatrix()} - * Matrix4::scaling({500, 500, 500}); - - rScnRender.m_drawTransform[rPlanetDraw.axis[0]] - = Matrix4::translation(attractorPos) - * Matrix4{mainToAreaRot.toMatrix()} - * Matrix4::scaling({500000, 10, 10}); - rScnRender.m_drawTransform[rPlanetDraw.axis[1]] - = Matrix4::translation(attractorPos) - * Matrix4{mainToAreaRot.toMatrix()} - * Matrix4::scaling({10, 500000, 10}); - rScnRender.m_drawTransform[rPlanetDraw.axis[2]] - = Matrix4::translation(attractorPos) - * Matrix4{mainToAreaRot.toMatrix()} - * Matrix4::scaling({10, 10, 500000}); - - for (std::size_t i = 0; i < rMainSpace.m_satCount; ++i) - { - Vector3g const relative = mainToArea.transform_position({x[i], y[i], z[i]}); - Vector3 const relativeMeters = Vector3(relative) * scale; - - Quaterniond const rot{{qx[i], qy[i], qz[i]}, qw[i]}; - - DrawEnt const drawEnt = rPlanetDraw.drawEnts[i]; - - rScnRender.m_drawTransform[drawEnt] - = Matrix4::translation(relativeMeters) - * Matrix4::scaling({200, 200, 200}) - * Matrix4{(mainToAreaRot * Quaternion{rot}).toMatrix()}; - } - - }); - - return out; -} - } // namespace testapp::scenes diff --git a/src/test_application/activescenes/scene_renderer.h b/src/testapp/sessions/magnum.h similarity index 56% rename from src/test_application/activescenes/scene_renderer.h rename to src/testapp/sessions/magnum.h index 1136f2a3..197cbfcd 100644 --- a/src/test_application/activescenes/scene_renderer.h +++ b/src/testapp/sessions/magnum.h @@ -24,28 +24,15 @@ */ #pragma once -#include "scenarios.h" - -#include - +#include "../scenarios.h" #include "../MagnumApplication.h" +#include +#include namespace testapp::scenes { -osp::Session setup_window_app( - osp::TopTaskBuilder& rBuilder, - osp::ArrayView topData, - osp::Session const& application); - -osp::Session setup_scene_renderer( - osp::TopTaskBuilder& rBuilder, - osp::ArrayView topData, - osp::Session const& application, - osp::Session const& windowApp, - osp::Session const& commonScene); - osp::Session setup_magnum( osp::TopTaskBuilder& rBuilder, osp::ArrayView topData, @@ -76,7 +63,7 @@ osp::Session setup_shader_visualizer( osp::Session const& sceneRenderer, osp::Session const& magnum, osp::Session const& magnumScene, - osp::active::MaterialId materialId = lgrn::id_null()); + osp::draw::MaterialId materialId = lgrn::id_null()); /** * @brief Magnum Flat shader and optional material for drawing ActiveEnts with it @@ -88,7 +75,7 @@ osp::Session setup_shader_flat( osp::Session const& sceneRenderer, osp::Session const& magnum, osp::Session const& magnumScene, - osp::active::MaterialId materialId = lgrn::id_null()); + osp::draw::MaterialId materialId = lgrn::id_null()); /** * @brief Magnum Phong shader and optional material for drawing ActiveEnts with it @@ -100,51 +87,6 @@ osp::Session setup_shader_phong( osp::Session const& sceneRenderer, osp::Session const& magnum, osp::Session const& magnumScene, - osp::active::MaterialId materialId = lgrn::id_null()); - -/** - * @brief Red indicators over Magic Rockets - */ -osp::Session setup_thrust_indicators( - osp::TopTaskBuilder& rBuilder, - osp::ArrayView topData, - osp::Session const& magnum, - osp::Session const& commonScene, - osp::Session const& parts, - osp::Session const& signalsFloat, - osp::Session const& scnRender, - osp::Session const& cameraCtrl, - osp::Session const& shFlat, - osp::TopDataId const idResources, - osp::PkgId const pkg); - -/** - * @brief Wireframe cube over the camera controller's target - */ -osp::Session setup_cursor( - osp::TopTaskBuilder& rBuilder, - osp::ArrayView topData, - osp::Session const& application, - osp::Session const& sceneRenderer, - osp::Session const& cameraCtrl, - osp::Session const& commonScene, - osp::active::MaterialId const material, - osp::PkgId const pkg); - -/** - * @brief Draw universe, specifically designed for setup_uni_test_planets - */ -osp::Session setup_testplanets_draw( - osp::TopTaskBuilder& rBuilder, - osp::ArrayView topData, - osp::Session const& windowApp, - osp::Session const& sceneRenderer, - osp::Session const& cameraCtrl, - osp::Session const& commonScene, - osp::Session const& uniCore, - osp::Session const& uniScnFrame, - osp::Session const& uniTestPlanets, - osp::active::MaterialId const matPlanets, - osp::active::MaterialId const matAxis); + osp::draw::MaterialId materialId = lgrn::id_null()); } diff --git a/src/test_application/activescenes/scene_misc.cpp b/src/testapp/sessions/misc.cpp similarity index 83% rename from src/test_application/activescenes/scene_misc.cpp rename to src/testapp/sessions/misc.cpp index b473fae7..2de5aeb9 100644 --- a/src/test_application/activescenes/scene_misc.cpp +++ b/src/testapp/sessions/misc.cpp @@ -22,32 +22,25 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "scene_misc.h" -#include "scene_physics.h" -#include "scenarios.h" -#include "identifiers.h" +#include "misc.h" +#include "physics.h" -#include "CameraController.h" - -#include -#include - -#include -#include - -#include - -#include +#include +#include +#include +#include +#include #include +using namespace adera; using namespace osp; using namespace osp::active; +using namespace osp::draw; -using osp::phys::EShape; using osp::input::EButtonControlIndex; -// for the 0xrrggbb_rgbf and angle literals +// for the 0xrrggbb_rgbf and angle literalss using namespace Magnum::Math::Literals; namespace testapp::scenes @@ -64,7 +57,6 @@ void create_materials( for (int i = 0; i < count; ++i) { [[maybe_unused]] MaterialId const mat = rScnRender.m_materialIds.create(); - LGRN_ASSERT(int(mat) == i); } rScnRender.m_materials.resize(count); @@ -138,7 +130,10 @@ Session setup_camera_ctrl( }); return out; -} +} // setup_camera_ctrl + + + Session setup_camera_free( TopTaskBuilder& rBuilder, @@ -168,7 +163,9 @@ Session setup_camera_free( }); return out; -} +} // setup_camera_free + + Session setup_thrower( @@ -223,7 +220,10 @@ Session setup_thrower( }); return out; -} +} // setup_thrower + + + Session setup_droppers( TopTaskBuilder& rBuilder, @@ -293,7 +293,10 @@ Session setup_droppers( }); return out; -} +} // setup_droppers + + + Session setup_bounds( TopTaskBuilder& rBuilder, @@ -396,6 +399,60 @@ Session setup_bounds( }); return out; -} +} // setup_bounds + + + + +Session setup_cursor( + TopTaskBuilder& rBuilder, + ArrayView const topData, + Session const& application, + Session const& sceneRenderer, + Session const& cameraCtrl, + Session const& commonScene, + MaterialId const material, + PkgId const pkg) +{ + OSP_DECLARE_GET_DATA_IDS(application, TESTAPP_DATA_APPLICATION); + OSP_DECLARE_GET_DATA_IDS(sceneRenderer, TESTAPP_DATA_SCENE_RENDERER); + OSP_DECLARE_GET_DATA_IDS(commonScene, TESTAPP_DATA_COMMON_SCENE); + OSP_DECLARE_GET_DATA_IDS(cameraCtrl, TESTAPP_DATA_CAMERA_CTRL); + auto const tgCmCt = cameraCtrl .get_pipelines(); + auto const tgScnRdr = sceneRenderer .get_pipelines(); + + auto &rResources = top_get< Resources > (topData, idResources); + auto &rScnRender = top_get< ACtxSceneRender > (topData, idScnRender); + auto &rDrawing = top_get< ACtxDrawing > (topData, idDrawing); + auto &rDrawingRes = top_get< ACtxDrawingRes > (topData, idDrawingRes); + + Session out; + auto const [idCursorEnt] = out.acquire_data<1>(topData); + + auto const cursorEnt = top_emplace(topData, idCursorEnt, rScnRender.m_drawIds.create()); + rScnRender.resize_draw(); + + rScnRender.m_mesh[cursorEnt] = SysRender::add_drawable_mesh(rDrawing, rDrawingRes, rResources, pkg, "cubewire"); + rScnRender.m_color[cursorEnt] = { 0.0f, 1.0f, 0.0f, 1.0f }; + rScnRender.m_visible.set(std::size_t(cursorEnt)); + rScnRender.m_opaque.set(std::size_t(cursorEnt)); + + Material &rMat = rScnRender.m_materials[material]; + rMat.m_ents.set(std::size_t(cursorEnt)); + + rBuilder.task() + .name ("Move cursor") + .run_on ({tgScnRdr.render(Run)}) + .sync_with ({tgCmCt.camCtrl(Ready), tgScnRdr.drawTransforms(Modify_), tgScnRdr.drawEntResized(Done)}) + .push_to (out.m_tasks) + .args ({ idCursorEnt, idCamCtrl, idScnRender }) + .func([] (DrawEnt const cursorEnt, ACtxCameraController const& rCamCtrl, ACtxSceneRender& rScnRender) noexcept + { + rScnRender.m_drawTransform[cursorEnt] = Matrix4::translation(rCamCtrl.m_target.value()); + }); + + return out; +} // setup_cursor + } // namespace testapp::scenes diff --git a/src/test_application/activescenes/scene_misc.h b/src/testapp/sessions/misc.h similarity index 84% rename from src/test_application/activescenes/scene_misc.h rename to src/testapp/sessions/misc.h index 05b8f07d..b3318d81 100644 --- a/src/test_application/activescenes/scene_misc.h +++ b/src/testapp/sessions/misc.h @@ -24,9 +24,10 @@ */ #pragma once -#include "scenarios.h" +#include "../scenarios.h" -#include +#include +#include namespace testapp::scenes { @@ -39,7 +40,7 @@ void create_materials( void add_floor( osp::ArrayView topData, osp::Session const& shapeSpawn, - osp::active::MaterialId material, + osp::draw::MaterialId material, osp::PkgId pkg, int size); @@ -93,5 +94,18 @@ osp::Session setup_bounds( osp::Session const& commonScene, osp::Session const& shapeSpawn); +/** + * @brief Wireframe cube over the camera controller's target + */ +osp::Session setup_cursor( + osp::TopTaskBuilder& rBuilder, + osp::ArrayView topData, + osp::Session const& application, + osp::Session const& sceneRenderer, + osp::Session const& cameraCtrl, + osp::Session const& commonScene, + osp::draw::MaterialId const material, + osp::PkgId const pkg); + } diff --git a/src/test_application/activescenes/scene_newton.cpp b/src/testapp/sessions/newton.cpp similarity index 98% rename from src/test_application/activescenes/scene_newton.cpp rename to src/testapp/sessions/newton.cpp index 2c89fbcc..4848baeb 100644 --- a/src/test_application/activescenes/scene_newton.cpp +++ b/src/testapp/sessions/newton.cpp @@ -22,27 +22,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "scene_newton.h" -#include "scene_physics.h" -#include "identifiers.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include "newton.h" +#include "physics.h" + +#include +#include +#include +#include +#include #include -#include -#include +#include using namespace osp; using namespace osp::active; @@ -50,7 +41,6 @@ using namespace osp::link; using namespace ospnewton; using osp::restypes::gc_importer; -using osp::phys::EShape; using Corrade::Containers::arrayView; namespace testapp::scenes @@ -107,7 +97,8 @@ Session setup_newton( top_emplace< ACtxNwtWorld >(topData, idNwt, 2); return out; -} +} // setup_newton + @@ -123,7 +114,10 @@ osp::Session setup_newton_factors( std::fill(rFactors.begin(), rFactors.end(), 0); return out; -} +} // setup_newton_factors + + + osp::Session setup_newton_force_accel( TopTaskBuilder& rBuilder, @@ -166,7 +160,9 @@ osp::Session setup_newton_force_accel( factorBits.set(index); return nwtAccel; -} +} // setup_newton_force_accel + + Session setup_shape_spawn_newton( @@ -230,7 +226,9 @@ Session setup_shape_spawn_newton( }); return out; -} +} // setup_shape_spawn_newton + + #if 0 diff --git a/src/test_application/activescenes/scene_newton.h b/src/testapp/sessions/newton.h similarity index 94% rename from src/test_application/activescenes/scene_newton.h rename to src/testapp/sessions/newton.h index 55738f29..18964e03 100644 --- a/src/test_application/activescenes/scene_newton.h +++ b/src/testapp/sessions/newton.h @@ -24,15 +24,15 @@ */ #pragma once -#include "scenarios.h" +#include "../scenarios.h" +#include +#include #include -#include #include -#include -#include +#include -#include +#include #include diff --git a/src/test_application/activescenes/scene_physics.cpp b/src/testapp/sessions/physics.cpp similarity index 96% rename from src/test_application/activescenes/scene_physics.cpp rename to src/testapp/sessions/physics.cpp index 66fa06fc..293c4606 100644 --- a/src/test_application/activescenes/scene_physics.cpp +++ b/src/testapp/sessions/physics.cpp @@ -22,27 +22,21 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "scene_physics.h" -#include "scene_common.h" -#include "scenarios.h" -#include "identifiers.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include "physics.h" +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include using namespace osp; using namespace osp::active; +using namespace osp::draw; using osp::restypes::gc_importer; -using osp::phys::EShape; using Corrade::Containers::arrayView; namespace testapp::scenes @@ -81,7 +75,10 @@ Session setup_physics( }); return out; -} +} // setup_physics + + + Session setup_shape_spawn( TopTaskBuilder& rBuilder, @@ -179,8 +176,7 @@ Session setup_shape_spawn( if (spawn.m_mass != 0.0f) { rPhys.m_setVelocity.emplace_back(root, spawn.m_velocity); - Vector3 const inertia - = phys::collider_inertia_tensor(spawn.m_shape, spawn.m_size, spawn.m_mass); + Vector3 const inertia = collider_inertia_tensor(spawn.m_shape, spawn.m_size, spawn.m_mass); Vector3 const offset{0.0f, 0.0f, 0.0f}; rPhys.m_mass.emplace( child, ACompMass{ inertia, offset, spawn.m_mass } ); } @@ -214,7 +210,10 @@ Session setup_shape_spawn( return out; -} +} // setup_shape_spawn + + + Session setup_shape_spawn_draw( TopTaskBuilder& rBuilder, @@ -325,7 +324,7 @@ Session setup_shape_spawn_draw( rScnRender.m_needDrawTf.set(std::size_t(root)); rScnRender.m_needDrawTf.set(std::size_t(child)); - phys::EShape const shape = rPhys.m_shape.at(child); + EShape const shape = rPhys.m_shape.at(child); rScnRender.m_mesh[drawEnt] = rDrawing.m_meshRefCounts.ref_add(rNMesh.m_shapeToMesh.at(shape)); rScnRender.m_meshDirty.push_back(drawEnt); @@ -352,7 +351,7 @@ Session setup_shape_spawn_draw( }); return out; -} +} // setup_shape_spawn_draw #if 0 diff --git a/src/test_application/activescenes/scene_physics.h b/src/testapp/sessions/physics.h similarity index 83% rename from src/test_application/activescenes/scene_physics.h rename to src/testapp/sessions/physics.h index 62da0cf5..07256bc4 100644 --- a/src/test_application/activescenes/scene_physics.h +++ b/src/testapp/sessions/physics.h @@ -24,10 +24,11 @@ */ #pragma once -#include "scenarios.h" +#include "../scenarios.h" -#include -#include +#include +#include +#include #include @@ -38,11 +39,11 @@ namespace testapp::scenes struct SpawnShape { - osp::Vector3 m_position; - osp::Vector3 m_velocity; - osp::Vector3 m_size; - float m_mass; - osp::phys::EShape m_shape; + osp::Vector3 m_position; + osp::Vector3 m_velocity; + osp::Vector3 m_size; + float m_mass; + osp::EShape m_shape; }; struct ACtxShapeSpawner @@ -51,7 +52,7 @@ struct ACtxShapeSpawner std::vector m_spawnRequest; osp::active::ActiveEntVec_t m_ents; - osp::active::MaterialId m_materialId; + osp::draw::MaterialId m_materialId; }; /** @@ -65,15 +66,6 @@ osp::Session setup_physics( osp::Session const& scene, osp::Session const& commonScene); -/** - * @brief Newton Dynamics physics integration - */ -osp::Session setup_newton_physics( - osp::TopTaskBuilder& rBuilder, - osp::ArrayView topData, - osp::Session const& commonScene, - osp::Session const& physics); - /** * @brief Queues and logic for spawning physics shapes */ @@ -83,7 +75,7 @@ osp::Session setup_shape_spawn( osp::Session const& scene, osp::Session const& commonScene, osp::Session const& physics, - osp::active::MaterialId materialId); + osp::draw::MaterialId materialId); osp::Session setup_shape_spawn_draw( osp::TopTaskBuilder& rBuilder, diff --git a/src/test_application/activescenes/scene_universe.cpp b/src/testapp/sessions/universe.cpp similarity index 53% rename from src/test_application/activescenes/scene_universe.cpp rename to src/testapp/sessions/universe.cpp index f9c23209..73f2ab70 100644 --- a/src/test_application/activescenes/scene_universe.cpp +++ b/src/testapp/sessions/universe.cpp @@ -23,20 +23,23 @@ * SOFTWARE. */ -#include "scene_universe.h" +#include "universe.h" +#include "common.h" -#include "identifiers.h" +#include +#include +#include #include #include - -#include -#include +#include #include -using namespace osp; +using namespace adera; +using namespace osp::draw; using namespace osp::universe; +using namespace osp; namespace testapp::scenes { @@ -58,7 +61,9 @@ Session setup_uni_core( rBuilder.pipeline(tgUCore.transfer).parent(tgUCore.update); return out; -} +} // setup_uni_core + + Session setup_uni_sceneframe( @@ -78,7 +83,9 @@ Session setup_uni_sceneframe( rBuilder.pipeline(tgUSFrm.sceneFrame).parent(tgUCore.update); return out; -} +} // setup_uni_sceneframe + + Session setup_uni_testplanets( @@ -297,6 +304,231 @@ Session setup_uni_testplanets( }); return out; -} +} // setup_uni_testplanets + + + + +struct PlanetDraw +{ + DrawEntVec_t drawEnts; + std::array axis; + DrawEnt attractor; + MaterialId matPlanets; + MaterialId matAxis; +}; + +Session setup_testplanets_draw( + TopTaskBuilder& rBuilder, + ArrayView const topData, + Session const& windowApp, + Session const& sceneRenderer, + Session const& cameraCtrl, + Session const& commonScene, + Session const& uniCore, + Session const& uniScnFrame, + Session const& uniTestPlanets, + MaterialId const matPlanets, + MaterialId const matAxis) +{ + OSP_DECLARE_GET_DATA_IDS(commonScene, TESTAPP_DATA_COMMON_SCENE); + OSP_DECLARE_GET_DATA_IDS(sceneRenderer, TESTAPP_DATA_SCENE_RENDERER); + OSP_DECLARE_GET_DATA_IDS(cameraCtrl, TESTAPP_DATA_CAMERA_CTRL); + OSP_DECLARE_GET_DATA_IDS(uniCore, TESTAPP_DATA_UNI_CORE); + OSP_DECLARE_GET_DATA_IDS(uniScnFrame, TESTAPP_DATA_UNI_SCENEFRAME); + OSP_DECLARE_GET_DATA_IDS(uniTestPlanets, TESTAPP_DATA_UNI_PLANETS); + + auto const tgWin = windowApp .get_pipelines(); + auto const tgScnRdr = sceneRenderer .get_pipelines(); + auto const tgCmCt = cameraCtrl .get_pipelines(); + auto const tgUSFrm = uniScnFrame .get_pipelines(); + + Session out; + + auto const [idPlanetDraw] = out.acquire_data<1>(topData); + + auto &rPlanetDraw = top_emplace(topData, idPlanetDraw); + + rPlanetDraw.matPlanets = matPlanets; + rPlanetDraw.matAxis = matAxis; + + rBuilder.task() + .name ("Position SceneFrame center to Camera Controller target") + .run_on ({tgWin.inputs(Run)}) + .sync_with ({tgCmCt.camCtrl(Ready), tgUSFrm.sceneFrame(Modify)}) + .push_to (out.m_tasks) + .args ({ idCamCtrl, idScnFrame }) + .func([] (ACtxCameraController& rCamCtrl, SceneFrame& rScnFrame) noexcept + { + if ( ! rCamCtrl.m_target.has_value()) + { + return; + } + Vector3 &rCamPl = rCamCtrl.m_target.value(); + + // check origin translation + // ADL used for Magnum::Math::sign/floor/abs + float const maxDist = 512.0f; + Vector3 const translate = sign(rCamPl) * floor(abs(rCamPl) / maxDist) * maxDist; + + if ( ! translate.isZero()) + { + rCamCtrl.m_transform.translation() -= translate; + rCamPl -= translate; + + // a bit janky to modify universe stuff directly here, but it works lol + Vector3 const rotated = Quaternion(rScnFrame.m_rotation).transformVector(translate); + rScnFrame.m_position += Vector3g(math::mul_2pow(rotated, rScnFrame.m_precision)); + } + + rScnFrame.m_scenePosition = Vector3g(math::mul_2pow(rCamCtrl.m_target.value(), rScnFrame.m_precision)); + + }); + + rBuilder.task() + .name ("Resync test planets, create DrawEnts") + .run_on ({tgWin.resync(Run)}) + .sync_with ({tgScnRdr.drawEntResized(ModifyOrSignal)}) + .push_to (out.m_tasks) + .args ({ idScnRender, idPlanetDraw, idUniverse, idPlanetMainSpace}) + .func([] (ACtxSceneRender& rScnRender, PlanetDraw& rPlanetDraw, Universe& rUniverse, CoSpaceId const planetMainSpace) noexcept + { + CoSpaceCommon &rMainSpace = rUniverse.m_coordCommon[planetMainSpace]; + + rPlanetDraw.drawEnts.resize(rMainSpace.m_satCount, lgrn::id_null()); + + rScnRender.m_drawIds.create(rPlanetDraw.drawEnts .begin(), rPlanetDraw.drawEnts .end()); + rScnRender.m_drawIds.create(rPlanetDraw.axis .begin(), rPlanetDraw.axis .end()); + rPlanetDraw.attractor = rScnRender.m_drawIds.create(); + }); + + rBuilder.task() + .name ("Resync test planets, add mesh and material") + .run_on ({tgWin.resync(Run)}) + .sync_with ({tgScnRdr.drawEntResized(Done), tgScnRdr.materialDirty(Modify_), tgScnRdr.entMeshDirty(Modify_)}) + .push_to (out.m_tasks) + .args ({ idDrawing, idScnRender, idNMesh, idPlanetDraw, idUniverse, idPlanetMainSpace}) + .func([] (ACtxDrawing& rDrawing, ACtxSceneRender& rScnRender, NamedMeshes& rNMesh, PlanetDraw& rPlanetDraw, Universe& rUniverse, CoSpaceId const planetMainSpace) noexcept + { + CoSpaceCommon &rMainSpace = rUniverse.m_coordCommon[planetMainSpace]; + + Material &rMatPlanet = rScnRender.m_materials[rPlanetDraw.matPlanets]; + Material &rMatAxis = rScnRender.m_materials[rPlanetDraw.matAxis]; + + MeshId const sphereMeshId = rNMesh.m_shapeToMesh.at(EShape::Sphere); + MeshId const cubeMeshId = rNMesh.m_shapeToMesh.at(EShape::Box); + + for (std::size_t i = 0; i < rMainSpace.m_satCount; ++i) + { + DrawEnt const drawEnt = rPlanetDraw.drawEnts[i]; + + rScnRender.m_mesh[drawEnt] = rDrawing.m_meshRefCounts.ref_add(sphereMeshId); + rScnRender.m_meshDirty.push_back(drawEnt); + rScnRender.m_visible.set(std::size_t(drawEnt)); + rScnRender.m_opaque.set(std::size_t(drawEnt)); + rMatPlanet.m_ents.set(std::size_t(drawEnt)); + rMatPlanet.m_dirty.push_back(drawEnt); + } + + rScnRender.m_mesh[rPlanetDraw.attractor] = rDrawing.m_meshRefCounts.ref_add(sphereMeshId); + rScnRender.m_meshDirty.push_back(rPlanetDraw.attractor); + rScnRender.m_visible.set(std::size_t(rPlanetDraw.attractor)); + rScnRender.m_opaque.set(std::size_t(rPlanetDraw.attractor)); + rMatPlanet.m_ents.set(std::size_t(rPlanetDraw.attractor)); + rMatPlanet.m_dirty.push_back(rPlanetDraw.attractor); + + for (DrawEnt const drawEnt : rPlanetDraw.axis) + { + rScnRender.m_mesh[drawEnt] = rDrawing.m_meshRefCounts.ref_add(cubeMeshId); + rScnRender.m_meshDirty.push_back(drawEnt); + rScnRender.m_visible.set(std::size_t(drawEnt)); + rScnRender.m_opaque.set(std::size_t(drawEnt)); + rMatAxis.m_ents.set(std::size_t(drawEnt)); + rMatAxis.m_dirty.push_back(drawEnt); + } + + rScnRender.m_color[rPlanetDraw.axis[0]] = {1.0f, 0.0f, 0.0f, 1.0f}; + rScnRender.m_color[rPlanetDraw.axis[1]] = {0.0f, 1.0f, 0.0f, 1.0f}; + rScnRender.m_color[rPlanetDraw.axis[2]] = {0.0f, 0.0f, 1.0f, 1.0f}; + }); + + rBuilder.task() + .name ("Reposition test planet DrawEnts") + .run_on ({tgScnRdr.render(Run)}) + .sync_with ({tgScnRdr.drawTransforms(Modify_), tgScnRdr.drawEntResized(Done), tgCmCt.camCtrl(Ready), tgUSFrm.sceneFrame(Modify)}) + .push_to (out.m_tasks) + .args ({ idDrawing, idScnRender, idPlanetDraw, idUniverse, idScnFrame, idPlanetMainSpace}) + .func([] (ACtxDrawing& rDrawing, ACtxSceneRender& rScnRender, PlanetDraw& rPlanetDraw, Universe& rUniverse, SceneFrame const& rScnFrame, CoSpaceId const planetMainSpace) noexcept + { + + CoSpaceCommon &rMainSpace = rUniverse.m_coordCommon[planetMainSpace]; + auto const [x, y, z] = sat_views(rMainSpace.m_satPositions, rMainSpace.m_data, rMainSpace.m_satCount); + auto const [qx, qy, qz, qw] = sat_views(rMainSpace.m_satRotations, rMainSpace.m_data, rMainSpace.m_satCount); + + // Calculate transform from universe to area/local-space for rendering. + // This can be generalized by finding a common ancestor within the tree + // of coordinate spaces. Since there's only two possibilities, an if + // statement works. + CoordTransformer mainToArea; + if (rScnFrame.m_parent == planetMainSpace) + { + mainToArea = coord_parent_to_child(rMainSpace, rScnFrame); + } + else + { + CoSpaceId const landedId = rScnFrame.m_parent; + CoSpaceCommon &rLanded = rUniverse.m_coordCommon[landedId]; + + CoSpaceTransform const landedTf = coord_get_transform(rLanded, rLanded, x, y, z, qx, qy, qz, qw); + CoordTransformer const mainToLanded = coord_parent_to_child(rMainSpace, landedTf); + CoordTransformer const landedToArea = coord_parent_to_child(landedTf, rScnFrame); + + mainToArea = coord_composite(landedToArea, mainToLanded); + } + Quaternion const mainToAreaRot{mainToArea.rotation()}; + + float const scale = math::mul_2pow(1.0f, -rMainSpace.m_precision); + + Vector3 const attractorPos = Vector3(mainToArea.transform_position({0, 0, 0})) * scale; + + // Attractor + rScnRender.m_drawTransform[rPlanetDraw.attractor] + = Matrix4::translation(attractorPos) + * Matrix4{mainToAreaRot.toMatrix()} + * Matrix4::scaling({500, 500, 500}); + + rScnRender.m_drawTransform[rPlanetDraw.axis[0]] + = Matrix4::translation(attractorPos) + * Matrix4{mainToAreaRot.toMatrix()} + * Matrix4::scaling({500000, 10, 10}); + rScnRender.m_drawTransform[rPlanetDraw.axis[1]] + = Matrix4::translation(attractorPos) + * Matrix4{mainToAreaRot.toMatrix()} + * Matrix4::scaling({10, 500000, 10}); + rScnRender.m_drawTransform[rPlanetDraw.axis[2]] + = Matrix4::translation(attractorPos) + * Matrix4{mainToAreaRot.toMatrix()} + * Matrix4::scaling({10, 10, 500000}); + + for (std::size_t i = 0; i < rMainSpace.m_satCount; ++i) + { + Vector3g const relative = mainToArea.transform_position({x[i], y[i], z[i]}); + Vector3 const relativeMeters = Vector3(relative) * scale; + + Quaterniond const rot{{qx[i], qy[i], qz[i]}, qw[i]}; + + DrawEnt const drawEnt = rPlanetDraw.drawEnts[i]; + + rScnRender.m_drawTransform[drawEnt] + = Matrix4::translation(relativeMeters) + * Matrix4::scaling({200, 200, 200}) + * Matrix4{(mainToAreaRot * Quaternion{rot}).toMatrix()}; + } + + }); + + return out; +} // setup_testplanets_draw + } // namespace testapp::scenes diff --git a/src/test_application/activescenes/scene_universe.h b/src/testapp/sessions/universe.h similarity index 74% rename from src/test_application/activescenes/scene_universe.h rename to src/testapp/sessions/universe.h index a10d7db3..94039d16 100644 --- a/src/test_application/activescenes/scene_universe.h +++ b/src/testapp/sessions/universe.h @@ -24,7 +24,9 @@ */ #pragma once -#include "scenarios.h" +#include "../scenarios.h" + +#include namespace testapp::scenes { @@ -55,4 +57,19 @@ osp::Session setup_uni_testplanets( osp::Session const& uniScnFrame); +/** + * @brief Draw universe, specifically designed for setup_uni_test_planets + */ +osp::Session setup_testplanets_draw( + osp::TopTaskBuilder& rBuilder, + osp::ArrayView topData, + osp::Session const& windowApp, + osp::Session const& sceneRenderer, + osp::Session const& cameraCtrl, + osp::Session const& commonScene, + osp::Session const& uniCore, + osp::Session const& uniScnFrame, + osp::Session const& uniTestPlanets, + osp::draw::MaterialId const matPlanets, + osp::draw::MaterialId const matAxis); } diff --git a/src/test_application/activescenes/scene_vehicles.cpp b/src/testapp/sessions/vehicles.cpp similarity index 99% rename from src/test_application/activescenes/scene_vehicles.cpp rename to src/testapp/sessions/vehicles.cpp index 5b5d862b..e04cc2b6 100644 --- a/src/test_application/activescenes/scene_vehicles.cpp +++ b/src/testapp/sessions/vehicles.cpp @@ -22,23 +22,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "scene_vehicles.h" -#include "scenarios.h" -#include "identifiers.h" -#include "CameraController.h" -#include "../VehicleBuilder.h" +#include "vehicles.h" +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include using namespace osp; using namespace osp::active; diff --git a/src/test_application/activescenes/scene_vehicles.h b/src/testapp/sessions/vehicles.h similarity index 90% rename from src/test_application/activescenes/scene_vehicles.h rename to src/testapp/sessions/vehicles.h index 5ea998e5..aa3b8967 100644 --- a/src/test_application/activescenes/scene_vehicles.h +++ b/src/testapp/sessions/vehicles.h @@ -24,7 +24,7 @@ */ #pragma once -#include "scenarios.h" +#include "../scenarios.h" namespace testapp { struct VehicleData; } @@ -155,4 +155,20 @@ osp::Session setup_camera_vehicle( osp::Session const& vehicleControl); +/** + * @brief Red indicators over Magic Rockets + */ +osp::Session setup_thrust_indicators( + osp::TopTaskBuilder& rBuilder, + osp::ArrayView topData, + osp::Session const& magnum, + osp::Session const& commonScene, + osp::Session const& parts, + osp::Session const& signalsFloat, + osp::Session const& scnRender, + osp::Session const& cameraCtrl, + osp::Session const& shFlat, + osp::TopDataId const idResources, + osp::PkgId const pkg); + } diff --git a/src/test_application/testapp.cpp b/src/testapp/testapp.cpp similarity index 72% rename from src/test_application/testapp.cpp rename to src/testapp/testapp.cpp index 753623be..23e007f2 100644 --- a/src/test_application/testapp.cpp +++ b/src/testapp/testapp.cpp @@ -23,13 +23,14 @@ * SOFTWARE. */ #include "testapp.h" +#include "identifiers.h" -#include "activescenes/identifiers.h" - -#include -#include - +#include +#include +#include #include +#include +#include namespace testapp { @@ -150,4 +151,51 @@ void TestApp::clear_resource_owners() }); } + +//----------------------------------------------------------------------------- + + +void SingleThreadedExecutor::load(TestAppTasks& rAppTasks) +{ + osp::exec_conform(rAppTasks.m_tasks, m_execContext); + m_execContext.doLogging = m_log != nullptr; +} + +void SingleThreadedExecutor::run(TestAppTasks& rAppTasks, osp::PipelineId pipeline) +{ + osp::exec_request_run(m_execContext, pipeline); +} + +void SingleThreadedExecutor::signal(TestAppTasks& rAppTasks, osp::PipelineId pipeline) +{ + osp::exec_signal(m_execContext, pipeline); +} + +void SingleThreadedExecutor::wait(TestAppTasks& rAppTasks) +{ + if (m_log != nullptr) + { + m_log->info("\n>>>>>>>>>> Previous State Changes\n{}\n>>>>>>>>>> Current State\n{}\n", + osp::TopExecWriteLog {rAppTasks.m_tasks, rAppTasks.m_taskData, rAppTasks.m_graph, m_execContext}, + osp::TopExecWriteState{rAppTasks.m_tasks, rAppTasks.m_taskData, rAppTasks.m_graph, m_execContext} ); + m_execContext.logMsg.clear(); + } + + osp::exec_update(rAppTasks.m_tasks, rAppTasks.m_graph, m_execContext); + osp::top_run_blocking(rAppTasks.m_tasks, rAppTasks.m_graph, rAppTasks.m_taskData, rAppTasks.m_topData, m_execContext); + + if (m_log != nullptr) + { + m_log->info("\n>>>>>>>>>> New State Changes\n{}", + osp::TopExecWriteLog{rAppTasks.m_tasks, rAppTasks.m_taskData, rAppTasks.m_graph, m_execContext} ); + m_execContext.logMsg.clear(); + } +} + +bool SingleThreadedExecutor::is_running(TestAppTasks const& appTasks) +{ + return m_execContext.hasRequestRun || (m_execContext.pipelinesRunning != 0); +} + + } // namespace testapp diff --git a/src/test_application/testapp.h b/src/testapp/testapp.h similarity index 79% rename from src/test_application/testapp.h rename to src/testapp/testapp.h index 794ce1d5..bd57699f 100644 --- a/src/test_application/testapp.h +++ b/src/testapp/testapp.h @@ -24,14 +24,14 @@ */ #pragma once -#include - -#include - -#include - +#include +#include #include +#include #include +#include + +#include #include @@ -39,6 +39,7 @@ namespace testapp { struct TestApp; +class IExecutor; using RendererSetupFunc_t = void(*)(TestApp&); using SceneSetupFunc_t = RendererSetupFunc_t(*)(TestApp&); @@ -51,19 +52,6 @@ struct TestAppTasks osp::TaskGraph m_graph; }; -struct IExecutor -{ - virtual void load(TestAppTasks& rAppTasks) = 0; - - virtual void run(TestAppTasks& rAppTasks, osp::PipelineId pipeline) = 0; - - virtual void signal(TestAppTasks& rAppTasks, osp::PipelineId pipeline) = 0; - - virtual void wait(TestAppTasks& rAppTasks) = 0; - - virtual bool is_running(TestAppTasks const& rAppTasks) = 0; -}; - struct TestApp : TestAppTasks { void close_sessions(osp::ArrayView sessions); @@ -91,5 +79,38 @@ struct TestApp : TestAppTasks osp::PkgId m_defaultPkg { lgrn::id_null() }; }; +class IExecutor +{ +public: + + virtual void load(TestAppTasks& rAppTasks) = 0; + + virtual void run(TestAppTasks& rAppTasks, osp::PipelineId pipeline) = 0; + + virtual void signal(TestAppTasks& rAppTasks, osp::PipelineId pipeline) = 0; + + virtual void wait(TestAppTasks& rAppTasks) = 0; + + virtual bool is_running(TestAppTasks const& rAppTasks) = 0; +}; + +//----------------------------------------------------------------------------- + +class SingleThreadedExecutor final : public IExecutor +{ +public: + void load(TestAppTasks& rAppTasks) override; + + void run(TestAppTasks& rAppTasks, osp::PipelineId pipeline) override; + + void signal(TestAppTasks& rAppTasks, osp::PipelineId pipeline) override; + + void wait(TestAppTasks& rAppTasks) override; + + bool is_running(TestAppTasks const& rAppTasks) override; + + osp::ExecContext m_execContext; + std::shared_ptr m_log; +}; } // namespace testapp diff --git a/test/resources/CMakeLists.txt b/test/resources/CMakeLists.txt index 16df3b18..13719b66 100644 --- a/test/resources/CMakeLists.txt +++ b/test/resources/CMakeLists.txt @@ -27,4 +27,4 @@ ADD_TEST_DIRECTORY(${PROJECT_NAME}) # workaround? TARGET_LINK_LIBRARIES(test_resources PRIVATE longeron EnTT::EnTT) -TARGET_SOURCES(test_resources PRIVATE "${CMAKE_SOURCE_DIR}/src/osp/Resource/resources.cpp") +TARGET_SOURCES(test_resources PRIVATE "${CMAKE_SOURCE_DIR}/src/osp/core/Resources.cpp") diff --git a/test/resources/main.cpp b/test/resources/main.cpp index 062c3b2e..0b52674c 100644 --- a/test/resources/main.cpp +++ b/test/resources/main.cpp @@ -22,7 +22,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include +#include +#include #include diff --git a/test/shared_string/main.cpp b/test/shared_string/main.cpp index 3a15a7dd..adffeb0e 100644 --- a/test/shared_string/main.cpp +++ b/test/shared_string/main.cpp @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include +#include #include diff --git a/test/string_concat/main.cpp b/test/string_concat/main.cpp index 1dfef5c3..a9a0ba78 100644 --- a/test/string_concat/main.cpp +++ b/test/string_concat/main.cpp @@ -22,8 +22,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include -#include +#include +#include #include diff --git a/test/universe/main.cpp b/test/universe/main.cpp index 19724acd..3decf39e 100644 --- a/test/universe/main.cpp +++ b/test/universe/main.cpp @@ -24,7 +24,7 @@ */ #include #include -#include +#include #include