diff --git a/modules/wfc/image_indexer.cpp b/modules/wfc/image_indexer.cpp index 29d3636fd..204e5b3c0 100644 --- a/modules/wfc/image_indexer.cpp +++ b/modules/wfc/image_indexer.cpp @@ -4,15 +4,14 @@ PoolColorArray ImageIndexer::get_colors() { return _colors; } -PoolIntArray ImageIndexer::get_color_indices() { - return _color_indices; -} -void ImageIndexer::index_image(Ref image) { - ERR_FAIL_COND(!image.is_valid()); +PoolIntArray ImageIndexer::index_image(Ref image) { + if(!image.is_valid()) { + return PoolIntArray(); + } _colors.resize(0); - _color_indices.resize(0); + PoolIntArray color_indices; image->lock(); @@ -30,16 +29,17 @@ void ImageIndexer::index_image(Ref image) { _col_map.set(c, color_index); } - _color_indices.push_back(color_index); + color_indices.push_back(color_index); } } image->unlock(); + + return color_indices; } void ImageIndexer::reset() { _colors.resize(0); - _color_indices.resize(0); _col_map.clear(); } @@ -72,7 +72,6 @@ ImageIndexer::~ImageIndexer() { void ImageIndexer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_colors"), &ImageIndexer::get_colors); - ClassDB::bind_method(D_METHOD("get_color_indices"), &ImageIndexer::get_color_indices); ClassDB::bind_method(D_METHOD("index_image", "image"), &ImageIndexer::index_image); ClassDB::bind_method(D_METHOD("reset"), &ImageIndexer::reset); ClassDB::bind_method(D_METHOD("indices_to_argb8_data", "indices"), &ImageIndexer::indices_to_argb8_data); diff --git a/modules/wfc/image_indexer.h b/modules/wfc/image_indexer.h index 0d2569882..b4c75552b 100644 --- a/modules/wfc/image_indexer.h +++ b/modules/wfc/image_indexer.h @@ -11,9 +11,8 @@ class ImageIndexer : public Reference { public: PoolColorArray get_colors(); - PoolIntArray get_color_indices(); - void index_image(Ref image); + PoolIntArray index_image(Ref image); void reset(); PoolByteArray indices_to_argb8_data(const PoolIntArray &indices); @@ -26,7 +25,6 @@ protected: private: PoolColorArray _colors; - PoolIntArray _color_indices; OAHashMap _col_map; };