Fix weighted cluster fit.
Set metric before color sets.
This commit is contained in:
parent
77168bb40b
commit
b7f3ce664f
|
@ -30,9 +30,14 @@
|
||||||
|
|
||||||
namespace squish {
|
namespace squish {
|
||||||
|
|
||||||
ClusterFit::ClusterFit( ColourSet const* colours, int flags )
|
ClusterFit::ClusterFit()
|
||||||
: ColourFit( colours, flags )
|
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClusterFit::SetColourSet( ColourSet const* colours, int flags )
|
||||||
|
{
|
||||||
|
ColourFit::SetColourSet( colours, flags );
|
||||||
|
|
||||||
// initialise the best error
|
// initialise the best error
|
||||||
#if SQUISH_USE_SIMD
|
#if SQUISH_USE_SIMD
|
||||||
m_besterror = VEC4_CONST( FLT_MAX );
|
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
|
#if SQUISH_USE_SIMD
|
||||||
m_metric = Vec4(r, g, b, 0);
|
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;
|
m_metricSqr = m_metric * m_metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ClusterFit::bestError() const
|
float ClusterFit::GetBestError() const
|
||||||
{
|
{
|
||||||
#if SQUISH_USE_SIMD
|
#if SQUISH_USE_SIMD
|
||||||
return m_besterror.GetVec3().X();
|
return m_besterror.GetVec3().X();
|
||||||
|
|
|
@ -36,10 +36,12 @@ namespace squish {
|
||||||
class ClusterFit : public ColourFit
|
class ClusterFit : public ColourFit
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClusterFit( ColourSet const* colours, int flags );
|
ClusterFit();
|
||||||
|
|
||||||
void setMetric(float r, float g, float b);
|
void SetColourSet( ColourSet const* colours, int flags );
|
||||||
float bestError() const;
|
|
||||||
|
void SetMetric(float r, float g, float b);
|
||||||
|
float GetBestError() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void Compress3( void* block );
|
virtual void Compress3( void* block );
|
||||||
|
|
|
@ -28,12 +28,16 @@
|
||||||
|
|
||||||
namespace squish {
|
namespace squish {
|
||||||
|
|
||||||
ColourFit::ColourFit( ColourSet const* colours, int flags )
|
ColourFit::ColourFit()
|
||||||
: m_colours( colours ),
|
|
||||||
m_flags( flags )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColourFit::SetColourSet( ColourSet const* colours, int flags )
|
||||||
|
{
|
||||||
|
m_colours = colours;
|
||||||
|
m_flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
void ColourFit::Compress( void* block )
|
void ColourFit::Compress( void* block )
|
||||||
{
|
{
|
||||||
bool isDxt1 = ( ( m_flags & kDxt1 ) != 0 );
|
bool isDxt1 = ( ( m_flags & kDxt1 ) != 0 );
|
||||||
|
|
|
@ -36,7 +36,9 @@ class ColourSet;
|
||||||
class ColourFit
|
class ColourFit
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ColourFit( ColourSet const* colours, int flags );
|
ColourFit();
|
||||||
|
|
||||||
|
void SetColourSet( ColourSet const* colours, int flags );
|
||||||
|
|
||||||
void Compress( void* block );
|
void Compress( void* block );
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,14 @@
|
||||||
|
|
||||||
namespace squish {
|
namespace squish {
|
||||||
|
|
||||||
FastClusterFit::FastClusterFit( ColourSet const* colours, int flags ) :
|
FastClusterFit::FastClusterFit()
|
||||||
ColourFit( colours, flags )
|
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FastClusterFit::SetColourSet( ColourSet const* colours, int flags )
|
||||||
|
{
|
||||||
|
ColourFit::SetColourSet( colours, flags );
|
||||||
|
|
||||||
// initialise the best error
|
// initialise the best error
|
||||||
#if SQUISH_USE_SIMD
|
#if SQUISH_USE_SIMD
|
||||||
m_besterror = VEC4_CONST( FLT_MAX );
|
m_besterror = VEC4_CONST( FLT_MAX );
|
||||||
|
@ -102,7 +107,7 @@ struct Precomp {
|
||||||
static Precomp s_threeElement[153];
|
static Precomp s_threeElement[153];
|
||||||
static Precomp s_fourElement[969];
|
static Precomp s_fourElement[969];
|
||||||
|
|
||||||
void FastClusterFit::doPrecomputation()
|
void FastClusterFit::DoPrecomputation()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -177,7 +182,7 @@ void FastClusterFit::doPrecomputation()
|
||||||
//printf("%d four cluster elements\n", i);
|
//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
|
#if SQUISH_USE_SIMD
|
||||||
m_metric = Vec4(r, g, b, 0);
|
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;
|
m_metricSqr = m_metric * m_metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
float FastClusterFit::bestError() const
|
float FastClusterFit::GetBestError() const
|
||||||
{
|
{
|
||||||
#if SQUISH_USE_SIMD
|
#if SQUISH_USE_SIMD
|
||||||
Vec4 x = m_xxsum * m_metricSqr;
|
Vec4 x = m_xxsum * m_metricSqr;
|
||||||
|
|
|
@ -37,12 +37,14 @@ namespace squish {
|
||||||
class FastClusterFit : public ColourFit
|
class FastClusterFit : public ColourFit
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FastClusterFit( ColourSet const* colours, int flags );
|
FastClusterFit();
|
||||||
|
|
||||||
void setMetric(float r, float g, float b);
|
void SetColourSet( ColourSet const* colours, int flags );
|
||||||
float bestError() const;
|
|
||||||
|
|
||||||
static void doPrecomputation();
|
void SetMetric(float r, float g, float b);
|
||||||
|
float GetBestError() const;
|
||||||
|
|
||||||
|
static void DoPrecomputation();
|
||||||
|
|
||||||
// Make them public
|
// Make them public
|
||||||
virtual void Compress3( void* block );
|
virtual void Compress3( void* block );
|
||||||
|
|
|
@ -32,9 +32,14 @@
|
||||||
|
|
||||||
namespace squish {
|
namespace squish {
|
||||||
|
|
||||||
WeightedClusterFit::WeightedClusterFit( ColourSet const* colours, int flags ) :
|
WeightedClusterFit::WeightedClusterFit()
|
||||||
ColourFit( colours, flags )
|
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void WeightedClusterFit::SetColourSet( ColourSet const* colours, int flags )
|
||||||
|
{
|
||||||
|
ColourFit::SetColourSet( colours, flags );
|
||||||
|
|
||||||
// initialise the best error
|
// initialise the best error
|
||||||
#if SQUISH_USE_SIMD
|
#if SQUISH_USE_SIMD
|
||||||
m_besterror = VEC4_CONST( FLT_MAX );
|
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
|
#if SQUISH_USE_SIMD
|
||||||
m_metric = Vec4(r, g, b, 0);
|
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;
|
m_metricSqr = m_metric * m_metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
float WeightedClusterFit::bestError() const
|
float WeightedClusterFit::GetBestError() const
|
||||||
{
|
{
|
||||||
#if SQUISH_USE_SIMD
|
#if SQUISH_USE_SIMD
|
||||||
Vec4 x = m_xxsum * m_metricSqr;
|
Vec4 x = m_xxsum * m_metricSqr;
|
||||||
|
|
|
@ -37,12 +37,12 @@ namespace squish {
|
||||||
class WeightedClusterFit : public ColourFit
|
class WeightedClusterFit : public ColourFit
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WeightedClusterFit( ColourSet const* colours, int flags );
|
WeightedClusterFit();
|
||||||
|
|
||||||
void setMetric(float r, float g, float b);
|
void SetColourSet( ColourSet const* colours, int flags );
|
||||||
float bestError() const;
|
|
||||||
|
|
||||||
static void doPrecomputation();
|
void SetMetric(float r, float g, float b);
|
||||||
|
float GetBestError() const;
|
||||||
|
|
||||||
// Make them public
|
// Make them public
|
||||||
virtual void Compress3( void* block );
|
virtual void Compress3( void* block );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user