mirror of https://github.com/mosra/magnum.git
Browse Source
Conflicts: src/CMakeLists.txt src/Math/Test/CMakeLists.txt src/Physics/ObjectShapeGroup.cpp src/Physics/ObjectShapeGroup.h src/ResourceManager.h
53 changed files with 1011 additions and 411 deletions
@ -1 +1 @@
|
||||
corrade_add_test2(MathAlgorithmsGaussJordanTest GaussJordanTest.cpp) |
||||
corrade_add_test2(MathAlgorithmsGaussJordanTest GaussJordanTest.cpp LIBRARIES MagnumMathTestLib) |
||||
|
||||
@ -0,0 +1,106 @@
|
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
#include "RectangularMatrix.h" |
||||
|
||||
namespace Magnum { namespace Math { |
||||
|
||||
#ifndef DOXYGEN_GENERATING_OUTPUT |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 2, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 3, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 4, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 2, int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 3, int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 4, int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 2, unsigned int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 3, unsigned int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 4, unsigned int>&); |
||||
#ifndef MAGNUM_TARGET_GLES |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 2, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 3, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<1, 4, double>&); |
||||
#endif |
||||
|
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 2, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 3, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 4, float>&); |
||||
#ifndef MAGNUM_TARGET_GLES |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 2, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 3, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 4, double>&); |
||||
#endif |
||||
|
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 3, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 2, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 4, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 2, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 4, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 3, float>&); |
||||
#ifndef MAGNUM_TARGET_GLES |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 3, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 2, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 4, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 2, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 4, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 3, double>&); |
||||
#endif |
||||
#endif |
||||
|
||||
}} |
||||
|
||||
namespace Corrade { namespace Utility { |
||||
|
||||
#ifndef DOXYGEN_GENERATING_OUTPUT |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 2, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 3, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 4, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 2, int>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 3, int>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 4, int>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 2, unsigned int>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 3, unsigned int>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 4, unsigned int>>; |
||||
#ifndef MAGNUM_TARGET_GLES |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 2, double>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 3, double>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<1, 4, double>>; |
||||
#endif |
||||
|
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, float>>; |
||||
#ifndef MAGNUM_TARGET_GLES |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, double>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, double>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, double>>; |
||||
#endif |
||||
|
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, float>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, float>>; |
||||
#ifndef MAGNUM_TARGET_GLES |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, double>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, double>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, double>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, double>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, double>>; |
||||
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, double>>; |
||||
#endif |
||||
#endif |
||||
|
||||
}} |
||||
@ -1,24 +1,19 @@
|
||||
corrade_add_test2(MathConstantsTest ConstantsTest.cpp) |
||||
if(NOT CMAKE_NO_OBJECT_TARGET) |
||||
set(MathTest_SRCS MathTest.cpp $<TARGET_OBJECTS:MagnumMathObjects>) |
||||
else() |
||||
set(MathTest_SRCS MathTest.cpp ${MagnumMath_SRCS}) |
||||
endif() |
||||
corrade_add_test2(MathTest ${MathTest_SRCS}) |
||||
corrade_add_test2(MathTest MathTest.cpp LIBRARIES MagnumMathTestLib) |
||||
corrade_add_test2(MathMathTypeTraitsTest MathTypeTraitsTest.cpp) |
||||
|
||||
corrade_add_test2(MathRectangularMatrixTest RectangularMatrixTest.cpp) |
||||
corrade_add_test2(MathRectangularMatrixTest RectangularMatrixTest.cpp LIBRARIES MagnumMathTestLib) |
||||
|
||||
corrade_add_test2(MathVectorTest VectorTest.cpp) |
||||
corrade_add_test2(MathVector2Test Vector2Test.cpp) |
||||
corrade_add_test2(MathVector3Test Vector3Test.cpp) |
||||
corrade_add_test2(MathVector4Test Vector4Test.cpp) |
||||
corrade_add_test2(MathVectorTest VectorTest.cpp LIBRARIES MagnumMathTestLib) |
||||
corrade_add_test2(MathVector2Test Vector2Test.cpp LIBRARIES MagnumMathTestLib) |
||||
corrade_add_test2(MathVector3Test Vector3Test.cpp LIBRARIES MagnumMathTestLib) |
||||
corrade_add_test2(MathVector4Test Vector4Test.cpp LIBRARIES MagnumMathTestLib) |
||||
|
||||
corrade_add_test2(MathPoint2DTest Point2DTest.cpp) |
||||
corrade_add_test2(MathPoint3DTest Point3DTest.cpp) |
||||
corrade_add_test2(MathPoint2DTest Point2DTest.cpp LIBRARIES MagnumMathTestLib) |
||||
corrade_add_test2(MathPoint3DTest Point3DTest.cpp LIBRARIES MagnumMathTestLib) |
||||
|
||||
corrade_add_test2(MathMatrixTest MatrixTest.cpp) |
||||
corrade_add_test2(MathMatrix3Test Matrix3Test.cpp) |
||||
corrade_add_test2(MathMatrix4Test Matrix4Test.cpp) |
||||
corrade_add_test2(MathMatrixTest MatrixTest.cpp LIBRARIES MagnumMathTestLib) |
||||
corrade_add_test2(MathMatrix3Test Matrix3Test.cpp LIBRARIES MagnumMathTestLib) |
||||
corrade_add_test2(MathMatrix4Test Matrix4Test.cpp LIBRARIES MagnumMathTestLib) |
||||
|
||||
set_target_properties(MathVectorTest MathMatrix4Test PROPERTIES COMPILE_FLAGS -DCORRADE_GRACEFUL_ASSERT) |
||||
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
#include "Vector.h" |
||||
|
||||
namespace Magnum { namespace Math { |
||||
|
||||
#ifndef DOXYGEN_GENERATING_OUTPUT |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, float>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, unsigned int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, unsigned int>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, unsigned int>&); |
||||
#ifndef MAGNUM_TARGET_GLES |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, double>&); |
||||
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, double>&); |
||||
#endif |
||||
#endif |
||||
|
||||
}} |
||||
@ -0,0 +1,58 @@
|
||||
#ifndef Magnum_Physics_Implementation_DebugRenderer_h |
||||
#define Magnum_Physics_Implementation_DebugRenderer_h |
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
#include "ResourceManager.h" |
||||
#include "SceneGraph/Drawable.h" |
||||
#include "AbstractDebugRenderer.h" |
||||
|
||||
namespace Magnum { |
||||
|
||||
class AbstractShaderProgram; |
||||
class Mesh; |
||||
|
||||
namespace Shaders { |
||||
template<std::uint8_t> class FlatShader; |
||||
} |
||||
|
||||
namespace Physics { namespace Implementation { |
||||
|
||||
struct Options; |
||||
|
||||
template<std::uint8_t dimensions> class DebugRenderer: public SceneGraph::Drawable<dimensions> { |
||||
public: |
||||
DebugRenderer(SceneGraph::AbstractObject<dimensions>* object, Resource<Options>&& options): SceneGraph::Drawable<dimensions>(object), options(options) {} |
||||
|
||||
inline ~DebugRenderer() { |
||||
for(auto i: renderers) delete i; |
||||
} |
||||
|
||||
inline void addRenderer(AbstractDebugRenderer<dimensions>* renderer) { |
||||
renderers.push_back(renderer); |
||||
} |
||||
|
||||
inline void draw(const typename DimensionTraits<dimensions>::MatrixType& transformationMatrix, SceneGraph::AbstractCamera<dimensions, GLfloat>* camera) override { |
||||
for(auto i: renderers) i->draw(options, transformationMatrix, camera); |
||||
} |
||||
|
||||
private: |
||||
Resource<Options> options; |
||||
std::vector<AbstractDebugRenderer<dimensions>*> renderers; |
||||
}; |
||||
|
||||
}}} |
||||
|
||||
#endif |
||||
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
#include "ObjectShape.h" |
||||
|
||||
#include <algorithm> |
||||
|
||||
#include "AbstractShape.h" |
||||
#include "ObjectShapeGroup.h" |
||||
|
||||
using namespace std; |
||||
|
||||
namespace Magnum { namespace Physics { |
||||
|
||||
template<uint8_t dimensions> ObjectShape<dimensions>::ObjectShape(SceneGraph::AbstractObject<dimensions>* object, ObjectShapeGroup<dimensions>* group): SceneGraph::AbstractGroupedFeature<dimensions, ObjectShape<dimensions>>(object, group), _shape(nullptr) { |
||||
this->setCachedTransformations(SceneGraph::AbstractFeature<dimensions>::CachedTransformation::Absolute); |
||||
} |
||||
|
||||
template<uint8_t dimensions> ObjectShape<dimensions>::~ObjectShape() { |
||||
delete _shape; |
||||
} |
||||
|
||||
template<uint8_t dimensions> void ObjectShape<dimensions>::markDirty() { |
||||
group()->setDirty(); |
||||
} |
||||
|
||||
template<uint8_t dimensions> void ObjectShape<dimensions>::clean(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& absoluteTransformation) { |
||||
if(_shape) _shape->applyTransformation(absoluteTransformation); |
||||
} |
||||
|
||||
template class ObjectShape<2>; |
||||
template class ObjectShape<3>; |
||||
|
||||
}} |
||||
@ -0,0 +1,98 @@
|
||||
#ifndef Magnum_Physics_ObjectShape_h |
||||
#define Magnum_Physics_ObjectShape_h |
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Class Magnum::Physics::ObjectShape |
||||
*/ |
||||
|
||||
#include "SceneGraph/AbstractGroupedFeature.h" |
||||
#include "ObjectShapeGroup.h" |
||||
|
||||
#include "magnumPhysicsVisibility.h" |
||||
|
||||
namespace Magnum { namespace Physics { |
||||
|
||||
template<std::uint8_t> class ObjectShapeGroup; |
||||
template<std::uint8_t> class AbstractShape; |
||||
|
||||
/**
|
||||
@brief Object shape |
||||
|
||||
Adds shape for collision detection to object. |
||||
@see ObjectShape2D, ObjectShape3D |
||||
*/ |
||||
template<std::uint8_t dimensions> class PHYSICS_EXPORT ObjectShape: public SceneGraph::AbstractGroupedFeature<dimensions, ObjectShape<dimensions>> { |
||||
public: |
||||
/**
|
||||
* @brief Constructor |
||||
* @param object Object holding this feature |
||||
* @param group Group this shape belongs to |
||||
* |
||||
* Creates empty object shape. |
||||
* @see setShape() |
||||
*/ |
||||
ObjectShape(SceneGraph::AbstractObject<dimensions>* object, ObjectShapeGroup<dimensions>* group = nullptr); |
||||
|
||||
/**
|
||||
* @brief Destructor |
||||
* |
||||
* Deletes associated shape. |
||||
*/ |
||||
~ObjectShape(); |
||||
|
||||
/** @brief Shape */ |
||||
inline AbstractShape<dimensions>* shape() { return _shape; } |
||||
inline const AbstractShape<dimensions>* shape() const { return _shape; } /**< @overload */ |
||||
|
||||
/**
|
||||
* @brief Set shape |
||||
* @return Pointer to self (for method chaining) |
||||
*/ |
||||
inline ObjectShape<dimensions>* setShape(AbstractShape<dimensions>* shape) { |
||||
_shape = shape; |
||||
this->object()->setDirty(); |
||||
return this; |
||||
} |
||||
|
||||
inline ObjectShapeGroup<dimensions>* group() { |
||||
return static_cast<ObjectShapeGroup<dimensions>*>(SceneGraph::AbstractGroupedFeature<dimensions, ObjectShape<dimensions>>::group()); |
||||
} |
||||
|
||||
inline const ObjectShapeGroup<dimensions>* group() const { |
||||
return static_cast<const ObjectShapeGroup<dimensions>*>(SceneGraph::AbstractGroupedFeature<dimensions, ObjectShape<dimensions>>::group()); |
||||
} |
||||
|
||||
protected: |
||||
/** Marks also the group as dirty */ |
||||
void markDirty() override; |
||||
|
||||
/** Applies transformation to associated shape. */ |
||||
void clean(const typename DimensionTraits<dimensions>::MatrixType& absoluteTransformation) override; |
||||
|
||||
private: |
||||
AbstractShape<dimensions>* _shape; |
||||
}; |
||||
|
||||
/** @brief Two-dimensional object shape */ |
||||
typedef ObjectShape<2> ObjectShape2D; |
||||
|
||||
/** @brief Three-dimensional object shape */ |
||||
typedef ObjectShape<3> ObjectShape3D; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -1,51 +0,0 @@
|
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
#include "ShapedObject.h" |
||||
|
||||
#include <algorithm> |
||||
|
||||
#include "AbstractShape.h" |
||||
#include "ShapedObjectGroup.h" |
||||
|
||||
using namespace std; |
||||
|
||||
namespace Magnum { namespace Physics { |
||||
|
||||
template<uint8_t dimensions> ShapedObject<dimensions>::ShapedObject(ShapedObjectGroup<dimensions>* group, typename SceneGraph::AbstractObject<dimensions>::ObjectType* parent): SceneGraph::AbstractObject<dimensions>::ObjectType(parent), group(group), _shape(nullptr) { |
||||
group->objects.push_back(this); |
||||
} |
||||
|
||||
template<uint8_t dimensions> ShapedObject<dimensions>::~ShapedObject() { |
||||
group->objects.erase(find(group->objects.begin(), group->objects.end(), this)); |
||||
delete _shape; |
||||
} |
||||
|
||||
template<uint8_t dimensions> void ShapedObject<dimensions>::setDirty() { |
||||
SceneGraph::AbstractObject<dimensions>::ObjectType::setDirty(); |
||||
|
||||
group->setDirty(); |
||||
} |
||||
|
||||
template<uint8_t dimensions> void ShapedObject<dimensions>::clean(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& absoluteTransformation) { |
||||
SceneGraph::AbstractObject<dimensions>::ObjectType::clean(absoluteTransformation); |
||||
|
||||
if(_shape) _shape->applyTransformation(absoluteTransformation); |
||||
} |
||||
|
||||
template class ShapedObject<2>; |
||||
template class ShapedObject<3>; |
||||
|
||||
}} |
||||
@ -1,97 +0,0 @@
|
||||
#ifndef Magnum_Physics_ShapedObject_h |
||||
#define Magnum_Physics_ShapedObject_h |
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Class Magnum::Physics::ShapedObject |
||||
*/ |
||||
|
||||
#include "SceneGraph/Object.h" |
||||
|
||||
#include "magnumPhysicsVisibility.h" |
||||
|
||||
namespace Magnum { namespace Physics { |
||||
|
||||
template<std::uint8_t> class ShapedObjectGroup; |
||||
template<std::uint8_t> class AbstractShape; |
||||
|
||||
/**
|
||||
@brief Object with assigned shape |
||||
|
||||
@see ShapedObject2D, ShapedObject3D |
||||
*/ |
||||
template<std::uint8_t dimensions> class PHYSICS_EXPORT ShapedObject: public SceneGraph::AbstractObject<dimensions>::ObjectType { |
||||
public: |
||||
/**
|
||||
* @brief Constructor |
||||
* @param group Group this shaped object belongs to |
||||
* @param parent Parent object |
||||
* |
||||
* Creates object with no shape. |
||||
* @see setShape() |
||||
*/ |
||||
ShapedObject(ShapedObjectGroup<dimensions>* group, typename SceneGraph::AbstractObject<dimensions>::ObjectType* parent = nullptr); |
||||
|
||||
/**
|
||||
* @brief Destructor |
||||
* |
||||
* Deletes associated shape. |
||||
*/ |
||||
~ShapedObject(); |
||||
|
||||
/** @brief Object shape */ |
||||
inline AbstractShape<dimensions>* shape() { return _shape; } |
||||
inline const AbstractShape<dimensions>* shape() const { return _shape; } /**< @overload */ |
||||
|
||||
/**
|
||||
* @brief Set object shape |
||||
* @return Pointer to self (for method chaining) |
||||
*/ |
||||
inline ShapedObject<dimensions>* setShape(AbstractShape<dimensions>* shape) { |
||||
_shape = shape; |
||||
setDirty(); |
||||
return this; |
||||
} |
||||
|
||||
/**
|
||||
* @copybrief SceneGraph::AbstractObject::setDirty() |
||||
* |
||||
* Marks shaped object group as dirty. |
||||
*/ |
||||
void setDirty(); |
||||
|
||||
protected: |
||||
/**
|
||||
* @copybrief SceneGraph::AbstractObject::clean() |
||||
* |
||||
* Applies transformation to associated shape. |
||||
*/ |
||||
void clean(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& absoluteTransformation); |
||||
|
||||
private: |
||||
ShapedObjectGroup<dimensions>* group; |
||||
AbstractShape<dimensions>* _shape; |
||||
}; |
||||
|
||||
/** @brief Two-dimensional shaped object */ |
||||
typedef ShapedObject<2> ShapedObject2D; |
||||
|
||||
/** @brief Three-dimensional shaped object */ |
||||
typedef ShapedObject<3> ShapedObject3D; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -0,0 +1,94 @@
|
||||
#ifndef Magnum_SceneGraph_SceneGraph_h |
||||
#define Magnum_SceneGraph_SceneGraph_h |
||||
/*
|
||||
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
This file is part of Magnum. |
||||
|
||||
Magnum is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Lesser General Public License version 3 |
||||
only, as published by the Free Software Foundation. |
||||
|
||||
Magnum is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Lesser General Public License version 3 for more details. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Forward declarations for Magnum::SceneGraph namespace |
||||
*/ |
||||
|
||||
#include <cstdint> |
||||
|
||||
#include "Magnum.h" |
||||
|
||||
namespace Magnum { namespace SceneGraph { |
||||
|
||||
template<std::uint8_t dimensions, class T = GLfloat> class AbstractCamera; |
||||
#ifndef MAGNUM_GCC46_COMPATIBILITY |
||||
template<class T = GLfloat> using AbstractCamera2D = AbstractCamera<2, T>; |
||||
template<class T = GLfloat> using AbstractCamera3D = AbstractCamera<3, T>; |
||||
#endif |
||||
|
||||
template<std::uint8_t dimensions, class T = GLfloat> class AbstractFeature; |
||||
#ifndef MAGNUM_GCC46_COMPATIBILITY |
||||
template<class T = GLfloat> using AbstractFeature2D = AbstractFeature<2, T>; |
||||
template<class T = GLfloat> using AbstractFeature3D = AbstractFeature<3, T>; |
||||
#endif |
||||
|
||||
template<std::uint8_t dimensions, class Derived, class T = GLfloat> class AbstractGroupedFeature; |
||||
#ifndef MAGNUM_GCC46_COMPATIBILITY |
||||
template<class Derived, class T = GLfloat> using AbstractGroupedFeature2D = AbstractGroupedFeature<2, Derived, T>; |
||||
template<class Derived, class T = GLfloat> using AbstractGroupedFeature3D = AbstractGroupedFeature<3, Derived, T>; |
||||
#endif |
||||
|
||||
template<std::uint8_t dimensions, class T = GLfloat> class AbstractObject; |
||||
#ifndef MAGNUM_GCC46_COMPATIBILITY |
||||
template<class T = GLfloat> using AbstractObject2D = AbstractObject<2, T>; |
||||
template<class T = GLfloat> using AbstractObject3D = AbstractObject<3, T>; |
||||
#endif |
||||
|
||||
template<std::uint8_t dimensions, class T = GLfloat> class AbstractTransformation; |
||||
#ifndef MAGNUM_GCC46_COMPATIBILITY |
||||
template<class T = GLfloat> using AbstractTransformation2D = AbstractTransformation<2, T>; |
||||
template<class T = GLfloat> using AbstractTransformation3D = AbstractTransformation<3, T>; |
||||
#endif |
||||
|
||||
template<class T = GLfloat> class AbstractTranslationRotation2D; |
||||
template<class T = GLfloat> class AbstractTranslationRotation3D; |
||||
template<class T = GLfloat> class AbstractTranslationRotationScaling2D; |
||||
template<class T = GLfloat> class AbstractTranslationRotationScaling3D; |
||||
|
||||
template<class T = GLfloat> class Camera2D; |
||||
template<class T = GLfloat> class Camera3D; |
||||
|
||||
template<std::uint8_t dimensions, class T = GLfloat> class Drawable; |
||||
#ifndef MAGNUM_GCC46_COMPATIBILITY |
||||
template<class T = GLfloat> using Drawable2D = Drawable<2, T>; |
||||
template<class T = GLfloat> using Drawable3D = Drawable<3, T>; |
||||
#endif |
||||
|
||||
template<std::uint8_t dimensions, class Feature, class T = GLfloat> class FeatureGroup; |
||||
#ifndef MAGNUM_GCC46_COMPATIBILITY |
||||
template<class Feature, class T = GLfloat> using FeatureGroup2D = FeatureGroup<2, Feature, T>; |
||||
template<class Feature, class T = GLfloat> using FeatureGroup3D = FeatureGroup<3, Feature, T>; |
||||
#endif |
||||
|
||||
#ifndef MAGNUM_GCC46_COMPATIBILITY |
||||
template<std::uint8_t dimensions, class T = GLfloat> using DrawableGroup = FeatureGroup<dimensions, Drawable<dimensions, T>, T>; |
||||
template<class T = GLfloat> using DrawableGroup2D = DrawableGroup<2, T>; |
||||
template<class T = GLfloat> using DrawableGroup3D = DrawableGroup<3, T>; |
||||
#else |
||||
template<std::uint8_t dimensions, class T = GLfloat> class DrawableGroup; |
||||
#endif |
||||
|
||||
template<class T = GLfloat> class MatrixTransformation2D; |
||||
template<class T = GLfloat> class MatrixTransformation3D; |
||||
|
||||
template<class Transformation> class Object; |
||||
template<class Transformation> class Scene; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -1,5 +1,5 @@
|
||||
corrade_add_test2(ColorTest ColorTest.cpp) |
||||
corrade_add_test2(ColorTest ColorTest.cpp LIBRARIES MagnumMathTestLib) |
||||
corrade_add_test2(ResourceManagerTest ResourceManagerTest.cpp) |
||||
corrade_add_test2(SwizzleTest SwizzleTest.cpp) |
||||
corrade_add_test2(SwizzleTest SwizzleTest.cpp LIBRARIES MagnumMathTestLib) |
||||
|
||||
set_target_properties(ResourceManagerTest PROPERTIES COMPILE_FLAGS -DCORRADE_GRACEFUL_ASSERT) |
||||
|
||||
Loading…
Reference in new issue