mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-24 12:47:12 +01:00
Work on fixing compile when layered tile maps are enabled.
This commit is contained in:
parent
37e287d86d
commit
b59530099e
@ -33,8 +33,8 @@
|
|||||||
#include "layered_tile_map.compat.inc"
|
#include "layered_tile_map.compat.inc"
|
||||||
|
|
||||||
#include "core/core_string_names.h"
|
#include "core/core_string_names.h"
|
||||||
#include "scene/2d/tile_map_layer.h"
|
#include "layered_tile_map_layer.h"
|
||||||
#include "scene/gui/control.h"
|
#include "scene/main/control.h"
|
||||||
|
|
||||||
#define TILEMAP_CALL_FOR_LAYER(layer, function, ...) \
|
#define TILEMAP_CALL_FOR_LAYER(layer, function, ...) \
|
||||||
if (layer < 0) { \
|
if (layer < 0) { \
|
||||||
@ -105,7 +105,10 @@ void LayeredTileMap::set_rendering_quadrant_size(int p_size) {
|
|||||||
ERR_FAIL_COND_MSG(p_size < 1, "LayeredTileMapQuadrant size cannot be smaller than 1.");
|
ERR_FAIL_COND_MSG(p_size < 1, "LayeredTileMapQuadrant size cannot be smaller than 1.");
|
||||||
|
|
||||||
rendering_quadrant_size = p_size;
|
rendering_quadrant_size = p_size;
|
||||||
for (LayeredTileMapLayer *layer : layers) {
|
|
||||||
|
for (uint32_t i = 0; i < layers.size(); ++i) {
|
||||||
|
LayeredTileMapLayer *layer = layers[i];
|
||||||
|
|
||||||
layer->set_rendering_quadrant_size(p_size);
|
layer->set_rendering_quadrant_size(p_size);
|
||||||
}
|
}
|
||||||
_emit_changed();
|
_emit_changed();
|
||||||
@ -115,7 +118,7 @@ int LayeredTileMap::get_rendering_quadrant_size() const {
|
|||||||
return rendering_quadrant_size;
|
return rendering_quadrant_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<LayeredTileSet> p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame, Color p_modulation, const TileData *p_tile_data_override, real_t p_normalized_animation_offset) {
|
void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<LayeredTileSet> p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame, Color p_modulation, const LayeredTileData *p_tile_data_override, real_t p_normalized_animation_offset) {
|
||||||
ERR_FAIL_COND(!p_tile_set.is_valid());
|
ERR_FAIL_COND(!p_tile_set.is_valid());
|
||||||
ERR_FAIL_COND(!p_tile_set->has_source(p_atlas_source_id));
|
ERR_FAIL_COND(!p_tile_set->has_source(p_atlas_source_id));
|
||||||
ERR_FAIL_COND(!p_tile_set->get_source(p_atlas_source_id)->has_tile(p_atlas_coords));
|
ERR_FAIL_COND(!p_tile_set->get_source(p_atlas_source_id)->has_tile(p_atlas_coords));
|
||||||
@ -141,7 +144,7 @@ void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get tile data.
|
// Get tile data.
|
||||||
const TileData *tile_data = p_tile_data_override ? p_tile_data_override : atlas_source->get_tile_data(p_atlas_coords, p_alternative_tile);
|
const LayeredTileData *tile_data = p_tile_data_override ? p_tile_data_override : atlas_source->get_tile_data(p_atlas_coords, p_alternative_tile);
|
||||||
|
|
||||||
// Get the tile modulation.
|
// Get the tile modulation.
|
||||||
Color modulate = tile_data->get_modulate() * p_modulation;
|
Color modulate = tile_data->get_modulate() * p_modulation;
|
||||||
@ -173,10 +176,10 @@ void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, con
|
|||||||
// Draw the tile.
|
// Draw the tile.
|
||||||
if (p_frame >= 0) {
|
if (p_frame >= 0) {
|
||||||
Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, p_frame);
|
Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, p_frame);
|
||||||
tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, p_tile_set->is_uv_clipping());
|
tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, Ref<Texture>(), p_tile_set->is_uv_clipping());
|
||||||
} else if (atlas_source->get_tile_animation_frames_count(p_atlas_coords) == 1) {
|
} else if (atlas_source->get_tile_animation_frames_count(p_atlas_coords) == 1) {
|
||||||
Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, 0);
|
Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, 0);
|
||||||
tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, p_tile_set->is_uv_clipping());
|
tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, Ref<Texture>(), p_tile_set->is_uv_clipping());
|
||||||
} else {
|
} else {
|
||||||
real_t speed = atlas_source->get_tile_animation_speed(p_atlas_coords);
|
real_t speed = atlas_source->get_tile_animation_speed(p_atlas_coords);
|
||||||
real_t animation_duration = atlas_source->get_tile_animation_total_duration(p_atlas_coords) / speed;
|
real_t animation_duration = atlas_source->get_tile_animation_total_duration(p_atlas_coords) / speed;
|
||||||
@ -191,7 +194,7 @@ void LayeredTileMap::draw_tile(RID p_canvas_item, const Vector2 &p_position, con
|
|||||||
RenderingServer::get_singleton()->canvas_item_add_animation_slice(p_canvas_item, animation_duration, slice_start, slice_end, animation_offset);
|
RenderingServer::get_singleton()->canvas_item_add_animation_slice(p_canvas_item, animation_duration, slice_start, slice_end, animation_offset);
|
||||||
|
|
||||||
Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, frame);
|
Rect2i source_rect = atlas_source->get_runtime_tile_texture_region(p_atlas_coords, frame);
|
||||||
tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, p_tile_set->is_uv_clipping());
|
tex->draw_rect_region(p_canvas_item, dest_rect, source_rect, modulate, transpose, Ref<Texture>(), p_tile_set->is_uv_clipping());
|
||||||
|
|
||||||
time_unscaled += frame_duration_unscaled;
|
time_unscaled += frame_duration_unscaled;
|
||||||
}
|
}
|
||||||
@ -406,7 +409,7 @@ int LayeredTileMap::get_cell_alternative_tile(int p_layer, const Vector2i &p_coo
|
|||||||
TILEMAP_CALL_FOR_LAYER_V(p_layer, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE, get_cell_alternative_tile, p_coords, p_use_proxies);
|
TILEMAP_CALL_FOR_LAYER_V(p_layer, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE, get_cell_alternative_tile, p_coords, p_use_proxies);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileData *LayeredTileMap::get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
|
LayeredTileData *LayeredTileMap::get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies) const {
|
||||||
TILEMAP_CALL_FOR_LAYER_V(p_layer, nullptr, get_cell_tile_data, p_coords, p_use_proxies);
|
TILEMAP_CALL_FOR_LAYER_V(p_layer, nullptr, get_cell_tile_data, p_coords, p_use_proxies);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -832,8 +835,8 @@ PoolVector2iArray LayeredTileMap::get_surrounding_cells(const Vector2i &p_coords
|
|||||||
return tile_set->get_surrounding_cells(p_coords);
|
return tile_set->get_surrounding_cells(p_coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
PackedStringArray LayeredTileMap::get_configuration_warnings() const {
|
PoolStringArray LayeredTileMap::get_configuration_warnings() const {
|
||||||
PackedStringArray warnings = Node::get_configuration_warnings();
|
PoolStringArray warnings = Node::get_configuration_warnings();
|
||||||
|
|
||||||
// Retrieve the set of Z index values with a Y-sorted layer.
|
// Retrieve the set of Z index values with a Y-sorted layer.
|
||||||
RBSet<int> y_sorted_z_index;
|
RBSet<int> y_sorted_z_index;
|
||||||
|
@ -113,7 +113,7 @@ public:
|
|||||||
void set_rendering_quadrant_size(int p_size);
|
void set_rendering_quadrant_size(int p_size);
|
||||||
int get_rendering_quadrant_size() const;
|
int get_rendering_quadrant_size() const;
|
||||||
|
|
||||||
static void draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<LayeredTileSet> p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame = -1, Color p_modulation = Color(1.0, 1.0, 1.0, 1.0), const TileData *p_tile_data_override = nullptr, real_t p_normalized_animation_offset = 0.0);
|
static void draw_tile(RID p_canvas_item, const Vector2 &p_position, const Ref<LayeredTileSet> p_tile_set, int p_atlas_source_id, const Vector2i &p_atlas_coords, int p_alternative_tile, int p_frame = -1, Color p_modulation = Color(1.0, 1.0, 1.0, 1.0), const LayeredTileData *p_tile_data_override = nullptr, real_t p_normalized_animation_offset = 0.0);
|
||||||
|
|
||||||
// Layers management.
|
// Layers management.
|
||||||
int get_layers_count() const;
|
int get_layers_count() const;
|
||||||
@ -155,7 +155,7 @@ public:
|
|||||||
Vector2i get_cell_atlas_coords(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
|
Vector2i get_cell_atlas_coords(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
|
||||||
int get_cell_alternative_tile(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
|
int get_cell_alternative_tile(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
|
||||||
// Helper method to make accessing the data easier.
|
// Helper method to make accessing the data easier.
|
||||||
TileData *get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
|
LayeredTileData *get_cell_tile_data(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
|
||||||
|
|
||||||
// Patterns.
|
// Patterns.
|
||||||
Ref<LayeredTileMapPattern> get_pattern(int p_layer, PoolVector2iArray p_coords_array);
|
Ref<LayeredTileMapPattern> get_pattern(int p_layer, PoolVector2iArray p_coords_array);
|
||||||
@ -212,12 +212,12 @@ public:
|
|||||||
// Helpers?
|
// Helpers?
|
||||||
PoolVector2iArray get_surrounding_cells(const Vector2i &p_coords);
|
PoolVector2iArray get_surrounding_cells(const Vector2i &p_coords);
|
||||||
|
|
||||||
// Virtual function to modify the TileData at runtime.
|
// Virtual function to modify the LayeredTileData at runtime.
|
||||||
GDVIRTUAL2R(bool, _use_tile_data_runtime_update, int, Vector2i);
|
GDVIRTUAL2R(bool, _use_tile_data_runtime_update, int, Vector2i);
|
||||||
GDVIRTUAL3(_tile_data_runtime_update, int, Vector2i, TileData *);
|
GDVIRTUAL3(_tile_data_runtime_update, int, Vector2i, LayeredTileData *);
|
||||||
|
|
||||||
// Configuration warnings.
|
// Configuration warnings.
|
||||||
PackedStringArray get_configuration_warnings() const;
|
PoolStringArray get_configuration_warnings() const;
|
||||||
|
|
||||||
LayeredTileMap();
|
LayeredTileMap();
|
||||||
~LayeredTileMap();
|
~LayeredTileMap();
|
||||||
|
@ -33,12 +33,12 @@
|
|||||||
|
|
||||||
#include "core/core_string_names.h"
|
#include "core/core_string_names.h"
|
||||||
#include "core/io/marshalls.h"
|
#include "core/io/marshalls.h"
|
||||||
#include "scene/gui/control.h"
|
#include "scene/main/control.h"
|
||||||
#include "scene/resources/world_2d.h"
|
#include "scene/resources/world_2d.h"
|
||||||
#include "servers/navigation_server_2d.h"
|
#include "servers/navigation_2d_server.h"
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
#include "servers/navigation_server_3d.h"
|
#include "servers/navigation_server.h"
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
@ -297,7 +297,7 @@ void LayeredTileMapLayer::_rendering_update() {
|
|||||||
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(*tile_set->get_source(cell_data.cell.source_id));
|
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(*tile_set->get_source(cell_data.cell.source_id));
|
||||||
|
|
||||||
// Get the tile data.
|
// Get the tile data.
|
||||||
const TileData *tile_data;
|
const LayeredTileData *tile_data;
|
||||||
if (cell_data.runtime_tile_data_cache) {
|
if (cell_data.runtime_tile_data_cache) {
|
||||||
tile_data = cell_data.runtime_tile_data_cache;
|
tile_data = cell_data.runtime_tile_data_cache;
|
||||||
} else {
|
} else {
|
||||||
@ -469,7 +469,7 @@ void LayeredTileMapLayer::_rendering_quadrants_update_cell(CellData &r_cell_data
|
|||||||
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
||||||
if (atlas_source && atlas_source->has_tile(r_cell_data.cell.get_atlas_coords()) && atlas_source->has_alternative_tile(r_cell_data.cell.get_atlas_coords(), r_cell_data.cell.alternative_tile)) {
|
if (atlas_source && atlas_source->has_tile(r_cell_data.cell.get_atlas_coords()) && atlas_source->has_alternative_tile(r_cell_data.cell.get_atlas_coords(), r_cell_data.cell.alternative_tile)) {
|
||||||
is_valid = true;
|
is_valid = true;
|
||||||
const TileData *tile_data;
|
const LayeredTileData *tile_data;
|
||||||
if (r_cell_data.runtime_tile_data_cache) {
|
if (r_cell_data.runtime_tile_data_cache) {
|
||||||
tile_data = r_cell_data.runtime_tile_data_cache;
|
tile_data = r_cell_data.runtime_tile_data_cache;
|
||||||
} else {
|
} else {
|
||||||
@ -577,7 +577,7 @@ void LayeredTileMapLayer::_rendering_occluders_update_cell(CellData &r_cell_data
|
|||||||
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
||||||
if (atlas_source) {
|
if (atlas_source) {
|
||||||
// Get the tile data.
|
// Get the tile data.
|
||||||
const TileData *tile_data;
|
const LayeredTileData *tile_data;
|
||||||
if (r_cell_data.runtime_tile_data_cache) {
|
if (r_cell_data.runtime_tile_data_cache) {
|
||||||
tile_data = r_cell_data.runtime_tile_data_cache;
|
tile_data = r_cell_data.runtime_tile_data_cache;
|
||||||
} else {
|
} else {
|
||||||
@ -773,7 +773,7 @@ void LayeredTileMapLayer::_physics_update_cell(CellData &r_cell_data) {
|
|||||||
if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) {
|
if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) {
|
||||||
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
||||||
if (atlas_source) {
|
if (atlas_source) {
|
||||||
const TileData *tile_data;
|
const LayeredTileData *tile_data;
|
||||||
if (r_cell_data.runtime_tile_data_cache) {
|
if (r_cell_data.runtime_tile_data_cache) {
|
||||||
tile_data = r_cell_data.runtime_tile_data_cache;
|
tile_data = r_cell_data.runtime_tile_data_cache;
|
||||||
} else {
|
} else {
|
||||||
@ -1038,7 +1038,7 @@ void LayeredTileMapLayer::_navigation_update_cell(CellData &r_cell_data) {
|
|||||||
if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) {
|
if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) {
|
||||||
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
||||||
if (atlas_source) {
|
if (atlas_source) {
|
||||||
const TileData *tile_data;
|
const LayeredTileData *tile_data;
|
||||||
if (r_cell_data.runtime_tile_data_cache) {
|
if (r_cell_data.runtime_tile_data_cache) {
|
||||||
tile_data = r_cell_data.runtime_tile_data_cache;
|
tile_data = r_cell_data.runtime_tile_data_cache;
|
||||||
} else {
|
} else {
|
||||||
@ -1144,7 +1144,7 @@ void LayeredTileMapLayer::_navigation_draw_cell_debug(const RID &p_canvas_item,
|
|||||||
if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) {
|
if (source->has_tile(c.get_atlas_coords()) && source->has_alternative_tile(c.get_atlas_coords(), c.alternative_tile)) {
|
||||||
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
||||||
if (atlas_source) {
|
if (atlas_source) {
|
||||||
const TileData *tile_data;
|
const LayeredTileData *tile_data;
|
||||||
if (r_cell_data.runtime_tile_data_cache) {
|
if (r_cell_data.runtime_tile_data_cache) {
|
||||||
tile_data = r_cell_data.runtime_tile_data_cache;
|
tile_data = r_cell_data.runtime_tile_data_cache;
|
||||||
} else {
|
} else {
|
||||||
@ -1394,10 +1394,10 @@ void LayeredTileMapLayer::_build_runtime_update_tile_data_for_cell(CellData &r_c
|
|||||||
if (p_use_tilemap_for_runtime) {
|
if (p_use_tilemap_for_runtime) {
|
||||||
// Compatibility with LayeredTileMap.
|
// Compatibility with LayeredTileMap.
|
||||||
if (tile_map_node->GDVIRTUAL_CALL(_use_tile_data_runtime_update, layer_index_in_tile_map_node, r_cell_data.coords, ret) && ret) {
|
if (tile_map_node->GDVIRTUAL_CALL(_use_tile_data_runtime_update, layer_index_in_tile_map_node, r_cell_data.coords, ret) && ret) {
|
||||||
TileData *tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile);
|
LayeredTileData *tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile);
|
||||||
|
|
||||||
// Create the runtime TileData.
|
// Create the runtime LayeredTileData.
|
||||||
TileData *tile_data_runtime_use = tile_data->duplicate();
|
LayeredTileData *tile_data_runtime_use = tile_data->duplicate();
|
||||||
tile_data_runtime_use->set_allow_transform(true);
|
tile_data_runtime_use->set_allow_transform(true);
|
||||||
r_cell_data.runtime_tile_data_cache = tile_data_runtime_use;
|
r_cell_data.runtime_tile_data_cache = tile_data_runtime_use;
|
||||||
|
|
||||||
@ -1409,10 +1409,10 @@ void LayeredTileMapLayer::_build_runtime_update_tile_data_for_cell(CellData &r_c
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (GDVIRTUAL_CALL(_use_tile_data_runtime_update, r_cell_data.coords, ret) && ret) {
|
if (GDVIRTUAL_CALL(_use_tile_data_runtime_update, r_cell_data.coords, ret) && ret) {
|
||||||
TileData *tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile);
|
LayeredTileData *tile_data = atlas_source->get_tile_data(c.get_atlas_coords(), c.alternative_tile);
|
||||||
|
|
||||||
// Create the runtime TileData.
|
// Create the runtime LayeredTileData.
|
||||||
TileData *tile_data_runtime_use = tile_data->duplicate();
|
LayeredTileData *tile_data_runtime_use = tile_data->duplicate();
|
||||||
tile_data_runtime_use->set_allow_transform(true);
|
tile_data_runtime_use->set_allow_transform(true);
|
||||||
r_cell_data.runtime_tile_data_cache = tile_data_runtime_use;
|
r_cell_data.runtime_tile_data_cache = tile_data_runtime_use;
|
||||||
|
|
||||||
@ -1559,13 +1559,13 @@ RBSet<TerrainConstraint> LayeredTileMapLayer::_get_terrain_constraints_from_pain
|
|||||||
// Count the number of occurrences per terrain.
|
// Count the number of occurrences per terrain.
|
||||||
HashMap<Vector2i, LayeredTileSet::CellNeighbor> overlapping_terrain_bits = E_constraint.get_overlapping_coords_and_peering_bits();
|
HashMap<Vector2i, LayeredTileSet::CellNeighbor> overlapping_terrain_bits = E_constraint.get_overlapping_coords_and_peering_bits();
|
||||||
for (const KeyValue<Vector2i, LayeredTileSet::CellNeighbor> &E_overlapping : overlapping_terrain_bits) {
|
for (const KeyValue<Vector2i, LayeredTileSet::CellNeighbor> &E_overlapping : overlapping_terrain_bits) {
|
||||||
TileData *neighbor_tile_data = nullptr;
|
LayeredTileData *neighbor_tile_data = nullptr;
|
||||||
LayeredTileMapCell neighbor_cell = get_cell(E_overlapping.key);
|
LayeredTileMapCell neighbor_cell = get_cell(E_overlapping.key);
|
||||||
if (neighbor_cell.source_id != LayeredTileSet::INVALID_SOURCE) {
|
if (neighbor_cell.source_id != LayeredTileSet::INVALID_SOURCE) {
|
||||||
Ref<LayeredTileSetSource> source = tile_set->get_source(neighbor_cell.source_id);
|
Ref<LayeredTileSetSource> source = tile_set->get_source(neighbor_cell.source_id);
|
||||||
Ref<LayeredTileSetAtlasSource> atlas_source = source;
|
Ref<LayeredTileSetAtlasSource> atlas_source = source;
|
||||||
if (atlas_source.is_valid()) {
|
if (atlas_source.is_valid()) {
|
||||||
TileData *tile_data = atlas_source->get_tile_data(neighbor_cell.get_atlas_coords(), neighbor_cell.alternative_tile);
|
LayeredTileData *tile_data = atlas_source->get_tile_data(neighbor_cell.get_atlas_coords(), neighbor_cell.alternative_tile);
|
||||||
if (tile_data && tile_data->get_terrain_set() == p_terrain_set) {
|
if (tile_data && tile_data->get_terrain_set() == p_terrain_set) {
|
||||||
neighbor_tile_data = tile_data;
|
neighbor_tile_data = tile_data;
|
||||||
}
|
}
|
||||||
@ -1601,7 +1601,7 @@ RBSet<TerrainConstraint> LayeredTileMapLayer::_get_terrain_constraints_from_pain
|
|||||||
|
|
||||||
// Add the centers as constraints.
|
// Add the centers as constraints.
|
||||||
for (Vector2i E_coords : p_painted) {
|
for (Vector2i E_coords : p_painted) {
|
||||||
TileData *tile_data = nullptr;
|
LayeredTileData *tile_data = nullptr;
|
||||||
LayeredTileMapCell cell = get_cell(E_coords);
|
LayeredTileMapCell cell = get_cell(E_coords);
|
||||||
if (cell.source_id != LayeredTileSet::INVALID_SOURCE) {
|
if (cell.source_id != LayeredTileSet::INVALID_SOURCE) {
|
||||||
Ref<LayeredTileSetSource> source = tile_set->get_source(cell.source_id);
|
Ref<LayeredTileSetSource> source = tile_set->get_source(cell.source_id);
|
||||||
@ -1658,7 +1658,7 @@ void LayeredTileMapLayer::_deferred_internal_update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LayeredTileMapLayer::_internal_update() {
|
void LayeredTileMapLayer::_internal_update() {
|
||||||
// Find TileData that need a runtime modification.
|
// Find LayeredTileData that need a runtime modification.
|
||||||
// This may add cells to the dirty list if a runtime modification has been notified.
|
// This may add cells to the dirty list if a runtime modification has been notified.
|
||||||
_build_runtime_update_tile_data();
|
_build_runtime_update_tile_data();
|
||||||
|
|
||||||
@ -1818,7 +1818,7 @@ HashMap<Vector2i, LayeredTileSet::TerrainsPattern> LayeredTileMapLayer::terrain_
|
|||||||
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
||||||
if (atlas_source) {
|
if (atlas_source) {
|
||||||
// Get tile data.
|
// Get tile data.
|
||||||
TileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile);
|
LayeredTileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile);
|
||||||
if (tile_data && tile_data->get_terrain_set() == p_terrain_set) {
|
if (tile_data && tile_data->get_terrain_set() == p_terrain_set) {
|
||||||
current_pattern = tile_data->get_terrains_pattern();
|
current_pattern = tile_data->get_terrains_pattern();
|
||||||
}
|
}
|
||||||
@ -1880,7 +1880,7 @@ HashMap<Vector2i, LayeredTileSet::TerrainsPattern> LayeredTileMapLayer::terrain_
|
|||||||
connect = true;
|
connect = true;
|
||||||
} else {
|
} else {
|
||||||
// Get the center bit of the cell.
|
// Get the center bit of the cell.
|
||||||
TileData *tile_data = nullptr;
|
LayeredTileData *tile_data = nullptr;
|
||||||
LayeredTileMapCell cell = get_cell(coords);
|
LayeredTileMapCell cell = get_cell(coords);
|
||||||
if (cell.source_id != LayeredTileSet::INVALID_SOURCE) {
|
if (cell.source_id != LayeredTileSet::INVALID_SOURCE) {
|
||||||
Ref<LayeredTileSetSource> source = tile_set->get_source(cell.source_id);
|
Ref<LayeredTileSetSource> source = tile_set->get_source(cell.source_id);
|
||||||
@ -2318,7 +2318,7 @@ int LayeredTileMapLayer::get_cell_alternative_tile(const Vector2i &p_coords, boo
|
|||||||
return E->value.cell.alternative_tile;
|
return E->value.cell.alternative_tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileData *LayeredTileMapLayer::get_cell_tile_data(const Vector2i &p_coords, bool p_use_proxies) const {
|
LayeredTileData *LayeredTileMapLayer::get_cell_tile_data(const Vector2i &p_coords, bool p_use_proxies) const {
|
||||||
int source_id = get_cell_source_id(p_coords, p_use_proxies);
|
int source_id = get_cell_source_id(p_coords, p_use_proxies);
|
||||||
if (source_id == LayeredTileSet::INVALID_SOURCE) {
|
if (source_id == LayeredTileSet::INVALID_SOURCE) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -2433,7 +2433,7 @@ void LayeredTileMapLayer::set_cells_terrain_connect(PoolVector2iArray p_cells, i
|
|||||||
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
||||||
if (atlas_source) {
|
if (atlas_source) {
|
||||||
// Get tile data.
|
// Get tile data.
|
||||||
TileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile);
|
LayeredTileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile);
|
||||||
if (tile_data && tile_data->get_terrain_set() == p_terrain_set) {
|
if (tile_data && tile_data->get_terrain_set() == p_terrain_set) {
|
||||||
in_map_terrain_pattern = tile_data->get_terrains_pattern();
|
in_map_terrain_pattern = tile_data->get_terrains_pattern();
|
||||||
}
|
}
|
||||||
@ -2474,7 +2474,7 @@ void LayeredTileMapLayer::set_cells_terrain_path(PoolVector2iArray p_path, int p
|
|||||||
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
LayeredTileSetAtlasSource *atlas_source = Object::cast_to<LayeredTileSetAtlasSource>(source);
|
||||||
if (atlas_source) {
|
if (atlas_source) {
|
||||||
// Get tile data.
|
// Get tile data.
|
||||||
TileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile);
|
LayeredTileData *tile_data = atlas_source->get_tile_data(cell.get_atlas_coords(), cell.alternative_tile);
|
||||||
if (tile_data && tile_data->get_terrain_set() == p_terrain_set) {
|
if (tile_data && tile_data->get_terrain_set() == p_terrain_set) {
|
||||||
in_map_terrain_pattern = tile_data->get_terrains_pattern();
|
in_map_terrain_pattern = tile_data->get_terrains_pattern();
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "layered_tile_set.h"
|
#include "layered_tile_set.h"
|
||||||
#include "scene/2d/tile_map.h"
|
#include "layered_tile_map.h"
|
||||||
|
|
||||||
class LayeredTileSetAtlasSource;
|
class LayeredTileSetAtlasSource;
|
||||||
|
|
||||||
@ -115,8 +115,8 @@ struct CellData {
|
|||||||
// Scenes.
|
// Scenes.
|
||||||
String scene;
|
String scene;
|
||||||
|
|
||||||
// Runtime TileData cache.
|
// Runtime LayeredTileData cache.
|
||||||
TileData *runtime_tile_data_cache = nullptr;
|
LayeredTileData *runtime_tile_data_cache = nullptr;
|
||||||
|
|
||||||
// List elements.
|
// List elements.
|
||||||
SelfList<CellData> dirty_list_element;
|
SelfList<CellData> dirty_list_element;
|
||||||
@ -164,8 +164,8 @@ struct CellDataYSortedComparator {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
class DebugQuadrant : public RefCounted {
|
class DebugQuadrant : public Reference {
|
||||||
GDCLASS(DebugQuadrant, RefCounted);
|
GDCLASS(DebugQuadrant, Reference);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Vector2i quadrant_coords;
|
Vector2i quadrant_coords;
|
||||||
@ -184,8 +184,8 @@ public:
|
|||||||
};
|
};
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
class RenderingQuadrant : public RefCounted {
|
class RenderingQuadrant : public Reference {
|
||||||
GDCLASS(RenderingQuadrant, RefCounted);
|
GDCLASS(RenderingQuadrant, Reference);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct CoordsWorldComparator {
|
struct CoordsWorldComparator {
|
||||||
@ -393,7 +393,7 @@ public:
|
|||||||
int get_cell_source_id(const Vector2i &p_coords, bool p_use_proxies = false) const;
|
int get_cell_source_id(const Vector2i &p_coords, bool p_use_proxies = false) const;
|
||||||
Vector2i get_cell_atlas_coords(const Vector2i &p_coords, bool p_use_proxies = false) const;
|
Vector2i get_cell_atlas_coords(const Vector2i &p_coords, bool p_use_proxies = false) const;
|
||||||
int get_cell_alternative_tile(const Vector2i &p_coords, bool p_use_proxies = false) const;
|
int get_cell_alternative_tile(const Vector2i &p_coords, bool p_use_proxies = false) const;
|
||||||
TileData *get_cell_tile_data(const Vector2i &p_coords, bool p_use_proxies = false) const; // Helper method to make accessing the data easier.
|
LayeredTileData *get_cell_tile_data(const Vector2i &p_coords, bool p_use_proxies = false) const; // Helper method to make accessing the data easier.
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
// Patterns.
|
// Patterns.
|
||||||
@ -445,9 +445,9 @@ public:
|
|||||||
// Helper.
|
// Helper.
|
||||||
Ref<LayeredTileSet> get_effective_tile_set() const;
|
Ref<LayeredTileSet> get_effective_tile_set() const;
|
||||||
|
|
||||||
// Virtual function to modify the TileData at runtime.
|
// Virtual function to modify the LayeredTileData at runtime.
|
||||||
GDVIRTUAL1R(bool, _use_tile_data_runtime_update, Vector2i);
|
GDVIRTUAL1R(bool, _use_tile_data_runtime_update, Vector2i);
|
||||||
GDVIRTUAL2(_tile_data_runtime_update, Vector2i, TileData *);
|
GDVIRTUAL2(_tile_data_runtime_update, Vector2i, LayeredTileData *);
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
LayeredTileMapLayer();
|
LayeredTileMapLayer();
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include "core/core_string_names.h"
|
#include "core/core_string_names.h"
|
||||||
#include "layered_tile_map_layer.h"
|
#include "layered_tile_map_layer.h"
|
||||||
#include "scene/resources/2d/tile_set.h"
|
#include "layered_tile_set.h"
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "scene/2d/node_2d.h"
|
#include "scene/main/node_2d.h"
|
||||||
|
|
||||||
class LayeredTileSet;
|
class LayeredTileSet;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user