X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fpatch.cpp;h=0d80278d70f2ac62ec2a5c1e86b4d20a8359fa45;hb=a34196919ed992e3cda24ef9603daf262669b267;hp=1270a9e0c7f203d13bcfd2fed2092fab27831d21;hpb=3c73487420fde8d4a3b5360d8b99e48132517900;p=xonotic%2Fnetradiant.git diff --git a/radiant/patch.cpp b/radiant/patch.cpp index 1270a9e0..0d80278d 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -21,7 +21,7 @@ #include "patch.h" -#include +#include #include "preferences.h" #include "brush_primit.h" #include "signal/signal.h" @@ -1357,14 +1357,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 +1382,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 +1408,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 +1545,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 ){