Skip to content

Commit

Permalink
Fix integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fire committed Oct 10, 2024
1 parent adb33b8 commit d8ed4ba
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions modules/many_bone_ik/src/ik_bone_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ BoneId IKBone3D::get_bone_id() const {
}

void IKBone3D::set_parent(const Ref<IKBone3D> &p_parent) {
ERR_FAIL_NULL(p_parent);
ERR_FAIL_COND(p_parent.is_null());
parent = p_parent;
if (parent.is_valid()) {
parent->children.push_back(this);
Expand Down Expand Up @@ -126,7 +126,7 @@ Ref<IKBone3D> IKBone3D::get_parent() const {
}

void IKBone3D::set_pin(const Ref<IKEffector3D> &p_pin) {
ERR_FAIL_NULL(p_pin);
ERR_FAIL_COND(p_pin.is_null());
pin = p_pin;
}

Expand Down
10 changes: 5 additions & 5 deletions modules/many_bone_ik/src/ik_bone_segment_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Ref<IKBone3D> IKBoneSegment3D::get_tip() const {
}

bool IKBoneSegment3D::is_pinned() const {
ERR_FAIL_NULL_V(tip, false);
ERR_FAIL_COND_V(tip.is_null(), false);
return tip->is_pinned();
}

Expand Down Expand Up @@ -88,7 +88,7 @@ void IKBoneSegment3D::update_pinned_list(Vector<Vector<double>> &r_weights) {
}

void IKBoneSegment3D::_update_optimal_rotation(Ref<IKBone3D> p_for_bone, double p_damp, bool p_translate, bool p_constraint_mode, int32_t current_iteration, int32_t total_iterations) {
ERR_FAIL_NULL(p_for_bone);
ERR_FAIL_COND(p_for_bone.is_null());
_update_target_headings(p_for_bone, &heading_weights, &target_headings);
_update_tip_headings(p_for_bone, &tip_headings);
_set_optimal_rotation(p_for_bone, &tip_headings, &target_headings, &heading_weights, p_damp, p_translate, p_constraint_mode);
Expand Down Expand Up @@ -127,7 +127,7 @@ float IKBoneSegment3D::_get_manual_msd(const PackedVector3Array &r_htip, const P
}

void IKBoneSegment3D::_set_optimal_rotation(Ref<IKBone3D> p_for_bone, PackedVector3Array *r_htip, PackedVector3Array *r_htarget, Vector<double> *r_weights, float p_dampening, bool p_translate, bool p_constraint_mode, double current_iteration, double total_iterations) {
ERR_FAIL_NULL(p_for_bone);
ERR_FAIL_COND(p_for_bone.is_null());
ERR_FAIL_NULL(r_htip);
ERR_FAIL_NULL(r_htarget);
ERR_FAIL_NULL(r_weights);
Expand Down Expand Up @@ -181,7 +181,7 @@ void IKBoneSegment3D::_set_optimal_rotation(Ref<IKBone3D> p_for_bone, PackedVect
}

void IKBoneSegment3D::_update_target_headings(Ref<IKBone3D> p_for_bone, Vector<double> *r_weights, PackedVector3Array *r_target_headings) {
ERR_FAIL_NULL(p_for_bone);
ERR_FAIL_COND(p_for_bone.is_null());
ERR_FAIL_NULL(r_weights);
ERR_FAIL_NULL(r_target_headings);
int32_t last_index = 0;
Expand All @@ -196,7 +196,7 @@ void IKBoneSegment3D::_update_target_headings(Ref<IKBone3D> p_for_bone, Vector<d

void IKBoneSegment3D::_update_tip_headings(Ref<IKBone3D> p_for_bone, PackedVector3Array *r_heading_tip) {
ERR_FAIL_NULL(r_heading_tip);
ERR_FAIL_NULL(p_for_bone);
ERR_FAIL_COND(p_for_bone.is_null());
int32_t last_index = 0;
for (int32_t effector_i = 0; effector_i < effector_list.size(); effector_i++) {
Ref<IKEffector3D> effector = effector_list[effector_i];
Expand Down
8 changes: 4 additions & 4 deletions modules/many_bone_ik/src/ik_effector_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Vector3 IKEffector3D::get_direction_priorities() const {

void IKEffector3D::update_target_global_transform(Skeleton3D *p_skeleton, ManyBoneIK3D *p_many_bone_ik) {
ERR_FAIL_NULL(p_skeleton);
ERR_FAIL_NULL(for_bone);
ERR_FAIL_COND(for_bone.is_null());
Node3D *current_target_node = cast_to<Node3D>(p_many_bone_ik->get_node_or_null(target_node_path));
if (current_target_node && current_target_node->is_visible_in_tree()) {
target_relative_to_skeleton_origin = p_skeleton->get_global_transform().affine_inverse() * current_target_node->get_global_transform();
Expand All @@ -90,7 +90,7 @@ Transform3D IKEffector3D::get_target_global_transform() const {
int32_t IKEffector3D::update_effector_target_headings(PackedVector3Array *p_headings, int32_t p_index, Ref<IKBone3D> p_for_bone, const Vector<double> *p_weights) const {
ERR_FAIL_COND_V(p_index == -1, -1);
ERR_FAIL_NULL_V(p_headings, -1);
ERR_FAIL_NULL_V(p_for_bone, -1);
ERR_FAIL_COND_V(p_for_bone.is_null(), -1);
ERR_FAIL_NULL_V(p_weights, -1);

int32_t index = p_index;
Expand Down Expand Up @@ -118,7 +118,7 @@ int32_t IKEffector3D::update_effector_target_headings(PackedVector3Array *p_head
int32_t IKEffector3D::update_effector_tip_headings(PackedVector3Array *p_headings, int32_t p_index, Ref<IKBone3D> p_for_bone) const {
ERR_FAIL_COND_V(p_index == -1, -1);
ERR_FAIL_NULL_V(p_headings, -1);
ERR_FAIL_NULL_V(p_for_bone, -1);
ERR_FAIL_COND_V(p_for_bone.is_null(), -1);

Transform3D tip_xform_relative_to_skeleton_origin = for_bone->get_bone_direction_global_pose();
Basis tip_basis = tip_xform_relative_to_skeleton_origin.basis;
Expand Down Expand Up @@ -170,7 +170,7 @@ real_t IKEffector3D::get_weight() const {
}

IKEffector3D::IKEffector3D(const Ref<IKBone3D> &p_current_bone) {
ERR_FAIL_NULL(p_current_bone);
ERR_FAIL_COND(p_current_bone.is_null());
for_bone = p_current_bone;
}

Expand Down
6 changes: 3 additions & 3 deletions modules/many_bone_ik/src/ik_kusudama_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ void IKKusudama3D::_update_constraint(Ref<IKNode3D> p_limiting_axes) {
// Avoiding antipodal singularities by reorienting the axes.
Vector<Vector3> directions;

if (open_cones.size() == 1 && open_cones[0] != nullptr) {
if (open_cones.size() == 1 && open_cones[0].is_valid()) {
directions.push_back(open_cones[0]->get_control_point());
} else {
for (int i = 0; i < open_cones.size() - 1; i++) {
if (open_cones[i] == nullptr || open_cones[i + 1] == nullptr) {
if (open_cones[i].is_null() || open_cones[i + 1].is_null()) {
continue;
}

Expand Down Expand Up @@ -77,7 +77,7 @@ void IKKusudama3D::_update_constraint(Ref<IKNode3D> p_limiting_axes) {
p_limiting_axes->rotate_local_with_global(old_y_to_new_y);

for (Ref<IKLimitCone3D> open_cone : open_cones) {
if (open_cone == nullptr) {
if (open_cone.is_null()) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/many_bone_ik/src/many_bone_ik_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ bool ManyBoneIK3D::_get(const StringName &p_name, Variant &r_ret) const {
String what = name.get_slicec('/', 2);
ERR_FAIL_INDEX_V(index, pins.size(), false);
Ref<IKEffectorTemplate3D> effector_template = pins[index];
ERR_FAIL_NULL_V(effector_template, false);
ERR_FAIL_COND_V(effector_template.is_null(), false);
if (what == "bone_name") {
r_ret = effector_template->get_name();
return true;
Expand Down Expand Up @@ -448,7 +448,7 @@ float ManyBoneIK3D::get_pin_motion_propagation_factor(int32_t p_effector_index)
void ManyBoneIK3D::set_pin_motion_propagation_factor(int32_t p_effector_index, const float p_motion_propagation_factor) {
ERR_FAIL_INDEX(p_effector_index, pins.size());
Ref<IKEffectorTemplate3D> effector_template = pins[p_effector_index];
ERR_FAIL_NULL(effector_template);
ERR_FAIL_COND(effector_template.is_null());
effector_template->set_motion_propagation_factor(p_motion_propagation_factor);
set_dirty();
}
Expand Down

0 comments on commit d8ed4ba

Please sign in to comment.