mirror of
https://github.com/Relintai/terraman_2d.git
synced 2024-11-12 10:15:18 +01:00
Removed faces from the surfaces.
This commit is contained in:
parent
f722a9ea6b
commit
c5afc68256
@ -233,18 +233,16 @@ void Terrain2DLibraryMerger::refresh_rects() {
|
||||
Ref<Terrain2DSurfaceMerger> surface = Ref<Terrain2DSurfaceMerger>(_terra_surfaces[i]);
|
||||
|
||||
if (surface.is_valid()) {
|
||||
for (int j = 0; j < Terrain2DSurface::TERRAIN_2D_SIDES_COUNT; ++j) {
|
||||
Ref<Texture> tex = surface->get_texture(static_cast<Terrain2DSurface::Terrain2DSurfaceSides>(j));
|
||||
Ref<Texture> tex = surface->get_texture();
|
||||
|
||||
if (!tex.is_valid())
|
||||
continue;
|
||||
if (!tex.is_valid())
|
||||
continue;
|
||||
|
||||
if (!_packer->contains_texture(tex)) {
|
||||
texture_added = true;
|
||||
surface->set_region(static_cast<Terrain2DSurface::Terrain2DSurfaceSides>(j), _packer->add_texture(tex));
|
||||
} else {
|
||||
surface->set_region(static_cast<Terrain2DSurface::Terrain2DSurfaceSides>(j), _packer->get_texture(tex));
|
||||
}
|
||||
if (!_packer->contains_texture(tex)) {
|
||||
texture_added = true;
|
||||
surface->set_region(_packer->add_texture(tex));
|
||||
} else {
|
||||
surface->set_region(_packer->get_texture(tex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,18 +109,16 @@ void Terrain2DMaterialCachePCM::refresh_rects() {
|
||||
Ref<Terrain2DSurfaceMerger> surface = Ref<Terrain2DSurfaceMerger>(_surfaces[i]);
|
||||
|
||||
if (surface.is_valid()) {
|
||||
for (int j = 0; j < Terrain2DSurface::TERRAIN_2D_SIDES_COUNT; ++j) {
|
||||
Ref<Texture> tex = surface->get_texture(static_cast<Terrain2DSurface::Terrain2DSurfaceSides>(j));
|
||||
Ref<Texture> tex = surface->get_texture();
|
||||
|
||||
if (!tex.is_valid())
|
||||
continue;
|
||||
if (!tex.is_valid())
|
||||
continue;
|
||||
|
||||
if (!_packer->contains_texture(tex)) {
|
||||
texture_added = true;
|
||||
surface->set_region(static_cast<Terrain2DSurface::Terrain2DSurfaceSides>(j), _packer->add_texture(tex));
|
||||
} else {
|
||||
surface->set_region(static_cast<Terrain2DSurface::Terrain2DSurfaceSides>(j), _packer->get_texture(tex));
|
||||
}
|
||||
if (!_packer->contains_texture(tex)) {
|
||||
texture_added = true;
|
||||
surface->set_region(_packer->add_texture(tex));
|
||||
} else {
|
||||
surface->set_region(_packer->get_texture(tex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ void Terrain2DSurface::set_id(const int value) {
|
||||
_id = value;
|
||||
}
|
||||
|
||||
Rect2 Terrain2DSurface::get_rect(const Terrain2DSurfaceSides side) const {
|
||||
return _rects[side];
|
||||
Rect2 Terrain2DSurface::get_rect() const {
|
||||
return _rect;
|
||||
}
|
||||
void Terrain2DSurface::set_rect(const Terrain2DSurfaceSides side, const Rect2 &rect) {
|
||||
_rects[side] = rect;
|
||||
void Terrain2DSurface::set_rect(const Rect2 &rect) {
|
||||
_rect = rect;
|
||||
}
|
||||
|
||||
Ref<Terrain2DLibrary> Terrain2DSurface::get_library() const {
|
||||
@ -44,10 +44,10 @@ void Terrain2DSurface::set_library(Ref<Terrain2DLibrary> library) {
|
||||
_library = (*library);
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2 Terrain2DSurface::transform_uv(const Terrain2DSurfaceSides p_side, const Vector2 &p_uv) const {
|
||||
_FORCE_INLINE_ Vector2 Terrain2DSurface::transform_uv(const Vector2 &p_uv) const {
|
||||
Vector2 uv = p_uv;
|
||||
|
||||
Rect2 r = _rects[p_side];
|
||||
Rect2 r = _rect;
|
||||
|
||||
uv.x *= r.size.x;
|
||||
uv.y *= r.size.y;
|
||||
@ -57,10 +57,10 @@ _FORCE_INLINE_ Vector2 Terrain2DSurface::transform_uv(const Terrain2DSurfaceSide
|
||||
return uv;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Vector2 Terrain2DSurface::transform_uv_scaled(const Terrain2DSurfaceSides p_side, const Vector2 &p_uv, const int p_current_x, const int p_current_y, const int p_max) const {
|
||||
_FORCE_INLINE_ Vector2 Terrain2DSurface::transform_uv_scaled(const Vector2 &p_uv, const int p_current_x, const int p_current_y, const int p_max) const {
|
||||
Vector2 uv = p_uv;
|
||||
|
||||
Rect2 r = _rects[p_side];
|
||||
Rect2 r = _rect;
|
||||
|
||||
float sizex = r.size.x / static_cast<float>(p_max);
|
||||
float sizey = r.size.x / static_cast<float>(p_max);
|
||||
@ -96,17 +96,11 @@ void Terrain2DSurface::_bind_methods() {
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "voxel_name"), "set_name", "get_name");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_rect", "side"), &Terrain2DSurface::get_rect);
|
||||
ClassDB::bind_method(D_METHOD("set_rect", "side", "rect"), &Terrain2DSurface::set_rect);
|
||||
ClassDB::bind_method(D_METHOD("get_rect"), &Terrain2DSurface::get_rect);
|
||||
ClassDB::bind_method(D_METHOD("set_rect", "rect"), &Terrain2DSurface::set_rect);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("transform_uv", "side", "uv"), &Terrain2DSurface::transform_uv);
|
||||
ClassDB::bind_method(D_METHOD("transform_uv_scaled", "side", "uv", "p_current_x", "p_current_y", "max"), &Terrain2DSurface::transform_uv_scaled);
|
||||
ClassDB::bind_method(D_METHOD("transform_uv", "uv"), &Terrain2DSurface::transform_uv);
|
||||
ClassDB::bind_method(D_METHOD("transform_uv_scaled", "uv", "p_current_x", "p_current_y", "max"), &Terrain2DSurface::transform_uv_scaled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("refresh_rects"), &Terrain2DSurface::refresh_rects);
|
||||
|
||||
BIND_ENUM_CONSTANT(TERRAIN_2D_SIDE_TOP);
|
||||
BIND_ENUM_CONSTANT(TERRAIN_2D_SIDE_BOTTOM);
|
||||
BIND_ENUM_CONSTANT(TERRAIN_2D_SIDE_SIDE);
|
||||
|
||||
BIND_CONSTANT(TERRAIN_2D_SIDES_COUNT);
|
||||
}
|
||||
|
@ -47,43 +47,17 @@ class Terrain2DSurface : public Resource {
|
||||
GDCLASS(Terrain2DSurface, Resource)
|
||||
|
||||
public:
|
||||
/*
|
||||
_____
|
||||
/_____/I
|
||||
I I I <- BACK
|
||||
I F I I
|
||||
I_____I/
|
||||
|
||||
|
||||
I y
|
||||
I I
|
||||
O----- x I B
|
||||
/ I F I /
|
||||
/ z+ I ---I/
|
||||
*/
|
||||
|
||||
enum Terrain2DSurfaceSides {
|
||||
TERRAIN_2D_SIDE_TOP = 0,
|
||||
TERRAIN_2D_SIDE_BOTTOM = 1,
|
||||
TERRAIN_2D_SIDE_SIDE = 2,
|
||||
};
|
||||
|
||||
enum {
|
||||
TERRAIN_2D_SIDES_COUNT = 3,
|
||||
TERRAIN_2D_SIDES_ARRAY_SIZE = TERRAIN_2D_SIDES_COUNT * 2,
|
||||
};
|
||||
|
||||
int get_id() const;
|
||||
void set_id(const int value);
|
||||
|
||||
Rect2 get_rect(const Terrain2DSurfaceSides side) const;
|
||||
void set_rect(const Terrain2DSurfaceSides side, const Rect2 &rect);
|
||||
Rect2 get_rect() const;
|
||||
void set_rect(const Rect2 &rect);
|
||||
|
||||
Ref<Terrain2DLibrary> get_library() const;
|
||||
void set_library(Ref<Terrain2DLibrary> library);
|
||||
|
||||
Vector2 transform_uv(const Terrain2DSurfaceSides p_side, const Vector2 &p_uv) const;
|
||||
Vector2 transform_uv_scaled(const Terrain2DSurfaceSides p_side, const Vector2 &p_uv, const int p_current_x, const int p_current_y, const int p_max) const;
|
||||
Vector2 transform_uv(const Vector2 &p_uv) const;
|
||||
Vector2 transform_uv_scaled(const Vector2 &p_uv, const int p_current_x, const int p_current_y, const int p_max) const;
|
||||
|
||||
virtual void refresh_rects();
|
||||
|
||||
@ -99,9 +73,7 @@ protected:
|
||||
int _mesher_index;
|
||||
bool _transparent;
|
||||
bool _liquid;
|
||||
Rect2 _rects[TERRAIN_2D_SIDES_COUNT];
|
||||
Rect2 _rect;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(Terrain2DSurface::Terrain2DSurfaceSides);
|
||||
|
||||
#endif
|
||||
|
@ -30,70 +30,62 @@ SOFTWARE.
|
||||
#define Texture Texture2D
|
||||
#endif
|
||||
|
||||
Ref<AtlasTexture> Terrain2DSurfaceMerger::get_region(const Terrain2DSurfaceSides side) {
|
||||
return _regions[side];
|
||||
Ref<AtlasTexture> Terrain2DSurfaceMerger::get_region() {
|
||||
return _region;
|
||||
}
|
||||
void Terrain2DSurfaceMerger::set_region(const Terrain2DSurfaceSides side, const Ref<AtlasTexture> &texture) {
|
||||
_regions[side] = texture;
|
||||
void Terrain2DSurfaceMerger::set_region(const Ref<AtlasTexture> &texture) {
|
||||
_region = texture;
|
||||
}
|
||||
|
||||
Ref<Texture> Terrain2DSurfaceMerger::get_texture(const Terrain2DSurfaceSides side) {
|
||||
return _textures[side];
|
||||
Ref<Texture> Terrain2DSurfaceMerger::get_texture() {
|
||||
return _texture;
|
||||
}
|
||||
void Terrain2DSurfaceMerger::set_texture(const Terrain2DSurfaceSides side, const Ref<Texture> &texture) {
|
||||
_textures[side] = texture;
|
||||
void Terrain2DSurfaceMerger::set_texture(const Ref<Texture> &texture) {
|
||||
_texture = texture;
|
||||
}
|
||||
|
||||
void Terrain2DSurfaceMerger::refresh_rects() {
|
||||
for (int i = 0; i < TERRAIN_2D_SIDES_COUNT; ++i) {
|
||||
if (!_regions[i].is_valid()) {
|
||||
_rects[i] = Rect2();
|
||||
continue;
|
||||
}
|
||||
|
||||
Ref<AtlasTexture> at = _regions[i];
|
||||
Ref<Texture> tex = at->get_atlas();
|
||||
|
||||
if (!tex.is_valid()) {
|
||||
_rects[i] = Rect2();
|
||||
continue;
|
||||
}
|
||||
|
||||
Rect2 region = at->get_region();
|
||||
float w = tex->get_width();
|
||||
float h = tex->get_height();
|
||||
|
||||
Rect2 r;
|
||||
|
||||
r.position.x = region.position.x / w;
|
||||
r.position.y = region.position.y / h;
|
||||
r.size.x = region.size.x / w;
|
||||
r.size.y = region.size.y / h;
|
||||
|
||||
_rects[i] = r;
|
||||
if (!_region.is_valid()) {
|
||||
_rect = Rect2();
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<AtlasTexture> at = _region;
|
||||
Ref<Texture> tex = at->get_atlas();
|
||||
|
||||
if (!tex.is_valid()) {
|
||||
_rect = Rect2();
|
||||
return;
|
||||
}
|
||||
|
||||
Rect2 region = at->get_region();
|
||||
float w = at->get_width();
|
||||
float h = at->get_height();
|
||||
|
||||
Rect2 r;
|
||||
|
||||
r.position.x = region.position.x / w;
|
||||
r.position.y = region.position.y / h;
|
||||
r.size.x = region.size.x / w;
|
||||
r.size.y = region.size.y / h;
|
||||
|
||||
_rect = r;
|
||||
}
|
||||
|
||||
Terrain2DSurfaceMerger::Terrain2DSurfaceMerger() {
|
||||
for (int i = 0; i < TERRAIN_2D_SIDES_COUNT; ++i) {
|
||||
_regions[i].unref();
|
||||
_textures[i].unref();
|
||||
}
|
||||
_region.unref();
|
||||
_texture.unref();
|
||||
}
|
||||
|
||||
Terrain2DSurfaceMerger::~Terrain2DSurfaceMerger() {
|
||||
}
|
||||
|
||||
void Terrain2DSurfaceMerger::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_region", "side"), &Terrain2DSurfaceMerger::get_region);
|
||||
ClassDB::bind_method(D_METHOD("set_region", "side", "texture"), &Terrain2DSurfaceMerger::set_region);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "region_top", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region", TERRAIN_2D_SIDE_TOP);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "region_bottom", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region", TERRAIN_2D_SIDE_BOTTOM);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "region_side", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region", TERRAIN_2D_SIDE_SIDE);
|
||||
ClassDB::bind_method(D_METHOD("get_region"), &Terrain2DSurfaceMerger::get_region);
|
||||
ClassDB::bind_method(D_METHOD("set_region", "texture"), &Terrain2DSurfaceMerger::set_region);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "region", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_texture", "side"), &Terrain2DSurfaceMerger::get_texture);
|
||||
ClassDB::bind_method(D_METHOD("set_texture", "side", "texture"), &Terrain2DSurfaceMerger::set_texture);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_top", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TERRAIN_2D_SIDE_TOP);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_bottom", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TERRAIN_2D_SIDE_BOTTOM);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_side", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TERRAIN_2D_SIDE_SIDE);
|
||||
ClassDB::bind_method(D_METHOD("get_texture"), &Terrain2DSurfaceMerger::get_texture);
|
||||
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Terrain2DSurfaceMerger::set_texture);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ class Terrain2DSurfaceMerger : public Terrain2DSurface {
|
||||
GDCLASS(Terrain2DSurfaceMerger, Terrain2DSurface)
|
||||
|
||||
public:
|
||||
Ref<AtlasTexture> get_region(const Terrain2DSurfaceSides side);
|
||||
void set_region(const Terrain2DSurfaceSides side, const Ref<AtlasTexture> &texture);
|
||||
Ref<AtlasTexture> get_region();
|
||||
void set_region(const Ref<AtlasTexture> &texture);
|
||||
|
||||
Ref<Texture> get_texture(const Terrain2DSurfaceSides side);
|
||||
void set_texture(const Terrain2DSurfaceSides side, const Ref<Texture> &texture);
|
||||
Ref<Texture> get_texture();
|
||||
void set_texture(const Ref<Texture> &texture);
|
||||
|
||||
void refresh_rects();
|
||||
|
||||
@ -54,8 +54,8 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<AtlasTexture> _regions[TERRAIN_2D_SIDES_COUNT];
|
||||
Ref<Texture> _textures[TERRAIN_2D_SIDES_COUNT];
|
||||
Ref<AtlasTexture> _region;
|
||||
Ref<Texture> _texture;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -24,26 +24,18 @@ SOFTWARE.
|
||||
|
||||
#include "terrain_2d_library_simple.h"
|
||||
|
||||
int Terrain2DSurfaceSimple::get_atlas_x(const Terrain2DSurfaceSides side) const {
|
||||
int indx = (side * 2);
|
||||
|
||||
return _atlas_positions[indx];
|
||||
int Terrain2DSurfaceSimple::get_atlas_x() const {
|
||||
return _atlas_position_x;
|
||||
}
|
||||
void Terrain2DSurfaceSimple::set_atlas_x(const Terrain2DSurfaceSides side, int value) {
|
||||
int indx = (side * 2);
|
||||
|
||||
_atlas_positions[indx] = value;
|
||||
void Terrain2DSurfaceSimple::set_atlas_x(int value) {
|
||||
_atlas_position_x = value;
|
||||
}
|
||||
|
||||
int Terrain2DSurfaceSimple::get_atlas_y(const Terrain2DSurfaceSides side) const {
|
||||
int indx = (side * 2) + 1;
|
||||
|
||||
return _atlas_positions[indx];
|
||||
int Terrain2DSurfaceSimple::get_atlas_y() const {
|
||||
return _atlas_position_y;
|
||||
}
|
||||
void Terrain2DSurfaceSimple::set_atlas_y(const Terrain2DSurfaceSides side, int value) {
|
||||
int indx = (side * 2) + 1;
|
||||
|
||||
_atlas_positions[indx] = value;
|
||||
void Terrain2DSurfaceSimple::set_atlas_y(int value) {
|
||||
_atlas_position_y = value;
|
||||
}
|
||||
|
||||
void Terrain2DSurfaceSimple::refresh_rects() {
|
||||
@ -51,44 +43,34 @@ void Terrain2DSurfaceSimple::refresh_rects() {
|
||||
|
||||
ERR_FAIL_COND(lib == NULL);
|
||||
|
||||
for (int i = 0; i < TERRAIN_2D_SIDES_COUNT; ++i) {
|
||||
float culomn = 1.0 / static_cast<float>(lib->get_atlas_columns());
|
||||
float row = 1.0 / static_cast<float>(lib->get_atlas_rows());
|
||||
float culomn = 1.0 / static_cast<float>(lib->get_atlas_columns());
|
||||
float row = 1.0 / static_cast<float>(lib->get_atlas_rows());
|
||||
|
||||
Rect2 r;
|
||||
Rect2 r;
|
||||
|
||||
r.position.x = _atlas_positions[i * 2] * culomn;
|
||||
r.position.y = _atlas_positions[i * 2 + 1] * row;
|
||||
r.position.x = _atlas_position_x * culomn;
|
||||
r.position.y = _atlas_position_y * row;
|
||||
|
||||
r.size.x = culomn;
|
||||
r.size.y = row;
|
||||
r.size.x = culomn;
|
||||
r.size.y = row;
|
||||
|
||||
_rects[i] = r;
|
||||
}
|
||||
_rect = r;
|
||||
}
|
||||
|
||||
Terrain2DSurfaceSimple::Terrain2DSurfaceSimple() {
|
||||
for (int i = 0; i < TERRAIN_2D_SIDES_ARRAY_SIZE; ++i) {
|
||||
_atlas_positions[i] = 0;
|
||||
}
|
||||
_atlas_position_x = 0;
|
||||
_atlas_position_y = 0;
|
||||
}
|
||||
|
||||
Terrain2DSurfaceSimple::~Terrain2DSurfaceSimple() {
|
||||
}
|
||||
|
||||
void Terrain2DSurfaceSimple::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_atlas_x", "side"), &Terrain2DSurfaceSimple::get_atlas_x);
|
||||
ClassDB::bind_method(D_METHOD("set_atlas_x", "side", "value"), &Terrain2DSurfaceSimple::set_atlas_x);
|
||||
ClassDB::bind_method(D_METHOD("get_atlas_x"), &Terrain2DSurfaceSimple::get_atlas_x);
|
||||
ClassDB::bind_method(D_METHOD("set_atlas_x", "value"), &Terrain2DSurfaceSimple::set_atlas_x);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "atlas_x"), "set_atlas_x", "get_atlas_x");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_atlas_y", "side"), &Terrain2DSurfaceSimple::get_atlas_y);
|
||||
ClassDB::bind_method(D_METHOD("set_atlas_y", "side", "value"), &Terrain2DSurfaceSimple::set_atlas_y);
|
||||
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "top_atlas_x"), "set_atlas_x", "get_atlas_x", TERRAIN_2D_SIDE_TOP);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "top_atlas_y"), "set_atlas_y", "get_atlas_y", TERRAIN_2D_SIDE_TOP);
|
||||
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "bottom_atlas_x"), "set_atlas_x", "get_atlas_x", TERRAIN_2D_SIDE_BOTTOM);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "bottom_atlas_y"), "set_atlas_y", "get_atlas_y", TERRAIN_2D_SIDE_BOTTOM);
|
||||
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "side_atlas_x"), "set_atlas_x", "get_atlas_x", TERRAIN_2D_SIDE_SIDE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::INT, "side_atlas_y"), "set_atlas_y", "get_atlas_y", TERRAIN_2D_SIDE_SIDE);
|
||||
ClassDB::bind_method(D_METHOD("get_atlas_y"), &Terrain2DSurfaceSimple::get_atlas_y);
|
||||
ClassDB::bind_method(D_METHOD("set_atlas_y", "value"), &Terrain2DSurfaceSimple::set_atlas_y);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "atlas_y"), "set_atlas_y", "get_atlas_y");
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ class Terrain2DSurfaceSimple : public Terrain2DSurface {
|
||||
GDCLASS(Terrain2DSurfaceSimple, Terrain2DSurface)
|
||||
|
||||
public:
|
||||
int get_atlas_x(const Terrain2DSurfaceSides side) const;
|
||||
void set_atlas_x(const Terrain2DSurfaceSides side, int value);
|
||||
int get_atlas_x() const;
|
||||
void set_atlas_x(int value);
|
||||
|
||||
int get_atlas_y(const Terrain2DSurfaceSides side) const;
|
||||
void set_atlas_y(const Terrain2DSurfaceSides side, int value);
|
||||
int get_atlas_y() const;
|
||||
void set_atlas_y(int value);
|
||||
|
||||
void refresh_rects();
|
||||
|
||||
@ -44,7 +44,8 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _atlas_positions[TERRAIN_2D_SIDES_ARRAY_SIZE];
|
||||
int _atlas_position_x;
|
||||
int _atlas_position_y;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -154,10 +154,10 @@ void Terrain2DMesherBlocky::add_chunk_normal(Ref<Terrain2DChunkDefault> chunk) {
|
||||
add_indices(vc + 0);
|
||||
|
||||
Vector2 uvs[] = {
|
||||
surface->transform_uv_scaled(Terrain2DSurface::TERRAIN_2D_SIDE_TOP, Vector2(1, 0), x % get_texture_scale(), y % get_texture_scale(), get_texture_scale()),
|
||||
surface->transform_uv_scaled(Terrain2DSurface::TERRAIN_2D_SIDE_TOP, Vector2(0, 0), x % get_texture_scale(), y % get_texture_scale(), get_texture_scale()),
|
||||
surface->transform_uv_scaled(Terrain2DSurface::TERRAIN_2D_SIDE_TOP, Vector2(0, 1), x % get_texture_scale(), y % get_texture_scale(), get_texture_scale()),
|
||||
surface->transform_uv_scaled(Terrain2DSurface::TERRAIN_2D_SIDE_TOP, Vector2(1, 1), x % get_texture_scale(), y % get_texture_scale(), get_texture_scale())
|
||||
surface->transform_uv_scaled(Vector2(1, 0), x % get_texture_scale(), y % get_texture_scale(), get_texture_scale()),
|
||||
surface->transform_uv_scaled(Vector2(0, 0), x % get_texture_scale(), y % get_texture_scale(), get_texture_scale()),
|
||||
surface->transform_uv_scaled(Vector2(0, 1), x % get_texture_scale(), y % get_texture_scale(), get_texture_scale()),
|
||||
surface->transform_uv_scaled(Vector2(1, 1), x % get_texture_scale(), y % get_texture_scale(), get_texture_scale())
|
||||
};
|
||||
|
||||
int xx = (x + 1) * cell_size_x;
|
||||
|
Loading…
Reference in New Issue
Block a user