Changeset View
Standalone View
intern/cycles/graph/node.h
| Show All 24 Lines | |||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| class MD5Hash; | class MD5Hash; | ||||
| struct Node; | struct Node; | ||||
| struct NodeType; | struct NodeType; | ||||
| struct Transform; | struct Transform; | ||||
| /* Node */ | /* Node */ | ||||
brecht: I wouldn't add `public` as part of the macro, since it affects further struct members in a… | |||||
| struct Node { | struct Node { | ||||
| explicit Node(const NodeType *type, ustring name = ustring()); | explicit Node(const NodeType *type, ustring name = ustring()); | ||||
| virtual ~Node() = 0; | virtual ~Node() = 0; | ||||
| /* set values */ | /* set values */ | ||||
| void set(const SocketType &input, bool value); | void set(const SocketType &input, bool value); | ||||
| void set(const SocketType &input, int value); | void set(const SocketType &input, int value); | ||||
| void set(const SocketType &input, uint value); | void set(const SocketType &input, uint value); | ||||
| void set(const SocketType &input, float value); | void set(const SocketType &input, float value); | ||||
| void set(const SocketType &input, float2 value); | void set(const SocketType &input, float2 value); | ||||
| void set(const SocketType &input, float3 value); | void set(const SocketType &input, float3 value); | ||||
| void set(const SocketType &input, const char *value); | void set(const SocketType &input, const char *value); | ||||
| void set(const SocketType &input, ustring value); | void set(const SocketType &input, ustring value); | ||||
| void set(const SocketType &input, const Transform &value); | void set(const SocketType &input, const Transform &value); | ||||
| void set(const SocketType &input, Node *value); | void set(const SocketType &input, Node *value); | ||||
Not Done Inline ActionsConstructing a ustring and calling find_input for every set or get seems too slow to me. Maybe just using static const SocketType *socket is enough? It would only need to be initialized once for each socket type, and checking if it has been initialized afterwards is probably done pretty efficiently by the compiler. I would then also put static variable in a shared function, so we don't have 3 copies. brecht: Constructing a `ustring` and calling `find_input` for every `set` or `get` seems too slow to me. | |||||
| /* set array values. the memory from the input array will taken over | /* set array values. the memory from the input array will taken over | ||||
| * by the node and the input array will be empty after return */ | * by the node and the input array will be empty after return */ | ||||
| void set(const SocketType &input, array<bool> &value); | void set(const SocketType &input, array<bool> &value); | ||||
| void set(const SocketType &input, array<int> &value); | void set(const SocketType &input, array<int> &value); | ||||
| void set(const SocketType &input, array<float> &value); | void set(const SocketType &input, array<float> &value); | ||||
| void set(const SocketType &input, array<float2> &value); | void set(const SocketType &input, array<float2> &value); | ||||
| void set(const SocketType &input, array<float3> &value); | void set(const SocketType &input, array<float3> &value); | ||||
| Show All 35 Lines | struct Node { | ||||
| void hash(MD5Hash &md5); | void hash(MD5Hash &md5); | ||||
| /* Get total size of this node. */ | /* Get total size of this node. */ | ||||
| size_t get_total_size_in_bytes() const; | size_t get_total_size_in_bytes() const; | ||||
| /* Type testing, taking into account base classes. */ | /* Type testing, taking into account base classes. */ | ||||
| bool is_a(const NodeType *type); | bool is_a(const NodeType *type); | ||||
| inline bool socket_has_changed(const SocketType &input) const | |||||
brechtUnsubmitted Done Inline ActionsNo need to explicitly use inline. brecht: No need to explicitly use `inline`. | |||||
| { | |||||
| return (update_flags & input.update_flag_bit) != 0; | |||||
| } | |||||
| inline bool need_update_() | |||||
kevindietrichAuthorUnsubmitted Not Done Inline ActionsThis is need_update_ (with an underscore at the end) because other nodes have a need_update (with no trailing underscore) member which conflicts, it can be renamed or we can rename the members and remove the trailing underscore (the need_update members will be replaced by the flags anyway at some point in the future). kevindietrich: This is `need_update_` (with an underscore at the end) because other nodes have a `need_update`… | |||||
brechtUnsubmitted Not Done Inline ActionsMaybe rename need_update_() to is_modified()? Just to keep the naming consistent. brecht: Maybe rename `need_update_()` to `is_modified()`? Just to keep the naming consistent. | |||||
| { | |||||
| return update_flags != 0; | |||||
| } | |||||
| void mark_processed(); | |||||
| ustring name; | ustring name; | ||||
| const NodeType *type; | const NodeType *type; | ||||
| unsigned int update_flags; | |||||
brechtUnsubmitted Done Inline ActionsDefine it like this, making clear this is per socket and ensuring every place use the same amount of bits in case we want to increase it later: typedef uint32_t SocketModifiedFlags; SocketUpdateFlags socket_modified; We also use "modified" rather than "changed" in some places already, I'd remain consistent with that naming. Also I suggest "modified" rather than "update" since the node base class only tracks what has been modified, and what that then means in terms of updates is up to the specific node implementations and managers. brecht: Define it like this, making clear this is per socket and ensuring every place use the same… | |||||
| }; | }; | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
I wouldn't add public as part of the macro, since it affects further struct members in a hidden way.