1
1
forked from 0ad/0ad
0ad/source/dcdt/se/sr_points.cpp
janwas 5bf9bca9ef fix/disable warnings.
there are too many W4 and "potentially uninitialized", so those are
disabled by 0ad_warning_disable.h.

the silly "int x = strlen" and very dangerous "int x = (void*)p" (and
vice versa) problems are fixed.

This was SVN commit r5526.
2007-12-23 12:18:57 +00:00

106 lines
2.0 KiB
C++

#include "precompiled.h"
#include "0ad_warning_disable.h"
# include "sr_box.h"
# include "sr_vec2.h"
# include "sr_points.h"
//# define SR_USE_TRACE1 // Constructor and Destructor
# include "sr_trace.h"
//======================================= SrPoints ====================================
const char* SrPoints::class_name = "Points";
SrPoints::SrPoints ()
{
SR_TRACE1 ( "Constructor" );
A = 0;
}
SrPoints::~SrPoints ()
{
SR_TRACE1 ( "Destructor" );
delete A;
}
void SrPoints::init ()
{
P.size(0);
}
void SrPoints::init_with_attributes ()
{
P.size(0);
if ( A )
A->size(0);
else A = new SrArray<Atrib>;
}
void SrPoints::compress ()
{
P.compress();
if ( A ) A->compress();
}
void SrPoints::push ( const SrPnt& p )
{
P.push() = p;
if ( A ) A->push().s=1;
}
void SrPoints::push ( const SrPnt2& p )
{
P.push().set ( p.x, p.y, 0 );
if ( A ) A->push().s=1;
}
void SrPoints::push ( float x, float y, float z )
{
P.push().set(x,y,z);
if ( A ) A->push().s=1;
}
void SrPoints::push ( const SrPnt& p, SrColor c, float size )
{
if ( !A ) return;
P.push() = p;
A->push().s=size;
A->top().c = c;
}
void SrPoints::push ( const SrPnt2& p, SrColor c, float size )
{
if ( !A ) return;
P.push().set ( p.x, p.y, 0 );
A->push().s=size;
A->top().c = c;
}
void SrPoints::push ( float x, float y, SrColor c, float size )
{
if ( !A ) return;
P.push().set(x,y,0);
A->push().s=size;
A->top().c = c;
}
void SrPoints::push ( float x, float y, float z, SrColor c, float size )
{
if ( !A ) return;
P.push().set(x,y,z);
A->push().s=size;
A->top().c = c;
}
void SrPoints::get_bounding_box ( SrBox& b ) const
{
int i;
b.set_empty ();
for ( i=0; i<P.size(); i++ )
{ b.extend ( P[i] );
}
}
//================================ EOF =================================================