Integrating up through commit 90f050496

This commit is contained in:
alexpete
2021-04-07 14:03:29 -07:00
parent 8f2ed080a9
commit c2cbd430fe
2694 changed files with 285622 additions and 176874 deletions
@@ -0,0 +1,100 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/Math/Matrix3x4.h>
#include <AzCore/std/algorithm.h>
#include <AzCore/std/typetraits/is_base_of.h>
#include <SceneAPI/SceneCore/Containers/Scene.h>
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/Containers/Views/FilterIterator.h>
#include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
#include <SceneAPI/SceneCore/Containers/Utilities/SceneGraphUtilities.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphChildIterator.h>
#include <SceneAPI/SceneCore/Containers/Views/SceneGraphUpwardsIterator.h>
#include <SceneAPI/SceneCore/DataTypes/GraphData/ITransform.h>
#include <SceneAPI/SceneCore/DataTypes/Rules/ICoordinateSystemRule.h>
#include <SceneAPI/SceneCore/Containers/RuleContainer.h>
namespace AZ
{
namespace SceneAPI
{
namespace Utilities
{
DataTypes::MatrixType ConcatenateMatricesUpwards(const Containers::SceneGraph& graph, Containers::SceneGraph::NodeIndex nodeIndex)
{
DataTypes::MatrixType outTransform = DataTypes::MatrixType::Identity();
while (nodeIndex.IsValid())
{
auto view = Containers::Views::MakeSceneGraphChildView<Containers::Views::AcceptEndPointsOnly>(graph, nodeIndex, graph.GetContentStorage().begin(), true);
auto result = AZStd::find_if(view.begin(), view.end(), Containers::DerivedTypeFilter<DataTypes::ITransform>());
if (result != view.end())
{
// Check if the node has any child transform node
const DataTypes::MatrixType& azTransform = azrtti_cast<const DataTypes::ITransform*>(result->get())->GetMatrix();
outTransform = azTransform * outTransform;
}
else
{
// Check if the node itself is a transform node.
AZStd::shared_ptr<const DataTypes::ITransform> transformData = azrtti_cast<const DataTypes::ITransform*>(graph.GetNodeContent(nodeIndex));
if (transformData)
{
outTransform = transformData->GetMatrix() * outTransform;
}
}
if (graph.HasNodeParent(nodeIndex))
{
nodeIndex = graph.GetNodeParent(nodeIndex);
}
else
{
break;
}
}
return outTransform;
}
SCENE_CORE_API DataTypes::MatrixType DetermineWorldTransform(const Containers::Scene& scene, const Containers::SceneGraph::NodeIndex nodeIndex, const Containers::RuleContainer& ruleContainer)
{
auto coordinateSystemRule = ruleContainer.FindFirstByType<DataTypes::ICoordinateSystemRule>();
if (coordinateSystemRule && coordinateSystemRule->GetUseAdvancedData())
{
SceneAPI::DataTypes::MatrixType matrix = SceneAPI::DataTypes::MatrixType::CreateIdentity();
if (coordinateSystemRule->GetTranslation() != Vector3(0.0f, 0.0f, 0.0f) || !coordinateSystemRule->GetRotation().IsIdentity())
{
matrix = DataTypes::MatrixType::CreateFromQuaternionAndTranslation(coordinateSystemRule->GetRotation(), coordinateSystemRule->GetTranslation());
}
if (coordinateSystemRule->GetScale() != 1.0f)
{
float scale = coordinateSystemRule->GetScale();
matrix.MultiplyByScale(Vector3(scale, scale, scale));
}
if (!coordinateSystemRule->GetOriginNodeName().empty())
{
auto rootIndex = scene.GetGraph().Find(coordinateSystemRule->GetOriginNodeName());
if (rootIndex.IsValid())
{
auto worldMatrix = ConcatenateMatricesUpwards(scene.GetGraph(), rootIndex);
worldMatrix.InvertFull();
matrix *= worldMatrix;
}
}
return matrix;
}
return ConcatenateMatricesUpwards(scene.GetGraph(), nodeIndex);
}
} // Utilities
} // SceneAPI
} // AZ
@@ -0,0 +1,35 @@
#pragma once
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <SceneAPI/SceneCore/Containers/SceneGraph.h>
#include <SceneAPI/SceneCore/DataTypes/MatrixType.h>
namespace AZ
{
namespace SceneAPI
{
namespace Containers
{
class Scene;
class RuleContainer;
}
namespace Utilities
{
SCENE_CORE_API DataTypes::MatrixType DetermineWorldTransform(
const Containers::Scene& scene,
const Containers::SceneGraph::NodeIndex nodeIndex,
const Containers::RuleContainer& ruleContainer);
} // Utilities
} // SceneAPI
} // AZ
@@ -125,7 +125,7 @@ namespace AZ
template<typename Iterator, typename Traversal>
void SceneGraphDownwardsIterator<Iterator, Traversal>::IgnoreNodeDescendants()
{
m_ignoreDescendants = true;
m_ignoreDescendants = -1;
}
template<typename Iterator, typename Traversal>
@@ -43,5 +43,12 @@ namespace AZ::SceneAPI::DataTypes
virtual CoordinateSystem GetTargetCoordinateSystem() const = 0;
virtual const CoordinateSystemConverter& GetCoordinateSystemConverter() const = 0;
// advanced coordinate settings
virtual bool GetUseAdvancedData() const = 0;
virtual const AZStd::string& GetOriginNodeName() const = 0;
virtual const Quaternion& GetRotation() const = 0;
virtual const Vector3& GetTranslation() const = 0;
virtual float GetScale() const = 0;
};
} // namespace AZ::SceneAPI::DataTypes
@@ -144,6 +144,7 @@ namespace AZ
if (context && (context->IsRemovingReflection() || !context->FindClassData(AZ::SceneAPI::DataTypes::IGroup::TYPEINFO_Uuid())))
{
AZ::SceneAPI::DataTypes::IManifestObject::Reflect(context);
AZ::SceneAPI::Events::CallProcessorBinder::Reflect(context);
// Register components
AZ::SceneAPI::SceneCore::BehaviorComponent::Reflect(context);
AZ::SceneAPI::SceneCore::LoadingComponent::Reflect(context);
@@ -10,6 +10,7 @@
*
*/
#include <AzCore/Serialization/SerializeContext.h>
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.h>
namespace AZ
@@ -48,6 +49,14 @@ namespace AZ
m_bindings.clear();
}
void CallProcessorBinder::Reflect(AZ::ReflectContext* context)
{
SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<CallProcessorBinder>()->Version(1);
}
}
} // namespace Events
} // namespace SceneAPI
} // namespace AZ
@@ -20,6 +20,8 @@
namespace AZ
{
class ReflectContext;
namespace SceneAPI
{
namespace Events
@@ -55,6 +57,8 @@ namespace AZ
CallProcessorBinder() = default;
SCENE_CORE_API virtual ~CallProcessorBinder();
static void Reflect(AZ::ReflectContext* context);
protected:
CallProcessorBinder(const CallProcessorBinder&) = delete;
@@ -133,4 +137,4 @@ namespace AZ
} // namespace SceneAPI
} // namespace AZ
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.inl>
#include <SceneAPI/SceneCore/Events/CallProcessorBinder.inl>
@@ -94,6 +94,8 @@ set(FILES
Containers/Utilities/ProxyPointer.inl
Containers/Utilities/Filters.h
Containers/Utilities/Filters.inl
Containers/Utilities/SceneUtilities.h
Containers/Utilities/SceneUtilities.cpp
Containers/Utilities/SceneGraphUtilities.h
Containers/Utilities/SceneGraphUtilities.inl
Containers/Utilities/SceneGraphUtilities.cpp