PR feedback addressing
Signed-off-by: Sergey Pereslavtsev <pereslav@amazon.com>monroegm-disable-blank-issue-2
parent
8d30524028
commit
701b7a55e6
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <EditorSelectableTagListProvider.h>
|
||||
#include <SurfaceData/SurfaceTag.h>
|
||||
|
||||
namespace Terrain
|
||||
{
|
||||
AZStd::vector<AZStd::pair<AZ::u32, AZStd::string>> EditorSelectableTagListProvider::BuildSelectableTagList() const
|
||||
{
|
||||
AZStd::vector<AZStd::pair<AZ::u32, AZStd::string>> availableTags = SurfaceData::SurfaceTag::GetRegisteredTags();
|
||||
|
||||
AZStd::unordered_set<AZ::u32> tagsInUse = AZStd::move(GetSurfaceTagsInUse());
|
||||
|
||||
// Filter out all tags in use from the list of registered tags
|
||||
availableTags.erase(std::remove_if(availableTags.begin(), availableTags.end(),
|
||||
[&tagsInUse](const auto& tag)-> bool
|
||||
{
|
||||
return tagsInUse.contains(tag.first);
|
||||
}), availableTags.end());
|
||||
|
||||
return AZStd::move(availableTags);
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/containers/unordered_set.h>
|
||||
|
||||
namespace Terrain
|
||||
{
|
||||
//! Interface for a class providing information about surface tags available for selecting in Editor components.
|
||||
class EditorSelectableTagListProvider
|
||||
{
|
||||
public:
|
||||
//! Returns a list of available tags to be selected in the component.
|
||||
virtual AZStd::vector<AZStd::pair<AZ::u32, AZStd::string>> BuildSelectableTagList() const;
|
||||
|
||||
//! Returns a set of CRC of all surface tags currently in use and not available for selecting.
|
||||
virtual AZStd::unordered_set<AZ::u32> GetSurfaceTagsInUse() const = 0;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <EditorSurfaceTagListProvider.h>
|
||||
#include <AzCore/std/sort.h>
|
||||
|
||||
|
||||
namespace Terrain
|
||||
{
|
||||
AZStd::vector<AZStd::pair<AZ::u32, AZStd::string>> BuildSelectableTagList(const EditorSurfaceTagListProvider* tagListProvider,
|
||||
const SurfaceData::SurfaceTag& currentTag)
|
||||
{
|
||||
AZStd::vector<AZStd::pair<AZ::u32, AZStd::string>> availableTags = SurfaceData::SurfaceTag::GetRegisteredTags();
|
||||
|
||||
AZStd::unordered_set<SurfaceData::SurfaceTag> tagsInUse;
|
||||
|
||||
if (tagListProvider)
|
||||
{
|
||||
tagsInUse = AZStd::move(tagListProvider->GetSurfaceTagsInUse());
|
||||
|
||||
// Filter out all tags in use from the list of registered tags
|
||||
AZStd::erase_if(availableTags, [&tagsInUse](const auto& tag)-> bool
|
||||
{
|
||||
return tagsInUse.contains(SurfaceData::SurfaceTag(tag.first));
|
||||
});
|
||||
}
|
||||
|
||||
// Insert the current tag back if it was removed via tagsInUse
|
||||
availableTags.emplace_back({ AZ::u32(currentTag), currentTag.GetDisplayName() });
|
||||
|
||||
// Sorting for consistency
|
||||
AZStd::sort(availableTags.begin(), availableTags.end(), [](const auto& lhs, const auto& rhs) {return lhs.second < rhs.second; });
|
||||
|
||||
return AZStd::move(availableTags);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
#include <AzCore/std/containers/unordered_set.h>
|
||||
#include <SurfaceData/SurfaceTag.h>
|
||||
|
||||
namespace Terrain
|
||||
{
|
||||
//! Interface for a class providing information about surface tags available for selecting in Editor components.
|
||||
class EditorSurfaceTagListProvider
|
||||
{
|
||||
public:
|
||||
//! Returns a set of all surface tags currently in use that won't be available for selecting.
|
||||
virtual AZStd::unordered_set<SurfaceData::SurfaceTag> GetSurfaceTagsInUse() const = 0;
|
||||
};
|
||||
|
||||
//! Returns a list of available tags to be selected in the component.
|
||||
AZStd::vector<AZStd::pair<AZ::u32, AZStd::string>> BuildSelectableTagList(
|
||||
const EditorSurfaceTagListProvider* tagListProvider,
|
||||
const SurfaceData::SurfaceTag& currentTag);
|
||||
}
|
||||
Loading…
Reference in New Issue