mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-05 10:17:46 +00:00
fix more style
This commit is contained in:
parent
e5f612bc43
commit
29edf87924
4 changed files with 432 additions and 374 deletions
|
@ -63,11 +63,15 @@ static void calcExtends(const BoundsItem* items, const int /*nitems*/,
|
|||
for( int i = imin + 1; i < imax; ++i )
|
||||
{
|
||||
const BoundsItem& it = items[ i ];
|
||||
if (it.bmin[0] < bmin[0]) bmin[0] = it.bmin[0];
|
||||
if (it.bmin[1] < bmin[1]) bmin[1] = it.bmin[1];
|
||||
if( it.bmin[ 0 ] < bmin[ 0 ] )
|
||||
bmin[ 0 ] = it.bmin[ 0 ];
|
||||
if( it.bmin[ 1 ] < bmin[ 1 ] )
|
||||
bmin[ 1 ] = it.bmin[ 1 ];
|
||||
|
||||
if (it.bmax[0] > bmax[0]) bmax[0] = it.bmax[0];
|
||||
if (it.bmax[1] > bmax[1]) bmax[1] = it.bmax[1];
|
||||
if( it.bmax[ 0 ] > bmax[ 0 ] )
|
||||
bmax[ 0 ] = it.bmax[ 0 ];
|
||||
if( it.bmax[ 1 ] > bmax[ 1 ] )
|
||||
bmax[ 1 ] = it.bmax[ 1 ];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,11 +174,15 @@ bool rcCreateChunkyTriMesh(const float* verts, const int* tris, int ntris,
|
|||
for( int j = 1; j < 3; ++j )
|
||||
{
|
||||
const float* v = &verts[ t[ j ] * 3 ];
|
||||
if (v[0] < it.bmin[0]) it.bmin[0] = v[0];
|
||||
if (v[2] < it.bmin[1]) it.bmin[1] = v[2];
|
||||
if( v[ 0 ] < it.bmin[ 0 ] )
|
||||
it.bmin[ 0 ] = v[ 0 ];
|
||||
if( v[ 2 ] < it.bmin[ 1 ] )
|
||||
it.bmin[ 1 ] = v[ 2 ];
|
||||
|
||||
if (v[0] > it.bmax[0]) it.bmax[0] = v[0];
|
||||
if (v[2] > it.bmax[1]) it.bmax[1] = v[2];
|
||||
if( v[ 0 ] > it.bmax[ 0 ] )
|
||||
it.bmax[ 0 ] = v[ 0 ];
|
||||
if( v[ 2 ] > it.bmax[ 1 ] )
|
||||
it.bmax[ 1 ] = v[ 2 ];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +200,8 @@ bool rcCreateChunkyTriMesh(const float* verts, const int* tris, int ntris,
|
|||
{
|
||||
rcChunkyTriMeshNode& node = cm->nodes[ i ];
|
||||
const bool isLeaf = node.i >= 0;
|
||||
if (!isLeaf) continue;
|
||||
if( !isLeaf )
|
||||
continue;
|
||||
if( node.n > cm->maxTrisPerChunk )
|
||||
cm->maxTrisPerChunk = node.n;
|
||||
}
|
||||
|
@ -245,7 +254,6 @@ int rcGetChunksOverlappingRect(const rcChunkyTriMesh* cm,
|
|||
}
|
||||
|
||||
|
||||
|
||||
static bool checkOverlapSegment( const float p[2], const float q[2],
|
||||
const float bmin[2], const float bmax[2] )
|
||||
{
|
||||
|
@ -271,10 +279,18 @@ static bool checkOverlapSegment(const float p[2], const float q[2],
|
|||
float ood = 1.0f / d[ i ];
|
||||
float t1 = ( bmin[ i ] - p[ i ] ) * ood;
|
||||
float t2 = ( bmax[ i ] - p[ i ] ) * ood;
|
||||
if (t1 > t2) { float tmp = t1; t1 = t2; t2 = tmp; }
|
||||
if (t1 > tmin) tmin = t1;
|
||||
if (t2 < tmax) tmax = t2;
|
||||
if (tmin > tmax) return false;
|
||||
if( t1 > t2 )
|
||||
{
|
||||
float tmp = t1;
|
||||
t1 = t2;
|
||||
t2 = tmp;
|
||||
}
|
||||
if( t1 > tmin )
|
||||
tmin = t1;
|
||||
if( t2 < tmax )
|
||||
tmax = t2;
|
||||
if( tmin > tmax )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -29,8 +29,16 @@ struct rcChunkyTriMeshNode
|
|||
|
||||
struct rcChunkyTriMesh
|
||||
{
|
||||
inline rcChunkyTriMesh() : nodes(0), nnodes(0), tris(0), ntris(0), maxTrisPerChunk(0) {};
|
||||
inline ~rcChunkyTriMesh() { delete [] nodes; delete [] tris; }
|
||||
inline rcChunkyTriMesh() :
|
||||
nodes( 0 ), nnodes( 0 ), tris( 0 ), ntris( 0 ), maxTrisPerChunk( 0 )
|
||||
{
|
||||
};
|
||||
|
||||
inline ~rcChunkyTriMesh()
|
||||
{
|
||||
delete[] nodes;
|
||||
delete[] tris;
|
||||
}
|
||||
|
||||
rcChunkyTriMeshNode* nodes;
|
||||
int nnodes;
|
||||
|
@ -41,6 +49,7 @@ struct rcChunkyTriMesh
|
|||
private:
|
||||
// Explicitly disabled copy constructor and copy assignment operator.
|
||||
rcChunkyTriMesh( const rcChunkyTriMesh& );
|
||||
|
||||
rcChunkyTriMesh& operator=( const rcChunkyTriMesh& );
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstring>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include <math.h>
|
||||
|
||||
rcMeshLoaderObj::rcMeshLoaderObj() :
|
||||
|
@ -91,14 +93,16 @@ static char* parseRow(char* buf, char* bufEnd, char* row, int len)
|
|||
case '\\':
|
||||
break;
|
||||
case '\n':
|
||||
if (start) break;
|
||||
if( start )
|
||||
break;
|
||||
done = true;
|
||||
break;
|
||||
case '\r':
|
||||
break;
|
||||
case '\t':
|
||||
case ' ':
|
||||
if (start) break;
|
||||
if( start )
|
||||
break;
|
||||
// else falls through
|
||||
default:
|
||||
start = false;
|
||||
|
@ -124,14 +128,16 @@ static int parseFace(char* row, int* data, int n, int vcnt)
|
|||
// Find vertex delimiter and terminated the string there for conversion.
|
||||
while( *row != '\0' && *row != ' ' && *row != '\t' )
|
||||
{
|
||||
if (*row == '/') *row = '\0';
|
||||
if( *row == '/' )
|
||||
*row = '\0';
|
||||
row++;
|
||||
}
|
||||
if( *s == '\0' )
|
||||
continue;
|
||||
int vi = atoi( s );
|
||||
data[ j++ ] = vi < 0 ? vi + vcnt : vi - 1;
|
||||
if (j >= n) return j;
|
||||
if( j >= n )
|
||||
return j;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
@ -188,7 +194,8 @@ bool rcMeshLoaderObj::load(const std::string& filename)
|
|||
row[ 0 ] = '\0';
|
||||
src = parseRow( src, srcEnd, row, sizeof( row ) / sizeof( char ) );
|
||||
// Skip comments
|
||||
if (row[0] == '#') continue;
|
||||
if( row[ 0 ] == '#' )
|
||||
continue;
|
||||
if( row[ 0 ] == 'v' && row[ 1 ] != 'n' && row[ 1 ] != 't' )
|
||||
{
|
||||
// Vertex pos
|
||||
|
|
|
@ -25,23 +25,49 @@ class rcMeshLoaderObj
|
|||
{
|
||||
public:
|
||||
rcMeshLoaderObj();
|
||||
|
||||
~rcMeshLoaderObj();
|
||||
|
||||
bool load( const std::string& fileName );
|
||||
|
||||
const float* getVerts() const { return m_verts; }
|
||||
const float* getNormals() const { return m_normals; }
|
||||
const int* getTris() const { return m_tris; }
|
||||
int getVertCount() const { return m_vertCount; }
|
||||
int getTriCount() const { return m_triCount; }
|
||||
const std::string& getFileName() const { return m_filename; }
|
||||
const float* getVerts() const
|
||||
{
|
||||
return m_verts;
|
||||
}
|
||||
|
||||
const float* getNormals() const
|
||||
{
|
||||
return m_normals;
|
||||
}
|
||||
|
||||
const int* getTris() const
|
||||
{
|
||||
return m_tris;
|
||||
}
|
||||
|
||||
int getVertCount() const
|
||||
{
|
||||
return m_vertCount;
|
||||
}
|
||||
|
||||
int getTriCount() const
|
||||
{
|
||||
return m_triCount;
|
||||
}
|
||||
|
||||
const std::string& getFileName() const
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
private:
|
||||
// Explicitly disabled copy constructor and copy assignment operator.
|
||||
rcMeshLoaderObj( const rcMeshLoaderObj& );
|
||||
|
||||
rcMeshLoaderObj& operator=( const rcMeshLoaderObj& );
|
||||
|
||||
void addVertex( float x, float y, float z, int& cap );
|
||||
|
||||
void addTriangle( int a, int b, int c, int& cap );
|
||||
|
||||
std::string m_filename;
|
||||
|
|
Loading…
Add table
Reference in a new issue