diff --git a/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp index 903cfbf57..9ef7904d5 100644 --- a/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp +++ b/src/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp @@ -34,11 +34,9 @@ namespace Magnum { namespace DebugTools { namespace Implementation { template AxisAlignedBoxRenderer::AxisAlignedBoxRenderer(Physics::AxisAlignedBox& axisAlignedBox): axisAlignedBox(axisAlignedBox) {} template void AxisAlignedBoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) { - /* Half scale, because the box is 2x2(x2) */ - typename DimensionTraits::MatrixType transformation = + this->shader->setTransformationProjectionMatrix(projectionMatrix* DimensionTraits::MatrixType::translation((axisAlignedBox.transformedMin()+axisAlignedBox.transformedMax())/2)* - DimensionTraits::MatrixType::scaling((axisAlignedBox.transformedMax()-axisAlignedBox.transformedMin())/2); - this->shader->setTransformationProjectionMatrix(projectionMatrix*transformation) + DimensionTraits::MatrixType::scaling(axisAlignedBox.transformedMax()-axisAlignedBox.transformedMin())) ->setColor(options->color()) ->use(); this->mesh->draw(); diff --git a/src/DebugTools/Implementation/BoxRenderer.cpp b/src/DebugTools/Implementation/BoxRenderer.cpp index e838b67f1..d9a34c62d 100644 --- a/src/DebugTools/Implementation/BoxRenderer.cpp +++ b/src/DebugTools/Implementation/BoxRenderer.cpp @@ -34,9 +34,7 @@ namespace Magnum { namespace DebugTools { namespace Implementation { template BoxRenderer::BoxRenderer(Physics::Box& box): box(box) {} template void BoxRenderer::draw(Resource& options, const typename DimensionTraits::MatrixType& projectionMatrix) { - /* Half scale, because the box is 2x2(x2) */ - this->shader->setTransformationProjectionMatrix(projectionMatrix*box.transformedTransformation()* - DimensionTraits::MatrixType::scaling(typename DimensionTraits::VectorType(0.5f))) + this->shader->setTransformationProjectionMatrix(projectionMatrix*box.transformedTransformation()) ->setColor(options->color()) ->use(); this->mesh->draw(); diff --git a/src/Physics/AxisAlignedBox.h b/src/Physics/AxisAlignedBox.h index bcb164434..d987c8674 100644 --- a/src/Physics/AxisAlignedBox.h +++ b/src/Physics/AxisAlignedBox.h @@ -39,6 +39,8 @@ namespace Magnum { namespace Physics { /** @brief Axis-aligned box +Unit-size means that half extents are equal to 1, equivalent to e.g. sphere +radius. @see AxisAlignedBox2D, AxisAlignedBox3D @todo Assert for rotation */ diff --git a/src/Physics/Box.h b/src/Physics/Box.h index e442e915d..e0b79de96 100644 --- a/src/Physics/Box.h +++ b/src/Physics/Box.h @@ -39,6 +39,8 @@ namespace Magnum { namespace Physics { /** @brief Unit-size box with assigned transformation matrix +Unit-size means that half extents are equal to 1, equivalent to e.g. sphere +radius. @todo Use quat + position + size instead? @see Box2D, Box3D @todo Assert for skew