|
|
|
|
@@ -35,6 +35,7 @@ Node::Node(const NodeType *type_, ustring name_) : name(name_), type(type_)
|
|
|
|
|
assert(type);
|
|
|
|
|
|
|
|
|
|
owner = nullptr;
|
|
|
|
|
socket_modified = ~0;
|
|
|
|
|
|
|
|
|
|
/* assign non-empty name, convenient for debugging */
|
|
|
|
|
if (name.empty()) {
|
|
|
|
|
@@ -74,37 +75,37 @@ static bool is_socket_array_float3(const SocketType &socket)
|
|
|
|
|
void Node::set(const SocketType &input, bool value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::BOOLEAN);
|
|
|
|
|
get_socket_value<bool>(this, input) = value;
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, int value)
|
|
|
|
|
{
|
|
|
|
|
assert((input.type == SocketType::INT || input.type == SocketType::ENUM));
|
|
|
|
|
get_socket_value<int>(this, input) = value;
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, uint value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::UINT);
|
|
|
|
|
get_socket_value<uint>(this, input) = value;
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, float value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::FLOAT);
|
|
|
|
|
get_socket_value<float>(this, input) = value;
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, float2 value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::FLOAT);
|
|
|
|
|
get_socket_value<float2>(this, input) = value;
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, float3 value)
|
|
|
|
|
{
|
|
|
|
|
assert(is_socket_float3(input));
|
|
|
|
|
get_socket_value<float3>(this, input) = value;
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, const char *value)
|
|
|
|
|
@@ -115,12 +116,12 @@ void Node::set(const SocketType &input, const char *value)
|
|
|
|
|
void Node::set(const SocketType &input, ustring value)
|
|
|
|
|
{
|
|
|
|
|
if (input.type == SocketType::STRING) {
|
|
|
|
|
get_socket_value<ustring>(this, input) = value;
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
else if (input.type == SocketType::ENUM) {
|
|
|
|
|
const NodeEnum &enm = *input.enum_values;
|
|
|
|
|
if (enm.exists(value)) {
|
|
|
|
|
get_socket_value<int>(this, input) = enm[value];
|
|
|
|
|
set_if_different(input, enm[value]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
assert(0);
|
|
|
|
|
@@ -134,62 +135,62 @@ void Node::set(const SocketType &input, ustring value)
|
|
|
|
|
void Node::set(const SocketType &input, const Transform &value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::TRANSFORM);
|
|
|
|
|
get_socket_value<Transform>(this, input) = value;
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, Node *value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::NODE);
|
|
|
|
|
get_socket_value<Node *>(this, input) = value;
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set array values */
|
|
|
|
|
void Node::set(const SocketType &input, array<bool> &value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::BOOLEAN_ARRAY);
|
|
|
|
|
get_socket_value<array<bool>>(this, input).steal_data(value);
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, array<int> &value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::INT_ARRAY);
|
|
|
|
|
get_socket_value<array<int>>(this, input).steal_data(value);
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, array<float> &value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::FLOAT_ARRAY);
|
|
|
|
|
get_socket_value<array<float>>(this, input).steal_data(value);
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, array<float2> &value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::FLOAT_ARRAY);
|
|
|
|
|
get_socket_value<array<float2>>(this, input).steal_data(value);
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, array<float3> &value)
|
|
|
|
|
{
|
|
|
|
|
assert(is_socket_array_float3(input));
|
|
|
|
|
get_socket_value<array<float3>>(this, input).steal_data(value);
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, array<ustring> &value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::STRING_ARRAY);
|
|
|
|
|
get_socket_value<array<ustring>>(this, input).steal_data(value);
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, array<Transform> &value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::TRANSFORM_ARRAY);
|
|
|
|
|
get_socket_value<array<Transform>>(this, input).steal_data(value);
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::set(const SocketType &input, array<Node *> &value)
|
|
|
|
|
{
|
|
|
|
|
assert(input.type == SocketType::TRANSFORM_ARRAY);
|
|
|
|
|
get_socket_value<array<Node *>>(this, input).steal_data(value);
|
|
|
|
|
set_if_different(input, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get values */
|
|
|
|
|
@@ -696,4 +697,56 @@ void Node::set_owner(const NodeOwner *owner_)
|
|
|
|
|
owner = owner_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Node::socket_is_modified(const SocketType &input) const
|
|
|
|
|
{
|
|
|
|
|
return (socket_modified & input.modified_flag_bit) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Node::is_modified()
|
|
|
|
|
{
|
|
|
|
|
return socket_modified != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::tag_modified()
|
|
|
|
|
{
|
|
|
|
|
socket_modified = ~0u;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::clear_modified()
|
|
|
|
|
{
|
|
|
|
|
socket_modified = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T> void Node::set_if_different(const SocketType &input, T value)
|
|
|
|
|
{
|
|
|
|
|
if (get_socket_value<T>(this, input) == value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_socket_value<T>(this, input) = value;
|
|
|
|
|
socket_modified |= input.modified_flag_bit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T> void Node::set_if_different(const SocketType &input, array<T> &value)
|
|
|
|
|
{
|
|
|
|
|
if (!socket_is_modified(input)) {
|
|
|
|
|
if (get_socket_value<array<T>>(this, input) == value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_socket_value<array<T>>(this, input).steal_data(value);
|
|
|
|
|
socket_modified |= input.modified_flag_bit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Node::print_modified_sockets() const
|
|
|
|
|
{
|
|
|
|
|
printf("Node : %s\n", name.c_str());
|
|
|
|
|
for (auto &socket : type->inputs) {
|
|
|
|
|
if (socket_is_modified(socket)) {
|
|
|
|
|
printf("-- socket modified : %s\n", socket.name.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|