AnimTestbed/tests/NodeDescriptorTests.cc
2025-03-19 21:43:01 +01:00

56 lines
1.8 KiB
C++

//
// Created by martin on 04.02.22.
//
#include "AnimGraph/AnimGraphData.h"
#include "AnimGraph/AnimGraphNodes.h"
#include "catch.hpp"
TEST_CASE("Descriptor Access", "[NodeDescriptorTests]") {
Blend2Node blend2Node;
NodeDescriptor<Blend2Node> blend2Descriptor(&blend2Node);
CHECK(blend2Descriptor.m_inputs.size() == 3);
CHECK(
*blend2Descriptor.m_inputs[0].m_reference.ptr_ptr == blend2Node.i_input0);
CHECK(
*blend2Descriptor.m_inputs[1].m_reference.ptr_ptr == blend2Node.i_input1);
CHECK(
*blend2Descriptor.m_inputs[2].m_reference.ptr_ptr
== blend2Node.i_blend_weight);
CHECK(blend2Descriptor.m_inputs[0].m_type_size == sizeof(Pose));
CHECK(blend2Descriptor.m_inputs[2].m_type_size == 4);
CHECK(blend2Descriptor.m_outputs.size() == 1);
CHECK(
*blend2Descriptor.m_outputs[0].m_reference.ptr_ptr
== blend2Node.o_output);
CHECK(blend2Descriptor.m_properties.size() == 1);
CHECK(
blend2Descriptor.m_properties[0].m_reference.ptr
== &blend2Node.m_sync_blend);
// Check we can properly update inputs
CHECK(blend2Node.i_input0 == nullptr);
Pose pose;
blend2Descriptor.SetInput("Input0", &pose);
CHECK(blend2Node.i_input0 == &pose);
// Check we properly can set properties
CHECK(blend2Node.m_sync_blend == false);
CHECK(blend2Descriptor.GetProperty<bool>("Sync") == false);
blend2Descriptor.SetProperty<bool>("Sync", true);
CHECK(blend2Node.m_sync_blend == true);
CHECK(blend2Descriptor.GetProperty<bool>("Sync") == true);
// Check that flags are properly set.
CHECK(blend2Node.m_sync_blend == true);
blend2Descriptor.UpdateFlags();
Socket* weight_input_socket = blend2Descriptor.GetInputSocket("Weight");
CHECK(weight_input_socket != nullptr);
CHECK(
weight_input_socket->m_flags
& SocketFlagAffectsTime == SocketFlagAffectsTime);
}