mirror of https://github.com/mosra/magnum.git
Browse Source
In the future it will use multithreading/GPU transform feedback for large arrays.pull/279/head
2 changed files with 45 additions and 0 deletions
@ -0,0 +1,44 @@ |
|||||||
|
#ifndef Magnum_MeshTools_Transform_h |
||||||
|
#define Magnum_MeshTools_Transform_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 Function Magnum::MeshTools::transform() |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "Math/Matrix.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace MeshTools { |
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Transform vertices using given matrix |
||||||
|
|
||||||
|
Usable for mesh transformations that would otherwise negatively affect |
||||||
|
dependent objects, such as (uneven) scaling. Example usage: |
||||||
|
|
||||||
|
@code |
||||||
|
std::vector<Point3D> vertices; |
||||||
|
MeshTools::transform(Matrix4::scaling({2.0f, 0.5f, 0.0f}), vertices); |
||||||
|
@endcode |
||||||
|
*/ |
||||||
|
template<size_t size, class T, class U> inline void transform(const Math::Matrix<size, T>& matrix, U& vertices) { |
||||||
|
for(Math::Vector<size, T>& vertex: vertices) |
||||||
|
vertex = matrix*vertex; |
||||||
|
} |
||||||
|
|
||||||
|
}} |
||||||
|
|
||||||
|
#endif |
||||||
Loading…
Reference in new issue