Skip to content

Commit

Permalink
feat: Set tiles in conflict when overlapping
Browse files Browse the repository at this point in the history
  • Loading branch information
piiertho committed Jun 4, 2024
1 parent 4e936a9 commit 737a6a8
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 49 deletions.
1 change: 1 addition & 0 deletions demo/maps/dojomap.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ layers = {
0: "Default"
}
last_layer_id = 1
metadata/_LAYER_0_COLOR = Color(0.878431, 0.160784, 0.160784, 1)
11 changes: 11 additions & 0 deletions demo/maps/resize_map_tets/inner_set.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_resource type="PositionableSet" format=3 uid="uid://5elc74fyn66n"]

[resource]
categories = PackedStringArray("innerall")
categories_to_identifiers = {
"innerall": [1]
}
last_id = 1
identifier_to_scene_path = {
1: "res://block.tscn"
}
13 changes: 13 additions & 0 deletions demo/maps/resize_map_tets/innermap.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://bajnk0o2x5783"]

[ext_resource type="PositionableSet" uid="uid://5elc74fyn66n" path="res://maps/resize_map_tets/inner_set.tres" id="1_wenw3"]

[node name="Innermap" type="IsometricMap"]
size = Vector3(4, 3, 1)
positionable_set = ExtResource("1_wenw3")
grid_3d = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
layers_grid_3d = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
layers = {
0: "Default"
}
metadata/_LAYER_0_COLOR = Color(0, 0, 0, 1)
13 changes: 13 additions & 0 deletions demo/maps/resize_map_tets/mainmap.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://c3a512da8wyhc"]

[ext_resource type="PositionableSet" uid="uid://dhsxl2jgqoyib" path="res://maps/resize_map_tets/set.tres" id="1_mlceb"]

[node name="Mainmap" type="IsometricMap"]
size = Vector3(10, 10, 10)
positionable_set = ExtResource("1_mlceb")
grid_3d = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 2, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
layers_grid_3d = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
layers = {
0: "Default"
}
metadata/_LAYER_0_COLOR = Color(0, 0, 0, 1)
13 changes: 13 additions & 0 deletions demo/maps/resize_map_tets/set.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="PositionableSet" format=3 uid="uid://dhsxl2jgqoyib"]

[resource]
categories = PackedStringArray("all", "")
categories_to_identifiers = {
"": [],
"all": [1, 2]
}
last_id = 2
identifier_to_scene_path = {
1: "res://block.tscn",
2: "res://maps/resize_map_tets/innermap.tscn"
}
4 changes: 2 additions & 2 deletions demo/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ player_left={
}
set_debug={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
set_sync={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":83,"key_label":83,"unicode":0,"echo":false,"script":null)
]
}

Expand Down
41 changes: 41 additions & 0 deletions src/containers/grid_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ namespace containers {

bool insert_box(const AABB& aabb, T data, bool remove = false);

Vector<T> get_box(const AABB& aabb) const;

bool is_overlapping(const AABB& aabb) const;

bool has(T object) const;
Expand Down Expand Up @@ -159,6 +161,45 @@ namespace containers {
return true;
}

template<class T, T default_value>
Vector<T> Grid3D<T, default_value>::get_box(const AABB& aabb) const {
Vector<T> ret;

Vector3 position {
MAX(aabb.position.x, 0),
MAX(aabb.position.y, 0),
MAX(aabb.position.z, 0)
};
const Vector3& size {aabb.size};
int sizeX = static_cast<int>(size.x);
int sizeY = static_cast<int>(size.y);
int sizeZ = static_cast<int>(size.z);
int endX = static_cast<int>(position.x) + sizeX;
int endY = static_cast<int>(position.y) + sizeY;
int endZ = static_cast<int>(position.z) + sizeZ;

if (endX > width) {
sizeX -= endX - width;
}

if (endY > depth) {
sizeY -= endY - depth;
}

if (endZ > height) {
sizeZ -= endZ - height;
}

int index {get_index_from_position(position)};
ret.push_back(internal_array[index]);
for (int i = 1; i < sizeX * sizeY * sizeZ; i++) {
index += Grid3D::index_increment_from(plane_square_and_jumps_from(size), size, i);
ret.push_back(internal_array[index]);
}

return ret;
}

template<class T, T default_value>
bool Grid3D<T, default_value>::is_overlapping(const AABB& aabb) const {
int index {get_index_from_position(aabb.position)};
Expand Down
4 changes: 2 additions & 2 deletions src/data/isometric_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace data {

int z_order = 0;

#ifdef TOOLS_ENABLED
Color editor_modulate = Color(1, 1, 1);
#ifdef DEBUG_ENABLED
Color debug_modulate = Color(1, 1, 1);
#endif
};
}// namespace data
Expand Down
14 changes: 8 additions & 6 deletions src/editor/commands/add_positionable_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
using namespace editor::commands;

void AddPositionableCommand::redo() {
context_node->add_positionable_if_nothing_present(
aabb,
positionable_id,
layer_id
);
if (is_overlapping) {
context_node->add_positionable(aabb.position, positionable_id, layer_id);
} else {
context_node->add_positionable_if_nothing_present(aabb, positionable_id, layer_id);
}
Command<node::IsometricMap>::redo();
}

void AddPositionableCommand::undo() {
is_overlapping = context_node->is_overlapping(aabb);
context_node->remove_positionable(aabb);
Command<node::IsometricMap>::undo();
}
Expand All @@ -33,6 +34,7 @@ void AddPositionableCommand::set_layer_id(uint32_t p_layer_id) {

AddPositionableCommand::AddPositionableCommand() :
positionable_id(resource::PositionableSet::NONE_POSITIONABLE_ID),
layer_id(node::IsometricMap::DEFAULT_LAYER_ID) {}
layer_id(node::IsometricMap::DEFAULT_LAYER_ID),
is_overlapping(false) {}

#endif
1 change: 1 addition & 0 deletions src/editor/commands/add_positionable_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace editor {
AABB aabb;
int positionable_id;
uint32_t layer_id;
bool is_overlapping;
};
}// namespace commands
}// namespace editor
Expand Down
17 changes: 9 additions & 8 deletions src/editor/commands/emitters/move_selection_command_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

using namespace editor::commands::emitters;

static Color CONFLICT_MODULATE_COLOR {1, 0, 0, 0.5};
static Color DEFAULT_MODULATE_COLOR {1, 1, 1, 0.5};

Vector<Ref<editor::commands::Command<node::IsometricMap>>> MoveSelectionCommandEmitter::from_gui_input_to_command_impl([[maybe_unused]] Ref<InputEventMouse> p_event) {
Expand Down Expand Up @@ -70,8 +69,7 @@ Vector<Ref<editor::commands::Command<node::IsometricMap>>> MoveSelectionCommandE
for (const Vector3& position : selected_positions) {
node::IsometricPositionable* original_positionable = map->get_positionable_at(position);
auto* duplicate {
Object::cast_to<node::IsometricPositionable>(original_positionable->duplicate()
)
Object::cast_to<node::IsometricPositionable>(original_positionable->duplicate())
};
original_positionable->set_visible(false);
duplicate->set_is_dynamic(true);
Expand All @@ -89,14 +87,17 @@ Vector<Ref<editor::commands::Command<node::IsometricMap>>> MoveSelectionCommandE

for (const KeyValue<Vector3, node::IsometricPositionable*>& keyValuePair : current_preview_nodes) {
node::IsometricPositionable* positionable {keyValuePair.value};
Vector3 new_position { keyValuePair.key + position_delta };
Vector3 initial_position { keyValuePair.key };
Vector3 new_position {initial_position + position_delta };
Vector3 positionable_size = positionable->get_size();

if ((map->get_positionable_at(new_position) && !current_preview_nodes.has(new_position)) ||
!map->is_aabb_in_map({new_position, positionable->get_size()})) {
positionable->set_editor_modulate(CONFLICT_MODULATE_COLOR);
if ((map->has_positionable_in({new_position, positionable_size}, map->get_positionable_at(initial_position)) &&
!current_preview_nodes.has(new_position)) ||
!map->is_aabb_in_map({new_position, positionable_size})) {
positionable->set_debug_modulate(node::IsometricPositionable::CONFLICT_MODULATE_COLOR);
is_move_valid = false;
} else {
positionable->set_editor_modulate(DEFAULT_MODULATE_COLOR);
positionable->set_debug_modulate(DEFAULT_MODULATE_COLOR);
}

positionable->set_local_position_3d(new_position);
Expand Down
14 changes: 7 additions & 7 deletions src/isometric_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void IsometricServer::command_update_visual_server() {
RenderingServer::get_singleton()->canvas_item_set_modulate(
visual_rid,
#ifdef TOOLS_ENABLED
static_element->editor_modulate
static_element->debug_modulate
#else
Color(1., 1., 1.)
#endif
Expand All @@ -426,7 +426,7 @@ void IsometricServer::command_update_visual_server() {
RenderingServer::get_singleton()->canvas_item_set_modulate(
visual_rid,
#ifdef TOOLS_ENABLED
dynamic_element->editor_modulate
dynamic_element->debug_modulate
#else
Color(1., 1., 1.)
#endif
Expand All @@ -449,15 +449,15 @@ void IsometricServer::command_stop_server() {
exit_thread = true;
}

#ifdef TOOLS_ENABLED
void IsometricServer::isometric_element_set_editor_modulate(const RID element_rid, const Color color) {
#ifdef DEBUG_ENABLED
void IsometricServer::isometric_element_set_debug_modulate(const RID element_rid, const Color color) {
GET_ELEMENT_RID_DATA(element, element_rid);
command_queue.push(this, &IsometricServer::command_set_editor_modulate, element, color);
command_queue.push(this, &IsometricServer::command_set_debug_modulate, element, color);
}

void IsometricServer::command_set_editor_modulate(data::IsometricElement* element, const Color color) {
void IsometricServer::command_set_debug_modulate(data::IsometricElement* element, const Color color) { // NOLINT(*-convert-member-functions-to-static)
if (IsometricSpace* space {element->space}) { space->dirty = true; }
element->editor_modulate = color;
element->debug_modulate = color;
}
#endif

Expand Down
8 changes: 4 additions & 4 deletions src/isometric_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class IsometricServer : public Object {
void isometric_element_set_size(const RID element_rid, const Vector3 size);
void isometric_element_set_depth(const RID element_rid, const int depth);

#ifdef TOOLS_ENABLED
void isometric_element_set_editor_modulate(const RID element_rid, const Color color);
#ifdef DEBUG_ENABLED
void isometric_element_set_debug_modulate(const RID element_rid, const Color color);
#endif

/// ORDERING
Expand Down Expand Up @@ -114,8 +114,8 @@ class IsometricServer : public Object {
void command_set_debug(bool p_debug);
void command_stop_server();

#ifdef TOOLS_ENABLED
void command_set_editor_modulate(data::IsometricElement* element, const Color color);
#ifdef DEBUG_ENABLED
void command_set_debug_modulate(data::IsometricElement* element, const Color color);
#endif

///////////////UTILITIES/////////
Expand Down
Loading

0 comments on commit 737a6a8

Please sign in to comment.