Skip to content

Commit

Permalink
Merge pull request #2 from tuatec/unweighted-bones
Browse files Browse the repository at this point in the history
Add Unweighted Bones directly in Unreal
  • Loading branch information
AchimTuran authored Jul 18, 2022
2 parents 7b02b13 + 3c6080b commit 13ddaa7
Show file tree
Hide file tree
Showing 13 changed files with 771 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Content/Data/DT_ConstraintBone.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Data/DT_IKBoneChains.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Data/DT_Sockets.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/Data/DT_UnweightedBones.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Data/DT_VirtualBones.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/EditorHooks/BP_IKRigFunctions.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/EditorHooks/BP_SkeletonBoneFunctions.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/HeldObjectEditor/BP_HeldObjectEditor.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/Structures/ST_TTUnweightedBones.uasset
Git LFS file not shown
35 changes: 30 additions & 5 deletions Source/TTToolbox/Private/IKRig_ConstraintBones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,40 @@ void UIKRig_ConstraintBones::Initialize(const FIKRigSkeleton& IKRigSkeleton)
{
m_constraintBones.Reserve(ConstraintBones.Num());

bool errorsOccurred = false;

//! @todo @ffs sort bone indices
for (auto& constraintBone : ConstraintBones)
for (auto& constraint : ConstraintBones)
{
m_constraintBones.Add(
{
IKRigSkeleton.GetBoneIndexFromName(constraintBone.ConstraintBone),
IKRigSkeleton.GetBoneIndexFromName(constraintBone.ModifiedBone)
int32 constraintBone = IKRigSkeleton.GetBoneIndexFromName(constraint.ConstraintBone);
int32 modifiedBone = IKRigSkeleton.GetBoneIndexFromName(constraint.ModifiedBone);

if (constraintBone == INDEX_NONE)
{
errorsOccurred = true;
UE_LOG(LogTemp, Error, TEXT("Failed get get bone index for constaint bone %s"), *constraint.ConstraintBone.ToString());
continue;
}

if (modifiedBone == INDEX_NONE)
{
errorsOccurred = true;
UE_LOG(LogTemp, Error, TEXT("Failed get get bone index for constaint bone %s"), *constraint.ModifiedBone.ToString());
continue;
}

m_constraintBones.Add(
{
constraintBone,
modifiedBone
});
}

if (errorsOccurred)
{
UE_LOG(LogTemp, Error, TEXT("Some constraint bones could not be set up, no constraining will be done. Please check the error messages above."));
m_constraintBones.Empty();
}
}

void UIKRig_ConstraintBones::Solve(FIKRigSkeleton& IKRigSkeleton, const FIKRigGoalContainer& Goals)
Expand Down
Loading

0 comments on commit 13ddaa7

Please sign in to comment.