Skip to content

Commit

Permalink
Refactor ManyBoneIK3D class: remove unused methods and member variables
Browse files Browse the repository at this point in the history
- Removed the following unused methods:
  - set_twist_constraint_defaults
  - get_twist_constraint_defaults
  - set_orientation_constraint_defaults
  - get_orientation_constraint_defaults
  - set_bone_direction_constraint_defaults
  - get_bone_direction_constraint_defaults

- Removed the following unused member variables:
  - twist_constraint_defaults
  - orientation_constraint_defaults
  - bone_direction_constraint_defaults
  • Loading branch information
fire committed Nov 5, 2023
1 parent f78b5b2 commit 68812c7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 69 deletions.
63 changes: 1 addition & 62 deletions src/many_bone_ik_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,6 @@ void ManyBoneIK3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_constraint_mode"), &ManyBoneIK3D::get_constraint_mode);
ClassDB::bind_method(D_METHOD("set_ui_selected_bone", "bone"), &ManyBoneIK3D::set_ui_selected_bone);
ClassDB::bind_method(D_METHOD("get_ui_selected_bone"), &ManyBoneIK3D::get_ui_selected_bone);
ClassDB::bind_method(D_METHOD("set_twist_constraint_defaults", "defaults"), &ManyBoneIK3D::set_twist_constraint_defaults);
ClassDB::bind_method(D_METHOD("get_twist_constraint_defaults"), &ManyBoneIK3D::get_twist_constraint_defaults);
ClassDB::bind_method(D_METHOD("set_orientation_constraint_defaults", "defaults"), &ManyBoneIK3D::set_orientation_constraint_defaults);
ClassDB::bind_method(D_METHOD("get_orientation_constraint_defaults"), &ManyBoneIK3D::get_orientation_constraint_defaults);
ClassDB::bind_method(D_METHOD("set_bone_direction_constraint_defaults", "defaults"), &ManyBoneIK3D::set_bone_direction_constraint_defaults);
ClassDB::bind_method(D_METHOD("get_bone_direction_constraint_defaults"), &ManyBoneIK3D::get_bone_direction_constraint_defaults);
ClassDB::bind_method(D_METHOD("set_stabilization_passes", "passes"), &ManyBoneIK3D::set_stabilization_passes);
ClassDB::bind_method(D_METHOD("get_stabilization_passes"), &ManyBoneIK3D::get_stabilization_passes);
ClassDB::bind_method(D_METHOD("set_pin_bone_name", "index", "name"), &ManyBoneIK3D::set_pin_bone_name);
Expand All @@ -456,10 +450,7 @@ void ManyBoneIK3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "constraint_mode"), "set_constraint_mode", "get_constraint_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "ui_selected_bone", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_ui_selected_bone", "get_ui_selected_bone");
ADD_PROPERTY(PropertyInfo(Variant::INT, "stabilization_passes"), "set_stabilization_passes", "get_stabilization_passes");
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "twist_constraint_defaults", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_twist_constraint_defaults", "get_twist_constraint_defaults");
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "orientation_constraint_defaults", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_orientation_constraint_defaults", "get_orientation_constraint_defaults");
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "bone_direction_constraint_defaults", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_bone_direction_constraint_defaults", "get_bone_direction_constraint_defaults");
}
}

ManyBoneIK3D::ManyBoneIK3D() {
}
Expand Down Expand Up @@ -712,12 +703,6 @@ void ManyBoneIK3D::execute(real_t delta) {
if (is_dirty) {
skeleton_changed(get_skeleton());
is_dirty = false;
for (int32_t constraint_i = 0; constraint_i < get_constraint_count(); constraint_i++) {
String constraint_name = get_constraint_name(constraint_i);
twist_constraint_defaults[constraint_name] = get_constraint_twist_transform(constraint_i);
orientation_constraint_defaults[constraint_name] = get_constraint_orientation_transform(constraint_i);
bone_direction_constraint_defaults[constraint_name] = get_bone_direction_transform(constraint_i);
}
}
if (bone_list.size()) {
Ref<IKNode3D> root_ik_bone = bone_list.write[0]->get_ik_transform();
Expand Down Expand Up @@ -812,23 +797,6 @@ void ManyBoneIK3D::skeleton_changed(Skeleton3D *p_skeleton) {
break;
}
}
if (!twist_constraint_defaults.size() && !orientation_constraint_defaults.size() && !bone_direction_constraint_defaults.size()) {
for (Ref<IKBone3D> &ik_bone_3d : bone_list) {
ik_bone_3d->update_default_constraint_transform();
}
for (int32_t constraint_i = 0; constraint_i < get_constraint_count(); ++constraint_i) {
String constraint_name = get_constraint_name(constraint_i);
twist_constraint_defaults[constraint_name] = get_constraint_twist_transform(constraint_i);
orientation_constraint_defaults[constraint_name] = get_constraint_orientation_transform(constraint_i);
bone_direction_constraint_defaults[constraint_name] = get_bone_direction_transform(constraint_i);
}
}
for (int32_t constraint_i = 0; constraint_i < get_constraint_count(); ++constraint_i) {
String constraint_name = get_constraint_name(constraint_i);
set_constraint_twist_transform(constraint_i, twist_constraint_defaults[constraint_name]);
set_constraint_orientation_transform(constraint_i, orientation_constraint_defaults[constraint_name]);
set_bone_direction_transform(constraint_i, bone_direction_constraint_defaults[constraint_name]);
}
if (queue_debug_skeleton) {
queue_debug_skeleton = false;
}
Expand Down Expand Up @@ -1115,9 +1083,6 @@ void ManyBoneIK3D::register_skeleton() {
void ManyBoneIK3D::reset_constraints() {
Skeleton3D *skeleton = get_skeleton();
if (skeleton) {
orientation_constraint_defaults.clear();
twist_constraint_defaults.clear();
bone_direction_constraint_defaults.clear();
int32_t saved_pin_count = get_pin_count();
set_pin_count(0);
set_pin_count(saved_pin_count);
Expand Down Expand Up @@ -1155,32 +1120,6 @@ int32_t ManyBoneIK3D::get_stabilization_passes() {
return stabilize_passes;
}

void ManyBoneIK3D::set_twist_constraint_defaults(Dictionary p_defaults) {
twist_constraint_defaults = p_defaults;
set_dirty();
}

Dictionary ManyBoneIK3D::get_twist_constraint_defaults() {
return twist_constraint_defaults;
}

void ManyBoneIK3D::set_orientation_constraint_defaults(Dictionary p_defaults) {
orientation_constraint_defaults = p_defaults;
}

Dictionary ManyBoneIK3D::get_orientation_constraint_defaults() {
return orientation_constraint_defaults;
}

void ManyBoneIK3D::set_bone_direction_constraint_defaults(Dictionary p_defaults) {
bone_direction_constraint_defaults = p_defaults;
set_dirty();
}

Dictionary ManyBoneIK3D::get_bone_direction_constraint_defaults() {
return bone_direction_constraint_defaults;
}

Transform3D ManyBoneIK3D::get_godot_skeleton_transform_inverse() {
return godot_skeleton_transform_inverse;
}
Expand Down
7 changes: 0 additions & 7 deletions src/many_bone_ik_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class ManyBoneIK3DState;
class ManyBoneIK3D : public Node3D {
GDCLASS(ManyBoneIK3D, Node3D);

Dictionary twist_constraint_defaults, orientation_constraint_defaults, bone_direction_constraint_defaults;
bool is_constraint_mode = false;
NodePath skeleton_path;
Vector<Ref<IKBoneSegment3D>> segmented_skeletons;
Expand Down Expand Up @@ -105,12 +104,6 @@ class ManyBoneIK3D : public Node3D {
void add_constraint();
void set_stabilization_passes(int32_t p_passes);
int32_t get_stabilization_passes();
void set_twist_constraint_defaults(Dictionary p_defaults);
Dictionary get_twist_constraint_defaults();
void set_orientation_constraint_defaults(Dictionary p_defaults);
Dictionary get_orientation_constraint_defaults();
void set_bone_direction_constraint_defaults(Dictionary p_defaults);
Dictionary get_bone_direction_constraint_defaults();
Transform3D get_godot_skeleton_transform_inverse();
Ref<IKNode3D> get_godot_skeleton_transform();
void set_ui_selected_bone(int32_t p_ui_selected_bone);
Expand Down

0 comments on commit 68812c7

Please sign in to comment.