diff --git a/doc/scenegraph.dox b/doc/scenegraph.dox index f20938241..e72d7cf42 100644 --- a/doc/scenegraph.dox +++ b/doc/scenegraph.dox @@ -45,13 +45,11 @@ main components: @section scenegraph-transformation Transformations Transformation handles object position, rotation etc. and its basic property -is dimension count (2D or 3D) and underlying floating-point type (by default -@ref Float type is used everywhere, but you can use @ref Double too). +is dimension count (2D or 3D) and underlying floating-point type. -@note All classes in SceneGraph have Float as default underlying floating-point - type, which means that you can omit that template parameter and write just - %AbstractObject<2> or %MatrixTransformation3D<> instead of - %AbstractObject<2, Float> and %MatrixTransformation3D<Float>. +@note All classes in SceneGraph are templated on underlying type. However, in + most cases Float is used and thus nearly all classes have convenience + aliases so you don't have to explicitly specify it. %Scene graph has implementation of transformations in both 2D and 3D, using either matrices or combination of position and rotation. Each implementation @@ -74,8 +72,8 @@ in 2D and part in 3D just wouldn't make sense). Common usage is to typedef %Scene and %Object with desired transformation type to save unnecessary typing later: @code -typedef SceneGraph::Scene> Scene3D; -typedef SceneGraph::Object> Object3D; +typedef SceneGraph::Scene Scene3D; +typedef SceneGraph::Object Object3D; @endcode Then you can start building the hierarchy by *parenting* one object to another. @@ -149,9 +147,9 @@ implement needed functions in your own Object subclass without having to subclass each feature individually (and making the code overly verbose). Simplified example: @code -class Bomb: public Object3D, SceneGraph::Drawable3D<>, SceneGraph:.Animable3D<> { +class Bomb: public Object3D, SceneGraph::Drawable3D, SceneGraph:.Animable3D { public: - Bomb(Object3D* parent): Object3D(parent), SceneGraph::Drawable3D<>(this), SceneGraph::Animable3D<>(this) {} + Bomb(Object3D* parent): Object3D(parent), SceneGraph::Drawable3D(this), SceneGraph::Animable3D(this) {} protected: // drawing implementation for Drawable feature @@ -195,9 +193,9 @@ it first, because by default the caching is disabled. You can enable it using AbstractFeature::setCachedTransformations() and then implement corresponding cleaning function(s): @code -class CachingObject: public Object3D, SceneGraph::AbstractFeature3D<> { +class CachingObject: public Object3D, SceneGraph::AbstractFeature3D { public: - CachingObject(Object3D* parent): SceneGraph::AbstractFeature3D<>(this) { + CachingObject(Object3D* parent): SceneGraph::AbstractFeature3D(this) { setCachedTransformations(CachedTransformation::Absolute); } diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index 06e76489a..05fc4ef07 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -1457,8 +1457,8 @@ template struct Attribute>: Doubl template struct Attribute>: Attribute> {}; template struct Attribute>: Attribute> {}; template struct Attribute>: Attribute> {}; -template struct Attribute>: Attribute> {}; -template struct Attribute>: Attribute> {}; +template struct Attribute>: Attribute> {}; +template struct Attribute>: Attribute> {}; /* Common float and double rectangular matrix attributes */ template struct Attribute>: FloatAttribute, SizedAttribute {}; diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 18b64c2c6..4096e3dbf 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -208,7 +208,7 @@ class MAGNUM_EXPORT AbstractTexture { * with @def_gl{TEXTURE_BORDER_COLOR} * @requires_es_extension %Extension @es_extension{NV,texture_border_clamp} */ - AbstractTexture* setBorderColor(const Color4<>& color) { + AbstractTexture* setBorderColor(const Color4& color) { #ifndef MAGNUM_TARGET_GLES (this->*parameterfvImplementation)(GL_TEXTURE_BORDER_COLOR, color.data()); #else diff --git a/src/Color.h b/src/Color.h index fe7971a39..685e4c149 100644 --- a/src/Color.h +++ b/src/Color.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::Color3, Magnum::Color4 + * @brief Class Magnum::BasicColor3, Magnum::BasicColor4, typedef Magnum::Color3, Magnum::Color4 */ #include @@ -39,7 +39,7 @@ namespace Magnum { namespace Implementation { /* Convert color from HSV */ -template typename std::enable_if::value, Color3>::type fromHSV(typename Color3::HSV hsv) { +template typename std::enable_if::value, BasicColor3>::type fromHSV(typename BasicColor3::HSV hsv) { Math::Deg hue; T saturation, value; std::tie(hue, saturation, value) = hsv; @@ -65,12 +65,12 @@ template typename std::enable_if::value, Colo default: CORRADE_ASSERT_UNREACHABLE(); } } -template inline typename std::enable_if::value, Color3>::type fromHSV(typename Color3::HSV hsv) { - return Math::denormalize>(fromHSV::FloatingPointType>(hsv)); +template inline typename std::enable_if::value, BasicColor3>::type fromHSV(typename BasicColor3::HSV hsv) { + return Math::denormalize>(fromHSV::FloatingPointType>(hsv)); } /* Internal hue computing function */ -template Math::Deg hue(const Color3& color, T max, T delta) { +template Math::Deg hue(const BasicColor3& color, T max, T delta) { T deltaInv60 = T(60)/delta; T hue(0); @@ -87,40 +87,40 @@ template Math::Deg hue(const Color3& color, T max, T delta) { } /* Hue, saturation, value for floating-point types */ -template inline Math::Deg hue(typename std::enable_if::value, const Color3&>::type color) { +template inline Math::Deg hue(typename std::enable_if::value, const BasicColor3&>::type color) { T max = color.max(); T delta = max - color.min(); return hue(color, max, delta); } -template inline T saturation(typename std::enable_if::value, const Color3&>::type color) { +template inline T saturation(typename std::enable_if::value, const BasicColor3&>::type color) { T max = color.max(); T delta = max - color.min(); return max != T(0) ? delta/max : T(0); } -template inline T value(typename std::enable_if::value, const Color3&>::type color) { +template inline T value(typename std::enable_if::value, const BasicColor3&>::type color) { return color.max(); } /* Hue, saturation, value for integral types */ -template inline Math::Deg::FloatingPointType> hue(typename std::enable_if::value, const Color3&>::type color) { - return hue::FloatingPointType>(Math::normalize::FloatingPointType>>(color)); +template inline Math::Deg::FloatingPointType> hue(typename std::enable_if::value, const BasicColor3&>::type color) { + return hue::FloatingPointType>(Math::normalize::FloatingPointType>>(color)); } -template inline typename Color3::FloatingPointType saturation(typename std::enable_if::value, const Color3&>::type& color) { - return saturation::FloatingPointType>(Math::normalize::FloatingPointType>>(color)); +template inline typename BasicColor3::FloatingPointType saturation(typename std::enable_if::value, const BasicColor3&>::type& color) { + return saturation::FloatingPointType>(Math::normalize::FloatingPointType>>(color)); } -template inline typename Color3::FloatingPointType value(typename std::enable_if::value, const Color3&>::type color) { - return Math::normalize::FloatingPointType>(color.max()); +template inline typename BasicColor3::FloatingPointType value(typename std::enable_if::value, const BasicColor3&>::type color) { + return Math::normalize::FloatingPointType>(color.max()); } /* Convert color to HSV */ -template inline typename Color3::HSV toHSV(typename std::enable_if::value, const Color3&>::type color) { +template inline typename BasicColor3::HSV toHSV(typename std::enable_if::value, const BasicColor3&>::type color) { T max = color.max(); T delta = max - color.min(); - return typename Color3::HSV(hue::FloatingPointType>(color, max, delta), max != T(0) ? delta/max : T(0), max); + return typename BasicColor3::HSV(hue::FloatingPointType>(color, max, delta), max != T(0) ? delta/max : T(0), max); } -template inline typename Color3::HSV toHSV(typename std::enable_if::value, const Color3&>::type color) { - return toHSV::FloatingPointType>(Math::normalize::FloatingPointType>>(color)); +template inline typename BasicColor3::HSV toHSV(typename std::enable_if::value, const BasicColor3&>::type color) { + return toHSV::FloatingPointType>(Math::normalize::FloatingPointType>>(color)); } /* Default alpha value */ @@ -144,16 +144,11 @@ Conversion from and to HSV is done always using floating-point types, so hue is always in range in range @f$ [0.0, 360.0] @f$, saturation and value in range @f$ [0.0, 1.0] @f$. -@see Color4 +@see @ref Color3, @ref BasicColor4 */ /* Not using template specialization because some internal functions are impossible to explicitly instantiate */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class Color3: public Math::Vector3 { +template class BasicColor3: public Math::Vector3 { public: /** @brief Corresponding floating-point type for HSV computation */ typedef typename Math::TypeTraits::FloatingPointType FloatingPointType; @@ -172,11 +167,11 @@ class Color3: public Math::Vector3 { * * Hue can overflow the range @f$ [0.0, 360.0] @f$. */ - constexpr static Color3 fromHSV(HSV hsv) { + constexpr static BasicColor3 fromHSV(HSV hsv) { return Implementation::fromHSV(hsv); } /** @overload */ - constexpr static Color3 fromHSV(Math::Deg hue, FloatingPointType saturation, FloatingPointType value) { + constexpr static BasicColor3 fromHSV(Math::Deg hue, FloatingPointType saturation, FloatingPointType value) { return fromHSV(std::make_tuple(hue, saturation, value)); } @@ -185,13 +180,13 @@ class Color3: public Math::Vector3 { * * All components are set to zero. */ - constexpr /*implicit*/ Color3() {} + constexpr /*implicit*/ BasicColor3() {} /** * @brief Gray constructor * @param rgb RGB value */ - constexpr explicit Color3(T rgb): Math::Vector3(rgb) {} + constexpr explicit BasicColor3(T rgb): Math::Vector3(rgb) {} /** * @brief Constructor @@ -199,13 +194,13 @@ class Color3: public Math::Vector3 { * @param g G value * @param b B value */ - constexpr /*implicit*/ Color3(T r, T g, T b): Math::Vector3(r, g, b) {} + constexpr /*implicit*/ BasicColor3(T r, T g, T b): Math::Vector3(r, g, b) {} /** @copydoc Math::Vector::Vector(const Vector&) */ - template constexpr explicit Color3(const Math::Vector<3, U>& other): Math::Vector3(other) {} + template constexpr explicit BasicColor3(const Math::Vector<3, U>& other): Math::Vector3(other) {} /** @brief Copy constructor */ - constexpr Color3(const Math::Vector<3, T>& other): Math::Vector3(other) {} + constexpr BasicColor3(const Math::Vector<3, T>& other): Math::Vector3(other) {} T& r() { return Math::Vector3::x(); } /**< @brief R component */ constexpr T r() const { return Math::Vector3::x(); } /**< @overload */ @@ -259,15 +254,19 @@ class Color3: public Math::Vector3 { return Implementation::value(*this); } - MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Color3, 3) + MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(BasicColor3, 3) }; -MAGNUM_VECTOR_SUBCLASS_OPERATOR_IMPLEMENTATION(Color3, 3) +/** @brief Three-component (RGB) float color */ +typedef BasicColor3 Color3; + +MAGNUM_VECTOR_SUBCLASS_OPERATOR_IMPLEMENTATION(BasicColor3, 3) /** @brief Four-component (RGBA) color -See Color3 for more information. +See @ref BasicColor3 for more information. +@see @ref Color4 */ /* Not using template specialization because some internal functions are impossible to explicitly instantiate */ @@ -276,24 +275,24 @@ template #else template #endif -class Color4: public Math::Vector4 { +class BasicColor4: public Math::Vector4 { public: - /** @copydoc Color3::FloatingPointType */ - typedef typename Color3::FloatingPointType FloatingPointType; + /** @copydoc BasicColor3::FloatingPointType */ + typedef typename BasicColor3::FloatingPointType FloatingPointType; - /** @copydoc Color3::HSV */ - typedef typename Color3::HSV HSV; + /** @copydoc BasicColor3::HSV */ + typedef typename BasicColor3::HSV HSV; /** - * @copydoc Color3::fromHSV() + * @copydoc BasicColor3::fromHSV() * @param a Alpha value, defaults to 1.0 for floating-point types * and maximum positive value for integral types. */ - constexpr static Color4 fromHSV(HSV hsv, T a = Implementation::defaultAlpha()) { - return Color4(Implementation::fromHSV(hsv), a); + constexpr static BasicColor4 fromHSV(HSV hsv, T a = Implementation::defaultAlpha()) { + return BasicColor4(Implementation::fromHSV(hsv), a); } /** @overload */ - constexpr static Color4 fromHSV(Math::Deg hue, FloatingPointType saturation, FloatingPointType value, T alpha) { + constexpr static BasicColor4 fromHSV(Math::Deg hue, FloatingPointType saturation, FloatingPointType value, T alpha) { return fromHSV(std::make_tuple(hue, saturation, value), alpha); } @@ -303,14 +302,14 @@ class Color4: public Math::Vector4 { * RGB components are set to zero, A component is set to 1.0 for * floating-point types and maximum positive value for integral types. */ - constexpr /*implicit*/ Color4(): Math::Vector4(T(0), T(0), T(0), Implementation::defaultAlpha()) {} + constexpr /*implicit*/ BasicColor4(): Math::Vector4(T(0), T(0), T(0), Implementation::defaultAlpha()) {} /** - * @copydoc Color3::Color3(T) + * @copydoc BasicColor3::BasicColor3(T) * @param alpha Alpha value, defaults to 1.0 for floating-point types * and maximum positive value for integral types. */ - constexpr explicit Color4(T rgb, T alpha = Implementation::defaultAlpha()): Math::Vector4(rgb, rgb, rgb, alpha) {} + constexpr explicit BasicColor4(T rgb, T alpha = Implementation::defaultAlpha()): Math::Vector4(rgb, rgb, rgb, alpha) {} /** * @brief Constructor @@ -320,22 +319,22 @@ class Color4: public Math::Vector4 { * @param a A value, defaults to 1.0 for floating-point types and * maximum positive value for integral types. */ - constexpr /*implicit*/ Color4(T r, T g, T b, T a = Implementation::defaultAlpha()): Math::Vector4(r, g, b, a) {} + constexpr /*implicit*/ BasicColor4(T r, T g, T b, T a = Implementation::defaultAlpha()): Math::Vector4(r, g, b, a) {} /** * @brief Constructor * @param rgb Three-component color * @param a A value */ - /* Not marked as explicit, because conversion from Color3 to Color4 + /* Not marked as explicit, because conversion from BasicColor3 to BasicColor4 is fairly common, nearly always with A set to 1 */ - constexpr /*implicit*/ Color4(const Math::Vector3& rgb, T a = Implementation::defaultAlpha()): Math::Vector4(rgb[0], rgb[1], rgb[2], a) {} + constexpr /*implicit*/ BasicColor4(const Math::Vector3& rgb, T a = Implementation::defaultAlpha()): Math::Vector4(rgb[0], rgb[1], rgb[2], a) {} /** @copydoc Math::Vector::Vector(const Vector&) */ - template constexpr explicit Color4(const Math::Vector<4, U>& other): Math::Vector4(other) {} + template constexpr explicit BasicColor4(const Math::Vector<4, U>& other): Math::Vector4(other) {} /** @brief Copy constructor */ - constexpr Color4(const Math::Vector<4, T>& other): Math::Vector4(other) {} + constexpr BasicColor4(const Math::Vector<4, T>& other): Math::Vector4(other) {} T& r() { return Math::Vector4::x(); } /**< @brief R component */ constexpr T r() const { return Math::Vector4::x(); } /**< @overload */ @@ -352,52 +351,55 @@ class Color4: public Math::Vector4 { * * @see swizzle() */ - Color3& rgb() { return Color3::from(Math::Vector4::data()); } - constexpr Color3 rgb() const { return Color3::from(Math::Vector4::data()); } /**< @overload */ + BasicColor3& rgb() { return BasicColor3::from(Math::Vector4::data()); } + constexpr BasicColor3 rgb() const { return BasicColor3::from(Math::Vector4::data()); } /**< @overload */ - /** @copydoc Color3::toHSV() */ + /** @copydoc BasicColor3::toHSV() */ constexpr HSV toHSV() const { return Implementation::toHSV(rgb()); } - /** @copydoc Color3::hue() */ + /** @copydoc BasicColor3::hue() */ constexpr Math::Deg hue() const { return Implementation::hue(rgb()); } - /** @copydoc Color3::saturation() */ + /** @copydoc BasicColor3::saturation() */ constexpr FloatingPointType saturation() const { return Implementation::saturation(rgb()); } - /** @copydoc Color3::value() */ + /** @copydoc BasicColor3::value() */ constexpr FloatingPointType value() const { return Implementation::value(rgb()); } - MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Color4, 4) + MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(BasicColor4, 4) }; -MAGNUM_VECTOR_SUBCLASS_OPERATOR_IMPLEMENTATION(Color4, 4) +/** @brief Four-component (RGBA) float color */ +typedef BasicColor4 Color4; + +MAGNUM_VECTOR_SUBCLASS_OPERATOR_IMPLEMENTATION(BasicColor4, 4) -/** @debugoperator{Magnum::Color3} */ -template inline Debug operator<<(Debug debug, const Color3& value) { +/** @debugoperator{Magnum::BasicColor3} */ +template inline Debug operator<<(Debug debug, const BasicColor3& value) { return debug << static_cast&>(value); } -/** @debugoperator{Magnum::Color4} */ -template inline Debug operator<<(Debug debug, const Color4& value) { +/** @debugoperator{Magnum::BasicColor4} */ +template inline Debug operator<<(Debug debug, const BasicColor4& value) { return debug << static_cast&>(value); } } namespace Corrade { namespace Utility { - /** @configurationvalue{Magnum::Color3} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; + /** @configurationvalue{Magnum::BasicColor3} */ + template struct ConfigurationValue>: public ConfigurationValue> {}; - /** @configurationvalue{Magnum::Color4} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; + /** @configurationvalue{Magnum::BasicColor4} */ + template struct ConfigurationValue>: public ConfigurationValue> {}; }} #endif diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index 2308568f2..7d93fbb4a 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -233,7 +233,7 @@ class CubeMapTexture: public AbstractTexture { return this; } #ifndef MAGNUM_TARGET_GLES3 - CubeMapTexture* setBorderColor(const Color4<>& color) { + CubeMapTexture* setBorderColor(const Color4& color) { AbstractTexture::setBorderColor(color); return this; } diff --git a/src/CubeMapTextureArray.h b/src/CubeMapTextureArray.h index 7219706c8..617e3066d 100644 --- a/src/CubeMapTextureArray.h +++ b/src/CubeMapTextureArray.h @@ -243,7 +243,7 @@ class CubeMapTextureArray: public AbstractTexture { return this; } #ifndef MAGNUM_TARGET_GLES3 - CubeMapTextureArray* setBorderColor(const Color4<>& color) { + CubeMapTextureArray* setBorderColor(const Color4& color) { AbstractTexture::setBorderColor(color); return this; } diff --git a/src/DebugTools/ForceRenderer.cpp b/src/DebugTools/ForceRenderer.cpp index e0998962c..800b0747b 100644 --- a/src/DebugTools/ForceRenderer.cpp +++ b/src/DebugTools/ForceRenderer.cpp @@ -64,7 +64,7 @@ const std::array indices{{ } -template ForceRenderer::ForceRenderer(SceneGraph::AbstractObject* object, const typename DimensionTraits::VectorType& forcePosition, const typename DimensionTraits::VectorType* force, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(object, drawables), forcePosition(forcePosition), force(force), options(ResourceManager::instance()->get(options)) { +template ForceRenderer::ForceRenderer(SceneGraph::AbstractBasicObject* object, const typename DimensionTraits::VectorType& forcePosition, const typename DimensionTraits::VectorType* force, ResourceKey options, SceneGraph::BasicDrawableGroup* drawables): SceneGraph::BasicDrawable(object, drawables), forcePosition(forcePosition), force(force), options(ResourceManager::instance()->get(options)) { /* Shader */ shader = ResourceManager::instance()->get>(shaderKey()); if(!shader) ResourceManager::instance()->set(shader.key(), new Shaders::Flat); @@ -94,7 +94,7 @@ template ForceRenderer::ForceRenderer(SceneG ResourceManager::instance()->set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); } -template void ForceRenderer::draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) { +template void ForceRenderer::draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) { shader->setTransformationProjectionMatrix(camera->projectionMatrix()*Implementation::forceRendererTransformation(transformationMatrix.transformPoint(forcePosition), *force)*DimensionTraits::MatrixType::scaling(typename DimensionTraits::VectorType(options->scale()))) ->setColor(options->color()) ->use(); diff --git a/src/DebugTools/ForceRenderer.h b/src/DebugTools/ForceRenderer.h index f0af13d9b..3a40ec092 100644 --- a/src/DebugTools/ForceRenderer.h +++ b/src/DebugTools/ForceRenderer.h @@ -47,7 +47,7 @@ class ForceRendererOptions { constexpr ForceRendererOptions(): _color(1.0f), _size(1.0f) {} /** @brief Color of rendered arrow */ - constexpr Color4<> color() const { return _color; } + constexpr Color4 color() const { return _color; } /** * @brief Set color of rendered arrow @@ -55,7 +55,7 @@ class ForceRendererOptions { * * Default is 100% opaque white. */ - ForceRendererOptions* setColor(const Color4<>& color) { + ForceRendererOptions* setColor(const Color4& color) { _color = color; return this; } @@ -75,7 +75,7 @@ class ForceRendererOptions { } private: - Color4<> _color; + Color4 _color; Float _size; }; @@ -91,7 +91,7 @@ Example code: @code // Create some options DebugTools::ResourceManager::instance()->set("my", (new DebugTools::ForceRendererOptions) - ->setScale(5.0f)->setColor(Color3<>::fromHSV(120.0_degf, 1.0f, 0.7f))); + ->setScale(5.0f)->setColor(Color3::fromHSV(120.0_degf, 1.0f, 0.7f))); // Create debug renderer for given object, use "my" options for it Object3D* object; @@ -101,7 +101,7 @@ new DebugTools::ForceRenderer2D(object, {0.3f, 1.5f, -0.7f}, &force, "my", debug @see ForceRenderer2D, ForceRenderer3D */ -template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: public SceneGraph::Drawable { +template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: public SceneGraph::BasicDrawable { public: /** * @brief Constructor @@ -117,11 +117,10 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: p * saved as reference to original vector and thus it must be available * for the whole lifetime of the renderer. */ - explicit ForceRenderer(SceneGraph::AbstractObject* object, const typename DimensionTraits::VectorType& forcePosition, const typename DimensionTraits::VectorType* force, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); + explicit ForceRenderer(SceneGraph::AbstractBasicObject* object, const typename DimensionTraits::VectorType& forcePosition, const typename DimensionTraits::VectorType* force, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup* drawables = nullptr); protected: - /** @todoc Remove Float when Doxygen properly treats this as override */ - void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) override; + void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) override; private: const typename DimensionTraits::VectorType forcePosition; diff --git a/src/DebugTools/ObjectRenderer.cpp b/src/DebugTools/ObjectRenderer.cpp index ed5cc13ab..96461e6a9 100644 --- a/src/DebugTools/ObjectRenderer.cpp +++ b/src/DebugTools/ObjectRenderer.cpp @@ -43,7 +43,7 @@ template<> struct Renderer<2> { static ResourceKey mesh() { return {"object2d"}; } static const std::array positions; - static const std::array, 8> colors; + static const std::array colors; static const std::array indices; }; @@ -59,7 +59,7 @@ const std::array Renderer<2>::positions{{ {-0.1f, 0.9f} }}; -const std::array, 8> Renderer<2>::colors{{ +const std::array Renderer<2>::colors{{ {1.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, /* X axis */ {1.0f, 0.0f, 0.0f}, @@ -88,7 +88,7 @@ template<> struct Renderer<3> { static ResourceKey mesh() { return {"object3d"}; } static const std::array positions; - static const std::array, 12> colors; + static const std::array colors; static const std::array indices; }; @@ -109,7 +109,7 @@ const std::array Renderer<3>::positions{{ {-0.1f, 0.0f, 0.9f} }}; -const std::array, 12> Renderer<3>::colors{{ +const std::array Renderer<3>::colors{{ {1.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f}, /* X axis */ {1.0f, 0.0f, 0.0f}, @@ -142,7 +142,7 @@ const std::array Renderer<3>::indices{{ } -template ObjectRenderer::ObjectRenderer(SceneGraph::AbstractObject* object, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(object, drawables), options(ResourceManager::instance()->get(options)) { +template ObjectRenderer::ObjectRenderer(SceneGraph::AbstractBasicObject* object, ResourceKey options, SceneGraph::BasicDrawableGroup* drawables): SceneGraph::BasicDrawable(object, drawables), options(ResourceManager::instance()->get(options)) { /* Shader */ shader = ResourceManager::instance()->get>(Renderer::shader()); if(!shader) ResourceManager::instance()->set(shader.key(), new Shaders::VertexColor); @@ -173,7 +173,7 @@ template ObjectRenderer::ObjectRenderer(Scen ResourceManager::instance()->set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); } -template void ObjectRenderer::draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) { +template void ObjectRenderer::draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) { shader->setTransformationProjectionMatrix(camera->projectionMatrix()*transformationMatrix*DimensionTraits::MatrixType::scaling(typename DimensionTraits::VectorType(options->size()))) ->use(); diff --git a/src/DebugTools/ObjectRenderer.h b/src/DebugTools/ObjectRenderer.h index 1c3c77f26..7f86de227 100644 --- a/src/DebugTools/ObjectRenderer.h +++ b/src/DebugTools/ObjectRenderer.h @@ -84,7 +84,7 @@ new DebugTools::ObjectRenderer2D(object, "my", debugDrawables); @see ObjectRenderer2D, ObjectRenderer3D */ -template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: public SceneGraph::Drawable { +template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: public SceneGraph::BasicDrawable { public: /** * @brief Constructor @@ -96,11 +96,10 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: * * The renderer is automatically added to object's features. */ - explicit ObjectRenderer(SceneGraph::AbstractObject* object, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); + explicit ObjectRenderer(SceneGraph::AbstractBasicObject* object, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup* drawables = nullptr); protected: - /** @todoc Remove Float when Doxygen properly treats this as override */ - void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) override; + void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) override; private: Resource options; diff --git a/src/DebugTools/ShapeRenderer.cpp b/src/DebugTools/ShapeRenderer.cpp index 459b25724..58e43fedc 100644 --- a/src/DebugTools/ShapeRenderer.cpp +++ b/src/DebugTools/ShapeRenderer.cpp @@ -94,7 +94,7 @@ template<> void createDebugMesh(ShapeRenderer<3>* renderer, const Shapes::Implem } -template ShapeRenderer::ShapeRenderer(Shapes::AbstractShape* shape, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(shape->object(), drawables), options(ResourceManager::instance()->get(options)) { +template ShapeRenderer::ShapeRenderer(Shapes::AbstractShape* shape, ResourceKey options, SceneGraph::BasicDrawableGroup* drawables): SceneGraph::BasicDrawable(shape->object(), drawables), options(ResourceManager::instance()->get(options)) { Implementation::createDebugMesh(this, Shapes::Implementation::getAbstractShape(shape)); } @@ -103,7 +103,7 @@ template ShapeRenderer::~ShapeRenderer() { delete *it; } -template void ShapeRenderer::draw(const typename DimensionTraits::MatrixType&, SceneGraph::AbstractCamera* camera) { +template void ShapeRenderer::draw(const typename DimensionTraits::MatrixType&, SceneGraph::AbstractBasicCamera* camera) { typename DimensionTraits::MatrixType projectionMatrix = camera->projectionMatrix()*camera->cameraMatrix(); for(auto it = renderers.begin(); it != renderers.end(); ++it) (*it)->draw(options, projectionMatrix); diff --git a/src/DebugTools/ShapeRenderer.h b/src/DebugTools/ShapeRenderer.h index a237cab71..9c8e0eaf1 100644 --- a/src/DebugTools/ShapeRenderer.h +++ b/src/DebugTools/ShapeRenderer.h @@ -83,7 +83,7 @@ class ShapeRendererOptions { } /** @brief Color of rendered shape */ - constexpr Color4<> color() const { return _color; } + constexpr Color4 color() const { return _color; } /** * @brief Set color of rendered shape @@ -91,7 +91,7 @@ class ShapeRendererOptions { * * Default is 100% opaque white. */ - ShapeRendererOptions* setColor(const Color4<>& color) { + ShapeRendererOptions* setColor(const Color4& color) { _color = color; return this; } @@ -112,7 +112,7 @@ class ShapeRendererOptions { } private: - Color4<> _color; + Color4 _color; Float _pointSize; RenderMode _renderMode; }; @@ -138,7 +138,7 @@ new DebugTools::ShapeRenderer2D(shape, "red", debugDrawables); @see ShapeRenderer2D, ShapeRenderer3D */ -template class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::Drawable { +template class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::BasicDrawable { friend void Implementation::createDebugMesh<>(ShapeRenderer*, const Shapes::Implementation::AbstractShape*); public: @@ -154,13 +154,13 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: p * @p shape must be available for the whole lifetime of the renderer * and if it is group, it must not change its internal structure. */ - explicit ShapeRenderer(Shapes::AbstractShape* shape, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); + explicit ShapeRenderer(Shapes::AbstractShape* shape, ResourceKey options = ResourceKey(), SceneGraph::BasicDrawableGroup* drawables = nullptr); ~ShapeRenderer(); protected: /** @todoc Remove Float when Doxygen properly treats this as override */ - void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractCamera* camera) override; + void draw(const typename DimensionTraits::MatrixType& transformationMatrix, SceneGraph::AbstractBasicCamera* camera) override; private: Resource options; diff --git a/src/Magnum.h b/src/Magnum.h index 84a79ee44..1e4614315 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -354,8 +354,10 @@ enum class BufferTextureFormat: GLenum; #endif #endif -template class Color3; -template class Color4; +template class BasicColor3; +template class BasicColor4; +typedef BasicColor3 Color3; +typedef BasicColor4 Color4; #ifndef CORRADE_GCC45_COMPATIBILITY enum class Version: Int; diff --git a/src/Mesh.h b/src/Mesh.h index 2db8523d9..a68d8bbe7 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -173,7 +173,7 @@ mesh->setPrimitive(plane.primitive()) class MyShader: public AbstractShaderProgram { public: typedef Attribute<0, Vector3> Position; - typedef Attribute<1, Color4<>> Color; + typedef Attribute<1, Color4> Color; // ... }; diff --git a/src/MeshTools/Interleave.h b/src/MeshTools/Interleave.h index 8745a5da3..e95ec8ebd 100644 --- a/src/MeshTools/Interleave.h +++ b/src/MeshTools/Interleave.h @@ -160,7 +160,7 @@ achieve that, you can specify gaps between the attributes: @code std::vector positions; std::vector weights; -std::vector> vertexColors; +std::vector> vertexColors; std::size_t attributeCount; std::size_t stride; char* data; diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 7fb8ed7a5..d823af8d8 100644 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -50,7 +50,7 @@ void Renderer::setHint(const Hint target, const HintMode mode) { glHint(GLenum(target), GLenum(mode)); } -void Renderer::setClearColor(const Color4<>& color) { +void Renderer::setClearColor(const Color4& color) { glClearColor(color.r(), color.g(), color.b(), color.a()); } @@ -152,7 +152,7 @@ void Renderer::setBlendFunction(const BlendFunction sourceRgb, const BlendFuncti glBlendFuncSeparate(GLenum(sourceRgb), GLenum(destinationRgb), GLenum(sourceAlpha), GLenum(destinationAlpha)); } -void Renderer::setBlendColor(const Color4<>& color) { +void Renderer::setBlendColor(const Color4& color) { glBlendColor(color.r(), color.g(), color.b(), color.a()); } diff --git a/src/Renderer.h b/src/Renderer.h index e66e8311b..e6cbc7609 100644 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -238,7 +238,7 @@ class MAGNUM_EXPORT Renderer { * Initial value is fully opaque black. * @see @fn_gl{ClearColor} */ - static void setClearColor(const Color4<>& color); + static void setClearColor(const Color4& color); #ifndef MAGNUM_TARGET_GLES /** @@ -809,7 +809,7 @@ class MAGNUM_EXPORT Renderer { * @see @ref Feature "Feature::Blending", setBlendEquation(), * setBlendFunction(), @fn_gl{BlendColor} */ - static void setBlendColor(const Color4<>& color); + static void setBlendColor(const Color4& color); /*@}*/ diff --git a/src/SceneGraph/AbstractCamera.h b/src/SceneGraph/AbstractCamera.h index 43287ba10..e07f90bb2 100644 --- a/src/SceneGraph/AbstractCamera.h +++ b/src/SceneGraph/AbstractCamera.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractCamera, enum Magnum::SceneGraph::AspectRatioPolicy, alias Magnum::SceneGraph::AbstractCamera2D, Magnum::SceneGraph::AbstractCamera3D + * @brief Class Magnum::SceneGraph::AbstractBasicCamera, enum Magnum::SceneGraph::AspectRatioPolicy, typedef Magnum::SceneGraph::AbstractCamera2D, Magnum::SceneGraph::AbstractCamera3D */ #include "Math/Matrix3.h" @@ -39,7 +39,7 @@ namespace Magnum { namespace SceneGraph { /** @brief Camera aspect ratio policy -@see AbstractCamera::setAspectRatioPolicy() +@see AbstractBasicCamera::setAspectRatioPolicy() */ enum class AspectRatioPolicy: UnsignedByte { NotPreserved, /**< Don't preserve aspect ratio (default) */ @@ -67,25 +67,20 @@ relevant sections in @ref Camera3D-explicit-specializations "Camera3D" class documentation or @ref compilation-speedup-hpp for more information. - - @ref AbstractCamera "AbstractCamera<2, Float>" - - @ref AbstractCamera "AbstractCamera<3, Float>" + - @ref AbstractBasicCamera "AbstractBasicCamera<2, Float>" + - @ref AbstractBasicCamera "AbstractBasicCamera<3, Float>" -@see @ref scenegraph, Drawable, DrawableGroup, AbstractCamera2D, AbstractCamera3D +@see AbstractCamera2D, AbstractCamera3D, @ref scenegraph, Drawable, DrawableGroup */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature { +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicCamera: public AbstractBasicFeature { public: /** * @brief Constructor * @param object Object holding the camera */ - explicit AbstractCamera(AbstractObject* object); + explicit AbstractBasicCamera(AbstractBasicObject* object); - virtual ~AbstractCamera() = 0; + virtual ~AbstractBasicCamera() = 0; /** @brief Aspect ratio policy */ AspectRatioPolicy aspectRatioPolicy() const { return _aspectRatioPolicy; } @@ -94,7 +89,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature* setAspectRatioPolicy(AspectRatioPolicy policy); + AbstractBasicCamera* setAspectRatioPolicy(AspectRatioPolicy policy); /** * @brief Camera matrix @@ -103,7 +98,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature::MatrixType cameraMatrix() { - AbstractFeature::object()->setClean(); + AbstractBasicFeature::object()->setClean(); return _cameraMatrix; } @@ -143,7 +138,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature& group); + virtual void draw(BasicDrawableGroup& group); protected: /** Recalculates camera matrix */ @@ -167,37 +162,19 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractCamera: public AbstractFeature%AbstractCamera<2, T>. See AbstractCamera -for more information. -@note Not available on GCC < 4.7. Use %AbstractCamera<2, T> instead. @see AbstractCamera3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractCamera2D = AbstractCamera<2, T>; +typedef AbstractBasicCamera<2, Float> AbstractCamera2D; /** -@brief Base for three-dimensional cameras +@brief Base camera for three-dimensional float scenes -Convenience alternative to %AbstractCamera<3, T>. See AbstractCamera -for more information. -@note Not available on GCC < 4.7. Use %AbstractCamera<3, T> instead. -@see AbstractCamera2D +@see AbstractBasicCamera2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractCamera3D = AbstractCamera<3, T>; -#endif +typedef AbstractBasicCamera<3, Float> AbstractCamera3D; }} diff --git a/src/SceneGraph/AbstractCamera.hpp b/src/SceneGraph/AbstractCamera.hpp index 413cc4b86..dbd368ba9 100644 --- a/src/SceneGraph/AbstractCamera.hpp +++ b/src/SceneGraph/AbstractCamera.hpp @@ -70,32 +70,32 @@ template typename DimensionTraits AbstractCamera::AbstractCamera(AbstractObject* object): AbstractFeature(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) { - AbstractFeature::setCachedTransformations(CachedTransformation::InvertedAbsolute); +template AbstractBasicCamera::AbstractBasicCamera(AbstractBasicObject* object): AbstractBasicFeature(object), _aspectRatioPolicy(AspectRatioPolicy::NotPreserved) { + AbstractBasicFeature::setCachedTransformations(CachedTransformation::InvertedAbsolute); } -template AbstractCamera::~AbstractCamera() {} +template AbstractBasicCamera::~AbstractBasicCamera() {} -template AbstractCamera* AbstractCamera::setAspectRatioPolicy(AspectRatioPolicy policy) { +template AbstractBasicCamera* AbstractBasicCamera::setAspectRatioPolicy(AspectRatioPolicy policy) { _aspectRatioPolicy = policy; fixAspectRatio(); return this; } -template void AbstractCamera::setViewport(const Vector2i& size) { +template void AbstractBasicCamera::setViewport(const Vector2i& size) { _viewport = size; fixAspectRatio(); } -template void AbstractCamera::draw(DrawableGroup& group) { - AbstractObject* scene = AbstractFeature::object()->scene(); +template void AbstractBasicCamera::draw(BasicDrawableGroup& group) { + AbstractBasicObject* scene = AbstractBasicFeature::object()->scene(); CORRADE_ASSERT(scene, "Camera::draw(): cannot draw when camera is not part of any scene", ); /* Compute camera matrix */ - AbstractFeature::object()->setClean(); + AbstractBasicFeature::object()->setClean(); /* Compute transformations of all objects in the group relative to the camera */ - std::vector*> objects(group.size()); + std::vector*> objects(group.size()); for(std::size_t i = 0; i != group.size(); ++i) objects[i] = group[i]->object(); std::vector::MatrixType> transformations = diff --git a/src/SceneGraph/AbstractFeature.h b/src/SceneGraph/AbstractFeature.h index ea421e132..3cd00f42b 100644 --- a/src/SceneGraph/AbstractFeature.h +++ b/src/SceneGraph/AbstractFeature.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractFeature, alias Magnum::SceneGraph::AbstractFeature2D, Magnum::SceneGraph::AbstractFeature3D, enum Magnum::SceneGraph::CachedTransformation, enum set Magnum::SceneGraph::CachedTransformations + * @brief Class Magnum::SceneGraph::AbstractBasicFeature, typedef Magnum::SceneGraph::AbstractFeature2D, Magnum::SceneGraph::AbstractFeature3D, enum Magnum::SceneGraph::CachedTransformation, enum set Magnum::SceneGraph::CachedTransformations */ #include @@ -40,8 +40,8 @@ namespace Magnum { namespace SceneGraph { @brief Which transformation to cache in given feature @see @ref scenegraph-caching, CachedTransformations, - AbstractFeature::setCachedTransformations(), AbstractFeature::clean(), - AbstractFeature::cleanInverted() + AbstractBasicFeature::setCachedTransformations(), AbstractBasicFeature::clean(), + AbstractBasicFeature::cleanInverted() @todo Provide also simpler representations from which could benefit other transformation implementations, as they won't need to e.g. create transformation matrix from quaternion? @@ -65,8 +65,8 @@ enum class CachedTransformation: UnsignedByte { /** @brief Which transformations to cache in this feature -@see @ref scenegraph-caching, AbstractFeature::setCachedTransformations(), - AbstractFeature::clean(), AbstractFeature::cleanInverted() +@see @ref scenegraph-caching, AbstractBasicFeature::setCachedTransformations(), + AbstractBasicFeature::clean(), AbstractBasicFeature::cleanInverted() */ typedef Containers::EnumSet CachedTransformations; @@ -98,9 +98,9 @@ caching is disabled. You can enable it using setCachedTransformations() and then implement corresponding cleaning function(s) -- either clean(), cleanInverted() or both. Example: @code -class CachingFeature: public SceneGraph::AbstractFeature3D<> { +class CachingFeature: public SceneGraph::AbstractFeature3D { public: - CachingFeature(SceneGraph::AbstractObject3D<>* object): SceneGraph::AbstractFeature3D<>(object) { + CachingFeature(SceneGraph::AbstractObject3D* object): SceneGraph::AbstractFeature3D(object) { setCachedTransformations(CachedTransformation::Absolute); } @@ -131,21 +131,20 @@ transformation implementations. Using small trick we are able to get pointer to both AbstractObject and needed transformation from one constructor parameter: @code -class TransformingFeature: public SceneGraph::AbstractFeature3D<> { +class TransformingFeature: public SceneGraph::AbstractFeature3D { public: template TransformingFeature(SceneGraph::Object* object): - SceneGraph::AbstractFeature3D<>(object), transformation(object) {} + SceneGraph::AbstractFeature3D(object), transformation(object) {} private: - SceneGraph::AbstractTranslationRotation3D<>* transformation; + SceneGraph::AbstractTranslationRotation3D* transformation; }; @endcode -If we take for example @ref Object "Object>", it is -derived from @ref AbstractObject "AbstractObject3D<>" and -@ref MatrixTransformation3D "MatrixTransformation3D<>", which is derived from -@ref AbstractTranslationRotationScaling3D "AbstractTranslationRotationScaling3D<>", -which is derived from -@ref AbstractTranslationRotation3D "AbstractTranslationRotation3D<>", +If we take for example @ref Object "Object", it is +derived from @ref AbstractBasicObject "AbstractObject3D" and +@ref BasicMatrixTransformation3D "MatrixTransformation3D", which is derived +from @ref BasicAbstractTranslationRotationScaling3D "AbstractTranslationRotationScaling3D", +which is derived from @ref BasicAbstractTranslationRotation3D "AbstractTranslationRotation3D", which is automatically extracted from the pointer in our constructor. @section AbstractFeature-explicit-specializations Explicit template specializations @@ -155,19 +154,18 @@ For other specializations (e.g. using Double type) you have to use AbstractFeature.hpp implementation file to avoid linker errors. See also @ref compilation-speedup-hpp for more information. - - @ref AbstractFeature "AbstractFeature<2, Float>" - - @ref AbstractFeature "AbstractFeature<3, Float>" + - @ref AbstractBasicFeature "AbstractBasicFeature<2, Float>" + - @ref AbstractBasicFeature "AbstractBasicFeature<3, Float>" -@see AbstractFeature2D, AbstractFeature3D +@see @ref AbstractFeature2D, @ref AbstractFeature3D */ +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature #ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeature: private Containers::LinkedListItem, AbstractObject> -#else -template class AbstractFeature +: private Containers::LinkedListItem, AbstractBasicObject> #endif { - friend class Containers::LinkedList>; - friend class Containers::LinkedListItem, AbstractObject>; + friend class Containers::LinkedList>; + friend class Containers::LinkedListItem, AbstractBasicObject>; template friend class Object; public: @@ -175,38 +173,38 @@ template class AbstractFeature * @brief Constructor * @param object %Object holding this feature */ - explicit AbstractFeature(AbstractObject* object); + explicit AbstractBasicFeature(AbstractBasicObject* object); - virtual ~AbstractFeature() = 0; + virtual ~AbstractBasicFeature() = 0; /** @brief %Object holding this feature */ - AbstractObject* object() { - return Containers::LinkedListItem, AbstractObject>::list(); + AbstractBasicObject* object() { + return Containers::LinkedListItem, AbstractBasicObject>::list(); } /** @overload */ - const AbstractObject* object() const { - return Containers::LinkedListItem, AbstractObject>::list(); + const AbstractBasicObject* object() const { + return Containers::LinkedListItem, AbstractBasicObject>::list(); } /** @brief Previous feature or `nullptr`, if this is first feature */ - AbstractFeature* previousFeature() { - return Containers::LinkedListItem, AbstractObject>::previous(); + AbstractBasicFeature* previousFeature() { + return Containers::LinkedListItem, AbstractBasicObject>::previous(); } /** @overload */ - const AbstractFeature* previousFeature() const { - return Containers::LinkedListItem, AbstractObject>::previous(); + const AbstractBasicFeature* previousFeature() const { + return Containers::LinkedListItem, AbstractBasicObject>::previous(); } /** @brief Next feature or `nullptr`, if this is last feature */ - AbstractFeature* nextFeature() { - return Containers::LinkedListItem, AbstractObject>::next(); + AbstractBasicFeature* nextFeature() { + return Containers::LinkedListItem, AbstractBasicObject>::next(); } /** @overload */ - const AbstractFeature* nextFeature() const { - return Containers::LinkedListItem, AbstractObject>::next(); + const AbstractBasicFeature* nextFeature() const { + return Containers::LinkedListItem, AbstractBasicObject>::next(); } /** @@ -284,37 +282,19 @@ template class AbstractFeature CachedTransformations _cachedTransformations; }; -#ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Base for two-dimensional features +@brief Base feature for two-dimensional float scenes -Convenience alternative to %AbstractFeature<2, T>. See AbstractFeature -for more information. -@note Not available on GCC < 4.7. Use %AbstractFeature<2, T> instead. -@see AbstractFeature3D +@see @ref AbstractFeature3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractFeature2D = AbstractFeature<2, T>; +typedef AbstractBasicFeature<2, Float> AbstractFeature2D; /** -@brief Base for three-dimensional features +@brief Base feature for three-dimensional float scenes -Convenience alternative to %AbstractFeature<3, T>. See AbstractFeature -for more information. -@note Not available on GCC < 4.7. Use %AbstractFeature<3, T> instead. -@see AbstractFeature2D +@see @ref AbstractFeature2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractFeature3D = AbstractFeature<3, T>; -#endif +typedef AbstractBasicFeature<3, Float> AbstractFeature3D; }} diff --git a/src/SceneGraph/AbstractFeature.hpp b/src/SceneGraph/AbstractFeature.hpp index c824bc75d..ead61006b 100644 --- a/src/SceneGraph/AbstractFeature.hpp +++ b/src/SceneGraph/AbstractFeature.hpp @@ -32,18 +32,18 @@ namespace Magnum { namespace SceneGraph { -template AbstractFeature::AbstractFeature(AbstractObject* object) { - object->Containers::template LinkedList>::insert(this); +template AbstractBasicFeature::AbstractBasicFeature(AbstractBasicObject* object) { + object->Containers::template LinkedList>::insert(this); } /* `= default` causes linker errors in GCC 4.5 */ -template AbstractFeature::~AbstractFeature() {} +template AbstractBasicFeature::~AbstractBasicFeature() {} -template void AbstractFeature::markDirty() {} +template void AbstractBasicFeature::markDirty() {} -template void AbstractFeature::clean(const typename DimensionTraits::MatrixType&) {} +template void AbstractBasicFeature::clean(const typename DimensionTraits::MatrixType&) {} -template void AbstractFeature::cleanInverted(const typename DimensionTraits::MatrixType&) {} +template void AbstractBasicFeature::cleanInverted(const typename DimensionTraits::MatrixType&) {} }} diff --git a/src/SceneGraph/AbstractGroupedFeature.h b/src/SceneGraph/AbstractGroupedFeature.h index 8b636c885..2d5efe8c9 100644 --- a/src/SceneGraph/AbstractGroupedFeature.h +++ b/src/SceneGraph/AbstractGroupedFeature.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractGroupedFeature, alias Magnum::SceneGraph::AbstractGroupedFeature2D, Magnum::SceneGraph::AbstractGroupedFeature3D + * @brief Class Magnum::SceneGraph::AbstractBasicGroupedFeature, alias Magnum::SceneGraph::AbstractGroupedFeature2D, Magnum::SceneGraph::AbstractGroupedFeature3D */ #include @@ -38,12 +38,12 @@ namespace Magnum { namespace SceneGraph { /** @brief Base for grouped features -Used together with FeatureGroup. +Used together with BasicFeatureGroup. @section AbstractGroupedFeature-subclassing Subclassing Usage is via subclassing the feature using [CRTP](http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern) -and typedef'ing FeatureGroup to accept only given type, e.g.: +and typedef'ing BasicFeatureGroup to accept only given type, e.g.: @code class Drawable: public SceneGraph::AbstractGroupedFeature3D { // ... @@ -59,19 +59,15 @@ For other specializations (e.g. using Double type) you have to use AbstractGroupedFeature.hpp implementation file to avoid linker errors. See also @ref compilation-speedup-hpp for more information. - - @ref AbstractFeatureGroup "AbstractFeatureGroup<2, Float>" - - @ref AbstractFeatureGroup "AbstractFeatureGroup<3, Float>" + - @ref AbstractBasicFeatureGroup "AbstractBasicFeatureGroup<2, Float>" + - @ref AbstractBasicFeatureGroup "AbstractBasicFeatureGroup<3, Float>" -@see @ref scenegraph, AbstractGroupedFeature2D, AbstractGroupedFeature3D, - FeatureGroup, FeatureGroup2D, FeatureGroup3D +@see @ref AbstractGroupedFeature2D, @ref AbstractGroupedFeature3D, + @ref scenegraph, @ref BasicFeatureGroup, @ref FeatureGroup2D, + @ref FeatureGroup3D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class AbstractGroupedFeature: public AbstractFeature { - friend class FeatureGroup; +template class AbstractBasicGroupedFeature: public AbstractBasicFeature { + friend class BasicFeatureGroup; public: /** @@ -82,7 +78,7 @@ class AbstractGroupedFeature: public AbstractFeature { * Adds the feature to the object and to group, if specified. * @see FeatureGroup::add() */ - explicit AbstractGroupedFeature(AbstractObject* object, FeatureGroup* group = nullptr): AbstractFeature(object), _group(nullptr) { + explicit AbstractBasicGroupedFeature(AbstractBasicObject* object, BasicFeatureGroup* group = nullptr): AbstractBasicFeature(object), _group(nullptr) { if(group) group->add(static_cast(this)); } @@ -92,56 +88,44 @@ class AbstractGroupedFeature: public AbstractFeature { * Removes the feature from object and from group, if it belongs to * any. */ - ~AbstractGroupedFeature() { + ~AbstractBasicGroupedFeature() { if(_group) _group->remove(static_cast(this)); } /** @brief Group this feature belongs to */ - FeatureGroup* group() { + BasicFeatureGroup* group() { return _group; } /** @overload */ - const FeatureGroup* group() const { + const BasicFeatureGroup* group() const { return _group; } private: - FeatureGroup* _group; + BasicFeatureGroup* _group; }; #ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Base for two-dimensional grouped features +@brief Base grouped feature for two-dimensional float scenes -Convenience alternative to %AbstractGroupedFeature<2, Derived, T>. See -AbstractGroupedFeature for more information. -@note Not available on GCC < 4.7. Use %AbstractGroupedFeature<2, Derived, T> +Convenience alternative to %AbstractBasicGroupedFeature<2, Derived, Float>. +@note Not available on GCC < 4.7. Use %AbstractBasicGroupedFeature<2, Derived, Float> instead. -@see AbstractGroupedFeature3D +@see @ref AbstractGroupedFeature3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractGroupedFeature2D = AbstractGroupedFeature<2, Derived, T>; +template using AbstractGroupedFeature2D = AbstractBasicGroupedFeature<2, Derived, Float>; /** @brief Base for three-dimensional grouped features -Convenience alternative to %AbstractGroupedFeature<3, Derived, T>. See -AbstractGroupedFeature for more information. -@note Not available on GCC < 4.7. Use %AbstractGroupedFeature<3, Derived, T> +Convenience alternative to %AbstractBasicGroupedFeature<3, Derived, Float>. +@note Not available on GCC < 4.7. Use %AbstractBasicGroupedFeature<3, Derived, Float> instead. -@see AbstractGroupedFeature2D +@see @ref AbstractGroupedFeature2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractGroupedFeature3D = AbstractGroupedFeature<3, Derived, T>; +template using AbstractGroupedFeature3D = AbstractBasicGroupedFeature<3, Derived, Float>; #endif }} diff --git a/src/SceneGraph/AbstractObject.h b/src/SceneGraph/AbstractObject.h index d7e572cb3..ee1c5e9ab 100644 --- a/src/SceneGraph/AbstractObject.h +++ b/src/SceneGraph/AbstractObject.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractObject, alias Magnum::SceneGraph::AbstractObject2D, Magnum::SceneGraph::AbstractObject3D + * @brief Class Magnum::SceneGraph::AbstractBasicObject, alias Magnum::SceneGraph::AbstractObject2D, Magnum::SceneGraph::AbstractObject3D */ #include @@ -54,61 +54,60 @@ for(AbstractFeature* feature = o->firstFeature(); feature; feature = feature->ne } @endcode -@see AbstractObject2D, AbstractObject3D +@see @ref AbstractObject2D, @ref AbstractObject3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template class AbstractObject -#else -template class MAGNUM_SCENEGRAPH_EXPORT AbstractObject: private Containers::LinkedList> -#endif +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicObject + #ifndef DOXYGEN_GENERATING_OUTPUT + : private Containers::LinkedList> + #endif { - friend class Containers::LinkedList>; - friend class Containers::LinkedListItem, AbstractObject>; - friend class AbstractFeature; + friend class Containers::LinkedList>; + friend class Containers::LinkedListItem, AbstractBasicObject>; + friend class AbstractBasicFeature; public: /** @brief Matrix type */ typedef typename DimensionTraits::MatrixType MatrixType; /** @brief Feature object type */ - typedef AbstractFeature FeatureType; + typedef AbstractBasicFeature FeatureType; - explicit AbstractObject(); - virtual ~AbstractObject(); + explicit AbstractBasicObject(); + virtual ~AbstractBasicObject(); /** @brief Whether this object has features */ bool hasFeatures() const { - return !Containers::LinkedList>::isEmpty(); + return !Containers::LinkedList>::isEmpty(); } /** @brief First object feature or `nullptr`, if this object has no features */ FeatureType* firstFeature() { - return Containers::LinkedList>::first(); + return Containers::LinkedList>::first(); } /** @overload */ const FeatureType* firstFeature() const { - return Containers::LinkedList>::first(); + return Containers::LinkedList>::first(); } /** @brief Last object feature or `nullptr`, if this object has no features */ FeatureType* lastFeature() { - return Containers::LinkedList>::last(); + return Containers::LinkedList>::last(); } /** @overload */ const FeatureType* lastFeature() const { - return Containers::LinkedList>::last(); + return Containers::LinkedList>::last(); } /** * @brief %Scene * @return %Scene or `nullptr`, if the object is not part of any scene. */ - AbstractObject* scene() { return doScene(); } + AbstractBasicObject* scene() { return doScene(); } /** @overload */ - const AbstractObject* scene() const { return doScene(); } + const AbstractBasicObject* scene() const { return doScene(); } /** @{ @name Object transformation */ @@ -139,7 +138,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT Abstrac * Object type, use typesafe Object::transformationMatrices() when * possible. */ - std::vector transformationMatrices(const std::vector*>& objects, const MatrixType& initialTransformationMatrix = MatrixType()) const { + std::vector transformationMatrices(const std::vector*>& objects, const MatrixType& initialTransformationMatrix = MatrixType()) const { return doTransformationMatrices(objects, initialTransformationMatrix); } @@ -158,7 +157,7 @@ template class MAGNUM_SCENEGRAPH_EXPORT Abstrac * @warning This function cannot check if all objects are of the same * Object type, use typesafe Object::setClean() when possible. */ - static void setClean(const std::vector*>& objects) { + static void setClean(const std::vector*>& objects) { if(objects.empty()) return; objects.front()->doSetClean(objects); } @@ -204,50 +203,32 @@ template class MAGNUM_SCENEGRAPH_EXPORT Abstrac /*@}*/ private: - virtual AbstractObject* doScene() = 0; - virtual const AbstractObject* doScene() const = 0; + virtual AbstractBasicObject* doScene() = 0; + virtual const AbstractBasicObject* doScene() const = 0; virtual MatrixType doTransformationMatrix() const = 0; virtual MatrixType doAbsoluteTransformationMatrix() const = 0; - virtual std::vector doTransformationMatrices(const std::vector*>& objects, const MatrixType& initialTransformationMatrix) const = 0; + virtual std::vector doTransformationMatrices(const std::vector*>& objects, const MatrixType& initialTransformationMatrix) const = 0; virtual bool doIsDirty() const = 0; virtual void doSetDirty() = 0; virtual void doSetClean() = 0; - virtual void doSetClean(const std::vector*>& objects) = 0; + virtual void doSetClean(const std::vector*>& objects) = 0; }; -#ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Base for two-dimensional objects +@brief Base object for two-dimensional float scenes -Convenience alternative to %AbstractObject<2, T>. See AbstractObject -for more information. -@note Not available on GCC < 4.7. Use %AbstractObject<2, T> instead. -@see AbstractObject3D +@see @ref AbstractObject3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractObject2D = AbstractObject<2, T>; +typedef AbstractBasicObject<2, Float> AbstractObject2D; /** -@brief Base for three-dimensional objects +@brief Base object for three-dimensional float scenes -Convenience alternative to %AbstractObject<3, T>. See AbstractObject -for more information. -@note Not available on GCC < 4.7. Use %AbstractObject<3, T> instead. -@see AbstractObject2D +@see @ref AbstractObject2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractObject3D = AbstractObject<3, T>; -#endif +typedef AbstractBasicObject<3, Float> AbstractObject3D; }} diff --git a/src/SceneGraph/AbstractTransformation.h b/src/SceneGraph/AbstractTransformation.h index 5f828a7a1..95dfbbeff 100644 --- a/src/SceneGraph/AbstractTransformation.h +++ b/src/SceneGraph/AbstractTransformation.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractTransformation, enum Magnum::SceneGraph::TransformationType, alias Magnum::SceneGraph::AbstractTransformation2D, Magnum::SceneGraph::AbstractTransformation3D + * @brief Class Magnum::SceneGraph::AbstractBasicTransformation, enum Magnum::SceneGraph::TransformationType, typedef Magnum::SceneGraph::AbstractTransformation2D, Magnum::SceneGraph::AbstractTransformation3D */ #include @@ -50,14 +50,10 @@ When subclassing, you have to: - Implement all members listed in **Subclass implementation** group above - Provide implicit (parameterless) constructor -@see @ref scenegraph, AbstractTransformation2D, AbstractTransformation3D +@see @ref AbstractTransformation2D, @ref AbstractTransformation3D, + @ref scenegraph */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT AbstractTransformation { +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation { public: /** @brief Underlying floating-point type */ typedef T Type; @@ -65,8 +61,8 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractTransformation { /** @brief Dimension count */ static const UnsignedInt Dimensions = dimensions; - explicit AbstractTransformation(); - virtual ~AbstractTransformation() = 0; + explicit AbstractBasicTransformation(); + virtual ~AbstractBasicTransformation() = 0; #ifdef DOXYGEN_GENERATING_OUTPUT /** @@ -142,7 +138,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractTransformation { * @brief Reset object transformation * @return Pointer to self (for method chaining) */ - AbstractTransformation* resetTransformation() { + AbstractBasicTransformation* resetTransformation() { doResetTransformation(); return this; } @@ -165,39 +161,19 @@ enum class TransformationType: UnsignedByte { Local = 0x01 }; -#ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Base for two-dimensional transformations +@brief Base transformation for two-dimensional float scenes -Convenience alternative to %AbstractTransformation<2, T>. See -AbstractTransformation for more information. -@note Not available on GCC < 4.7. Use %AbstractTransformation<2, T> - instead. -@see AbstractTransformation3D +@see @ref AbstractTransformation3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractTransformation2D = AbstractTransformation<2, T>; +typedef AbstractBasicTransformation<2, Float> AbstractTransformation2D; /** -@brief Base for three-dimensional transformations +@brief Base transformation for three-dimensional float scenes -Convenience alternative to %AbstractTransformation<3, T>. See -AbstractTransformation for more information. -@note Not available on GCC < 4.7. Use %AbstractTransformation<3, T> - instead. -@see AbstractTransformation2D +@see @ref AbstractTransformation2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AbstractTransformation3D = AbstractTransformation<3, T>; -#endif +typedef AbstractBasicTransformation<3, Float> AbstractTransformation3D; }} diff --git a/src/SceneGraph/AbstractTranslationRotation2D.h b/src/SceneGraph/AbstractTranslationRotation2D.h index ad8336a70..ba6c3a67f 100644 --- a/src/SceneGraph/AbstractTranslationRotation2D.h +++ b/src/SceneGraph/AbstractTranslationRotation2D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractTranslationRotation2D + * @brief Class Magnum::SceneGraph::AbstractBasicTranslationRotation2D, typedef Magnum::SceneGraph::AbstractTranslationRotation2D */ #include "AbstractTransformation.h" @@ -33,18 +33,13 @@ namespace Magnum { namespace SceneGraph { /** -@brief Base for two-dimensional transformations supporting translation and rotation +@brief Base translation for two-dimensional scenes supporting translation and rotation -@see @ref scenegraph, AbstractTranslationRotation3D +@see @ref AbstractTranslationRotation2D, @ref scenegraph, @ref AbstractBasicTranslationRotation3D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class AbstractTranslationRotation2D: public AbstractTransformation<2, T> { +template class AbstractBasicTranslationRotation2D: public AbstractBasicTransformation<2, T> { public: - explicit AbstractTranslationRotation2D(); + explicit AbstractBasicTranslationRotation2D(); /** * @brief Translate object @@ -54,7 +49,7 @@ class AbstractTranslationRotation2D: public AbstractTransformation<2, T> { * * @see Vector2::xAxis(), Vector2::yAxis() */ - AbstractTranslationRotation2D* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation2D* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { doTranslate(vector, type); return this; } @@ -65,15 +60,15 @@ class AbstractTranslationRotation2D: public AbstractTransformation<2, T> { * @param type Transformation type * @return Pointer to self (for method chaining) */ - AbstractTranslationRotation2D* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation2D* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { doRotate(angle, type); return this; } /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - AbstractTranslationRotation2D* resetTransformation() { - AbstractTransformation<2, T>::resetTransformation(); + AbstractBasicTranslationRotation2D* resetTransformation() { + AbstractBasicTransformation<2, T>::resetTransformation(); return this; } #endif @@ -90,7 +85,14 @@ class AbstractTranslationRotation2D: public AbstractTransformation<2, T> { virtual void doRotate(Math::Rad angle, TransformationType type) = 0; }; -template inline AbstractTranslationRotation2D::AbstractTranslationRotation2D() = default; +template inline AbstractBasicTranslationRotation2D::AbstractBasicTranslationRotation2D() = default; + +/** +@brief Base transformation for two-dimensional float scenes supporting translation and rotation + +@see @ref AbstractTranslationRotation3D +*/ +typedef AbstractBasicTranslationRotation2D AbstractTranslationRotation2D; }} diff --git a/src/SceneGraph/AbstractTranslationRotation3D.h b/src/SceneGraph/AbstractTranslationRotation3D.h index 7cc28b8c5..6a60f00ab 100644 --- a/src/SceneGraph/AbstractTranslationRotation3D.h +++ b/src/SceneGraph/AbstractTranslationRotation3D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractTranslationRotation3D + * @brief Class Magnum::SceneGraph::AbstractBasicTranslationRotation3D, typedef Magnum::SceneGraph::AbstractTranslationRotation3D */ #include "AbstractTransformation.h" @@ -34,18 +34,13 @@ namespace Magnum { namespace SceneGraph { /** -@brief Base for three-dimensional transformations supporting translation and rotation +@brief Base translation for three-dimensional scenes supporting translation and rotation -@see @ref scenegraph, AbstractTranslationRotation2D +@see @ref AbstractTranslationRotation3D @ref scenegraph, @ref AbstractBasicTranslationRotation2D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { +template class AbstractBasicTranslationRotation3D: public AbstractBasicTransformation<3, T> { public: - explicit AbstractTranslationRotation3D(); + explicit AbstractBasicTranslationRotation3D(); /** * @brief Translate object @@ -55,7 +50,7 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { * * @see Vector3::xAxis(), Vector3::yAxis(), Vector3::zAxis() */ - AbstractTranslationRotation3D* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { doTranslate(vector, type); return this; } @@ -70,7 +65,7 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { * @see rotateX(), rotateY(), rotateZ(), Vector3::xAxis(), * Vector3::yAxis(), Vector3::zAxis() */ - AbstractTranslationRotation3D* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { doRotate(angle, normalizedAxis, type); return this; } @@ -84,7 +79,7 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { * In some implementations faster than calling * `rotate(angle, Vector3::xAxis())`. */ - AbstractTranslationRotation3D* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { doRotateX(angle, type); return this; } @@ -98,7 +93,7 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { * In some implementations faster than calling * `rotate(angle, Vector3::yAxis())`. */ - AbstractTranslationRotation3D* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { doRotateX(angle, type); return this; } @@ -112,15 +107,15 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { * In some implementations faster than calling * `rotate(angle, Vector3::zAxis())`. */ - AbstractTranslationRotation3D* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { doRotateZ(angle, type); return this; } /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - AbstractTranslationRotation3D* resetTransformation() { - AbstractTransformation<3, T>::resetTransformation(); + AbstractBasicTranslationRotation3D* resetTransformation() { + AbstractBasicTransformation<3, T>::resetTransformation(); return this; } #endif @@ -164,7 +159,14 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { } }; -template inline AbstractTranslationRotation3D::AbstractTranslationRotation3D() = default; +template inline AbstractBasicTranslationRotation3D::AbstractBasicTranslationRotation3D() = default; + +/** +@brief Base transformation for three-dimensional float scenes supporting translation and rotation + +@see @ref AbstractTranslationRotation2D +*/ +typedef AbstractBasicTranslationRotation3D AbstractTranslationRotation3D; }} diff --git a/src/SceneGraph/AbstractTranslationRotationScaling2D.h b/src/SceneGraph/AbstractTranslationRotationScaling2D.h index 8e39d16ad..c5a5dea3d 100644 --- a/src/SceneGraph/AbstractTranslationRotationScaling2D.h +++ b/src/SceneGraph/AbstractTranslationRotationScaling2D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractTranslationRotationScaling2D + * @brief Class Magnum::SceneGraph::AbstractBasicTranslationRotationScaling2D, typedef Magnum::SceneGraph::AbstractTranslationRotationScaling2D */ #include "AbstractTranslationRotation2D.h" @@ -33,18 +33,13 @@ namespace Magnum { namespace SceneGraph { /** -@brief Base for two-dimensional transformations supporting translation, rotation and scaling +@brief Base transformation for two-dimensional scenes supporting translation, rotation and scaling -@see @ref scenegraph, AbstractTranslationRotationScaling2D +@see @ref AbstractTranslationRotationScaling2D, @ref scenegraph, @ref AbstractBasicTranslationRotationScaling2D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class AbstractTranslationRotationScaling2D: public AbstractTranslationRotation2D { +template class AbstractBasicTranslationRotationScaling2D: public AbstractBasicTranslationRotation2D { public: - explicit AbstractTranslationRotationScaling2D(); + explicit AbstractBasicTranslationRotationScaling2D(); /** * @brief Scale object @@ -54,23 +49,23 @@ class AbstractTranslationRotationScaling2D: public AbstractTranslationRotation2D * * @see Vector2::xScale(), Vector2::yScale() */ - AbstractTranslationRotationScaling2D* scale(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotationScaling2D* scale(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { doScale(vector, type); return this; } /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - AbstractTranslationRotationScaling2D* resetTransformation() { - AbstractTranslationRotation2D::resetTransformation(); + AbstractBasicTranslationRotationScaling2D* resetTransformation() { + AbstractBasicTranslationRotation2D::resetTransformation(); return this; } - AbstractTranslationRotationScaling2D* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { - AbstractTranslationRotation2D::translate(vector, type); + AbstractBasicTranslationRotationScaling2D* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation2D::translate(vector, type); return this; } - AbstractTranslationRotationScaling2D* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { - AbstractTranslationRotation2D::rotate(angle, type); + AbstractBasicTranslationRotationScaling2D* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation2D::rotate(angle, type); return this; } #endif @@ -84,7 +79,14 @@ class AbstractTranslationRotationScaling2D: public AbstractTranslationRotation2D virtual void doScale(const Math::Vector2& vector, TransformationType type) = 0; }; -template inline AbstractTranslationRotationScaling2D::AbstractTranslationRotationScaling2D() = default; +template inline AbstractBasicTranslationRotationScaling2D::AbstractBasicTranslationRotationScaling2D() = default; + +/** +@brief Base transformation for two-dimensional float scenes supporting translation, rotation and scaling + +@see @ref AbstractTranslationRotationScaling3D +*/ +typedef AbstractBasicTranslationRotationScaling2D AbstractTranslationRotationScaling2D; }} diff --git a/src/SceneGraph/AbstractTranslationRotationScaling3D.h b/src/SceneGraph/AbstractTranslationRotationScaling3D.h index 18f814978..e05e34d3f 100644 --- a/src/SceneGraph/AbstractTranslationRotationScaling3D.h +++ b/src/SceneGraph/AbstractTranslationRotationScaling3D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AbstractTranslationRotationScaling3D + * @brief Class Magnum::SceneGraph::AbstractBasicTranslationRotationScaling3D, typedef Magnum::SceneGraph::AbstractTranslationRotationScaling3D */ #include "AbstractTranslationRotation3D.h" @@ -35,16 +35,11 @@ namespace Magnum { namespace SceneGraph { /** @brief Base for three-dimensional transformations supporting translation, rotation and scaling -@see @ref scenegraph, AbstractTranslationRotationScaling2D +@see @ref AbstractTranslationRotationScaling3D, @ref scenegraph, @ref AbstractBasicTranslationRotationScaling2D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class AbstractTranslationRotationScaling3D: public AbstractTranslationRotation3D { +template class AbstractBasicTranslationRotationScaling3D: public AbstractBasicTranslationRotation3D { public: - explicit AbstractTranslationRotationScaling3D(); + explicit AbstractBasicTranslationRotationScaling3D(); /** * @brief Scale object @@ -54,35 +49,35 @@ class AbstractTranslationRotationScaling3D: public AbstractTranslationRotation3D * * @see Vector3::xScale(), Vector3::yScale(), Vector3::zScale() */ - AbstractTranslationRotationScaling3D* scale(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotationScaling3D* scale(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { doScale(vector, type); return this; } /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - AbstractTranslationRotationScaling3D* resetTransformation() { - AbstractTranslationRotation3D::resetTransformation(); + AbstractBasicTranslationRotationScaling3D* resetTransformation() { + AbstractBasicTranslationRotation3D::resetTransformation(); return this; } - AbstractTranslationRotationScaling3D* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { - AbstractTranslationRotation3D::translate(vector, type); + AbstractBasicTranslationRotationScaling3D* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D::translate(vector, type); return this; } - AbstractTranslationRotationScaling3D* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { - AbstractTranslationRotation3D::rotate(angle, normalizedAxis, type); + AbstractBasicTranslationRotationScaling3D* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D::rotate(angle, normalizedAxis, type); return this; } - AbstractTranslationRotationScaling3D* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { - AbstractTranslationRotation3D::rotateX(angle, type); + AbstractBasicTranslationRotationScaling3D* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D::rotateX(angle, type); return this; } - AbstractTranslationRotationScaling3D* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { - AbstractTranslationRotation3D::rotateY(angle, type); + AbstractBasicTranslationRotationScaling3D* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D::rotateY(angle, type); return this; } - AbstractTranslationRotationScaling3D* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { - AbstractTranslationRotation3D::rotateZ(angle, type); + AbstractBasicTranslationRotationScaling3D* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { + AbstractBasicTranslationRotation3D::rotateZ(angle, type); return this; } #endif @@ -96,7 +91,14 @@ class AbstractTranslationRotationScaling3D: public AbstractTranslationRotation3D virtual void doScale(const Math::Vector3& vector, TransformationType type) = 0; }; -template inline AbstractTranslationRotationScaling3D::AbstractTranslationRotationScaling3D() = default; +template inline AbstractBasicTranslationRotationScaling3D::AbstractBasicTranslationRotationScaling3D() = default; + +/** +@brief Base transformation for three-dimensional float scenes supporting translation, rotation and scaling + +@see @ref AbstractTranslationRotationScaling2D +*/ +typedef AbstractBasicTranslationRotationScaling3D AbstractTranslationRotationScaling3D; }} diff --git a/src/SceneGraph/Animable.cpp b/src/SceneGraph/Animable.cpp index 1087f8371..ad53b31fe 100644 --- a/src/SceneGraph/Animable.cpp +++ b/src/SceneGraph/Animable.cpp @@ -27,10 +27,10 @@ namespace Magnum { namespace SceneGraph { #ifndef DOXYGEN_GENERATING_OUTPUT -template class MAGNUM_SCENEGRAPH_EXPORT Animable<2, Float>; -template class MAGNUM_SCENEGRAPH_EXPORT Animable<3, Float>; -template class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup<2, Float>; -template class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup<3, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable<2, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable<3, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup<2, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup<3, Float>; #endif Debug operator<<(Debug debug, AnimationState value) { diff --git a/src/SceneGraph/Animable.h b/src/SceneGraph/Animable.h index 207f4edf8..8d22714d7 100644 --- a/src/SceneGraph/Animable.h +++ b/src/SceneGraph/Animable.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::Animable, enum Magnum::SceneGraph::AnimationState + * @brief Class Magnum::SceneGraph::BasicAnimable, typedef Magnum::SceneGraph::Animable2D, Magnum::SceneGraph::Animable3D, enum Magnum::SceneGraph::AnimationState */ #include "AbstractGroupedFeature.h" @@ -37,7 +37,7 @@ namespace Magnum { namespace SceneGraph { /** @brief Animation state -@see Animable::setState() +@see BasicAnimable::setState() */ enum class AnimationState: UnsignedByte { /** @@ -56,7 +56,7 @@ enum class AnimationState: UnsignedByte { Running }; -/** @debugoperator{Magnum::SceneGraph::Animable} */ +/** @debugoperator{Magnum::SceneGraph::BasicAnimable} */ Debug MAGNUM_SCENEGRAPH_EXPORT operator<<(Debug debug, AnimationState value); /** @@ -73,12 +73,12 @@ animationStep(). You can do it conveniently using multiple inheritance (see implement your animation, the function provides both absolute animation time and time delta. Example: @code -typedef SceneGraph::Object> Object3D; -typedef SceneGraph::Scene> Scene3D; +typedef SceneGraph::Object Object3D; +typedef SceneGraph::Scene Scene3D; -class AnimableObject: public Object3D, SceneGraph::Animable3D<> { +class AnimableObject: public Object3D, SceneGraph::Animable3D { public: - AnimableObject(Object* parent = nullptr, SceneGraph::DrawableGroup3D<>* group = nullptr): Object3D(parent), SceneGraph::Animable3D<>(this, group) { + AnimableObject(Object* parent = nullptr, SceneGraph::DrawableGroup3D* group = nullptr): Object3D(parent), SceneGraph::Animable3D(this, group) { setDuration(10.0f); // ... } @@ -90,22 +90,23 @@ class AnimableObject: public Object3D, SceneGraph::Animable3D<> { @endcode Then add the object to your scene and some animation group. You can also use -AnimableGroup::add() and AnimableGroup::remove() instead of passing the group -in the constructor. The animation is initially in stopped state and without -repeat, see setState(), setRepeated() and setRepeatCount() for more information. +BasicAnimableGroup::add() and BasicAnimableGroup::remove() instead of passing +the group in the constructor. The animation is initially in stopped state and +without repeat, see setState(), setRepeated() and setRepeatCount() for more +information. @code Scene3D scene; -SceneGraph::AnimableGroup3D<> animables; +SceneGraph::AnimableGroup3D animables; (new AnimableObject(&scene, &animables)) ->setState(SceneGraph::AnimationState::Running); // ... @endcode -Animation step is performed by calling AnimableGroup::step() in your draw event -implementation. The function expects absolute time from relative to some fixed -point in the past and time delta (i.e. duration of the frame). You can use -Timeline for that, see its documentation for more information. +Animation step is performed by calling BasicAnimableGroup::step() in your draw +event implementation. The function expects absolute time from relative to some +fixed point in the past and time delta (i.e. duration of the frame). You can +use Timeline for that, see its documentation for more information. @code Timeline timeline; timeline.start(); @@ -121,11 +122,11 @@ void MyApplication::drawEvent() { @section Animable-performance Using animable groups to improve performance -AnimableGroup is optimized for case when no animation is running - it just +Animable group is optimized for case when no animation is running - it just puts itself to rest and waits until some animation changes its state to @ref AnimationState "AnimationState::Running" again. If you put animations which are not pernamently running to separate group, they will not be always -traversed when calling AnimableGroup::step(), saving precious frame time. +traversed when calling BasicAnimableGroup::step(), saving precious frame time. @section Animable-explicit-specializations Explicit template specializations @@ -134,18 +135,14 @@ For other specializations (e.g. using Double type) you have to use Animable.hpp implementation file to avoid linker errors. See also @ref compilation-speedup-hpp for more information. - - @ref Animable "Animable<2, Float>", @ref AnimableGroup "AnimableGroup<2, Float>" - - @ref Animable "Animable<3, Float>", @ref AnimableGroup "AnimableGroup<3, Float>" + - @ref BasicAnimable "BasicAnimable<2, Float>", @ref BasicAnimableGroup "BasicAnimableGroup<2, Float>" + - @ref BasicAnimable "BasicAnimable<3, Float>", @ref BasicAnimableGroup "BasicAnimableGroup<3, Float>" -@see @ref scenegraph, Animable2D, Animable3D, AnimableGroup2D, AnimableGroup3D +@see @ref Animable2D, @ref Animable3D, @ref scenegraph, @ref AnimableGroup2D, + @ref AnimableGroup3D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractGroupedFeature, T> { - friend class AnimableGroup; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimable: public AbstractBasicGroupedFeature, T> { + friend class BasicAnimableGroup; public: /** @@ -155,11 +152,11 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractGroupedFeature* object, AnimableGroup* group = nullptr); + explicit BasicAnimable(AbstractBasicObject* object, BasicAnimableGroup* group = nullptr); - ~Animable(); + ~BasicAnimable(); /** @brief Animation duration */ Float duration() const { return _duration; } @@ -178,7 +175,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractGroupedFeature* setState(AnimationState state); + BasicAnimable* setState(AnimationState state); /** * @brief Whether the animation is repeated @@ -194,7 +191,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractGroupedFeature* setRepeated(bool repeated) { + BasicAnimable* setRepeated(bool repeated) { _repeated = repeated; return this; } @@ -214,7 +211,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractGroupedFeature* setRepeatCount(UnsignedShort count) { + BasicAnimable* setRepeatCount(UnsignedShort count) { _repeatCount = count; return this; } @@ -224,8 +221,8 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractGroupedFeature* group(); - const AnimableGroup* group() const; /**< @overload */ + BasicAnimableGroup* group(); + const BasicAnimableGroup* group() const; /**< @overload */ protected: /** @@ -236,7 +233,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractGroupedFeature* setDuration(Float duration) { + BasicAnimable* setDuration(Float duration) { _duration = duration; return this; } @@ -246,8 +243,8 @@ class MAGNUM_SCENEGRAPH_EXPORT Animable: public AbstractGroupedFeature%Animable<2, T>. See Animable for more -information. -@note Not available on GCC < 4.7. Use %Animable<2, T> instead. -@see Animable3D +@see @ref Animable3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using Animable2D = Animable<2, T>; +typedef BasicAnimable<2, Float> Animable2D; /** -@brief Three-dimensional animable +@brief Animable for three-dimensional float scenes -Convenience alternative to %Animable<3, T>. See Animable for more -information. -@note Not available on GCC < 4.7. Use %Animable<3, T> instead. -@see Animable2D +@see @ref Animable2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using Animable3D = Animable<3, T>; -#endif +typedef BasicAnimable<3, Float> Animable3D; }} diff --git a/src/SceneGraph/Animable.hpp b/src/SceneGraph/Animable.hpp index 598959bac..b34101bea 100644 --- a/src/SceneGraph/Animable.hpp +++ b/src/SceneGraph/Animable.hpp @@ -35,11 +35,11 @@ namespace Magnum { namespace SceneGraph { -template Animable::Animable(AbstractObject* object, AnimableGroup* group): AbstractGroupedFeature, T>(object, group), _duration(0.0f), startTime(std::numeric_limits::infinity()), pauseTime(-std::numeric_limits::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {} +template BasicAnimable::BasicAnimable(AbstractBasicObject* object, BasicAnimableGroup* group): AbstractBasicGroupedFeature, T>(object, group), _duration(0.0f), startTime(std::numeric_limits::infinity()), pauseTime(-std::numeric_limits::infinity()), previousState(AnimationState::Stopped), currentState(AnimationState::Stopped), _repeated(false), _repeatCount(0), repeats(0) {} -template Animable::~Animable() {} +template BasicAnimable::~BasicAnimable() {} -template Animable* Animable::setState(AnimationState state) { +template BasicAnimable* BasicAnimable::setState(AnimationState state) { if(currentState == state) return this; /* Not allowed (for sanity) */ @@ -52,20 +52,20 @@ template Animable* Animable AnimableGroup* Animable::group() { - return static_cast*>(AbstractGroupedFeature, T>::group()); +template BasicAnimableGroup* BasicAnimable::group() { + return static_cast*>(AbstractBasicGroupedFeature, T>::group()); } -template const AnimableGroup* Animable::group() const { - return static_cast*>(AbstractGroupedFeature, T>::group()); +template const BasicAnimableGroup* BasicAnimable::group() const { + return static_cast*>(AbstractBasicGroupedFeature, T>::group()); } -template void AnimableGroup::step(const Float time, const Float delta) { +template void BasicAnimableGroup::step(const Float time, const Float delta) { if(!_runningCount && !wakeUp) return; wakeUp = false; for(std::size_t i = 0; i != this->size(); ++i) { - Animable* animable = (*this)[i]; + BasicAnimable* animable = (*this)[i]; /* The animation was stopped recently, just decrease count of running animations if the animation was running before */ @@ -126,9 +126,9 @@ template void AnimableGroup::ste /* Animation is still running, perform animation step */ CORRADE_ASSERT(time-animable->startTime >= 0.0f, - "SceneGraph::AnimableGroup::step(): animation was started in future - probably wrong time passed", ); + "SceneGraph::BasicAnimableGroup::step(): animation was started in future - probably wrong time passed", ); CORRADE_ASSERT(delta >= 0.0f, - "SceneGraph::AnimableGroup::step(): negative delta passed", ); + "SceneGraph::BasicAnimableGroup::step(): negative delta passed", ); animable->animationStep(time - animable->startTime, delta); } diff --git a/src/SceneGraph/AnimableGroup.h b/src/SceneGraph/AnimableGroup.h index 134218798..835ee4769 100644 --- a/src/SceneGraph/AnimableGroup.h +++ b/src/SceneGraph/AnimableGroup.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::AnimableGroup + * @brief Class Magnum::SceneGraph::BasicAnimableGroup, typedef Magnum::SceneGraph::AnimableGroup2D, Magnum::SceneGraph::AnimableGroup3D */ #include "FeatureGroup.h" @@ -37,22 +37,17 @@ namespace Magnum { namespace SceneGraph { /** @brief Group of animables -See Animable for more information. -@see @ref scenegraph, AnimableGroup2D, AnimableGroup3D +See BasicAnimable for more information. +@see @ref AnimableGroup2D, @ref AnimableGroup3D, @ref scenegraph */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup: public FeatureGroup, T> { - friend class Animable; +template class MAGNUM_SCENEGRAPH_EXPORT BasicAnimableGroup: public BasicFeatureGroup, T> { + friend class BasicAnimable; public: /** * @brief Constructor */ - explicit AnimableGroup(): _runningCount(0), wakeUp(false) {} + explicit BasicAnimableGroup(): _runningCount(0), wakeUp(false) {} /** * @brief Count of running animations @@ -76,37 +71,19 @@ class MAGNUM_SCENEGRAPH_EXPORT AnimableGroup: public FeatureGroup%AnimableGroup<2, T>. See Animable for -more information. -@note Not available on GCC < 4.7. Use %AnimableGroup<2, T> instead. -@see AnimableGroup3D +@see @ref AnimableGroup3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AnimableGroup2D = AnimableGroup<2, T>; +typedef BasicAnimableGroup<2, Float> AnimableGroup2D; /** -@brief Three-dimensional animable +@brief Animable group for three-dimensional float scenes -Convenience alternative to %AnimableGroup<3, T>. See Animable for -more information. -@note Not available on GCC < 4.7. Use %AnimableGroup<3, T> instead. -@see AnimableGroup2D +@see @ref AnimableGroup2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using AnimableGroup3D = AnimableGroup<3, T>; -#endif +typedef BasicAnimableGroup<3, Float> AnimableGroup3D; }} diff --git a/src/SceneGraph/Camera2D.h b/src/SceneGraph/Camera2D.h index ad52e41b6..02a935d1b 100644 --- a/src/SceneGraph/Camera2D.h +++ b/src/SceneGraph/Camera2D.h @@ -1,5 +1,5 @@ -#ifndef Magnum_SceneGraph_Camera2D_h -#define Magnum_SceneGraph_Camera2D_h +#ifndef Magnum_SceneGraph_BasicCamera2D_h +#define Magnum_SceneGraph_BasicCamera2D_h /* This file is part of Magnum. @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::Camera2D + * @brief Class Magnum::SceneGraph::BasicCamera2D, typedef Magnum::SceneGraph::Camera2D */ #include "AbstractCamera.h" @@ -39,7 +39,7 @@ See Drawable documentation for introduction. The camera by default displays OpenGL unit cube `[(-1, -1, -1); (1, 1, 1)]` and doesn't do any aspect ratio correction. Common setup example: @code -SceneGraph::Camera2D<>* camera = new SceneGraph::Camera2D<>(&cameraObject); +SceneGraph::BasicCamera2D* camera = new SceneGraph::BasicCamera2D(&cameraObject); camera->setProjection({4.0f/3.0f, 1.0f}) ->setAspectRatioPolicy(SceneGraph::AspectRatioPolicy::Extend); @endcode @@ -48,19 +48,14 @@ camera->setProjection({4.0f/3.0f, 1.0f}) The following specialization are explicitly compiled into SceneGraph library. For other specializations (e.g. using Double type) you have to use -Camera2D.hpp implementation file to avoid linker errors. See +BasicCamera2D.hpp implementation file to avoid linker errors. See @ref compilation-speedup-hpp for more information. - - @ref Camera2D "Camera2D" + - @ref BasicCamera2D "BasicCamera2D" -@see @ref scenegraph, Camera3D, Drawable, DrawableGroup +@see @ref Camera2D, @ref scenegraph, @ref BasicCamera3D, @ref BasicDrawable, @ref BasicDrawableGroup */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT Camera2D: public AbstractCamera<2, T> { +template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera2D: public AbstractBasicCamera<2, T> { public: /** * @brief Constructor @@ -69,7 +64,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera2D: public AbstractCamera<2, T> { * Sets orthographic projection to the default OpenGL cube (range @f$ [-1; 1] @f$ in all directions). * @see setProjection() */ - explicit Camera2D(AbstractObject<2, T>* object); + explicit BasicCamera2D(AbstractBasicObject<2, T>* object); /** * @brief Set projection @@ -78,17 +73,24 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera2D: public AbstractCamera<2, T> { * * @see Matrix3::projection() */ - Camera2D* setProjection(const Math::Vector2& size); + BasicCamera2D* setProjection(const Math::Vector2& size); /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - Camera2D* setAspectRatioPolicy(AspectRatioPolicy policy) { - AbstractCamera<2, T>::setAspectRatioPolicy(policy); + BasicCamera2D* setAspectRatioPolicy(AspectRatioPolicy policy) { + AbstractBasicCamera<2, T>::setAspectRatioPolicy(policy); return this; } #endif }; +/** +@brief Camera for two-dimensional float scenes + +@see @ref Camera3D +*/ +typedef BasicCamera2D Camera2D; + }} #endif diff --git a/src/SceneGraph/Camera2D.hpp b/src/SceneGraph/Camera2D.hpp index 900d976b1..7de9807fd 100644 --- a/src/SceneGraph/Camera2D.hpp +++ b/src/SceneGraph/Camera2D.hpp @@ -35,12 +35,12 @@ using namespace std; namespace Magnum { namespace SceneGraph { -template Camera2D::Camera2D(AbstractObject<2, T>* object): AbstractCamera<2, T>(object) {} +template BasicCamera2D::BasicCamera2D(AbstractBasicObject<2, T>* object): AbstractBasicCamera<2, T>(object) {} -template Camera2D* Camera2D::setProjection(const Math::Vector2& size) { - AbstractCamera<2, T>::rawProjectionMatrix = Math::Matrix3::projection(size); +template BasicCamera2D* BasicCamera2D::setProjection(const Math::Vector2& size) { + AbstractBasicCamera<2, T>::rawProjectionMatrix = Math::Matrix3::projection(size); - AbstractCamera<2, T>::fixAspectRatio(); + AbstractBasicCamera<2, T>::fixAspectRatio(); return this; } diff --git a/src/SceneGraph/Camera3D.h b/src/SceneGraph/Camera3D.h index 6885037df..77cba35a2 100644 --- a/src/SceneGraph/Camera3D.h +++ b/src/SceneGraph/Camera3D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::Camera3D + * @brief Class Magnum::SceneGraph::BasicCamera3D, typedef Magnum::SceneGraph::Camera3D */ #include "AbstractCamera.h" @@ -44,7 +44,7 @@ See Drawable documentation for introduction. The camera by default displays OpenGL unit cube `[(-1, -1, -1); (1, 1, 1)]` with orthographic projection and doesn't do any aspect ratio correction. Common setup example: @code -SceneGraph::Camera3D<>* camera = new SceneGraph::Camera3D<>(&cameraObject); +SceneGraph::BasicCamera3D* camera = new SceneGraph::BasicCamera3D(&cameraObject); camera->setPerspective({}, 0.001f, 100.0f) ->setAspectRatioPolicy(SceneGraph::AspectRatioPolicy::Extend); @endcode @@ -53,25 +53,20 @@ camera->setPerspective({}, 0.001f, 100.0f) The following specialization are explicitly compiled into SceneGraph library. For other specializations (e.g. using Double type) you have to use -Camera3D.hpp implementation file to avoid linker errors. See +BasicCamera3D.hpp implementation file to avoid linker errors. See @ref compilation-speedup-hpp for more information. - - @ref Camera3D "Camera3D" + - @ref BasicCamera3D "BasicCamera3D" -@see @ref scenegraph, Camera2D, Drawable, DrawableGroup +@see @ref Camera3D, @ref scenegraph, @ref BasicCamera2D, @ref BasicDrawable, @ref BasicDrawableGroup */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { +template class MAGNUM_SCENEGRAPH_EXPORT BasicCamera3D: public AbstractBasicCamera<3, T> { public: /** * @brief Constructor * @param object %Object holding this feature */ - explicit Camera3D(AbstractObject<3, T>* object); + explicit BasicCamera3D(AbstractBasicObject<3, T>* object); /** * @brief Set orthographic projection @@ -82,7 +77,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { * * @see setPerspective(), Matrix4::orthographicProjection() */ - Camera3D* setOrthographic(const Math::Vector2& size, T near, T far); + BasicCamera3D* setOrthographic(const Math::Vector2& size, T near, T far); /** * @brief Set perspective projection @@ -93,7 +88,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { * * @see setOrthographic(), Matrix4::perspectiveProjection() */ - Camera3D* setPerspective(const Math::Vector2& size, T near, T far); + BasicCamera3D* setPerspective(const Math::Vector2& size, T near, T far); /** * @brief Set perspective projection @@ -105,7 +100,7 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { * * @see setOrthographic(), Matrix4::perspectiveProjection() */ - Camera3D* setPerspective(Math::Rad fov, T aspectRatio, T near, T far); + BasicCamera3D* setPerspective(Math::Rad fov, T aspectRatio, T near, T far); /** @brief Near clipping plane */ T near() const { return _near; } @@ -115,8 +110,8 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - Camera3D* setAspectRatioPolicy(AspectRatioPolicy policy) { - AbstractCamera<3, T>::setAspectRatioPolicy(policy); + BasicCamera3D* setAspectRatioPolicy(AspectRatioPolicy policy) { + AbstractBasicCamera<3, T>::setAspectRatioPolicy(policy); return this; } #endif @@ -125,6 +120,13 @@ class MAGNUM_SCENEGRAPH_EXPORT Camera3D: public AbstractCamera<3, T> { T _near, _far; }; +/** +@brief Camera for three-dimensional float scenes + +@see @ref Camera2D +*/ +typedef BasicCamera3D Camera3D; + }} #endif diff --git a/src/SceneGraph/Camera3D.hpp b/src/SceneGraph/Camera3D.hpp index 732cba3f7..4cee4003b 100644 --- a/src/SceneGraph/Camera3D.hpp +++ b/src/SceneGraph/Camera3D.hpp @@ -33,35 +33,35 @@ namespace Magnum { namespace SceneGraph { -template Camera3D::Camera3D(AbstractObject<3, T>* object): AbstractCamera<3, T>(object), _near(T(0)), _far(T(0)) {} +template BasicCamera3D::BasicCamera3D(AbstractBasicObject<3, T>* object): AbstractBasicCamera<3, T>(object), _near(T(0)), _far(T(0)) {} -template Camera3D* Camera3D::setOrthographic(const Math::Vector2& size, T near, T far) { +template BasicCamera3D* BasicCamera3D::setOrthographic(const Math::Vector2& size, T near, T far) { /** @todo Get near/far from the matrix */ _near = near; _far = far; - AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4::orthographicProjection(size, near, far); - AbstractCamera<3, T>::fixAspectRatio(); + AbstractBasicCamera<3, T>::rawProjectionMatrix = Math::Matrix4::orthographicProjection(size, near, far); + AbstractBasicCamera<3, T>::fixAspectRatio(); return this; } -template Camera3D* Camera3D::setPerspective(const Math::Vector2& size, T near, T far) { +template BasicCamera3D* BasicCamera3D::setPerspective(const Math::Vector2& size, T near, T far) { /** @todo Get near/far from the matrix */ _near = near; _far = far; - AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4::perspectiveProjection(size, near, far); - AbstractCamera<3, T>::fixAspectRatio(); + AbstractBasicCamera<3, T>::rawProjectionMatrix = Math::Matrix4::perspectiveProjection(size, near, far); + AbstractBasicCamera<3, T>::fixAspectRatio(); return this; } -template Camera3D* Camera3D::setPerspective(Math::Rad fov, T aspectRatio, T near, T far) { +template BasicCamera3D* BasicCamera3D::setPerspective(Math::Rad fov, T aspectRatio, T near, T far) { /** @todo Get near/far from the matrix */ _near = near; _far = far; - AbstractCamera<3, T>::rawProjectionMatrix = Math::Matrix4::perspectiveProjection(fov, aspectRatio, near, far); - AbstractCamera<3, T>::fixAspectRatio(); + AbstractBasicCamera<3, T>::rawProjectionMatrix = Math::Matrix4::perspectiveProjection(fov, aspectRatio, near, far); + AbstractBasicCamera<3, T>::fixAspectRatio(); return this; } diff --git a/src/SceneGraph/Drawable.h b/src/SceneGraph/Drawable.h index 5afb8b80d..e5beac03f 100644 --- a/src/SceneGraph/Drawable.h +++ b/src/SceneGraph/Drawable.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::Drawable, Magnum::SceneGraph::DrawableGroup, alias Magnum::SceneGraph::Drawable2D, Magnum::SceneGraph::Drawable3D, Magnum::SceneGraph::DrawableGroup2D, Magnum::SceneGraph::DrawableGroup3D + * @brief Class Magnum::SceneGraph::BasicDrawable, Magnum::SceneGraph::BasicDrawableGroup, typedef Magnum::SceneGraph::Drawable2D, Magnum::SceneGraph::Drawable3D, Magnum::SceneGraph::DrawableGroup2D, Magnum::SceneGraph::DrawableGroup3D */ #include "AbstractGroupedFeature.h" @@ -35,7 +35,7 @@ namespace Magnum { namespace SceneGraph { /** @brief %Drawable -Adds drawing function to the object. Each %Drawable is part of some DrawableGroup +Adds drawing function to the object. Each Drawable is part of some DrawableGroup and the whole group is drawn with particular camera using AbstractCamera::draw(). @section Drawable-usage Usage @@ -44,27 +44,27 @@ First thing is add Drawable feature to some object and implement draw(). You can do it conveniently using multiple inheritance (see @ref scenegraph-features for introduction). Example: @code -typedef SceneGraph::Object> Object3D; -typedef SceneGraph::Scene> Scene3D; +typedef SceneGraph::Object Object3D; +typedef SceneGraph::Scene Scene3D; -class DrawableObject: public Object3D, SceneGraph::Drawable3D<> { +class DrawableObject: public Object3D, SceneGraph::Drawable3D { public: - DrawableObject(Object* parent = nullptr, SceneGraph::DrawableGroup3D<>* group = nullptr): Object3D(parent), SceneGraph::Drawable3D<>(this, group) { + DrawableObject(Object* parent = nullptr, SceneGraph::DrawableGroup3D* group = nullptr): Object3D(parent), SceneGraph::Drawable3D(this, group) { // ... } - void draw(const Matrix4& transformationMatrix, AbstractCamera3D<>* camera) override { + void draw(const Matrix4& transformationMatrix, AbstractCamera3D* camera) override { // ... } } @endcode Then you add these objects to your scene and some drawable group and transform -them as you like. You can also use DrawableGroup::add() and -DrawableGroup::remove(). +them as you like. You can also use BasicDrawableGroup::add() and +BasicDrawableGroup::remove(). @code Scene3D scene; -SceneGraph::DrawableGroup3D<> drawables; +SceneGraph::DrawableGroup3D drawables; (new DrawableObject(&scene, &drawables)) ->translate(Vector3::yAxis(-0.3f)) @@ -97,7 +97,7 @@ parameters once for whole group instead of setting them again in each draw() implementation. Example: @code Shaders::PhongShader* shader; -SceneGraph::DrawableGroup3D<> phongObjects, transparentObjects; +SceneGraph::DrawableGroup3D phongObjects, transparentObjects; void MyApplication::drawEvent() { shader->setProjectionMatrix(camera->projectionMatrix()) @@ -114,14 +114,9 @@ void MyApplication::drawEvent() { } @endcode -@see @ref scenegraph, Drawable2D, Drawable3D, DrawableGroup2D, DrawableGroup3D +@see Drawable2D, Drawable3D, @ref scenegraph, DrawableGroup2D, DrawableGroup3D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class Drawable: public AbstractGroupedFeature, T> { +template class BasicDrawable: public AbstractBasicGroupedFeature, T> { public: /** * @brief Constructor @@ -129,9 +124,9 @@ class Drawable: public AbstractGroupedFeature* object, DrawableGroup* drawables = nullptr): AbstractGroupedFeature, T>(object, drawables) {} + explicit BasicDrawable(AbstractBasicObject* object, BasicDrawableGroup* drawables = nullptr): AbstractBasicGroupedFeature, T>(object, drawables) {} /** * @brief Draw the object using given camera @@ -141,40 +136,22 @@ class Drawable: public AbstractGroupedFeature::MatrixType& transformationMatrix, AbstractCamera* camera) = 0; + virtual void draw(const typename DimensionTraits::MatrixType& transformationMatrix, AbstractBasicCamera* camera) = 0; }; -#ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Two-dimensional drawable +@brief Two-dimensional drawable for float scenes -Convenience alternative to %Drawable<2, T>. See Drawable for more -information. -@note Not available on GCC < 4.7. Use %Drawable<2, T> instead. @see Drawable3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using Drawable2D = Drawable<2, T>; +typedef BasicDrawable<2, Float> Drawable2D; /** -@brief Three-dimensional drawable +@brief Three-dimensional drawable for float scenes -Convenience alternative to %Drawable<3, T>. See Drawable for more -information. -@note Not available on GCC < 4.7. Use %Drawable<3, T> instead. @see Drawable2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using Drawable3D = Drawable<3, T>; -#endif +typedef BasicDrawable<3, Float> Drawable3D; /** @brief Group of drawables @@ -183,52 +160,24 @@ See Drawable for more information. @see @ref scenegraph, DrawableGroup2D, DrawableGroup3D */ #ifndef CORRADE_GCC46_COMPATIBILITY -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using DrawableGroup = FeatureGroup, T>; -#else -#ifdef DOXYGEN_GENERATING_OUTPUT -template +template using BasicDrawableGroup = BasicFeatureGroup, T>; #else -template -#endif -class DrawableGroup: public FeatureGroup, T> {}; +template class BasicDrawableGroup: public BasicFeatureGroup, T> {}; #endif -#ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Group of two-dimensional drawables +@brief Group of two-dimensional drawables for float scenes -Convenience alternative to %DrawableGroup<2, T>. See Drawable for -more information. -@note Not available on GCC < 4.7. Use %Drawable<2, T> instead. @see DrawableGroup3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using DrawableGroup2D = DrawableGroup<2, T>; +typedef BasicDrawableGroup<2, Float> DrawableGroup2D; /** -@brief Group of three-dimensional drawables +@brief Group of three-dimensional drawables for float scenes -Convenience alternative to %DrawableGroup<3, T>. See Drawable for -more information. -@note Not available on GCC < 4.7. Use %Drawable<3, T> instead. @see DrawableGroup2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using DrawableGroup3D = DrawableGroup<3, T>; -#endif +typedef BasicDrawableGroup<3, Float> DrawableGroup3D; }} diff --git a/src/SceneGraph/DualComplexTransformation.h b/src/SceneGraph/DualComplexTransformation.h index 0a9e008cd..fbb582c92 100644 --- a/src/SceneGraph/DualComplexTransformation.h +++ b/src/SceneGraph/DualComplexTransformation.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::DualComplexTransformation + * @brief Class Magnum::SceneGraph::BasicDualComplexTransformation, typedef Magnum::SceneGraph::DualComplexTransformation */ #include "Math/DualComplex.h" @@ -39,14 +39,9 @@ namespace Magnum { namespace SceneGraph { This class allows only rigid transformation (i.e. only rotation and translation). -@see @ref scenegraph, Math::DualComplex, DualQuaternionTransformation +@see @ref DualComplexTransformation, @ref scenegraph, Math::DualComplex, @ref BasicDualQuaternionTransformation */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class DualComplexTransformation: public AbstractTranslationRotation2D { +template class BasicDualComplexTransformation: public AbstractBasicTranslationRotation2D { public: /** @brief Transformation type */ typedef Math::DualComplex DataType; @@ -81,9 +76,9 @@ class DualComplexTransformation: public AbstractTranslationRotation2D { * the object subsequently. * @see DualComplex::normalized() */ - Object>* normalizeRotation() { + Object>* normalizeRotation() { setTransformationInternal(_transformation.normalized()); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -93,18 +88,18 @@ class DualComplexTransformation: public AbstractTranslationRotation2D { * Expects that the dual complex number is normalized. * @see DualComplex::isNormalized() */ - Object>* setTransformation(const Math::DualComplex& transformation) { + Object>* setTransformation(const Math::DualComplex& transformation) { CORRADE_ASSERT(transformation.isNormalized(), "SceneGraph::DualComplexTransformation::setTransformation(): the dual complex number is not normalized", - static_cast>*>(this)); + static_cast>*>(this)); setTransformationInternal(transformation); - return static_cast>*>(this); + return static_cast>*>(this); } /** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */ - Object>* resetTransformation() { + Object>* resetTransformation() { setTransformationInternal({}); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -116,21 +111,21 @@ class DualComplexTransformation: public AbstractTranslationRotation2D { * Expects that the dual complex number is normalized. * @see DualComplex::isNormalized() */ - Object>* transform(const Math::DualComplex& transformation, TransformationType type = TransformationType::Global) { + Object>* transform(const Math::DualComplex& transformation, TransformationType type = TransformationType::Global) { CORRADE_ASSERT(transformation.isNormalized(), "SceneGraph::DualComplexTransformation::transform(): the dual complex number is not normalized", - static_cast>*>(this)); + static_cast>*>(this)); transformInternal(transformation, type); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling2D::translate() * Same as calling transform() with DualComplex::translation(). */ - Object>* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { + Object>* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { transformInternal(Math::DualComplex::translation(vector), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -142,9 +137,9 @@ class DualComplexTransformation: public AbstractTranslationRotation2D { * Same as calling transform() with DualComplex::rotation(). * @see normalizeRotation() */ - Object>* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { transformInternal(Math::DualComplex::rotation(angle), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -153,14 +148,14 @@ class DualComplexTransformation: public AbstractTranslationRotation2D { * if you want to move it above all. * @return Pointer to self (for method chaining) */ - Object>* move(Object>* under) { - static_cast*>(this)->Containers::template LinkedList>>::move(this, under); - return static_cast>*>(this); + Object>* move(Object>* under) { + static_cast*>(this)->Containers::template LinkedList>>::move(this, under); + return static_cast>*>(this); } protected: /* Allow construction only from Object */ - explicit DualComplexTransformation(); + explicit BasicDualComplexTransformation(); private: void doResetTransformation() override final { resetTransformation(); } @@ -178,9 +173,9 @@ class DualComplexTransformation: public AbstractTranslationRotation2D { /* Setting transformation is forbidden for the scene */ /** @todo Assert for this? */ /** @todo Do this in some common code so we don't need to include Object? */ - if(!static_cast>*>(this)->isScene()) { + if(!static_cast>*>(this)->isScene()) { _transformation = transformation; - static_cast>*>(this)->setDirty(); + static_cast>*>(this)->setDirty(); } } @@ -193,7 +188,14 @@ class DualComplexTransformation: public AbstractTranslationRotation2D { Math::DualComplex _transformation; }; -template inline DualComplexTransformation::DualComplexTransformation() = default; +template inline BasicDualComplexTransformation::BasicDualComplexTransformation() = default; + +/** +@brief Two-dimensional transformation for float scenes implemented using dual complex numbers + +@see @ref DualQuaternionTransformation +*/ +typedef BasicDualComplexTransformation DualComplexTransformation; }} diff --git a/src/SceneGraph/DualQuaternionTransformation.h b/src/SceneGraph/DualQuaternionTransformation.h index 4db82fe78..2a9b1638f 100644 --- a/src/SceneGraph/DualQuaternionTransformation.h +++ b/src/SceneGraph/DualQuaternionTransformation.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::DualQuaternionTransformation + * @brief Class Magnum::SceneGraph::BasicDualQuaternionTransformation, typedef Magnum::SceneGraph::DualQuaternionTransformation */ #include "Math/DualQuaternion.h" @@ -39,14 +39,9 @@ namespace Magnum { namespace SceneGraph { This class allows only rigid transformation (i.e. only rotation and translation). -@see @ref scenegraph, Math::DualQuaternion, DualComplexTransformation +@see @ref DualQuaternionTransformation @ref scenegraph, Math::DualQuaternion, @ref BasicDualComplexTransformation */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class DualQuaternionTransformation: public AbstractTranslationRotation3D { +template class BasicDualQuaternionTransformation: public AbstractBasicTranslationRotation3D { public: /** @brief Underlying transformation type */ typedef Math::DualQuaternion DataType; @@ -83,9 +78,9 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D { * the object subsequently. * @see DualQuaternion::normalized() */ - Object>* normalizeRotation() { + Object>* normalizeRotation() { setTransformation(_transformation.normalized()); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -95,18 +90,18 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D { * Expects that the dual quaternion is normalized. * @see DualQuaternion::isNormalized() */ - Object>* setTransformation(const Math::DualQuaternion& transformation) { + Object>* setTransformation(const Math::DualQuaternion& transformation) { CORRADE_ASSERT(transformation.isNormalized(), "SceneGraph::DualQuaternionTransformation::setTransformation(): the dual quaternion is not normalized", - static_cast>*>(this)); + static_cast>*>(this)); setTransformationInternal(transformation); - return static_cast>*>(this); + return static_cast>*>(this); } /** @copydoc AbstractTranslationRotationScaling3D::resetTransformation() */ - Object>* resetTransformation() { + Object>* resetTransformation() { setTransformation({}); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -118,21 +113,21 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D { * Expects that the dual quaternion is normalized. * @see DualQuaternion::isNormalized() */ - Object>* transform(const Math::DualQuaternion& transformation, TransformationType type = TransformationType::Global) { + Object>* transform(const Math::DualQuaternion& transformation, TransformationType type = TransformationType::Global) { CORRADE_ASSERT(transformation.isNormalized(), "SceneGraph::DualQuaternionTransformation::transform(): the dual quaternion is not normalized", - static_cast>*>(this)); + static_cast>*>(this)); transformInternal(transformation, type); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling3D::translate() * Same as calling transform() with DualQuaternion::translation(). */ - Object>* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { + Object>* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { transformInternal(Math::DualQuaternion::translation(vector), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -146,27 +141,27 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D { * @see Vector3::xAxis(), Vector3::yAxis(), Vector3::zAxis(), * normalizeRotation() */ - Object>* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { + Object>* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { transformInternal(Math::DualQuaternion::rotation(angle, normalizedAxis), type); - return static_cast>*>(this); + return static_cast>*>(this); } /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - Object>* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { return rotate(angle, Math::Vector3::xAxis(), type); } - Object>* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { return rotate(angle, Math::Vector3::yAxis(), type); } - Object>* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { return rotate(angle, Math::Vector3::zAxis(), type); } #endif protected: /* Allow construction only from Object */ - explicit DualQuaternionTransformation(); + explicit BasicDualQuaternionTransformation(); private: void doResetTransformation() override final { resetTransformation(); } @@ -184,9 +179,9 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D { /* Setting transformation is forbidden for the scene */ /** @todo Assert for this? */ /** @todo Do this in some common code so we don't need to include Object? */ - if(!static_cast>*>(this)->isScene()) { + if(!static_cast>*>(this)->isScene()) { _transformation = transformation; - static_cast>*>(this)->setDirty(); + static_cast>*>(this)->setDirty(); } } @@ -199,7 +194,14 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D { Math::DualQuaternion _transformation; }; -template inline DualQuaternionTransformation::DualQuaternionTransformation() = default; +template inline BasicDualQuaternionTransformation::BasicDualQuaternionTransformation() = default; + +/** +@brief Three-dimensional transformation for float scenes implemented using dual quaternions + +@see @ref DualComplexTransformation +*/ +typedef BasicDualQuaternionTransformation DualQuaternionTransformation; }} diff --git a/src/SceneGraph/FeatureGroup.h b/src/SceneGraph/FeatureGroup.h index bad4ea67d..fc8059c29 100644 --- a/src/SceneGraph/FeatureGroup.h +++ b/src/SceneGraph/FeatureGroup.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::FeatureGroup, alias Magnum::SceneGraph::FeatureGroup2D, Magnum::SceneGraph::FeatureGroup3D + * @brief Class Magnum::SceneGraph::AbstractBasicFeatureGroup, Magnum::SceneGraph::BasicFeatureGroup, alias Magnum::SceneGraph::FeatureGroup2D, Magnum::SceneGraph::FeatureGroup3D */ #include @@ -39,48 +39,38 @@ namespace Magnum { namespace SceneGraph { /** @brief Base for group of features -See FeatureGroup. +See BasicFeatureGroup. */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MAGNUM_SCENEGRAPH_EXPORT AbstractFeatureGroup { - template friend class FeatureGroup; +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeatureGroup { + template friend class BasicFeatureGroup; - explicit AbstractFeatureGroup(); - virtual ~AbstractFeatureGroup(); + explicit AbstractBasicFeatureGroup(); + virtual ~AbstractBasicFeatureGroup(); - void add(AbstractFeature* feature); - void remove(AbstractFeature* feature); + void add(AbstractBasicFeature* feature); + void remove(AbstractBasicFeature* feature); - std::vector*> features; + std::vector*> features; }; /** @brief Group of features -See AbstractGroupedFeature for more information. -@see @ref scenegraph, FeatureGroup2D, FeatureGroup3D +See AbstractBasicGroupedFeature for more information. +@see @ref FeatureGroup2D, @ref FeatureGroup3D, @ref scenegraph */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class FeatureGroup: public AbstractFeatureGroup { - friend class AbstractGroupedFeature; +template class BasicFeatureGroup: public AbstractBasicFeatureGroup { + friend class AbstractBasicGroupedFeature; public: - explicit FeatureGroup(); + explicit BasicFeatureGroup(); /** * @brief Destructor * * Removes all features belonging to this group, but not deletes them. */ - ~FeatureGroup(); + ~BasicFeatureGroup(); /** @brief Whether the group is empty */ bool isEmpty() const { return this->features.empty(); } @@ -103,9 +93,9 @@ class FeatureGroup: public AbstractFeatureGroup { * @return Pointer to self (for method chaining) * * If the features is part of another group, it is removed from it. - * @see remove(), AbstractGroupedFeature::AbstractGroupedFeature() + * @see remove(), AbstractBasicGroupedFeature::AbstractBasicGroupedFeature() */ - FeatureGroup* add(Feature* feature); + BasicFeatureGroup* add(Feature* feature); /** * @brief Remove feature from the group @@ -114,66 +104,54 @@ class FeatureGroup: public AbstractFeatureGroup { * The feature must be part of the group. * @see add() */ - FeatureGroup* remove(Feature* feature); + BasicFeatureGroup* remove(Feature* feature); }; -template inline FeatureGroup::FeatureGroup() = default; +template inline BasicFeatureGroup::BasicFeatureGroup() = default; #ifndef CORRADE_GCC46_COMPATIBILITY /** -@brief Base for two-dimensional object features +@brief Base feature for two-dimensional float scenes -Convenience alternative to %FeatureGroup<2, Feature, T>. See -AbstractGroupedFeature for more information. -@note Not available on GCC < 4.7. Use %FeatureGroup<2, Feature, T> +Convenience alternative to %BasicFeatureGroup<2, Feature, Float>. +@note Not available on GCC < 4.7. Use %BasicFeatureGroup<2, Feature, Float> instead. -@see FeatureGroup3D +@see @ref FeatureGroup3D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using FeatureGroup2D = FeatureGroup<2, Feature, T>; +template using FeatureGroup2D = BasicFeatureGroup<2, Feature, Float>; /** -@brief Base for three-dimensional object features +@brief Base feature for three-dimensional float scenes -Convenience alternative to %FeatureGroup<3, Feature, T>. See -AbstractGroupedFeature for more information. -@note Not available on GCC < 4.7. Use %FeatureGroup<3, Feature, T> +Convenience alternative to %BasicFeatureGroup<3, Feature, Float>. +@note Not available on GCC < 4.7. Use %FeatureGroup<3, Feature, Float> instead. -@see FeatureGroup2D +@see @ref FeatureGroup2D */ -#ifdef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -using FeatureGroup3D = FeatureGroup<3, Feature, T>; +template using FeatureGroup3D = BasicFeatureGroup<3, Feature, Float>; #endif -template FeatureGroup::~FeatureGroup() { +template BasicFeatureGroup::~BasicFeatureGroup() { for(auto it = this->features.begin(); it != this->features.end(); ++it) static_cast(*it)->_group = nullptr; } -template FeatureGroup* FeatureGroup::add(Feature* feature) { +template BasicFeatureGroup* BasicFeatureGroup::add(Feature* feature) { /* Remove from previous group */ if(feature->_group) feature->_group->remove(feature); /* Crossreference the feature and group together */ - AbstractFeatureGroup::add(feature); + AbstractBasicFeatureGroup::add(feature); feature->_group = this; return this; } -template FeatureGroup* FeatureGroup::remove(Feature* feature) { +template BasicFeatureGroup* BasicFeatureGroup::remove(Feature* feature) { CORRADE_ASSERT(feature->_group == this, - "SceneGraph::AbstractFeatureGroup::remove(): feature is not part of this group", this); + "SceneGraph::AbstractBasicFeatureGroup::remove(): feature is not part of this group", this); - AbstractFeatureGroup::remove(feature); + AbstractBasicFeatureGroup::remove(feature); feature->_group = nullptr; return this; } diff --git a/src/SceneGraph/FeatureGroup.hpp b/src/SceneGraph/FeatureGroup.hpp index 24f7d8cf8..3b293396e 100644 --- a/src/SceneGraph/FeatureGroup.hpp +++ b/src/SceneGraph/FeatureGroup.hpp @@ -35,16 +35,16 @@ namespace Magnum { namespace SceneGraph { /* `= default` causes linker errors in GCC 4.5 */ -template AbstractFeatureGroup::AbstractFeatureGroup() {} +template AbstractBasicFeatureGroup::AbstractBasicFeatureGroup() {} /* `= default` causes linker errors in GCC 4.4 */ -template AbstractFeatureGroup::~AbstractFeatureGroup() {} +template AbstractBasicFeatureGroup::~AbstractBasicFeatureGroup() {} -template void AbstractFeatureGroup::add(AbstractFeature* feature) { +template void AbstractBasicFeatureGroup::add(AbstractBasicFeature* feature) { features.push_back(feature); } -template void AbstractFeatureGroup::remove(AbstractFeature* feature) { +template void AbstractBasicFeatureGroup::remove(AbstractBasicFeature* feature) { features.erase(std::find(features.begin(), features.end(), feature)); } diff --git a/src/SceneGraph/MatrixTransformation2D.h b/src/SceneGraph/MatrixTransformation2D.h index da52ad415..81d317b3b 100644 --- a/src/SceneGraph/MatrixTransformation2D.h +++ b/src/SceneGraph/MatrixTransformation2D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::MatrixTransformation2D + * @brief Class Magnum::SceneGraph::BasicMatrixTransformation2D, typedef Magnum::SceneGraph::MatrixTransformation2D */ #include "Math/Matrix3.h" @@ -38,14 +38,9 @@ namespace Magnum { namespace SceneGraph { @brief Two-dimensional transformation implemented using matrices Uses Math::Matrix3 as underlying type. -@see @ref scenegraph, RigidMatrixTransformation2D, MatrixTransformation3D +@see @ref MatrixTransformation2D, @ref scenegraph, @ref RigidBasicMatrixTransformation2D, @ref BasicMatrixTransformation3D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { +template class BasicMatrixTransformation2D: public AbstractBasicTranslationRotationScaling2D { public: /** @brief Underlying transformation type */ typedef Math::Matrix3 DataType; @@ -76,16 +71,16 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { * @brief Set transformation * @return Pointer to self (for method chaining) */ - Object>* setTransformation(const Math::Matrix3& transformation) { + Object>* setTransformation(const Math::Matrix3& transformation) { /* Setting transformation is forbidden for the scene */ /** @todo Assert for this? */ /** @todo Do this in some common code so we don't need to include Object? */ - if(!static_cast>*>(this)->isScene()) { + if(!static_cast>*>(this)->isScene()) { _transformation = transformation; - static_cast>*>(this)->setDirty(); + static_cast>*>(this)->setDirty(); } - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -94,43 +89,43 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { * @param type Transformation type * @return Pointer to self (for method chaining) */ - Object>* transform(const Math::Matrix3& transformation, TransformationType type = TransformationType::Global) { + Object>* transform(const Math::Matrix3& transformation, TransformationType type = TransformationType::Global) { setTransformation(type == TransformationType::Global ? transformation*_transformation : _transformation*transformation); - return static_cast>*>(this); + return static_cast>*>(this); } /** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */ - Object>* resetTransformation() { + Object>* resetTransformation() { setTransformation({}); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling2D::translate() * Same as calling transform() with Matrix3::translation(). */ - Object>* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { + Object>* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { transform(Math::Matrix3::translation(vector), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling2D::rotate() * Same as calling transform() with Matrix3::rotation(). */ - Object>* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { transform(Math::Matrix3::rotation(angle), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling2D::scale() * Same as calling transform() with Matrix3::scaling(). */ - Object>* scale(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { + Object>* scale(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { transform(Math::Matrix3::scaling(vector), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -142,9 +137,9 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { * * Same as calling transform() with Matrix3::reflection(). */ - Object>* reflect(const Math::Vector2& normal, TransformationType type = TransformationType::Global) { + Object>* reflect(const Math::Vector2& normal, TransformationType type = TransformationType::Global) { transform(Math::Matrix3::reflection(normal), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -153,14 +148,14 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { * if you want to move it above all. * @return Pointer to self (for method chaining) */ - Object>* move(Object>* under) { - static_cast*>(this)->Containers::template LinkedList>>::move(this, under); - return static_cast>*>(this); + Object>* move(Object>* under) { + static_cast*>(this)->Containers::template LinkedList>>::move(this, under); + return static_cast>*>(this); } protected: /* Allow construction only from Object */ - explicit MatrixTransformation2D(); + explicit BasicMatrixTransformation2D(); private: void doResetTransformation() override final { resetTransformation(); } @@ -180,7 +175,7 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { Math::Matrix3 _transformation; }; -template inline MatrixTransformation2D::MatrixTransformation2D() = default; +template inline BasicMatrixTransformation2D::BasicMatrixTransformation2D() = default; }} diff --git a/src/SceneGraph/MatrixTransformation3D.h b/src/SceneGraph/MatrixTransformation3D.h index c0fe352f9..8bf92d5e1 100644 --- a/src/SceneGraph/MatrixTransformation3D.h +++ b/src/SceneGraph/MatrixTransformation3D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::MatrixTransformation3D + * @brief Class Magnum::SceneGraph::BasicMatrixTransformation3D, typedef Magnum::SceneGraph::MatrixTransformation3D */ #include "Math/Matrix4.h" @@ -38,14 +38,9 @@ namespace Magnum { namespace SceneGraph { @brief Three-dimensional transformation implemented using matrices Uses Math::Matrix4 as underlying type. -@see @ref scenegraph, RigidMatrixTransformation3D, MatrixTransformation2D +@see @ref MatrixTransformation3D, @ref scenegraph, @ref BasicRigidMatrixTransformation3D, @ref BasicMatrixTransformation2D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { +template class BasicMatrixTransformation3D: public AbstractBasicTranslationRotationScaling3D { public: /** @brief Underlying transformation type */ typedef Math::Matrix4 DataType; @@ -76,22 +71,22 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { * @brief Set transformation * @return Pointer to self (for method chaining) */ - Object>* setTransformation(const Math::Matrix4& transformation) { + Object>* setTransformation(const Math::Matrix4& transformation) { /* Setting transformation is forbidden for the scene */ /** @todo Assert for this? */ /** @todo Do this in some common code so we don't need to include Object? */ - if(!static_cast>*>(this)->isScene()) { + if(!static_cast>*>(this)->isScene()) { _transformation = transformation; - static_cast>*>(this)->setDirty(); + static_cast>*>(this)->setDirty(); } - return static_cast>*>(this); + return static_cast>*>(this); } /** @copydoc AbstractTranslationRotationScaling3D::resetTransformation() */ - Object>* resetTransformation() { + Object>* resetTransformation() { setTransformation({}); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -100,28 +95,28 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { * @param type Transformation type * @return Pointer to self (for method chaining) */ - Object>* transform(const Math::Matrix4& transformation, TransformationType type = TransformationType::Global) { + Object>* transform(const Math::Matrix4& transformation, TransformationType type = TransformationType::Global) { setTransformation(type == TransformationType::Global ? transformation*_transformation : _transformation*transformation); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling3D::translate() * Same as calling transform() with Matrix4::translation(). */ - Object>* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { + Object>* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { transform(Math::Matrix4::translation(vector), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling3D::rotate() * Same as calling transform() with Matrix4::rotation(). */ - Object>* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { + Object>* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { transform(Math::Matrix4::rotation(angle, normalizedAxis), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -132,9 +127,9 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { * * Same as calling transform() with Matrix4::rotationX(). */ - Object>* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { transform(Math::Matrix4::rotationX(angle), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -145,9 +140,9 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { * * Same as calling transform() with Matrix4::rotationY(). */ - Object>* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { transform(Math::Matrix4::rotationY(angle), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -158,18 +153,18 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { * * Same as calling transform() with Matrix4::rotationZ(). */ - Object>* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { transform(Math::Matrix4::rotationZ(angle), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling3D::scale() * Same as calling transform() with Matrix4::scaling(). */ - Object>* scale(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { + Object>* scale(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { transform(Math::Matrix4::scaling(vector), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -181,14 +176,14 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { * * Same as calling transform() with Matrix4::reflection(). */ - Object>* reflect(const Math::Vector3& normal, TransformationType type = TransformationType::Global) { + Object>* reflect(const Math::Vector3& normal, TransformationType type = TransformationType::Global) { transform(Math::Matrix4::reflection(normal), type); - return static_cast>*>(this); + return static_cast>*>(this); } protected: /* Allow construction only from Object */ - explicit MatrixTransformation3D(); + explicit BasicMatrixTransformation3D(); private: void doResetTransformation() override final { resetTransformation(); } @@ -220,7 +215,14 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { Math::Matrix4 _transformation; }; -template inline MatrixTransformation3D::MatrixTransformation3D() = default; +template inline BasicMatrixTransformation3D::BasicMatrixTransformation3D() = default; + +/** +@brief Three-dimensional transformation for float scenes implemented using matrices + +@see @ref MatrixTransformation2D +*/ +typedef BasicMatrixTransformation3D MatrixTransformation3D; }} diff --git a/src/SceneGraph/Object.h b/src/SceneGraph/Object.h index eccadac90..51c6c0658 100644 --- a/src/SceneGraph/Object.h +++ b/src/SceneGraph/Object.h @@ -59,8 +59,8 @@ for introduction. Common usage is to typedef Object with desired transformation type to save unnecessary typing later, along with Scene and possibly other types, e.g.: @code -typedef SceneGraph::Scene> Scene3D; -typedef SceneGraph::Object> Object3D; +typedef SceneGraph::Scene Scene3D; +typedef SceneGraph::Object Object3D; @endcode Uses Corrade::Containers::LinkedList for parent/children relationship. @@ -88,7 +88,7 @@ See @ref compilation-speedup-hpp for more information. @see Scene, AbstractFeature, AbstractTransformation, DebugTools::ObjectRenderer */ -template class MAGNUM_SCENEGRAPH_EXPORT Object: public AbstractObject, public Transformation +template class MAGNUM_SCENEGRAPH_EXPORT Object: public AbstractBasicObject, public Transformation #ifndef DOXYGEN_GENERATING_OUTPUT , private Containers::LinkedList>, private Containers::LinkedListItem, Object> #endif @@ -305,14 +305,14 @@ template class MAGNUM_SCENEGRAPH_EXPORT Object: public Abs return absoluteTransformationMatrix(); } - std::vector doTransformationMatrices(const std::vector*>& objects, const MatrixType& initialTransformationMatrix) const override final; + std::vector doTransformationMatrices(const std::vector*>& objects, const MatrixType& initialTransformationMatrix) const override final; typename Transformation::DataType MAGNUM_SCENEGRAPH_LOCAL computeJointTransformation(const std::vector*>& jointObjects, std::vector& jointTransformations, const std::size_t joint, const typename Transformation::DataType& initialTransformation) const; bool MAGNUM_SCENEGRAPH_LOCAL doIsDirty() const override final { return isDirty(); } void MAGNUM_SCENEGRAPH_LOCAL doSetDirty() override final { setDirty(); } void MAGNUM_SCENEGRAPH_LOCAL doSetClean() override final { setClean(); } - void doSetClean(const std::vector*>& objects) override final; + void doSetClean(const std::vector*>& objects) override final; void MAGNUM_SCENEGRAPH_LOCAL setClean(const typename Transformation::DataType& absoluteTransformation); diff --git a/src/SceneGraph/Object.hpp b/src/SceneGraph/Object.hpp index 1ebb15e79..a84046eaf 100644 --- a/src/SceneGraph/Object.hpp +++ b/src/SceneGraph/Object.hpp @@ -38,11 +38,11 @@ namespace Magnum { namespace SceneGraph { -template AbstractObject::AbstractObject() {} -template AbstractObject::~AbstractObject() {} +template AbstractBasicObject::AbstractBasicObject() {} +template AbstractBasicObject::~AbstractBasicObject() {} -template AbstractTransformation::AbstractTransformation() {} -template AbstractTransformation::~AbstractTransformation() {} +template AbstractBasicTransformation::AbstractBasicTransformation() {} +template AbstractBasicTransformation::~AbstractBasicTransformation() {} /* `= default` causes linker errors in GCC 4.4 */ template Object::~Object() {} @@ -114,7 +114,7 @@ template void Object::setDirty() { Object* self = static_cast*>(this); /* Make all features dirty */ - for(AbstractFeature* i = self->firstFeature(); i; i = i->nextFeature()) + for(AbstractBasicFeature* i = self->firstFeature(); i; i = i->nextFeature()) i->markDirty(); /* Make all children dirty */ @@ -162,7 +162,7 @@ template void Object::setClean() { } } -template auto Object::doTransformationMatrices(const std::vector*>& objects, const MatrixType& initialTransformationMatrix) const -> std::vector { +template auto Object::doTransformationMatrices(const std::vector*>& objects, const MatrixType& initialTransformationMatrix) const -> std::vector { std::vector*> castObjects(objects.size()); for(std::size_t i = 0; i != objects.size(); ++i) /** @todo Ensure this doesn't crash, somehow */ @@ -324,7 +324,7 @@ template typename Transformation::DataType Object void Object::doSetClean(const std::vector*>& objects) { +template void Object::doSetClean(const std::vector*>& objects) { std::vector*> castObjects(objects.size()); for(std::size_t i = 0; i != objects.size(); ++i) /** @todo Ensure this doesn't crash, somehow */ @@ -379,7 +379,7 @@ template void Object::setClean(const typen MatrixType matrix, invertedMatrix; /* Clean all features */ - for(AbstractFeature* i = this->firstFeature(); i; i = i->nextFeature()) { + for(AbstractBasicFeature* i = this->firstFeature(); i; i = i->nextFeature()) { /* Cached absolute transformation, compute it if it wasn't computed already */ if(i->cachedTransformations() & CachedTransformation::Absolute) { diff --git a/src/SceneGraph/RigidMatrixTransformation2D.h b/src/SceneGraph/RigidMatrixTransformation2D.h index 6386df859..4df999783 100644 --- a/src/SceneGraph/RigidMatrixTransformation2D.h +++ b/src/SceneGraph/RigidMatrixTransformation2D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::RigidMatrixTransformation2D + * @brief Class Magnum::SceneGraph::BasicRigidMatrixTransformation2D, typedef Magnum::SceneGraph::RigidMatrixTransformation2D */ #include "Math/Matrix3.h" @@ -38,17 +38,13 @@ namespace Magnum { namespace SceneGraph { /** @brief Two-dimensional rigid transformation implemented using matrices -Unlike MatrixTransformation2D this class allows only rotation, reflection and -translation (no scaling or setting arbitrary transformations). This allows to -use Matrix3::invertedRigid() for faster computation of inverse transformations. -@see @ref scenegraph, RigidMatrixTransformation3D +Unlike BasicMatrixTransformation2D this class allows only rotation, reflection +and translation (no scaling or setting arbitrary transformations). This allows +to use Matrix3::invertedRigid() for faster computation of inverse +transformations. +@see @ref RigidMatrixTransformation2D, @ref scenegraph, @ref BasicRigidMatrixTransformation3D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class RigidMatrixTransformation2D: public AbstractTranslationRotation2D { +template class BasicRigidMatrixTransformation2D: public AbstractBasicTranslationRotation2D { public: /** @brief Underlying transformation type */ typedef Math::Matrix3 DataType; @@ -84,11 +80,11 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D { * Normalizes the rotation part using Math::Algorithms::gramSchmidt() * to prevent rounding errors when rotating the object subsequently. */ - Object>* normalizeRotation() { + Object>* normalizeRotation() { setTransformationInternal(Math::Matrix3::from( Math::Algorithms::gramSchmidtOrthonormalize(_transformation.rotationScaling()), _transformation.translation())); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -98,18 +94,18 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D { * Expects that the matrix represents rigid transformation. * @see Matrix3::isRigidTransformation() */ - Object>* setTransformation(const Math::Matrix3& transformation) { + Object>* setTransformation(const Math::Matrix3& transformation) { CORRADE_ASSERT(transformation.isRigidTransformation(), "SceneGraph::RigidMatrixTransformation2D::setTransformation(): the matrix doesn't represent rigid transformation", - static_cast>*>(this)); + static_cast>*>(this)); setTransformationInternal(transformation); - return static_cast>*>(this); + return static_cast>*>(this); } /** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */ - Object>* resetTransformation() { + Object>* resetTransformation() { setTransformationInternal({}); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -121,21 +117,21 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D { * Expects that the matrix represents rigid transformation. * @see Matrix3::isRigidTransformation() */ - Object>* transform(const Math::Matrix3& transformation, TransformationType type = TransformationType::Global) { + Object>* transform(const Math::Matrix3& transformation, TransformationType type = TransformationType::Global) { CORRADE_ASSERT(transformation.isRigidTransformation(), "SceneGraph::RigidMatrixTransformation2D::transform(): the matrix doesn't represent rigid transformation", - static_cast>*>(this)); + static_cast>*>(this)); transformInternal(transformation, type); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling2D::translate() * Same as calling transform() with Matrix3::translation(). */ - Object>* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { + Object>* translate(const Math::Vector2& vector, TransformationType type = TransformationType::Global) { transformInternal(Math::Matrix3::translation(vector), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -147,9 +143,9 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D { * Same as calling transform() with Matrix3::rotation(). * @see normalizeRotation() */ - Object>* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) { transformInternal(Math::Matrix3::rotation(angle), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -161,9 +157,9 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D { * * Same as calling transform() with Matrix3::reflection(). */ - Object>* reflect(const Math::Vector2& normal, TransformationType type = TransformationType::Global) { + Object>* reflect(const Math::Vector2& normal, TransformationType type = TransformationType::Global) { transformInternal(Math::Matrix3::reflection(normal), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -172,14 +168,14 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D { * if you want to move it above all. * @return Pointer to self (for method chaining) */ - Object>* move(Object>* under) { - static_cast*>(this)->Containers::template LinkedList>>::move(this, under); - return static_cast>*>(this); + Object>* move(Object>* under) { + static_cast*>(this)->Containers::template LinkedList>>::move(this, under); + return static_cast>*>(this); } protected: /* Allow construction only from Object */ - explicit RigidMatrixTransformation2D(); + explicit BasicRigidMatrixTransformation2D(); private: void doResetTransformation() override final { resetTransformation(); } @@ -197,9 +193,9 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D { /* Setting transformation is forbidden for the scene */ /** @todo Assert for this? */ /** @todo Do this in some common code so we don't need to include Object? */ - if(!static_cast>*>(this)->isScene()) { + if(!static_cast>*>(this)->isScene()) { _transformation = transformation; - static_cast>*>(this)->setDirty(); + static_cast>*>(this)->setDirty(); } } @@ -212,7 +208,7 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D { Math::Matrix3 _transformation; }; -template inline RigidMatrixTransformation2D::RigidMatrixTransformation2D() = default; +template inline BasicRigidMatrixTransformation2D::BasicRigidMatrixTransformation2D() = default; }} diff --git a/src/SceneGraph/RigidMatrixTransformation3D.h b/src/SceneGraph/RigidMatrixTransformation3D.h index b0c60572e..f2a9dd4c5 100644 --- a/src/SceneGraph/RigidMatrixTransformation3D.h +++ b/src/SceneGraph/RigidMatrixTransformation3D.h @@ -25,7 +25,7 @@ */ /** @file - * @brief Class Magnum::SceneGraph::RigidMatrixTransformation3D + * @brief Class Magnum::SceneGraph::BasicRigidMatrixTransformation3D, typedef Magnum::SceneGraph::RigidMatrixTransformation3D */ #include "Math/Matrix4.h" @@ -38,17 +38,13 @@ namespace Magnum { namespace SceneGraph { /** @brief Three-dimensional rigid transformation implemented using matrices -Unlike MatrixTransformation3D this class allows only rotation, reflection and -translation (no scaling or setting arbitrary transformations). This allows to -use Matrix4::invertedRigid() for faster computation of inverse transformations. -@see @ref scenegraph, RigidMatrixTransformation2D +Unlike BasicMatrixTransformation3D this class allows only rotation, reflection +and translation (no scaling or setting arbitrary transformations). This allows +to use Matrix4::invertedRigid() for faster computation of inverse +transformations. +@see @ref RigidMatrixTransformation3D, @ref scenegraph, @ref BasicRigidMatrixTransformation2D */ -#ifndef DOXYGEN_GENERATING_OUTPUT -template -#else -template -#endif -class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { +template class BasicRigidMatrixTransformation3D: public AbstractBasicTranslationRotation3D { public: /** @brief Underlying transformation type */ typedef Math::Matrix4 DataType; @@ -84,11 +80,11 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { * Normalizes the rotation part using Math::Algorithms::gramSchmidt() * to prevent rounding errors when rotating the object subsequently. */ - Object>* normalizeRotation() { + Object>* normalizeRotation() { setTransformation(Math::Matrix4::from( Math::Algorithms::gramSchmidtOrthonormalize(_transformation.rotationScaling()), _transformation.translation())); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -98,18 +94,18 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { * Expects that the matrix represents rigid transformation. * @see Matrix4::isRigidTransformation() */ - Object>* setTransformation(const Math::Matrix4& transformation) { + Object>* setTransformation(const Math::Matrix4& transformation) { CORRADE_ASSERT(transformation.isRigidTransformation(), "SceneGraph::RigidMatrixTransformation3D::setTransformation(): the matrix doesn't represent rigid transformation", - static_cast>*>(this)); + static_cast>*>(this)); setTransformationInternal(transformation); - return static_cast>*>(this); + return static_cast>*>(this); } /** @copydoc AbstractTranslationRotationScaling3D::resetTransformation() */ - Object>* resetTransformation() { + Object>* resetTransformation() { setTransformation({}); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -121,21 +117,21 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { * Expects that the matrix represents rigid transformation. * @see Matrix4::isRigidTransformation() */ - Object>* transform(const Math::Matrix4& transformation, TransformationType type = TransformationType::Global) { + Object>* transform(const Math::Matrix4& transformation, TransformationType type = TransformationType::Global) { CORRADE_ASSERT(transformation.isRigidTransformation(), "SceneGraph::RigidMatrixTransformation3D::transform(): the matrix doesn't represent rigid transformation", - static_cast>*>(this)); + static_cast>*>(this)); transformInternal(transformation, type); - return static_cast>*>(this); + return static_cast>*>(this); } /** * @copydoc AbstractTranslationRotationScaling3D::translate() * Same as calling transform() with Matrix4::translation(). */ - Object>* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { + Object>* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) { transformInternal(Math::Matrix4::translation(vector), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -149,9 +145,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { * @see rotateX(), rotateY(), rotateZ(), Vector3::xAxis(), * Vector3::yAxis(), Vector3::zAxis(), normalizeRotation() */ - Object>* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { + Object>* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) { transformInternal(Math::Matrix4::rotation(angle, normalizedAxis), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -163,9 +159,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { * Same as calling transform() with Matrix4::rotationX(). * @see normalizeRotation() */ - Object>* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { transformInternal(Math::Matrix4::rotationX(angle), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -177,9 +173,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { * Same as calling transform() with Matrix4::rotationY(). * @see normalizeRotation() */ - Object>* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { transformInternal(Math::Matrix4::rotationY(angle), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -191,9 +187,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { * Same as calling transform() with Matrix4::rotationZ(). * @see normalizeRotation() */ - Object>* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { + Object>* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { transformInternal(Math::Matrix4::rotationZ(angle), type); - return static_cast>*>(this); + return static_cast>*>(this); } /** @@ -205,14 +201,14 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { * * Same as calling transform() with Matrix4::reflection(). */ - Object>* reflect(const Math::Vector3& normal, TransformationType type = TransformationType::Global) { + Object>* reflect(const Math::Vector3& normal, TransformationType type = TransformationType::Global) { transformInternal(Math::Matrix4::reflection(normal), type); - return static_cast>*>(this); + return static_cast>*>(this); } protected: /* Allow construction only from Object */ - explicit RigidMatrixTransformation3D(); + explicit BasicRigidMatrixTransformation3D(); private: void doResetTransformation() override final { resetTransformation(); } @@ -242,9 +238,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { /* Setting transformation is forbidden for the scene */ /** @todo Assert for this? */ /** @todo Do this in some common code so we don't need to include Object? */ - if(!static_cast>*>(this)->isScene()) { + if(!static_cast>*>(this)->isScene()) { _transformation = transformation; - static_cast>*>(this)->setDirty(); + static_cast>*>(this)->setDirty(); } } @@ -257,7 +253,14 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D { Math::Matrix4 _transformation; }; -template inline RigidMatrixTransformation3D::RigidMatrixTransformation3D() = default; +template inline BasicRigidMatrixTransformation3D::BasicRigidMatrixTransformation3D() = default; + +/** +@brief Three-dimensional rigid transformation for float scenes implemented using matrices + +@see @ref RigidMatrixTransformation2D +*/ +typedef BasicRigidMatrixTransformation3D RigidMatrixTransformation3D; }} diff --git a/src/SceneGraph/SceneGraph.h b/src/SceneGraph/SceneGraph.h index 2298a9924..9364c84e1 100644 --- a/src/SceneGraph/SceneGraph.h +++ b/src/SceneGraph/SceneGraph.h @@ -40,102 +40,99 @@ namespace Magnum { namespace SceneGraph { enum class AspectRatioPolicy: UnsignedByte; #endif -template class AbstractCamera; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using AbstractCamera2D = AbstractCamera<2, T>; -template using AbstractCamera3D = AbstractCamera<3, T>; -#endif +template class AbstractBasicCamera; +typedef AbstractBasicCamera<2, Float> AbstractCamera2D; +typedef AbstractBasicCamera<3, Float> AbstractCamera3D; /* Enum CachedTransformation and CachedTransformations used only directly */ -template class AbstractFeature; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using AbstractFeature2D = AbstractFeature<2, T>; -template using AbstractFeature3D = AbstractFeature<3, T>; -#endif +template class AbstractBasicFeature; +typedef AbstractBasicFeature<2, Float> AbstractFeature2D; +typedef AbstractBasicFeature<3, Float> AbstractFeature3D; -template class AbstractFeatureGroup; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using AbstractFeatureGroup2D = AbstractFeatureGroup<2, T>; -template using AbstractFeatureGroup3D = AbstractFeatureGroup<3, T>; -#endif +template class AbstractBasicFeatureGroup; +typedef AbstractBasicFeatureGroup<2, Float> AbstractFeatureGroup2D; +typedef AbstractBasicFeatureGroup<3, Float> AbstractFeatureGroup3D; -template class AbstractGroupedFeature; +template class AbstractBasicGroupedFeature; #ifndef CORRADE_GCC46_COMPATIBILITY -template using AbstractGroupedFeature2D = AbstractGroupedFeature<2, Derived, T>; -template using AbstractGroupedFeature3D = AbstractGroupedFeature<3, Derived, T>; +template using AbstractGroupedFeature2D = AbstractBasicGroupedFeature<2, Derived, Float>; +template using AbstractGroupedFeature3D = AbstractBasicGroupedFeature<3, Derived, Float>; #endif -template class AbstractObject; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using AbstractObject2D = AbstractObject<2, T>; -template using AbstractObject3D = AbstractObject<3, T>; -#endif +template class AbstractBasicObject; +typedef AbstractBasicObject<2, Float> AbstractObject2D; +typedef AbstractBasicObject<3, Float> AbstractObject3D; #ifndef CORRADE_GCC45_COMPATIBILITY enum class TransformationType: UnsignedByte; #endif -template class AbstractTransformation; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using AbstractTransformation2D = AbstractTransformation<2, T>; -template using AbstractTransformation3D = AbstractTransformation<3, T>; -#endif +template class AbstractBasicTransformation; +typedef AbstractBasicTransformation<2, Float> AbstractTransformation2D; +typedef AbstractBasicTransformation<3, Float> AbstractTransformation3D; -template class AbstractTranslationRotation2D; -template class AbstractTranslationRotation3D; -template class AbstractTranslationRotationScaling2D; -template class AbstractTranslationRotationScaling3D; +template class AbstractBasicTranslationRotation2D; +template class AbstractBasicTranslationRotation3D; +typedef AbstractBasicTranslationRotation2D AbstractTranslationRotation2D; +typedef AbstractBasicTranslationRotation3D AbstractTranslationRotation3D; -template class Animable; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using Animable2D = Animable<2, T>; -template using Animable3D = Animable<3, T>; -#endif +template class AbstractBasicTranslationRotationScaling2D; +template class AbstractBasicTranslationRotationScaling3D; +typedef AbstractBasicTranslationRotationScaling2D AbstractTranslationRotationScaling2D; +typedef AbstractBasicTranslationRotationScaling3D AbstractTranslationRotationScaling3D; + +template class BasicAnimable; +typedef BasicAnimable<2, Float> Animable2D; +typedef BasicAnimable<3, Float> Animable3D; #ifndef CORRADE_GCC45_COMPATIBILITY enum class AnimationState: UnsignedByte; #endif -template class AnimableGroup; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using AnimableGroup2D = AnimableGroup<2, T>; -template using AnimableGroup3D = AnimableGroup<3, T>; -#endif +template class BasicAnimableGroup; +typedef BasicAnimableGroup<2, Float> AnimableGroup2D; +typedef BasicAnimableGroup<3, Float> AnimableGroup3D; -template class Camera2D; -template class Camera3D; +template class BasicCamera2D; +template class BasicCamera3D; +typedef BasicCamera2D Camera2D; +typedef BasicCamera3D Camera3D; -template class Drawable; -#ifndef CORRADE_GCC46_COMPATIBILITY -template using Drawable2D = Drawable<2, T>; -template using Drawable3D = Drawable<3, T>; -#endif +template class BasicDrawable; +typedef BasicDrawable<2, Float> Drawable2D; +typedef BasicDrawable<3, Float> Drawable3D; -template class DualComplexTransformation; -template class DualQuaternionTransformation; +template class BasicDualComplexTransformation; +template class BasicDualQuaternionTransformation; +typedef BasicDualComplexTransformation DualComplexTransformation; +typedef BasicDualQuaternionTransformation DualQuaternionTransformation; -template class FeatureGroup; +template class BasicFeatureGroup; #ifndef CORRADE_GCC46_COMPATIBILITY -template using FeatureGroup2D = FeatureGroup<2, Feature, T>; -template using FeatureGroup3D = FeatureGroup<3, Feature, T>; +template using BasicFeatureGroup2D = BasicFeatureGroup<2, Feature, Float>; +template using BasicFeatureGroup3D = BasicFeatureGroup<3, Feature, Float>; #endif #ifndef CORRADE_GCC46_COMPATIBILITY -template using DrawableGroup = FeatureGroup, T>; -template using DrawableGroup2D = DrawableGroup<2, T>; -template using DrawableGroup3D = DrawableGroup<3, T>; +template using BasicDrawableGroup = BasicFeatureGroup, T>; #else -template class DrawableGroup; +template class BasicDrawableGroup; #endif +typedef BasicDrawableGroup<2, Float> DrawableGroup2D; +typedef BasicDrawableGroup<3, Float> DrawableGroup3D; -template class MatrixTransformation2D; -template class MatrixTransformation3D; +template class BasicMatrixTransformation2D; +template class BasicMatrixTransformation3D; +typedef BasicMatrixTransformation2D MatrixTransformation2D; +typedef BasicMatrixTransformation3D MatrixTransformation3D; template class Object; -template class RigidMatrixTransformation2D; -template class RigidMatrixTransformation3D; +template class BasicRigidMatrixTransformation2D; +template class BasicRigidMatrixTransformation3D; +typedef BasicRigidMatrixTransformation2D RigidMatrixTransformation2D; +typedef BasicRigidMatrixTransformation3D RigidMatrixTransformation3D; template class Scene; #endif diff --git a/src/SceneGraph/Test/AnimableTest.cpp b/src/SceneGraph/Test/AnimableTest.cpp index 3f6e02adf..ed3726ec3 100644 --- a/src/SceneGraph/Test/AnimableTest.cpp +++ b/src/SceneGraph/Test/AnimableTest.cpp @@ -45,7 +45,7 @@ class AnimableTest: public TestSuite::Tester { void debug(); }; -typedef SceneGraph::Object> Object3D; +typedef SceneGraph::Object Object3D; AnimableTest::AnimableTest() { addTests({&AnimableTest::state, @@ -59,9 +59,9 @@ AnimableTest::AnimableTest() { } void AnimableTest::state() { - class StateTrackingAnimable: public SceneGraph::Animable<3> { + class StateTrackingAnimable: public SceneGraph::Animable3D { public: - StateTrackingAnimable(AbstractObject<3>* object, AnimableGroup<3>* group = nullptr): SceneGraph::Animable<3>(object, group) { + StateTrackingAnimable(AbstractObject3D* object, AnimableGroup3D* group = nullptr): SceneGraph::Animable3D(object, group) { setDuration(1.0f); } @@ -77,7 +77,7 @@ void AnimableTest::state() { }; Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; CORRADE_COMPARE(group.runningCount(), 0); /* Verify initial state */ @@ -149,9 +149,9 @@ void AnimableTest::state() { CORRADE_COMPARE(group.runningCount(), 2); } -class OneShotAnimable: public SceneGraph::Animable<3> { +class OneShotAnimable: public SceneGraph::Animable3D { public: - OneShotAnimable(AbstractObject<3>* object, AnimableGroup<3>* group = nullptr): SceneGraph::Animable<3>(object, group), time(-1.0f) { + OneShotAnimable(AbstractObject3D* object, AnimableGroup3D* group = nullptr): SceneGraph::Animable3D(object, group), time(-1.0f) { setDuration(10.0f); setState(AnimationState::Running); } @@ -174,9 +174,9 @@ class OneShotAnimable: public SceneGraph::Animable<3> { }; void AnimableTest::step() { - class InifiniteAnimable: public SceneGraph::Animable<3> { + class InifiniteAnimable: public SceneGraph::Animable3D { public: - InifiniteAnimable(AbstractObject<3>* object, AnimableGroup<3>* group = nullptr): SceneGraph::Animable<3>(object, group), time(-1.0f), delta(0.0f) {} + InifiniteAnimable(AbstractObject3D* object, AnimableGroup3D* group = nullptr): SceneGraph::Animable3D(object, group), time(-1.0f), delta(0.0f) {} Float time, delta; @@ -188,7 +188,7 @@ void AnimableTest::step() { }; Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; InifiniteAnimable animable(&object, &group); /* Calling step() if no object is running should do nothing */ @@ -213,7 +213,7 @@ void AnimableTest::step() { void AnimableTest::duration() { Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; OneShotAnimable animable(&object, &group); CORRADE_VERIFY(!animable.isRepeated()); @@ -233,9 +233,9 @@ void AnimableTest::duration() { } void AnimableTest::repeat() { - class RepeatingAnimable: public SceneGraph::Animable<3> { + class RepeatingAnimable: public SceneGraph::Animable3D { public: - RepeatingAnimable(AbstractObject<3>* object, AnimableGroup<3>* group = nullptr): SceneGraph::Animable<3>(object, group), time(-1.0f) { + RepeatingAnimable(AbstractObject3D* object, AnimableGroup3D* group = nullptr): SceneGraph::Animable3D(object, group), time(-1.0f) { setDuration(10.0f); setState(AnimationState::Running); setRepeated(true); @@ -250,7 +250,7 @@ void AnimableTest::repeat() { }; Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; RepeatingAnimable animable(&object, &group); CORRADE_COMPARE(animable.repeatCount(), 0); @@ -295,7 +295,7 @@ void AnimableTest::repeat() { void AnimableTest::stop() { Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; OneShotAnimable animable(&object, &group); CORRADE_COMPARE(animable.repeatCount(), 0); @@ -320,7 +320,7 @@ void AnimableTest::stop() { void AnimableTest::pause() { Object3D object; - AnimableGroup<3> group; + AnimableGroup3D group; OneShotAnimable animable(&object, &group); /* First two steps, animation is running */ diff --git a/src/SceneGraph/Test/CameraTest.cpp b/src/SceneGraph/Test/CameraTest.cpp index c31da6842..54402cdc2 100644 --- a/src/SceneGraph/Test/CameraTest.cpp +++ b/src/SceneGraph/Test/CameraTest.cpp @@ -48,11 +48,9 @@ class CameraTest: public TestSuite::Tester { void draw(); }; -typedef SceneGraph::Object> Object2D; -typedef SceneGraph::Object> Object3D; -typedef SceneGraph::Scene> Scene3D; -typedef SceneGraph::Camera2D<> Camera2D; -typedef SceneGraph::Camera3D<> Camera3D; +typedef SceneGraph::Object Object2D; +typedef SceneGraph::Object Object3D; +typedef SceneGraph::Scene Scene3D; CameraTest::CameraTest() { addTests({&CameraTest::fixAspectRatio, @@ -158,12 +156,12 @@ void CameraTest::projectionSizeViewport() { } void CameraTest::draw() { - class Drawable: public SceneGraph::Drawable<3> { + class Drawable: public SceneGraph::Drawable3D { public: - Drawable(AbstractObject<3>* object, DrawableGroup<3>* group, Matrix4& result): SceneGraph::Drawable<3>(object, group), result(result) {} + Drawable(AbstractObject3D* object, DrawableGroup3D* group, Matrix4& result): SceneGraph::Drawable3D(object, group), result(result) {} protected: - void draw(const Matrix4& transformationMatrix, AbstractCamera<3>*) { + void draw(const Matrix4& transformationMatrix, AbstractCamera3D*) { result = transformationMatrix; } @@ -171,7 +169,7 @@ void CameraTest::draw() { Matrix4& result; }; - DrawableGroup<3> group; + DrawableGroup3D group; Scene3D scene; Object3D first(&scene); diff --git a/src/SceneGraph/Test/DualComplexTransformationTest.cpp b/src/SceneGraph/Test/DualComplexTransformationTest.cpp index 853051f58..87d222df4 100644 --- a/src/SceneGraph/Test/DualComplexTransformationTest.cpp +++ b/src/SceneGraph/Test/DualComplexTransformationTest.cpp @@ -30,8 +30,8 @@ namespace Magnum { namespace SceneGraph { namespace Test { -typedef Object> Object2D; -typedef Scene> Scene2D; +typedef Object Object2D; +typedef Scene Scene2D; class DualComplexTransformationTest: public TestSuite::Tester { public: @@ -67,24 +67,24 @@ DualComplexTransformationTest::DualComplexTransformationTest() { void DualComplexTransformationTest::fromMatrix() { Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); DualComplex c = DualComplex::rotation(Deg(17.0f))*DualComplex::translation({1.0f, -0.3f}); - CORRADE_COMPARE(DualComplexTransformation<>::fromMatrix(m), c); + CORRADE_COMPARE(DualComplexTransformation::fromMatrix(m), c); } void DualComplexTransformationTest::toMatrix() { DualComplex c = DualComplex::rotation(Deg(17.0f))*DualComplex::translation({1.0f, -0.3f}); Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); - CORRADE_COMPARE(DualComplexTransformation<>::toMatrix(c), m); + CORRADE_COMPARE(DualComplexTransformation::toMatrix(c), m); } void DualComplexTransformationTest::compose() { DualComplex parent = DualComplex::rotation(Deg(17.0f)); DualComplex child = DualComplex::translation({1.0f, -0.3f}); - CORRADE_COMPARE(DualComplexTransformation<>::compose(parent, child), parent*child); + CORRADE_COMPARE(DualComplexTransformation::compose(parent, child), parent*child); } void DualComplexTransformationTest::inverted() { DualComplex c = DualComplex::rotation(Deg(17.0f))*DualComplex::translation({1.0f, -0.3f}); - CORRADE_COMPARE(DualComplexTransformation<>::inverted(c)*c, DualComplex()); + CORRADE_COMPARE(DualComplexTransformation::inverted(c)*c, DualComplex()); } void DualComplexTransformationTest::setTransformation() { diff --git a/src/SceneGraph/Test/DualQuaternionTransformationTest.cpp b/src/SceneGraph/Test/DualQuaternionTransformationTest.cpp index bfacea1a6..8433eebbb 100644 --- a/src/SceneGraph/Test/DualQuaternionTransformationTest.cpp +++ b/src/SceneGraph/Test/DualQuaternionTransformationTest.cpp @@ -30,8 +30,8 @@ namespace Magnum { namespace SceneGraph { namespace Test { -typedef Object> Object3D; -typedef Scene> Scene3D; +typedef Object Object3D; +typedef Scene Scene3D; class DualQuaternionTransformationTest: public TestSuite::Tester { public: @@ -67,24 +67,24 @@ DualQuaternionTransformationTest::DualQuaternionTransformationTest() { void DualQuaternionTransformationTest::fromMatrix() { Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); DualQuaternion q = DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis())*DualQuaternion::translation({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(DualQuaternionTransformation<>::fromMatrix(m), q); + CORRADE_COMPARE(DualQuaternionTransformation::fromMatrix(m), q); } void DualQuaternionTransformationTest::toMatrix() { DualQuaternion q = DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis())*DualQuaternion::translation({1.0f, -0.3f, 2.3f}); Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(DualQuaternionTransformation<>::toMatrix(q), m); + CORRADE_COMPARE(DualQuaternionTransformation::toMatrix(q), m); } void DualQuaternionTransformationTest::compose() { DualQuaternion parent = DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis()); DualQuaternion child = DualQuaternion::translation({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(DualQuaternionTransformation<>::compose(parent, child), parent*child); + CORRADE_COMPARE(DualQuaternionTransformation::compose(parent, child), parent*child); } void DualQuaternionTransformationTest::inverted() { DualQuaternion q = DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis())*DualQuaternion::translation({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(DualQuaternionTransformation<>::inverted(q)*q, DualQuaternion()); + CORRADE_COMPARE(DualQuaternionTransformation::inverted(q)*q, DualQuaternion()); } void DualQuaternionTransformationTest::setTransformation() { diff --git a/src/SceneGraph/Test/MatrixTransformation2DTest.cpp b/src/SceneGraph/Test/MatrixTransformation2DTest.cpp index f000e4742..d997a0f17 100644 --- a/src/SceneGraph/Test/MatrixTransformation2DTest.cpp +++ b/src/SceneGraph/Test/MatrixTransformation2DTest.cpp @@ -29,8 +29,8 @@ namespace Magnum { namespace SceneGraph { namespace Test { -typedef Object> Object2D; -typedef Scene> Scene2D; +typedef Object Object2D; +typedef Scene Scene2D; class MatrixTransformation2DTest: public TestSuite::Tester { public: @@ -67,23 +67,23 @@ MatrixTransformation2DTest::MatrixTransformation2DTest() { void MatrixTransformation2DTest::fromMatrix() { Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); - CORRADE_COMPARE(MatrixTransformation2D<>::fromMatrix(m), m); + CORRADE_COMPARE(MatrixTransformation2D::fromMatrix(m), m); } void MatrixTransformation2DTest::toMatrix() { Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); - CORRADE_COMPARE(MatrixTransformation2D<>::toMatrix(m), m); + CORRADE_COMPARE(MatrixTransformation2D::toMatrix(m), m); } void MatrixTransformation2DTest::compose() { Matrix3 parent = Matrix3::rotation(Deg(17.0f)); Matrix3 child = Matrix3::translation({1.0f, -0.3f}); - CORRADE_COMPARE(MatrixTransformation2D<>::compose(parent, child), parent*child); + CORRADE_COMPARE(MatrixTransformation2D::compose(parent, child), parent*child); } void MatrixTransformation2DTest::inverted() { Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); - CORRADE_COMPARE(MatrixTransformation2D<>::inverted(m)*m, Matrix3()); + CORRADE_COMPARE(MatrixTransformation2D::inverted(m)*m, Matrix3()); } void MatrixTransformation2DTest::setTransformation() { diff --git a/src/SceneGraph/Test/MatrixTransformation3DTest.cpp b/src/SceneGraph/Test/MatrixTransformation3DTest.cpp index 955775572..32a09dbfc 100644 --- a/src/SceneGraph/Test/MatrixTransformation3DTest.cpp +++ b/src/SceneGraph/Test/MatrixTransformation3DTest.cpp @@ -29,8 +29,8 @@ namespace Magnum { namespace SceneGraph { namespace Test { -typedef Object> Object3D; -typedef Scene> Scene3D; +typedef Object Object3D; +typedef Scene Scene3D; class MatrixTransformation3DTest: public TestSuite::Tester { public: @@ -67,23 +67,23 @@ MatrixTransformation3DTest::MatrixTransformation3DTest() { void MatrixTransformation3DTest::fromMatrix() { Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f}); - CORRADE_COMPARE(MatrixTransformation3D<>::fromMatrix(m), m); + CORRADE_COMPARE(MatrixTransformation3D::fromMatrix(m), m); } void MatrixTransformation3DTest::toMatrix() { Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f}); - CORRADE_COMPARE(MatrixTransformation3D<>::toMatrix(m), m); + CORRADE_COMPARE(MatrixTransformation3D::toMatrix(m), m); } void MatrixTransformation3DTest::compose() { Matrix4 parent = Matrix4::rotationX(Deg(17.0f)); Matrix4 child = Matrix4::translation({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(MatrixTransformation3D<>::compose(parent, child), parent*child); + CORRADE_COMPARE(MatrixTransformation3D::compose(parent, child), parent*child); } void MatrixTransformation3DTest::inverted() { Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f}); - CORRADE_COMPARE(MatrixTransformation3D<>::inverted(m)*m, Matrix4()); + CORRADE_COMPARE(MatrixTransformation3D::inverted(m)*m, Matrix4()); } void MatrixTransformation3DTest::setTransformation() { diff --git a/src/SceneGraph/Test/ObjectTest.cpp b/src/SceneGraph/Test/ObjectTest.cpp index 2ec5848ae..272b915d7 100644 --- a/src/SceneGraph/Test/ObjectTest.cpp +++ b/src/SceneGraph/Test/ObjectTest.cpp @@ -47,12 +47,12 @@ class ObjectTest: public TestSuite::Tester { void setCleanListBulk(); }; -typedef SceneGraph::Object> Object3D; -typedef SceneGraph::Scene> Scene3D; +typedef SceneGraph::Object Object3D; +typedef SceneGraph::Scene Scene3D; -class CachingObject: public Object3D, AbstractFeature<3> { +class CachingObject: public Object3D, AbstractFeature3D { public: - CachingObject(Object3D* parent = nullptr): Object3D(parent), AbstractFeature<3>(this) { + CachingObject(Object3D* parent = nullptr): Object3D(parent), AbstractFeature3D(this) { setCachedTransformations(CachedTransformation::Absolute); } @@ -269,9 +269,9 @@ void ObjectTest::transformationsDuplicate() { void ObjectTest::setClean() { Scene3D scene; - class CachingFeature: public AbstractFeature<3> { + class CachingFeature: public AbstractFeature3D { public: - CachingFeature(AbstractObject<3>* object): AbstractFeature<3>(object) { + CachingFeature(AbstractObject3D* object): AbstractFeature3D(object) { setCachedTransformations(CachedTransformation::Absolute); } @@ -282,9 +282,9 @@ void ObjectTest::setClean() { } }; - class CachingInvertedFeature: public AbstractFeature<3> { + class CachingInvertedFeature: public AbstractFeature3D { public: - CachingInvertedFeature(AbstractObject<3>* object): AbstractFeature<3>(object) { + CachingInvertedFeature(AbstractObject3D* object): AbstractFeature3D(object) { setCachedTransformations(CachedTransformation::InvertedAbsolute); } @@ -367,9 +367,9 @@ void ObjectTest::setClean() { void ObjectTest::setCleanListHierarchy() { Scene3D scene; - class CachingFeature: public AbstractFeature<3> { + class CachingFeature: public AbstractFeature3D { public: - CachingFeature(AbstractObject<3>* object): AbstractFeature<3>(object) { + CachingFeature(AbstractObject3D* object): AbstractFeature3D(object) { setCachedTransformations(CachedTransformation::Absolute); } diff --git a/src/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp b/src/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp index 31d3625c9..b362e97de 100644 --- a/src/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp +++ b/src/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp @@ -30,8 +30,8 @@ namespace Magnum { namespace SceneGraph { namespace Test { -typedef Object> Object2D; -typedef Scene> Scene2D; +typedef Object Object2D; +typedef Scene Scene2D; class RigidMatrixTransformation2DTest: public TestSuite::Tester { public: @@ -69,27 +69,27 @@ RigidMatrixTransformation2DTest::RigidMatrixTransformation2DTest() { void RigidMatrixTransformation2DTest::fromMatrix() { std::ostringstream o; Error::setOutput(&o); - RigidMatrixTransformation2D<>::fromMatrix(Matrix3::scaling(Vector2(4.0f))); + RigidMatrixTransformation2D::fromMatrix(Matrix3::scaling(Vector2(4.0f))); CORRADE_COMPARE(o.str(), "SceneGraph::RigidMatrixTransformation2D::fromMatrix(): the matrix doesn't represent rigid transformation\n"); Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); - CORRADE_COMPARE(RigidMatrixTransformation2D<>::fromMatrix(m), m); + CORRADE_COMPARE(RigidMatrixTransformation2D::fromMatrix(m), m); } void RigidMatrixTransformation2DTest::toMatrix() { Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); - CORRADE_COMPARE(RigidMatrixTransformation2D<>::toMatrix(m), m); + CORRADE_COMPARE(RigidMatrixTransformation2D::toMatrix(m), m); } void RigidMatrixTransformation2DTest::compose() { Matrix3 parent = Matrix3::rotation(Deg(17.0f)); Matrix3 child = Matrix3::translation({1.0f, -0.3f}); - CORRADE_COMPARE(RigidMatrixTransformation2D<>::compose(parent, child), parent*child); + CORRADE_COMPARE(RigidMatrixTransformation2D::compose(parent, child), parent*child); } void RigidMatrixTransformation2DTest::inverted() { Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); - CORRADE_COMPARE(RigidMatrixTransformation2D<>::inverted(m)*m, Matrix3()); + CORRADE_COMPARE(RigidMatrixTransformation2D::inverted(m)*m, Matrix3()); } void RigidMatrixTransformation2DTest::setTransformation() { diff --git a/src/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp b/src/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp index 7c9495a2d..ef56d9d69 100644 --- a/src/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp +++ b/src/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp @@ -30,8 +30,8 @@ namespace Magnum { namespace SceneGraph { namespace Test { -typedef Object> Object3D; -typedef Scene> Scene3D; +typedef Object Object3D; +typedef Scene Scene3D; class RigidMatrixTransformation3DTest: public TestSuite::Tester { public: @@ -69,27 +69,27 @@ RigidMatrixTransformation3DTest::RigidMatrixTransformation3DTest() { void RigidMatrixTransformation3DTest::fromMatrix() { std::ostringstream o; Error::setOutput(&o); - RigidMatrixTransformation3D<>::fromMatrix(Matrix4::scaling(Vector3(4.0f))); + RigidMatrixTransformation3D::fromMatrix(Matrix4::scaling(Vector3(4.0f))); CORRADE_COMPARE(o.str(), "SceneGraph::RigidMatrixTransformation3D::fromMatrix(): the matrix doesn't represent rigid transformation\n"); Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(RigidMatrixTransformation3D<>::fromMatrix(m), m); + CORRADE_COMPARE(RigidMatrixTransformation3D::fromMatrix(m), m); } void RigidMatrixTransformation3DTest::toMatrix() { Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(RigidMatrixTransformation3D<>::toMatrix(m), m); + CORRADE_COMPARE(RigidMatrixTransformation3D::toMatrix(m), m); } void RigidMatrixTransformation3DTest::compose() { Matrix4 parent = Matrix4::rotationX(Deg(17.0f)); Matrix4 child = Matrix4::translation({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(RigidMatrixTransformation3D<>::compose(parent, child), parent*child); + CORRADE_COMPARE(RigidMatrixTransformation3D::compose(parent, child), parent*child); } void RigidMatrixTransformation3DTest::inverted() { Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(RigidMatrixTransformation3D<>::inverted(m)*m, Matrix4()); + CORRADE_COMPARE(RigidMatrixTransformation3D::inverted(m)*m, Matrix4()); } void RigidMatrixTransformation3DTest::setTransformation() { diff --git a/src/SceneGraph/Test/SceneTest.cpp b/src/SceneGraph/Test/SceneTest.cpp index a2a725504..65f8dcb60 100644 --- a/src/SceneGraph/Test/SceneTest.cpp +++ b/src/SceneGraph/Test/SceneTest.cpp @@ -37,8 +37,8 @@ class SceneTest: public TestSuite::Tester { void parent(); }; -typedef SceneGraph::Scene> Scene3D; -typedef SceneGraph::Object> Object3D; +typedef SceneGraph::Scene Scene3D; +typedef SceneGraph::Object Object3D; SceneTest::SceneTest() { addTests({&SceneTest::transformation, diff --git a/src/SceneGraph/instantiation.cpp b/src/SceneGraph/instantiation.cpp index b3db08d88..ce04fb137 100644 --- a/src/SceneGraph/instantiation.cpp +++ b/src/SceneGraph/instantiation.cpp @@ -37,27 +37,27 @@ namespace Magnum { namespace SceneGraph { #ifndef DOXYGEN_GENERATING_OUTPUT -template class AbstractObject<2, Float>; -template class AbstractObject<3, Float>; -template class AbstractTransformation<2, Float>; -template class AbstractTransformation<3, Float>; - -template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeature<2, Float>; -template class MAGNUM_SCENEGRAPH_EXPORT AbstractFeature<3, Float>; -template class AbstractFeatureGroup<2, Float>; -template class AbstractFeatureGroup<3, Float>; - -template class AbstractCamera<2, Float>; -template class AbstractCamera<3, Float>; -template class Camera2D; -template class Camera3D; - -template class MAGNUM_SCENEGRAPH_EXPORT Object>; -template class MAGNUM_SCENEGRAPH_EXPORT Object>; -template class MAGNUM_SCENEGRAPH_EXPORT Object>; -template class MAGNUM_SCENEGRAPH_EXPORT Object>; -template class MAGNUM_SCENEGRAPH_EXPORT Object>; -template class MAGNUM_SCENEGRAPH_EXPORT Object>; +template class AbstractBasicObject<2, Float>; +template class AbstractBasicObject<3, Float>; +template class AbstractBasicTransformation<2, Float>; +template class AbstractBasicTransformation<3, Float>; + +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<2, Float>; +template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<3, Float>; +template class AbstractBasicFeatureGroup<2, Float>; +template class AbstractBasicFeatureGroup<3, Float>; + +template class AbstractBasicCamera<2, Float>; +template class AbstractBasicCamera<3, Float>; +template class BasicCamera2D; +template class BasicCamera3D; + +template class MAGNUM_SCENEGRAPH_EXPORT Object>; +template class MAGNUM_SCENEGRAPH_EXPORT Object>; +template class MAGNUM_SCENEGRAPH_EXPORT Object>; +template class MAGNUM_SCENEGRAPH_EXPORT Object>; +template class MAGNUM_SCENEGRAPH_EXPORT Object>; +template class MAGNUM_SCENEGRAPH_EXPORT Object>; #endif }} diff --git a/src/Shaders/DistanceFieldVector.h b/src/Shaders/DistanceFieldVector.h index ab6455e57..50ad57051 100644 --- a/src/Shaders/DistanceFieldVector.h +++ b/src/Shaders/DistanceFieldVector.h @@ -63,7 +63,7 @@ template class MAGNUM_SHADERS_EXPORT DistanceFieldVector * * @see setOutlineColor() */ - DistanceFieldVector* setColor(const Color4<>& color) { + DistanceFieldVector* setColor(const Color4& color) { AbstractShaderProgram::setUniform(colorUniform, color); return this; } @@ -74,7 +74,7 @@ template class MAGNUM_SHADERS_EXPORT DistanceFieldVector * * @see setOutlineRange(), setColor() */ - DistanceFieldVector* setOutlineColor(const Color4<>& color) { + DistanceFieldVector* setOutlineColor(const Color4& color) { AbstractShaderProgram::setUniform(outlineColorUniform, color); return this; } diff --git a/src/Shaders/Flat.h b/src/Shaders/Flat.h index be01877fd..69e9cccf0 100644 --- a/src/Shaders/Flat.h +++ b/src/Shaders/Flat.h @@ -64,7 +64,7 @@ template class MAGNUM_SHADERS_EXPORT Flat: public Abstra * @brief Set color * @return Pointer to self (for method chaining) */ - Flat* setColor(const Color4<>& color) { + Flat* setColor(const Color4& color) { setUniform(colorUniform, color); return this; } diff --git a/src/Shaders/MeshVisualizer.cpp b/src/Shaders/MeshVisualizer.cpp index 7a5393e4a..0ad479de6 100644 --- a/src/Shaders/MeshVisualizer.cpp +++ b/src/Shaders/MeshVisualizer.cpp @@ -115,9 +115,9 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ #ifdef MAGNUM_TARGET_GLES - setColor(Color3<>(1.0f)); + setColor(Color3(1.0f)); if(flags & Flag::Wireframe) { - setWireframeColor(Color3<>(0.0f)); + setWireframeColor(Color3(0.0f)); setWireframeWidth(1.0f); setSmoothness(2.0f); } diff --git a/src/Shaders/MeshVisualizer.h b/src/Shaders/MeshVisualizer.h index cb75305d2..e48aaefbd 100644 --- a/src/Shaders/MeshVisualizer.h +++ b/src/Shaders/MeshVisualizer.h @@ -138,7 +138,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram { * * Initial value is fully opaque white. */ - MeshVisualizer* setColor(const Color4<>& color) { + MeshVisualizer* setColor(const Color4& color) { setUniform(colorUniform, color); return this; } @@ -150,7 +150,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram { * Initial value is fully opaque black. Has effect only if * @ref Flag "Flag::Wireframe" is enabled. */ - MeshVisualizer* setWireframeColor(const Color4<>& color) { + MeshVisualizer* setWireframeColor(const Color4& color) { if(flags & Flag::Wireframe) setUniform(wireframeColorUniform, color); return this; } diff --git a/src/Shaders/Phong.h b/src/Shaders/Phong.h index 7bce3636b..f153dc761 100644 --- a/src/Shaders/Phong.h +++ b/src/Shaders/Phong.h @@ -55,7 +55,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * * If not set, default value is `(0.0f, 0.0f, 0.0f)`. */ - Phong* setAmbientColor(const Color3<>& color) { + Phong* setAmbientColor(const Color3& color) { setUniform(ambientColorUniform, color); return this; } @@ -64,7 +64,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * @brief Set diffuse color * @return Pointer to self (for method chaining) */ - Phong* setDiffuseColor(const Color3<>& color) { + Phong* setDiffuseColor(const Color3& color) { setUniform(diffuseColorUniform, color); return this; } @@ -75,7 +75,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * * If not set, default value is `(1.0f, 1.0f, 1.0f)`. */ - Phong* setSpecularColor(const Color3<>& color) { + Phong* setSpecularColor(const Color3& color) { setUniform(specularColorUniform, color); return this; } @@ -126,7 +126,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * * If not set, default value is `(1.0f, 1.0f, 1.0f)`. */ - Phong* setLightColor(const Color3<>& color) { + Phong* setLightColor(const Color3& color) { setUniform(lightColorUniform, color); return this; } diff --git a/src/Shaders/Vector.h b/src/Shaders/Vector.h index 9c86a0f3e..f4d7e61c2 100644 --- a/src/Shaders/Vector.h +++ b/src/Shaders/Vector.h @@ -60,7 +60,7 @@ template class MAGNUM_SHADERS_EXPORT Vector: public Abst * @brief Set fill color * @return Pointer to self (for method chaining) */ - Vector* setColor(const Color4<>& color) { + Vector* setColor(const Color4& color) { AbstractShaderProgram::setUniform(colorUniform, color); return this; } diff --git a/src/Shaders/VertexColor.h b/src/Shaders/VertexColor.h index e47630e46..d50eea060 100644 --- a/src/Shaders/VertexColor.h +++ b/src/Shaders/VertexColor.h @@ -50,7 +50,7 @@ template class MAGNUM_SHADERS_EXPORT VertexColor: public typedef Attribute<0, typename DimensionTraits::VectorType> Position; /** @brief Vertex color */ - typedef Attribute<1, Color3<>> Color; + typedef Attribute<1, Color3> Color; explicit VertexColor(); diff --git a/src/Shapes/AbstractShape.cpp b/src/Shapes/AbstractShape.cpp index 4ee79d443..baff8f03f 100644 --- a/src/Shapes/AbstractShape.cpp +++ b/src/Shapes/AbstractShape.cpp @@ -31,16 +31,16 @@ namespace Magnum { namespace Shapes { -template AbstractShape::AbstractShape(SceneGraph::AbstractObject* object, ShapeGroup* group): SceneGraph::AbstractGroupedFeature>(object, group) { +template AbstractShape::AbstractShape(SceneGraph::AbstractBasicObject* object, ShapeGroup* group): SceneGraph::AbstractBasicGroupedFeature, Float>(object, group) { this->setCachedTransformations(SceneGraph::CachedTransformation::Absolute); } template ShapeGroup* AbstractShape::group() { - return static_cast*>(SceneGraph::AbstractGroupedFeature>::group()); + return static_cast*>(SceneGraph::AbstractBasicGroupedFeature, Float>::group()); } template const ShapeGroup* AbstractShape::group() const { - return static_cast*>(SceneGraph::AbstractGroupedFeature>::group()); + return static_cast*>(SceneGraph::AbstractBasicGroupedFeature, Float>::group()); } template auto AbstractShape::type() const -> Type { diff --git a/src/Shapes/AbstractShape.h b/src/Shapes/AbstractShape.h index c742b969e..b980d9f60 100644 --- a/src/Shapes/AbstractShape.h +++ b/src/Shapes/AbstractShape.h @@ -49,7 +49,7 @@ This class is not directly instantiable, see Shape instead. See @ref shapes for brief introduction. @see AbstractShape2D, AbstractShape3D */ -template class MAGNUM_SHAPES_EXPORT AbstractShape: public SceneGraph::AbstractGroupedFeature> { +template class MAGNUM_SHAPES_EXPORT AbstractShape: public SceneGraph::AbstractBasicGroupedFeature, Float> { friend const Implementation::AbstractShape* Implementation::getAbstractShape<>(const AbstractShape*); public: @@ -79,7 +79,7 @@ template class MAGNUM_SHAPES_EXPORT AbstractShape: publi * @param object Object holding this feature * @param group Group this shape belongs to */ - explicit AbstractShape(SceneGraph::AbstractObject* object, ShapeGroup* group = nullptr); + explicit AbstractShape(SceneGraph::AbstractBasicObject* object, ShapeGroup* group = nullptr); /** * @brief Shape group containing this shape diff --git a/src/Shapes/Shape.h b/src/Shapes/Shape.h index 37f478d05..c2073baff 100644 --- a/src/Shapes/Shape.h +++ b/src/Shapes/Shape.h @@ -75,17 +75,17 @@ template class MAGNUM_SHAPES_EXPORT Shape: public AbstractShape explicit Shape(SceneGraph::AbstractObject* object, const T& shape, ShapeGroup* group = nullptr): AbstractShape(object, group) { + template explicit Shape(SceneGraph::AbstractBasicObject* object, const T& shape, ShapeGroup* group = nullptr): AbstractShape(object, group) { Implementation::ShapeHelper::set(*this, shape); } /** @overload */ - template explicit Shape(SceneGraph::AbstractObject* object, T&& shape, ShapeGroup* group = nullptr): AbstractShape(object, group) { + template explicit Shape(SceneGraph::AbstractBasicObject* object, T&& shape, ShapeGroup* group = nullptr): AbstractShape(object, group) { Implementation::ShapeHelper::set(*this, std::move(shape)); } /** @overload */ - template explicit Shape(SceneGraph::AbstractObject* object, ShapeGroup* group = nullptr): AbstractShape(object, group) {} + template explicit Shape(SceneGraph::AbstractBasicObject* object, ShapeGroup* group = nullptr): AbstractShape(object, group) {} /** @brief Shape */ const T& shape() const { return _shape.shape; } diff --git a/src/Shapes/ShapeGroup.cpp b/src/Shapes/ShapeGroup.cpp index d99b9d598..226e7d15d 100644 --- a/src/Shapes/ShapeGroup.cpp +++ b/src/Shapes/ShapeGroup.cpp @@ -31,11 +31,11 @@ namespace Magnum { namespace Shapes { template void ShapeGroup::setClean() { /* Clean all objects */ if(!this->isEmpty()) { - std::vector*> objects(this->size()); + std::vector*> objects(this->size()); for(std::size_t i = 0; i != this->size(); ++i) objects[i] = (*this)[i]->object(); - SceneGraph::AbstractObject::setClean(objects); + SceneGraph::AbstractBasicObject::setClean(objects); } dirty = false; diff --git a/src/Shapes/ShapeGroup.h b/src/Shapes/ShapeGroup.h index b3564f372..6b4a3a8be 100644 --- a/src/Shapes/ShapeGroup.h +++ b/src/Shapes/ShapeGroup.h @@ -43,7 +43,7 @@ namespace Magnum { namespace Shapes { See Shape for more information. See @ref shapes for brief introduction. @see @ref scenegraph, ShapeGroup2D, ShapeGroup3D */ -template class MAGNUM_SHAPES_EXPORT ShapeGroup: public SceneGraph::FeatureGroup> { +template class MAGNUM_SHAPES_EXPORT ShapeGroup: public SceneGraph::BasicFeatureGroup, Float> { friend class AbstractShape; public: diff --git a/src/Shapes/Test/ShapeTest.cpp b/src/Shapes/Test/ShapeTest.cpp index 3515a2739..7c8e2d8b0 100644 --- a/src/Shapes/Test/ShapeTest.cpp +++ b/src/Shapes/Test/ShapeTest.cpp @@ -44,10 +44,10 @@ class ShapeTest: public TestSuite::Tester { void shapeGroup(); }; -typedef SceneGraph::Scene> Scene2D; -typedef SceneGraph::Object> Object2D; -typedef SceneGraph::Scene> Scene3D; -typedef SceneGraph::Object> Object3D; +typedef SceneGraph::Scene Scene2D; +typedef SceneGraph::Object Object2D; +typedef SceneGraph::Scene Scene3D; +typedef SceneGraph::Object Object3D; ShapeTest::ShapeTest() { addTests({&ShapeTest::clean, diff --git a/src/Swizzle.h b/src/Swizzle.h index 07216c3b1..2072f7223 100644 --- a/src/Swizzle.h +++ b/src/Swizzle.h @@ -47,10 +47,10 @@ namespace Implementation { template struct TypeForSize<2, T> { typedef Math::Vector2 Type; }; template struct TypeForSize<3, T> { typedef Math::Vector3 Type; }; template struct TypeForSize<4, T> { typedef Math::Vector4 Type; }; - template struct TypeForSize<3, Color3> { typedef Color3 Type; }; - template struct TypeForSize<3, Color4> { typedef Color3 Type; }; - template struct TypeForSize<4, Color3> { typedef Color4 Type; }; - template struct TypeForSize<4, Color4> { typedef Color4 Type; }; + template struct TypeForSize<3, BasicColor3> { typedef BasicColor3 Type; }; + template struct TypeForSize<3, BasicColor4> { typedef BasicColor3 Type; }; + template struct TypeForSize<4, BasicColor3> { typedef BasicColor4 Type; }; + template struct TypeForSize<4, BasicColor4> { typedef BasicColor4 Type; }; } /** diff --git a/src/Test/ColorTest.cpp b/src/Test/ColorTest.cpp index 52b815f65..93da6047c 100644 --- a/src/Test/ColorTest.cpp +++ b/src/Test/ColorTest.cpp @@ -52,10 +52,8 @@ class ColorTest: public TestSuite::Tester { void configuration(); }; -typedef Magnum::Color3 Color3; -typedef Magnum::Color4 Color4; -typedef Magnum::Color3 Color3f; -typedef Magnum::Color4 Color4f; +typedef Magnum::BasicColor3 Color3ub; +typedef Magnum::BasicColor4 Color4ub; ColorTest::ColorTest() { addTests({&ColorTest::access, @@ -77,8 +75,8 @@ ColorTest::ColorTest() { } void ColorTest::access() { - Color3f c3(15, 255, 10); - const Color3f cc3(15, 255, 10); + Color3ub c3(15, 255, 10); + const Color3ub cc3(15, 255, 10); CORRADE_COMPARE(c3.r(), 15); CORRADE_COMPARE(c3.g(), 255); @@ -87,8 +85,8 @@ void ColorTest::access() { CORRADE_COMPARE(cc3.g(), 255); CORRADE_COMPARE(cc3.b(), 10); - Color4 c4(125, 98, 51, 22); - const Color4f cc4(125, 98, 51, 22); + Color4ub c4(125, 98, 51, 22); + const Color4ub cc4(125, 98, 51, 22); CORRADE_COMPARE(c4.r(), 125); CORRADE_COMPARE(c4.g(), 98); @@ -101,98 +99,98 @@ void ColorTest::access() { } void ColorTest::fromHue() { - CORRADE_COMPARE(Color3::fromHSV(Deg(27.0f), 1.0f, 1.0f), Color3(255, 114, 0)); - CORRADE_COMPARE(Color3::fromHSV(Deg(86.0f), 1.0f, 1.0f), Color3(144, 255, 0)); - CORRADE_COMPARE(Color3::fromHSV(Deg(134.0f), 1.0f, 1.0f), Color3(0, 255, 59)); - CORRADE_COMPARE(Color3::fromHSV(Deg(191.0f), 1.0f, 1.0f), Color3(0, 208, 255)); - CORRADE_COMPARE(Color3::fromHSV(Deg(269.0f), 1.0f, 1.0f), Color3(123, 0, 255)); - CORRADE_COMPARE(Color3::fromHSV(Deg(317.0f), 1.0f, 1.0f), Color3(255, 0, 182)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(27.0f), 1.0f, 1.0f), Color3ub(255, 114, 0)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(86.0f), 1.0f, 1.0f), Color3ub(144, 255, 0)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(134.0f), 1.0f, 1.0f), Color3ub(0, 255, 59)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(191.0f), 1.0f, 1.0f), Color3ub(0, 208, 255)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(269.0f), 1.0f, 1.0f), Color3ub(123, 0, 255)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(317.0f), 1.0f, 1.0f), Color3ub(255, 0, 182)); } void ColorTest::hue() { - CORRADE_COMPARE(Color3(255, 115, 0).hue(), Deg(27.058824f)); - CORRADE_COMPARE(Color3(145, 255, 0).hue(), Deg(85.882353f)); - CORRADE_COMPARE(Color3(0, 255, 60).hue(), Deg(134.11765f)); - CORRADE_COMPARE(Color3(0, 208, 255).hue(), Deg(191.05882f)); - CORRADE_COMPARE(Color3(123, 0, 255).hue(), Deg(268.94117f)); - CORRADE_COMPARE(Color3(255, 0, 183).hue(), Deg(316.94117f)); + CORRADE_COMPARE(Color3ub(255, 115, 0).hue(), Deg(27.058824f)); + CORRADE_COMPARE(Color3ub(145, 255, 0).hue(), Deg(85.882353f)); + CORRADE_COMPARE(Color3ub(0, 255, 60).hue(), Deg(134.11765f)); + CORRADE_COMPARE(Color3ub(0, 208, 255).hue(), Deg(191.05882f)); + CORRADE_COMPARE(Color3ub(123, 0, 255).hue(), Deg(268.94117f)); + CORRADE_COMPARE(Color3ub(255, 0, 183).hue(), Deg(316.94117f)); } void ColorTest::fromSaturation() { - CORRADE_COMPARE(Color3::fromHSV(Deg(0.0f), 0.702f, 1.0f), Color3(255, 75, 75)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(0.0f), 0.702f, 1.0f), Color3ub(255, 75, 75)); } void ColorTest::saturation() { - CORRADE_COMPARE(Color3(255, 76, 76).saturation(), 0.701961f); - CORRADE_COMPARE(Color3().saturation(), 0.0f); + CORRADE_COMPARE(Color3ub(255, 76, 76).saturation(), 0.701961f); + CORRADE_COMPARE(Color3ub().saturation(), 0.0f); } void ColorTest::fromValue() { - CORRADE_COMPARE(Color3::fromHSV(Deg(0.0f), 1.0f, 0.522f), Color3(133, 0, 0)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(0.0f), 1.0f, 0.522f), Color3ub(133, 0, 0)); } void ColorTest::value() { - CORRADE_COMPARE(Color3(133, 0, 0).value(), 0.521569f); + CORRADE_COMPARE(Color3ub(133, 0, 0).value(), 0.521569f); } void ColorTest::hsv() { - CORRADE_COMPARE(Color3::fromHSV(Deg(230.0f), 0.749f, 0.427f), Color3(27, 40, 108)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(230.0f), 0.749f, 0.427f), Color3ub(27, 40, 108)); Deg hue; Float saturation, value; - std::tie(hue, saturation, value) = Color3(27, 41, 109).toHSV(); + std::tie(hue, saturation, value) = Color3ub(27, 41, 109).toHSV(); CORRADE_COMPARE(hue, Deg(229.756106f)); CORRADE_COMPARE(saturation, 0.752294f); CORRADE_COMPARE(value, 0.427451f); } void ColorTest::hsvOverflow() { - CORRADE_COMPARE(Color3::fromHSV(Deg(27.0f-360.0f), 1.0f, 1.0f), Color3(255, 114, 0)); - CORRADE_COMPARE(Color3::fromHSV(Deg(86.0f-360.0f), 1.0f, 1.0f), Color3(144, 255, 0)); - CORRADE_COMPARE(Color3::fromHSV(Deg(134.0f-360.0f), 1.0f, 1.0f), Color3(0, 255, 59)); - CORRADE_COMPARE(Color3::fromHSV(Deg(191.0f-360.0f), 1.0f, 1.0f), Color3(0, 208, 255)); - CORRADE_COMPARE(Color3::fromHSV(Deg(269.0f-360.0f), 1.0f, 1.0f), Color3(123, 0, 255)); - CORRADE_COMPARE(Color3::fromHSV(Deg(317.0f-360.0f), 1.0f, 1.0f), Color3(255, 0, 182)); - - CORRADE_COMPARE(Color3::fromHSV(Deg(360.0f+27.0f), 1.0f, 1.0f), Color3(255, 114, 0)); - CORRADE_COMPARE(Color3::fromHSV(Deg(360.0f+86.0f), 1.0f, 1.0f), Color3(144, 255, 0)); - CORRADE_COMPARE(Color3::fromHSV(Deg(360.0f+134.0f), 1.0f, 1.0f), Color3(0, 255, 59)); - CORRADE_COMPARE(Color3::fromHSV(Deg(360.0f+191.0f), 1.0f, 1.0f), Color3(0, 208, 255)); - CORRADE_COMPARE(Color3::fromHSV(Deg(360.0f+269.0f), 1.0f, 1.0f), Color3(123, 0, 255)); - CORRADE_COMPARE(Color3::fromHSV(Deg(360.0f+317.0f), 1.0f, 1.0f), Color3(255, 0, 182)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(27.0f-360.0f), 1.0f, 1.0f), Color3ub(255, 114, 0)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(86.0f-360.0f), 1.0f, 1.0f), Color3ub(144, 255, 0)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(134.0f-360.0f), 1.0f, 1.0f), Color3ub(0, 255, 59)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(191.0f-360.0f), 1.0f, 1.0f), Color3ub(0, 208, 255)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(269.0f-360.0f), 1.0f, 1.0f), Color3ub(123, 0, 255)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(317.0f-360.0f), 1.0f, 1.0f), Color3ub(255, 0, 182)); + + CORRADE_COMPARE(Color3ub::fromHSV(Deg(360.0f+27.0f), 1.0f, 1.0f), Color3ub(255, 114, 0)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(360.0f+86.0f), 1.0f, 1.0f), Color3ub(144, 255, 0)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(360.0f+134.0f), 1.0f, 1.0f), Color3ub(0, 255, 59)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(360.0f+191.0f), 1.0f, 1.0f), Color3ub(0, 208, 255)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(360.0f+269.0f), 1.0f, 1.0f), Color3ub(123, 0, 255)); + CORRADE_COMPARE(Color3ub::fromHSV(Deg(360.0f+317.0f), 1.0f, 1.0f), Color3ub(255, 0, 182)); } void ColorTest::hsvAlpha() { - CORRADE_COMPARE(Color4::fromHSV(std::make_tuple(Deg(230.0f), 0.749f, 0.427f), 23), Color4(27, 40, 108, 23)); - CORRADE_COMPARE(Color4::fromHSV(Deg(230.0f), 0.749f, 0.427f, 23), Color4(27, 40, 108, 23)); + CORRADE_COMPARE(Color4ub::fromHSV(std::make_tuple(Deg(230.0f), 0.749f, 0.427f), 23), Color4ub(27, 40, 108, 23)); + CORRADE_COMPARE(Color4ub::fromHSV(Deg(230.0f), 0.749f, 0.427f, 23), Color4ub(27, 40, 108, 23)); } void ColorTest::debug() { std::ostringstream o; - Debug(&o) << Color3f(0.5f, 0.75f, 1.0f); + Debug(&o) << Color3(0.5f, 0.75f, 1.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 0.75, 1)\n"); o.str({}); - Debug(&o) << Color4f(0.5f, 0.75f, 0.0f, 1.0f); + Debug(&o) << Color4(0.5f, 0.75f, 0.0f, 1.0f); CORRADE_COMPARE(o.str(), "Vector(0.5, 0.75, 0, 1)\n"); } void ColorTest::configuration() { Utility::Configuration c; - Color3f color3(0.5f, 0.75f, 1.0f); + Color3 color3(0.5f, 0.75f, 1.0f); std::string value3("0.5 0.75 1"); c.setValue("color3", color3); CORRADE_COMPARE(c.value("color3"), value3); - CORRADE_COMPARE(c.value("color3"), color3); + CORRADE_COMPARE(c.value("color3"), color3); - Color4f color4(0.5f, 0.75f, 0.0f, 1.0f); + Color4 color4(0.5f, 0.75f, 0.0f, 1.0f); std::string value4("0.5 0.75 0 1"); c.setValue("color4", color4); CORRADE_COMPARE(c.value("color4"), value4); - CORRADE_COMPARE(c.value("color4"), color4); + CORRADE_COMPARE(c.value("color4"), color4); } }} diff --git a/src/Test/SwizzleTest.cpp b/src/Test/SwizzleTest.cpp index 164785e27..6ff58281b 100644 --- a/src/Test/SwizzleTest.cpp +++ b/src/Test/SwizzleTest.cpp @@ -50,8 +50,8 @@ void SwizzleTest::rgba() { void SwizzleTest::type() { constexpr Vector4i orig; - constexpr Color3 origColor3; - constexpr Color4 origColor4; + constexpr Color3 origColor3; + constexpr BasicColor4 origColor4; /* decltype(a) is not const because a is not constexpr under GCC <= 4.5 */ #ifdef CORRADE_GCC45_COMPATIBILITY @@ -68,16 +68,16 @@ void SwizzleTest::type() { CORRADE_VERIFY((std::is_same::value)); constexpr auto d = swizzle<'y', 'z', 'r'>(origColor3); - CORRADE_VERIFY((std::is_same>::value)); + CORRADE_VERIFY((std::is_same::value)); constexpr auto e = swizzle<'y', 'z', 'a'>(origColor4); - CORRADE_VERIFY((std::is_same>::value)); + CORRADE_VERIFY((std::is_same>::value)); constexpr auto f = swizzle<'y', 'z', 'y', 'x'>(origColor3); - CORRADE_VERIFY((std::is_same>::value)); + CORRADE_VERIFY((std::is_same::value)); constexpr auto g = swizzle<'y', 'a', 'y', 'x'>(origColor4); - CORRADE_VERIFY((std::is_same>::value)); + CORRADE_VERIFY((std::is_same>::value)); #ifdef CORRADE_GCC45_COMPATIBILITY #undef const diff --git a/src/Text/TextRenderer.h b/src/Text/TextRenderer.h index ee0ad3abe..57ba2d6fa 100644 --- a/src/Text/TextRenderer.h +++ b/src/Text/TextRenderer.h @@ -163,7 +163,7 @@ std::tie(mesh, rectangle) = Text::TextRenderer2D::render(font, cache, 0.15f, // Draw white text centered on the screen shader->setTransformationProjectionMatrix(projection*Matrix3::translation(-rectangle.width()/2.0f)) - ->setColor(Color3<>(1.0f)); + ->setColor(Color3(1.0f)); ->use(); glyphCache->texture()->bind(Shaders::VectorShader2D::FontTextureLayer); mesh.draw(); @@ -189,7 +189,7 @@ renderer.render("Hello World Countdown: 10"); // Draw the text centered on the screen shader->setTransformationProjectionMatrix(projection*Matrix3::translation(-renderer.rectangle().width()/2.0f)) - ->setColor(Color3<>(1.0f)); + ->setColor(Color3(1.0f)); ->use(); glyphCache->texture()->bind(Shaders::VectorShader2D::FontTextureLayer); renderer.mesh().draw(); diff --git a/src/Texture.h b/src/Texture.h index dce833157..90c5a8e9d 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -427,7 +427,7 @@ template class Texture: public AbstractTexture { return this; } #ifndef MAGNUM_TARGET_GLES3 - Texture* setBorderColor(const Color4<>& color) { + Texture* setBorderColor(const Color4& color) { AbstractTexture::setBorderColor(color); return this; }