Fixed various clang-tidy messages.
parent
c659909020
commit
c809fe0c8c
|
@ -44,7 +44,7 @@ AnimSamplerNode::~AnimSamplerNode() noexcept {
|
||||||
|
|
||||||
bool AnimSamplerNode::Init(AnimGraphContext& context) {
|
bool AnimSamplerNode::Init(AnimGraphContext& context) {
|
||||||
assert (m_animation == nullptr);
|
assert (m_animation == nullptr);
|
||||||
assert(m_filename.size() != 0);
|
assert(!m_filename.empty());
|
||||||
|
|
||||||
AnimGraphContext::AnimationFileMap::const_iterator animation_map_iter;
|
AnimGraphContext::AnimationFileMap::const_iterator animation_map_iter;
|
||||||
animation_map_iter = context.m_animation_map.find(m_filename);
|
animation_map_iter = context.m_animation_map.find(m_filename);
|
||||||
|
|
|
@ -13,13 +13,6 @@
|
||||||
|
|
||||||
struct AnimNode;
|
struct AnimNode;
|
||||||
|
|
||||||
struct NodeInput {
|
|
||||||
AnimNode* m_node;
|
|
||||||
SocketType m_type = SocketType::SocketTypeUndefined;
|
|
||||||
Socket* m_node_output_socket;
|
|
||||||
std::string m_input_name;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class AnimNodeEvalState {
|
enum class AnimNodeEvalState {
|
||||||
Undefined,
|
Undefined,
|
||||||
Deactivated,
|
Deactivated,
|
||||||
|
@ -45,13 +38,13 @@ struct AnimNode {
|
||||||
AnimNodeEvalState m_state = AnimNodeEvalState::Undefined;
|
AnimNodeEvalState m_state = AnimNodeEvalState::Undefined;
|
||||||
SyncTrack m_sync_track;
|
SyncTrack m_sync_track;
|
||||||
|
|
||||||
virtual ~AnimNode(){};
|
virtual ~AnimNode() = default;
|
||||||
|
|
||||||
virtual bool Init(AnimGraphContext& context) { return true; };
|
virtual bool Init(AnimGraphContext& context) { return true; };
|
||||||
|
|
||||||
virtual void MarkActiveInputs(const std::vector<AnimGraphConnection>& inputs) {
|
virtual void MarkActiveInputs(const std::vector<AnimGraphConnection>& inputs) {
|
||||||
for (size_t i = 0, n = inputs.size(); i < n; i++) {
|
for (const auto & input : inputs) {
|
||||||
AnimNode* input_node = inputs[i].m_source_node;
|
AnimNode* input_node = input.m_source_node;
|
||||||
if (input_node != nullptr) {
|
if (input_node != nullptr) {
|
||||||
input_node->m_state = AnimNodeEvalState::Activated;
|
input_node->m_state = AnimNodeEvalState::Activated;
|
||||||
}
|
}
|
||||||
|
@ -59,10 +52,10 @@ struct AnimNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void CalcSyncTrack(const std::vector<AnimGraphConnection>& inputs) {
|
virtual void CalcSyncTrack(const std::vector<AnimGraphConnection>& inputs) {
|
||||||
for (size_t i = 0, n = inputs.size(); i < n; i++) {
|
for (const auto & input : inputs) {
|
||||||
AnimNode* input_node = inputs[i].m_source_node;
|
AnimNode* input_node = input.m_source_node;
|
||||||
if (input_node != nullptr
|
if (input_node != nullptr
|
||||||
&& inputs[i].m_source_socket.m_type == SocketType::SocketTypeAnimation
|
&& input.m_source_socket.m_type == SocketType::SocketTypeAnimation
|
||||||
&& input_node->m_state != AnimNodeEvalState::Deactivated) {
|
&& input_node->m_state != AnimNodeEvalState::Deactivated) {
|
||||||
m_sync_track = input_node->m_sync_track;
|
m_sync_track = input_node->m_sync_track;
|
||||||
return;
|
return;
|
||||||
|
@ -101,18 +94,18 @@ struct Blend2Node : public AnimNode {
|
||||||
bool m_sync_blend = false;
|
bool m_sync_blend = false;
|
||||||
|
|
||||||
virtual void MarkActiveInputs(const std::vector<AnimGraphConnection>& inputs) override {
|
virtual void MarkActiveInputs(const std::vector<AnimGraphConnection>& inputs) override {
|
||||||
for (size_t i = 0, n = inputs.size(); i < n; i++) {
|
for (const auto & input : inputs) {
|
||||||
AnimNode* input_node = inputs[i].m_source_node;
|
AnimNode* input_node = input.m_source_node;
|
||||||
if (input_node == nullptr) {
|
if (input_node == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputs[i].m_target_socket.m_name == "Input0" && *i_blend_weight < 0.999) {
|
if (input.m_target_socket.m_name == "Input0" && *i_blend_weight < 0.999) {
|
||||||
input_node->m_state = AnimNodeEvalState::Activated;
|
input_node->m_state = AnimNodeEvalState::Activated;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputs[i].m_target_socket.m_name == "Input1" && *i_blend_weight > 0.001) {
|
if (input.m_target_socket.m_name == "Input1" && *i_blend_weight > 0.001) {
|
||||||
input_node->m_state = AnimNodeEvalState::Activated;
|
input_node->m_state = AnimNodeEvalState::Activated;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +131,7 @@ struct NodeDescriptor<Blend2Node> : public NodeDescriptorBase {
|
||||||
Socket* weight_input_socket = FindSocket("Weight", m_inputs);
|
Socket* weight_input_socket = FindSocket("Weight", m_inputs);
|
||||||
assert(weight_input_socket != nullptr);
|
assert(weight_input_socket != nullptr);
|
||||||
|
|
||||||
if (GetProperty<bool>("Sync") == true) {
|
if (GetProperty<bool>("Sync")) {
|
||||||
weight_input_socket->m_flags = SocketFlags::SocketFlagAffectsTime;
|
weight_input_socket->m_flags = SocketFlags::SocketFlagAffectsTime;
|
||||||
} else {
|
} else {
|
||||||
weight_input_socket->m_flags = SocketFlags::SocketFlagNone;
|
weight_input_socket->m_flags = SocketFlags::SocketFlagNone;
|
||||||
|
@ -217,10 +210,10 @@ struct NodeDescriptor<AnimSamplerNode> : public NodeDescriptorBase {
|
||||||
struct LockTranslationNode : public AnimNode {
|
struct LockTranslationNode : public AnimNode {
|
||||||
AnimData* i_input = nullptr;
|
AnimData* i_input = nullptr;
|
||||||
AnimData* o_output = nullptr;
|
AnimData* o_output = nullptr;
|
||||||
int m_locked_bone_index;
|
int m_locked_bone_index = 0;
|
||||||
bool m_lock_x;
|
bool m_lock_x = false;
|
||||||
bool m_lock_y;
|
bool m_lock_y = false;
|
||||||
bool m_lock_z;
|
bool m_lock_z = false;
|
||||||
|
|
||||||
virtual void Evaluate(AnimGraphContext& context) override;
|
virtual void Evaluate(AnimGraphContext& context) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@ json sSocketToJson(const Socket& socket) {
|
||||||
result["type"] = sSocketTypeToStr(socket.m_type);
|
result["type"] = sSocketTypeToStr(socket.m_type);
|
||||||
|
|
||||||
if (socket.m_type == SocketType::SocketTypeString
|
if (socket.m_type == SocketType::SocketTypeString
|
||||||
&& socket.m_value_string.size() > 0) {
|
&& !socket.m_value_string.empty()) {
|
||||||
result["value"] = socket.m_value_string;
|
result["value"] = socket.m_value_string;
|
||||||
} else if (socket.m_value.flag) {
|
} else if (socket.m_value.flag) {
|
||||||
if (socket.m_type == SocketType::SocketTypeBool) {
|
if (socket.m_type == SocketType::SocketTypeBool) {
|
||||||
|
@ -123,7 +123,7 @@ Socket sJsonToSocket(const json& json_data) {
|
||||||
//
|
//
|
||||||
json sAnimGraphNodeToJson(
|
json sAnimGraphNodeToJson(
|
||||||
const AnimNodeResource& node,
|
const AnimNodeResource& node,
|
||||||
int node_index,
|
size_t node_index,
|
||||||
const std::vector<AnimGraphConnectionResource>& connections) {
|
const std::vector<AnimGraphConnectionResource>& connections) {
|
||||||
json result;
|
json result;
|
||||||
|
|
||||||
|
@ -135,17 +135,15 @@ json sAnimGraphNodeToJson(
|
||||||
result["position"][j] = node.m_position[j];
|
result["position"][j] = node.m_position[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t j = 0, n = node.m_socket_accessor->m_inputs.size(); j < n; j++) {
|
for (const auto & socket : node.m_socket_accessor->m_inputs) {
|
||||||
const Socket& socket = node.m_socket_accessor->m_inputs[j];
|
|
||||||
|
|
||||||
if (socket.m_type == SocketType::SocketTypeAnimation) {
|
if (socket.m_type == SocketType::SocketTypeAnimation) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool socket_connected = false;
|
bool socket_connected = false;
|
||||||
for (size_t k = 0, m = connections.size(); k < m; k++) {
|
for (const auto & connection : connections) {
|
||||||
if (connections[k].source_node_index == node_index
|
if (connection.source_node_index == node_index
|
||||||
&& connections[k].source_socket_name == socket.m_name) {
|
&& connection.source_socket_name == socket.m_name) {
|
||||||
socket_connected = true;
|
socket_connected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -156,16 +154,14 @@ json sAnimGraphNodeToJson(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t j = 0, n = node.m_socket_accessor->m_properties.size(); j < n;
|
for (auto & property : node.m_socket_accessor->m_properties) {
|
||||||
j++) {
|
|
||||||
Socket& property = node.m_socket_accessor->m_properties[j];
|
|
||||||
result["properties"][property.m_name] = sSocketToJson(property);
|
result["properties"][property.m_name] = sSocketToJson(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimNodeResource sAnimGraphNodeFromJson(const json& json_node, int node_index) {
|
AnimNodeResource sAnimGraphNodeFromJson(const json& json_node, size_t node_index) {
|
||||||
AnimNodeResource result;
|
AnimNodeResource result;
|
||||||
|
|
||||||
result.m_name = json_node["name"];
|
result.m_name = json_node["name"];
|
||||||
|
@ -177,9 +173,7 @@ AnimNodeResource sAnimGraphNodeFromJson(const json& json_node, int node_index) {
|
||||||
result.m_socket_accessor =
|
result.m_socket_accessor =
|
||||||
AnimNodeDescriptorFactory(result.m_type_name, result.m_anim_node);
|
AnimNodeDescriptorFactory(result.m_type_name, result.m_anim_node);
|
||||||
|
|
||||||
for (size_t j = 0, n = result.m_socket_accessor->m_properties.size(); j < n;
|
for (auto & property : result.m_socket_accessor->m_properties) {
|
||||||
j++) {
|
|
||||||
Socket& property = result.m_socket_accessor->m_properties[j];
|
|
||||||
property = sJsonToSocket(json_node["properties"][property.m_name]);
|
property = sJsonToSocket(json_node["properties"][property.m_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +199,6 @@ AnimNodeResource sAnimGraphNodeFromJson(const json& json_node, int node_index) {
|
||||||
// AnimGraphConnectionResource <-> Json
|
// AnimGraphConnectionResource <-> Json
|
||||||
//
|
//
|
||||||
json sAnimGraphConnectionToJson(
|
json sAnimGraphConnectionToJson(
|
||||||
const AnimGraphResource& graph_resource,
|
|
||||||
const AnimGraphConnectionResource& connection) {
|
const AnimGraphConnectionResource& connection) {
|
||||||
json result;
|
json result;
|
||||||
|
|
||||||
|
@ -221,7 +214,6 @@ json sAnimGraphConnectionToJson(
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimGraphConnectionResource sAnimGraphConnectionFromJson(
|
AnimGraphConnectionResource sAnimGraphConnectionFromJson(
|
||||||
const AnimGraphResource& graph_resource,
|
|
||||||
const json& json_node) {
|
const json& json_node) {
|
||||||
AnimGraphConnectionResource connection;
|
AnimGraphConnectionResource connection;
|
||||||
|
|
||||||
|
@ -244,11 +236,11 @@ void AnimGraphResource::clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimGraphResource::clearNodes() {
|
void AnimGraphResource::clearNodes() {
|
||||||
for (size_t i = 0; i < m_nodes.size(); i++) {
|
for (auto & m_node : m_nodes) {
|
||||||
delete m_nodes[i].m_socket_accessor;
|
delete m_node.m_socket_accessor;
|
||||||
m_nodes[i].m_socket_accessor = nullptr;
|
m_node.m_socket_accessor = nullptr;
|
||||||
delete m_nodes[i].m_anim_node;
|
delete m_node.m_anim_node;
|
||||||
m_nodes[i].m_anim_node = nullptr;
|
m_node.m_anim_node = nullptr;
|
||||||
}
|
}
|
||||||
m_nodes.clear();
|
m_nodes.clear();
|
||||||
}
|
}
|
||||||
|
@ -273,7 +265,7 @@ bool AnimGraphResource::saveToFile(const char* filename) const {
|
||||||
|
|
||||||
for (size_t i = 0; i < m_connections.size(); i++) {
|
for (size_t i = 0; i < m_connections.size(); i++) {
|
||||||
const AnimGraphConnectionResource& connection = m_connections[i];
|
const AnimGraphConnectionResource& connection = m_connections[i];
|
||||||
result["connections"][i] = sAnimGraphConnectionToJson(*this, connection);
|
result["connections"][i] = sAnimGraphConnectionToJson(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Graph inputs and outputs
|
// Graph inputs and outputs
|
||||||
|
@ -340,22 +332,21 @@ bool AnimGraphResource::loadFromFile(const char* filename) {
|
||||||
|
|
||||||
// Setup graph inputs and outputs
|
// Setup graph inputs and outputs
|
||||||
const json& graph_outputs = json_data["nodes"][0]["inputs"];
|
const json& graph_outputs = json_data["nodes"][0]["inputs"];
|
||||||
for (size_t i = 0, n = graph_outputs.size(); i < n; i++) {
|
for (const auto & graph_output : graph_outputs) {
|
||||||
AnimNodeResource& graph_node = m_nodes[0];
|
AnimNodeResource& graph_node = m_nodes[0];
|
||||||
graph_node.m_socket_accessor->m_inputs.push_back(
|
graph_node.m_socket_accessor->m_inputs.push_back(
|
||||||
sJsonToSocket(graph_outputs[i]));
|
sJsonToSocket(graph_output));
|
||||||
}
|
}
|
||||||
|
|
||||||
const json& graph_inputs = json_data["nodes"][1]["outputs"];
|
const json& graph_inputs = json_data["nodes"][1]["outputs"];
|
||||||
for (size_t i = 0, n = graph_inputs.size(); i < n; i++) {
|
for (const auto & graph_input : graph_inputs) {
|
||||||
AnimNodeResource& graph_node = m_nodes[1];
|
AnimNodeResource& graph_node = m_nodes[1];
|
||||||
graph_node.m_socket_accessor->m_outputs.push_back(
|
graph_node.m_socket_accessor->m_outputs.push_back(
|
||||||
sJsonToSocket(graph_inputs[i]));
|
sJsonToSocket(graph_input));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load connections
|
// Load connections
|
||||||
for (size_t i = 0; i < json_data["connections"].size(); i++) {
|
for (const auto & json_connection : json_data["connections"]) {
|
||||||
const json& json_connection = json_data["connections"][i];
|
|
||||||
if (json_connection["type"] != "AnimGraphConnectionResource") {
|
if (json_connection["type"] != "AnimGraphConnectionResource") {
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "Invalid json object. Expected type 'AnimGraphConnectionResource' "
|
<< "Invalid json object. Expected type 'AnimGraphConnectionResource' "
|
||||||
|
@ -365,7 +356,7 @@ bool AnimGraphResource::loadFromFile(const char* filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimGraphConnectionResource connection =
|
AnimGraphConnectionResource connection =
|
||||||
sAnimGraphConnectionFromJson(*this, json_connection);
|
sAnimGraphConnectionFromJson(json_connection);
|
||||||
m_connections.push_back(connection);
|
m_connections.push_back(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,17 +375,16 @@ void AnimGraphResource::createInstance(AnimGraph& result) const {
|
||||||
void AnimGraphResource::createRuntimeNodeInstances(AnimGraph& instance) const {
|
void AnimGraphResource::createRuntimeNodeInstances(AnimGraph& instance) const {
|
||||||
for (int i = 0; i < m_nodes.size(); i++) {
|
for (int i = 0; i < m_nodes.size(); i++) {
|
||||||
const AnimNodeResource& node_resource = m_nodes[i];
|
const AnimNodeResource& node_resource = m_nodes[i];
|
||||||
AnimNode* node = AnimNodeFactory(node_resource.m_type_name.c_str());
|
AnimNode* node = AnimNodeFactory(node_resource.m_type_name);
|
||||||
node->m_name = node_resource.m_name;
|
node->m_name = node_resource.m_name;
|
||||||
node->m_node_type_name = node_resource.m_type_name;
|
node->m_node_type_name = node_resource.m_type_name;
|
||||||
node->m_index = i;
|
node->m_index = i;
|
||||||
instance.m_nodes.push_back(node);
|
instance.m_nodes.push_back(node);
|
||||||
|
|
||||||
// runtime node connections
|
// runtime node connections
|
||||||
instance.m_node_input_connections.push_back(
|
instance.m_node_input_connections.emplace_back();
|
||||||
std::vector<AnimGraphConnection>());
|
instance.m_node_output_connections.emplace_back();
|
||||||
instance.m_node_output_connections.push_back(
|
|
||||||
std::vector<AnimGraphConnection>());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,9 +441,8 @@ void AnimGraphResource::prepareGraphIOData(AnimGraph& instance) const {
|
||||||
|
|
||||||
// connections: make source and target sockets point to the same address in the connection data storage.
|
// connections: make source and target sockets point to the same address in the connection data storage.
|
||||||
// TODO: instead of every connection, only create data blocks for the source sockets and make sure every source socket gets allocated once.
|
// TODO: instead of every connection, only create data blocks for the source sockets and make sure every source socket gets allocated once.
|
||||||
int connection_data_storage_size = 0;
|
size_t connection_data_storage_size = 0;
|
||||||
for (int i = 0; i < m_connections.size(); i++) {
|
for (const auto & connection : m_connections) {
|
||||||
const AnimGraphConnectionResource& connection = m_connections[i];
|
|
||||||
const AnimNodeResource& source_node = m_nodes[connection.source_node_index];
|
const AnimNodeResource& source_node = m_nodes[connection.source_node_index];
|
||||||
Socket* source_socket = source_node.m_socket_accessor->GetOutputSocket(
|
Socket* source_socket = source_node.m_socket_accessor->GetOutputSocket(
|
||||||
connection.source_socket_name.c_str());
|
connection.source_socket_name.c_str());
|
||||||
|
@ -470,7 +459,7 @@ void AnimGraphResource::prepareGraphIOData(AnimGraph& instance) const {
|
||||||
nullptr);
|
nullptr);
|
||||||
for (int i = 0; i < m_nodes.size(); i++) {
|
for (int i = 0; i < m_nodes.size(); i++) {
|
||||||
instance_node_descriptors[i] = AnimNodeDescriptorFactory(
|
instance_node_descriptors[i] = AnimNodeDescriptorFactory(
|
||||||
m_nodes[i].m_type_name.c_str(),
|
m_nodes[i].m_type_name,
|
||||||
instance.m_nodes[i]);
|
instance.m_nodes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,10 +467,8 @@ void AnimGraphResource::prepareGraphIOData(AnimGraph& instance) const {
|
||||||
instance_node_descriptors[1]->m_outputs =
|
instance_node_descriptors[1]->m_outputs =
|
||||||
instance.m_node_descriptor->m_outputs;
|
instance.m_node_descriptor->m_outputs;
|
||||||
|
|
||||||
int connection_data_offset = 0;
|
size_t connection_data_offset = 0;
|
||||||
for (int i = 0; i < m_connections.size(); i++) {
|
for (const auto & connection : m_connections) {
|
||||||
const AnimGraphConnectionResource& connection = m_connections[i];
|
|
||||||
|
|
||||||
NodeDescriptorBase* source_node_descriptor =
|
NodeDescriptorBase* source_node_descriptor =
|
||||||
instance_node_descriptors[connection.source_node_index];
|
instance_node_descriptors[connection.source_node_index];
|
||||||
NodeDescriptorBase* target_node_descriptor =
|
NodeDescriptorBase* target_node_descriptor =
|
||||||
|
@ -526,16 +513,16 @@ void AnimGraphResource::prepareGraphIOData(AnimGraph& instance) const {
|
||||||
// const node inputs
|
// const node inputs
|
||||||
//
|
//
|
||||||
std::vector<Socket*> const_inputs =
|
std::vector<Socket*> const_inputs =
|
||||||
getConstNodeInputs(instance, instance_node_descriptors);
|
getConstNodeInputs( instance_node_descriptors);
|
||||||
int const_node_inputs_buffer_size = 0;
|
size_t const_node_inputs_buffer_size = 0;
|
||||||
for (int i = 0, n = const_inputs.size(); i < n; i++) {
|
for (auto & const_input : const_inputs) {
|
||||||
if (const_inputs[i]->m_type == SocketType::SocketTypeString) {
|
if (const_input->m_type == SocketType::SocketTypeString) {
|
||||||
// TODO: implement string const node input support
|
// TODO: implement string const node input support
|
||||||
std::cerr << "Error: const inputs for strings not yet implemented!"
|
std::cerr << "Error: const inputs for strings not yet implemented!"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
const_node_inputs_buffer_size += const_inputs[i]->m_type_size;
|
const_node_inputs_buffer_size += const_input->m_type_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const_node_inputs_buffer_size > 0) {
|
if (const_node_inputs_buffer_size > 0) {
|
||||||
|
@ -543,18 +530,18 @@ void AnimGraphResource::prepareGraphIOData(AnimGraph& instance) const {
|
||||||
memset(instance.m_const_node_inputs, '\0', const_node_inputs_buffer_size);
|
memset(instance.m_const_node_inputs, '\0', const_node_inputs_buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int const_input_buffer_offset = 0;
|
size_t const_input_buffer_offset = 0;
|
||||||
for (int i = 0, n = const_inputs.size(); i < n; i++) {
|
for (auto & i : const_inputs) {
|
||||||
Socket* const_input = const_inputs[i];
|
Socket* const_input = i;
|
||||||
|
|
||||||
// TODO: implement string const node input support
|
// TODO: implement string const node input support
|
||||||
assert(const_input->m_type != SocketType::SocketTypeString);
|
assert(const_input->m_type != SocketType::SocketTypeString);
|
||||||
|
|
||||||
*const_input->m_reference.ptr_ptr =
|
*const_input->m_reference.ptr_ptr =
|
||||||
&instance.m_const_node_inputs[const_input_buffer_offset];
|
&instance.m_const_node_inputs[const_input_buffer_offset];
|
||||||
memcpy (*const_input->m_reference.ptr_ptr, &const_input->m_value, const_inputs[i]->m_type_size);
|
memcpy (*const_input->m_reference.ptr_ptr, &const_input->m_value, i->m_type_size);
|
||||||
|
|
||||||
const_input_buffer_offset += const_inputs[i]->m_type_size;
|
const_input_buffer_offset += i->m_type_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_nodes.size(); i++) {
|
for (int i = 0; i < m_nodes.size(); i++) {
|
||||||
|
@ -572,8 +559,7 @@ void AnimGraphResource::setRuntimeNodeProperties(AnimGraph& instance) const {
|
||||||
|
|
||||||
std::vector<Socket>& resource_properties =
|
std::vector<Socket>& resource_properties =
|
||||||
node_resource.m_socket_accessor->m_properties;
|
node_resource.m_socket_accessor->m_properties;
|
||||||
for (size_t j = 0, n = resource_properties.size(); j < n; j++) {
|
for (const auto & property : resource_properties) {
|
||||||
const Socket& property = resource_properties[j];
|
|
||||||
const std::string& name = property.m_name;
|
const std::string& name = property.m_name;
|
||||||
|
|
||||||
switch (property.m_type) {
|
switch (property.m_type) {
|
||||||
|
@ -618,12 +604,11 @@ void AnimGraphResource::setRuntimeNodeProperties(AnimGraph& instance) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Socket*> AnimGraphResource::getConstNodeInputs(
|
std::vector<Socket*> AnimGraphResource::getConstNodeInputs(
|
||||||
AnimGraph& instance,
|
|
||||||
std::vector<NodeDescriptorBase*>& instance_node_descriptors) const {
|
std::vector<NodeDescriptorBase*>& instance_node_descriptors) const {
|
||||||
std::vector<Socket*> result;
|
std::vector<Socket*> result;
|
||||||
|
|
||||||
for (int i = 0; i < m_nodes.size(); i++) {
|
for (size_t i = 0; i < m_nodes.size(); i++) {
|
||||||
for (int j = 0, num_inputs = instance_node_descriptors[i]->m_inputs.size();
|
for (size_t j = 0, num_inputs = instance_node_descriptors[i]->m_inputs.size();
|
||||||
j < num_inputs;
|
j < num_inputs;
|
||||||
j++) {
|
j++) {
|
||||||
Socket& input = instance_node_descriptors[i]->m_inputs[j];
|
Socket& input = instance_node_descriptors[i]->m_inputs[j];
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "SyncTrack.h"
|
#include "SyncTrack.h"
|
||||||
|
|
||||||
struct AnimNode;
|
struct AnimNode;
|
||||||
struct NodeSocketAccessorBase;
|
|
||||||
|
|
||||||
struct AnimNodeResource {
|
struct AnimNodeResource {
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
|
@ -34,7 +33,7 @@ static inline AnimNodeResource AnimNodeResourceFactory(
|
||||||
result.m_type_name = node_type_name;
|
result.m_type_name = node_type_name;
|
||||||
result.m_anim_node = AnimNodeFactory(node_type_name);
|
result.m_anim_node = AnimNodeFactory(node_type_name);
|
||||||
result.m_socket_accessor =
|
result.m_socket_accessor =
|
||||||
AnimNodeDescriptorFactory(node_type_name.c_str(), result.m_anim_node);
|
AnimNodeDescriptorFactory(node_type_name, result.m_anim_node);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,9 +42,9 @@ static inline AnimNodeResource AnimNodeResourceFactory(
|
||||||
//
|
//
|
||||||
struct AnimGraphConnectionResource {
|
struct AnimGraphConnectionResource {
|
||||||
size_t source_node_index = -1;
|
size_t source_node_index = -1;
|
||||||
std::string source_socket_name = "";
|
std::string source_socket_name;
|
||||||
size_t target_node_index = -1;
|
size_t target_node_index = -1;
|
||||||
std::string target_socket_name = "";
|
std::string target_socket_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AnimGraphResource {
|
struct AnimGraphResource {
|
||||||
|
@ -54,9 +53,9 @@ struct AnimGraphResource {
|
||||||
std::vector<AnimGraphConnectionResource> m_connections;
|
std::vector<AnimGraphConnectionResource> m_connections;
|
||||||
|
|
||||||
~AnimGraphResource() {
|
~AnimGraphResource() {
|
||||||
for (size_t i = 0, n = m_nodes.size(); i < n; i++) {
|
for (auto & m_node : m_nodes) {
|
||||||
delete m_nodes[i].m_anim_node;
|
delete m_node.m_anim_node;
|
||||||
delete m_nodes[i].m_socket_accessor;
|
delete m_node.m_socket_accessor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,9 +70,6 @@ struct AnimGraphResource {
|
||||||
AnimNodeResource& getGraphOutputNode() { return m_nodes[0]; }
|
AnimNodeResource& getGraphOutputNode() { return m_nodes[0]; }
|
||||||
AnimNodeResource& getGraphInputNode() { return m_nodes[1]; }
|
AnimNodeResource& getGraphInputNode() { return m_nodes[1]; }
|
||||||
|
|
||||||
const AnimNodeResource& getGraphOutputNode() const { return m_nodes[0]; }
|
|
||||||
const AnimNodeResource& getGraphInputNode() const { return m_nodes[1]; }
|
|
||||||
|
|
||||||
size_t getNodeIndex(const AnimNodeResource& node_resource) const {
|
size_t getNodeIndex(const AnimNodeResource& node_resource) const {
|
||||||
for (size_t i = 0, n = m_nodes.size(); i < n; i++) {
|
for (size_t i = 0, n = m_nodes.size(); i < n; i++) {
|
||||||
if (&m_nodes[i] == &node_resource) {
|
if (&m_nodes[i] == &node_resource) {
|
||||||
|
@ -84,7 +80,7 @@ struct AnimGraphResource {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t addNode(AnimNodeResource node_resource) {
|
size_t addNode(const AnimNodeResource &node_resource) {
|
||||||
m_nodes.push_back(node_resource);
|
m_nodes.push_back(node_resource);
|
||||||
return m_nodes.size() - 1;
|
return m_nodes.size() - 1;
|
||||||
}
|
}
|
||||||
|
@ -126,9 +122,8 @@ struct AnimGraphResource {
|
||||||
bool isSocketConnected(
|
bool isSocketConnected(
|
||||||
const AnimNodeResource& node,
|
const AnimNodeResource& node,
|
||||||
const std::string& socket_name) {
|
const std::string& socket_name) {
|
||||||
int node_index = getNodeIndex(node);
|
size_t node_index = getNodeIndex(node);
|
||||||
for (size_t i = 0, n = m_connections.size(); i < n; i++) {
|
for (const auto & connection : m_connections) {
|
||||||
const AnimGraphConnectionResource& connection = m_connections[i];
|
|
||||||
if ((connection.source_node_index == node_index
|
if ((connection.source_node_index == node_index
|
||||||
&& connection.source_socket_name == socket_name)
|
&& connection.source_socket_name == socket_name)
|
||||||
|| ((connection.target_node_index == node_index)
|
|| ((connection.target_node_index == node_index)
|
||||||
|
@ -144,9 +139,8 @@ struct AnimGraphResource {
|
||||||
|
|
||||||
void createRuntimeNodeInstances(AnimGraph& instance) const;
|
void createRuntimeNodeInstances(AnimGraph& instance) const;
|
||||||
void prepareGraphIOData(AnimGraph& instance) const;
|
void prepareGraphIOData(AnimGraph& instance) const;
|
||||||
void connectRuntimeNodes(AnimGraph& instance) const;
|
|
||||||
void setRuntimeNodeProperties(AnimGraph& instance) const;
|
void setRuntimeNodeProperties(AnimGraph& instance) const;
|
||||||
std::vector<Socket*> getConstNodeInputs(AnimGraph& instance, std::vector<NodeDescriptorBase*>& instance_node_descriptors) const;
|
std::vector<Socket*> getConstNodeInputs(std::vector<NodeDescriptorBase*>& instance_node_descriptors) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //ANIMTESTBED_ANIMGRAPHRESOURCE_H
|
#endif //ANIMTESTBED_ANIMGRAPHRESOURCE_H
|
||||||
|
|
Loading…
Reference in New Issue