ソースを参照

Merge branch 'stabilization/2106' into mbalfour/gitflow_210622

# Conflicts:
#	Scripts/build/Jenkins/Jenkinsfile
mbalfour 4 年 前
コミット
36dba91bee

+ 33 - 16
Gem/Code/Source/DynamicDrawExampleComponent.cpp

@@ -138,22 +138,32 @@ namespace AtomSampleViewer
         const uint32_t TetrahedronIndexCount = 12;
         const uint32_t TetrahedronWireframeIndexCount = 6;
 
+        float positions[4][3] =
+        {
+            { 0.2, 0.2f, 0.2f },
+            { 0.2, -0.2f, -0.2f },
+            { -0.2, 0.2f, -0.2f },
+            { -0.2, -0.2f, 0.2f }
+        };
+
+        float colors[4][4] = { { 1, 0, 0, 0.5f }, { 0, 1, 0, 0.5f }, { 0, 0, 1, 0.5f }, {1, 1, 0, 0.5f}};
+
         ExampleVertex tetrahedronVerts[TetrahedronVertexCount] = {
-            {0.2, 0.2f, 0.2f,       1, 0, 0, 0.5f}, // 0
-            {-0.2, -0.2f, 0.2f,     1, 0, 0, 0.5f}, // 3
-            {0.2, -0.2f, -0.2f,     1, 0, 0, 0.5f}, // 1
+            ExampleVertex{positions[0], colors[0]}, // 0
+            ExampleVertex{positions[3], colors[0]}, // 3
+            ExampleVertex{positions[1], colors[0]}, // 1
 
-            {0.2, 0.2f, 0.2f,       0, 1, 0, 0.5f}, // 0
-            {0.2, -0.2f, -0.2f,     0, 1, 0, 0.5f}, // 1
-            {-0.2, 0.2f, -0.2f,     0, 1, 0, 0.5f}, // 2
+            ExampleVertex{positions[0], colors[1]}, // 0
+            ExampleVertex{positions[1], colors[1]}, // 1
+            ExampleVertex{positions[2], colors[1]}, // 2
 
-            {0.2, 0.2f, 0.2f,       0, 0, 1, 0.5f}, // 0
-            {-0.2, 0.2f, -0.2f,     0, 0, 1, 0.5f}, // 2
-            {-0.2, -0.2f, 0.2f,     0, 0, 1, 0.5f}, // 3
+            ExampleVertex{positions[0], colors[2]}, // 0
+            ExampleVertex{positions[2], colors[2]}, // 2
+            ExampleVertex{positions[3], colors[2]}, // 3
 
-            {0.2, -0.2f, -0.2f,     1, 1, 0, 0.5f}, // 1
-            {-0.2, -0.2f, 0.2f,     1, 1, 0, 0.5f}, // 3
-            {-0.2, 0.2f, -0.2f,     1, 1, 0, 0.5f}  // 2
+            ExampleVertex{positions[1], colors[3]}, // 1
+            ExampleVertex{positions[3], colors[3]}, // 3
+            ExampleVertex{positions[2], colors[3]} // 2
         };
         u16 tetrahedronIndices[TetrahedronIndexCount] = {
             0, 1, 2,
@@ -162,14 +172,21 @@ namespace AtomSampleViewer
             9, 10, 11
         };
 
+        ExampleVertex tetrahedronWireFrameVerts[4] = {
+            ExampleVertex{ positions[0], colors[0] },
+            ExampleVertex{ positions[1], colors[1] }, 
+            ExampleVertex{ positions[2], colors[2] }, 
+            ExampleVertex{ positions[3], colors[3] }
+        };
+
         u16 tetrahedronWireframeIndices[TetrahedronIndexCount] =
         {
             0, 1,
             0, 2,
-            0, 4,
+            0, 3,
             1, 2,
-            2, 4,
-            4, 1
+            2, 3,
+            3, 1
         };
 
         // Enable depth test and write
@@ -228,7 +245,7 @@ namespace AtomSampleViewer
             drawSrg->SetConstant(index, Vector3(xPos, 0, 0));
             drawSrg->Compile();
             m_dynamicDraw->SetPrimitiveType(RHI::PrimitiveTopology::LineList);
-            m_dynamicDraw->DrawIndexed(tetrahedronVerts, TetrahedronVertexCount, tetrahedronWireframeIndices, TetrahedronIndexCount, RHI::IndexFormat::Uint16, drawSrg);
+            m_dynamicDraw->DrawIndexed(tetrahedronWireFrameVerts, 4, tetrahedronWireframeIndices, TetrahedronIndexCount, RHI::IndexFormat::Uint16, drawSrg);
             m_dynamicDraw->SetPrimitiveType(RHI::PrimitiveTopology::TriangleList);
         }
 

+ 7 - 2
Gem/Code/Source/DynamicDrawExampleComponent.h

@@ -51,8 +51,13 @@ namespace AtomSampleViewer
     private:
         struct ExampleVertex
         {
-            float x, y, z;
-            float r, g, b, a;
+            ExampleVertex(float position[3], float color[4])
+            {
+                memcpy(m_position, position, sizeof(float)*3);
+                memcpy(m_color, color, sizeof(float)*4);
+            }
+            float m_position[3];
+            float m_color[4];
         };
 
         AZ::RHI::Ptr<AZ::RPI::DynamicDrawContext> m_dynamicDraw;

+ 46 - 9
Gem/Code/Source/MultiSceneExampleComponent.cpp

@@ -23,6 +23,8 @@
 #include <Atom/RPI.Reflect/Asset/AssetUtils.h>
 #include <Atom/RPI.Reflect/Model/ModelAsset.h>
 
+#include <Automation/ScriptRunnerBus.h>
+
 #include <AzCore/Math/MatrixUtils.h>
 
 #include <AzCore/Component/Entity.h>
@@ -39,6 +41,15 @@
 
 namespace AtomSampleViewer
 {
+    using namespace AZ;
+
+    namespace
+    {
+        const char* BunnyModelFilePath = "objects/bunny.azmodel";
+        const char* ShaderBallModelFilePath = "objects/shaderball_simple.azmodel";
+        const char* CubeModelFilePath = "testdata/objects/cube/cube.azmodel";
+    };
+
     //////////////////////////////////////////////////////////////////////////
     // SecondWindowedScene
 
@@ -154,8 +165,11 @@ namespace AtomSampleViewer
         const auto LoadMesh = [this](const char* modelPath) -> Render::MeshFeatureProcessorInterface::MeshHandle
         {
             AZ_Assert(m_meshFeatureProcessor, "Cannot find mesh feature processor on scene");
-            auto meshAsset = RPI::AssetUtils::GetAssetByProductPath<RPI::ModelAsset>(modelPath, RPI::AssetUtils::TraceLevel::Assert);
-            Render::MeshFeatureProcessorInterface::MeshHandle meshHandle = m_meshFeatureProcessor->AcquireMesh(meshAsset);
+            auto meshAsset = RPI::AssetUtils::GetAssetByProductPath<RPI::ModelAsset>(modelPath, RPI::AssetUtils::TraceLevel::Assert);            
+            auto materialAsset = RPI::AssetUtils::LoadAssetByProductPath<RPI::MaterialAsset>(DefaultPbrMaterialPath,
+                RPI::AssetUtils::TraceLevel::Assert);
+            auto material = AZ::RPI::Material::FindOrCreate(materialAsset);
+            Render::MeshFeatureProcessorInterface::MeshHandle meshHandle = m_meshFeatureProcessor->AcquireMesh(meshAsset, material);
 
             return meshHandle;
         };
@@ -164,7 +178,7 @@ namespace AtomSampleViewer
         {
             for (uint32_t i = 0u; i < ShaderBallCount; i++)
             {
-                m_shaderBallMeshHandles.push_back(LoadMesh("objects/shaderball_simple.azmodel"));
+                m_shaderBallMeshHandles.push_back(LoadMesh(ShaderBallModelFilePath));
                 auto updateShaderBallTransform = [this, i](Data::Instance<RPI::Model> model)
                 {
                     const Aabb& aabb = model->GetModelAsset()->GetAabb();
@@ -192,7 +206,7 @@ namespace AtomSampleViewer
             const Vector3 nonUniformScale{ 24.f, 24.f, 1.0f };
             const Vector3 translation{ 0.f, 0.f, 0.0f };
             const auto transform = Transform::CreateTranslation(translation);
-            m_floorMeshHandle = LoadMesh("testdata/objects/cube/cube.azmodel");
+            m_floorMeshHandle = LoadMesh(CubeModelFilePath);
             m_meshFeatureProcessor->SetTransform(m_floorMeshHandle, transform, nonUniformScale);
         }
 
@@ -427,15 +441,37 @@ namespace AtomSampleViewer
         using namespace AZ;
 
         // Setup primary camera controls
-        Debug::CameraControllerRequestBus::Event(GetCameraEntityId(), &Debug::CameraControllerRequestBus::Events::Enable,
-            azrtti_typeid<Debug::NoClipControllerComponent>());
+        Debug::CameraControllerRequestBus::Event(
+            GetCameraEntityId(), &Debug::CameraControllerRequestBus::Events::Enable, azrtti_typeid<Debug::NoClipControllerComponent>());
+        
+        m_defaultIbl.PreloadAssets();
+
+        // preload assets
+        AZStd::vector<AssetCollectionAsyncLoader::AssetToLoadInfo> assetList = {
+            { DefaultPbrMaterialPath, azrtti_typeid<RPI::MaterialAsset>() },
+            { BunnyModelFilePath, azrtti_typeid<RPI::ModelAsset>() },
+            { CubeModelFilePath, azrtti_typeid<RPI::ModelAsset>() },
+            { ShaderBallModelFilePath, azrtti_typeid<RPI::ModelAsset>() }
+        };
+
+        PreloadAssets(assetList);
 
+        ScriptRunnerRequestBus::Broadcast(&ScriptRunnerRequests::PauseScriptWithTimeout, 120.0f);
+    }
+        
+    void MultiSceneExampleComponent::OnAllAssetsReadyActivate()
+    {
+        using namespace AZ;
         RPI::ScenePtr scene = RPI::RPISystemInterface::Get()->GetDefaultScene();
 
         // Setup Main Mesh Entity
         {
-            auto bunnyAsset = RPI::AssetUtils::GetAssetByProductPath<RPI::ModelAsset>("objects/bunny.azmodel", RPI::AssetUtils::TraceLevel::Assert);
-            m_meshHandle = GetMeshFeatureProcessor()->AcquireMesh(bunnyAsset);
+            auto materialAsset = RPI::AssetUtils::LoadAssetByProductPath<RPI::MaterialAsset>(DefaultPbrMaterialPath,
+                RPI::AssetUtils::TraceLevel::Assert);
+            auto material = AZ::RPI::Material::FindOrCreate(materialAsset);
+            auto bunnyAsset = RPI::AssetUtils::LoadAssetByProductPath<RPI::ModelAsset>(BunnyModelFilePath,
+                RPI::AssetUtils::TraceLevel::Assert);
+            m_meshHandle = GetMeshFeatureProcessor()->AcquireMesh(bunnyAsset, material);
             GetMeshFeatureProcessor()->SetTransform(m_meshHandle, Transform::CreateRotationZ(Constants::Pi));
         }
 
@@ -448,7 +484,8 @@ namespace AtomSampleViewer
         {
             OpenSecondSceneWindow();
         }
-
+        
+        ScriptRunnerRequestBus::Broadcast(&ScriptRunnerRequests::ResumeScript);
         TickBus::Handler::BusConnect();
     }
 

+ 3 - 0
Gem/Code/Source/MultiSceneExampleComponent.h

@@ -131,6 +131,9 @@ namespace AtomSampleViewer
         // AZ::TickBus::Handler overrides ...
         void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override;
 
+        // CommonSampleComponentBase overrides ...
+        void OnAllAssetsReadyActivate() override;
+
         void OpenSecondSceneWindow();
 
         AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;

+ 2 - 2
Scripts/ExpectedScreenshots/DynamicDraw/screenshot_1.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:5a0c651a0404f21efd33f3e690c7dc913d3a33c8488d9228a64447596d7d2b61
-size 13328
+oid sha256:03c1e2f08023c1cf5169c3e72807afda57d4e92d679690b20fd73f64a112323b
+size 14358

+ 2 - 2
Scripts/ExpectedScreenshots/MultiScene/Start_MultiScene1.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:bbb06e9e5933540d296383bc1665729888c346c4a97319667765bdb64f1b8c68
-size 45119
+oid sha256:81f7bd730608ab3e2203d0f2386183b727bbdb1d39aaf8f5c92b20ed7ee534e0
+size 57307

+ 2 - 2
Scripts/ExpectedScreenshots/MultiScene/Start_MultiScene2.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:1c937bf596b2ac02ba374de04fa04e99387916baa8a3637cb4fccb87e9409b72
-size 255992
+oid sha256:e78dc8c7a735985ce9ef002d9044f6e4b2df5acbb4483a15a68fa0d9b5413f51
+size 223658