Fix weighted cluster fit.

Set metric before color sets.
2.0
castano 17 years ago
parent 77168bb40b
commit b7f3ce664f

@ -30,9 +30,14 @@
namespace squish {
ClusterFit::ClusterFit( ColourSet const* colours, int flags )
: ColourFit( colours, flags )
ClusterFit::ClusterFit()
{
}
void ClusterFit::SetColourSet( ColourSet const* colours, int flags )
{
ColourFit::SetColourSet( colours, flags );
// initialise the best error
#if SQUISH_USE_SIMD
m_besterror = VEC4_CONST( FLT_MAX );
@ -91,7 +96,7 @@ ClusterFit::ClusterFit( ColourSet const* colours, int flags )
}
void ClusterFit::setMetric(float r, float g, float b)
void ClusterFit::SetMetric(float r, float g, float b)
{
#if SQUISH_USE_SIMD
m_metric = Vec4(r, g, b, 0);
@ -101,7 +106,7 @@ void ClusterFit::setMetric(float r, float g, float b)
m_metricSqr = m_metric * m_metric;
}
float ClusterFit::bestError() const
float ClusterFit::GetBestError() const
{
#if SQUISH_USE_SIMD
return m_besterror.GetVec3().X();

@ -36,10 +36,12 @@ namespace squish {
class ClusterFit : public ColourFit
{
public:
ClusterFit( ColourSet const* colours, int flags );
void setMetric(float r, float g, float b);
float bestError() const;
ClusterFit();
void SetColourSet( ColourSet const* colours, int flags );
void SetMetric(float r, float g, float b);
float GetBestError() const;
private:
virtual void Compress3( void* block );

@ -28,12 +28,16 @@
namespace squish {
ColourFit::ColourFit( ColourSet const* colours, int flags )
: m_colours( colours ),
m_flags( flags )
ColourFit::ColourFit()
{
}
void ColourFit::SetColourSet( ColourSet const* colours, int flags )
{
m_colours = colours;
m_flags = flags;
}
void ColourFit::Compress( void* block )
{
bool isDxt1 = ( ( m_flags & kDxt1 ) != 0 );

@ -36,7 +36,9 @@ class ColourSet;
class ColourFit
{
public:
ColourFit( ColourSet const* colours, int flags );
ColourFit();
void SetColourSet( ColourSet const* colours, int flags );
void Compress( void* block );

@ -31,9 +31,14 @@
namespace squish {
FastClusterFit::FastClusterFit( ColourSet const* colours, int flags ) :
ColourFit( colours, flags )
FastClusterFit::FastClusterFit()
{
}
void FastClusterFit::SetColourSet( ColourSet const* colours, int flags )
{
ColourFit::SetColourSet( colours, flags );
// initialise the best error
#if SQUISH_USE_SIMD
m_besterror = VEC4_CONST( FLT_MAX );
@ -102,7 +107,7 @@ struct Precomp {
static Precomp s_threeElement[153];
static Precomp s_fourElement[969];
void FastClusterFit::doPrecomputation()
void FastClusterFit::DoPrecomputation()
{
int i = 0;
@ -177,7 +182,7 @@ void FastClusterFit::doPrecomputation()
//printf("%d four cluster elements\n", i);
}
void FastClusterFit::setMetric(float r, float g, float b)
void FastClusterFit::SetMetric(float r, float g, float b)
{
#if SQUISH_USE_SIMD
m_metric = Vec4(r, g, b, 0);
@ -187,7 +192,7 @@ void FastClusterFit::setMetric(float r, float g, float b)
m_metricSqr = m_metric * m_metric;
}
float FastClusterFit::bestError() const
float FastClusterFit::GetBestError() const
{
#if SQUISH_USE_SIMD
Vec4 x = m_xxsum * m_metricSqr;

@ -37,12 +37,14 @@ namespace squish {
class FastClusterFit : public ColourFit
{
public:
FastClusterFit( ColourSet const* colours, int flags );
FastClusterFit();
void setMetric(float r, float g, float b);
float bestError() const;
void SetColourSet( ColourSet const* colours, int flags );
static void doPrecomputation();
void SetMetric(float r, float g, float b);
float GetBestError() const;
static void DoPrecomputation();
// Make them public
virtual void Compress3( void* block );

@ -32,9 +32,14 @@
namespace squish {
WeightedClusterFit::WeightedClusterFit( ColourSet const* colours, int flags ) :
ColourFit( colours, flags )
WeightedClusterFit::WeightedClusterFit()
{
}
void WeightedClusterFit::SetColourSet( ColourSet const* colours, int flags )
{
ColourFit::SetColourSet( colours, flags );
// initialise the best error
#if SQUISH_USE_SIMD
m_besterror = VEC4_CONST( FLT_MAX );
@ -100,7 +105,7 @@ WeightedClusterFit::WeightedClusterFit( ColourSet const* colours, int flags ) :
}
void WeightedClusterFit::setMetric(float r, float g, float b)
void WeightedClusterFit::SetMetric(float r, float g, float b)
{
#if SQUISH_USE_SIMD
m_metric = Vec4(r, g, b, 0);
@ -110,7 +115,7 @@ void WeightedClusterFit::setMetric(float r, float g, float b)
m_metricSqr = m_metric * m_metric;
}
float WeightedClusterFit::bestError() const
float WeightedClusterFit::GetBestError() const
{
#if SQUISH_USE_SIMD
Vec4 x = m_xxsum * m_metricSqr;

@ -37,12 +37,12 @@ namespace squish {
class WeightedClusterFit : public ColourFit
{
public:
WeightedClusterFit( ColourSet const* colours, int flags );
void setMetric(float r, float g, float b);
float bestError() const;
WeightedClusterFit();
static void doPrecomputation();
void SetColourSet( ColourSet const* colours, int flags );
void SetMetric(float r, float g, float b);
float GetBestError() const;
// Make them public
virtual void Compress3( void* block );

Loading…
Cancel
Save