SphereColliderComponent.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Source/SphereColliderComponent.h>
  9. #include <AzCore/Component/Entity.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <AzCore/std/smart_ptr/make_shared.h>
  12. #include <Source/Utils.h>
  13. namespace PhysX
  14. {
  15. void SphereColliderComponent::Reflect(AZ::ReflectContext* context)
  16. {
  17. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  18. {
  19. serializeContext->Class<SphereColliderComponent, BaseColliderComponent>()
  20. ->Version(1)
  21. ;
  22. }
  23. }
  24. // BaseColliderComponent
  25. void SphereColliderComponent::UpdateScaleForShapeConfigs()
  26. {
  27. if (m_shapeConfigList.size() != 1)
  28. {
  29. AZ_Error("PhysX Capsule Collider Component", false,
  30. "Expected exactly one collider/shape configuration for entity \"%s\".", GetEntity()->GetName().c_str());
  31. return;
  32. }
  33. m_shapeConfigList[0].second->m_scale = AZ::Vector3(Utils::GetTransformScale(GetEntityId()));
  34. }
  35. }