remove SGContentBrowserExtension_SKeleton and clean up the editor module
This commit is contained in:
@@ -1,152 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file
|
|
||||||
*
|
|
||||||
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
||||||
*
|
|
||||||
* @section LICENSE
|
|
||||||
*
|
|
||||||
* (The MIT License)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 - 2023 SenseGlove
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*
|
|
||||||
* @section DESCRIPTION
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "SGEditor/SGContentBrowserExtension_SKeleton.h"
|
|
||||||
|
|
||||||
#include "AssetRegistry/AssetData.h"
|
|
||||||
#include "ContentBrowserDelegates.h"
|
|
||||||
#include "ContentBrowserModule.h"
|
|
||||||
#include "Framework/MultiBox/MultiBoxBuilder.h"
|
|
||||||
#include "Framework/MultiBox/MultiBoxExtender.h"
|
|
||||||
#include "Math/Transform.h"
|
|
||||||
#include "ReferenceSkeleton.h"
|
|
||||||
|
|
||||||
#include "SGLog/SGLog.h"
|
|
||||||
|
|
||||||
#define LOCTEXT_NAMESPACE "SGContentBrowserExtension_Skeleton"
|
|
||||||
|
|
||||||
void FSGContentBrowserExtension_Skeleton::Register()
|
|
||||||
{
|
|
||||||
FContentBrowserModule& ContentBrowserModule{
|
|
||||||
FModuleManager::LoadModuleChecked<FContentBrowserModule>(TEXT("ContentBrowser"))
|
|
||||||
};
|
|
||||||
|
|
||||||
TArray<FContentBrowserMenuExtender_SelectedAssets>& ContextMenuDelegates{
|
|
||||||
ContentBrowserModule.GetAllAssetViewContextMenuExtenders()
|
|
||||||
};
|
|
||||||
|
|
||||||
ContextMenuDelegates.Add(FContentBrowserMenuExtender_SelectedAssets::CreateStatic(&OnExtendAssetSelectionMenu));
|
|
||||||
}
|
|
||||||
|
|
||||||
TSharedRef<FExtender> FSGContentBrowserExtension_Skeleton::OnExtendAssetSelectionMenu(
|
|
||||||
const TArray<FAssetData>& SelectedAssets)
|
|
||||||
{
|
|
||||||
TSharedRef<FExtender> Extender{MakeShared<FExtender>()};
|
|
||||||
Extender->AddMenuExtension(
|
|
||||||
"CommonAssetActions",
|
|
||||||
EExtensionHook::After,
|
|
||||||
nullptr,
|
|
||||||
FMenuExtensionDelegate::CreateStatic(&AssetExtenderCallback, SelectedAssets)
|
|
||||||
);
|
|
||||||
return MoveTemp(Extender);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FSGContentBrowserExtension_Skeleton::AssetExtenderCallback(
|
|
||||||
FMenuBuilder& MenuBuilder, const TArray<FAssetData> SelectedAssets)
|
|
||||||
{
|
|
||||||
MenuBuilder.BeginSection("SenseGloveContext", LOCTEXT("SENSEGLOVE_CONTEXT", "SenseGlove"));
|
|
||||||
{
|
|
||||||
for (const FAssetData& Asset: SelectedAssets)
|
|
||||||
{
|
|
||||||
if (!Asset.IsRedirector() &&
|
|
||||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 1
|
|
||||||
FName(*Asset.AssetClassPath.ToString())
|
|
||||||
#else
|
|
||||||
Asset.AssetClass
|
|
||||||
#endif
|
|
||||||
!= NAME_Class && !(Asset.PackageFlags & PKG_FilterEditorOnly))
|
|
||||||
{
|
|
||||||
if (Asset.GetClass()->IsChildOf(USkeleton::StaticClass()))
|
|
||||||
{
|
|
||||||
MenuBuilder.AddMenuEntry(
|
|
||||||
LOCTEXT("UpdateSkeletonReferencePose", "Use Current Pose As SenseGlove Reference Pose"),
|
|
||||||
LOCTEXT(
|
|
||||||
"Apply the current pose as the reference pose!"
|
|
||||||
" This will modify and update the skeleton's reference pose transforms.",
|
|
||||||
"Apply the current pose as the reference pose!"
|
|
||||||
" This will modify and update the skeleton's reference pose transforms."),
|
|
||||||
FSlateIcon(
|
|
||||||
#if ENGINE_MAJOR_VERSION >= 5
|
|
||||||
FAppStyle::GetAppStyleSetName()
|
|
||||||
#else
|
|
||||||
FEditorStyle::GetStyleSetName()
|
|
||||||
#endif /* ENGINE_MAJOR_VERSION >= 5 */
|
|
||||||
, ""),
|
|
||||||
FUIAction(FExecuteAction::CreateLambda([SelectedAssets]()-> void
|
|
||||||
{
|
|
||||||
for (const FAssetData& Asset: SelectedAssets)
|
|
||||||
{
|
|
||||||
USkeleton* Skeleton{Cast<USkeleton>(Asset.GetAsset())};
|
|
||||||
|
|
||||||
if (!IsValid(Skeleton))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateRefPoseTransform(Skeleton);
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
NAME_None,
|
|
||||||
EUserInterfaceActionType::Button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MenuBuilder.EndSection();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FSGContentBrowserExtension_Skeleton::UpdateRefPoseTransform(USkeleton* Skeleton)
|
|
||||||
{
|
|
||||||
FReferenceSkeleton ReferenceSkeleton{Skeleton->GetReferenceSkeleton()};
|
|
||||||
FReferenceSkeletonModifier SkeletonModifier{ReferenceSkeleton, Skeleton};
|
|
||||||
|
|
||||||
const TArray<FMeshBoneInfo>& RefBoneInfo{ReferenceSkeleton.GetRefBoneInfo()};
|
|
||||||
const TArray<FTransform>& RefBonePose{ReferenceSkeleton.GetRefBonePose()};
|
|
||||||
|
|
||||||
for (const FMeshBoneInfo& BoneInfo : RefBoneInfo)
|
|
||||||
{
|
|
||||||
SGLOG(FString::Printf(TEXT("Modifying reference pose transform on '%s'..."), *BoneInfo.Name.ToString()));
|
|
||||||
|
|
||||||
const FName& BoneName{BoneInfo.Name};
|
|
||||||
const int32 BoneIndex = ReferenceSkeleton.FindBoneIndex(BoneName);
|
|
||||||
const FTransform& BoneTransform{RefBonePose[BoneIndex]};
|
|
||||||
|
|
||||||
SGLOG(BoneName, BoneIndex, BoneTransform);
|
|
||||||
|
|
||||||
SkeletonModifier.UpdateRefPoseTransform(BoneIndex, BoneTransform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef LOCTEXT_NAMESPACE
|
|
||||||
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
#include "SenseGloveEditorModule.h"
|
#include "SenseGloveEditorModule.h"
|
||||||
|
|
||||||
#include "SGEditor/SGContentBrowserExtension_SKeleton.h"
|
|
||||||
#include "SGLog/SGLog.h"
|
#include "SGLog/SGLog.h"
|
||||||
|
|
||||||
#define LOCTEXT_NAMESPACE "FSenseGloveEditorModule"
|
#define LOCTEXT_NAMESPACE "FSenseGloveEditorModule"
|
||||||
@@ -43,8 +42,6 @@
|
|||||||
void FSenseGloveEditorModule::StartupModule()
|
void FSenseGloveEditorModule::StartupModule()
|
||||||
{
|
{
|
||||||
SGLOG("Starting up SenseGloveEditor module...");
|
SGLOG("Starting up SenseGloveEditor module...");
|
||||||
|
|
||||||
FSGContentBrowserExtension_Skeleton::Register();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSenseGloveEditorModule::PreUnloadCallback()
|
void FSenseGloveEditorModule::PreUnloadCallback()
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file
|
|
||||||
*
|
|
||||||
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
||||||
*
|
|
||||||
* @section LICENSE
|
|
||||||
*
|
|
||||||
* (The MIT License)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2020 - 2023 SenseGlove
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*
|
|
||||||
* @section DESCRIPTION
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Containers/Array.h"
|
|
||||||
#include "Templates/SharedPointer.h"
|
|
||||||
|
|
||||||
struct FAssetData;
|
|
||||||
class FMenuBuilder;
|
|
||||||
class USkeleton;
|
|
||||||
|
|
||||||
class FSGContentBrowserExtension_Skeleton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void Register();
|
|
||||||
|
|
||||||
static TSharedRef<FExtender> OnExtendAssetSelectionMenu(const TArray<FAssetData>& SelectedAssets);
|
|
||||||
static void AssetExtenderCallback(FMenuBuilder& MenuBuilder, const TArray<FAssetData> SelectedAssets);
|
|
||||||
|
|
||||||
static void UpdateRefPoseTransform(USkeleton* Skeleton);
|
|
||||||
|
|
||||||
private:
|
|
||||||
FSGContentBrowserExtension_Skeleton() = delete;
|
|
||||||
virtual ~FSGContentBrowserExtension_Skeleton() = delete;
|
|
||||||
};
|
|
||||||
@@ -55,11 +55,6 @@ public class SenseGloveEditor : ModuleRules
|
|||||||
new string[]
|
new string[]
|
||||||
{
|
{
|
||||||
"AssetTools",
|
"AssetTools",
|
||||||
"EditorStyle",
|
|
||||||
"InputCore",
|
|
||||||
"SkeletonEditor",
|
|
||||||
"Slate",
|
|
||||||
"SlateCore",
|
|
||||||
"UnrealEd",
|
"UnrealEd",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user