Changeset View
Standalone View
intern/cycles/render/nodes.h
| Show First 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | public: | ||||
| float3 vector; | float3 vector; | ||||
| TextureMapping tex_mapping; | TextureMapping tex_mapping; | ||||
| }; | }; | ||||
| class RGBToBWNode : public ShaderNode { | class RGBToBWNode : public ShaderNode { | ||||
| public: | public: | ||||
| SHADER_NODE_CLASS(RGBToBWNode) | SHADER_NODE_CLASS(RGBToBWNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | ||||
sergey: <Controversiality>
For own projects found it more readable/reliable to use const references… | |||||
Not Done Inline ActionsI don't really see the point of using using references and pointers to distinguish between const and non-const, I rather use it to distinguish between nullable and non-nullable. That way you can train yourself to remember to check for NULL whenever you use ->. But we are not doing that consistently in Cycles at all, so there's not much value in that at the moment and I don't care much which convention we use. brecht: I don't really see the point of using using references and pointers to distinguish between… | |||||
Not Done Inline ActionsThe point is to avoid possible override of external data. It's quite often in code you operate on arguments directly (like, ensuring they're within a range) instead of using temp variables for that. And it's not rare this causes issues, especially when something is passed by reference. The point of NULL-able is valid tho. So we need two types of references! :)
That's what makes me sad. Consistency level is not great :( But let's leave this for another discussion, outside of this patch. sergey: The point is to avoid possible override of external data. It's quite often in code you operate… | |||||
Not Done Inline Actions
Actually the main point about non-const references in C++ is that at the *call site* you can't immediately see if the parameter can be modified by the called function or not. For comparison, when passing by reference in C# the ref keyword is required both in parameter declaration and in the actuall call so it's obvious. Here however it's not much of a problem, especially because even without const all fields of the class are constant. angavrilov: > The point is to avoid possible override of external data.
Actually the main point about non… | |||||
| float3 color; | float3 color; | ||||
| }; | }; | ||||
| class ConvertNode : public ShaderNode { | class ConvertNode : public ShaderNode { | ||||
| public: | public: | ||||
| ConvertNode(SocketType::Type from, SocketType::Type to, bool autoconvert = false); | ConvertNode(SocketType::Type from, SocketType::Type to, bool autoconvert = false); | ||||
| SHADER_NODE_BASE_CLASS(ConvertNode) | SHADER_NODE_BASE_CLASS(ConvertNode) | ||||
| ▲ Show 20 Lines • Show All 345 Lines • ▼ Show 20 Lines | public: | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| float fac; | float fac; | ||||
| float3 color; | float3 color; | ||||
| }; | }; | ||||
| class MixNode : public ShaderNode { | class MixNode : public ShaderNode { | ||||
| bool try_fold_as_noop(ShaderGraph *graph, ShaderInput *input, float3 input_value, ShaderInput *optimized); | |||||
| public: | public: | ||||
| SHADER_NODE_CLASS(MixNode) | SHADER_NODE_CLASS(MixNode) | ||||
| bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized); | ||||
| virtual int get_group() { return NODE_GROUP_LEVEL_3; } | virtual int get_group() { return NODE_GROUP_LEVEL_3; } | ||||
| NodeMix type; | NodeMix type; | ||||
| bool use_clamp; | bool use_clamp; | ||||
| ▲ Show 20 Lines • Show All 311 Lines • Show Last 20 Lines | |||||
<Controversiality>
For own projects found it more readable/reliable to use const references only (so you don't accidentally assign value and so) and for non-const use pointers.
What do you guys think of using such approach in Cycles as well?
</Controversiality>