FBox UPhysicsConstraintComponent::GetBodyBoxInternal(EConstraintFrame::Type Frame, FName InBoneName) const { FBox ResultBox(0); UPrimitiveComponent* PrimComp = GetComponentInternal(Frame); // Skeletal case USkeletalMeshComponent* SkelComp = Cast<USkeletalMeshComponent>(PrimComp); if(SkelComp != NULL) { UPhysicsAsset * const PhysicsAsset = SkelComp->GetPhysicsAsset(); if (PhysicsAsset) { int32 BoneIndex = SkelComp->GetBoneIndex(InBoneName); int32 BodyIndex = PhysicsAsset->FindBodyIndex(InBoneName); if(BoneIndex != INDEX_NONE && BodyIndex != INDEX_NONE) { const FTransform BoneTransform = SkelComp->GetBoneTransform(BoneIndex); ResultBox = PhysicsAsset->BodySetup[BodyIndex]->AggGeom.CalcAABB(BoneTransform); } } } else if(PrimComp != NULL) { ResultBox = PrimComp->Bounds.GetBox(); } return ResultBox; }
FWidget::EWidgetMode FFabrikEditMode::GetWidgetMode() const { USkeletalMeshComponent* SkelComp = GetAnimPreviewScene().GetPreviewMeshComponent(); int32 BoneIndex = SkelComp->GetBoneIndex(GraphNode->Node.EffectorTransformBone.BoneName); if (BoneIndex != INDEX_NONE) { return FWidget::WM_Translate; } return FWidget::WM_None; }
FVector FObserveBoneEditMode::GetWidgetLocation() const { USkeletalMeshComponent* SkelComp = GetAnimPreviewScene().GetPreviewMeshComponent(); USkeleton* Skeleton = SkelComp->SkeletalMesh->Skeleton; FVector WidgetLoc = FVector::ZeroVector; int32 MeshBoneIndex = SkelComp->GetBoneIndex(GraphNode->Node.BoneToObserve.BoneName); if (MeshBoneIndex != INDEX_NONE) { const FTransform BoneTM = SkelComp->GetBoneTransform(MeshBoneIndex); WidgetLoc = BoneTM.GetLocation(); } return WidgetLoc; }
FTransform UPhysicsConstraintComponent::GetBodyTransformInternal(EConstraintFrame::Type Frame, FName InBoneName) const { UPrimitiveComponent* PrimComp = GetComponentInternal(Frame); if(!PrimComp) { return FTransform::Identity; } //Use ComponentToWorld by default for all components FTransform ResultTM = PrimComp->ComponentToWorld; // Skeletal case USkeletalMeshComponent* SkelComp = Cast<USkeletalMeshComponent>(PrimComp); if(SkelComp != NULL) { int32 BoneIndex = SkelComp->GetBoneIndex(InBoneName); if(BoneIndex != INDEX_NONE) { ResultTM = SkelComp->GetBoneTransform(BoneIndex); } } return ResultTM; }