Tagger: Added some functions to the class to be used anywhere

This commit is contained in:
Daniel Santos-Olivan 2020-07-27 16:53:07 +02:00 committed by DSantosO
parent 53f54ee0b7
commit 5eb2f6dc18
2 changed files with 21 additions and 11 deletions

View File

@ -20,7 +20,7 @@ static auto CastEnum(T label)
return static_cast<typename std::underlying_type<T>::type>(label);
}
static ECityObjectLabel GetLabelByFolderName(const FString &String) {
ECityObjectLabel ATagger::GetLabelByFolderName(const FString &String) {
if (String == "Buildings") return ECityObjectLabel::Buildings;
else if (String == "Fences") return ECityObjectLabel::Fences;
else if (String == "Pedestrians") return ECityObjectLabel::Pedestrians;
@ -36,16 +36,7 @@ static ECityObjectLabel GetLabelByFolderName(const FString &String) {
else return ECityObjectLabel::None;
}
template <typename T>
static ECityObjectLabel GetLabelByPath(const T *Object)
{
const FString Path = Object->GetPathName();
TArray<FString> StringArray;
Path.ParseIntoArray(StringArray, TEXT("/"), false);
return (StringArray.Num() > 4 ? GetLabelByFolderName(StringArray[4]) : ECityObjectLabel::None);
}
static void SetStencilValue(
void ATagger::SetStencilValue(
UPrimitiveComponent &Component,
const ECityObjectLabel &Label,
const bool bSetRenderCustomDepth) {

View File

@ -47,6 +47,7 @@ public:
/// objects having this value active.
static void TagActor(const AActor &Actor, bool bTagForSemanticSegmentation);
/// Set the tag of every actor in level.
///
/// If bTagForSemanticSegmentation true, activate the custom depth pass. This
@ -71,8 +72,26 @@ public:
return (Tag == GetTagOfTaggedComponent(Component));
}
/// Retrieve the tags of an already tagged actor. ECityObjectLabel::None is
/// not added to the array.
static FString GetTagAsString(ECityObjectLabel Tag);
/// Method that computes the label corresponding to a folder path
static ECityObjectLabel GetLabelByFolderName(const FString &String);
/// Method that computes the label corresponding to an specific object
/// using the folder path in which it is stored
template <typename T>
static ECityObjectLabel GetLabelByPath(const T *Object) {
const FString Path = Object->GetPathName();
TArray<FString> StringArray;
Path.ParseIntoArray(StringArray, TEXT("/"), false);
return (StringArray.Num() > 4 ? GetLabelByFolderName(StringArray[4]) : ECityObjectLabel::None);
}
static void SetStencilValue(UPrimitiveComponent &Component,
const ECityObjectLabel &Label, const bool bSetRenderCustomDepth);
ATagger();
protected: