Integrating up through commit 90f050496
This commit is contained in:
@@ -27,8 +27,9 @@
|
||||
#include <Components/ClothComponentMesh/ClothDebugDisplay.h>
|
||||
#include <Components/ClothComponentMesh/ClothComponentMesh.h>
|
||||
|
||||
#include <AzFramework/Physics/World.h>
|
||||
#include <AzFramework/Physics/PhysicsScene.h>
|
||||
#include <AzFramework/Physics/WindBus.h>
|
||||
#include <AzFramework/Physics/Common/PhysicsTypes.h>
|
||||
|
||||
namespace NvCloth
|
||||
{
|
||||
@@ -637,8 +638,15 @@ namespace NvCloth
|
||||
// Gravity and scale
|
||||
if (m_config.IsUsingWorldBusGravity())
|
||||
{
|
||||
AZ::Vector3 gravity(0.0f, 0.0f, -9.81f);
|
||||
Physics::WorldRequestBus::EventResult(gravity, Physics::DefaultPhysicsWorldId, &Physics::WorldRequests::GetGravity);
|
||||
AZ::Vector3 gravity = AzPhysics::DefaultGravity;
|
||||
if (auto* sceneInterface = AZ::Interface<AzPhysics::SceneInterface>::Get())
|
||||
{
|
||||
AzPhysics::SceneHandle defaultScene = sceneInterface->GetSceneHandle(AzPhysics::DefaultPhysicsSceneName);
|
||||
if (defaultScene != AzPhysics::InvalidSceneHandle)
|
||||
{
|
||||
gravity = sceneInterface->GetGravity(defaultScene);
|
||||
}
|
||||
}
|
||||
clothConfig->SetGravity(gravity * m_config.m_gravityScale);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace NvCloth
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void CopyNvRange(const nv::cloth::Range<const T>& nvRange, AZStd::vector<T>& azVector)
|
||||
static void CopyNvRange(const nv::cloth::Range<const T>& nvRange, AZStd::vector<T>& azVector)
|
||||
{
|
||||
azVector.resize(nvRange.size());
|
||||
AZStd::copy(nvRange.begin(), nvRange.end(), azVector.begin());
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <AzCore/UserSettings/UserSettingsComponent.h>
|
||||
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
#include <AzToolsFramework/Application/ToolsApplication.h>
|
||||
#include <AzToolsFramework/UnitTest/ToolsTestApplication.h>
|
||||
|
||||
#include <System/FabricCooker.h>
|
||||
#include <System/TangentSpaceHelper.h>
|
||||
@@ -29,6 +29,24 @@
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class NvClothToolsTestApplication
|
||||
: public ToolsTestApplication
|
||||
{
|
||||
public:
|
||||
explicit NvClothToolsTestApplication(AZStd::string applicationName)
|
||||
: ToolsTestApplication(applicationName)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
bool IsPrefabSystemEnabled() const override
|
||||
{
|
||||
// The NvCloth unit tests currently have a crash on teardown when the prefab system is enabled,
|
||||
// so they can only be run with prefabs disabled at this time.
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
//! Sets up gem test environment, required components, and shared objects used by cloth (e.g. FabricCooker) for all test cases.
|
||||
class NvClothEditorTestEnvironment
|
||||
: public AZ::Test::GemTestEnvironment
|
||||
@@ -102,7 +120,7 @@ namespace UnitTest
|
||||
|
||||
AZ::ComponentApplication* NvClothEditorTestEnvironment::CreateApplicationInstance()
|
||||
{
|
||||
return aznew AzToolsFramework::ToolsApplication;
|
||||
return aznew NvClothToolsTestApplication("NvClothEditorTests");
|
||||
}
|
||||
} // namespace UnitTest
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@ namespace NvCloth
|
||||
const AZStd::vector<SimIndexType>& indices,
|
||||
const AZ::Vector3& fabricGravity,
|
||||
bool useGeodesicTether);
|
||||
template <typename T>
|
||||
void CopyNvRange(const nv::cloth::Range<const T>& nvRange, AZStd::vector<T>& azVector);
|
||||
void CopyCookedData(FabricCookedData::InternalCookedData& azCookedData, const nv::cloth::CookedData& nvCookedData);
|
||||
AZStd::optional<FabricCookedData> Cook(
|
||||
const AZStd::vector<SimParticleFormat>& particles,
|
||||
@@ -123,41 +121,6 @@ namespace UnitTest
|
||||
EXPECT_NE(fabricId1, fabricId2);
|
||||
}
|
||||
|
||||
TEST(NvClothSystem, FactoryCooker_CopyNvRangeEmpty_CopiedDataIsEmpty)
|
||||
{
|
||||
const nv::cloth::Range<const int> nvRange;
|
||||
|
||||
AZStd::vector<int> azVector;
|
||||
NvCloth::Internal::CopyNvRange(nvRange, azVector);
|
||||
|
||||
EXPECT_TRUE(azVector.empty());
|
||||
ExpectEq(azVector, nvRange);
|
||||
}
|
||||
|
||||
TEST(NvClothSystem, FactoryCooker_CopyNvRangeU32Data_CopiedDataMatchesSource)
|
||||
{
|
||||
const AZ::u32 data[] = { 0, 2, 45, 64, 125 };
|
||||
const size_t numDataElements = sizeof(data) / sizeof(data[0]);
|
||||
const nv::cloth::Range<const AZ::u32> nvRange(data, data + numDataElements);
|
||||
|
||||
AZStd::vector<AZ::u32> azVector;
|
||||
NvCloth::Internal::CopyNvRange(nvRange, azVector);
|
||||
|
||||
ExpectEq(azVector, nvRange);
|
||||
}
|
||||
|
||||
TEST(NvClothSystem, FactoryCooker_CopyNvRangeFloatData_CopiedDataMatchesSource)
|
||||
{
|
||||
const float data[] = { 0.0f, 1.5f, -3.4f, 3.1f, 400.0f };
|
||||
const size_t numDataElements = sizeof(data) / sizeof(data[0]);
|
||||
const nv::cloth::Range<const float> nvRange(data, data + numDataElements);
|
||||
|
||||
AZStd::vector<float> azVector;
|
||||
NvCloth::Internal::CopyNvRange(nvRange, azVector);
|
||||
|
||||
ExpectEq(azVector, nvRange);
|
||||
}
|
||||
|
||||
TEST(NvClothSystem, FactoryCooker_CopyInternalCookedDataEmpty_CopiedDataIsEmpty)
|
||||
{
|
||||
nv::cloth::CookedData nvCookedData;
|
||||
|
||||
Reference in New Issue
Block a user