Initial step for connectivity refactor.
Instead of wiring up pointers with prepareNodeEval() and finishNodeEval() use for each connection a single memory block where outputs and inputs point to.
This commit is contained in:
@@ -15,16 +15,9 @@ bool AnimGraph::init(AnimGraphContext& context) {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<AnimGraphConnection>& graph_outputs = m_node_input_connections[0];
|
||||
for (size_t i = 0, n = graph_outputs.size(); i < n; i++) {
|
||||
AnimGraphConnection& connection = graph_outputs[i];
|
||||
if (connection.m_target_socket.m_type == SocketType::SocketTypeAnimation) {
|
||||
AnimData* graph_anim_output =
|
||||
static_cast<AnimData*>(connection.m_target_socket.m_reference.ptr);
|
||||
assert(graph_anim_output != nullptr);
|
||||
graph_anim_output->m_local_matrices.resize(
|
||||
context.m_skeleton->num_soa_joints());
|
||||
}
|
||||
for (size_t i = 0; i < m_animdata_blocks.size(); i++) {
|
||||
int num_soa_joints = context.m_skeleton->num_soa_joints();
|
||||
m_animdata_blocks[i]->m_local_matrices.resize(num_soa_joints);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -37,11 +30,11 @@ void AnimGraph::updateOrderedNodes() {
|
||||
|
||||
void AnimGraph::updateOrderedNodesRecursive(int node_index) {
|
||||
AnimNode* node = m_nodes[node_index];
|
||||
const std::vector<AnimGraphConnection> node_input_connections =
|
||||
const std::vector<AnimGraphConnection>& node_input_connections =
|
||||
m_node_input_connections[node_index];
|
||||
for (size_t i = 0, n = node_input_connections.size(); i < n; i++) {
|
||||
int input_node_index =
|
||||
getAnimNodeIndex(node_input_connections[i].m_source_node);
|
||||
getAnimNodeIndex(node_input_connections.at(i).m_source_node);
|
||||
|
||||
if (input_node_index == 1) {
|
||||
continue;
|
||||
@@ -104,10 +97,7 @@ void AnimGraph::prepareNodeEval(
|
||||
continue;
|
||||
}
|
||||
|
||||
assert (*output_connection.m_source_socket.m_reference.ptr_ptr == nullptr);
|
||||
|
||||
(*output_connection.m_source_socket.m_reference.ptr_ptr) =
|
||||
m_anim_data_allocator.allocate(graph_context.m_skeleton);
|
||||
// TODO: only allocate local matrices for active nodes
|
||||
}
|
||||
|
||||
for (size_t i = 0, n = m_node_input_connections[node_index].size(); i < n;
|
||||
@@ -118,9 +108,6 @@ void AnimGraph::prepareNodeEval(
|
||||
!= SocketType::SocketTypeAnimation) {
|
||||
continue;
|
||||
}
|
||||
|
||||
(*input_connection.m_target_socket.m_reference.ptr_ptr) =
|
||||
(*input_connection.m_source_socket.m_reference.ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,9 +121,7 @@ void AnimGraph::finishNodeEval(size_t node_index) {
|
||||
continue;
|
||||
}
|
||||
|
||||
m_anim_data_allocator.free(static_cast<AnimData*>(
|
||||
*input_connection.m_source_socket.m_reference.ptr_ptr));
|
||||
(*input_connection.m_source_socket.m_reference.ptr_ptr) = nullptr;
|
||||
// TODO: free local matrices for inactive nodes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,20 +147,6 @@ void AnimGraph::evalOutputNode() {
|
||||
for (size_t i = 0, n = m_node_input_connections[0].size(); i < n; i++) {
|
||||
AnimGraphConnection& graph_output_connection =
|
||||
m_node_input_connections[0][i];
|
||||
|
||||
if (graph_output_connection.m_source_socket.m_type
|
||||
!= SocketType::SocketTypeAnimation) {
|
||||
memcpy(
|
||||
graph_output_connection.m_target_socket.m_reference.ptr,
|
||||
graph_output_connection.m_source_socket.m_reference.ptr,
|
||||
graph_output_connection.m_target_socket.m_type_size);
|
||||
} else {
|
||||
AnimData* source_data = static_cast<AnimData*>(
|
||||
*graph_output_connection.m_source_socket.m_reference.ptr_ptr);
|
||||
AnimData* target_data = static_cast<AnimData*>(
|
||||
graph_output_connection.m_target_socket.m_reference.ptr);
|
||||
target_data->m_local_matrices = source_data->m_local_matrices;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user