InstanceData.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 <Vegetation/InstanceData.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. namespace Vegetation
  11. {
  12. void InstanceData::Reflect(AZ::ReflectContext* context)
  13. {
  14. AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
  15. if (serialize)
  16. {
  17. serialize->RegisterGenericType<AZStd::vector<InstanceData>>();
  18. serialize->Class<InstanceData>()
  19. ->Version(1)
  20. ->Field("Id", &InstanceData::m_id)
  21. ->Field("InstanceId", &InstanceData::m_instanceId)
  22. ->Field("Position", &InstanceData::m_position)
  23. ->Field("Normal", &InstanceData::m_normal)
  24. ->Field("Rotation", &InstanceData::m_rotation)
  25. ->Field("Alignment", &InstanceData::m_alignment)
  26. ->Field("Scale", &InstanceData::m_scale)
  27. ->Field("Descriptor", &InstanceData::m_descriptorPtr)
  28. ;
  29. }
  30. if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
  31. {
  32. behaviorContext->Class<InstanceData>()
  33. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
  34. ->Attribute(AZ::Script::Attributes::Category, "Vegetation")
  35. ->Attribute(AZ::Script::Attributes::Module, "vegetation")
  36. ->Constructor()
  37. ->Property("id", BehaviorValueProperty(&InstanceData::m_id))
  38. ->Property("instanceId", BehaviorValueProperty(&InstanceData::m_instanceId))
  39. ->Property("position", BehaviorValueProperty(&InstanceData::m_position))
  40. ->Property("normal", BehaviorValueProperty(&InstanceData::m_normal))
  41. ->Property("rotation", BehaviorValueProperty(&InstanceData::m_rotation))
  42. ->Property("alignment", BehaviorValueProperty(&InstanceData::m_alignment))
  43. ->Property("scale", BehaviorValueProperty(&InstanceData::m_scale))
  44. // Return a bare pointer instead of a smart pointer for easier use from scripting languages.
  45. ->Property("descriptor", [](InstanceData* thisPtr) { return thisPtr->m_descriptorPtr.get(); }, nullptr)
  46. ;
  47. }
  48. }
  49. } // namespace Vegetation