Files
UnrealEngineUWP/Engine/Source/Editor/AnimGraph/Private/AnimGraphNode_Fabrik.cpp
PaulEremeeff 3d878d5a79 PR #996: Fixing PVS-Studio warnings (Contributed by PaulEremeeff)
I have reviewed each change carefully, but it is a large change and I could have missed something! Here is a summary of the types of changes in this CL:
 * Made nullptr checks consistent (the plurality of the changes are of this type)
 * Completed switch statements (IE, switch did not explicitly handle default case, but had unhandled enum entries - this is the second most popular type of fix)
 * Removed unused variables
 * Removed redundant initializations
 * WidgetNavigationCustomization.cpp was fixed by the owner
 * integers converted to floats where result was stored in a float
 * Removed redundent null checks (e.g. before delete statements)
 * Renamed variables to prevent non-obvious shadowing
 * Fixed use of bitwise & when checking for equality to an enum entry (which is often 0)
 * Fixes for some copy paste errors (e.g. FoliageEdMode.cpp)

[CL 2498053 by Dan Oconnor in Main branch]
2015-03-31 20:12:31 -04:00

82 lines
2.5 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "AnimGraphPrivatePCH.h"
#include "AnimGraphNode_Fabrik.h"
/////////////////////////////////////////////////////
// UAnimGraphNode_Fabrik
#define LOCTEXT_NAMESPACE "A3Nodes"
UAnimGraphNode_Fabrik::UAnimGraphNode_Fabrik(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
FText UAnimGraphNode_Fabrik::GetControllerDescription() const
{
return LOCTEXT("Fabrik", "FABRIK");
}
FText UAnimGraphNode_Fabrik::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
return GetControllerDescription();
}
FVector UAnimGraphNode_Fabrik::GetWidgetLocation(const USkeletalMeshComponent* SkelComp, FAnimNode_SkeletalControlBase* AnimNode)
{
FName& BoneName = Node.EffectorTransformBone.BoneName;
FVector Location = Node.EffectorTransform.GetLocation();
EBoneControlSpace Space = Node.EffectorTransformSpace;
FVector WidgetLoc = ConvertWidgetLocation(SkelComp, AnimNode->ForwardedPose, BoneName, Location, Space);
return WidgetLoc;
}
int32 UAnimGraphNode_Fabrik::GetWidgetMode(const USkeletalMeshComponent* SkelComp)
{
uint32 BoneIndex = SkelComp->GetBoneIndex(Node.EffectorTransformBone.BoneName);
if (BoneIndex != INDEX_NONE)
{
return FWidget::WM_Translate;
}
return FWidget::WM_None;
}
FName UAnimGraphNode_Fabrik::FindSelectedBone()
{
return Node.EffectorTransformBone.BoneName;
}
void UAnimGraphNode_Fabrik::DoTranslation(const USkeletalMeshComponent* SkelComp, FVector& Drag, FAnimNode_Base* InOutAnimNode)
{
FAnimNode_Fabrik* Fabrik = static_cast<FAnimNode_Fabrik*>(InOutAnimNode);
if (Fabrik)
{
FVector Offset = ConvertCSVectorToBoneSpace(SkelComp, Drag, Fabrik->ForwardedPose, Node.EffectorTransformBone.BoneName, Node.EffectorTransformSpace);
Fabrik->EffectorTransform.AddToTranslation(Offset);
// copy same value to internal node for data consistency
Node.EffectorTransform.SetTranslation(Fabrik->EffectorTransform.GetTranslation());
}
}
void UAnimGraphNode_Fabrik::CopyNodeDataTo(FAnimNode_Base* AnimNode)
{
FAnimNode_Fabrik* Fabrik = static_cast<FAnimNode_Fabrik*>(AnimNode);
// copies Pin values from the internal node to get data which are not compiled yet
Fabrik->EffectorTransform = Node.EffectorTransform;
}
void UAnimGraphNode_Fabrik::CopyNodeDataFrom(const FAnimNode_Base* InNewAnimNode)
{
const FAnimNode_Fabrik* Fabrik = static_cast<const FAnimNode_Fabrik*>(InNewAnimNode);
// copies Pin data from updated values
Node.EffectorTransform = Fabrik->EffectorTransform;
}
#undef LOCTEXT_NAMESPACE