feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -39,19 +39,17 @@
#endif //TOOLS_ENABLED
bool Bone2D::_set(const StringName &p_path, const Variant &p_value) {
String path = p_path;
if (path.begins_with("auto_calculate_length_and_angle")) {
if (p_path == SNAME("auto_calculate_length_and_angle")) {
set_autocalculate_length_and_angle(p_value);
} else if (path.begins_with("length")) {
} else if (p_path == SNAME("length")) {
set_length(p_value);
} else if (path.begins_with("bone_angle")) {
} else if (p_path == SNAME("bone_angle")) {
set_bone_angle(Math::deg_to_rad(real_t(p_value)));
} else if (path.begins_with("default_length")) {
} else if (p_path == SNAME("default_length")) {
set_length(p_value);
}
#ifdef TOOLS_ENABLED
else if (path.begins_with("editor_settings/show_bone_gizmo")) {
else if (p_path == SNAME("editor_settings/show_bone_gizmo")) {
_editor_set_show_bone_gizmo(p_value);
}
#endif // TOOLS_ENABLED
@ -63,19 +61,17 @@ bool Bone2D::_set(const StringName &p_path, const Variant &p_value) {
}
bool Bone2D::_get(const StringName &p_path, Variant &r_ret) const {
String path = p_path;
if (path.begins_with("auto_calculate_length_and_angle")) {
if (p_path == SNAME("auto_calculate_length_and_angle")) {
r_ret = get_autocalculate_length_and_angle();
} else if (path.begins_with("length")) {
} else if (p_path == SNAME("length")) {
r_ret = get_length();
} else if (path.begins_with("bone_angle")) {
} else if (p_path == SNAME("bone_angle")) {
r_ret = Math::rad_to_deg(get_bone_angle());
} else if (path.begins_with("default_length")) {
} else if (p_path == SNAME("default_length")) {
r_ret = get_length();
}
#ifdef TOOLS_ENABLED
else if (path.begins_with("editor_settings/show_bone_gizmo")) {
else if (p_path == SNAME("editor_settings/show_bone_gizmo")) {
r_ret = _editor_get_show_bone_gizmo();
}
#endif // TOOLS_ENABLED
@ -163,7 +159,7 @@ void Bone2D::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
if (skeleton) {
for (int i = 0; i < skeleton->bones.size(); i++) {
for (uint32_t i = 0; i < skeleton->bones.size(); i++) {
if (skeleton->bones[i].bone == this) {
skeleton->bones.remove_at(i);
break;
@ -330,9 +326,7 @@ bool Bone2D::_editor_get_bone_shape(Vector<Vector2> *p_shape, Vector<Vector2> *p
rel = (p_other_bone->get_global_position() - get_global_position());
rel = rel.rotated(-get_global_rotation()); // Undo Bone2D node's rotation so its drawn correctly regardless of the node's rotation
} else {
real_t angle_to_use = get_rotation() + bone_angle;
rel = Vector2(cos(angle_to_use), sin(angle_to_use)) * (length * MIN(get_global_scale().x, get_global_scale().y));
rel = rel.rotated(-get_rotation()); // Undo Bone2D node's rotation so its drawn correctly regardless of the node's rotation
rel = Vector2(Math::cos(bone_angle), Math::sin(bone_angle)) * length * get_global_scale();
}
Vector2 relt = rel.rotated(Math_PI * 0.5).normalized() * bone_width;
@ -418,7 +412,7 @@ int Bone2D::get_index_in_skeleton() const {
}
PackedStringArray Bone2D::get_configuration_warnings() const {
PackedStringArray warnings = Node::get_configuration_warnings();
PackedStringArray warnings = Node2D::get_configuration_warnings();
if (!skeleton) {
if (parent_bone) {
warnings.push_back(RTR("This Bone2D chain should end at a Skeleton2D node."));
@ -518,23 +512,19 @@ Bone2D::~Bone2D() {
//////////////////////////////////////
bool Skeleton2D::_set(const StringName &p_path, const Variant &p_value) {
String path = p_path;
if (path.begins_with("modification_stack")) {
if (p_path == SNAME("modification_stack")) {
set_modification_stack(p_value);
return true;
}
return true;
return false;
}
bool Skeleton2D::_get(const StringName &p_path, Variant &r_ret) const {
String path = p_path;
if (path.begins_with("modification_stack")) {
if (p_path == SNAME("modification_stack")) {
r_ret = get_modification_stack();
return true;
}
return true;
return false;
}
void Skeleton2D::_get_property_list(List<PropertyInfo> *p_list) const {
@ -565,17 +555,17 @@ void Skeleton2D::_update_bone_setup() {
bones.sort(); //sorting so that they are always in the same order/index
for (int i = 0; i < bones.size(); i++) {
bones.write[i].rest_inverse = bones[i].bone->get_skeleton_rest().affine_inverse(); //bind pose
bones.write[i].bone->skeleton_index = i;
for (uint32_t i = 0; i < bones.size(); i++) {
bones[i].rest_inverse = bones[i].bone->get_skeleton_rest().affine_inverse(); //bind pose
bones[i].bone->skeleton_index = i;
Bone2D *parent_bone = Object::cast_to<Bone2D>(bones[i].bone->get_parent());
if (parent_bone) {
bones.write[i].parent_index = parent_bone->skeleton_index;
bones[i].parent_index = parent_bone->skeleton_index;
} else {
bones.write[i].parent_index = -1;
bones[i].parent_index = -1;
}
bones.write[i].local_pose_override = bones[i].bone->get_skeleton_rest();
bones[i].local_pose_override = bones[i].bone->get_skeleton_rest();
}
transform_dirty = true;
@ -604,16 +594,16 @@ void Skeleton2D::_update_transform() {
transform_dirty = false;
for (int i = 0; i < bones.size(); i++) {
ERR_CONTINUE(bones[i].parent_index >= i);
for (uint32_t i = 0; i < bones.size(); i++) {
ERR_CONTINUE(bones[i].parent_index >= (int)i);
if (bones[i].parent_index >= 0) {
bones.write[i].accum_transform = bones[bones[i].parent_index].accum_transform * bones[i].bone->get_transform();
bones[i].accum_transform = bones[bones[i].parent_index].accum_transform * bones[i].bone->get_transform();
} else {
bones.write[i].accum_transform = bones[i].bone->get_transform();
bones[i].accum_transform = bones[i].bone->get_transform();
}
}
for (int i = 0; i < bones.size(); i++) {
for (uint32_t i = 0; i < bones.size(); i++) {
Transform2D final_xform = bones[i].accum_transform * bones[i].rest_inverse;
RS::get_singleton()->skeleton_bone_set_transform_2d(skeleton, i, final_xform);
}
@ -623,6 +613,7 @@ int Skeleton2D::get_bone_count() const {
ERR_FAIL_COND_V(!is_inside_tree(), 0);
if (bone_setup_dirty) {
// TODO: Is this necessary? It doesn't seem to change bones.size()
const_cast<Skeleton2D *>(this)->_update_bone_setup();
}
@ -631,7 +622,7 @@ int Skeleton2D::get_bone_count() const {
Bone2D *Skeleton2D::get_bone(int p_idx) {
ERR_FAIL_COND_V(!is_inside_tree(), nullptr);
ERR_FAIL_INDEX_V(p_idx, bones.size(), nullptr);
ERR_FAIL_INDEX_V(p_idx, (int)bones.size(), nullptr);
return bones[p_idx].bone;
}
@ -743,14 +734,14 @@ RID Skeleton2D::get_skeleton() const {
}
void Skeleton2D::set_bone_local_pose_override(int p_bone_idx, Transform2D p_override, real_t p_amount, bool p_persistent) {
ERR_FAIL_INDEX_MSG(p_bone_idx, bones.size(), "Bone index is out of range!");
bones.write[p_bone_idx].local_pose_override = p_override;
bones.write[p_bone_idx].local_pose_override_amount = p_amount;
bones.write[p_bone_idx].local_pose_override_persistent = p_persistent;
ERR_FAIL_INDEX_MSG(p_bone_idx, (int)bones.size(), "Bone index is out of range!");
bones[p_bone_idx].local_pose_override = p_override;
bones[p_bone_idx].local_pose_override_amount = p_amount;
bones[p_bone_idx].local_pose_override_persistent = p_persistent;
}
Transform2D Skeleton2D::get_bone_local_pose_override(int p_bone_idx) {
ERR_FAIL_INDEX_V_MSG(p_bone_idx, bones.size(), Transform2D(), "Bone index is out of range!");
ERR_FAIL_INDEX_V_MSG(p_bone_idx, (int)bones.size(), Transform2D(), "Bone index is out of range!");
return bones[p_bone_idx].local_pose_override;
}
@ -776,12 +767,12 @@ Ref<SkeletonModificationStack2D> Skeleton2D::get_modification_stack() const {
}
void Skeleton2D::execute_modifications(real_t p_delta, int p_execution_mode) {
if (!modification_stack.is_valid()) {
if (modification_stack.is_null()) {
return;
}
// Do not cache the transform changes caused by the modifications!
for (int i = 0; i < bones.size(); i++) {
for (uint32_t i = 0; i < bones.size(); i++) {
bones[i].bone->copy_transform_to_cache = false;
}
@ -793,7 +784,7 @@ void Skeleton2D::execute_modifications(real_t p_delta, int p_execution_mode) {
// Only apply the local pose override on _process. Otherwise, just calculate the local_pose_override and reset the transform.
if (p_execution_mode == SkeletonModificationStack2D::EXECUTION_MODE::execution_mode_process) {
for (int i = 0; i < bones.size(); i++) {
for (uint32_t i = 0; i < bones.size(); i++) {
if (bones[i].local_pose_override_amount > 0) {
bones[i].bone->set_meta("_local_pose_override_enabled_", true);
@ -803,7 +794,7 @@ void Skeleton2D::execute_modifications(real_t p_delta, int p_execution_mode) {
bones[i].bone->propagate_call("force_update_transform");
if (bones[i].local_pose_override_persistent) {
bones.write[i].local_pose_override_amount = 0.0;
bones[i].local_pose_override_amount = 0.0;
}
} else {
// TODO: see if there is a way to undo the override without having to resort to setting every bone's transform.
@ -814,7 +805,7 @@ void Skeleton2D::execute_modifications(real_t p_delta, int p_execution_mode) {
}
// Cache any future transform changes
for (int i = 0; i < bones.size(); i++) {
for (uint32_t i = 0; i < bones.size(); i++) {
bones[i].bone->copy_transform_to_cache = true;
}