diff --git a/CMakeLists.txt b/CMakeLists.txt index b03431419..a0de8a35f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,12 @@ cmake_dependent_option(TARGET_GLES2 "Build for OpenGL ES 2" ON "TARGET_GLES" OFF # Parts of the library option(WITH_EVERYTHING "Build everything (doesn't include *Application libraries)" ON) -cmake_dependent_option(WITH_MESHTOOLS "Build MeshTools library" OFF "NOT WITH_EVERYTHING;NOT WITH_PHYSICS" ON) -cmake_dependent_option(WITH_PHYSICS "Build Physics library" OFF "NOT WITH_EVERYTHING" ON) -cmake_dependent_option(WITH_PRIMITIVES "Builf Primitives library" OFF "NOT WITH_EVERYTHING;NOT WITH_PHYSICS" ON) -cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" OFF "NOT WITH_EVERYTHING;NOT WITH_PHYSICS" ON) -cmake_dependent_option(WITH_SHADERS "Build Shaders library" OFF "NOT WITH_EVERYTHING;NOT WITH_PHYSICS" ON) +cmake_dependent_option(WITH_DEBUGTOOLS "Build DebugTools library" OFF "NOT WITH_EVERYTHING" ON) +cmake_dependent_option(WITH_MESHTOOLS "Build MeshTools library" OFF "NOT WITH_EVERYTHING;NOT WITH_DEBUGTOOLS" ON) +cmake_dependent_option(WITH_PHYSICS "Build Physics library" OFF "NOT WITH_EVERYTHING;NOT WITH_DEBUGTOOLS" ON) +cmake_dependent_option(WITH_PRIMITIVES "Builf Primitives library" OFF "NOT WITH_EVERYTHING;NOT WITH_DEBUGTOOLS" ON) +cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" OFF "NOT WITH_EVERYTHING;NOT WITH_DEBUGTOOLS" ON) +cmake_dependent_option(WITH_SHADERS "Build Shaders library" OFF "NOT WITH_EVERYTHING;NOT WITH_DEBUGTOOLS" ON) cmake_dependent_option(WITH_MAGNUMINFO "Build magnum-info utility" OFF "NOT WITH_EVERYTHING" ON) diff --git a/doc/building.dox b/doc/building.dox index 4014adb3d..9d2d6ecda 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -66,6 +66,8 @@ specify which parts will be built and which not: - `WITH_EVERYTHING` - Defaults to `ON`, builds everything except application libraries. If set to `OFF`, only the main library is built and you can select additional components with the following: + - `WITH_DEBUGTOOLS` - DebugTools library. Enables also building of MeshTools, + Physics, Primitives, SceneGraph and Shaders libraries. - `WITH_MESHTOOLS` - MeshTools library. - `WITH_PHYSICS` - Physics library. - `WITH_PRIMITIVES` - Primitives library. diff --git a/doc/mainpage.dox b/doc/mainpage.dox index b262155a7..27a0ec6db 100644 --- a/doc/mainpage.dox +++ b/doc/mainpage.dox @@ -13,7 +13,7 @@ Features: @ref Framebuffer "framebuffer" and @ref AbstractQuery "occlusion queries". - @ref MeshTools "Mesh tools" for cleaning, optimizing and generating meshes, utility classes for @ref Color.h "color conversion", @ref Timeline "timeline" - and @ref Profiler "profiling". + and @ref DebugTools::Profiler "profiling". - Hierarchical @ref SceneGraph "scene graph" which supports transformation caching for better performance, @ref Physics "physics library" for collision detection and rigid body dynamics. diff --git a/doc/namespaces.dox b/doc/namespaces.dox index 7e0f7c08e..915f3c0b2 100644 --- a/doc/namespaces.dox +++ b/doc/namespaces.dox @@ -47,6 +47,15 @@ Various matrix and vector algorithms. Functions for computing intersections, distances, areas and volumes. */ +/** @dir DebugTools + * @brief Namespace Magnum::DebugTools + */ +/** @namespace Magnum::DebugTools +@brief %Debug tools + +Debugging helpers, renderers and profilers. +*/ + /** @dir MeshTools * @brief Namespace Magnum::MeshTools */ diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 6a69a0d03..be3423bc4 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -15,9 +15,10 @@ # components. The base library depends on Corrade, OpenGL and GLEW # libraries. Additional dependencies are specified by the components. The # optional components are: +# DebugTools - DebugTools library (depends on MeshTools, Physics, +# Primitives, SceneGraph and Shaders components) # MeshTools - MeshTools library -# Physics - Physics library (depends on Primitives, SceneGraph and -# Shaders components) +# Physics - Physics library # Primitives - Library with stock geometric primitives (static) # SceneGraph - Scene graph library # Shaders - Library with stock shaders @@ -166,6 +167,11 @@ foreach(component ${Magnum_FIND_COMPONENTS}) endif() endif() + # DebugTools library + if(${component} STREQUAL DebugTools) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Profiler.h) + endif() + # Mesh tools library if(${component} STREQUAL MeshTools) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES CompressIndices.h) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eb5732e97..ed702f4f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,7 +23,6 @@ set(Magnum_SRCS Image.cpp IndexedMesh.cpp Mesh.cpp - Profiler.cpp Query.cpp Renderbuffer.cpp Resource.cpp @@ -72,7 +71,6 @@ set(Magnum_HEADERS IndexedMesh.h Magnum.h Mesh.h - Profiler.h Query.h Renderbuffer.h Renderer.h @@ -140,6 +138,10 @@ add_subdirectory(Platform) add_subdirectory(Math) add_subdirectory(Trade) +if(WITH_DEBUGTOOLS) + add_subdirectory(DebugTools) +endif() + if(WITH_MESHTOOLS) add_subdirectory(MeshTools) endif() diff --git a/src/DebugTools/CMakeLists.txt b/src/DebugTools/CMakeLists.txt new file mode 100644 index 000000000..3b6f17daf --- /dev/null +++ b/src/DebugTools/CMakeLists.txt @@ -0,0 +1,24 @@ +set(MagnumDebugTools_SRCS + Profiler.cpp + ResourceManager.cpp + ShapeRenderer.cpp + + Implementation/AbstractBoxRenderer.cpp + Implementation/AbstractShapeRenderer.cpp + Implementation/AxisAlignedBoxRenderer.cpp + Implementation/BoxRenderer.cpp) + +set(MagnumDebugTools_HEADERS + DebugTools.h + Profiler.h + ResourceManager.h + ShapeRenderer.h + + magnumDebugToolsVisibility.h) + +add_library(MagnumDebugTools SHARED ${MagnumDebugTools_SRCS}) + +target_link_libraries(MagnumDebugTools Magnum MagnumPhysics MagnumPrimitives MagnumSceneGraph MagnumShaders) + +install(TARGETS MagnumDebugTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +install(FILES ${MagnumDebugTools_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/DebugTools) diff --git a/src/DebugTools/DebugTools.h b/src/DebugTools/DebugTools.h new file mode 100644 index 000000000..82ab4d2b3 --- /dev/null +++ b/src/DebugTools/DebugTools.h @@ -0,0 +1,33 @@ +#ifndef Magnum_DebugTools_DebugTools_h +#define Magnum_DebugTools_DebugTools_h +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +/** @file + * @brief Forward declarations for Magnum::DebugTools namespace + */ + +#include + +namespace Magnum { namespace DebugTools { + +class Profiler; +class ResourceManager; +template class ShapeRenderer; +struct ShapeRendererOptions; + +}} + +#endif diff --git a/src/Physics/Implementation/AbstractBoxRenderer.cpp b/src/DebugTools/Implementation/AbstractBoxRenderer.cpp similarity index 77% rename from src/Physics/Implementation/AbstractBoxRenderer.cpp rename to src/DebugTools/Implementation/AbstractBoxRenderer.cpp index 95e7cdaeb..d22610977 100644 --- a/src/Physics/Implementation/AbstractBoxRenderer.cpp +++ b/src/DebugTools/Implementation/AbstractBoxRenderer.cpp @@ -16,12 +16,12 @@ #include "AbstractBoxRenderer.h" #include "Buffer.h" -#include "Physics/DebugDrawResourceManager.h" +#include "DebugTools/ResourceManager.h" #include "Primitives/Cube.h" #include "Primitives/Square.h" #include "Shaders/FlatShader.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace DebugTools { namespace Implementation { namespace { template struct BoxMesh {}; @@ -55,10 +55,10 @@ namespace { }; } -template AbstractBoxRenderer::AbstractBoxRenderer(): AbstractDebugRenderer(BoxMesh::shader(), BoxMesh::key()), buffer(DebugDrawResourceManager::instance()->get(BoxMesh::key())) { +template AbstractBoxRenderer::AbstractBoxRenderer(): AbstractShapeRenderer(BoxMesh::shader(), BoxMesh::key()), buffer(ResourceManager::instance()->get(BoxMesh::key())) { if(!this->mesh) { - DebugDrawResourceManager::instance()->set(this->buffer.key(), new Buffer, ResourceDataState::Final, ResourcePolicy::Manual); - DebugDrawResourceManager::instance()->set(this->mesh.key(), BoxMesh::mesh(buffer), ResourceDataState::Final, ResourcePolicy::Manual); + ResourceManager::instance()->set(this->buffer.key(), new Buffer, ResourceDataState::Final, ResourcePolicy::Manual); + ResourceManager::instance()->set(this->mesh.key(), BoxMesh::mesh(buffer), ResourceDataState::Final, ResourcePolicy::Manual); } } diff --git a/src/Physics/Implementation/AbstractBoxRenderer.h b/src/DebugTools/Implementation/AbstractBoxRenderer.h similarity index 75% rename from src/Physics/Implementation/AbstractBoxRenderer.h rename to src/DebugTools/Implementation/AbstractBoxRenderer.h index 2c7bcea28..ef3023527 100644 --- a/src/Physics/Implementation/AbstractBoxRenderer.h +++ b/src/DebugTools/Implementation/AbstractBoxRenderer.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Implementation_AbstractBoxRenderer_h -#define Magnum_Physics_Implementation_AbstractBoxRenderer_h +#ifndef Magnum_DebugTools_Implementation_AbstractBoxRenderer_h +#define Magnum_DebugTools_Implementation_AbstractBoxRenderer_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -15,13 +15,13 @@ GNU Lesser General Public License version 3 for more details. */ -#include "AbstractDebugRenderer.h" +#include "AbstractShapeRenderer.h" #include "corradeCompatibility.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace DebugTools { namespace Implementation { -template class AbstractBoxRenderer: public AbstractDebugRenderer { +template class AbstractBoxRenderer: public AbstractShapeRenderer { public: AbstractBoxRenderer(); diff --git a/src/Physics/Implementation/AbstractShapeRenderer.cpp b/src/DebugTools/Implementation/AbstractShapeRenderer.cpp similarity index 77% rename from src/Physics/Implementation/AbstractShapeRenderer.cpp rename to src/DebugTools/Implementation/AbstractShapeRenderer.cpp index ee4d3596e..0ddb6964c 100644 --- a/src/Physics/Implementation/AbstractShapeRenderer.cpp +++ b/src/DebugTools/Implementation/AbstractShapeRenderer.cpp @@ -17,12 +17,12 @@ #include "AbstractShaderProgram.h" #include "Mesh.h" -#include "Physics/DebugDrawResourceManager.h" +#include "DebugTools/ResourceManager.h" #include "Shaders/FlatShader.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace DebugTools { namespace Implementation { -template AbstractShapeRenderer::AbstractShapeRenderer(ResourceKey shader, ResourceKey mesh): shader(DebugDrawResourceManager::instance()->get>(shader)), mesh(DebugDrawResourceManager::instance()->get(mesh)) {} +template AbstractShapeRenderer::AbstractShapeRenderer(ResourceKey shader, ResourceKey mesh): shader(ResourceManager::instance()->get>(shader)), mesh(ResourceManager::instance()->get(mesh)) {} template AbstractShapeRenderer::~AbstractShapeRenderer() {} diff --git a/src/Physics/Implementation/AbstractShapeRenderer.h b/src/DebugTools/Implementation/AbstractShapeRenderer.h similarity index 66% rename from src/Physics/Implementation/AbstractShapeRenderer.h rename to src/DebugTools/Implementation/AbstractShapeRenderer.h index 737e29895..adec6e7fe 100644 --- a/src/Physics/Implementation/AbstractShapeRenderer.h +++ b/src/DebugTools/Implementation/AbstractShapeRenderer.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Implementation_AbstractShapeRenderer_h -#define Magnum_Physics_Implementation_AbstractShapeRenderer_h +#ifndef Magnum_DebugTools_Implementation_AbstractShapeRenderer_h +#define Magnum_DebugTools_Implementation_AbstractShapeRenderer_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -18,19 +18,10 @@ #include "DimensionTraits.h" #include "ResourceManager.h" #include "SceneGraph/SceneGraph.h" +#include "Shaders/Shaders.h" +#include "DebugTools/DebugTools.h" -namespace Magnum { - -class AbstractShaderProgram; -class Mesh; - -namespace Shaders { - template class FlatShader; -} - -namespace Physics { namespace Implementation { - -struct Options; +namespace Magnum { namespace DebugTools { namespace Implementation { template class AbstractShapeRenderer { public: @@ -38,7 +29,7 @@ template class AbstractShapeRenderer { virtual ~AbstractShapeRenderer(); - virtual void draw(Resource& options, const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) = 0; + virtual void draw(Resource& options, const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) = 0; protected: Resource> shader; diff --git a/src/Physics/Implementation/AxisAlignedBoxRenderer.cpp b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp similarity index 80% rename from src/Physics/Implementation/AxisAlignedBoxRenderer.cpp rename to src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp index 97102bf35..507682d9a 100644 --- a/src/Physics/Implementation/AxisAlignedBoxRenderer.cpp +++ b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp @@ -16,13 +16,14 @@ #include "AxisAlignedBoxRenderer.h" #include "Mesh.h" -#include "Physics/DebugDrawResourceManager.h" +#include "DebugTools/ResourceManager.h" +#include "DebugTools/ShapeRenderer.h" #include "SceneGraph/AbstractCamera.h" #include "Shaders/FlatShader.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace DebugTools { namespace Implementation { -template void AxisAlignedBoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType&, typename SceneGraph::AbstractCamera* camera) { +template void AxisAlignedBoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType&, typename SceneGraph::AbstractCamera* camera) { typename DimensionTraits::MatrixType transformation = DimensionTraits::MatrixType::translation(axisAlignedBox.transformedPosition())* DimensionTraits::MatrixType::scaling(axisAlignedBox.transformedSize()); diff --git a/src/Physics/Implementation/AxisAlignedBoxRenderer.h b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.h similarity index 58% rename from src/Physics/Implementation/AxisAlignedBoxRenderer.h rename to src/DebugTools/Implementation/AxisAlignedBoxRenderer.h index 7eae09acf..cf1120433 100644 --- a/src/Physics/Implementation/AxisAlignedBoxRenderer.h +++ b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Implementation_AxisAlignedBoxRenderer_h -#define Magnum_Physics_Implementation_AxisAlignedBoxRenderer_h +#ifndef Magnum_DebugTools_Implementation_AxisAlignedBoxRenderer_h +#define Magnum_DebugTools_Implementation_AxisAlignedBoxRenderer_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -21,16 +21,16 @@ #include "corradeCompatibility.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace DebugTools { namespace Implementation { template class AxisAlignedBoxRenderer: public AbstractBoxRenderer { public: - inline AxisAlignedBoxRenderer(AxisAlignedBox& axisAlignedBox): axisAlignedBox(axisAlignedBox) {} + inline AxisAlignedBoxRenderer(Physics::AxisAlignedBox& axisAlignedBox): axisAlignedBox(axisAlignedBox) {} - void draw(Resource& options, const typename DimensionTraits::MatrixType& transformation, typename SceneGraph::AbstractCamera* camera) override; + void draw(Resource& options, const typename DimensionTraits::MatrixType& transformation, typename SceneGraph::AbstractCamera* camera) override; private: - AxisAlignedBox& axisAlignedBox; + Physics::AxisAlignedBox& axisAlignedBox; }; }}} diff --git a/src/Physics/Implementation/BoxRenderer.cpp b/src/DebugTools/Implementation/BoxRenderer.cpp similarity index 76% rename from src/Physics/Implementation/BoxRenderer.cpp rename to src/DebugTools/Implementation/BoxRenderer.cpp index 840c6b306..a11ade2e7 100644 --- a/src/Physics/Implementation/BoxRenderer.cpp +++ b/src/DebugTools/Implementation/BoxRenderer.cpp @@ -16,13 +16,14 @@ #include "BoxRenderer.h" #include "Mesh.h" -#include "Physics/DebugDrawResourceManager.h" +#include "DebugTools/ResourceManager.h" +#include "DebugTools/ShapeRenderer.h" #include "SceneGraph/AbstractCamera.h" #include "Shaders/FlatShader.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace DebugTools { namespace Implementation { -template void BoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType&, typename SceneGraph::AbstractCamera* camera) { +template void BoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType&, typename SceneGraph::AbstractCamera* camera) { this->shader->setTransformationProjectionMatrix(camera->projectionMatrix()*camera->cameraMatrix()*box.transformedTransformation()) ->setColor(options->color) ->use(); diff --git a/src/Physics/Implementation/BoxRenderer.h b/src/DebugTools/Implementation/BoxRenderer.h similarity index 62% rename from src/Physics/Implementation/BoxRenderer.h rename to src/DebugTools/Implementation/BoxRenderer.h index ef67869fd..acaf154f6 100644 --- a/src/Physics/Implementation/BoxRenderer.h +++ b/src/DebugTools/Implementation/BoxRenderer.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Physics_Implementation_BoxRenderer_h -#define Magnum_Physics_Implementation_BoxRenderer_h +#ifndef Magnum_DebugTools_Implementation_BoxRenderer_h +#define Magnum_DebugTools_Implementation_BoxRenderer_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -21,16 +21,16 @@ #include "corradeCompatibility.h" -namespace Magnum { namespace Physics { namespace Implementation { +namespace Magnum { namespace DebugTools { namespace Implementation { template class BoxRenderer: public AbstractBoxRenderer { public: - inline BoxRenderer(Box& box): box(box) {} + inline BoxRenderer(Physics::Box& box): box(box) {} - void draw(Resource& options, const typename DimensionTraits::MatrixType& transformation, typename SceneGraph::AbstractCamera* camera) override; + void draw(Resource& options, const typename DimensionTraits::MatrixType& transformation, typename SceneGraph::AbstractCamera* camera) override; private: - Box& box; + Physics::Box& box; }; }}} diff --git a/src/Profiler.cpp b/src/DebugTools/Profiler.cpp similarity index 98% rename from src/Profiler.cpp rename to src/DebugTools/Profiler.cpp index 5682c3072..288ba1392 100644 --- a/src/Profiler.cpp +++ b/src/DebugTools/Profiler.cpp @@ -21,7 +21,7 @@ #include "Magnum.h" -namespace Magnum { +namespace Magnum { namespace DebugTools { Profiler::Section Profiler::addSection(const std::string& name) { CORRADE_ASSERT(!enabled, "Profiler: cannot add section when profiling is enabled", 0); @@ -108,4 +108,4 @@ void Profiler::printStatistics() { Debug() << ' ' << sections[totalSorted[i]] << std::chrono::microseconds(totalData[totalSorted[i]]).count()/frameCount << u8"µs"; } -} +}} diff --git a/src/Profiler.h b/src/DebugTools/Profiler.h similarity index 93% rename from src/Profiler.h rename to src/DebugTools/Profiler.h index 173b00b17..29f541f0a 100644 --- a/src/Profiler.h +++ b/src/DebugTools/Profiler.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Profiler_h -#define Magnum_Profiler_h +#ifndef Magnum_DebugTools_Profiler_h +#define Magnum_DebugTools_Profiler_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Profiler + * @brief Class Magnum::DebugTools::Profiler */ #include @@ -24,22 +24,22 @@ #include #include -#include "magnumVisibility.h" +#include "magnumDebugToolsVisibility.h" -namespace Magnum { +namespace Magnum { namespace DebugTools { /** -@brief Measuring elapsed time in each frame +@brief %Profiler Measures time passed during specified sections of each frame. It's meant to be used in rendering and event loops (e.g. Platform::GlutApplication::drawEvent()), but it's possible to use it standalone elsewhere. Example usage: @code -Profiler p; +DebugTools::Profiler p; // Register named sections struct { - Profiler::Section ai, physics, draw, bufferSwap; + DebugTools::Profiler::Section ai, physics, draw, bufferSwap; } sections; sections.ai = p.addSection("AI"); sections.physics = p.addSection("Physics"); @@ -88,7 +88,7 @@ stop it again using stop(), if you are not interested in profiling the rest. @todo Some unit testing @todo More time intervals */ -class MAGNUM_EXPORT Profiler { +class MAGNUM_DEBUGTOOLS_EXPORT Profiler { public: /** * @brief Section ID @@ -201,6 +201,6 @@ class MAGNUM_EXPORT Profiler { Section currentSection; }; -} +}} #endif diff --git a/src/DebugTools/ResourceManager.cpp b/src/DebugTools/ResourceManager.cpp new file mode 100644 index 000000000..5e85d0f48 --- /dev/null +++ b/src/DebugTools/ResourceManager.cpp @@ -0,0 +1,38 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#define MAGNUM_RESOURCEMANAGER_DEFINE_INTERNALINSTANCE + +#include "ResourceManager.h" + +#include "Buffer.h" +#include "Mesh.h" +#include "Shaders/FlatShader.h" +#include "ShapeRenderer.h" + +namespace Magnum { + +template class ResourceManager; + +namespace DebugTools { + +ResourceManager::ResourceManager() { + setFallback(new ShapeRendererOptions); + set("shader2d", new Shaders::FlatShader<2>, ResourceDataState::Final, ResourcePolicy::Resident); +} + +ResourceManager::~ResourceManager() {} + +}} diff --git a/src/DebugTools/ResourceManager.h b/src/DebugTools/ResourceManager.h new file mode 100644 index 000000000..98ca34956 --- /dev/null +++ b/src/DebugTools/ResourceManager.h @@ -0,0 +1,54 @@ +#ifndef Magnum_DebugTools_ResourceManager_h +#define Magnum_DebugTools_ResourceManager_h +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +/** @file + * @brief Class Magnum::DebugTools::ResourceManager + */ + +#include "Magnum.h" + +#ifndef MAGNUM_RESOURCEMANAGER_DEFINE_INTERNALINSTANCE +#define MAGNUM_RESOURCEMANAGER_DONT_DEFINE_INTERNALINSTANCE +#endif +#include "../ResourceManager.h" + +#include "SceneGraph/SceneGraph.h" +#include "Physics/Physics.h" +#include "DebugTools.h" + +#include "magnumDebugToolsVisibility.h" + +namespace Magnum { + +extern template ResourceManager MAGNUM_DEBUGTOOLS_EXPORT *& ResourceManager::internalInstance(); + +namespace DebugTools { + +/** +@brief %Resource manager for debug tools + +Stores various data used by debug renderers. +*/ +class MAGNUM_DEBUGTOOLS_EXPORT ResourceManager: public Magnum::ResourceManager { + public: + explicit ResourceManager(); + ~ResourceManager(); +}; + +}} + +#endif diff --git a/src/DebugTools/ShapeRenderer.cpp b/src/DebugTools/ShapeRenderer.cpp new file mode 100644 index 000000000..bb5f6fe6a --- /dev/null +++ b/src/DebugTools/ShapeRenderer.cpp @@ -0,0 +1,75 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include "ShapeRenderer.h" + +#include "ResourceManager.h" +#include "Physics/AbstractShape.h" +#include "Physics/AxisAlignedBox.h" +#include "Physics/Box.h" +#include "Physics/ObjectShape.h" +#include "Physics/ShapeGroup.h" + +#include "Implementation/AxisAlignedBoxRenderer.h" +#include "Implementation/BoxRenderer.h" + +namespace Magnum { namespace DebugTools { + +#ifndef DOXYGEN_GENERATING_OUTPUT +namespace Implementation { + +template<> void createDebugMesh(ShapeRenderer<2>* renderer, Physics::AbstractShape<2>* shape) { + switch(shape->type()) { + case Physics::AbstractShape2D::Type::AxisAlignedBox: + renderer->renderers.push_back(new Implementation::AxisAlignedBoxRenderer<2>(*static_cast(shape))); + case Physics::AbstractShape2D::Type::Box: + renderer->renderers.push_back(new Implementation::BoxRenderer<2>(*static_cast(shape))); + break; + case Physics::AbstractShape2D::Type::ShapeGroup: { + Physics::ShapeGroup2D* group = static_cast(shape); + if(group->first()) createDebugMesh(renderer, group->first()); + if(group->second()) createDebugMesh(renderer, group->second()); + } break; + default: + Warning() << "DebugTools::ShapeRenderer2D::createShapeRenderer(): type" << shape->type() << "not implemented"; + } +} + +template<> void createDebugMesh(ShapeRenderer<3>*, Physics::AbstractShape<3>* shape) { + switch(shape->type()) { + default: + Warning() << "DebugTools::ShapeRenderer3D::createShapeRenderer(): type" << shape->type() << "not implemented"; + } +} + +} +#endif + +template ShapeRenderer::ShapeRenderer(Physics::ObjectShape* shape, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(shape->object(), drawables), options(ResourceManager::instance()->get(options)) { + Implementation::createDebugMesh(this, shape->shape()); +} + +template ShapeRenderer::~ShapeRenderer() { + for(auto i: renderers) delete i; +} + +template void ShapeRenderer::draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) { + for(auto i: renderers) i->draw(options, transformationMatrix, camera); +} + +template class ShapeRenderer<2>; +template class ShapeRenderer<3>; + +}} diff --git a/src/DebugTools/ShapeRenderer.h b/src/DebugTools/ShapeRenderer.h new file mode 100644 index 000000000..0a600dff4 --- /dev/null +++ b/src/DebugTools/ShapeRenderer.h @@ -0,0 +1,119 @@ +#ifndef Magnum_DebugTools_ShapeRenderer_h +#define Magnum_DebugTools_ShapeRenderer_h +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include "Color.h" +#include "Resource.h" +#include "SceneGraph/Drawable.h" +#include "Physics/Physics.h" + +#include "magnumDebugToolsVisibility.h" + +namespace Magnum { namespace DebugTools { + +template class ShapeRenderer; + +#ifndef DOXYGEN_GENERATING_OUTPUT +namespace Implementation { + template class AbstractShapeRenderer; + + template void createDebugMesh(ShapeRenderer* renderer, Physics::AbstractShape* shape); +} +#endif + +/** +@brief Shape renderer options + +See ShapeRenderer documentation for more information. +*/ +struct ShapeRendererOptions { + Color3<> color; /**< @brief Color */ +}; + +/** +@brief Shape renderer + +Creates renderers for object collision shape. + +@section ShapeRenderer-usage Basic usage + +ResourceManager must be instanced for the whole lifetime of debug +renderers. You can specify options via Options struct - add it to the manager +and then create debug renderer with the same options key. This way you can +easily share the same options with more renderers. If no options for given key +exist, default is used. + +Example code: +@code +// Instance the manager at first +DebugTools::ResourceManager manager; + +// Group of drawables, preferrably dedicated for debug renderers, so you can +// easily enable or disable debug draw +SceneGraph::DrawableGroup2D debugDrawables; + +// Create some options +auto o = new DebugTools::ShapeRendererOptions { + {1.0f, 0.0f, 0.0f} // Red color +}; +manager->set("red", o, ResourceDataState::Final, ResourcePolicy::Persistent); + +// Create debug renderer for given shape, use "red" options for it +Physics::ObjectShape2D* shape; +debugDrawables.add(new DebugTools::ShapeRenderer2D(shape, "red", debugDrawables)); +@endcode + +@see ShapeRenderer2D, ShapeRenderer3D +*/ +template class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::Drawable { + #ifndef DOXYGEN_GENERATING_OUTPUT + friend void Implementation::createDebugMesh<>(ShapeRenderer*, Physics::AbstractShape*); + #endif + + public: + /** + * @brief Constructor + * @param shape Shape for which to create debug renderer + * @param options Options resource key. See + * @ref ShapeRenderer-usage "class documentation" for more + * information. + * @param drawables Drawable group + * + * @attention @p shape must be available for the whole lifetime of + * this class + */ + explicit ShapeRenderer(Physics::ObjectShape* shape, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); + + ~ShapeRenderer(); + + protected: + /** @todoc Remove GLfloat when Doxygen properly treats this as override */ + void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) override; + + private: + Resource options; + std::vector*> renderers; +}; + +/** @brief Two-dimensional shape renderer */ +typedef ShapeRenderer<2> ShapeRenderer2D; + +/** @brief Three-dimensional shape renderer */ +typedef ShapeRenderer<3> ShapeRenderer3D; + +}} + +#endif diff --git a/src/DebugTools/magnumDebugToolsVisibility.h b/src/DebugTools/magnumDebugToolsVisibility.h new file mode 100644 index 000000000..6032af2d1 --- /dev/null +++ b/src/DebugTools/magnumDebugToolsVisibility.h @@ -0,0 +1,28 @@ +#ifndef Magnum_DebugTools_magnumDebugToolsVisibility_h +#define Magnum_DebugTools_magnumDebugToolsVisibility_h +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#ifdef _WIN32 + #ifdef MagnumDebugTools_EXPORTS + #define MAGNUM_DEBUGTOOLS_EXPORT __declspec(dllexport) + #else + #define MAGNUM_DEBUGTOOLS_EXPORT __declspec(dllimport) + #endif +#else + #define MAGNUM_DEBUGTOOLS_EXPORT __attribute__ ((visibility ("default"))) +#endif + +#endif diff --git a/src/Magnum.h b/src/Magnum.h index 6e4cf7ee2..b4af2f8a3 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -175,7 +175,6 @@ typedef ImageWrapper<3> ImageWrapper3D; class IndexedMesh; class Mesh; -class Profiler; class Query; class Renderbuffer; diff --git a/src/Physics/CMakeLists.txt b/src/Physics/CMakeLists.txt index c2b35ce8a..a83dc21e3 100644 --- a/src/Physics/CMakeLists.txt +++ b/src/Physics/CMakeLists.txt @@ -3,26 +3,19 @@ set(MagnumPhysics_SRCS AxisAlignedBox.cpp Box.cpp Capsule.cpp - DebugDrawResourceManager.cpp Line.cpp Plane.cpp Point.cpp ObjectShape.cpp ObjectShapeGroup.cpp ShapeGroup.cpp - Sphere.cpp - - Implementation/AbstractBoxRenderer.cpp - Implementation/AbstractDebugRenderer.cpp - Implementation/AxisAlignedBoxRenderer.cpp - Implementation/BoxRenderer.cpp) + Sphere.cpp) set(MagnumPhysics_HEADERS AbstractShape.h AxisAlignedBox.h Box.h Capsule.h - DebugDrawResourceManager.h Line.h LineSegment.h ObjectShape.h diff --git a/src/Physics/DebugDrawResourceManager.cpp b/src/Physics/DebugDrawResourceManager.cpp deleted file mode 100644 index ba2560e02..000000000 --- a/src/Physics/DebugDrawResourceManager.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -#define MAGNUM_RESOURCEMANAGER_DEFINE_INTERNALINSTANCE - -#include "DebugDrawResourceManager.h" - -#include "AbstractShaderProgram.h" -#include "Buffer.h" -#include "Mesh.h" -#include "ResourceManager.h" -#include "Shaders/FlatShader.h" -#include "AbstractShape.h" -#include "AxisAlignedBox.h" -#include "Box.h" -#include "ObjectShape.h" -#include "ShapeGroup.h" -#include "Implementation/AxisAlignedBoxRenderer.h" -#include "Implementation/BoxRenderer.h" -#include "Implementation/DebugRenderer.h" - -namespace Magnum { - -template class ResourceManager; - -namespace Physics { - -template SceneGraph::Drawable* DebugDrawResourceManager::createDebugRenderer(ObjectShape* shape, ResourceKey options) { - Implementation::DebugRenderer* renderer = new Implementation::DebugRenderer(shape->object(), instance()->get(options)); - createDebugMesh(renderer, shape->shape()); - return renderer; -} - -template SceneGraph::Drawable<2> MAGNUM_PHYSICS_EXPORT * DebugDrawResourceManager::createDebugRenderer(ObjectShape<2>* shape, ResourceKey options); -template SceneGraph::Drawable<3> MAGNUM_PHYSICS_EXPORT * DebugDrawResourceManager::createDebugRenderer(ObjectShape<3>* shape, ResourceKey options); - -void DebugDrawResourceManager::createDebugMesh(Implementation::DebugRenderer<2>* renderer, AbstractShape2D* shape) { - switch(shape->type()) { - case AbstractShape2D::Type::AxisAlignedBox: - renderer->addRenderer(new Implementation::AxisAlignedBoxRenderer<2>(*static_cast(shape))); - case AbstractShape2D::Type::Box: - renderer->addRenderer(new Implementation::BoxRenderer<2>(*static_cast(shape))); - break; - case AbstractShape2D::Type::ShapeGroup: { - ShapeGroup2D* group = static_cast(shape); - if(group->first()) createDebugMesh(renderer, group->first()); - if(group->second()) createDebugMesh(renderer, group->second()); - break; - } - default: - Warning() << "Physics::DebugDrawResourceManager::createDebugRenderer(): type" << shape->type() << "not implemented"; - } -} - -void DebugDrawResourceManager::createDebugMesh(Implementation::DebugRenderer<3>*, AbstractShape3D*) {} - -DebugDrawResourceManager::DebugDrawResourceManager() { - setFallback(new Options); - set("shader2d", new Shaders::FlatShader<2>, ResourceDataState::Final, ResourcePolicy::Resident); -} - -DebugDrawResourceManager::~DebugDrawResourceManager() {} - -}} diff --git a/src/Physics/DebugDrawResourceManager.h b/src/Physics/DebugDrawResourceManager.h deleted file mode 100644 index 9381ac3f7..000000000 --- a/src/Physics/DebugDrawResourceManager.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef Magnum_Physics_DebugDrawResourceManager_h -#define Magnum_Physics_DebugDrawResourceManager_h -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -/** @file - * @brief Class Magnum::Physics::DebugDrawResourceManager - */ - -#include "Magnum.h" -#include "Color.h" - -#ifndef MAGNUM_RESOURCEMANAGER_DEFINE_INTERNALINSTANCE -#define MAGNUM_RESOURCEMANAGER_DONT_DEFINE_INTERNALINSTANCE -#endif -#include "ResourceManager.h" - -#include "SceneGraph/SceneGraph.h" -#include "Physics.h" - -#include "magnumPhysicsVisibility.h" - -namespace Magnum { - -#ifndef DOXYGEN_GENERATING_OUTPUT -namespace Physics { namespace Implementation { - struct Options { - Color3<> color; - }; - template class DebugRenderer; -}} -#endif - -extern template ResourceManager MAGNUM_PHYSICS_EXPORT *& ResourceManager::internalInstance(); - -namespace Physics { - -/** -@brief %Resource manager for physics debug draw - -Can create objects which draw object collision shape for debugging purposes. - -@section DebugDrawResourceManager-usage Basic usage -The manager must be instanced for the whole lifetime of debug draw objects. -To create debug renderers, call createDebugRenderer() and add the resulting -drawable to some group. You can specify options via Options struct - add it to -the manager and then create debug renderer with the same options key. This way -you can easily share the same options with more renderers. If no options for -given key exist, default is used. - -Example code: -@code -// Group of drawables,preferrably dedicated for debug renderers, so you can -// easily enable or disable debug draw -DrawableGroup2D group; - -// Instance the manager at first -DebugDrawResourceManager manager; - -// Create some options -auto o = new DebugDrawResourceManager::Options { - {1.0f, 0.0f, 0.0f} // Red color -}; -manager->set("red", o, ResourceDataState::Final, ResourcePolicy::Persistent); - -// Create debug renderer for given shape, use "red" options for it. Don't -// forget to add it to some drawable group. -ObjectShape2D* shape; -group.add(DebugDrawResourceManager::createDebugRenderer(shape, "red")); -@endcode -*/ -class MAGNUM_PHYSICS_EXPORT DebugDrawResourceManager: public ResourceManager { - public: - #ifdef DOXYGEN_GENERATING_OUTPUT - /** @brief %Options */ - struct Options { - Color3<> color; /**< @brief Color */ - }; - #else - typedef Implementation::Options Options; - #endif - - /** - * @brief Create debug renderer for given shape - * @param shape Shape for which to create debug renderer - * @param options Options resource key. See - * @ref DebugDrawResourceManager-usage "class documentation" for - * more information. - * - * Returned drawable is not part of any group, you have to add it to - * one yourself. - */ - template static SceneGraph::Drawable* createDebugRenderer(ObjectShape* shape, ResourceKey options = ResourceKey()); - - explicit DebugDrawResourceManager(); - ~DebugDrawResourceManager(); - - private: - static void createDebugMesh(Implementation::DebugRenderer<2>* renderer, AbstractShape2D* shape); - static void createDebugMesh(Implementation::DebugRenderer<3>* renderer, AbstractShape3D* shape); -}; - -}} - -#endif diff --git a/src/Physics/Implementation/AbstractDebugRenderer.cpp b/src/Physics/Implementation/AbstractDebugRenderer.cpp deleted file mode 100644 index dbd41dcd7..000000000 --- a/src/Physics/Implementation/AbstractDebugRenderer.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -#include "AbstractDebugRenderer.h" - -#include "AbstractShaderProgram.h" -#include "Mesh.h" -#include "Physics/DebugDrawResourceManager.h" -#include "Shaders/FlatShader.h" - -namespace Magnum { namespace Physics { namespace Implementation { - -template AbstractDebugRenderer::AbstractDebugRenderer(ResourceKey shader, ResourceKey mesh): shader(DebugDrawResourceManager::instance()->get>(shader)), mesh(DebugDrawResourceManager::instance()->get(mesh)) {} - -template AbstractDebugRenderer::~AbstractDebugRenderer() {} - -template class AbstractDebugRenderer<2>; -template class AbstractDebugRenderer<3>; - -}}} diff --git a/src/Physics/Implementation/AbstractDebugRenderer.h b/src/Physics/Implementation/AbstractDebugRenderer.h deleted file mode 100644 index 04e7a8a6b..000000000 --- a/src/Physics/Implementation/AbstractDebugRenderer.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef Magnum_Physics_Implementation_AbstractDebugRenderer_h -#define Magnum_Physics_Implementation_AbstractDebugRenderer_h -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -#include "DimensionTraits.h" -#include "ResourceManager.h" -#include "SceneGraph/SceneGraph.h" -#include "Shaders/Shaders.h" - -namespace Magnum { namespace Physics { namespace Implementation { - -struct Options; - -template class AbstractDebugRenderer { - public: - AbstractDebugRenderer(ResourceKey shader, ResourceKey mesh); - - virtual ~AbstractDebugRenderer(); - - virtual void draw(Resource& options, const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) = 0; - - protected: - Resource> shader; - Resource mesh; -}; - -}}} - -#endif diff --git a/src/Physics/Implementation/DebugRenderer.h b/src/Physics/Implementation/DebugRenderer.h deleted file mode 100644 index 87e806392..000000000 --- a/src/Physics/Implementation/DebugRenderer.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef Magnum_Physics_Implementation_DebugRenderer_h -#define Magnum_Physics_Implementation_DebugRenderer_h -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -#include "ResourceManager.h" -#include "SceneGraph/Drawable.h" -#include "AbstractDebugRenderer.h" - -namespace Magnum { - -class AbstractShaderProgram; -class Mesh; - -namespace Shaders { - template class FlatShader; -} - -namespace Physics { namespace Implementation { - -struct Options; - -template class DebugRenderer: public SceneGraph::Drawable { - public: - DebugRenderer(SceneGraph::AbstractObject* object, Resource&& options): SceneGraph::Drawable(object), options(options) {} - - inline ~DebugRenderer() { - for(auto i: renderers) delete i; - } - - inline void addRenderer(AbstractDebugRenderer* renderer) { - renderers.push_back(renderer); - } - - inline void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) override { - for(auto i: renderers) i->draw(options, transformationMatrix, camera); - } - - private: - Resource options; - std::vector*> renderers; -}; - -}}} - -#endif diff --git a/src/Physics/Physics.h b/src/Physics/Physics.h index aca5325fe..066c0a029 100644 --- a/src/Physics/Physics.h +++ b/src/Physics/Physics.h @@ -15,12 +15,12 @@ GNU Lesser General Public License version 3 for more details. */ -#include - /** @file * @brief Forward declarations for Magnum::Physics namespace */ +#include + namespace Magnum { namespace Physics { template class AbstractShape; @@ -39,8 +39,6 @@ template class Capsule; typedef Capsule<2> Capsule2D; typedef Capsule<3> Capsule3D; -class DebugDrawResourceManager; - template class Line; typedef Line<2> Line2D; typedef Line<3> Line3D; diff --git a/src/ResourceManager.h b/src/ResourceManager.h index 19bb8f1aa..1e6e68516 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -15,7 +15,7 @@ GNU Lesser General Public License version 3 for more details. */ -/** @file +/** @file /ResourceManager.h * @brief Class Magnum::ResourceManager, enum Magnum::ResourceDataState, Magnum::ResourcePolicy */