X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fpatch.cpp;h=3d53842f5568aa9d6e2158510960d7236d076ae9;hb=c692cc9ef765593ba8afb5444eaf5a49caaa0514;hp=1270a9e0c7f203d13bcfd2fed2092fab27831d21;hpb=b7e36c120eb1546a6c6f97f30e42ab7f9a559c61;p=xonotic%2Fnetradiant.git diff --git a/radiant/patch.cpp b/radiant/patch.cpp index 1270a9e0..3d53842f 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -19,9 +19,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#define _USE_MATH_DEFINES #include "patch.h" -#include +#include #include "preferences.h" #include "brush_primit.h" #include "signal/signal.h" @@ -1357,14 +1358,13 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std // vPos[1] = aabb.origin; // vPos[2] = vector3_added(aabb.origin, aabb.extents); - int i, j; float f = 1 / cos( M_PI / n ); - for ( i = 0; i < width; ++i ) + for ( std::size_t i = 0; i < width; ++i ) { float angle = ( M_PI * i ) / n; // 0 to 2pi float x = vPos[1][0] + ( vPos[2][0] - vPos[1][0] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); float y = vPos[1][1] + ( vPos[2][1] - vPos[1][1] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f ); - for ( j = 0; j < height; ++j ) + for ( std::size_t j = 0; j < height; ++j ) { float z = vPos[0][2] + ( vPos[2][2] - vPos[0][2] ) * ( j / (float)( height - 1 ) ); PatchControl *v; @@ -1383,12 +1383,11 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std // vPos[1] = aabb.origin; // vPos[2] = vector3_added(aabb.origin, aabb.extents); - int i, j; float f = 1 / cos( M_PI / n ); - for ( i = 0; i < width; ++i ) + for ( std::size_t i = 0; i < width; ++i ) { float angle = ( M_PI * i ) / n; - for ( j = 0; j < height; ++j ) + for ( std::size_t j = 0; j < height; ++j ) { float x = vPos[1][0] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][0] - vPos[1][0] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); float y = vPos[1][1] + ( 1.0f - ( j / (float)( height - 1 ) ) ) * ( vPos[2][1] - vPos[1][1] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f ); @@ -1410,13 +1409,12 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std // vPos[1] = aabb.origin; // vPos[2] = vector3_added(aabb.origin, aabb.extents); - int i, j; float f = 1 / cos( M_PI / n ); float g = 1 / cos( M_PI / ( 2 * m ) ); - for ( i = 0; i < width; ++i ) + for ( std::size_t i = 0; i < width; ++i ) { float angle = ( M_PI * i ) / n; - for ( j = 0; j < height; ++j ) + for ( std::size_t j = 0; j < height; ++j ) { float angle2 = ( M_PI * j ) / ( 2 * m ); float x = vPos[1][0] + ( vPos[2][0] - vPos[1][0] ) * sin( angle2 ) * ( ( j & 1 ) ? g : 1.0f ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); @@ -1548,14 +1546,14 @@ void RenderablePatchSolid::RenderNormals() const { glEnd(); } -#define DEGEN_0a 0x01 -#define DEGEN_1a 0x02 -#define DEGEN_2a 0x04 -#define DEGEN_0b 0x08 -#define DEGEN_1b 0x10 -#define DEGEN_2b 0x20 -#define SPLIT 0x40 -#define AVERAGE 0x80 +const int DEGEN_0a = 0x01; +const int DEGEN_1a = 0x02; +const int DEGEN_2a = 0x04; +const int DEGEN_0b = 0x08; +const int DEGEN_1b = 0x10; +const int DEGEN_2b = 0x20; +const int SPLIT = 0x40; +const int AVERAGE = 0x80; unsigned int subarray_get_degen( PatchControlIter subarray, std::size_t strideU, std::size_t strideV ){