Minor cleanup and added comments.
This commit is contained in:
parent
b4eda31242
commit
283306f225
@ -108,7 +108,7 @@ struct AnimGraphBlendTree : public AnimNode {
|
|||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SetInput(const char* name, T* value_ptr) {
|
void SetInput(const char* name, T* value_ptr) {
|
||||||
m_node_descriptor->SetOutput(name, value_ptr);
|
m_node_descriptor->SetInput(name, value_ptr);
|
||||||
|
|
||||||
std::vector<size_t> connected_node_indices;
|
std::vector<size_t> connected_node_indices;
|
||||||
|
|
||||||
|
@ -933,9 +933,9 @@ void BlendTreeResource::CreateBlendTreeRuntimeNodeInstances(
|
|||||||
embedded_blend_tree_resource->CreateBlendTreeInstance(
|
embedded_blend_tree_resource->CreateBlendTreeInstance(
|
||||||
*embedded_blend_tree);
|
*embedded_blend_tree);
|
||||||
embedded_blend_tree_resource->m_virtual_socket_accessor->m_inputs =
|
embedded_blend_tree_resource->m_virtual_socket_accessor->m_inputs =
|
||||||
embedded_blend_tree->m_node_descriptor->m_outputs;
|
|
||||||
embedded_blend_tree_resource->m_virtual_socket_accessor->m_outputs =
|
|
||||||
embedded_blend_tree->m_node_descriptor->m_inputs;
|
embedded_blend_tree->m_node_descriptor->m_inputs;
|
||||||
|
embedded_blend_tree_resource->m_virtual_socket_accessor->m_outputs =
|
||||||
|
embedded_blend_tree->m_node_descriptor->m_outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
node->m_name = node_resource->m_name;
|
node->m_name = node_resource->m_name;
|
||||||
@ -955,9 +955,9 @@ void BlendTreeResource::PrepareBlendTreeIOData(
|
|||||||
AnimNodeDescriptorFactory("BlendTree", instance.m_nodes[0]);
|
AnimNodeDescriptorFactory("BlendTree", instance.m_nodes[0]);
|
||||||
|
|
||||||
instance.m_node_descriptor->m_outputs =
|
instance.m_node_descriptor->m_outputs =
|
||||||
GetGraphInputNode()->m_virtual_socket_accessor->m_outputs;
|
|
||||||
instance.m_node_descriptor->m_inputs =
|
|
||||||
GetGraphOutputNode()->m_virtual_socket_accessor->m_inputs;
|
GetGraphOutputNode()->m_virtual_socket_accessor->m_inputs;
|
||||||
|
instance.m_node_descriptor->m_inputs =
|
||||||
|
GetGraphInputNode()->m_virtual_socket_accessor->m_outputs;
|
||||||
|
|
||||||
//
|
//
|
||||||
// graph inputs
|
// graph inputs
|
||||||
@ -1004,7 +1004,12 @@ void BlendTreeResource::PrepareBlendTreeIOData(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// connecton data storage
|
// connection data storage: we reserve memory for the used outputs of all
|
||||||
|
// nodes:
|
||||||
|
// * If a node output does not get used: we do not reserve a memory block.
|
||||||
|
// * If a node output gets used by multiple nodes: we only reserve a single
|
||||||
|
// memory block.
|
||||||
|
// The resulting memory offsets are stored in the node_offset_map.
|
||||||
//
|
//
|
||||||
size_t connection_data_storage_size = 0;
|
size_t connection_data_storage_size = 0;
|
||||||
for (const BlendTreeConnectionResource& connection : GetConnections()) {
|
for (const BlendTreeConnectionResource& connection : GetConnections()) {
|
||||||
@ -1028,6 +1033,61 @@ void BlendTreeResource::PrepareBlendTreeIOData(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlendTreeResource::SetRuntimeNodeProperties(
|
||||||
|
AnimGraphBlendTree& result) const {
|
||||||
|
for (int i = 2; i < GetNumNodes(); i++) {
|
||||||
|
const AnimNodeResource* node_resource = GetNode(i);
|
||||||
|
|
||||||
|
NodeDescriptorBase* node_instance_accessor = AnimNodeDescriptorFactory(
|
||||||
|
node_resource->m_node_type_name,
|
||||||
|
result.m_nodes[i]);
|
||||||
|
|
||||||
|
std::vector<Socket>& resource_properties =
|
||||||
|
node_resource->m_virtual_socket_accessor->m_properties;
|
||||||
|
for (const auto& property : resource_properties) {
|
||||||
|
const std::string& name = property.m_name;
|
||||||
|
|
||||||
|
switch (property.m_type) {
|
||||||
|
case SocketType::SocketTypeBool:
|
||||||
|
node_instance_accessor->SetProperty(
|
||||||
|
name.c_str(),
|
||||||
|
property.m_value.flag);
|
||||||
|
break;
|
||||||
|
case SocketType::SocketTypeInt:
|
||||||
|
node_instance_accessor->SetProperty(
|
||||||
|
name.c_str(),
|
||||||
|
property.m_value.int_value);
|
||||||
|
break;
|
||||||
|
case SocketType::SocketTypeFloat:
|
||||||
|
node_instance_accessor->SetProperty(
|
||||||
|
name.c_str(),
|
||||||
|
property.m_value.float_value);
|
||||||
|
break;
|
||||||
|
case SocketType::SocketTypeVec3:
|
||||||
|
node_instance_accessor->SetProperty<Vec3>(
|
||||||
|
name.c_str(),
|
||||||
|
property.m_value.vec3);
|
||||||
|
break;
|
||||||
|
case SocketType::SocketTypeQuat:
|
||||||
|
node_instance_accessor->SetProperty(
|
||||||
|
name.c_str(),
|
||||||
|
property.m_value.quat);
|
||||||
|
break;
|
||||||
|
case SocketType::SocketTypeString:
|
||||||
|
node_instance_accessor->SetProperty(
|
||||||
|
name.c_str(),
|
||||||
|
property.m_value_string);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::cerr << "Invalid socket type "
|
||||||
|
<< static_cast<int>(property.m_type) << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete node_instance_accessor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BlendTreeResource::CreateBlendTreeConnectionInstances(
|
void BlendTreeResource::CreateBlendTreeConnectionInstances(
|
||||||
AnimGraphBlendTree& instance,
|
AnimGraphBlendTree& instance,
|
||||||
NodeSocketDataOffsetMap& node_offset_map) const {
|
NodeSocketDataOffsetMap& node_offset_map) const {
|
||||||
@ -1047,9 +1107,10 @@ void BlendTreeResource::CreateBlendTreeConnectionInstances(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
instance_node_descriptors[0]->m_inputs = instance.m_node_descriptor->m_inputs;
|
instance_node_descriptors[0]->m_inputs =
|
||||||
instance_node_descriptors[1]->m_outputs =
|
|
||||||
instance.m_node_descriptor->m_outputs;
|
instance.m_node_descriptor->m_outputs;
|
||||||
|
instance_node_descriptors[1]->m_outputs =
|
||||||
|
instance.m_node_descriptor->m_inputs;
|
||||||
|
|
||||||
for (const BlendTreeConnectionResource& connection : GetConnections()) {
|
for (const BlendTreeConnectionResource& connection : GetConnections()) {
|
||||||
NodeDescriptorBase* source_node_descriptor =
|
NodeDescriptorBase* source_node_descriptor =
|
||||||
@ -1236,59 +1297,4 @@ void BlendTreeResource::CreateBlendTreeConnectionInstances(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlendTreeResource::SetRuntimeNodeProperties(
|
|
||||||
AnimGraphBlendTree& result) const {
|
|
||||||
for (int i = 2; i < GetNumNodes(); i++) {
|
|
||||||
const AnimNodeResource* node_resource = GetNode(i);
|
|
||||||
|
|
||||||
NodeDescriptorBase* node_instance_accessor = AnimNodeDescriptorFactory(
|
|
||||||
node_resource->m_node_type_name,
|
|
||||||
result.m_nodes[i]);
|
|
||||||
|
|
||||||
std::vector<Socket>& resource_properties =
|
|
||||||
node_resource->m_virtual_socket_accessor->m_properties;
|
|
||||||
for (const auto& property : resource_properties) {
|
|
||||||
const std::string& name = property.m_name;
|
|
||||||
|
|
||||||
switch (property.m_type) {
|
|
||||||
case SocketType::SocketTypeBool:
|
|
||||||
node_instance_accessor->SetProperty(
|
|
||||||
name.c_str(),
|
|
||||||
property.m_value.flag);
|
|
||||||
break;
|
|
||||||
case SocketType::SocketTypeInt:
|
|
||||||
node_instance_accessor->SetProperty(
|
|
||||||
name.c_str(),
|
|
||||||
property.m_value.int_value);
|
|
||||||
break;
|
|
||||||
case SocketType::SocketTypeFloat:
|
|
||||||
node_instance_accessor->SetProperty(
|
|
||||||
name.c_str(),
|
|
||||||
property.m_value.float_value);
|
|
||||||
break;
|
|
||||||
case SocketType::SocketTypeVec3:
|
|
||||||
node_instance_accessor->SetProperty<Vec3>(
|
|
||||||
name.c_str(),
|
|
||||||
property.m_value.vec3);
|
|
||||||
break;
|
|
||||||
case SocketType::SocketTypeQuat:
|
|
||||||
node_instance_accessor->SetProperty(
|
|
||||||
name.c_str(),
|
|
||||||
property.m_value.quat);
|
|
||||||
break;
|
|
||||||
case SocketType::SocketTypeString:
|
|
||||||
node_instance_accessor->SetProperty(
|
|
||||||
name.c_str(),
|
|
||||||
property.m_value_string);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::cerr << "Invalid socket type "
|
|
||||||
<< static_cast<int>(property.m_type) << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete node_instance_accessor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
@ -375,12 +375,12 @@ struct BlendTreeResource : AnimGraphResource {
|
|||||||
AnimGraphBlendTree& instance,
|
AnimGraphBlendTree& instance,
|
||||||
NodeSocketDataOffsetMap& node_offset_map) const;
|
NodeSocketDataOffsetMap& node_offset_map) const;
|
||||||
|
|
||||||
|
void SetRuntimeNodeProperties(AnimGraphBlendTree& result) const;
|
||||||
|
|
||||||
void CreateBlendTreeConnectionInstances(
|
void CreateBlendTreeConnectionInstances(
|
||||||
AnimGraphBlendTree& instance,
|
AnimGraphBlendTree& instance,
|
||||||
NodeSocketDataOffsetMap& node_offset_map) const;
|
NodeSocketDataOffsetMap& node_offset_map) const;
|
||||||
|
|
||||||
void SetRuntimeNodeProperties(AnimGraphBlendTree& result) const;
|
|
||||||
|
|
||||||
void InitGraphConnectors() {
|
void InitGraphConnectors() {
|
||||||
AddNode(AnimNodeResourceFactory("BlendTreeSockets"));
|
AddNode(AnimNodeResourceFactory("BlendTreeSockets"));
|
||||||
AnimNodeResource* output_node = GetGraphOutputNode();
|
AnimNodeResource* output_node = GetGraphOutputNode();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user