Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/graph/node.cpp
| Show All 24 Lines | |||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Node Type */ | /* Node Type */ | ||||
| Node::Node(const NodeType *type_, ustring name_) : name(name_), type(type_) | Node::Node(const NodeType *type_, ustring name_) : name(name_), type(type_) | ||||
| { | { | ||||
| assert(type); | assert(type); | ||||
| update_flags = 0; | |||||
brecht: This could set all bits, indicating that everything needs to be updated after the node has been… | |||||
| /* assign non-empty name, convenient for debugging */ | /* assign non-empty name, convenient for debugging */ | ||||
| if (name.empty()) { | if (name.empty()) { | ||||
| name = type->name; | name = type->name; | ||||
| } | } | ||||
| /* initialize default values */ | /* initialize default values */ | ||||
| foreach (const SocketType &socket, type->inputs) { | foreach (const SocketType &socket, type->inputs) { | ||||
| set_default_value(socket); | set_default_value(socket); | ||||
| Show All 23 Lines | |||||
| } | } | ||||
| #endif | #endif | ||||
| /* set values */ | /* set values */ | ||||
| void Node::set(const SocketType &input, bool value) | void Node::set(const SocketType &input, bool value) | ||||
| { | { | ||||
| assert(input.type == SocketType::BOOLEAN); | assert(input.type == SocketType::BOOLEAN); | ||||
| get_socket_value<bool>(this, input) = value; | get_socket_value<bool>(this, input) = value; | ||||
| update_flags |= input.update_flag_bit; | |||||
brechtUnsubmitted Done Inline ActionsWe should add code here comparing the new and old value, so that if nothing changed then nothing gets detected as modified. I guess the overhead of this will be small, and to keep first time export fast we can check if the update flag bit is already set and then avoid the comparison for arrays that might more costly to compare. brecht: We should add code here comparing the new and old value, so that if nothing changed then… | |||||
| } | } | ||||
| void Node::set(const SocketType &input, int value) | void Node::set(const SocketType &input, int value) | ||||
| { | { | ||||
| assert((input.type == SocketType::INT || input.type == SocketType::ENUM)); | assert((input.type == SocketType::INT || input.type == SocketType::ENUM)); | ||||
| get_socket_value<int>(this, input) = value; | get_socket_value<int>(this, input) = value; | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, uint value) | void Node::set(const SocketType &input, uint value) | ||||
| { | { | ||||
| assert(input.type == SocketType::UINT); | assert(input.type == SocketType::UINT); | ||||
| get_socket_value<uint>(this, input) = value; | get_socket_value<uint>(this, input) = value; | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, float value) | void Node::set(const SocketType &input, float value) | ||||
| { | { | ||||
| assert(input.type == SocketType::FLOAT); | assert(input.type == SocketType::FLOAT); | ||||
| get_socket_value<float>(this, input) = value; | get_socket_value<float>(this, input) = value; | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, float2 value) | void Node::set(const SocketType &input, float2 value) | ||||
| { | { | ||||
| assert(input.type == SocketType::FLOAT); | assert(input.type == SocketType::FLOAT); | ||||
| get_socket_value<float2>(this, input) = value; | get_socket_value<float2>(this, input) = value; | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, float3 value) | void Node::set(const SocketType &input, float3 value) | ||||
| { | { | ||||
| assert(is_socket_float3(input)); | assert(is_socket_float3(input)); | ||||
| get_socket_value<float3>(this, input) = value; | get_socket_value<float3>(this, input) = value; | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, const char *value) | void Node::set(const SocketType &input, const char *value) | ||||
| { | { | ||||
| set(input, ustring(value)); | set(input, ustring(value)); | ||||
| } | } | ||||
| void Node::set(const SocketType &input, ustring value) | void Node::set(const SocketType &input, ustring value) | ||||
| { | { | ||||
| if (input.type == SocketType::STRING) { | if (input.type == SocketType::STRING) { | ||||
| get_socket_value<ustring>(this, input) = value; | get_socket_value<ustring>(this, input) = value; | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| else if (input.type == SocketType::ENUM) { | else if (input.type == SocketType::ENUM) { | ||||
| const NodeEnum &enm = *input.enum_values; | const NodeEnum &enm = *input.enum_values; | ||||
| if (enm.exists(value)) { | if (enm.exists(value)) { | ||||
| get_socket_value<int>(this, input) = enm[value]; | get_socket_value<int>(this, input) = enm[value]; | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| else { | else { | ||||
| assert(0); | assert(0); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| assert(0); | assert(0); | ||||
| } | } | ||||
| } | } | ||||
| void Node::set(const SocketType &input, const Transform &value) | void Node::set(const SocketType &input, const Transform &value) | ||||
| { | { | ||||
| assert(input.type == SocketType::TRANSFORM); | assert(input.type == SocketType::TRANSFORM); | ||||
| get_socket_value<Transform>(this, input) = value; | get_socket_value<Transform>(this, input) = value; | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, Node *value) | void Node::set(const SocketType &input, Node *value) | ||||
| { | { | ||||
| assert(input.type == SocketType::NODE); | assert(input.type == SocketType::NODE); | ||||
| get_socket_value<Node *>(this, input) = value; | get_socket_value<Node *>(this, input) = value; | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| /* set array values */ | /* set array values */ | ||||
| void Node::set(const SocketType &input, array<bool> &value) | void Node::set(const SocketType &input, array<bool> &value) | ||||
| { | { | ||||
| assert(input.type == SocketType::BOOLEAN_ARRAY); | assert(input.type == SocketType::BOOLEAN_ARRAY); | ||||
| get_socket_value<array<bool>>(this, input).steal_data(value); | get_socket_value<array<bool>>(this, input).steal_data(value); | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, array<int> &value) | void Node::set(const SocketType &input, array<int> &value) | ||||
| { | { | ||||
| assert(input.type == SocketType::INT_ARRAY); | assert(input.type == SocketType::INT_ARRAY); | ||||
| get_socket_value<array<int>>(this, input).steal_data(value); | get_socket_value<array<int>>(this, input).steal_data(value); | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, array<float> &value) | void Node::set(const SocketType &input, array<float> &value) | ||||
| { | { | ||||
| assert(input.type == SocketType::FLOAT_ARRAY); | assert(input.type == SocketType::FLOAT_ARRAY); | ||||
| get_socket_value<array<float>>(this, input).steal_data(value); | get_socket_value<array<float>>(this, input).steal_data(value); | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, array<float2> &value) | void Node::set(const SocketType &input, array<float2> &value) | ||||
| { | { | ||||
| assert(input.type == SocketType::FLOAT_ARRAY); | assert(input.type == SocketType::FLOAT_ARRAY); | ||||
| get_socket_value<array<float2>>(this, input).steal_data(value); | get_socket_value<array<float2>>(this, input).steal_data(value); | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, array<float3> &value) | void Node::set(const SocketType &input, array<float3> &value) | ||||
| { | { | ||||
| assert(is_socket_array_float3(input)); | assert(is_socket_array_float3(input)); | ||||
| get_socket_value<array<float3>>(this, input).steal_data(value); | get_socket_value<array<float3>>(this, input).steal_data(value); | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, array<ustring> &value) | void Node::set(const SocketType &input, array<ustring> &value) | ||||
| { | { | ||||
| assert(input.type == SocketType::STRING_ARRAY); | assert(input.type == SocketType::STRING_ARRAY); | ||||
| get_socket_value<array<ustring>>(this, input).steal_data(value); | get_socket_value<array<ustring>>(this, input).steal_data(value); | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, array<Transform> &value) | void Node::set(const SocketType &input, array<Transform> &value) | ||||
| { | { | ||||
| assert(input.type == SocketType::TRANSFORM_ARRAY); | assert(input.type == SocketType::TRANSFORM_ARRAY); | ||||
| get_socket_value<array<Transform>>(this, input).steal_data(value); | get_socket_value<array<Transform>>(this, input).steal_data(value); | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| void Node::set(const SocketType &input, array<Node *> &value) | void Node::set(const SocketType &input, array<Node *> &value) | ||||
| { | { | ||||
| assert(input.type == SocketType::TRANSFORM_ARRAY); | assert(input.type == SocketType::TRANSFORM_ARRAY); | ||||
| get_socket_value<array<Node *>>(this, input).steal_data(value); | get_socket_value<array<Node *>>(this, input).steal_data(value); | ||||
| update_flags |= input.update_flag_bit; | |||||
| } | } | ||||
| /* get values */ | /* get values */ | ||||
| bool Node::get_bool(const SocketType &input) const | bool Node::get_bool(const SocketType &input) const | ||||
| { | { | ||||
| assert(input.type == SocketType::BOOLEAN); | assert(input.type == SocketType::BOOLEAN); | ||||
| return get_socket_value<bool>(this, input); | return get_socket_value<bool>(this, input); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 479 Lines • ▼ Show 20 Lines | bool Node::is_a(const NodeType *type_) | ||||
| for (const NodeType *base = type; base; base = base->base) { | for (const NodeType *base = type; base; base = base->base) { | ||||
| if (base == type_) { | if (base == type_) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| void Node::mark_processed() | |||||
brechtUnsubmitted Done Inline Actionsmark_processed -> clear_modified brecht: mark_processed -> clear_modified | |||||
| { | |||||
| update_flags = 0; | |||||
| } | |||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
This could set all bits, indicating that everything needs to be updated after the node has been created.
We could also leave this to the individual node types, but I'm not sure it's needed.