void UPhATEdSkeletalMeshComponent::DrawHierarchy(FPrimitiveDrawInterface* PDI, bool bAnimSkel) { for (int32 i=1; i<GetNumSpaceBases(); ++i) { int32 ParentIndex = SkeletalMesh->RefSkeleton.GetParentIndex(i); FVector ParentPos, ChildPos; if (bAnimSkel) { ParentPos = ComponentToWorld.TransformPosition(AnimationSpaceBases[ParentIndex].GetLocation()); ChildPos = ComponentToWorld.TransformPosition(AnimationSpaceBases[i].GetLocation()); } else { ParentPos = ComponentToWorld.TransformPosition(GetSpaceBases()[ParentIndex].GetLocation()); ChildPos = ComponentToWorld.TransformPosition(GetSpaceBases()[i].GetLocation()); } FColor DrawColor = bAnimSkel ? AnimSkelDrawColor : HierarchyDrawColor; PDI->DrawLine(ParentPos, ChildPos, DrawColor, SDPG_Foreground); } }
void USkeletalMeshComponent::BlendInPhysics(FTickFunction& ThisTickFunction) { check(IsInGameThread()); // Can't do anything without a SkeletalMesh if( !SkeletalMesh ) { return; } // We now have all the animations blended together and final relative transforms for each bone. // If we don't have or want any physics, we do nothing. if( Bodies.Num() > 0 ) { HandleExistingParallelEvaluationTask(/*bBlockOnTask = */ true, /*bPerformPostAnimEvaluation =*/ true); // start parallel work check(!IsValidRef(ParallelAnimationEvaluationTask)); const bool bParallelBlend = !!CVarUseParallelBlendPhysics.GetValueOnGameThread() && FApp::ShouldUseThreadingForPerformance(); if(bParallelBlend) { if (SkeletalMesh->RefSkeleton.GetNum() != AnimEvaluationContext.LocalAtoms.Num()) { // Initialize Parallel Task arrays AnimEvaluationContext.SpaceBases = GetSpaceBases(); } AnimEvaluationContext.LocalAtoms.Reset(LocalAtoms.Num()); AnimEvaluationContext.LocalAtoms.Append(LocalAtoms); ParallelAnimationEvaluationTask = TGraphTask<FParallelBlendPhysicsTask>::CreateTask().ConstructAndDispatchWhenReady(this); // set up a task to run on the game thread to accept the results FGraphEventArray Prerequistes; Prerequistes.Add(ParallelAnimationEvaluationTask); check(!IsValidRef(ParallelBlendPhysicsCompletionTask)); ParallelBlendPhysicsCompletionTask = TGraphTask<FParallelBlendPhysicsCompletionTask>::CreateTask(&Prerequistes).ConstructAndDispatchWhenReady(this); ThisTickFunction.GetCompletionHandle()->DontCompleteUntil(ParallelBlendPhysicsCompletionTask); } else { PerformBlendPhysicsBones(RequiredBones, LocalAtoms); PostBlendPhysics(); } } }