WIP: graph evaluations. Fixed various memory issues, better tests.
This commit is contained in:
@@ -120,6 +120,25 @@ TEST_CASE_METHOD(
|
||||
sampled_translation.z[0] == Approx(translation_key.value.z).margin(0.01));
|
||||
}
|
||||
|
||||
TEST_CASE("AnimDataPlacementNew", "[AnimGraphEval]") {
|
||||
std::cout << "blamp" << std::endl;
|
||||
|
||||
int anim_data_size = sizeof(AnimData);
|
||||
char* buf = new char[anim_data_size];
|
||||
|
||||
AnimData* anim_data_newed = new AnimData;
|
||||
anim_data_newed->m_local_matrices.resize(2);
|
||||
delete anim_data_newed;
|
||||
|
||||
AnimData* anim_data_ptr = new (buf) AnimData;
|
||||
anim_data_ptr->m_local_matrices.resize(4);
|
||||
anim_data_ptr->m_local_matrices.resize(0);
|
||||
anim_data_ptr->m_local_matrices.vector::~vector();
|
||||
|
||||
delete[] buf;
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(
|
||||
SimpleAnimFixture,
|
||||
"AnimGraphSimpleEval",
|
||||
|
||||
@@ -129,40 +129,44 @@ TEST_CASE("BasicGraph", "[AnimGraphResource]") {
|
||||
REQUIRE(anim_sampler_run->m_animation != nullptr);
|
||||
|
||||
WHEN("Emulating Graph Evaluation") {
|
||||
CHECK(graph.m_anim_data_work_buffer.size() == 0);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 0);
|
||||
graph.prepareNodeEval(graph_context, walk_node_index);
|
||||
graph.finishNodeEval(walk_node_index);
|
||||
CHECK(graph.m_anim_data_work_buffer.m_num_allocations == 1);
|
||||
CHECK(graph.m_anim_data_work_buffer.size() == 0);
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 1);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 0);
|
||||
|
||||
graph.prepareNodeEval(graph_context, run_node_index);
|
||||
graph.finishNodeEval(run_node_index);
|
||||
CHECK(graph.m_anim_data_work_buffer.m_num_allocations == 2);
|
||||
CHECK(graph.m_anim_data_work_buffer.size() == 0);
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 2);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 0);
|
||||
|
||||
graph.prepareNodeEval(graph_context, blend_node_index);
|
||||
CHECK(blend2_instance->i_input0 == anim_sampler_walk->o_output);
|
||||
CHECK(blend2_instance->i_input1 == anim_sampler_run->o_output);
|
||||
CHECK(graph.m_anim_data_work_buffer.m_num_allocations == 3);
|
||||
CHECK(graph.m_anim_data_work_buffer.size() == 0);
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 3);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 0);
|
||||
|
||||
graph.finishNodeEval(blend_node_index);
|
||||
CHECK(anim_sampler_walk->o_output == nullptr);
|
||||
CHECK(anim_sampler_run->o_output == nullptr);
|
||||
CHECK(graph.m_anim_data_work_buffer.m_num_allocations == 3);
|
||||
CHECK(graph.m_anim_data_work_buffer.size() == 2);
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 3);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 2);
|
||||
|
||||
// TODO: rethink output node evaluation
|
||||
graph.prepareNodeEval(graph_context, 0);
|
||||
const Socket* graph_output_socket = graph.getOutputSocket("GraphOutput");
|
||||
CHECK(blend2_instance->o_output == (*graph_output_socket->m_reference.ptr_ptr));
|
||||
AnimData* graph_output =
|
||||
static_cast<AnimData*>(*graph_output_socket->m_reference.ptr_ptr);
|
||||
// Evaluate output node.
|
||||
graph.evalOutputNode();
|
||||
graph.finishNodeEval(0);
|
||||
|
||||
|
||||
const Socket* graph_output_socket = graph.getOutputSocket("GraphOutput");
|
||||
AnimData* graph_output =
|
||||
static_cast<AnimData*>(graph_output_socket->m_reference.ptr);
|
||||
|
||||
CHECK(graph_output->m_local_matrices.size() == graph_context.m_skeleton->num_soa_joints());
|
||||
|
||||
CHECK(graph.m_anim_data_allocator.m_num_allocations == 3);
|
||||
CHECK(graph.m_anim_data_allocator.size() == 3);
|
||||
|
||||
CHECK(blend2_instance->o_output == nullptr);
|
||||
CHECK(graph_output == (*graph_output_socket->m_reference.ptr_ptr));
|
||||
CHECK(graph.m_anim_data_work_buffer.m_num_allocations == 3);
|
||||
CHECK(graph.m_anim_data_work_buffer.size() == 3);
|
||||
}
|
||||
|
||||
graph_context.freeAnimations();
|
||||
|
||||
Reference in New Issue
Block a user