diff --git a/SCsub b/SCsub index c0a4920..471f19f 100644 --- a/SCsub +++ b/SCsub @@ -2,5 +2,5 @@ Import('env') env.add_source_files(env.modules_sources,"register_types.cpp") -env.add_source_files(env.modules_sources,"merge_texture.cpp") +env.add_source_files(env.modules_sources,"texture_packer.cpp") env.add_source_files(env.modules_sources,"rectpack2D/pack.cpp") diff --git a/register_types.cpp b/register_types.cpp index 1f21041..f858bd7 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -1,9 +1,9 @@ #include "register_types.h" -#include "merge_texture.h" +#include "texture_packer.h" void register_texture_packer_types() { - ClassDB::register_class(); + ClassDB::register_class(); } void unregister_texture_packer_types() { diff --git a/merge_texture.cpp b/texture_packer.cpp similarity index 76% rename from merge_texture.cpp rename to texture_packer.cpp index 36905e2..d86934a 100644 --- a/merge_texture.cpp +++ b/texture_packer.cpp @@ -1,6 +1,6 @@ -#include "merge_texture.h" +#include "texture_packer.h" -Ref MergeTexture::add_texture(Ref texture) { +Ref TexturePacker::add_texture(Ref texture) { for (int i = 0; i < _rects.size(); ++i) { rect_xywhf *r = _rects.get(i); @@ -28,19 +28,19 @@ Ref MergeTexture::add_texture(Ref texture) { return tex; } -Ref MergeTexture::get_original_texture(int index) { +Ref TexturePacker::get_original_texture(int index) { ERR_FAIL_INDEX_V(index, _rects.size(), Ref()); return _rects.get(index)->original_texture; } -Ref MergeTexture::get_texture(int index) { +Ref TexturePacker::get_texture(int index) { ERR_FAIL_INDEX_V(index, _rects.size(), Ref()); return _rects.get(index)->atlas_texture; } -void MergeTexture::remove_texture_index(int index) { +void TexturePacker::remove_texture_index(int index) { ERR_FAIL_INDEX(index, _rects.size()); rect_xywhf *r = _rects.get(index); @@ -52,7 +52,7 @@ void MergeTexture::remove_texture_index(int index) { memdelete(r); } -void MergeTexture::remove_texture(Ref texture) { +void TexturePacker::remove_texture(Ref texture) { for (int i = 0; i < _rects.size(); ++i) { rect_xywhf *r = _rects.get(i); @@ -64,20 +64,20 @@ void MergeTexture::remove_texture(Ref texture) { } } -int MergeTexture::get_texture_count() { +int TexturePacker::get_texture_count() { return _rects.size(); } -Ref MergeTexture::get_generated_texture(int index) { +Ref TexturePacker::get_generated_texture(int index) { ERR_FAIL_INDEX_V(index, _generated_textures.size(), Ref()); return _generated_textures.get(index); } -int MergeTexture::get_generated_texture_count() { +int TexturePacker::get_generated_texture_count() { return _generated_textures.size(); } -void MergeTexture::merge() { +void TexturePacker::merge() { _bins.clear(); if (pack(_rects.ptr(), _rects.size(), 1024, false, _bins)) { @@ -143,7 +143,7 @@ void MergeTexture::merge() { } } -String MergeTexture::test() { +String TexturePacker::test() { String res = ""; const int RECTS = 200; @@ -177,10 +177,10 @@ String MergeTexture::test() { return res; } -MergeTexture::MergeTexture() { +TexturePacker::TexturePacker() { } -MergeTexture::~MergeTexture() { +TexturePacker::~TexturePacker() { _bins.clear(); @@ -196,18 +196,18 @@ MergeTexture::~MergeTexture() { _rects.clear(); } -void MergeTexture::_bind_methods() { - ClassDB::bind_method(D_METHOD("test"), &MergeTexture::test); +void TexturePacker::_bind_methods() { + ClassDB::bind_method(D_METHOD("test"), &TexturePacker::test); - ClassDB::bind_method(D_METHOD("add_texture", "texture"), &MergeTexture::add_texture); - ClassDB::bind_method(D_METHOD("get_texture", "index"), &MergeTexture::get_texture); - ClassDB::bind_method(D_METHOD("get_original_texture", "index"), &MergeTexture::get_original_texture); - ClassDB::bind_method(D_METHOD("remove_texture_index", "index"), &MergeTexture::remove_texture_index); - ClassDB::bind_method(D_METHOD("remove_texture", "texture"), &MergeTexture::remove_texture); - ClassDB::bind_method(D_METHOD("get_texture_count"), &MergeTexture::get_texture_count); + ClassDB::bind_method(D_METHOD("add_texture", "texture"), &TexturePacker::add_texture); + ClassDB::bind_method(D_METHOD("get_texture", "index"), &TexturePacker::get_texture); + ClassDB::bind_method(D_METHOD("get_original_texture", "index"), &TexturePacker::get_original_texture); + ClassDB::bind_method(D_METHOD("remove_texture_index", "index"), &TexturePacker::remove_texture_index); + ClassDB::bind_method(D_METHOD("remove_texture", "texture"), &TexturePacker::remove_texture); + ClassDB::bind_method(D_METHOD("get_texture_count"), &TexturePacker::get_texture_count); - ClassDB::bind_method(D_METHOD("get_generated_texture", "index"), &MergeTexture::get_generated_texture); - ClassDB::bind_method(D_METHOD("get_generated_texture_count"), &MergeTexture::get_generated_texture_count); + ClassDB::bind_method(D_METHOD("get_generated_texture", "index"), &TexturePacker::get_generated_texture); + ClassDB::bind_method(D_METHOD("get_generated_texture_count"), &TexturePacker::get_generated_texture_count); - ClassDB::bind_method(D_METHOD("merge"), &MergeTexture::merge); + ClassDB::bind_method(D_METHOD("merge"), &TexturePacker::merge); } diff --git a/merge_texture.h b/texture_packer.h similarity index 83% rename from merge_texture.h rename to texture_packer.h index 7719e38..d60fdfa 100644 --- a/merge_texture.h +++ b/texture_packer.h @@ -1,5 +1,5 @@ -#ifndef MERGE_TEXTURE_H -#define MERGE_TEXTURE_H +#ifndef TEXTURE_PACKER_H +#define TEXTURE_PACKER_H #include "core/image.h" #include "core/reference.h" @@ -11,8 +11,8 @@ #include "rectpack2D/pack.h" //Rename to TexturePacker -class MergeTexture : public Reference { - GDCLASS(MergeTexture, Reference); +class TexturePacker : public Reference { + GDCLASS(TexturePacker, Reference); public: Ref add_texture(Ref texture); @@ -29,8 +29,8 @@ public: String test(); - MergeTexture(); - ~MergeTexture(); + TexturePacker(); + ~TexturePacker(); protected: static void _bind_methods();