|
@@ -19,8 +19,7 @@
|
|
|
namespace GraphModelIntegration
|
|
|
{
|
|
|
template<class Type, int ElementCount>
|
|
|
- class VectorDataInterface
|
|
|
- : public GraphCanvas::VectorDataInterface
|
|
|
+ class VectorDataInterface : public GraphCanvas::VectorDataInterface
|
|
|
{
|
|
|
public:
|
|
|
AZ_CLASS_ALLOCATOR(VectorDataInterface, AZ::SystemAllocator, 0);
|
|
@@ -33,23 +32,17 @@ namespace GraphModelIntegration
|
|
|
|
|
|
const char* GetLabel(int index) const override
|
|
|
{
|
|
|
- if (index == 0)
|
|
|
+ switch (index)
|
|
|
{
|
|
|
+ case 0:
|
|
|
return "X";
|
|
|
- }
|
|
|
- else if (index == 1)
|
|
|
- {
|
|
|
+ case 1:
|
|
|
return "Y";
|
|
|
- }
|
|
|
- else if (index == 2)
|
|
|
- {
|
|
|
+ case 2:
|
|
|
return "Z";
|
|
|
- }
|
|
|
- else if (index == 3)
|
|
|
- {
|
|
|
+ case 3:
|
|
|
return "W";
|
|
|
}
|
|
|
-
|
|
|
return "???";
|
|
|
}
|
|
|
AZStd::string GetStyle() const override
|
|
@@ -69,27 +62,30 @@ namespace GraphModelIntegration
|
|
|
{
|
|
|
if (GraphModel::SlotPtr slot = m_slot.lock())
|
|
|
{
|
|
|
- return slot->GetValue<Type>().GetElement(index);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return 0.0;
|
|
|
+ if (index < ElementCount)
|
|
|
+ {
|
|
|
+ return slot->GetValue<Type>().GetElement(index);
|
|
|
+ }
|
|
|
}
|
|
|
+ return 0.0;
|
|
|
}
|
|
|
void SetValue(int index, double value) override
|
|
|
{
|
|
|
if (GraphModel::SlotPtr slot = m_slot.lock())
|
|
|
{
|
|
|
- Type vector = slot->GetValue<Type>();
|
|
|
- if (value != vector.GetElement(index))
|
|
|
+ if (index < ElementCount)
|
|
|
{
|
|
|
- const GraphCanvas::GraphId graphCanvasSceneId = GetDisplay()->GetSceneId();
|
|
|
- GraphCanvas::ScopedGraphUndoBatch undoBatch(graphCanvasSceneId);
|
|
|
+ Type vector = slot->GetValue<Type>();
|
|
|
+ if (value != vector.GetElement(index))
|
|
|
+ {
|
|
|
+ const GraphCanvas::GraphId graphCanvasSceneId = GetDisplay()->GetSceneId();
|
|
|
+ GraphCanvas::ScopedGraphUndoBatch undoBatch(graphCanvasSceneId);
|
|
|
|
|
|
- vector.SetElement(index, aznumeric_cast<float>(value));
|
|
|
- slot->SetValue(vector);
|
|
|
- GraphControllerNotificationBus::Event(
|
|
|
- graphCanvasSceneId, &GraphControllerNotifications::OnGraphModelGraphModified, slot->GetParentNode());
|
|
|
+ vector.SetElement(index, aznumeric_cast<float>(value));
|
|
|
+ slot->SetValue(vector);
|
|
|
+ GraphControllerNotificationBus::Event(
|
|
|
+ graphCanvasSceneId, &GraphControllerNotifications::OnGraphModelGraphModified, slot->GetParentNode());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|