Merge branch 'main' into hasareej_LYN-2475_viewportui_switcher

This commit is contained in:
hultonha
2021-04-27 11:02:20 +01:00
117 changed files with 2044 additions and 1111 deletions
+1 -1
View File
@@ -247,7 +247,7 @@ CUNIXConsole* pUnixConsole;
#define LOCALIZATION_TRANSLATIONS_LIST_FILE_NAME "Libs/Localization/localization.xml"
#define LOAD_LEGACY_RENDERER_FOR_EDITOR true // If you set this to false you must for now also set 'ed_useAtomNativeViewport' to true (see /Code/Sandbox/Editor/ViewManager.cpp)
#define LOAD_LEGACY_RENDERER_FOR_EDITOR false // If you set this to true you must also set 'ed_useAtomNativeViewport' to false (see /Code/Sandbox/Editor/ViewManager.cpp)
#define LOAD_LEGACY_RENDERER_FOR_LAUNCHER false
//////////////////////////////////////////////////////////////////////////
@@ -348,6 +348,11 @@ namespace AzToolsFramework
*/
virtual bool AreAnyEntitiesSelected() = 0;
/*!
* Returns the number of selected entities.
*/
virtual int GetSelectedEntitiesCount() = 0;
/*!
* Retrieves the set of selected entities.
* \return a list of entity Ids.
@@ -395,6 +395,7 @@ namespace AzToolsFramework
->Event("MarkEntityDeselected", &ToolsApplicationRequests::MarkEntityDeselected)
->Event("IsSelected", &ToolsApplicationRequests::IsSelected)
->Event("AreAnyEntitiesSelected", &ToolsApplicationRequests::AreAnyEntitiesSelected)
->Event("GetSelectedEntitiesCount", &ToolsApplicationRequests::GetSelectedEntitiesCount)
;
behaviorContext->EBus<ToolsApplicationNotificationBus>("ToolsApplicationNotificationBus")
@@ -101,6 +101,7 @@ namespace AzToolsFramework
SourceControlFileInfo GetSceneSourceControlInfo() override;
bool AreAnyEntitiesSelected() override { return !m_selectedEntities.empty(); }
int GetSelectedEntitiesCount() override { return m_selectedEntities.size(); }
const EntityIdList& GetSelectedEntities() override { return m_selectedEntities; }
const EntityIdList& GetHighlightedEntities() override { return m_highlightedEntities; }
void SetSelectedEntities(const EntityIdList& selectedEntities) override;
@@ -242,19 +242,6 @@ namespace AzToolsFramework
return false;
}
}
else
{
// The template is already loaded, this is the case of either saving as same name or different name(loaded from before).
// Update the template with the changes
AzToolsFramework::Prefab::PrefabDom dom;
bool success = AzToolsFramework::Prefab::PrefabDomUtils::StoreInstanceInPrefabDom(*m_rootInstance, dom);
if (!success)
{
AZ_Error("Prefab", false, "Failed to convert current root instance into a DOM when saving file '%.*s'", AZ_STRING_ARG(filename));
return false;
}
m_prefabSystemComponent->UpdatePrefabTemplate(templateId, dom);
}
Prefab::TemplateId prevTemplateId = m_rootInstance->GetTemplateId();
m_rootInstance->SetTemplateId(templateId);
@@ -200,7 +200,7 @@ namespace AzToolsFramework
}
return context.Report(result,
result.GetProcessing() == JSR::Processing::Completed ? "Succesfully loaded instance information for prefab." :
result.GetProcessing() == JSR::Processing::Completed ? "Successfully loaded instance information for prefab." :
"Failed to load instance information for prefab");
}
@@ -230,6 +230,10 @@ namespace AzToolsFramework
AZ_Assert(instanceDom.IsObject(), "Link Id '%u' cannot be added because the DOM of the instance is not an object.", m_id);
instanceDom.AddMember(rapidjson::StringRef(PrefabDomUtils::LinkIdName), rapidjson::Value().SetUint64(m_id), allocator);
}
else
{
linkIdReference->get().SetUint64(m_id);
}
}
} // namespace Prefab
@@ -392,12 +392,27 @@ namespace AzToolsFramework
if (patch.IsArray() && !patch.Empty() && beforeState.IsObject())
{
// Update the state of the entity
PrefabUndoEntityUpdate* state = aznew PrefabUndoEntityUpdate(AZStd::to_string(static_cast<AZ::u64>(entityId)));
state->SetParent(parentUndoBatch);
state->Capture(beforeState, afterState, entityId);
if (IsInstanceContainerEntity(entityId) && !IsLevelInstanceContainerEntity(entityId))
{
m_instanceToTemplateInterface->AppendEntityAliasToPatchPaths(patch, entityId);
state->Redo();
// Save these changes as patches to the link
PrefabUndoLinkUpdate* linkUpdate =
aznew PrefabUndoLinkUpdate(AZStd::to_string(static_cast<AZ::u64>(entityId)));
linkUpdate->SetParent(parentUndoBatch);
linkUpdate->Capture(patch, owningInstance->get().GetLinkId());
linkUpdate->Redo();
}
else
{
// Update the state of the entity
PrefabUndoEntityUpdate* state = aznew PrefabUndoEntityUpdate(AZStd::to_string(static_cast<AZ::u64>(entityId)));
state->SetParent(parentUndoBatch);
state->Capture(beforeState, afterState, entityId);
state->Redo();
}
}
// Update the cache
@@ -81,12 +81,17 @@ namespace UnitTest
ToolsApplicationRequestBus::BroadcastResult(
anyEntitySelected, &ToolsApplicationRequests::AreAnyEntitiesSelected);
int selectedEntitiesCount = 0;
ToolsApplicationRequestBus::BroadcastResult(
selectedEntitiesCount, &ToolsApplicationRequests::GetSelectedEntitiesCount);
EntityIdList selectedEntityIds;
ToolsApplicationRequestBus::BroadcastResult(
selectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities);
EXPECT_TRUE(testEntitySelected);
EXPECT_TRUE(anyEntitySelected);
EXPECT_EQ(selectedEntitiesCount, 1);
EXPECT_EQ(selectedEntityIds.size(), 1);
EXPECT_EQ(selectedEntityIds.front(), testEntityId);
@@ -100,11 +105,15 @@ namespace UnitTest
ToolsApplicationRequestBus::BroadcastResult(
anyEntitySelected, &ToolsApplicationRequests::AreAnyEntitiesSelected);
ToolsApplicationRequestBus::BroadcastResult(
selectedEntitiesCount, &ToolsApplicationRequests::GetSelectedEntitiesCount);
ToolsApplicationRequestBus::BroadcastResult(
selectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities);
EXPECT_FALSE(testEntitySelected);
EXPECT_FALSE(anyEntitySelected);
EXPECT_EQ(selectedEntitiesCount, 0);
EXPECT_TRUE(selectedEntityIds.empty());
}
@@ -141,11 +150,16 @@ namespace UnitTest
ToolsApplicationRequestBus::BroadcastResult(
anyEntitySelected, &ToolsApplicationRequests::AreAnyEntitiesSelected);
int selectedEntitiesCount = 0;
ToolsApplicationRequestBus::BroadcastResult(
selectedEntitiesCount, &ToolsApplicationRequests::GetSelectedEntitiesCount);
EntityIdList actualSelectedEntityIds;
ToolsApplicationRequestBus::BroadcastResult(
actualSelectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities);
EXPECT_TRUE(anyEntitySelected);
EXPECT_EQ(selectedEntitiesCount, expectedSelectedEntityIds.size());
EXPECT_EQ(actualSelectedEntityIds.size(), expectedSelectedEntityIds.size());
for (auto& id : expectedSelectedEntityIds)
{
@@ -160,10 +174,14 @@ namespace UnitTest
ToolsApplicationRequestBus::BroadcastResult(
anyEntitySelected, &ToolsApplicationRequests::AreAnyEntitiesSelected);
ToolsApplicationRequestBus::BroadcastResult(
selectedEntitiesCount, &ToolsApplicationRequests::GetSelectedEntitiesCount);
ToolsApplicationRequestBus::BroadcastResult(
actualSelectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities);
EXPECT_TRUE(anyEntitySelected);
EXPECT_EQ(selectedEntitiesCount, expectedSelectedEntityIds.size());
EXPECT_EQ(actualSelectedEntityIds.size(), expectedSelectedEntityIds.size());
for (auto& id : expectedSelectedEntityIds)
{
+10 -6
View File
@@ -232,7 +232,6 @@ int EditorViewportWidget::OnCreate()
{
m_renderer = GetIEditor()->GetRenderer();
m_engine = GetIEditor()->Get3DEngine();
assert(m_engine);
CreateRenderContext();
@@ -793,8 +792,14 @@ void EditorViewportWidget::OnRender()
// This is necessary so that automated editor tests using the null renderer to test systems like dynamic vegetation
// are still able to manipulate the current logical camera position, even if nothing is rendered.
GetIEditor()->GetSystem()->SetViewCamera(m_Camera);
GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera());
m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__);
if (GetIEditor()->GetRenderer())
{
GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera());
}
if (m_engine)
{
m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__);
}
return;
}
@@ -886,7 +891,7 @@ void EditorViewportWidget::OnBeginPrepareRender()
fov = 2 * atanf((h * tan(fov / 2)) / maxTargetHeight);
}
}
m_Camera.SetFrustum(w, h, fov, fNearZ, gEnv->p3DEngine->GetMaxViewDistance());
m_Camera.SetFrustum(w, h, fov, fNearZ);
}
GetIEditor()->GetSystem()->SetViewCamera(m_Camera);
@@ -2606,8 +2611,7 @@ bool EditorViewportWidget::GetActiveCameraPosition(AZ::Vector3& cameraPos)
{
if (GetIEditor()->IsInGameMode())
{
const Vec3 camPos = m_engine->GetRenderingCamera().GetPosition();
cameraPos = LYVec3ToAZVec3(camPos);
cameraPos = m_renderViewport->GetViewportContext()->GetCameraTransform().GetTranslation();
}
else
{
+34 -20
View File
@@ -139,7 +139,10 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE
// Make sure we unload any unused CGFs before exporting so that they don't end up in
// the level data.
pEditor->Get3DEngine()->FreeUnusedCGFResources();
if (pEditor->Get3DEngine())
{
pEditor->Get3DEngine()->FreeUnusedCGFResources();
}
CCryEditDoc* pDocument = pEditor->GetDocument();
@@ -282,7 +285,7 @@ void CGameExporter::ExportVisAreas(const char* pszGamePath, EEndian eExportEndia
SHotUpdateInfo exportInfo;
I3DEngine* p3DEngine = pEditor->Get3DEngine();
if (eExportEndian == GetPlatformEndian()) // skip second export, this data is common for PC and consoles
if (p3DEngine && (eExportEndian == GetPlatformEndian())) // skip second export, this data is common for PC and consoles
{
std::vector<struct IStatObj*>* pTempBrushTable = NULL;
std::vector<_smart_ptr<IMaterial>>* pTempMatsTable = NULL;
@@ -367,25 +370,28 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
QString missionFileName;
QString currentMissionFileName;
I3DEngine* p3DEngine = pEditor->Get3DEngine();
for (int i = 0; i < pDocument->GetMissionCount(); i++)
if (p3DEngine)
{
CMission* pMission = pDocument->GetMission(i);
QString name = pMission->GetName();
name.replace(' ', '_');
missionFileName = QStringLiteral("Mission_%1.xml").arg(name);
XmlNodeRef missionDescNode = missionsNode->newChild("Mission");
missionDescNode->setAttr("Name", pMission->GetName().toUtf8().data());
missionDescNode->setAttr("File", missionFileName.toUtf8().data());
missionDescNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
int nProgressBarRange = m_numExportedMaterials / 10 + p3DEngine->GetLoadedObjectCount();
missionDescNode->setAttr("ProgressBarRange", nProgressBarRange);
if (pMission == pCurrentMission)
for (int i = 0; i < pDocument->GetMissionCount(); i++)
{
currentMissionFileName = missionFileName;
CMission* pMission = pDocument->GetMission(i);
QString name = pMission->GetName();
name.replace(' ', '_');
missionFileName = QStringLiteral("Mission_%1.xml").arg(name);
XmlNodeRef missionDescNode = missionsNode->newChild("Mission");
missionDescNode->setAttr("Name", pMission->GetName().toUtf8().data());
missionDescNode->setAttr("File", missionFileName.toUtf8().data());
missionDescNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
int nProgressBarRange = m_numExportedMaterials / 10 + p3DEngine->GetLoadedObjectCount();
missionDescNode->setAttr("ProgressBarRange", nProgressBarRange);
if (pMission == pCurrentMission)
{
currentMissionFileName = missionFileName;
}
}
}
@@ -413,7 +419,10 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission)
XmlNodeRef missionNode = rootAction->createNode("Mission");
pCurrentMission->Export(missionNode, objectsNode);
missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
if (p3DEngine)
{
missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount());
}
//if (!CFileUtil::OverwriteFile( path+currentMissionFileName ))
// return;
@@ -483,6 +492,11 @@ void CGameExporter::ExportLevelInfo(const QString& path)
//////////////////////////////////////////////////////////////////////////
void CGameExporter::ExportMapInfo(XmlNodeRef& node)
{
if (!GetIEditor()->Get3DEngine())
{
return;
}
XmlNodeRef info = node->newChild("LevelInfo");
IEditor* pEditor = GetIEditor();
+5 -4
View File
@@ -22,7 +22,6 @@
#include "Include/ITransformManipulator.h"
#include "ActionManager.h"
#include "Settings.h"
#include "Objects/SelectionGroup.h"
#include "Include/IObjectManager.h"
#include "MathConversion.h"
@@ -191,10 +190,12 @@ void CInfoBar::IdleUpdate()
Vec3 marker = GetIEditor()->GetMarkerPosition();
CSelectionGroup* selection = GetIEditor()->GetSelection();
if (selection->GetCount() != m_numSelected)
int selectedEntitiesCount = 0;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
selectedEntitiesCount, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntitiesCount);
if (selectedEntitiesCount != m_numSelected)
{
m_numSelected = selection->GetCount();
m_numSelected = selectedEntitiesCount;
updateUI = true;
}
@@ -525,6 +525,11 @@ void CMaterialManager::OnEditorNotifyEvent(EEditorNotifyEvent event)
//////////////////////////////////////////////////////////////////////////
void CMaterialManager::ReloadDirtyMaterials()
{
if (!GetIEditor()->Get3DEngine())
{
return;
}
IMaterialManager* runtimeMaterialManager = GetIEditor()->Get3DEngine()->GetMaterialManager();
uint32 mtlCount = 0;
@@ -743,12 +748,15 @@ int CMaterialManager::GetHighlightFlags(CMaterial* pMaterial) const
result |= eHighlight_NoSurfaceType;
}
if (ISurfaceTypeManager* pSurfaceManager = GetIEditor()->Get3DEngine()->GetMaterialManager()->GetSurfaceTypeManager())
if (GetIEditor()->Get3DEngine())
{
const ISurfaceType* pSurfaceType = pSurfaceManager->GetSurfaceTypeByName(surfaceTypeName.toUtf8().data());
if (pSurfaceType && pSurfaceType->GetBreakability() != 0)
if (ISurfaceTypeManager* pSurfaceManager = GetIEditor()->Get3DEngine()->GetMaterialManager()->GetSurfaceTypeManager())
{
result |= eHighlight_Breakable;
const ISurfaceType* pSurfaceType = pSurfaceManager->GetSurfaceTypeByName(surfaceTypeName.toUtf8().data());
if (pSurfaceType && pSurfaceType->GetBreakability() != 0)
{
result |= eHighlight_Breakable;
}
}
}
+5 -2
View File
@@ -212,8 +212,11 @@ void CMission::SyncContent(bool bRetrieve, bool bIgnoreObjects, [[maybe_unused]]
else
{
// Save time of day.
m_timeOfDay = XmlHelpers::CreateXmlNode("TimeOfDay");
GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_timeOfDay, false);
if (GetIEditor()->Get3DEngine())
{
m_timeOfDay = XmlHelpers::CreateXmlNode("TimeOfDay");
GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_timeOfDay, false);
}
if (!bIgnoreObjects)
{
+1
View File
@@ -138,6 +138,7 @@ bool CLevelShaderCache::SaveBuffer(QString& textBuffer)
void CLevelShaderCache::Update()
{
IRenderer* pRenderer = gEnv->pRenderer;
if (pRenderer)
{
QString buf;
char* str = NULL;
@@ -97,6 +97,9 @@ namespace AZ
};
} // DataTypes
} // SceneAPI
AZ_TYPE_INFO_SPECIALIZE(SceneAPI::DataTypes::Color, "{937E3BF8-5204-4D40-A8DA-C8F083C89F9F}");
} // AZ
namespace AZStd
@@ -11,6 +11,8 @@
*/
#include <SceneAPI/SceneData/GraphData/AnimationData.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/RTTI/BehaviorContext.h>
namespace AZ
{
@@ -18,6 +20,31 @@ namespace AZ
{
namespace GraphData
{
void AnimationData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<AnimationData, SceneAPI::DataTypes::IAnimationData>()
->Version(1);
}
BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context);
if (behaviorContext)
{
behaviorContext->Class<SceneAPI::DataTypes::IAnimationData>()
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "scene")
->Method("GetKeyFrameCount", &SceneAPI::DataTypes::IAnimationData::GetKeyFrameCount)
->Method("GetKeyFrame", &SceneAPI::DataTypes::IAnimationData::GetKeyFrame)
->Method("GetTimeStepBetweenFrames", &SceneAPI::DataTypes::IAnimationData::GetTimeStepBetweenFrames);
behaviorContext->Class<AnimationData>()
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "scene");
}
}
AnimationData::AnimationData()
: m_timeStepBetweenFrames(1.0/30.0) // default value
{
@@ -61,6 +88,32 @@ namespace AZ
}
void BlendShapeAnimationData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<BlendShapeAnimationData, SceneAPI::DataTypes::IBlendShapeAnimationData>()
->Version(1);
}
BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context);
if (behaviorContext)
{
behaviorContext->Class<SceneAPI::DataTypes::IBlendShapeAnimationData>()
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "scene")
->Method("GetBlendShapeName", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetBlendShapeName)
->Method("GetKeyFrameCount", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetKeyFrameCount)
->Method("GetKeyFrame", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetKeyFrame)
->Method("GetTimeStepBetweenFrames", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetTimeStepBetweenFrames);
behaviorContext->Class<BlendShapeAnimationData>()
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "scene");
}
}
BlendShapeAnimationData::BlendShapeAnimationData()
: m_timeStepBetweenFrames(1 / 30.0) // default value
{
@@ -30,6 +30,8 @@ namespace AZ
public:
AZ_RTTI(AnimationData, "{D350732E-4727-41C8-95E0-FBAF5F2AC074}", SceneAPI::DataTypes::IAnimationData);
static void Reflect(ReflectContext* context);
SCENE_DATA_API AnimationData();
SCENE_DATA_API ~AnimationData() override = default;
SCENE_DATA_API virtual void AddKeyFrame(const SceneAPI::DataTypes::MatrixType& keyFrameTransform);
@@ -53,6 +55,8 @@ namespace AZ
public:
AZ_RTTI(BlendShapeAnimationData, "{02766CCF-BDA7-46B6-9BB1-58A90C1AD6AA}", SceneAPI::DataTypes::IBlendShapeAnimationData);
static void Reflect(ReflectContext* context);
SCENE_DATA_API BlendShapeAnimationData();
SCENE_DATA_API ~BlendShapeAnimationData() override = default;
SCENE_DATA_API void CloneAttributesFrom(const IGraphObject* sourceObject) override;
@@ -12,9 +12,13 @@
#include <AzCore/Casting/numeric_cast.h>
#include <SceneAPI/SceneData/GraphData/BlendShapeData.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/RTTI/BehaviorContext.h>
namespace AZ
{
AZ_TYPE_INFO_SPECIALIZE(SceneAPI::DataTypes::IBlendShapeData::Face, "{C972EC9A-3A5C-47CD-9A92-ECB4C0C0451C}");
namespace SceneData
{
namespace GraphData
@@ -23,6 +27,82 @@ namespace AZ
BlendShapeData::~BlendShapeData() = default;
void BlendShapeData::Reflect(ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<BlendShapeData, SceneAPI::DataTypes::IBlendShapeData>()
->Version(1);
}
BehaviorContext* behaviorContext = azrtti_cast<BehaviorContext*>(context);
if (behaviorContext)
{
behaviorContext->Class<SceneAPI::DataTypes::IBlendShapeData>()
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "scene")
->Method("GetUsedControlPointCount", &SceneAPI::DataTypes::IBlendShapeData::GetUsedControlPointCount)
->Method("GetControlPointIndex", &SceneAPI::DataTypes::IBlendShapeData::GetControlPointIndex)
->Method("GetUsedPointIndexForControlPoint", &SceneAPI::DataTypes::IBlendShapeData::GetUsedPointIndexForControlPoint)
->Method("GetVertexCount", &SceneAPI::DataTypes::IBlendShapeData::GetVertexCount)
->Method("GetFaceCount", &SceneAPI::DataTypes::IBlendShapeData::GetFaceCount)
->Method("GetFaceInfo", &SceneAPI::DataTypes::IBlendShapeData::GetFaceInfo)
->Method("GetPosition", &SceneAPI::DataTypes::IBlendShapeData::GetPosition)
->Method("GetNormal", &SceneAPI::DataTypes::IBlendShapeData::GetNormal)
->Method("GetFaceVertexIndex", &SceneAPI::DataTypes::IBlendShapeData::GetFaceVertexIndex);
behaviorContext->Class<SceneAPI::DataTypes::IBlendShapeData::Face>("BlendShapeDataFace")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "scene")
->Method("GetVertexIndex", [](const SceneAPI::DataTypes::IBlendShapeData::Face& self, int index)
{
if (index >= 0 && index < 3)
{
return self.vertexIndex[index];
}
return aznumeric_cast<unsigned int>(0);
});
behaviorContext->Class<BlendShapeData>()
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "scene")
->Method("GetUV", &BlendShapeData::GetUV)
->Method("GetTangent", [](const BlendShapeData& self, size_t index)
{
if (index < self.GetTangents().size())
{
return self.GetTangents().at(index);
}
AZ_Error("SceneGraphData", false, "Cannot get to tangent at index(%zu)", index);
return Vector4::CreateZero();
})
->Method("GetBitangent", [](const BlendShapeData& self, size_t index)
{
if (index < self.GetBitangents().size())
{
return self.GetBitangents().at(index);
}
AZ_Error("SceneGraphData", false, "Cannot get to bitangents at index(%zu)", index);
return Vector3::CreateZero();
})
->Method("GetColor", [](const BlendShapeData& self, AZ::u8 colorSetIndex, AZ::u8 colorIndex)
{
SceneAPI::DataTypes::Color color(0,0,0,0);
if (colorSetIndex < MaxNumColorSets)
{
const AZStd::vector<SceneAPI::DataTypes::Color>& colorChannel = self.GetColors(colorSetIndex);
if (colorIndex < colorChannel.size())
{
return colorChannel[colorIndex];
}
}
AZ_Error("SceneGraphData", false, "Cannot get to color setIndex(%d) at colorIndex(%d)", colorSetIndex, colorIndex);
return color;
});
}
}
void BlendShapeData::AddPosition(const Vector3& position)
{
m_positions.push_back(position);
@@ -31,6 +31,8 @@ namespace AZ
public:
AZ_RTTI(BlendShapeData, "{FF875C22-2E4F-4CE3-BA49-09BF78C70A09}", SceneAPI::DataTypes::IBlendShapeData)
SCENE_DATA_API static void Reflect(ReflectContext* context);
// Maximum number of color sets matches limitation set in assImp (AI_MAX_NUMBER_OF_COLOR_SETS)
static constexpr AZ::u8 MaxNumColorSets = 8;
// Maximum number of uv sets matches limitation set in assImp (AI_MAX_NUMBER_OF_TEXTURECOORDS)
@@ -16,8 +16,6 @@
namespace AZ
{
AZ_TYPE_INFO_SPECIALIZE(SceneAPI::DataTypes::Color, "{937E3BF8-5204-4D40-A8DA-C8F083C89F9F}");
namespace SceneData
{
namespace GraphData
@@ -40,7 +38,7 @@ namespace AZ
->Method("GetCount", &MeshVertexColorData::GetCount )
->Method("GetColor", &MeshVertexColorData::GetColor);
behaviorContext->Class<AZ::SceneAPI::DataTypes::Color>("MeshVertexColor")
behaviorContext->Class<AZ::SceneAPI::DataTypes::Color>("VertexColor")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "scene")
->Property("red", BehaviorValueGetter(&AZ::SceneAPI::DataTypes::Color::red), nullptr)
@@ -81,8 +81,9 @@ namespace AZ
SceneData::SceneNodeSelectionList::Reflect(context);
// Graph objects
context->Class<AZ::SceneData::GraphData::AnimationData>()->Version(1);
context->Class<AZ::SceneData::GraphData::BlendShapeData>()->Version(1);
AZ::SceneData::GraphData::AnimationData::Reflect(context);
AZ::SceneData::GraphData::BlendShapeAnimationData::Reflect(context);
AZ::SceneData::GraphData::BlendShapeData::Reflect(context);
AZ::SceneData::GraphData::BoneData::Reflect(context);
AZ::SceneData::GraphData::MaterialData::Reflect(context);
AZ::SceneData::GraphData::MeshData::Reflect(context);
@@ -107,6 +108,9 @@ namespace AZ
AZ::SceneData::GraphData::MeshVertexUVData::Reflect(context);
AZ::SceneData::GraphData::MeshVertexTangentData::Reflect(context);
AZ::SceneData::GraphData::MeshVertexBitangentData::Reflect(context);
AZ::SceneData::GraphData::AnimationData::Reflect(context);
AZ::SceneData::GraphData::BlendShapeAnimationData::Reflect(context);
AZ::SceneData::GraphData::BlendShapeData::Reflect(context);
}
} // namespace SceneAPI
} // namespace AZ
@@ -29,6 +29,8 @@
#include <SceneAPI/SceneData/GraphData/MeshVertexColorData.h>
#include <SceneAPI/SceneData/GraphData/MeshVertexTangentData.h>
#include <SceneAPI/SceneData/GraphData/MeshVertexUVData.h>
#include <SceneAPI/SceneData/GraphData/AnimationData.h>
#include <SceneAPI/SceneData/GraphData/BlendShapeData.h>
namespace AZ
{
@@ -101,6 +103,53 @@ namespace AZ
tangentData->SetTangentSetIndex(2);
return true;
}
else if (data.get_type_info().m_id == azrtti_typeid<AZ::SceneData::GraphData::AnimationData>())
{
auto* animationData = AZStd::any_cast<AZ::SceneData::GraphData::AnimationData>(&data);
animationData->ReserveKeyFrames(3);
animationData->AddKeyFrame(DataTypes::MatrixType::CreateFromValue(1.0));
animationData->AddKeyFrame(DataTypes::MatrixType::CreateFromValue(2.0));
animationData->AddKeyFrame(DataTypes::MatrixType::CreateFromValue(3.0));
animationData->SetTimeStepBetweenFrames(4.0);
return true;
}
else if (data.get_type_info().m_id == azrtti_typeid<AZ::SceneData::GraphData::BlendShapeAnimationData>())
{
auto* blendShapeAnimationData = AZStd::any_cast<AZ::SceneData::GraphData::BlendShapeAnimationData>(&data);
blendShapeAnimationData->SetBlendShapeName("mockBlendShapeName");
blendShapeAnimationData->ReserveKeyFrames(3);
blendShapeAnimationData->AddKeyFrame(1.0);
blendShapeAnimationData->AddKeyFrame(2.0);
blendShapeAnimationData->AddKeyFrame(3.0);
blendShapeAnimationData->SetTimeStepBetweenFrames(4.0);
return true;
}
else if (data.get_type_info().m_id == azrtti_typeid<AZ::SceneData::GraphData::BlendShapeData>())
{
auto* blendShapeData = AZStd::any_cast<AZ::SceneData::GraphData::BlendShapeData>(&data);
blendShapeData->AddPosition({ 1.0, 2.0, 3.0 });
blendShapeData->AddPosition({ 2.0, 3.0, 4.0 });
blendShapeData->AddPosition({ 3.0, 4.0, 5.0 });
blendShapeData->AddNormal({ 0.1, 0.2, 0.3 });
blendShapeData->AddNormal({ 0.2, 0.3, 0.4 });
blendShapeData->AddNormal({ 0.3, 0.4, 0.5 });
blendShapeData->AddTangentAndBitangent(Vector4{ 0.1f, 0.2f, 0.3f, 0.4f }, { 0.0, 0.1, 0.2 });
blendShapeData->AddTangentAndBitangent(Vector4{ 0.2f, 0.3f, 0.4f, 0.5f }, { 0.1, 0.2, 0.3 });
blendShapeData->AddTangentAndBitangent(Vector4{ 0.3f, 0.4f, 0.5f, 0.6f }, { 0.2, 0.3, 0.4 });
blendShapeData->AddUV(Vector2{ 0.9, 0.8 }, 0);
blendShapeData->AddUV(Vector2{ 0.7, 0.7 }, 1);
blendShapeData->AddUV(Vector2{ 0.6, 0.6 }, 2);
blendShapeData->AddColor(DataTypes::Color{ 0.1, 0.2, 0.3, 0.4 }, 0);
blendShapeData->AddColor(DataTypes::Color{ 0.2, 0.3, 0.4, 0.5 }, 1);
blendShapeData->AddColor(DataTypes::Color{ 0.3, 0.4, 0.5, 0.6 }, 2);
blendShapeData->AddFace({ 0, 1, 2 });
blendShapeData->AddFace({ 1, 2, 0 });
blendShapeData->AddFace({ 2, 0, 1 });
blendShapeData->SetVertexIndexToControlPointIndexMap(0, 1);
blendShapeData->SetVertexIndexToControlPointIndexMap(1, 2);
blendShapeData->SetVertexIndexToControlPointIndexMap(2, 0);
return true;
}
return false;
}
@@ -296,6 +345,116 @@ namespace AZ
ExpectExecute("TestExpectIntegerEquals(meshVertexTangentData:GetTangentSetIndex(), 2)");
ExpectExecute("TestExpectTrue(meshVertexTangentData:GetTangentSpace(), MeshVertexTangentData.EMotionFX)");
}
TEST_F(GrapDatahBehaviorScriptTest, SceneGraph_AnimationData_AccessWorks)
{
ExpectExecute("animationData = AnimationData()");
ExpectExecute("TestExpectTrue(animationData ~= nil)");
ExpectExecute("MockGraphData.FillData(animationData)");
ExpectExecute("TestExpectIntegerEquals(animationData:GetKeyFrameCount(), 3)");
ExpectExecute("TestExpectFloatEquals(animationData:GetTimeStepBetweenFrames(), 4.0)");
ExpectExecute("TestExpectFloatEquals(animationData:GetKeyFrame(0).basisX.x, 1.0)");
ExpectExecute("TestExpectFloatEquals(animationData:GetKeyFrame(1).basisX.y, 2.0)");
ExpectExecute("TestExpectFloatEquals(animationData:GetKeyFrame(2).basisX.z, 3.0)");
}
TEST_F(GrapDatahBehaviorScriptTest, SceneGraph_BlendShapeAnimationData_AccessWorks)
{
ExpectExecute("blendShapeAnimationData = BlendShapeAnimationData()");
ExpectExecute("TestExpectTrue(blendShapeAnimationData ~= nil)");
ExpectExecute("MockGraphData.FillData(blendShapeAnimationData)");
ExpectExecute("TestExpectTrue(blendShapeAnimationData:GetBlendShapeName() == 'mockBlendShapeName')");
ExpectExecute("TestExpectIntegerEquals(blendShapeAnimationData:GetKeyFrameCount(), 3)");
ExpectExecute("TestExpectFloatEquals(blendShapeAnimationData:GetKeyFrame(0), 1.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeAnimationData:GetKeyFrame(1), 2.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeAnimationData:GetKeyFrame(2), 3.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeAnimationData:GetTimeStepBetweenFrames(), 4.0)");
}
TEST_F(GrapDatahBehaviorScriptTest, SceneGraph_BlendShapeData_AccessWorks)
{
ExpectExecute("blendShapeData = BlendShapeData()");
ExpectExecute("TestExpectTrue(blendShapeData ~= nil)");
ExpectExecute("MockGraphData.FillData(blendShapeData)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetUsedControlPointCount(), 3)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetVertexCount(), 3)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetFaceCount(), 3)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetFaceVertexIndex(0, 2), 2)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetFaceVertexIndex(1, 0), 1)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetFaceVertexIndex(2, 1), 0)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetControlPointIndex(0), 1)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetControlPointIndex(1), 2)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetControlPointIndex(2), 0)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetUsedPointIndexForControlPoint(0), 2)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetUsedPointIndexForControlPoint(1), 0)");
ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetUsedPointIndexForControlPoint(2), 1)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(0).x, 1.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(0).y, 2.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(0).z, 3.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(1).x, 2.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(1).y, 3.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(1).z, 4.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(2).x, 3.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(2).y, 4.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(2).z, 5.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(0).x, 0.1)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(0).y, 0.2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(0).z, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(1).x, 0.2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(1).y, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(1).z, 0.4)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(2).x, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(2).y, 0.4)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(2).z, 0.5)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(0):GetVertexIndex(0), 0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(0):GetVertexIndex(1), 1)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(0):GetVertexIndex(2), 2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(1):GetVertexIndex(0), 1)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(1):GetVertexIndex(1), 2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(1):GetVertexIndex(2), 0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(2):GetVertexIndex(0), 2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(2):GetVertexIndex(1), 0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(2):GetVertexIndex(2), 1)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 0).x, 0.9)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 0).y, 0.8)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 1).x, 0.7)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 1).y, 0.7)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 2).x, 0.6)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 2).y, 0.6)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(0, 0).red, 0.1)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(0, 0).green, 0.2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(0, 0).blue, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(0, 0).alpha, 0.4)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(1, 0).red, 0.2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(1, 0).green, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(1, 0).blue, 0.4)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(1, 0).alpha, 0.5)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(2, 0).red, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(2, 0).green, 0.4)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(2, 0).blue, 0.5)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(2, 0).alpha, 0.6)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(0).x, 0.1)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(0).y, 0.2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(0).z, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(0).w, 0.4)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(1).x, 0.2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(1).y, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(1).z, 0.4)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(1).w, 0.5)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(2).x, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(2).y, 0.4)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(2).z, 0.5)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(2).w, 0.6)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(0).x, 0.0)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(0).y, 0.1)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(0).z, 0.2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(1).x, 0.1)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(1).y, 0.2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(1).z, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(2).x, 0.2)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(2).y, 0.3)");
ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(2).z, 0.4)");
}
}
}
}