/* * 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 "LmbrCentral_precompiled.h" #if ENABLE_CRY_PHYSICS #include "LmbrCentral.h" #include "LmbrCentralReflectionTest.h" #include "Physics/RigidPhysicsComponent.h" #include using namespace LmbrCentral; // Serialized legacy PhysicsComponent containing RigidPhysicsBehavior. // This should get converted to a RigidPhysicsComponent. const char kLegacyPhysicsComponentWithRigidBehavior[] = R"DELIMITER( )DELIMITER"; class LoadRigidPhysicsComponentFromLegacyData : public LoadReflectedObjectTest { protected: void SetUp() override { LoadReflectedObjectTest::SetUp(); if (m_object) { m_object->GetConfiguration(m_rigidPhysicsConfig); } } const char* GetSourceDataBuffer() const override { return kLegacyPhysicsComponentWithRigidBehavior; } AzFramework::RigidPhysicsConfig m_rigidPhysicsConfig; }; TEST_F(LoadRigidPhysicsComponentFromLegacyData, Application_IsRunning) { ASSERT_NE(GetApplication(), nullptr); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, Component_Loads) { EXPECT_NE(m_object.get(), nullptr); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, ComponentId_MatchesSourceData) { EXPECT_EQ(m_object->GetId(), 753); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, EnabledInitially_MatchesSourceData) { EXPECT_EQ(m_rigidPhysicsConfig.m_enabledInitially, false); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, SpecifyMassOrDensity_MatchesSourceData) { EXPECT_EQ(m_rigidPhysicsConfig.m_specifyMassOrDensity, static_cast(0)); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, Mass_MatchesSourceData) { EXPECT_FLOAT_EQ(m_rigidPhysicsConfig.m_mass, 33.f); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, Density_MatchesSourceData) { EXPECT_FLOAT_EQ(m_rigidPhysicsConfig.m_density, 555.f); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, AtRestInitially_MatchesSourceData) { EXPECT_EQ(m_rigidPhysicsConfig.m_atRestInitially, false); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, InteractsWithTriggers_MatchesSourceData) { EXPECT_EQ(m_rigidPhysicsConfig.m_interactsWithTriggers, false); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, RecordCollision_MatchesSourceData) { EXPECT_EQ(m_rigidPhysicsConfig.m_recordCollisions, true); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, MaxRecordedCollision_MatchesSourceData) { EXPECT_EQ(m_rigidPhysicsConfig.m_maxRecordedCollisions, 3); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, SimulationDamping_MatchesSourceData) { EXPECT_FLOAT_EQ(m_rigidPhysicsConfig.m_simulationDamping, 0.1f); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, SimulationMinEnergy_MatchesSourceData) { EXPECT_FLOAT_EQ(m_rigidPhysicsConfig.m_simulationMinEnergy, 0.003f); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, BuoyancyDamping_MatchesSourceData) { EXPECT_FLOAT_EQ(m_rigidPhysicsConfig.m_buoyancyDamping, 0.3f); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, BuoyancyDensity_MatchesSourceData) { EXPECT_FLOAT_EQ(m_rigidPhysicsConfig.m_buoyancyDensity, 1.3f); } TEST_F(LoadRigidPhysicsComponentFromLegacyData, BuoyancyResistance_MatchesSourceData) { EXPECT_FLOAT_EQ(m_rigidPhysicsConfig.m_buoyancyResistance, 1.6f); } #endif // ENABLE_CRY_PHYSICS