feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -56,7 +56,7 @@ void Curve::set_point_count(int p_count) {
notify_property_list_changed();
}
int Curve::_add_point(Vector2 p_position, real_t p_left_tangent, real_t p_right_tangent, TangentMode p_left_mode, TangentMode p_right_mode) {
int Curve::_add_point(Vector2 p_position, real_t p_left_tangent, real_t p_right_tangent, TangentMode p_left_mode, TangentMode p_right_mode, bool p_mark_dirty) {
// Add a point and preserve order.
// Points must remain within the given value and domain ranges.
@ -65,7 +65,7 @@ int Curve::_add_point(Vector2 p_position, real_t p_left_tangent, real_t p_right_
int ret = -1;
if (_points.size() == 0) {
if (_points.is_empty()) {
_points.push_back(Point(p_position, p_left_tangent, p_right_tangent, p_left_mode, p_right_mode));
ret = 0;
@ -99,7 +99,9 @@ int Curve::_add_point(Vector2 p_position, real_t p_left_tangent, real_t p_right_
update_auto_tangents(ret);
mark_dirty();
if (p_mark_dirty) {
mark_dirty();
}
return ret;
}
@ -221,10 +223,12 @@ Curve::TangentMode Curve::get_point_right_mode(int p_index) const {
return _points[p_index].right_mode;
}
void Curve::_remove_point(int p_index) {
void Curve::_remove_point(int p_index, bool p_mark_dirty) {
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_index, _points.size());
_points.remove_at(p_index);
mark_dirty();
if (p_mark_dirty) {
mark_dirty();
}
}
void Curve::remove_point(int p_index) {
@ -252,16 +256,13 @@ void Curve::set_point_value(int p_index, real_t p_position) {
int Curve::set_point_offset(int p_index, real_t p_offset) {
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_index, _points.size(), -1);
Point p = _points[p_index];
_remove_point(p_index);
int i = _add_point(Vector2(p_offset, p.position.y));
_points[i].left_tangent = p.left_tangent;
_points[i].right_tangent = p.right_tangent;
_points[i].left_mode = p.left_mode;
_points[i].right_mode = p.right_mode;
_remove_point(p_index, false);
int i = _add_point(Vector2(p_offset, p.position.y), p.left_tangent, p.right_tangent, p.left_mode, p.right_mode, false);
if (p_index != i) {
update_auto_tangents(p_index);
}
update_auto_tangents(i);
mark_dirty();
return i;
}
@ -376,7 +377,7 @@ void Curve::set_max_domain(real_t p_max) {
}
real_t Curve::sample(real_t p_offset) const {
if (_points.size() == 0) {
if (_points.is_empty()) {
return 0;
}
if (_points.size() == 1) {
@ -538,8 +539,8 @@ real_t Curve::sample_baked(real_t p_offset) const {
}
// Special cases if the cache is too small.
if (_baked_cache.size() == 0) {
if (_points.size() == 0) {
if (_baked_cache.is_empty()) {
if (_points.is_empty()) {
return 0;
}
return _points[0].position.y;
@ -568,7 +569,7 @@ real_t Curve::sample_baked(real_t p_offset) const {
}
void Curve::ensure_default_setup(real_t p_min, real_t p_max) {
if (_points.size() == 0 && _min_value == 0 && _max_value == 1) {
if (_points.is_empty() && _min_value == 0 && _max_value == 1) {
add_point(Vector2(0, 1));
add_point(Vector2(1, 1));
set_min_value(p_min);
@ -880,12 +881,22 @@ void Curve2D::_bake_segment2d_even_length(RBMap<real_t, Vector2> &r_bake, real_t
Vector2 Curve2D::_calculate_tangent(const Vector2 &p_begin, const Vector2 &p_control_1, const Vector2 &p_control_2, const Vector2 &p_end, const real_t p_t) {
// Handle corner cases.
if (Math::is_zero_approx(p_t - 0.0f) && p_control_1.is_equal_approx(p_begin)) {
return (p_end - p_begin).normalized();
}
if (Math::is_zero_approx(p_t - 1.0f) && p_control_2.is_equal_approx(p_end)) {
return (p_end - p_begin).normalized();
if (Math::is_zero_approx(p_t - 0.0f)) {
if (p_control_1.is_equal_approx(p_begin)) {
if (p_control_1.is_equal_approx(p_control_2)) {
return (p_end - p_begin).normalized();
} else {
return (p_control_2 - p_begin).normalized();
}
}
} else if (Math::is_zero_approx(p_t - 1.0f)) {
if (p_control_2.is_equal_approx(p_end)) {
if (p_control_2.is_equal_approx(p_control_1)) {
return (p_end - p_begin).normalized();
} else {
return (p_end - p_control_1).normalized();
}
}
}
return p_begin.bezier_derivative(p_control_1, p_control_2, p_end, p_t).normalized();
@ -899,7 +910,7 @@ void Curve2D::_bake() const {
baked_max_ofs = 0;
baked_cache_dirty = false;
if (points.size() == 0) {
if (points.is_empty()) {
baked_point_cache.clear();
baked_dist_cache.clear();
baked_forward_vector_cache.clear();
@ -1248,7 +1259,7 @@ void Curve2D::_set_data(const Dictionary &p_data) {
PackedVector2Array Curve2D::tessellate(int p_max_stages, real_t p_tolerance) const {
PackedVector2Array tess;
if (points.size() == 0) {
if (points.is_empty()) {
return tess;
}
@ -1298,7 +1309,7 @@ PackedVector2Array Curve2D::tessellate_even_length(int p_max_stages, real_t p_le
PackedVector2Array tess;
Vector<RBMap<real_t, Vector2>> midpoints = _tessellate_even_length(p_max_stages, p_length);
if (midpoints.size() == 0) {
if (midpoints.is_empty()) {
return tess;
}
@ -1619,12 +1630,22 @@ void Curve3D::_bake_segment3d_even_length(RBMap<real_t, Vector3> &r_bake, real_t
Vector3 Curve3D::_calculate_tangent(const Vector3 &p_begin, const Vector3 &p_control_1, const Vector3 &p_control_2, const Vector3 &p_end, const real_t p_t) {
// Handle corner cases.
if (Math::is_zero_approx(p_t - 0.0f) && p_control_1.is_equal_approx(p_begin)) {
return (p_end - p_begin).normalized();
}
if (Math::is_zero_approx(p_t - 1.0f) && p_control_2.is_equal_approx(p_end)) {
return (p_end - p_begin).normalized();
if (Math::is_zero_approx(p_t - 0.0f)) {
if (p_control_1.is_equal_approx(p_begin)) {
if (p_control_1.is_equal_approx(p_control_2)) {
return (p_end - p_begin).normalized();
} else {
return (p_control_2 - p_begin).normalized();
}
}
} else if (Math::is_zero_approx(p_t - 1.0f)) {
if (p_control_2.is_equal_approx(p_end)) {
if (p_control_2.is_equal_approx(p_control_1)) {
return (p_end - p_begin).normalized();
} else {
return (p_end - p_control_1).normalized();
}
}
}
return p_begin.bezier_derivative(p_control_1, p_control_2, p_end, p_t).normalized();
@ -1638,7 +1659,7 @@ void Curve3D::_bake() const {
baked_max_ofs = 0;
baked_cache_dirty = false;
if (points.size() == 0) {
if (points.is_empty()) {
#ifdef TOOLS_ENABLED
points_in_cache.clear();
#endif
@ -2272,7 +2293,7 @@ void Curve3D::_set_data(const Dictionary &p_data) {
PackedVector3Array Curve3D::tessellate(int p_max_stages, real_t p_tolerance) const {
PackedVector3Array tess;
if (points.size() == 0) {
if (points.is_empty()) {
return tess;
}
Vector<RBMap<real_t, Vector3>> midpoints;
@ -2335,7 +2356,7 @@ PackedVector3Array Curve3D::tessellate_even_length(int p_max_stages, real_t p_le
PackedVector3Array tess;
Vector<RBMap<real_t, Vector3>> midpoints = _tessellate_even_length(p_max_stages, p_length);
if (midpoints.size() == 0) {
if (midpoints.is_empty()) {
return tess;
}