Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/intern/node_socket_declarations.cc
| Show First 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | if (!this->matches_common_data(socket)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (socket.type != SOCK_VECTOR) { | if (socket.type != SOCK_VECTOR) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (socket.typeinfo->subtype != this->subtype) { | if (socket.typeinfo->subtype != this->subtype) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| const bNodeSocketValueVector &value = *static_cast<const bNodeSocketValueVector *>( | |||||
| socket.default_value); | |||||
| if (value.min != this->soft_min_value) { | |||||
| return false; | |||||
| } | |||||
| if (value.max != this->soft_max_value) { | |||||
| return false; | |||||
| } | |||||
| return true; | return true; | ||||
| } | } | ||||
| bool Vector::can_connect(const bNodeSocket &socket) const | bool Vector::can_connect(const bNodeSocket &socket) const | ||||
| { | { | ||||
| if (!sockets_can_connect(*this, socket)) { | if (!sockets_can_connect(*this, socket)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return basic_types_can_connect(*this, socket); | return basic_types_can_connect(*this, socket); | ||||
| } | } | ||||
| bNodeSocket &Vector::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const | bNodeSocket &Vector::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const | ||||
| { | { | ||||
| if (socket.type != SOCK_VECTOR) { | if (socket.type != SOCK_VECTOR) { | ||||
| BLI_assert(socket.in_out == this->in_out); | BLI_assert(socket.in_out == this->in_out); | ||||
| return this->build(ntree, node); | return this->build(ntree, node); | ||||
| } | } | ||||
| if (socket.typeinfo->subtype != this->subtype) { | if (socket.typeinfo->subtype != this->subtype) { | ||||
| modify_subtype_except_for_storage(socket, this->subtype); | modify_subtype_except_for_storage(socket, this->subtype); | ||||
| } | } | ||||
| this->set_common_flags(socket); | this->set_common_flags(socket); | ||||
| bNodeSocketValueVector &value = *(bNodeSocketValueVector *)socket.default_value; | bNodeSocketValueVector &value = *(bNodeSocketValueVector *)socket.default_value; | ||||
| value.subtype = this->subtype; | value.subtype = this->subtype; | ||||
| value.min = this->soft_min_value; | |||||
| value.max = this->soft_max_value; | |||||
| STRNCPY(socket.name, this->name.c_str()); | STRNCPY(socket.name, this->name.c_str()); | ||||
| return socket; | return socket; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name #Bool | /** \name #Bool | ||||
| Show All 28 Lines | |||||
| bool Bool::can_connect(const bNodeSocket &socket) const | bool Bool::can_connect(const bNodeSocket &socket) const | ||||
| { | { | ||||
| if (!sockets_can_connect(*this, socket)) { | if (!sockets_can_connect(*this, socket)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return basic_types_can_connect(*this, socket); | return basic_types_can_connect(*this, socket); | ||||
| } | } | ||||
| bNodeSocket &Bool::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const | |||||
| { | |||||
| if (socket.type != SOCK_BOOLEAN) { | |||||
| BLI_assert(socket.in_out == this->in_out); | |||||
| return this->build(ntree, node); | |||||
| } | |||||
| this->set_common_flags(socket); | |||||
| STRNCPY(socket.name, this->name.c_str()); | |||||
| return socket; | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name #Color | /** \name #Color | ||||
| * \{ */ | * \{ */ | ||||
| bNodeSocket &Color::build(bNodeTree &ntree, bNode &node) const | bNodeSocket &Color::build(bNodeTree &ntree, bNode &node) const | ||||
| { | { | ||||
| Show All 29 Lines | |||||
| bool Color::can_connect(const bNodeSocket &socket) const | bool Color::can_connect(const bNodeSocket &socket) const | ||||
| { | { | ||||
| if (!sockets_can_connect(*this, socket)) { | if (!sockets_can_connect(*this, socket)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return basic_types_can_connect(*this, socket); | return basic_types_can_connect(*this, socket); | ||||
| } | } | ||||
| bNodeSocket &Color::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const | |||||
| { | |||||
| if (socket.type != SOCK_RGBA) { | |||||
| BLI_assert(socket.in_out == this->in_out); | |||||
| return this->build(ntree, node); | |||||
| } | |||||
| this->set_common_flags(socket); | |||||
| STRNCPY(socket.name, this->name.c_str()); | |||||
| return socket; | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name #String | /** \name #String | ||||
| * \{ */ | * \{ */ | ||||
| bNodeSocket &String::build(bNodeTree &ntree, bNode &node) const | bNodeSocket &String::build(bNodeTree &ntree, bNode &node) const | ||||
| { | { | ||||
| Show All 20 Lines | bool String::matches(const bNodeSocket &socket) const | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool String::can_connect(const bNodeSocket &socket) const | bool String::can_connect(const bNodeSocket &socket) const | ||||
| { | { | ||||
| return sockets_can_connect(*this, socket) && socket.type == SOCK_STRING; | return sockets_can_connect(*this, socket) && socket.type == SOCK_STRING; | ||||
| } | } | ||||
| bNodeSocket &String::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const | |||||
| { | |||||
| if (socket.type != SOCK_STRING) { | |||||
| BLI_assert(socket.in_out == this->in_out); | |||||
| return this->build(ntree, node); | |||||
| } | |||||
| this->set_common_flags(socket); | |||||
| STRNCPY(socket.name, this->name.c_str()); | |||||
| return socket; | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name #IDSocketDeclaration | /** \name #IDSocketDeclaration | ||||
| * \{ */ | * \{ */ | ||||
| bNodeSocket &IDSocketDeclaration::build(bNodeTree &ntree, bNode &node) const | bNodeSocket &IDSocketDeclaration::build(bNodeTree &ntree, bNode &node) const | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | if (this->in_out == SOCK_IN) { | ||||
| return ELEM( | return ELEM( | ||||
| socket.type, SOCK_VECTOR, SOCK_RGBA, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_SHADER); | socket.type, SOCK_VECTOR, SOCK_RGBA, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_SHADER); | ||||
| } | } | ||||
| return socket.type == SOCK_SHADER; | return socket.type == SOCK_SHADER; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name #Extend | |||||
| * \{ */ | |||||
| bNodeSocket &Extend::build(bNodeTree &ntree, bNode &node) const | |||||
| { | |||||
| bNodeSocket &socket = *nodeAddSocket(&ntree, | |||||
| &node, | |||||
| this->in_out, | |||||
| "NodeSocketVirtual", | |||||
| this->identifier.c_str(), | |||||
| this->name.c_str()); | |||||
| return socket; | |||||
| } | |||||
| bool Extend::matches(const bNodeSocket &socket) const | |||||
| { | |||||
| if (socket.identifier != this->identifier) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| bool Extend::can_connect(const bNodeSocket & /*socket*/) const | |||||
| { | |||||
| return false; | |||||
| } | |||||
| bNodeSocket &Extend::update_or_build(bNodeTree & /*ntree*/, | |||||
| bNode & /*node*/, | |||||
| bNodeSocket &socket) const | |||||
| { | |||||
| return socket; | |||||
| } | |||||
| /** \} */ | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name #Custom | |||||
| * \{ */ | |||||
| bNodeSocket &Custom::build(bNodeTree &ntree, bNode &node) const | |||||
| { | |||||
| bNodeSocket &socket = *nodeAddSocket( | |||||
| &ntree, &node, this->in_out, idname_, this->identifier.c_str(), this->name.c_str()); | |||||
| return socket; | |||||
| } | |||||
| bool Custom::matches(const bNodeSocket &socket) const | |||||
| { | |||||
| if (!this->matches_common_data(socket)) { | |||||
| return false; | |||||
| } | |||||
| if (socket.type != SOCK_CUSTOM) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| bool Custom::can_connect(const bNodeSocket &socket) const | |||||
| { | |||||
| return sockets_can_connect(*this, socket) && STREQ(socket.idname, idname_); | |||||
| } | |||||
| bNodeSocket &Custom::update_or_build(bNodeTree & /*ntree*/, | |||||
| bNode & /*node*/, | |||||
| bNodeSocket &socket) const | |||||
| { | |||||
| return socket; | |||||
| } | |||||
| /** \} */ | |||||
| } // namespace blender::nodes::decl | } // namespace blender::nodes::decl | ||||