Add create minimal set option.
This commit is contained in:
parent
0959798ff6
commit
ad6597b75e
@ -28,12 +28,11 @@
|
||||
namespace squish {
|
||||
|
||||
// @@ Add flags:
|
||||
// - FindColorMatch
|
||||
// - DXT1a
|
||||
// - MatchTransparent
|
||||
// - WeightColorByAlpha
|
||||
|
||||
|
||||
ColourSet::ColourSet( u8 const* rgba, int flags )
|
||||
ColourSet::ColourSet( u8 const* rgba, int flags, bool createMinimalSet/*=false*/ )
|
||||
: m_count( 0 ),
|
||||
m_transparent( false )
|
||||
{
|
||||
@ -49,26 +48,11 @@ ColourSet::ColourSet( u8 const* rgba, int flags )
|
||||
{
|
||||
m_remap[i] = -1;
|
||||
m_transparent = true;
|
||||
// continue;
|
||||
if (createMinimalSet) continue;
|
||||
}
|
||||
|
||||
#if 1
|
||||
// normalise coordinates to [0,1]
|
||||
float x = ( float )rgba[4*i + 2] / 255.0f;
|
||||
float y = ( float )rgba[4*i + 1] / 255.0f;
|
||||
float z = ( float )rgba[4*i + 0] / 255.0f;
|
||||
|
||||
// ensure there is always non-zero weight even for zero alpha
|
||||
float w = ( float )( rgba[4*i + 3] + 1 ) / 256.0f;
|
||||
|
||||
// add the point
|
||||
m_points[m_count] = Vec3( x, y, z );
|
||||
m_weights[m_count] = ( weightByAlpha ? w : 1.0f );
|
||||
m_remap[i] = m_count;
|
||||
|
||||
// advance
|
||||
++m_count;
|
||||
#else
|
||||
if (createMinimalSet)
|
||||
{
|
||||
// loop over previous points for a match
|
||||
for( int j = 0;; ++j )
|
||||
{
|
||||
@ -97,7 +81,8 @@ ColourSet::ColourSet( u8 const* rgba, int flags )
|
||||
bool match = ( rgba[4*i] == rgba[4*j] )
|
||||
&& ( rgba[4*i + 1] == rgba[4*j + 1] )
|
||||
&& ( rgba[4*i + 2] == rgba[4*j + 2] )
|
||||
&& ( rgba[4*j + 3] != 0 || !isDxt1 );
|
||||
&& ( rgba[4*j + 3] != 0 || !isDxt1 ); // @@ I think this check is not necessary.
|
||||
|
||||
if( match )
|
||||
{
|
||||
// get the index of the match
|
||||
@ -112,7 +97,25 @@ ColourSet::ColourSet( u8 const* rgba, int flags )
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// normalise coordinates to [0,1]
|
||||
float x = ( float )rgba[4*i + 2] / 255.0f;
|
||||
float y = ( float )rgba[4*i + 1] / 255.0f;
|
||||
float z = ( float )rgba[4*i + 0] / 255.0f;
|
||||
|
||||
// ensure there is always non-zero weight even for zero alpha
|
||||
float w = ( float )( rgba[4*i + 3] + 1 ) / 256.0f;
|
||||
|
||||
// add the point
|
||||
m_points[m_count] = Vec3( x, y, z );
|
||||
m_weights[m_count] = ( weightByAlpha ? w : 1.0f );
|
||||
m_remap[i] = m_count;
|
||||
|
||||
// advance
|
||||
++m_count;
|
||||
}
|
||||
}
|
||||
|
||||
#if SQUISH_USE_SIMD
|
||||
|
@ -37,7 +37,7 @@ namespace squish {
|
||||
class ColourSet
|
||||
{
|
||||
public:
|
||||
ColourSet( u8 const* rgba, int flags );
|
||||
ColourSet( u8 const* rgba, int flags, bool createMinimalSet = false );
|
||||
|
||||
int GetCount() const { return m_count; }
|
||||
Vec3 const* GetPoints() const { return m_points; }
|
||||
|
Loading…
Reference in New Issue
Block a user