|
@@ -37,20 +37,20 @@
|
|
|
#ifndef _3D_DISABLED
|
|
|
|
|
|
FabrikInverseKinematic::ChainItem *FabrikInverseKinematic::ChainItem::find_child(const BoneId p_bone_id) {
|
|
|
- for (int i = childs.size() - 1; 0 <= i; --i) {
|
|
|
- if (p_bone_id == childs[i].bone) {
|
|
|
- return &childs.write[i];
|
|
|
+ for (int i = children.size() - 1; 0 <= i; --i) {
|
|
|
+ if (p_bone_id == children[i].bone) {
|
|
|
+ return &children.write[i];
|
|
|
}
|
|
|
}
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
FabrikInverseKinematic::ChainItem *FabrikInverseKinematic::ChainItem::add_child(const BoneId p_bone_id) {
|
|
|
- const int infant_child_id = childs.size();
|
|
|
- childs.resize(infant_child_id + 1);
|
|
|
- childs.write[infant_child_id].bone = p_bone_id;
|
|
|
- childs.write[infant_child_id].parent_item = this;
|
|
|
- return &childs.write[infant_child_id];
|
|
|
+ const int infant_child_id = children.size();
|
|
|
+ children.resize(infant_child_id + 1);
|
|
|
+ children.write[infant_child_id].bone = p_bone_id;
|
|
|
+ children.write[infant_child_id].parent_item = this;
|
|
|
+ return &children.write[infant_child_id];
|
|
|
}
|
|
|
|
|
|
/// Build a chain that starts from the root to tip
|
|
@@ -144,8 +144,8 @@ void FabrikInverseKinematic::update_chain(const Skeleton *p_sk, ChainItem *p_cha
|
|
|
p_chain_item->initial_transform = p_sk->get_bone_global_pose(p_chain_item->bone);
|
|
|
p_chain_item->current_pos = p_chain_item->initial_transform.origin;
|
|
|
|
|
|
- for (int i = p_chain_item->childs.size() - 1; 0 <= i; --i) {
|
|
|
- update_chain(p_sk, &p_chain_item->childs.write[i]);
|
|
|
+ for (int i = p_chain_item->children.size() - 1; 0 <= i; --i) {
|
|
|
+ update_chain(p_sk, &p_chain_item->children.write[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -210,9 +210,9 @@ void FabrikInverseKinematic::solve_simple_forwards(Chain &r_chain, bool p_solve_
|
|
|
while (sub_chain_root) { // Reach the tip
|
|
|
sub_chain_root->current_pos = origin;
|
|
|
|
|
|
- if (!sub_chain_root->childs.empty()) {
|
|
|
+ if (!sub_chain_root->children.empty()) {
|
|
|
|
|
|
- ChainItem &child(sub_chain_root->childs.write[0]);
|
|
|
+ ChainItem &child(sub_chain_root->children.write[0]);
|
|
|
|
|
|
// Is not tip
|
|
|
// So calculate next origin location
|
|
@@ -302,10 +302,10 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
|
|
|
Transform new_bone_pose(ci->initial_transform);
|
|
|
new_bone_pose.origin = ci->current_pos;
|
|
|
|
|
|
- if (!ci->childs.empty()) {
|
|
|
+ if (!ci->children.empty()) {
|
|
|
|
|
|
/// Rotate basis
|
|
|
- const Vector3 initial_ori((ci->childs[0].initial_transform.origin - ci->initial_transform.origin).normalized());
|
|
|
+ const Vector3 initial_ori((ci->children[0].initial_transform.origin - ci->initial_transform.origin).normalized());
|
|
|
const Vector3 rot_axis(initial_ori.cross(ci->current_ori).normalized());
|
|
|
|
|
|
if (rot_axis[0] != 0 && rot_axis[1] != 0 && rot_axis[2] != 0) {
|
|
@@ -322,8 +322,8 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove
|
|
|
|
|
|
p_task->skeleton->set_bone_global_pose(ci->bone, new_bone_pose);
|
|
|
|
|
|
- if (!ci->childs.empty())
|
|
|
- ci = &ci->childs.write[0];
|
|
|
+ if (!ci->children.empty())
|
|
|
+ ci = &ci->children.write[0];
|
|
|
else
|
|
|
ci = NULL;
|
|
|
}
|