feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -3,5 +3,21 @@ from misc.utility.scons_hints import *
|
|||
|
||||
Import("env")
|
||||
|
||||
env.add_source_files(env.scene_sources, "*.cpp")
|
||||
env.add_source_files(env.scene_sources, "skeleton/*.cpp")
|
||||
env.add_source_files(env.scene_sources, "tile_set.cpp")
|
||||
|
||||
if not env["disable_physics_2d"]:
|
||||
env.add_source_files(env.scene_sources, "capsule_shape_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "circle_shape_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "concave_polygon_shape_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "convex_polygon_shape_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "rectangle_shape_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "segment_shape_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "separation_ray_shape_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "shape_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "world_boundary_shape_2d.cpp")
|
||||
if not env["disable_navigation_2d"]:
|
||||
env.add_source_files(env.scene_sources, "navigation_mesh_source_geometry_data_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "navigation_polygon.cpp")
|
||||
env.add_source_files(env.scene_sources, "polygon_path_finder.cpp")
|
||||
|
||||
SConscript("skeleton/SCsub")
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
Vector<Vector2> CapsuleShape2D::_get_points() const {
|
||||
Vector<Vector2> points;
|
||||
const real_t turn_step = Math_TAU / 24.0;
|
||||
const real_t turn_step = Math::TAU / 24.0;
|
||||
for (int i = 0; i < 24; i++) {
|
||||
Vector2 ofs = Vector2(0, (i > 6 && i <= 18) ? -height * 0.5 + radius : height * 0.5 - radius);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CAPSULE_SHAPE_2D_H
|
||||
#define CAPSULE_SHAPE_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/2d/shape_2d.h"
|
||||
|
||||
|
|
@ -60,5 +59,3 @@ public:
|
|||
|
||||
CapsuleShape2D();
|
||||
};
|
||||
|
||||
#endif // CAPSULE_SHAPE_2D_H
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
|
|||
Vector<Vector2> points;
|
||||
points.resize(24);
|
||||
|
||||
const real_t turn_step = Math_TAU / 24.0;
|
||||
const real_t turn_step = Math::TAU / 24.0;
|
||||
for (int i = 0; i < 24; i++) {
|
||||
points.write[i] = Vector2(Math::cos(i * turn_step), Math::sin(i * turn_step)) * get_radius();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CIRCLE_SHAPE_2D_H
|
||||
#define CIRCLE_SHAPE_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/2d/shape_2d.h"
|
||||
|
||||
|
|
@ -54,5 +53,3 @@ public:
|
|||
|
||||
CircleShape2D();
|
||||
};
|
||||
|
||||
#endif // CIRCLE_SHAPE_2D_H
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ bool ConcavePolygonShape2D::_edit_is_selected_on_click(const Point2 &p_point, do
|
|||
|
||||
const Vector2 *r = s.ptr();
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, &r[i]);
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, r[i], r[i + 1]);
|
||||
if (p_point.distance_to(closest) < p_tolerance) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CONCAVE_POLYGON_SHAPE_2D_H
|
||||
#define CONCAVE_POLYGON_SHAPE_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/2d/shape_2d.h"
|
||||
|
||||
|
|
@ -51,5 +50,3 @@ public:
|
|||
|
||||
ConcavePolygonShape2D();
|
||||
};
|
||||
|
||||
#endif // CONCAVE_POLYGON_SHAPE_2D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef CONVEX_POLYGON_SHAPE_2D_H
|
||||
#define CONVEX_POLYGON_SHAPE_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/2d/shape_2d.h"
|
||||
|
||||
|
|
@ -55,5 +54,3 @@ public:
|
|||
|
||||
ConvexPolygonShape2D();
|
||||
};
|
||||
|
||||
#endif // CONVEX_POLYGON_SHAPE_2D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef NAVIGATION_MESH_SOURCE_GEOMETRY_DATA_2D_H
|
||||
#define NAVIGATION_MESH_SOURCE_GEOMETRY_DATA_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/resource.h"
|
||||
#include "core/os/rw_lock.h"
|
||||
|
|
@ -112,5 +111,3 @@ public:
|
|||
NavigationMeshSourceGeometryData2D() {}
|
||||
~NavigationMeshSourceGeometryData2D() { clear(); }
|
||||
};
|
||||
|
||||
#endif // NAVIGATION_MESH_SOURCE_GEOMETRY_DATA_2D_H
|
||||
|
|
|
|||
|
|
@ -396,9 +396,7 @@ void NavigationPolygon::make_polygons_from_outlines() {
|
|||
vertices.clear();
|
||||
|
||||
HashMap<Vector2, int> points;
|
||||
for (List<TPPLPoly>::Element *I = out_poly.front(); I; I = I->next()) {
|
||||
TPPLPoly &tp = I->get();
|
||||
|
||||
for (const TPPLPoly &tp : out_poly) {
|
||||
Vector<int> p;
|
||||
|
||||
for (int64_t i = 0; i < tp.GetNumPoints(); i++) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef NAVIGATION_POLYGON_H
|
||||
#define NAVIGATION_POLYGON_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/2d/node_2d.h"
|
||||
#include "scene/resources/navigation_mesh.h"
|
||||
|
|
@ -176,5 +175,3 @@ public:
|
|||
VARIANT_ENUM_CAST(NavigationPolygon::SamplePartitionType);
|
||||
VARIANT_ENUM_CAST(NavigationPolygon::ParsedGeometryType);
|
||||
VARIANT_ENUM_CAST(NavigationPolygon::SourceGeometryMode);
|
||||
|
||||
#endif // NAVIGATION_POLYGON_H
|
||||
|
|
|
|||
|
|
@ -141,12 +141,9 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
|
|||
|
||||
for (const Edge &E : edges) {
|
||||
const Edge &e = E;
|
||||
Vector2 seg[2] = {
|
||||
points[e.points[0]].pos,
|
||||
points[e.points[1]].pos
|
||||
};
|
||||
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(from, seg);
|
||||
const Vector2 segment_a = points[e.points[0]].pos;
|
||||
const Vector2 segment_b = points[e.points[1]].pos;
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(from, segment_a, segment_b);
|
||||
float d = from.distance_squared_to(closest);
|
||||
|
||||
if (d < closest_dist) {
|
||||
|
|
@ -165,12 +162,9 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
|
|||
|
||||
for (const Edge &E : edges) {
|
||||
const Edge &e = E;
|
||||
Vector2 seg[2] = {
|
||||
points[e.points[0]].pos,
|
||||
points[e.points[1]].pos
|
||||
};
|
||||
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(to, seg);
|
||||
const Vector2 segment_a = points[e.points[0]].pos;
|
||||
const Vector2 segment_b = points[e.points[1]].pos;
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(to, segment_a, segment_b);
|
||||
float d = to.distance_squared_to(closest);
|
||||
|
||||
if (d < closest_dist) {
|
||||
|
|
@ -301,7 +295,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector
|
|||
bool found_route = false;
|
||||
|
||||
while (true) {
|
||||
if (open_list.size() == 0) {
|
||||
if (open_list.is_empty()) {
|
||||
print_verbose("Open list empty.");
|
||||
break;
|
||||
}
|
||||
|
|
@ -493,12 +487,9 @@ Vector2 PolygonPathFinder::get_closest_point(const Vector2 &p_point) const {
|
|||
|
||||
for (const Edge &E : edges) {
|
||||
const Edge &e = E;
|
||||
Vector2 seg[2] = {
|
||||
points[e.points[0]].pos,
|
||||
points[e.points[1]].pos
|
||||
};
|
||||
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, seg);
|
||||
const Vector2 segment_a = points[e.points[0]].pos;
|
||||
const Vector2 segment_b = points[e.points[1]].pos;
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, segment_a, segment_b);
|
||||
float d = p_point.distance_squared_to(closest);
|
||||
|
||||
if (d < closest_dist) {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef POLYGON_PATH_FINDER_H
|
||||
#define POLYGON_PATH_FINDER_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/resource.h"
|
||||
|
||||
|
|
@ -94,5 +93,3 @@ public:
|
|||
|
||||
PolygonPathFinder();
|
||||
};
|
||||
|
||||
#endif // POLYGON_PATH_FINDER_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef RECTANGLE_SHAPE_2D_H
|
||||
#define RECTANGLE_SHAPE_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/2d/shape_2d.h"
|
||||
|
||||
|
|
@ -56,5 +55,3 @@ public:
|
|||
|
||||
RectangleShape2D();
|
||||
};
|
||||
|
||||
#endif // RECTANGLE_SHAPE_2D_H
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@
|
|||
#include "servers/rendering_server.h"
|
||||
|
||||
bool SegmentShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
|
||||
Vector2 l[2] = { a, b };
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, l);
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, a, b);
|
||||
return p_point.distance_to(closest) < p_tolerance;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SEGMENT_SHAPE_2D_H
|
||||
#define SEGMENT_SHAPE_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/2d/shape_2d.h"
|
||||
|
||||
|
|
@ -59,5 +58,3 @@ public:
|
|||
|
||||
SegmentShape2D();
|
||||
};
|
||||
|
||||
#endif // SEGMENT_SHAPE_2D_H
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ Rect2 SeparationRayShape2D::get_rect() const {
|
|||
Rect2 rect;
|
||||
rect.position = Vector2();
|
||||
rect.expand_to(Vector2(0, length));
|
||||
rect = rect.grow(Math_SQRT12 * 4);
|
||||
rect = rect.grow(Math::SQRT12 * 4);
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SEPARATION_RAY_SHAPE_2D_H
|
||||
#define SEPARATION_RAY_SHAPE_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/2d/shape_2d.h"
|
||||
|
||||
|
|
@ -57,5 +56,3 @@ public:
|
|||
|
||||
SeparationRayShape2D();
|
||||
};
|
||||
|
||||
#endif // SEPARATION_RAY_SHAPE_2D_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SHAPE_2D_H
|
||||
#define SHAPE_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/resource.h"
|
||||
|
||||
|
|
@ -66,5 +65,3 @@ public:
|
|||
|
||||
~Shape2D();
|
||||
};
|
||||
|
||||
#endif // SHAPE_2D_H
|
||||
|
|
|
|||
16
engine/scene/resources/2d/skeleton/SCsub
Normal file
16
engine/scene/resources/2d/skeleton/SCsub
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env python
|
||||
from misc.utility.scons_hints import *
|
||||
|
||||
Import("env")
|
||||
|
||||
env.add_source_files(env.scene_sources, "skeleton_modification_2d.cpp")
|
||||
env.add_source_files(env.scene_sources, "skeleton_modification_2d_ccdik.cpp")
|
||||
env.add_source_files(env.scene_sources, "skeleton_modification_2d_fabrik.cpp")
|
||||
env.add_source_files(env.scene_sources, "skeleton_modification_2d_lookat.cpp")
|
||||
env.add_source_files(env.scene_sources, "skeleton_modification_2d_stackholder.cpp")
|
||||
env.add_source_files(env.scene_sources, "skeleton_modification_2d_twoboneik.cpp")
|
||||
env.add_source_files(env.scene_sources, "skeleton_modification_stack_2d.cpp")
|
||||
|
||||
if not env["disable_physics_2d"]:
|
||||
env.add_source_files(env.scene_sources, "skeleton_modification_2d_jiggle.cpp")
|
||||
env.add_source_files(env.scene_sources, "skeleton_modification_2d_physicalbones.cpp")
|
||||
|
|
@ -81,15 +81,15 @@ bool SkeletonModification2D::get_enabled() {
|
|||
float SkeletonModification2D::clamp_angle(float p_angle, float p_min_bound, float p_max_bound, bool p_invert) {
|
||||
// Map to the 0 to 360 range (in radians though) instead of the -180 to 180 range.
|
||||
if (p_angle < 0) {
|
||||
p_angle = Math_TAU + p_angle;
|
||||
p_angle = Math::TAU + p_angle;
|
||||
}
|
||||
|
||||
// Make min and max in the range of 0 to 360 (in radians), and make sure they are in the right order
|
||||
if (p_min_bound < 0) {
|
||||
p_min_bound = Math_TAU + p_min_bound;
|
||||
p_min_bound = Math::TAU + p_min_bound;
|
||||
}
|
||||
if (p_max_bound < 0) {
|
||||
p_max_bound = Math_TAU + p_max_bound;
|
||||
p_max_bound = Math::TAU + p_max_bound;
|
||||
}
|
||||
if (p_min_bound > p_max_bound) {
|
||||
SWAP(p_min_bound, p_max_bound);
|
||||
|
|
@ -130,10 +130,10 @@ void SkeletonModification2D::editor_draw_angle_constraints(Bone2D *p_operation_b
|
|||
float arc_angle_min = p_min_bound;
|
||||
float arc_angle_max = p_max_bound;
|
||||
if (arc_angle_min < 0) {
|
||||
arc_angle_min = (Math_PI * 2) + arc_angle_min;
|
||||
arc_angle_min = (Math::PI * 2) + arc_angle_min;
|
||||
}
|
||||
if (arc_angle_max < 0) {
|
||||
arc_angle_max = (Math_PI * 2) + arc_angle_max;
|
||||
arc_angle_max = (Math::PI * 2) + arc_angle_max;
|
||||
}
|
||||
if (arc_angle_min > arc_angle_max) {
|
||||
SWAP(arc_angle_min, arc_angle_max);
|
||||
|
|
@ -159,7 +159,7 @@ void SkeletonModification2D::editor_draw_angle_constraints(Bone2D *p_operation_b
|
|||
|
||||
if (p_constraint_inverted) {
|
||||
stack->skeleton->draw_arc(Vector2(0, 0), p_operation_bone->get_length(),
|
||||
arc_angle_min + (Math_PI * 2), arc_angle_max, 32, bone_ik_color, 1.0);
|
||||
arc_angle_min + (Math::PI * 2), arc_angle_max, 32, bone_ik_color, 1.0);
|
||||
} else {
|
||||
stack->skeleton->draw_arc(Vector2(0, 0), p_operation_bone->get_length(),
|
||||
arc_angle_min, arc_angle_max, 32, bone_ik_color, 1.0);
|
||||
|
|
@ -169,7 +169,7 @@ void SkeletonModification2D::editor_draw_angle_constraints(Bone2D *p_operation_b
|
|||
|
||||
} else {
|
||||
stack->skeleton->draw_set_transform(stack->skeleton->to_local(p_operation_bone->get_global_position()));
|
||||
stack->skeleton->draw_arc(Vector2(0, 0), p_operation_bone->get_length(), 0, Math_PI * 2, 32, bone_ik_color, 1.0);
|
||||
stack->skeleton->draw_arc(Vector2(0, 0), p_operation_bone->get_length(), 0, Math::PI * 2, 32, bone_ik_color, 1.0);
|
||||
stack->skeleton->draw_line(Vector2(0, 0), Vector2(1, 0) * p_operation_bone->get_length(), bone_ik_color, 1.0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKELETON_MODIFICATION_2D_H
|
||||
#define SKELETON_MODIFICATION_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/2d/skeleton/skeleton_modification_stack_2d.h"
|
||||
|
||||
|
|
@ -85,5 +84,3 @@ public:
|
|||
|
||||
SkeletonModification2D();
|
||||
};
|
||||
|
||||
#endif // SKELETON_MODIFICATION_2D_H
|
||||
|
|
|
|||
|
|
@ -171,13 +171,13 @@ void SkeletonModification2DCCDIK::_execute(float p_delta) {
|
|||
return;
|
||||
}
|
||||
|
||||
Node2D *target = Object::cast_to<Node2D>(ObjectDB::get_instance(target_node_cache));
|
||||
Node2D *target = ObjectDB::get_instance<Node2D>(target_node_cache);
|
||||
if (!target || !target->is_inside_tree()) {
|
||||
ERR_PRINT_ONCE("Target node is not in the scene tree. Cannot execute modification!");
|
||||
return;
|
||||
}
|
||||
|
||||
Node2D *tip = Object::cast_to<Node2D>(ObjectDB::get_instance(tip_node_cache));
|
||||
Node2D *tip = ObjectDB::get_instance<Node2D>(tip_node_cache);
|
||||
if (!tip || !tip->is_inside_tree()) {
|
||||
ERR_PRINT_ONCE("Tip node is not in the scene tree. Cannot execute modification!");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKELETON_MODIFICATION_2D_CCDIK_H
|
||||
#define SKELETON_MODIFICATION_2D_CCDIK_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/2d/skeleton_2d.h"
|
||||
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
|
||||
|
|
@ -50,7 +49,7 @@ private:
|
|||
|
||||
bool enable_constraint = false;
|
||||
float constraint_angle_min = 0;
|
||||
float constraint_angle_max = (2.0 * Math_PI);
|
||||
float constraint_angle_max = (2.0 * Math::PI);
|
||||
bool constraint_angle_invert = false;
|
||||
bool constraint_in_localspace = true;
|
||||
|
||||
|
|
@ -112,5 +111,3 @@ public:
|
|||
SkeletonModification2DCCDIK();
|
||||
~SkeletonModification2DCCDIK();
|
||||
};
|
||||
|
||||
#endif // SKELETON_MODIFICATION_2D_CCDIK_H
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ void SkeletonModification2DFABRIK::_execute(float p_delta) {
|
|||
return;
|
||||
}
|
||||
|
||||
Node2D *target = Object::cast_to<Node2D>(ObjectDB::get_instance(target_node_cache));
|
||||
Node2D *target = ObjectDB::get_instance<Node2D>(target_node_cache);
|
||||
if (!target || !target->is_inside_tree()) {
|
||||
ERR_PRINT_ONCE("Target node is not in the scene tree. Cannot execute modification!");
|
||||
return;
|
||||
|
|
@ -128,7 +128,7 @@ void SkeletonModification2DFABRIK::_execute(float p_delta) {
|
|||
WARN_PRINT("Bone2D cache for origin joint is out of date. Updating...");
|
||||
}
|
||||
|
||||
Bone2D *origin_bone2d_node = Object::cast_to<Bone2D>(ObjectDB::get_instance(fabrik_data_chain[0].bone2d_node_cache));
|
||||
Bone2D *origin_bone2d_node = ObjectDB::get_instance<Bone2D>(fabrik_data_chain[0].bone2d_node_cache);
|
||||
if (!origin_bone2d_node || !origin_bone2d_node->is_inside_tree()) {
|
||||
ERR_PRINT_ONCE("Origin joint's Bone2D node is not in the scene tree. Cannot execute modification!");
|
||||
return;
|
||||
|
|
@ -146,7 +146,7 @@ void SkeletonModification2DFABRIK::_execute(float p_delta) {
|
|||
WARN_PRINT_ONCE("Bone2D cache for joint " + itos(i) + " is out of date.. Attempting to update...");
|
||||
fabrik_joint_update_bone2d_cache(i);
|
||||
}
|
||||
Bone2D *joint_bone2d_node = Object::cast_to<Bone2D>(ObjectDB::get_instance(fabrik_data_chain[i].bone2d_node_cache));
|
||||
Bone2D *joint_bone2d_node = ObjectDB::get_instance<Bone2D>(fabrik_data_chain[i].bone2d_node_cache);
|
||||
if (!joint_bone2d_node) {
|
||||
ERR_PRINT_ONCE("FABRIK Joint " + itos(i) + " does not have a Bone2D node set! Cannot execute modification!");
|
||||
return;
|
||||
|
|
@ -154,7 +154,7 @@ void SkeletonModification2DFABRIK::_execute(float p_delta) {
|
|||
fabrik_transform_chain.write[i] = joint_bone2d_node->get_global_transform();
|
||||
}
|
||||
|
||||
Bone2D *final_bone2d_node = Object::cast_to<Bone2D>(ObjectDB::get_instance(fabrik_data_chain[fabrik_data_chain.size() - 1].bone2d_node_cache));
|
||||
Bone2D *final_bone2d_node = ObjectDB::get_instance<Bone2D>(fabrik_data_chain[fabrik_data_chain.size() - 1].bone2d_node_cache);
|
||||
float final_bone2d_angle = final_bone2d_node->get_global_rotation();
|
||||
if (fabrik_data_chain[fabrik_data_chain.size() - 1].use_target_rotation) {
|
||||
final_bone2d_angle = target_global_pose.get_rotation();
|
||||
|
|
@ -183,7 +183,7 @@ void SkeletonModification2DFABRIK::_execute(float p_delta) {
|
|||
|
||||
// Apply all of the saved transforms to the Bone2D nodes
|
||||
for (int i = 0; i < fabrik_data_chain.size(); i++) {
|
||||
Bone2D *joint_bone2d_node = Object::cast_to<Bone2D>(ObjectDB::get_instance(fabrik_data_chain[i].bone2d_node_cache));
|
||||
Bone2D *joint_bone2d_node = ObjectDB::get_instance<Bone2D>(fabrik_data_chain[i].bone2d_node_cache);
|
||||
if (!joint_bone2d_node) {
|
||||
ERR_PRINT_ONCE("FABRIK Joint " + itos(i) + " does not have a Bone2D node set!");
|
||||
continue;
|
||||
|
|
@ -214,7 +214,7 @@ void SkeletonModification2DFABRIK::_execute(float p_delta) {
|
|||
|
||||
void SkeletonModification2DFABRIK::chain_backwards() {
|
||||
int final_joint_index = fabrik_data_chain.size() - 1;
|
||||
Bone2D *final_bone2d_node = Object::cast_to<Bone2D>(ObjectDB::get_instance(fabrik_data_chain[final_joint_index].bone2d_node_cache));
|
||||
Bone2D *final_bone2d_node = ObjectDB::get_instance<Bone2D>(fabrik_data_chain[final_joint_index].bone2d_node_cache);
|
||||
Transform2D final_bone2d_trans = fabrik_transform_chain[final_joint_index];
|
||||
|
||||
// Apply magnet position
|
||||
|
|
@ -241,7 +241,7 @@ void SkeletonModification2DFABRIK::chain_backwards() {
|
|||
while (i >= 1) {
|
||||
Transform2D previous_pose = fabrik_transform_chain[i];
|
||||
i -= 1;
|
||||
Bone2D *current_bone2d_node = Object::cast_to<Bone2D>(ObjectDB::get_instance(fabrik_data_chain[i].bone2d_node_cache));
|
||||
Bone2D *current_bone2d_node = ObjectDB::get_instance<Bone2D>(fabrik_data_chain[i].bone2d_node_cache);
|
||||
Transform2D current_pose = fabrik_transform_chain[i];
|
||||
|
||||
// Apply magnet position
|
||||
|
|
@ -266,7 +266,7 @@ void SkeletonModification2DFABRIK::chain_forwards() {
|
|||
fabrik_transform_chain.write[0] = origin_bone2d_trans;
|
||||
|
||||
for (int i = 0; i < fabrik_data_chain.size() - 1; i++) {
|
||||
Bone2D *current_bone2d_node = Object::cast_to<Bone2D>(ObjectDB::get_instance(fabrik_data_chain[i].bone2d_node_cache));
|
||||
Bone2D *current_bone2d_node = ObjectDB::get_instance<Bone2D>(fabrik_data_chain[i].bone2d_node_cache);
|
||||
Transform2D current_pose = fabrik_transform_chain[i];
|
||||
Transform2D next_pose = fabrik_transform_chain[i + 1];
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKELETON_MODIFICATION_2D_FABRIK_H
|
||||
#define SKELETON_MODIFICATION_2D_FABRIK_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/2d/skeleton_2d.h"
|
||||
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
|
||||
|
|
@ -104,5 +103,3 @@ public:
|
|||
SkeletonModification2DFABRIK();
|
||||
~SkeletonModification2DFABRIK();
|
||||
};
|
||||
|
||||
#endif // SKELETON_MODIFICATION_2D_FABRIK_H
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ void SkeletonModification2DJiggle::_execute(float p_delta) {
|
|||
update_target_cache();
|
||||
return;
|
||||
}
|
||||
Node2D *target = Object::cast_to<Node2D>(ObjectDB::get_instance(target_node_cache));
|
||||
Node2D *target = ObjectDB::get_instance<Node2D>(target_node_cache);
|
||||
if (!target || !target->is_inside_tree()) {
|
||||
ERR_PRINT_ONCE("Target node is not in the scene tree. Cannot execute modification!");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKELETON_MODIFICATION_2D_JIGGLE_H
|
||||
#define SKELETON_MODIFICATION_2D_JIGGLE_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/2d/skeleton_2d.h"
|
||||
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
|
||||
|
|
@ -135,5 +134,3 @@ public:
|
|||
SkeletonModification2DJiggle();
|
||||
~SkeletonModification2DJiggle();
|
||||
};
|
||||
|
||||
#endif // SKELETON_MODIFICATION_2D_JIGGLE_H
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ void SkeletonModification2DLookAt::_execute(float p_delta) {
|
|||
}
|
||||
|
||||
if (target_node_reference == nullptr) {
|
||||
target_node_reference = Object::cast_to<Node2D>(ObjectDB::get_instance(target_node_cache));
|
||||
target_node_reference = ObjectDB::get_instance<Node2D>(target_node_cache);
|
||||
}
|
||||
if (!target_node_reference || !target_node_reference->is_inside_tree()) {
|
||||
ERR_PRINT_ONCE("Target node is not in the scene tree. Cannot execute modification!");
|
||||
|
|
@ -399,7 +399,7 @@ SkeletonModification2DLookAt::SkeletonModification2DLookAt() {
|
|||
additional_rotation = 0;
|
||||
enable_constraint = false;
|
||||
constraint_angle_min = 0;
|
||||
constraint_angle_max = Math_PI * 2;
|
||||
constraint_angle_max = Math::PI * 2;
|
||||
constraint_angle_invert = false;
|
||||
enabled = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKELETON_MODIFICATION_2D_LOOKAT_H
|
||||
#define SKELETON_MODIFICATION_2D_LOOKAT_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/2d/skeleton_2d.h"
|
||||
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
|
||||
|
|
@ -53,7 +52,7 @@ private:
|
|||
float additional_rotation = 0;
|
||||
bool enable_constraint = false;
|
||||
float constraint_angle_min = 0;
|
||||
float constraint_angle_max = (2.0 * Math_PI);
|
||||
float constraint_angle_max = (2.0 * Math::PI);
|
||||
bool constraint_angle_invert = false;
|
||||
bool constraint_in_localspace = true;
|
||||
|
||||
|
|
@ -96,5 +95,3 @@ public:
|
|||
SkeletonModification2DLookAt();
|
||||
~SkeletonModification2DLookAt();
|
||||
};
|
||||
|
||||
#endif // SKELETON_MODIFICATION_2D_LOOKAT_H
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ void SkeletonModification2DPhysicalBones::_execute(float p_delta) {
|
|||
continue;
|
||||
}
|
||||
|
||||
PhysicalBone2D *physical_bone = Object::cast_to<PhysicalBone2D>(ObjectDB::get_instance(bone_data.physical_bone_node_cache));
|
||||
PhysicalBone2D *physical_bone = ObjectDB::get_instance<PhysicalBone2D>(bone_data.physical_bone_node_cache);
|
||||
if (!physical_bone) {
|
||||
ERR_PRINT_ONCE("PhysicalBone2D not found at index " + itos(i) + "!");
|
||||
return;
|
||||
|
|
@ -238,7 +238,7 @@ void SkeletonModification2DPhysicalBones::_update_simulation_state() {
|
|||
}
|
||||
_simulation_state_dirty = false;
|
||||
|
||||
if (_simulation_state_dirty_names.size() <= 0) {
|
||||
if (_simulation_state_dirty_names.is_empty()) {
|
||||
for (int i = 0; i < physical_bone_chain.size(); i++) {
|
||||
PhysicalBone2D *physical_bone = Object::cast_to<PhysicalBone2D>(stack->skeleton->get_node(physical_bone_chain[i].physical_bone_node));
|
||||
if (!physical_bone) {
|
||||
|
|
@ -249,7 +249,7 @@ void SkeletonModification2DPhysicalBones::_update_simulation_state() {
|
|||
}
|
||||
} else {
|
||||
for (int i = 0; i < physical_bone_chain.size(); i++) {
|
||||
PhysicalBone2D *physical_bone = Object::cast_to<PhysicalBone2D>(ObjectDB::get_instance(physical_bone_chain[i].physical_bone_node_cache));
|
||||
PhysicalBone2D *physical_bone = ObjectDB::get_instance<PhysicalBone2D>(physical_bone_chain[i].physical_bone_node_cache);
|
||||
if (!physical_bone) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKELETON_MODIFICATION_2D_PHYSICALBONES_H
|
||||
#define SKELETON_MODIFICATION_2D_PHYSICALBONES_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/2d/skeleton_2d.h"
|
||||
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
|
||||
|
|
@ -78,5 +77,3 @@ public:
|
|||
SkeletonModification2DPhysicalBones();
|
||||
~SkeletonModification2DPhysicalBones();
|
||||
};
|
||||
|
||||
#endif // SKELETON_MODIFICATION_2D_PHYSICALBONES_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKELETON_MODIFICATION_2D_STACKHOLDER_H
|
||||
#define SKELETON_MODIFICATION_2D_STACKHOLDER_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/2d/skeleton_2d.h"
|
||||
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
|
||||
|
|
@ -60,5 +59,3 @@ public:
|
|||
SkeletonModification2DStackHolder();
|
||||
~SkeletonModification2DStackHolder();
|
||||
};
|
||||
|
||||
#endif // SKELETON_MODIFICATION_2D_STACKHOLDER_H
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ void SkeletonModification2DTwoBoneIK::_execute(float p_delta) {
|
|||
update_joint_two_bone2d_cache();
|
||||
}
|
||||
|
||||
Node2D *target = Object::cast_to<Node2D>(ObjectDB::get_instance(target_node_cache));
|
||||
Node2D *target = ObjectDB::get_instance<Node2D>(target_node_cache);
|
||||
if (!target || !target->is_inside_tree()) {
|
||||
ERR_PRINT_ONCE("Target node is not in the scene tree. Cannot execute modification!");
|
||||
return;
|
||||
|
|
@ -178,7 +178,7 @@ void SkeletonModification2DTwoBoneIK::_execute(float p_delta) {
|
|||
// We cannot solve for this angle! Do nothing to avoid setting the rotation (and scale) to NaN.
|
||||
} else {
|
||||
joint_one_bone->set_global_rotation(angle_atan - angle_0 - joint_one_bone->get_bone_angle());
|
||||
joint_two_bone->set_rotation(-Math_PI - angle_1 - joint_two_bone->get_bone_angle() + joint_one_bone->get_bone_angle());
|
||||
joint_two_bone->set_rotation(-Math::PI - angle_1 - joint_two_bone->get_bone_angle() + joint_one_bone->get_bone_angle());
|
||||
}
|
||||
} else {
|
||||
joint_one_bone->set_global_rotation(angle_atan - joint_one_bone->get_bone_angle());
|
||||
|
|
@ -221,10 +221,10 @@ void SkeletonModification2DTwoBoneIK::_draw_editor_gizmo() {
|
|||
#endif // TOOLS_ENABLED
|
||||
|
||||
if (flip_bend_direction) {
|
||||
float angle = -(Math_PI * 0.5) + operation_bone_one->get_bone_angle();
|
||||
float angle = -(Math::PI * 0.5) + operation_bone_one->get_bone_angle();
|
||||
stack->skeleton->draw_line(Vector2(0, 0), Vector2(Math::cos(angle), sin(angle)) * (operation_bone_one->get_length() * 0.5), bone_ik_color, 2.0);
|
||||
} else {
|
||||
float angle = (Math_PI * 0.5) + operation_bone_one->get_bone_angle();
|
||||
float angle = (Math::PI * 0.5) + operation_bone_one->get_bone_angle();
|
||||
stack->skeleton->draw_line(Vector2(0, 0), Vector2(Math::cos(angle), sin(angle)) * (operation_bone_one->get_length() * 0.5), bone_ik_color, 2.0);
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ void SkeletonModification2DTwoBoneIK::_draw_editor_gizmo() {
|
|||
Vector2 target_direction = Vector2(0, 1);
|
||||
if (target_node_cache.is_valid()) {
|
||||
stack->skeleton->draw_set_transform(Vector2(0, 0), 0.0);
|
||||
Node2D *target = Object::cast_to<Node2D>(ObjectDB::get_instance(target_node_cache));
|
||||
Node2D *target = ObjectDB::get_instance<Node2D>(target_node_cache);
|
||||
target_direction = operation_bone_one->get_global_position().direction_to(target->get_global_position());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKELETON_MODIFICATION_2D_TWOBONEIK_H
|
||||
#define SKELETON_MODIFICATION_2D_TWOBONEIK_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/2d/skeleton_2d.h"
|
||||
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
|
||||
|
|
@ -103,5 +102,3 @@ public:
|
|||
SkeletonModification2DTwoBoneIK();
|
||||
~SkeletonModification2DTwoBoneIK();
|
||||
};
|
||||
|
||||
#endif // SKELETON_MODIFICATION_2D_TWOBONEIK_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef SKELETON_MODIFICATION_STACK_2D_H
|
||||
#define SKELETON_MODIFICATION_STACK_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/resource.h"
|
||||
|
||||
|
|
@ -94,5 +93,3 @@ public:
|
|||
|
||||
SkeletonModificationStack2D();
|
||||
};
|
||||
|
||||
#endif // SKELETON_MODIFICATION_STACK_2D_H
|
||||
|
|
|
|||
|
|
@ -32,16 +32,20 @@
|
|||
|
||||
#include "tile_set.h"
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
Ref<NavigationPolygon> TileData::_get_navigation_polygon_bind_compat_84660(int p_layer_id) const {
|
||||
return get_navigation_polygon(p_layer_id, false, false, false);
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
Ref<OccluderPolygon2D> TileData::_get_occluder_bind_compat_84660(int p_layer_id) const {
|
||||
return get_occluder_polygon(p_layer_id, 0, false, false, false);
|
||||
}
|
||||
|
||||
void TileData::_bind_compatibility_methods() {
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
ClassDB::bind_compatibility_method(D_METHOD("get_navigation_polygon"), &TileData::_get_navigation_polygon_bind_compat_84660);
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
ClassDB::bind_compatibility_method(D_METHOD("get_occluder"), &TileData::_get_occluder_bind_compat_84660);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@
|
|||
#include "core/templates/rb_set.h"
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/resources/image_texture.h"
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
#include "servers/navigation_server_2d.h"
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
/////////////////////////////// TileMapPattern //////////////////////////////////////
|
||||
|
||||
|
|
@ -305,8 +308,7 @@ void TileSet::TerrainsPattern::from_array(Array p_terrains) {
|
|||
}
|
||||
|
||||
Array TileSet::TerrainsPattern::as_array() const {
|
||||
Array output;
|
||||
output.push_back(get_terrain());
|
||||
Array output = { get_terrain() };
|
||||
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
|
||||
if (is_valid_bit[i]) {
|
||||
output.push_back(bits[i]);
|
||||
|
|
@ -636,6 +638,7 @@ bool TileSet::get_occlusion_layer_sdf_collision(int p_layer_index) const {
|
|||
return occlusion_layers[p_layer_index].sdf_collision;
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
int TileSet::get_physics_layers_count() const {
|
||||
return physics_layers.size();
|
||||
}
|
||||
|
|
@ -719,6 +722,7 @@ Ref<PhysicsMaterial> TileSet::get_physics_layer_physics_material(int p_layer_ind
|
|||
ERR_FAIL_INDEX_V(p_layer_index, physics_layers.size(), Ref<PhysicsMaterial>());
|
||||
return physics_layers[p_layer_index].physics_material;
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrains
|
||||
int TileSet::get_terrain_sets_count() const {
|
||||
|
|
@ -964,6 +968,7 @@ bool TileSet::is_valid_terrain_peering_bit(int p_terrain_set, TileSet::CellNeigh
|
|||
return is_valid_terrain_peering_bit_for_mode(terrain_mode, p_peering_bit);
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
int TileSet::get_navigation_layers_count() const {
|
||||
return navigation_layers.size();
|
||||
|
|
@ -1038,6 +1043,7 @@ bool TileSet::get_navigation_layer_layer_value(int p_layer_index, int p_layer_nu
|
|||
|
||||
return get_navigation_layer_layers(p_layer_index) & (1 << (p_layer_number - 1));
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Custom data.
|
||||
int TileSet::get_custom_data_layers_count() const {
|
||||
|
|
@ -1177,42 +1183,26 @@ void TileSet::set_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_f
|
|||
ERR_FAIL_COND(p_source_from == TileSet::INVALID_SOURCE || p_source_to == TileSet::INVALID_SOURCE);
|
||||
ERR_FAIL_COND(p_coords_from == TileSetSource::INVALID_ATLAS_COORDS || p_coords_to == TileSetSource::INVALID_ATLAS_COORDS);
|
||||
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
|
||||
Array to;
|
||||
to.push_back(p_source_to);
|
||||
to.push_back(p_coords_to);
|
||||
|
||||
Array from = { p_source_from, p_coords_from };
|
||||
Array to = { p_source_to, p_coords_to };
|
||||
coords_level_proxies[from] = to;
|
||||
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Array TileSet::get_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from };
|
||||
ERR_FAIL_COND_V(!coords_level_proxies.has(from), Array());
|
||||
|
||||
return coords_level_proxies[from];
|
||||
}
|
||||
|
||||
bool TileSet::has_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from };
|
||||
return coords_level_proxies.has(from);
|
||||
}
|
||||
|
||||
void TileSet::remove_coords_level_tile_proxy(int p_source_from, Vector2i p_coords_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from };
|
||||
ERR_FAIL_COND(!coords_level_proxies.has(from));
|
||||
|
||||
coords_level_proxies.erase(from);
|
||||
|
|
@ -1224,47 +1214,27 @@ void TileSet::set_alternative_level_tile_proxy(int p_source_from, Vector2i p_coo
|
|||
ERR_FAIL_COND(p_source_from == TileSet::INVALID_SOURCE || p_source_to == TileSet::INVALID_SOURCE);
|
||||
ERR_FAIL_COND(p_coords_from == TileSetSource::INVALID_ATLAS_COORDS || p_coords_to == TileSetSource::INVALID_ATLAS_COORDS);
|
||||
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
|
||||
Array to;
|
||||
to.push_back(p_source_to);
|
||||
to.push_back(p_coords_to);
|
||||
to.push_back(p_alternative_to);
|
||||
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
Array to = { p_source_to, p_coords_to, p_alternative_to };
|
||||
alternative_level_proxies[from] = to;
|
||||
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Array TileSet::get_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
ERR_FAIL_COND_V(!alternative_level_proxies.has(from), Array());
|
||||
|
||||
return alternative_level_proxies[from];
|
||||
}
|
||||
|
||||
bool TileSet::has_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
return alternative_level_proxies.has(from);
|
||||
}
|
||||
|
||||
void TileSet::remove_alternative_level_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
ERR_FAIL_COND(!alternative_level_proxies.has(from));
|
||||
|
||||
alternative_level_proxies.erase(from);
|
||||
|
|
@ -1306,10 +1276,7 @@ Array TileSet::get_alternative_level_tile_proxies() const {
|
|||
}
|
||||
|
||||
Array TileSet::map_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_alternative_from) const {
|
||||
Array from;
|
||||
from.push_back(p_source_from);
|
||||
from.push_back(p_coords_from);
|
||||
from.push_back(p_alternative_from);
|
||||
Array from = { p_source_from, p_coords_from, p_alternative_from };
|
||||
|
||||
// Check if the tile is valid, and if so, don't map the tile and return the input.
|
||||
if (has_source(p_source_from)) {
|
||||
|
|
@ -1334,17 +1301,11 @@ Array TileSet::map_tile_proxy(int p_source_from, Vector2i p_coords_from, int p_a
|
|||
|
||||
// Source matches.
|
||||
if (source_level_proxies.has(p_source_from)) {
|
||||
Array output;
|
||||
output.push_back(source_level_proxies[p_source_from]);
|
||||
output.push_back(p_coords_from);
|
||||
output.push_back(p_alternative_from);
|
||||
Array output = { source_level_proxies[p_source_from], p_coords_from, p_alternative_from };
|
||||
return output;
|
||||
}
|
||||
|
||||
Array output;
|
||||
output.push_back(p_source_from);
|
||||
output.push_back(p_coords_from);
|
||||
output.push_back(p_alternative_from);
|
||||
Array output = { p_source_from, p_coords_from, p_alternative_from };
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
@ -3238,8 +3199,10 @@ void TileSet::reset_state() {
|
|||
tile_filled_mesh.instantiate();
|
||||
tile_meshes_dirty = true;
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
physics_layers.clear();
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrains
|
||||
terrain_sets.clear();
|
||||
|
|
@ -3423,15 +3386,8 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
|
||||
// Add to the mapping.
|
||||
Array key_array;
|
||||
key_array.push_back(flip_h);
|
||||
key_array.push_back(flip_v);
|
||||
key_array.push_back(transpose);
|
||||
|
||||
Array value_array;
|
||||
value_array.push_back(source_id);
|
||||
value_array.push_back(coords);
|
||||
value_array.push_back(alternative_tile);
|
||||
Array key_array = { flip_h, flip_v, transpose };
|
||||
Array value_array = { source_id, coords, alternative_tile };
|
||||
|
||||
if (!compatibility_tilemap_mapping.has(E.key)) {
|
||||
compatibility_tilemap_mapping[E.key] = RBMap<Array, Array>();
|
||||
|
|
@ -3462,6 +3418,7 @@ void TileSet::_compatibility_conversion() {
|
|||
tile_data->add_occluder_polygon(0);
|
||||
tile_data->set_occluder_polygon(0, 0, occluder);
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
if (ctd->navigation.is_valid()) {
|
||||
if (get_navigation_layers_count() < 1) {
|
||||
add_navigation_layer();
|
||||
|
|
@ -3474,9 +3431,11 @@ void TileSet::_compatibility_conversion() {
|
|||
navigation->set_vertices(vertices);
|
||||
tile_data->set_navigation_polygon(0, navigation);
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
tile_data->set_z_index(ctd->z_index);
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Add the shapes.
|
||||
if (ctd->shapes.size() > 0) {
|
||||
if (get_physics_layers_count() < 1) {
|
||||
|
|
@ -3500,6 +3459,7 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
}
|
||||
// Update the size count.
|
||||
if (!compatibility_size_count.has(ctd->region.get_size())) {
|
||||
|
|
@ -3539,16 +3499,8 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
|
||||
// Add to the mapping.
|
||||
Array key_array;
|
||||
key_array.push_back(coords);
|
||||
key_array.push_back(flip_h);
|
||||
key_array.push_back(flip_v);
|
||||
key_array.push_back(transpose);
|
||||
|
||||
Array value_array;
|
||||
value_array.push_back(source_id);
|
||||
value_array.push_back(coords);
|
||||
value_array.push_back(alternative_tile);
|
||||
Array key_array = { coords, flip_h, flip_v, transpose };
|
||||
Array value_array = { source_id, coords, alternative_tile };
|
||||
|
||||
if (!compatibility_tilemap_mapping.has(E.key)) {
|
||||
compatibility_tilemap_mapping[E.key] = RBMap<Array, Array>();
|
||||
|
|
@ -3577,6 +3529,7 @@ void TileSet::_compatibility_conversion() {
|
|||
tile_data->add_occluder_polygon(0);
|
||||
tile_data->set_occluder_polygon(0, 0, occluder);
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
if (ctd->autotile_navpoly_map.has(coords)) {
|
||||
if (get_navigation_layers_count() < 1) {
|
||||
add_navigation_layer();
|
||||
|
|
@ -3589,6 +3542,7 @@ void TileSet::_compatibility_conversion() {
|
|||
navigation->set_vertices(vertices);
|
||||
tile_data->set_navigation_polygon(0, navigation);
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
if (ctd->autotile_priority_map.has(coords)) {
|
||||
tile_data->set_probability(ctd->autotile_priority_map[coords]);
|
||||
}
|
||||
|
|
@ -3596,6 +3550,7 @@ void TileSet::_compatibility_conversion() {
|
|||
tile_data->set_z_index(ctd->autotile_z_index_map[coords]);
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Add the shapes.
|
||||
if (ctd->shapes.size() > 0) {
|
||||
if (get_physics_layers_count() < 1) {
|
||||
|
|
@ -3619,6 +3574,7 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// -- TODO: handle --
|
||||
// Those are offset for the whole atlas, they are likely useless for the atlases, but might make sense for single tiles.
|
||||
|
|
@ -3641,6 +3597,7 @@ void TileSet::_compatibility_conversion() {
|
|||
} break;
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Offset all shapes
|
||||
for (int k = 0; k < ctd->shapes.size(); k++) {
|
||||
Ref<ConvexPolygonShape2D> convex = ctd->shapes[k].shape;
|
||||
|
|
@ -3652,6 +3609,7 @@ void TileSet::_compatibility_conversion() {
|
|||
convex->set_points(points);
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
}
|
||||
|
||||
// Update the TileSet tile_size according to the most common size found.
|
||||
|
|
@ -3673,10 +3631,11 @@ void TileSet::_compatibility_conversion() {
|
|||
}
|
||||
|
||||
Array TileSet::compatibility_tilemap_map(int p_tile_id, Vector2i p_coords, bool p_flip_h, bool p_flip_v, bool p_transpose) {
|
||||
Array cannot_convert_array;
|
||||
cannot_convert_array.push_back(TileSet::INVALID_SOURCE);
|
||||
cannot_convert_array.push_back(TileSetAtlasSource::INVALID_ATLAS_COORDS);
|
||||
cannot_convert_array.push_back(TileSetAtlasSource::INVALID_TILE_ALTERNATIVE);
|
||||
Array cannot_convert_array = {
|
||||
TileSet::INVALID_SOURCE,
|
||||
TileSetAtlasSource::INVALID_ATLAS_COORDS,
|
||||
TileSetAtlasSource::INVALID_TILE_ALTERNATIVE
|
||||
};
|
||||
|
||||
if (!compatibility_tilemap_mapping.has(p_tile_id)) {
|
||||
return cannot_convert_array;
|
||||
|
|
@ -3685,21 +3644,14 @@ Array TileSet::compatibility_tilemap_map(int p_tile_id, Vector2i p_coords, bool
|
|||
int tile_mode = compatibility_tilemap_mapping_tile_modes[p_tile_id];
|
||||
switch (tile_mode) {
|
||||
case COMPATIBILITY_TILE_MODE_SINGLE_TILE: {
|
||||
Array a;
|
||||
a.push_back(p_flip_h);
|
||||
a.push_back(p_flip_v);
|
||||
a.push_back(p_transpose);
|
||||
Array a = { p_flip_h, p_flip_v, p_transpose };
|
||||
return compatibility_tilemap_mapping[p_tile_id][a];
|
||||
}
|
||||
case COMPATIBILITY_TILE_MODE_AUTO_TILE:
|
||||
return cannot_convert_array;
|
||||
break;
|
||||
case COMPATIBILITY_TILE_MODE_ATLAS_TILE: {
|
||||
Array a;
|
||||
a.push_back(p_coords);
|
||||
a.push_back(p_flip_h);
|
||||
a.push_back(p_flip_v);
|
||||
a.push_back(p_transpose);
|
||||
Array a = { p_coords, p_flip_h, p_flip_v, p_transpose };
|
||||
return compatibility_tilemap_mapping[p_tile_id][a];
|
||||
}
|
||||
default:
|
||||
|
|
@ -3789,7 +3741,9 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
if (p[0].get_type() == Variant::VECTOR2) {
|
||||
last_coord = p[0];
|
||||
} else if (p[0].get_type() == Variant::OBJECT) {
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
ctd->autotile_navpoly_map.insert(last_coord, p[0]);
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
}
|
||||
p.pop_front();
|
||||
}
|
||||
|
|
@ -3830,18 +3784,20 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
for (int i = 0; i < p.size(); i++) {
|
||||
CompatibilityShapeData csd;
|
||||
Dictionary d = p[i];
|
||||
for (int j = 0; j < d.size(); j++) {
|
||||
String key = d.get_key_at_index(j);
|
||||
for (const KeyValue<Variant, Variant> &kv : d) {
|
||||
String key = kv.key;
|
||||
if (key == "autotile_coord") {
|
||||
csd.autotile_coords = d[key];
|
||||
csd.autotile_coords = kv.value;
|
||||
} else if (key == "one_way") {
|
||||
csd.one_way = d[key];
|
||||
csd.one_way = kv.value;
|
||||
} else if (key == "one_way_margin") {
|
||||
csd.one_way_margin = d[key];
|
||||
csd.one_way_margin = kv.value;
|
||||
} else if (key == "shape") {
|
||||
csd.shape = d[key];
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
csd.shape = kv.value;
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
} else if (key == "shape_transform") {
|
||||
csd.transform = d[key];
|
||||
csd.transform = kv.value;
|
||||
}
|
||||
}
|
||||
ctd->shapes.push_back(csd);
|
||||
|
|
@ -3849,7 +3805,9 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
} else if (what == "occluder") {
|
||||
ctd->occluder = p_value;
|
||||
} else if (what == "navigation") {
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
ctd->navigation = p_value;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
/*
|
||||
// IGNORED FOR NOW, they seem duplicated data compared to the shapes array
|
||||
|
|
@ -3897,6 +3855,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
set_occlusion_layer_sdf_collision(index, p_value);
|
||||
return true;
|
||||
}
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
} else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
// Physics layers.
|
||||
int index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
|
|
@ -3930,6 +3889,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
set_physics_layer_physics_material(index, physics_material);
|
||||
return true;
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int()) {
|
||||
// Terrains.
|
||||
int terrain_set_index = components[0].trim_prefix("terrain_set_").to_int();
|
||||
|
|
@ -3966,6 +3926,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
}
|
||||
}
|
||||
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation layers.
|
||||
int index = components[0].trim_prefix("navigation_layer_").to_int();
|
||||
ERR_FAIL_COND_V(index < 0, false);
|
||||
|
|
@ -3977,6 +3938,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
|
|||
set_navigation_layer_layers(index, p_value);
|
||||
return true;
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) {
|
||||
// Custom data layers.
|
||||
int index = components[0].trim_prefix("custom_data_layer_").to_int();
|
||||
|
|
@ -4061,6 +4023,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
r_ret = get_occlusion_layer_sdf_collision(index);
|
||||
return true;
|
||||
}
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
} else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
// Physics layers.
|
||||
int index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
|
|
@ -4080,6 +4043,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
r_ret = get_physics_layer_physics_material(index);
|
||||
return true;
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int()) {
|
||||
// Terrains.
|
||||
int terrain_set_index = components[0].trim_prefix("terrain_set_").to_int();
|
||||
|
|
@ -4108,10 +4072,12 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
if (index < 0 || index >= navigation_layers.size()) {
|
||||
return false;
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
if (components[1] == "layers") {
|
||||
r_ret = get_navigation_layer_layers(index);
|
||||
return true;
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) {
|
||||
// Custom data layers.
|
||||
int index = components[0].trim_prefix("custom_data_layer_").to_int();
|
||||
|
|
@ -4189,6 +4155,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
p_list->push_back(property_info);
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Physics", ""), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
|
||||
for (int i = 0; i < physics_layers.size(); i++) {
|
||||
|
|
@ -4215,6 +4182,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
}
|
||||
p_list->push_back(property_info);
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrains.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Terrains", ""), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
|
||||
|
|
@ -4310,6 +4278,7 @@ void TileSet::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_occlusion_layer_sdf_collision", "layer_index", "sdf_collision"), &TileSet::set_occlusion_layer_sdf_collision);
|
||||
ClassDB::bind_method(D_METHOD("get_occlusion_layer_sdf_collision", "layer_index"), &TileSet::get_occlusion_layer_sdf_collision);
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
ClassDB::bind_method(D_METHOD("get_physics_layers_count"), &TileSet::get_physics_layers_count);
|
||||
ClassDB::bind_method(D_METHOD("add_physics_layer", "to_position"), &TileSet::add_physics_layer, DEFVAL(-1));
|
||||
|
|
@ -4323,6 +4292,7 @@ void TileSet::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_physics_layer_collision_priority", "layer_index"), &TileSet::get_physics_layer_collision_priority);
|
||||
ClassDB::bind_method(D_METHOD("set_physics_layer_physics_material", "layer_index", "physics_material"), &TileSet::set_physics_layer_physics_material);
|
||||
ClassDB::bind_method(D_METHOD("get_physics_layer_physics_material", "layer_index"), &TileSet::get_physics_layer_physics_material);
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrains
|
||||
ClassDB::bind_method(D_METHOD("get_terrain_sets_count"), &TileSet::get_terrain_sets_count);
|
||||
|
|
@ -4341,6 +4311,7 @@ void TileSet::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_terrain_color", "terrain_set", "terrain_index", "color"), &TileSet::set_terrain_color);
|
||||
ClassDB::bind_method(D_METHOD("get_terrain_color", "terrain_set", "terrain_index"), &TileSet::get_terrain_color);
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layers_count"), &TileSet::get_navigation_layers_count);
|
||||
ClassDB::bind_method(D_METHOD("add_navigation_layer", "to_position"), &TileSet::add_navigation_layer, DEFVAL(-1));
|
||||
|
|
@ -4350,6 +4321,7 @@ void TileSet::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_navigation_layer_layers", "layer_index"), &TileSet::get_navigation_layer_layers);
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_layer_layer_value", "layer_index", "layer_number", "value"), &TileSet::set_navigation_layer_layer_value);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_layer_layer_value", "layer_index", "layer_number"), &TileSet::get_navigation_layer_layer_value);
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Custom data
|
||||
ClassDB::bind_method(D_METHOD("get_custom_data_layers_count"), &TileSet::get_custom_data_layers_count);
|
||||
|
|
@ -4397,7 +4369,9 @@ void TileSet::_bind_methods() {
|
|||
ADD_GROUP("", "");
|
||||
ADD_ARRAY("physics_layers", "physics_layer_");
|
||||
ADD_ARRAY("terrain_sets", "terrain_set_");
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
ADD_ARRAY("navigation_layers", "navigation_layer_");
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
ADD_ARRAY("custom_data_layers", "custom_data_layer_");
|
||||
|
||||
// -- Enum binding --
|
||||
|
|
@ -4531,6 +4505,7 @@ void TileSetAtlasSource::remove_occlusion_layer(int p_index) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
void TileSetAtlasSource::add_physics_layer(int p_to_pos) {
|
||||
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
|
||||
for (KeyValue<int, TileData *> E_alternative : E_tile.value.alternatives) {
|
||||
|
|
@ -4554,6 +4529,7 @@ void TileSetAtlasSource::remove_physics_layer(int p_index) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
void TileSetAtlasSource::add_terrain_set(int p_to_pos) {
|
||||
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
|
||||
|
|
@ -4603,6 +4579,7 @@ void TileSetAtlasSource::remove_terrain(int p_terrain_set, int p_index) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
void TileSetAtlasSource::add_navigation_layer(int p_to_pos) {
|
||||
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
|
||||
for (KeyValue<int, TileData *> E_alternative : E_tile.value.alternatives) {
|
||||
|
|
@ -4626,6 +4603,7 @@ void TileSetAtlasSource::remove_navigation_layer(int p_index) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
void TileSetAtlasSource::add_custom_data_layer(int p_to_pos) {
|
||||
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
|
||||
|
|
@ -5969,13 +5947,17 @@ void TileData::notify_tile_data_properties_should_change() {
|
|||
}
|
||||
|
||||
occluders.resize(tile_set->get_occlusion_layers_count());
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
physics.resize(tile_set->get_physics_layers_count());
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
for (int bit_index = 0; bit_index < 16; bit_index++) {
|
||||
if (terrain_set < 0 || terrain_peering_bits[bit_index] >= tile_set->get_terrains_count(terrain_set)) {
|
||||
terrain_peering_bits[bit_index] = -1;
|
||||
}
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
navigation.resize(tile_set->get_navigation_layers_count());
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Convert custom data to the new type.
|
||||
custom_data.resize(tile_set->get_custom_data_layers_count());
|
||||
|
|
@ -6017,6 +5999,7 @@ void TileData::remove_occlusion_layer(int p_index) {
|
|||
occluders.remove_at(p_index);
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
void TileData::add_physics_layer(int p_to_pos) {
|
||||
if (p_to_pos < 0) {
|
||||
p_to_pos = physics.size();
|
||||
|
|
@ -6036,6 +6019,7 @@ void TileData::remove_physics_layer(int p_index) {
|
|||
ERR_FAIL_INDEX(p_index, physics.size());
|
||||
physics.remove_at(p_index);
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
void TileData::add_terrain_set(int p_to_pos) {
|
||||
if (p_to_pos >= 0 && p_to_pos <= terrain_set) {
|
||||
|
|
@ -6112,6 +6096,7 @@ void TileData::remove_terrain(int p_terrain_set, int p_index) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
void TileData::add_navigation_layer(int p_to_pos) {
|
||||
if (p_to_pos < 0) {
|
||||
p_to_pos = navigation.size();
|
||||
|
|
@ -6131,6 +6116,7 @@ void TileData::remove_navigation_layer(int p_index) {
|
|||
ERR_FAIL_INDEX(p_index, navigation.size());
|
||||
navigation.remove_at(p_index);
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
void TileData::add_custom_data_layer(int p_to_pos) {
|
||||
if (p_to_pos < 0) {
|
||||
|
|
@ -6176,13 +6162,17 @@ TileData *TileData::duplicate() {
|
|||
output->z_index = z_index;
|
||||
output->y_sort_origin = y_sort_origin;
|
||||
output->occluders = occluders;
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
output->physics = physics;
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
// Terrain
|
||||
output->terrain_set = -1;
|
||||
memcpy(output->terrain_peering_bits, terrain_peering_bits, 16 * sizeof(int));
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
output->navigation = navigation;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
// Misc
|
||||
output->probability = probability;
|
||||
// Custom data
|
||||
|
|
@ -6347,6 +6337,7 @@ Ref<OccluderPolygon2D> TileData::get_occluder_polygon(int p_layer_id, int p_poly
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
void TileData::set_constant_linear_velocity(int p_layer_id, const Vector2 &p_velocity) {
|
||||
ERR_FAIL_INDEX(p_layer_id, physics.size());
|
||||
|
|
@ -6495,6 +6486,7 @@ Ref<ConvexPolygonShape2D> TileData::get_collision_polygon_shape(int p_layer_id,
|
|||
return I->value[shape_index];
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrain
|
||||
void TileData::set_terrain_set(int p_terrain_set) {
|
||||
|
|
@ -6568,6 +6560,7 @@ TileSet::TerrainsPattern TileData::get_terrains_pattern() const {
|
|||
return output;
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
void TileData::set_navigation_polygon(int p_layer_id, Ref<NavigationPolygon> p_navigation_polygon) {
|
||||
ERR_FAIL_INDEX(p_layer_id, navigation.size());
|
||||
|
|
@ -6615,6 +6608,7 @@ Ref<NavigationPolygon> TileData::get_navigation_polygon(int p_layer_id, bool p_f
|
|||
return I->value;
|
||||
}
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Misc
|
||||
void TileData::set_probability(float p_probability) {
|
||||
|
|
@ -6743,7 +6737,9 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
}
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
// Physics layers.
|
||||
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6798,7 +6794,10 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
// Navigation layers.
|
||||
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6815,7 +6814,9 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
|
|||
set_navigation_polygon(layer_index, polygon);
|
||||
return true;
|
||||
}
|
||||
} else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
|
||||
// Terrains.
|
||||
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
|
||||
TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
|
||||
|
|
@ -6887,7 +6888,9 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
}
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
// Physics layers.
|
||||
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6923,7 +6926,9 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
} else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
|
||||
// Terrains.
|
||||
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
|
||||
if (components[1] == TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]) {
|
||||
|
|
@ -6932,7 +6937,9 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
}
|
||||
}
|
||||
return false;
|
||||
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
}
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
// Occlusion layers.
|
||||
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6943,7 +6950,9 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
r_ret = get_navigation_polygon(layer_index);
|
||||
return true;
|
||||
}
|
||||
} else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) {
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) {
|
||||
// Custom data layers.
|
||||
int layer_index = components[0].trim_prefix("custom_data_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
|
@ -6976,6 +6985,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics layers.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Physics", ""), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
|
||||
for (int i = 0; i < physics.size(); i++) {
|
||||
|
|
@ -7018,6 +7028,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
p_list->push_back(property_info);
|
||||
}
|
||||
}
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrain data
|
||||
if (terrain_set >= 0) {
|
||||
|
|
@ -7034,6 +7045,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation layers.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Navigation", ""), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
|
||||
for (int i = 0; i < navigation.size(); i++) {
|
||||
|
|
@ -7043,6 +7055,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
|
|||
}
|
||||
p_list->push_back(property_info);
|
||||
}
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Custom data layers.
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Custom Data", "custom_data_"), PROPERTY_HINT_NONE, "custom_data_", PROPERTY_USAGE_GROUP));
|
||||
|
|
@ -7090,6 +7103,7 @@ void TileData::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_occluder", "layer_id", "flip_h", "flip_v", "transpose"), &TileData::get_occluder, DEFVAL(false), DEFVAL(false), DEFVAL(false));
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics.
|
||||
ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "layer_id", "velocity"), &TileData::set_constant_linear_velocity);
|
||||
ClassDB::bind_method(D_METHOD("get_constant_linear_velocity", "layer_id"), &TileData::get_constant_linear_velocity);
|
||||
|
|
@ -7105,6 +7119,7 @@ void TileData::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("is_collision_polygon_one_way", "layer_id", "polygon_index"), &TileData::is_collision_polygon_one_way);
|
||||
ClassDB::bind_method(D_METHOD("set_collision_polygon_one_way_margin", "layer_id", "polygon_index", "one_way_margin"), &TileData::set_collision_polygon_one_way_margin);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_polygon_one_way_margin", "layer_id", "polygon_index"), &TileData::get_collision_polygon_one_way_margin);
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrain
|
||||
ClassDB::bind_method(D_METHOD("set_terrain_set", "terrain_set"), &TileData::set_terrain_set);
|
||||
|
|
@ -7115,9 +7130,11 @@ void TileData::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_terrain_peering_bit", "peering_bit"), &TileData::get_terrain_peering_bit);
|
||||
ClassDB::bind_method(D_METHOD("is_valid_terrain_peering_bit", "peering_bit"), &TileData::is_valid_terrain_peering_bit);
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_polygon", "layer_id", "navigation_polygon"), &TileData::set_navigation_polygon);
|
||||
ClassDB::bind_method(D_METHOD("get_navigation_polygon", "layer_id", "flip_h", "flip_v", "transpose"), &TileData::get_navigation_polygon, DEFVAL(false), DEFVAL(false), DEFVAL(false));
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Misc.
|
||||
ClassDB::bind_method(D_METHOD("set_probability", "probability"), &TileData::set_probability);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TILE_SET_H
|
||||
#define TILE_SET_H
|
||||
#pragma once
|
||||
|
||||
#include "core/io/resource.h"
|
||||
#include "core/object/object.h"
|
||||
|
|
@ -37,12 +36,18 @@
|
|||
#include "core/templates/rb_set.h"
|
||||
#include "scene/2d/light_occluder_2d.h"
|
||||
#include "scene/main/canvas_item.h"
|
||||
#include "scene/resources/2d/convex_polygon_shape_2d.h"
|
||||
#include "scene/resources/2d/navigation_polygon.h"
|
||||
#include "scene/resources/image_texture.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/physics_material.h"
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
#include "scene/resources/2d/convex_polygon_shape_2d.h"
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
#include "scene/resources/2d/navigation_polygon.h"
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
#include "scene/resources/shader.h"
|
||||
#endif
|
||||
|
|
@ -52,12 +57,6 @@ class TileSetSource;
|
|||
class TileSetAtlasSource;
|
||||
class TileData;
|
||||
|
||||
// Forward-declare the plugins.
|
||||
class TileSetPlugin;
|
||||
class TileSetPluginAtlasRendering;
|
||||
class TileSetPluginAtlasPhysics;
|
||||
class TileSetPluginAtlasNavigation;
|
||||
|
||||
union TileMapCell {
|
||||
struct {
|
||||
int16_t source_id;
|
||||
|
|
@ -154,7 +153,9 @@ private:
|
|||
Vector2i autotile_coords;
|
||||
bool one_way;
|
||||
float one_way_margin;
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
Ref<Shape2D> shape;
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
Transform2D transform;
|
||||
};
|
||||
|
||||
|
|
@ -175,14 +176,18 @@ private:
|
|||
int autotile_spacing = 0;
|
||||
HashMap<Vector2i, int> autotile_bitmask_flags;
|
||||
HashMap<Vector2i, Ref<OccluderPolygon2D>> autotile_occluder_map;
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
HashMap<Vector2i, Ref<NavigationPolygon>> autotile_navpoly_map;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
HashMap<Vector2i, int> autotile_priority_map;
|
||||
HashMap<Vector2i, int> autotile_z_index_map;
|
||||
|
||||
Vector<CompatibilityShapeData> shapes;
|
||||
Ref<OccluderPolygon2D> occluder;
|
||||
Vector2 occluder_offset;
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
Ref<NavigationPolygon> navigation;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
Vector2 navigation_offset;
|
||||
int z_index = 0;
|
||||
};
|
||||
|
|
@ -323,6 +328,7 @@ private:
|
|||
Ref<ArrayMesh> tile_filled_mesh;
|
||||
mutable bool tile_meshes_dirty = true;
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
struct PhysicsLayer {
|
||||
uint32_t collision_layer = 1;
|
||||
|
|
@ -331,6 +337,7 @@ private:
|
|||
Ref<PhysicsMaterial> physics_material;
|
||||
};
|
||||
Vector<PhysicsLayer> physics_layers;
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrains
|
||||
struct Terrain {
|
||||
|
|
@ -401,9 +408,6 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
// --- Plugins ---
|
||||
Vector<TileSetPlugin *> get_tile_set_atlas_plugins() const;
|
||||
|
||||
// --- Accessors for TileSet data ---
|
||||
|
||||
// -- Shape and layout --
|
||||
|
|
@ -440,6 +444,7 @@ public:
|
|||
void set_occlusion_layer_sdf_collision(int p_layer_index, bool p_sdf_collision);
|
||||
bool get_occlusion_layer_sdf_collision(int p_layer_index) const;
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
int get_physics_layers_count() const;
|
||||
void add_physics_layer(int p_index = -1);
|
||||
|
|
@ -453,6 +458,7 @@ public:
|
|||
real_t get_physics_layer_collision_priority(int p_layer_index) const;
|
||||
void set_physics_layer_physics_material(int p_layer_index, Ref<PhysicsMaterial> p_physics_material);
|
||||
Ref<PhysicsMaterial> get_physics_layer_physics_material(int p_layer_index) const;
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrain sets
|
||||
int get_terrain_sets_count() const;
|
||||
|
|
@ -474,6 +480,7 @@ public:
|
|||
bool is_valid_terrain_peering_bit_for_mode(TileSet::TerrainMode p_terrain_mode, TileSet::CellNeighbor p_peering_bit) const;
|
||||
bool is_valid_terrain_peering_bit(int p_terrain_set, TileSet::CellNeighbor p_peering_bit) const;
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
int get_navigation_layers_count() const;
|
||||
void add_navigation_layer(int p_index = -1);
|
||||
|
|
@ -483,6 +490,7 @@ public:
|
|||
uint32_t get_navigation_layer_layers(int p_layer_index) const;
|
||||
void set_navigation_layer_layer_value(int p_layer_index, int p_layer_number, bool p_value);
|
||||
bool get_navigation_layer_layer_value(int p_layer_index, int p_layer_number) const;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Custom data
|
||||
int get_custom_data_layers_count() const;
|
||||
|
|
@ -686,18 +694,22 @@ public:
|
|||
virtual void add_occlusion_layer(int p_index) override;
|
||||
virtual void move_occlusion_layer(int p_from_index, int p_to_pos) override;
|
||||
virtual void remove_occlusion_layer(int p_index) override;
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
virtual void add_physics_layer(int p_index) override;
|
||||
virtual void move_physics_layer(int p_from_index, int p_to_pos) override;
|
||||
virtual void remove_physics_layer(int p_index) override;
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
virtual void add_terrain_set(int p_index) override;
|
||||
virtual void move_terrain_set(int p_from_index, int p_to_pos) override;
|
||||
virtual void remove_terrain_set(int p_index) override;
|
||||
virtual void add_terrain(int p_terrain_set, int p_index) override;
|
||||
virtual void move_terrain(int p_terrain_set, int p_from_index, int p_to_pos) override;
|
||||
virtual void remove_terrain(int p_terrain_set, int p_index) override;
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
virtual void add_navigation_layer(int p_index) override;
|
||||
virtual void move_navigation_layer(int p_from_index, int p_to_pos) override;
|
||||
virtual void remove_navigation_layer(int p_index) override;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
virtual void add_custom_data_layer(int p_index) override;
|
||||
virtual void move_custom_data_layer(int p_from_index, int p_to_pos) override;
|
||||
virtual void remove_custom_data_layer(int p_index) override;
|
||||
|
|
@ -853,6 +865,7 @@ private:
|
|||
};
|
||||
Vector<OcclusionLayerTileData> occluders;
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
struct PhysicsLayerTileData {
|
||||
struct PolygonShapeTileData {
|
||||
|
|
@ -868,19 +881,22 @@ private:
|
|||
Vector<PolygonShapeTileData> polygons;
|
||||
};
|
||||
Vector<PhysicsLayerTileData> physics;
|
||||
// TODO add support for areas.
|
||||
// TODO add support for areas.
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrain
|
||||
int terrain_set = -1;
|
||||
int terrain = -1;
|
||||
int terrain_peering_bits[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
struct NavigationLayerTileData {
|
||||
Ref<NavigationPolygon> navigation_polygon;
|
||||
mutable HashMap<int, Ref<NavigationPolygon>> transformed_navigation_polygon;
|
||||
};
|
||||
Vector<NavigationLayerTileData> navigation;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Misc
|
||||
double probability = 1.0;
|
||||
|
|
@ -895,7 +911,9 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
Ref<NavigationPolygon> _get_navigation_polygon_bind_compat_84660(int p_layer_id) const;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
Ref<OccluderPolygon2D> _get_occluder_bind_compat_84660(int p_layer_id) const;
|
||||
|
||||
static void _bind_compatibility_methods();
|
||||
|
|
@ -908,9 +926,11 @@ public:
|
|||
void add_occlusion_layer(int p_index);
|
||||
void move_occlusion_layer(int p_from_index, int p_to_pos);
|
||||
void remove_occlusion_layer(int p_index);
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
void add_physics_layer(int p_index);
|
||||
void move_physics_layer(int p_from_index, int p_to_pos);
|
||||
void remove_physics_layer(int p_index);
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
void add_terrain_set(int p_index);
|
||||
void move_terrain_set(int p_from_index, int p_to_pos);
|
||||
void remove_terrain_set(int p_index);
|
||||
|
|
@ -960,6 +980,7 @@ public:
|
|||
void set_occluder_polygon(int p_layer_id, int p_polygon_index, const Ref<OccluderPolygon2D> &p_occluder_polygon);
|
||||
Ref<OccluderPolygon2D> get_occluder_polygon(int p_layer_id, int p_polygon_index, bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false) const;
|
||||
|
||||
#ifndef PHYSICS_2D_DISABLED
|
||||
// Physics
|
||||
void set_constant_linear_velocity(int p_layer_id, const Vector2 &p_velocity);
|
||||
Vector2 get_constant_linear_velocity(int p_layer_id) const;
|
||||
|
|
@ -977,6 +998,7 @@ public:
|
|||
float get_collision_polygon_one_way_margin(int p_layer_id, int p_polygon_index) const;
|
||||
int get_collision_polygon_shapes_count(int p_layer_id, int p_polygon_index) const;
|
||||
Ref<ConvexPolygonShape2D> get_collision_polygon_shape(int p_layer_id, int p_polygon_index, int shape_index, bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false) const;
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
// Terrain
|
||||
void set_terrain_set(int p_terrain_id);
|
||||
|
|
@ -989,9 +1011,11 @@ public:
|
|||
|
||||
TileSet::TerrainsPattern get_terrains_pattern() const; // Not exposed.
|
||||
|
||||
#ifndef NAVIGATION_2D_DISABLED
|
||||
// Navigation
|
||||
void set_navigation_polygon(int p_layer_id, Ref<NavigationPolygon> p_navigation_polygon);
|
||||
Ref<NavigationPolygon> get_navigation_polygon(int p_layer_id, bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false) const;
|
||||
#endif // NAVIGATION_2D_DISABLED
|
||||
|
||||
// Misc
|
||||
void set_probability(float p_probability);
|
||||
|
|
@ -1015,5 +1039,3 @@ VARIANT_ENUM_CAST(TileSet::TileLayout);
|
|||
VARIANT_ENUM_CAST(TileSet::TileOffsetAxis);
|
||||
|
||||
VARIANT_ENUM_CAST(TileSetAtlasSource::TileAnimationMode);
|
||||
|
||||
#endif // TILE_SET_H
|
||||
|
|
|
|||
|
|
@ -35,23 +35,26 @@
|
|||
#include "servers/rendering_server.h"
|
||||
|
||||
bool WorldBoundaryShape2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
|
||||
Vector2 point = distance * normal;
|
||||
Vector2 l[2][2] = { { point - normal.orthogonal() * 100, point + normal.orthogonal() * 100 }, { point, point + normal * 30 } };
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Vector2 closest = Geometry2D::get_closest_point_to_segment(p_point, l[i]);
|
||||
if (p_point.distance_to(closest) < p_tolerance) {
|
||||
return true;
|
||||
}
|
||||
const Vector2 shape_center = distance * normal;
|
||||
// Orthogonal part of the shape editor gizmo (the flat line).
|
||||
const Vector2 ortho_segment_a = shape_center - normal.orthogonal() * 100;
|
||||
const Vector2 ortho_segment_b = shape_center + normal.orthogonal() * 100;
|
||||
const Vector2 ortho_closest = Geometry2D::get_closest_point_to_segment(p_point, ortho_segment_a, ortho_segment_b);
|
||||
if (p_point.distance_to(ortho_closest) < p_tolerance) {
|
||||
return true;
|
||||
}
|
||||
// Normal part of the shape editor gizmo (the arrow).
|
||||
const Vector2 normal_segment_a = shape_center;
|
||||
const Vector2 normal_segment_b = shape_center + normal * 30;
|
||||
const Vector2 normal_closest = Geometry2D::get_closest_point_to_segment(p_point, normal_segment_a, normal_segment_b);
|
||||
if (p_point.distance_to(normal_closest) < p_tolerance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void WorldBoundaryShape2D::_update_shape() {
|
||||
Array arr;
|
||||
arr.push_back(normal);
|
||||
arr.push_back(distance);
|
||||
Array arr = { normal, distance };
|
||||
PhysicsServer2D::get_singleton()->shape_set_data(get_rid(), arr);
|
||||
emit_changed();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef WORLD_BOUNDARY_SHAPE_2D_H
|
||||
#define WORLD_BOUNDARY_SHAPE_2D_H
|
||||
#pragma once
|
||||
|
||||
#include "scene/resources/2d/shape_2d.h"
|
||||
|
||||
|
|
@ -60,5 +59,3 @@ public:
|
|||
|
||||
WorldBoundaryShape2D();
|
||||
};
|
||||
|
||||
#endif // WORLD_BOUNDARY_SHAPE_2D_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue