Skip to content

Commit

Permalink
Merge pull request #177 from V-Sekai/update-planner
Browse files Browse the repository at this point in the history
Update renik
  • Loading branch information
fire committed Jul 21, 2024
2 parents c82063c + b3a206d commit c08c1b9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 76 deletions.
29 changes: 1 addition & 28 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,14 @@
}
},
"configurations": [
{
"name": "Run the editor with V-Sekai game windows",
"type": "lldb",
"request": "launch",
"args": ["--path", "${workspaceFolder}/11_vsekai_game", "-e"],
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/19_godot/bin/godot.windows.editor.double.x86_64.llvm.console.exe",
"preLaunchTask": "Godot Engine"
},
{
"name": "Run the editor with V-Sekai game macos",
"type": "lldb",
"request": "launch",
"args": ["--path", "${workspaceFolder}/11_vsekai_game", "-e"],
"args": ["--path", "/Users/ernest.lee/Documents/godot-merge-game-project", "-e"],
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/19_godot/bin/godot.macos.editor.double.arm64",
"preLaunchTask": "Godot Engine"
},
{
"name": "Run the editor with V-Sekai planner macos",
"type": "lldb",
"request": "launch",
"args": ["--path", "${workspaceFolder}/14_planner", "-e"],
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/19_godot/bin/godot.macos.editor.double.arm64",
"preLaunchTask": "Godot Engine"
},
{
"name": "Run the editor with V-Sekai planner windows",
"type": "lldb",
"request": "launch",
"args": ["--path", "${workspaceFolder}/14_planner", "-e"],
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/19_godot/bin/godot.windows.editor.double.x86_64.llvm.console.exe",
"preLaunchTask": "Godot Engine"
},
]
}
4 changes: 2 additions & 2 deletions 19_godot/modules/renik/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/V-Sekai/renik.git
branch = master
commit = 898fc6dec2fa448cf8fb2e80f75d8a4ee7192a81
parent = 20a73bceaf61829fce708a1d3e91d43a6bf8f226
commit = a0066245e5c1132dd0301689cd8705cfeae42ef4
parent = 16f4e596b3c232f928cadea385c19ae86db5046a
method = merge
cmdver = 0.4.6
46 changes: 25 additions & 21 deletions 19_godot/modules/renik/renik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,25 +1320,31 @@ void RenIK::_notification(int p_what) {
right_shoulder_pole_offset = Vector3(Math::deg_to_rad(0.0), Math::deg_to_rad(0.0),
Math::deg_to_rad(-78.0));
spine_chain.instantiate();
spine_chain->init(Vector3(0, 15, -15), 0.5, 0.5, 1, 0);
spine_chain->init(Vector3(0.0, 15, -15), 0.5, 0.5, 1, 0);
limb_arm_left.instantiate();
limb_arm_left->init(0, 0, Math::deg_to_rad(80.0), 0.5, 0,
Math::deg_to_rad(-180.0), Math::deg_to_rad(45.0), 0.33,
Vector3(Math::deg_to_rad(15.0), 0, Math::deg_to_rad(60.0)),
Vector3(2.0, -1.5, -1.0));
limb_arm_right.instantiate();
limb_arm_right->init(0, 0, Math::deg_to_rad(80.0), 0.5, 0,
Math::deg_to_rad(-180.0), Math::deg_to_rad(45.0), 0.33,
Vector3(Math::deg_to_rad(15.0), 0, Math::deg_to_rad(-60.0)),
Vector3(2.0, 1.5, 1.0));
set_arm_upper_twist_offset(190.0);
set_arm_lower_twist_offset(-60);
set_arm_roll_offset(270.0);
set_arm_upper_limb_twist(50);
set_arm_lower_limb_twist(90);
set_arm_twist_inflection_point_offset(-180.0);
set_arm_twist_overflow(45.0);
set_arm_target_rotation_influence(0.33);
set_arm_pole_offset(Vector3(15.0, 0, 60.0));
set_arm_target_position_influence(Vector3(2.0, -1.5, -1.0));
limb_leg_left.instantiate();
limb_leg_left->init(0, Math::deg_to_rad(-180.0), 0, 0.25, 0.25, 0, Math::deg_to_rad(45.0), 0.5,
Vector3(0, 0, Math_PI), Vector3());
limb_leg_right.instantiate();
limb_leg_right->init(0, Math::deg_to_rad(-180.0), 0, 0.25, 0.25, 0, Math::deg_to_rad(45.0), 0.5,
Vector3(0, 0, -Math_PI), Vector3());
set_leg_upper_twist_offset(0);
set_leg_lower_twist_offset(-180.0);
set_leg_roll_offset(0);
set_leg_upper_limb_twist(50);
set_leg_lower_limb_twist(90);
set_leg_twist_inflection_point_offset(0);
set_leg_twist_overflow(45.0);
set_leg_target_rotation_influence(0.5);
set_leg_pole_offset(Vector3(0, 0, 180));
set_arm_pole_offset(Vector3(15, 0, 60));
set_leg_target_position_influence(Vector3());
} break;
case NOTIFICATION_READY: {
_initialize();
Expand Down Expand Up @@ -1531,28 +1537,26 @@ RenIK::SpineTransforms RenIK::perform_torso_ik() {
spine_chain->get_joints()[0].relative_prev));
}

Transform3D hipLocalPose = skeleton->get_bone_pose(hip);
Transform3D correctedHipTransform = hipGlobalTransform;
correctedHipTransform.set_origin(-hipLocalPose.origin);

HashMap<BoneId, Quaternion> ik_map = solve_ik_qcp(
spine_chain,
hipGlobalTransform * skeleton->get_bone_rest(hip).basis.inverse(),
correctedHipTransform * skeleton->get_bone_rest(hip).basis.inverse(),
headGlobalTransform);
//skeleton->set_bone_global_pose_override(
// hip, hipGlobalTransform, 1.0f, true);
skeleton->set_bone_pose_rotation(hip, hipGlobalTransform.get_basis().get_rotation_quaternion());
skeleton->set_bone_pose_position(hip, hipGlobalTransform.get_origin());

apply_ik_map(ik_map, hipGlobalTransform,
bone_id_order(spine_chain));

// Keep Hip and Head as global poses tand then apply them as global pose
// override
Quaternion neckQuaternion = Quaternion();
int parent_bone = skeleton->get_bone_parent(head);
while (parent_bone != -1) {
neckQuaternion = skeleton->get_bone_pose_rotation(parent_bone) * neckQuaternion;
parent_bone = skeleton->get_bone_parent(parent_bone);
}
//skeleton->set_bone_global_pose_override(
// head, headGlobalTransform, 1.0f, true);
skeleton->set_bone_pose_rotation(head, neckQuaternion.inverse() * headGlobalTransform.get_basis().get_rotation_quaternion());

// Calculate and return the parent bone position for the arms
Expand Down
19 changes: 0 additions & 19 deletions 19_godot/modules/renik/renik/renik_limb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,6 @@

#include "renik_limb.h"

void RenIKLimb::init(float p_upper_twist_offset, float p_lower_twist_offset,
float p_roll_offset, float p_upper_limb_twist,
float p_lower_limb_twist,
float p_twist_inflection_point_offset,
float p_twist_overflow, float p_target_rotation_influence,
Vector3 p_pole_offset,
Vector3 p_target_position_influence) {
upper_twist_offset = p_upper_twist_offset;
lower_twist_offset = p_lower_twist_offset;
roll_offset = p_roll_offset;
upper_limb_twist = p_upper_limb_twist;
lower_limb_twist = p_lower_limb_twist;
twist_inflection_point_offset = p_twist_inflection_point_offset;
twist_overflow = p_twist_overflow;
target_rotation_influence = p_target_rotation_influence;
pole_offset = p_pole_offset;
target_position_influence = p_target_position_influence;
}

Transform3D RenIKLimb::get_extra_bones(Skeleton3D *p_skeleton,
BoneId p_root_bone_id,
BoneId p_tip_bone_id) {
Expand Down
6 changes: 0 additions & 6 deletions 19_godot/modules/renik/renik/renik_limb.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ struct RenIKLimb : public Resource {
// STATE: We're keeping a little bit of state now... kinda goes against the design, but it makes life easier so fuck it.
int overflow_state =
0; // 0 means no twist overflow. -1 means underflow. 1 means overflow.

void init(float p_upper_twist_offset, float p_lower_twist_offset,
float p_roll_offset, float p_upper_limb_twist,
float p_lower_limb_twist, float p_twist_inflection_point_offset,
float p_twist_overflow, float p_target_rotation_influence,
Vector3 p_pole_offset, Vector3 p_target_position_influence);
};

// TODO: If I'm really ambitious and feel like implementing multi-jointed limbs.
Expand Down

0 comments on commit c08c1b9

Please sign in to comment.