|
15 | 15 |
|
16 | 16 | namespace LmbrCentral
|
17 | 17 | {
|
18 |
| - using SplineComboBoxVec = AZStd::vector<AZ::Edit::EnumConstant<size_t>>; |
| 18 | + using SplineComboBoxVec = AZStd::vector<AZ::Edit::EnumConstant<SplineType>>; |
19 | 19 | static SplineComboBoxVec PopulateSplineTypeList()
|
20 | 20 | {
|
21 | 21 | return SplineComboBoxVec
|
22 | 22 | {
|
23 |
| - { AZ::LinearSpline::RTTI_Type().GetHash(), "Linear" }, |
24 |
| - { AZ::BezierSpline::RTTI_Type().GetHash(), "Bezier" }, |
25 |
| - { AZ::CatmullRomSpline::RTTI_Type().GetHash(), "Catmull-Rom" } |
| 23 | + { SplineType::LINEAR, "Linear" }, |
| 24 | + { SplineType::BEZIER, "Bezier" }, |
| 25 | + { SplineType::CATMULL_ROM, "Catmull-Rom" } |
26 | 26 | };
|
27 | 27 | }
|
28 |
| - |
29 |
| - static AZ::SplinePtr MakeSplinePtr(AZ::u64 splineType) |
| 28 | + static bool IsMatchingType(AZ::SplinePtr spline, SplineType splineType) |
30 | 29 | {
|
31 |
| - if (splineType == AZ::LinearSpline::RTTI_Type().GetHash()) |
| 30 | + auto splineTypeHash = spline->RTTI_GetType().GetHash(); |
| 31 | + switch (splineType) |
32 | 32 | {
|
33 |
| - return AZStd::make_shared<AZ::LinearSpline>(); |
| 33 | + case SplineType::LINEAR: |
| 34 | + { |
| 35 | + return (splineTypeHash == AZ::LinearSpline::RTTI_Type().GetHash()); |
| 36 | + } |
| 37 | + break; |
| 38 | + case SplineType::BEZIER: |
| 39 | + { |
| 40 | + return (splineTypeHash == AZ::BezierSpline::RTTI_Type().GetHash()); |
| 41 | + } |
| 42 | + break; |
| 43 | + case SplineType::CATMULL_ROM: |
| 44 | + { |
| 45 | + return (splineTypeHash == AZ::CatmullRomSpline::RTTI_Type().GetHash()); |
| 46 | + } |
| 47 | + break; |
| 48 | + default: |
| 49 | + break; |
34 | 50 | }
|
35 | 51 |
|
36 |
| - if (splineType == AZ::BezierSpline::RTTI_Type().GetHash()) |
37 |
| - { |
38 |
| - return AZStd::make_shared<AZ::BezierSpline>(); |
39 |
| - } |
| 52 | + return false; |
| 53 | + } |
40 | 54 |
|
41 |
| - if (splineType == AZ::CatmullRomSpline::RTTI_Type().GetHash()) |
| 55 | + static AZ::SplinePtr MakeSplinePtr(SplineType splineType) |
| 56 | + { |
| 57 | + switch (splineType) |
42 | 58 | {
|
43 |
| - return AZStd::make_shared<AZ::CatmullRomSpline>(); |
| 59 | + case SplineType::LINEAR: |
| 60 | + { |
| 61 | + return AZStd::make_shared<AZ::LinearSpline>(); |
| 62 | + } |
| 63 | + break; |
| 64 | + case SplineType::BEZIER: |
| 65 | + { |
| 66 | + return AZStd::make_shared<AZ::BezierSpline>(); |
| 67 | + } |
| 68 | + break; |
| 69 | + case SplineType::CATMULL_ROM: |
| 70 | + { |
| 71 | + return AZStd::make_shared<AZ::CatmullRomSpline>(); |
| 72 | + } |
| 73 | + break; |
| 74 | + default: |
| 75 | + { |
| 76 | + AZ_Assert(false, "Unhandled spline type %d in %s", splineType, __FUNCTION__); |
| 77 | + } |
| 78 | + break; |
44 | 79 | }
|
45 | 80 |
|
46 |
| - AZ_Assert(false, "Unhandled spline type %d in %s", splineType, __FUNCTION__); |
47 |
| - |
48 | 81 | return nullptr;
|
49 | 82 | }
|
50 | 83 |
|
51 |
| - static AZ::SplinePtr CopySplinePtr(AZ::u64 splineType, const AZ::SplinePtr& spline) |
| 84 | + static AZ::SplinePtr CopySplinePtr(SplineType splineType, const AZ::SplinePtr& spline) |
52 | 85 | {
|
53 |
| - if (splineType == AZ::LinearSpline::RTTI_Type().GetHash()) |
54 |
| - { |
55 |
| - return AZStd::make_shared<AZ::LinearSpline>(*spline); |
56 |
| - } |
57 |
| - |
58 |
| - if (splineType == AZ::BezierSpline::RTTI_Type().GetHash()) |
| 86 | + switch (splineType) |
59 | 87 | {
|
60 |
| - return AZStd::make_shared<AZ::BezierSpline>(*spline); |
61 |
| - } |
62 |
| - |
63 |
| - if (splineType == AZ::CatmullRomSpline::RTTI_Type().GetHash()) |
64 |
| - { |
65 |
| - return AZStd::make_shared<AZ::CatmullRomSpline>(*spline); |
| 88 | + case SplineType::LINEAR: |
| 89 | + { |
| 90 | + return AZStd::make_shared<AZ::LinearSpline>(*spline); |
| 91 | + } |
| 92 | + break; |
| 93 | + case SplineType::BEZIER: |
| 94 | + { |
| 95 | + return AZStd::make_shared<AZ::BezierSpline>(*spline); |
| 96 | + } |
| 97 | + break; |
| 98 | + case SplineType::CATMULL_ROM: |
| 99 | + { |
| 100 | + return AZStd::make_shared<AZ::CatmullRomSpline>(*spline); |
| 101 | + } |
| 102 | + break; |
| 103 | + default: |
| 104 | + { |
| 105 | + AZ_Assert(false, "Unhandled spline type %d in %s", splineType, __FUNCTION__); |
| 106 | + } |
| 107 | + break; |
66 | 108 | }
|
67 | 109 |
|
68 |
| - AZ_Assert(false, "Unhandled spline type %d in %s", splineType, __FUNCTION__); |
69 |
| - |
70 | 110 | return nullptr;
|
71 | 111 | }
|
72 | 112 |
|
@@ -101,7 +141,7 @@ namespace LmbrCentral
|
101 | 141 | }
|
102 | 142 | }
|
103 | 143 |
|
104 |
| - void SplineCommon::ChangeSplineType(AZ::u64 splineType) |
| 144 | + void SplineCommon::ChangeSplineType(SplineType splineType) |
105 | 145 | {
|
106 | 146 | m_splineType = splineType;
|
107 | 147 | OnChangeSplineType();
|
@@ -132,7 +172,7 @@ namespace LmbrCentral
|
132 | 172 | {
|
133 | 173 | AZ::u32 ret = AZ::Edit::PropertyRefreshLevels::None;
|
134 | 174 |
|
135 |
| - if (m_spline->RTTI_GetType().GetHash() != m_splineType) |
| 175 | + if (!IsMatchingType(m_spline, m_splineType)) |
136 | 176 | {
|
137 | 177 | m_spline = CopySplinePtr(m_splineType, m_spline);
|
138 | 178 | m_spline->SetCallbacks(
|
@@ -298,7 +338,7 @@ namespace LmbrCentral
|
298 | 338 | return m_splineCommon.m_spline;
|
299 | 339 | }
|
300 | 340 |
|
301 |
| - void SplineComponent::ChangeSplineType(AZ::u64 splineType) |
| 341 | + void SplineComponent::ChangeSplineType(SplineType splineType) |
302 | 342 | {
|
303 | 343 | m_splineCommon.ChangeSplineType(splineType);
|
304 | 344 | }
|
|
0 commit comments