mirror of
https://github.com/Relintai/props.git
synced 2024-11-12 10:15:25 +01:00
Removed texture rects from TiledWallData. I realized it's not going to work like this.
This commit is contained in:
parent
68d448f5e1
commit
874c84e631
@ -87,31 +87,6 @@ void TiledWallData::remove_texture(const int index) {
|
||||
_textures.remove(index);
|
||||
}
|
||||
|
||||
Rect2 TiledWallData::get_texture_rect(const int index) const {
|
||||
if (_texture_rects.size() <= index) {
|
||||
return Rect2(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
return _texture_rects[index];
|
||||
}
|
||||
void TiledWallData::set_texture_rect(const int index, const Rect2 &rect) {
|
||||
if (_texture_rects.size() <= index) {
|
||||
int tr_start_index = _texture_rects.size() - 1;
|
||||
|
||||
if (tr_start_index < 0) {
|
||||
tr_start_index = 0;
|
||||
}
|
||||
|
||||
_texture_rects.resize(index + 1);
|
||||
|
||||
for (int i = tr_start_index; i < _texture_rects.size(); ++i) {
|
||||
_texture_rects.set(i, Rect2(0, 0, 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
_texture_rects.set(index, rect);
|
||||
}
|
||||
|
||||
int TiledWallData::get_texture_count() const {
|
||||
return _textures.size();
|
||||
}
|
||||
@ -160,31 +135,6 @@ int TiledWallData::get_flavour_texture_count() const {
|
||||
return _flavour_textures.size();
|
||||
}
|
||||
|
||||
Rect2 TiledWallData::get_flavour_texture_rect(const int index) const {
|
||||
if (_flavour_texture_rects.size() <= index) {
|
||||
return Rect2(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
return _flavour_texture_rects[index];
|
||||
}
|
||||
void TiledWallData::set_flavour_texture_rect(const int index, const Rect2 &rect) {
|
||||
if (_flavour_texture_rects.size() <= index) {
|
||||
int tr_start_index = _flavour_texture_rects.size() - 1;
|
||||
|
||||
if (tr_start_index < 0) {
|
||||
tr_start_index = 0;
|
||||
}
|
||||
|
||||
_flavour_texture_rects.resize(index + 1);
|
||||
|
||||
for (int i = tr_start_index; i < _flavour_texture_rects.size(); ++i) {
|
||||
_flavour_texture_rects.set(i, Rect2(0, 0, 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
_flavour_texture_rects.set(index, rect);
|
||||
}
|
||||
|
||||
Vector<Variant> TiledWallData::get_flavour_textures() {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _flavour_textures.size(); i++) {
|
||||
@ -299,37 +249,6 @@ void TiledWallData::_setup_cache(Ref<PropMaterialCache> cache) {
|
||||
}
|
||||
}
|
||||
|
||||
void TiledWallData::setup_rects(Ref<PropMaterialCache> cache) {
|
||||
call("_setup_rects", cache);
|
||||
}
|
||||
void TiledWallData::_setup_rects(Ref<PropMaterialCache> cache) {
|
||||
_texture_rects.clear();
|
||||
_texture_rects.resize(_textures.size());
|
||||
|
||||
for (int i = 0; i < _textures.size(); ++i) {
|
||||
const Ref<Texture> &t = _textures[i];
|
||||
|
||||
if (t.is_valid()) {
|
||||
Rect2 r = cache->texture_get_uv_rect(t);
|
||||
|
||||
_texture_rects.set(i, r);
|
||||
}
|
||||
}
|
||||
|
||||
_flavour_texture_rects.clear();
|
||||
_texture_rects.resize(_flavour_textures.size());
|
||||
|
||||
for (int i = 0; i < _flavour_textures.size(); ++i) {
|
||||
const Ref<Texture> &t = _flavour_textures[i];
|
||||
|
||||
if (t.is_valid()) {
|
||||
Rect2 r = cache->texture_get_uv_rect(t);
|
||||
|
||||
_texture_rects.set(i, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TiledWallData::copy_from(const Ref<TiledWallData> &tiled_wall_data) {
|
||||
ERR_FAIL_COND(!tiled_wall_data.is_valid());
|
||||
|
||||
@ -370,9 +289,6 @@ void TiledWallData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("add_texture", "texture"), &TiledWallData::add_texture);
|
||||
ClassDB::bind_method(D_METHOD("remove_texture", "index"), &TiledWallData::remove_texture);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_texture_rect", "index"), &TiledWallData::get_texture_rect);
|
||||
ClassDB::bind_method(D_METHOD("set_texture_rect", "index", "rect"), &TiledWallData::set_texture_rect);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_texture_count"), &TiledWallData::get_texture_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData::get_textures);
|
||||
@ -385,9 +301,6 @@ void TiledWallData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("add_tflavour_exture", "texture"), &TiledWallData::add_flavour_texture);
|
||||
ClassDB::bind_method(D_METHOD("remove_flavour_texture", "index"), &TiledWallData::remove_flavour_texture);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_flavour_texture_rect", "index"), &TiledWallData::get_flavour_texture_rect);
|
||||
ClassDB::bind_method(D_METHOD("set_flavour_texture_rect", "index", "rect"), &TiledWallData::set_flavour_texture_rect);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_flavour_texture_count"), &TiledWallData::get_flavour_texture_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_flavour_textures"), &TiledWallData::get_flavour_textures);
|
||||
@ -414,11 +327,6 @@ void TiledWallData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("setup_cache", "cache"), &TiledWallData::setup_cache);
|
||||
ClassDB::bind_method(D_METHOD("_setup_cache", "cache"), &TiledWallData::_setup_cache);
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_setup_rects", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("setup_rects", "cache"), &TiledWallData::setup_rects);
|
||||
ClassDB::bind_method(D_METHOD("_setup_rects", "cache"), &TiledWallData::_setup_rects);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData::copy_from);
|
||||
|
||||
BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_NONE);
|
||||
|
@ -72,9 +72,6 @@ public:
|
||||
void add_texture(const Ref<Texture> &texture);
|
||||
void remove_texture(const int index);
|
||||
|
||||
Rect2 get_texture_rect(const int index) const;
|
||||
void set_texture_rect(const int index, const Rect2 &rect);
|
||||
|
||||
int get_texture_count() const;
|
||||
|
||||
Vector<Variant> get_textures();
|
||||
@ -86,9 +83,6 @@ public:
|
||||
void add_flavour_texture(const Ref<Texture> &texture);
|
||||
void remove_flavour_texture(const int index);
|
||||
|
||||
Rect2 get_flavour_texture_rect(const int index) const;
|
||||
void set_flavour_texture_rect(const int index, const Rect2 &rect);
|
||||
|
||||
int get_flavour_texture_count() const;
|
||||
|
||||
Vector<Variant> get_flavour_textures();
|
||||
@ -111,16 +105,13 @@ public:
|
||||
void setup_cache(Ref<PropMaterialCache> cache);
|
||||
void _setup_cache(Ref<PropMaterialCache> cache);
|
||||
|
||||
void setup_rects(Ref<PropMaterialCache> cache);
|
||||
void _setup_rects(Ref<PropMaterialCache> cache);
|
||||
|
||||
void copy_from(const Ref<TiledWallData> &tiled_wall_data);
|
||||
|
||||
//Ref<Shape> get_collider_shape();
|
||||
|
||||
//generate mesh -> add mesh into
|
||||
//genmerate_mesh() -> generate_mesh() PropMesher
|
||||
//PropMesher->tiled wall mesh_wimple(w, h, TWD)
|
||||
//PropMesher->tiled wall mesh_wimple(w, h, TWD, cache)
|
||||
|
||||
TiledWallData();
|
||||
~TiledWallData();
|
||||
@ -132,11 +123,7 @@ private:
|
||||
TiledWallTilingType _tiling_type;
|
||||
|
||||
Vector<Ref<Texture>> _textures;
|
||||
Vector<Rect2> _texture_rects;
|
||||
|
||||
Vector<Ref<Texture>> _flavour_textures;
|
||||
Vector<Rect2> _flavour_texture_rects;
|
||||
|
||||
Vector<Ref<Material>> _materials;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user