Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/CMakeLists.txt3
-rw-r--r--source/blender/nodes/NOD_common.h5
-rw-r--r--source/blender/nodes/NOD_composite.h5
-rw-r--r--source/blender/nodes/NOD_derived_node_tree.hh10
-rw-r--r--source/blender/nodes/NOD_function.h6
-rw-r--r--source/blender/nodes/NOD_node_tree_dependencies.hh5
-rw-r--r--source/blender/nodes/NOD_node_tree_multi_function.hh29
-rw-r--r--source/blender/nodes/NOD_node_tree_ref.hh9
-rw-r--r--source/blender/nodes/NOD_shader.h5
-rw-r--r--source/blender/nodes/NOD_simulation.h7
-rw-r--r--source/blender/nodes/NOD_socket.h10
-rw-r--r--source/blender/nodes/NOD_static_types.h4
-rw-r--r--source/blender/nodes/NOD_texture.h5
-rw-r--r--source/blender/nodes/composite/node_composite_util.h5
-rw-r--r--source/blender/nodes/function/node_function_util.hh5
-rw-r--r--source/blender/nodes/function/nodes/node_fn_random_float.cc89
-rw-r--r--source/blender/nodes/intern/derived_node_tree.cc11
-rw-r--r--source/blender/nodes/intern/node_common.c13
-rw-r--r--source/blender/nodes/intern/node_common.h5
-rw-r--r--source/blender/nodes/intern/node_exec.h5
-rw-r--r--source/blender/nodes/intern/node_socket.cc48
-rw-r--r--source/blender/nodes/intern/node_tree_dependencies.cc4
-rw-r--r--source/blender/nodes/intern/node_tree_multi_function.cc11
-rw-r--r--source/blender/nodes/intern/node_tree_ref.cc8
-rw-r--r--source/blender/nodes/intern/node_util.c2
-rw-r--r--source/blender/nodes/intern/node_util.h5
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c14
-rw-r--r--source/blender/nodes/shader/node_shader_util.h5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_attribute.c15
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_clamp.cc5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_curves.c29
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_displacement.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_geometry.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mapping.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.cc5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mixRgb.c9
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c37
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.cc5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_displacement.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_math.cc5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_rotate.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_wireframe.c18
-rw-r--r--source/blender/nodes/simulation/node_simulation_tree.cc4
-rw-r--r--source/blender/nodes/simulation/node_simulation_util.h5
-rw-r--r--source/blender/nodes/simulation/nodes/node_sim_age_reached_event.cc38
-rw-r--r--source/blender/nodes/simulation/nodes/node_sim_kill_particle.cc36
-rw-r--r--source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc1
-rw-r--r--source/blender/nodes/texture/node_texture_util.c13
-rw-r--r--source/blender/nodes/texture/node_texture_util.h5
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_curves.c2
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_rotate.c2
55 files changed, 395 insertions, 223 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index c53e01ac80f..33b95d50cc0 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -136,6 +136,7 @@ set(SRC
function/nodes/node_fn_float_compare.cc
function/nodes/node_fn_group_instance_id.cc
function/nodes/node_fn_object_transforms.cc
+ function/nodes/node_fn_random_float.cc
function/nodes/node_fn_switch.cc
function/node_function_util.cc
@@ -232,10 +233,12 @@ set(SRC
shader/node_shader_tree.c
shader/node_shader_util.c
+ simulation/nodes/node_sim_age_reached_event.cc
simulation/nodes/node_sim_common.cc
simulation/nodes/node_sim_emit_particles.cc
simulation/nodes/node_sim_execute_condition.cc
simulation/nodes/node_sim_force.cc
+ simulation/nodes/node_sim_kill_particle.cc
simulation/nodes/node_sim_multi_execute.cc
simulation/nodes/node_sim_particle_attribute.cc
simulation/nodes/node_sim_particle_birth_event.cc
diff --git a/source/blender/nodes/NOD_common.h b/source/blender/nodes/NOD_common.h
index dcc4f4d0b76..50ed992dcb6 100644
--- a/source/blender/nodes/NOD_common.h
+++ b/source/blender/nodes/NOD_common.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_COMMON_H__
-#define __NOD_COMMON_H__
+#pragma once
#include "BKE_node.h"
@@ -49,5 +48,3 @@ void node_group_output_update(struct bNodeTree *ntree, struct bNode *node);
#ifdef __cplusplus
}
#endif
-
-#endif /* __NOD_COMMON_H__ */
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index 6b1dd239294..99bcb849ebd 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_COMPOSITE_H__
-#define __NOD_COMPOSITE_H__
+#pragma once
#include "BKE_node.h"
@@ -150,5 +149,3 @@ void register_node_type_cmp_custom_group(bNodeType *ntype);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh
index b39c9fd1a23..9c71ae79cf2 100644
--- a/source/blender/nodes/NOD_derived_node_tree.hh
+++ b/source/blender/nodes/NOD_derived_node_tree.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_DERIVED_NODE_TREE_HH__
-#define __NOD_DERIVED_NODE_TREE_HH__
+#pragma once
/** \file
* \ingroup nodes
@@ -172,7 +171,6 @@ using NodeTreeRefMap = Map<bNodeTree *, std::unique_ptr<const NodeTreeRef>>;
class DerivedNodeTree : NonCopyable, NonMovable {
private:
LinearAllocator<> allocator_;
- bNodeTree *btree_;
Vector<DNode *> nodes_by_id_;
Vector<DGroupInput *> group_inputs_;
Vector<DParentNode *> parent_nodes_;
@@ -267,12 +265,12 @@ inline const DSocket &DSocket::as_base() const
inline const DInputSocket &DSocket::as_input() const
{
- return *(DInputSocket *)this;
+ return static_cast<const DInputSocket &>(*this);
}
inline const DOutputSocket &DSocket::as_output() const
{
- return *(DOutputSocket *)this;
+ return static_cast<const DOutputSocket &>(*this);
}
inline PointerRNA *DSocket::rna() const
@@ -507,5 +505,3 @@ inline Span<const DGroupInput *> DerivedNodeTree::group_inputs() const
}
} // namespace blender::nodes
-
-#endif /* __NOD_DERIVED_NODE_TREE_HH__ */
diff --git a/source/blender/nodes/NOD_function.h b/source/blender/nodes/NOD_function.h
index 4c05da694f7..58a968151ac 100644
--- a/source/blender/nodes/NOD_function.h
+++ b/source/blender/nodes/NOD_function.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_FUNCTION_H__
-#define __NOD_FUNCTION_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -27,9 +26,8 @@ void register_node_type_fn_switch(void);
void register_node_type_fn_group_instance_id(void);
void register_node_type_fn_combine_strings(void);
void register_node_type_fn_object_transforms(void);
+void register_node_type_fn_random_float(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __NOD_FUNCTION_H__ */
diff --git a/source/blender/nodes/NOD_node_tree_dependencies.hh b/source/blender/nodes/NOD_node_tree_dependencies.hh
index ca7059caa5f..13bb2bde2f3 100644
--- a/source/blender/nodes/NOD_node_tree_dependencies.hh
+++ b/source/blender/nodes/NOD_node_tree_dependencies.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_NODE_TREE_DEPENDENCIES_H__
-#define __NOD_NODE_TREE_DEPENDENCIES_H__
+#pragma once
#include "BLI_vector_set.hh"
@@ -75,5 +74,3 @@ class NodeTreeDependencies {
NodeTreeDependencies find_node_tree_dependencies(bNodeTree &ntree);
} // namespace blender::nodes
-
-#endif /* __NOD_NODE_TREE_DEPENDENCIES_H__ */
diff --git a/source/blender/nodes/NOD_node_tree_multi_function.hh b/source/blender/nodes/NOD_node_tree_multi_function.hh
index 81b467eca3a..25787231afa 100644
--- a/source/blender/nodes/NOD_node_tree_multi_function.hh
+++ b/source/blender/nodes/NOD_node_tree_multi_function.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_NODE_TREE_FUNCTION_HH__
-#define __NOD_NODE_TREE_FUNCTION_HH__
+#pragma once
/** \file
* \ingroup nodes
@@ -127,8 +126,20 @@ class MFNetworkTreeMap {
void add_try_match(const DNode &dnode, fn::MFNode &node)
{
- this->add_try_match(dnode.inputs(), node.inputs());
- this->add_try_match(dnode.outputs(), node.outputs());
+ this->add_try_match(dnode.inputs().cast<const DSocket *>(),
+ node.inputs().cast<fn::MFSocket *>());
+ this->add_try_match(dnode.outputs().cast<const DSocket *>(),
+ node.outputs().cast<fn::MFSocket *>());
+ }
+
+ void add_try_match(Span<const DInputSocket *> dsockets, Span<fn::MFInputSocket *> sockets)
+ {
+ this->add_try_match(dsockets.cast<const DSocket *>(), sockets.cast<fn::MFSocket *>());
+ }
+
+ void add_try_match(Span<const DOutputSocket *> dsockets, Span<fn::MFOutputSocket *> sockets)
+ {
+ this->add_try_match(dsockets.cast<const DSocket *>(), sockets.cast<fn::MFSocket *>());
}
void add_try_match(Span<const DSocket *> dsockets, Span<fn::MFSocket *> sockets)
@@ -251,19 +262,17 @@ class MFNetworkBuilderBase {
*/
class SocketMFNetworkBuilder : public MFNetworkBuilderBase {
private:
- const DSocket *dsocket_ = nullptr;
- const DGroupInput *group_input_ = nullptr;
bNodeSocket *bsocket_;
fn::MFOutputSocket *built_socket_ = nullptr;
public:
SocketMFNetworkBuilder(CommonMFNetworkBuilderData &common, const DSocket &dsocket)
- : MFNetworkBuilderBase(common), dsocket_(&dsocket), bsocket_(dsocket.bsocket())
+ : MFNetworkBuilderBase(common), bsocket_(dsocket.bsocket())
{
}
SocketMFNetworkBuilder(CommonMFNetworkBuilderData &common, const DGroupInput &group_input)
- : MFNetworkBuilderBase(common), group_input_(&group_input), bsocket_(group_input.bsocket())
+ : MFNetworkBuilderBase(common), bsocket_(group_input.bsocket())
{
}
@@ -280,7 +289,7 @@ class SocketMFNetworkBuilder : public MFNetworkBuilderBase {
*/
template<typename T> T *socket_default_value()
{
- return (T *)bsocket_->default_value;
+ return static_cast<T *>(bsocket_->default_value);
}
/**
@@ -389,5 +398,3 @@ MFNetworkTreeMap insert_node_tree_into_mf_network(fn::MFNetwork &network,
ResourceCollector &resources);
} // namespace blender::nodes
-
-#endif /* __NOD_NODE_TREE_FUNCTION_HH__ */
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh
index 13656c2e940..3b085248a39 100644
--- a/source/blender/nodes/NOD_node_tree_ref.hh
+++ b/source/blender/nodes/NOD_node_tree_ref.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_NODE_TREE_REF_HH__
-#define __NOD_NODE_TREE_REF_HH__
+#pragma once
/** \file
* \ingroup nodes
@@ -249,13 +248,13 @@ inline const SocketRef &SocketRef::as_base() const
inline const InputSocketRef &SocketRef::as_input() const
{
BLI_assert(this->is_input());
- return *(const InputSocketRef *)this;
+ return static_cast<const InputSocketRef &>(*this);
}
inline const OutputSocketRef &SocketRef::as_output() const
{
BLI_assert(this->is_output());
- return *(const OutputSocketRef *)this;
+ return static_cast<const OutputSocketRef &>(*this);
}
inline PointerRNA *SocketRef::rna() const
@@ -436,5 +435,3 @@ inline bNodeTree *NodeTreeRef::btree() const
}
} // namespace blender::nodes
-
-#endif /* __NOD_NODE_TREE_REF_HH__ */
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index bf548aea5f4..2911e0fbea6 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_SHADER_H__
-#define __NOD_SHADER_H__
+#pragma once
#include "BKE_node.h"
@@ -146,5 +145,3 @@ void register_node_type_sh_custom_group(bNodeType *ntype);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/NOD_simulation.h b/source/blender/nodes/NOD_simulation.h
index 2947d38fe83..266ded997c6 100644
--- a/source/blender/nodes/NOD_simulation.h
+++ b/source/blender/nodes/NOD_simulation.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NOD_SIMULATION_H__
-#define __NOD_SIMULATION_H__
+#pragma once
#ifdef __cplusplus
extern "C" {
@@ -39,9 +38,9 @@ void register_node_type_sim_particle_mesh_collision_event(void);
void register_node_type_sim_emit_particles(void);
void register_node_type_sim_time(void);
void register_node_type_sim_particle_attribute(void);
+void register_node_type_sim_age_reached_event(void);
+void register_node_type_sim_kill_particle(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __NOD_SIMULATION_H__ */
diff --git a/source/blender/nodes/NOD_socket.h b/source/blender/nodes/NOD_socket.h
index ce6f0da4aee..3344a25bdea 100644
--- a/source/blender/nodes/NOD_socket.h
+++ b/source/blender/nodes/NOD_socket.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_SOCKET_H__
-#define __NOD_SOCKET_H__
+#pragma once
#include "DNA_listBase.h"
@@ -48,10 +47,13 @@ void node_verify_socket_templates(struct bNodeTree *ntree, struct bNode *node);
void node_socket_init_default_value(struct bNodeSocket *sock);
void node_socket_copy_default_value(struct bNodeSocket *to, const struct bNodeSocket *from);
+void node_socket_skip_reroutes(struct ListBase *links,
+ struct bNode *node,
+ struct bNodeSocket *socket,
+ struct bNode **r_node,
+ struct bNodeSocket **r_socket);
void register_standard_node_socket_types(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __NOD_SOCKET_H__ */
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 31ce3f81450..7922a73902c 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -270,6 +270,8 @@ DefNode(SimulationNode, SIM_NODE_PARTICLE_MESH_COLLISION_EVENT, 0, "PARTIC
DefNode(SimulationNode, SIM_NODE_EMIT_PARTICLES, 0, "EMIT_PARTICLES", EmitParticles, "Emit Particles", "")
DefNode(SimulationNode, SIM_NODE_TIME, def_sim_time, "TIME", Time, "Time", "")
DefNode(SimulationNode, SIM_NODE_PARTICLE_ATTRIBUTE, def_sim_particle_attribute, "PARTICLE_ATTRIBUTE", ParticleAttribute, "Particle Attribute", "")
+DefNode(SimulationNode, SIM_NODE_AGE_REACHED_EVENT, 0, "AGE_REACHED_EVENT", AgeReachedEvent, "Age Reached Event", "")
+DefNode(SimulationNode, SIM_NODE_KILL_PARTICLE, 0, "KILL_PARTICLE", KillParticle, "Kill Particle", "")
DefNode(FunctionNode, FN_NODE_BOOLEAN_MATH, def_boolean_math, "BOOLEAN_MATH", BooleanMath, "Boolean Math", "")
DefNode(FunctionNode, FN_NODE_FLOAT_COMPARE, def_float_compare, "FLOAT_COMPARE", FloatCompare, "Float Compare", "")
@@ -277,7 +279,7 @@ DefNode(FunctionNode, FN_NODE_SWITCH, def_fn_switch, "SWITCH",
DefNode(FunctionNode, FN_NODE_GROUP_INSTANCE_ID, 0, "GROUP_INSTANCE_ID", GroupInstanceID, "Group Instance ID", "")
DefNode(FunctionNode, FN_NODE_COMBINE_STRINGS, 0, "COMBINE_STRINGS", CombineStrings, "Combine Strings", "")
DefNode(FunctionNode, FN_NODE_OBJECT_TRANSFORMS, 0, "OBJECT_TRANSFORMS", ObjectTransforms, "Object Transforms", "")
-
+DefNode(FunctionNode, FN_NODE_RANDOM_FLOAT, 0, "RANDOM_FLOAT", RandomFloat, "Random Float", "")
/* undefine macros */
diff --git a/source/blender/nodes/NOD_texture.h b/source/blender/nodes/NOD_texture.h
index 07a05f01bc5..af59fefd925 100644
--- a/source/blender/nodes/NOD_texture.h
+++ b/source/blender/nodes/NOD_texture.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NOD_TEXTURE_H__
-#define __NOD_TEXTURE_H__
+#pragma once
#include "BKE_node.h"
@@ -78,5 +77,3 @@ void register_node_type_tex_proc_distnoise(void);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h
index 0edc864e98f..8810b760e8c 100644
--- a/source/blender/nodes/composite/node_composite_util.h
+++ b/source/blender/nodes/composite/node_composite_util.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_COMPOSITE_UTIL_H__
-#define __NODE_COMPOSITE_UTIL_H__
+#pragma once
#include "DNA_ID.h"
#include "DNA_movieclip_types.h"
@@ -63,5 +62,3 @@ void cmp_node_type_base(
#ifdef __cplusplus
}
#endif
-
-#endif /* __NODE_COMPOSITE_UTIL_H__ */
diff --git a/source/blender/nodes/function/node_function_util.hh b/source/blender/nodes/function/node_function_util.hh
index 8e09ab0f24f..d57d1383019 100644
--- a/source/blender/nodes/function/node_function_util.hh
+++ b/source/blender/nodes/function/node_function_util.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NODE_FUNCTION_UTIL_H__
-#define __NODE_FUNCTION_UTIL_H__
+#pragma once
#include <string.h>
@@ -40,5 +39,3 @@
void fn_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
bool fn_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
-
-#endif /* __NODE_FUNCTION_UTIL_H__ */
diff --git a/source/blender/nodes/function/nodes/node_fn_random_float.cc b/source/blender/nodes/function/nodes/node_fn_random_float.cc
new file mode 100644
index 00000000000..584c544946e
--- /dev/null
+++ b/source/blender/nodes/function/nodes/node_fn_random_float.cc
@@ -0,0 +1,89 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_function_util.hh"
+
+#include "BLI_hash.h"
+
+static bNodeSocketTemplate fn_node_random_float_in[] = {
+ {SOCK_FLOAT, N_("Min"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE},
+ {SOCK_FLOAT, N_("Max"), 1.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE},
+ {SOCK_INT, N_("Seed")},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate fn_node_random_float_out[] = {
+ {SOCK_FLOAT, N_("Value")},
+ {-1, ""},
+};
+
+class RandomFloatFunction : public blender::fn::MultiFunction {
+ private:
+ uint32_t function_seed_;
+
+ public:
+ RandomFloatFunction(uint32_t function_seed) : function_seed_(function_seed)
+ {
+ blender::fn::MFSignatureBuilder signature = this->get_builder("Random float");
+ signature.single_input<float>("Min");
+ signature.single_input<float>("Max");
+ signature.single_input<int>("Seed");
+ signature.single_output<float>("Value");
+ }
+
+ void call(blender::IndexMask mask,
+ blender::fn::MFParams params,
+ blender::fn::MFContext UNUSED(context)) const override
+ {
+ blender::fn::VSpan<float> min_values = params.readonly_single_input<float>(0, "Min");
+ blender::fn::VSpan<float> max_values = params.readonly_single_input<float>(1, "Max");
+ blender::fn::VSpan<int> seeds = params.readonly_single_input<int>(2, "Seed");
+ blender::MutableSpan<float> values = params.uninitialized_single_output<float>(3, "Value");
+
+ for (int64_t i : mask) {
+ const float min_value = min_values[i];
+ const float max_value = max_values[i];
+ const int seed = seeds[i];
+ const float value = BLI_hash_int_01(static_cast<uint32_t>(seed) ^ function_seed_);
+ values[i] = value * (max_value - min_value) + min_value;
+ }
+ }
+};
+
+static void fn_node_random_float_expand_in_mf_network(
+ blender::nodes::NodeMFNetworkBuilder &builder)
+{
+ uint32_t function_seed = 1746872341u;
+ const blender::nodes::DNode &node = builder.dnode();
+ const blender::DefaultHash<blender::StringRefNull> hasher;
+ function_seed = 33 * function_seed + hasher(node.name());
+ for (const blender::nodes::DParentNode *parent = node.parent(); parent != nullptr;
+ parent = parent->parent()) {
+ function_seed = 33 * function_seed + hasher(parent->node_ref().name());
+ }
+
+ builder.construct_and_set_matching_fn<RandomFloatFunction>(function_seed);
+}
+
+void register_node_type_fn_random_float()
+{
+ static bNodeType ntype;
+
+ fn_node_type_base(&ntype, FN_NODE_RANDOM_FLOAT, "Random Float", 0, 0);
+ node_type_socket_templates(&ntype, fn_node_random_float_in, fn_node_random_float_out);
+ ntype.expand_in_mf_network = fn_node_random_float_expand_in_mf_network;
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/intern/derived_node_tree.cc b/source/blender/nodes/intern/derived_node_tree.cc
index 5414ea9208a..4612a479ebc 100644
--- a/source/blender/nodes/intern/derived_node_tree.cc
+++ b/source/blender/nodes/intern/derived_node_tree.cc
@@ -28,7 +28,7 @@ static const NodeTreeRef &get_tree_ref(NodeTreeRefMap &node_tree_refs, bNodeTree
[&]() { return std::make_unique<NodeTreeRef>(btree); });
}
-DerivedNodeTree::DerivedNodeTree(bNodeTree *btree, NodeTreeRefMap &node_tree_refs) : btree_(btree)
+DerivedNodeTree::DerivedNodeTree(bNodeTree *btree, NodeTreeRefMap &node_tree_refs)
{
const NodeTreeRef &main_tree_ref = get_tree_ref(node_tree_refs, btree);
@@ -59,9 +59,10 @@ BLI_NOINLINE void DerivedNodeTree::insert_nodes_and_links_in_id_order(const Node
/* Insert links. */
for (const NodeRef *node_ref : tree_ref.nodes()) {
for (const InputSocketRef *to_socket_ref : node_ref->inputs()) {
- DInputSocket *to_socket = (DInputSocket *)sockets_map[to_socket_ref->id()];
+ DInputSocket *to_socket = static_cast<DInputSocket *>(sockets_map[to_socket_ref->id()]);
for (const OutputSocketRef *from_socket_ref : to_socket_ref->linked_sockets()) {
- DOutputSocket *from_socket = (DOutputSocket *)sockets_map[from_socket_ref->id()];
+ DOutputSocket *from_socket = static_cast<DOutputSocket *>(
+ sockets_map[from_socket_ref->id()]);
to_socket->linked_sockets_.append(from_socket);
from_socket->linked_sockets_.append(to_socket);
}
@@ -130,7 +131,7 @@ BLI_NOINLINE void DerivedNodeTree::expand_group_node(DNode &group_node,
const NodeRef &group_node_ref = *group_node.node_ref_;
BLI_assert(group_node_ref.is_group_node());
- bNodeTree *btree = (bNodeTree *)group_node_ref.bnode()->id;
+ bNodeTree *btree = reinterpret_cast<bNodeTree *>(group_node_ref.bnode()->id);
if (btree == nullptr) {
return;
}
@@ -366,7 +367,7 @@ static dot::Cluster *get_cluster_for_parent(dot::DirectedGraph &graph,
}
return clusters.lookup_or_add_cb(parent, [&]() {
dot::Cluster *parent_cluster = get_cluster_for_parent(graph, clusters, parent->parent());
- bNodeTree *btree = (bNodeTree *)parent->node_ref().bnode()->id;
+ bNodeTree *btree = reinterpret_cast<bNodeTree *>(parent->node_ref().bnode()->id);
dot::Cluster *new_cluster = &graph.new_cluster(parent->node_ref().name() + " / " +
StringRef(btree->id.name + 2));
new_cluster->set_parent_cluster(parent_cluster);
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index 996fb93eb76..aa1f23163a0 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -84,13 +84,11 @@ bool node_group_poll_instance(bNode *node, bNodeTree *nodetree)
if (grouptree) {
return nodeGroupPoll(nodetree, grouptree);
}
- else {
- return true; /* without a linked node tree, group node is always ok */
- }
- }
- else {
- return false;
+
+ return true; /* without a linked node tree, group node is always ok */
}
+
+ return false;
}
int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
@@ -132,6 +130,9 @@ static bNodeSocket *group_verify_socket(
if (sock) {
strcpy(sock->name, iosock->name);
+ const int mask = SOCK_HIDE_VALUE;
+ sock->flag = (sock->flag & ~mask) | (iosock->flag & mask);
+
if (iosock->typeinfo->interface_verify_socket) {
iosock->typeinfo->interface_verify_socket(ntree, iosock, gnode, sock, "interface");
}
diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h
index 7810e9f1f14..7aad6782640 100644
--- a/source/blender/nodes/intern/node_common.h
+++ b/source/blender/nodes/intern/node_common.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_COMMON_H__
-#define __NODE_COMMON_H__
+#pragma once
#include "DNA_listBase.h"
@@ -40,5 +39,3 @@ void ntree_update_reroute_nodes(struct bNodeTree *ntree);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h
index 87a61f0a490..806dd10d9bf 100644
--- a/source/blender/nodes/intern/node_exec.h
+++ b/source/blender/nodes/intern/node_exec.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_EXEC_H__
-#define __NODE_EXEC_H__
+#pragma once
#include "DNA_listBase.h"
@@ -105,5 +104,3 @@ void ntreeTexEndExecTree_internal(struct bNodeTreeExec *exec);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc
index 57c8d51975e..0dfae7424cb 100644
--- a/source/blender/nodes/intern/node_socket.cc
+++ b/source/blender/nodes/intern/node_socket.cc
@@ -356,6 +356,54 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
to->flag |= (from->flag & SOCK_HIDE_VALUE);
}
+void node_socket_skip_reroutes(
+ ListBase *links, bNode *node, bNodeSocket *socket, bNode **r_node, bNodeSocket **r_socket)
+{
+ const int loop_limit = 100; /* Limit in case there is a connection cycle. */
+
+ if (socket->in_out == SOCK_IN) {
+ bNodeLink *first_link = (bNodeLink *)links->first;
+
+ for (int i = 0; node->type == NODE_REROUTE && i < loop_limit; i++) {
+ bNodeLink *link = first_link;
+
+ for (; link; link = link->next) {
+ if (link->fromnode == node && link->tonode != node) {
+ break;
+ }
+ }
+
+ if (link) {
+ node = link->tonode;
+ socket = link->tosock;
+ }
+ else {
+ break;
+ }
+ }
+ }
+ else {
+ for (int i = 0; node->type == NODE_REROUTE && i < loop_limit; i++) {
+ bNodeSocket *input = (bNodeSocket *)node->inputs.first;
+
+ if (input && input->link) {
+ node = input->link->fromnode;
+ socket = input->link->fromsock;
+ }
+ else {
+ break;
+ }
+ }
+ }
+
+ if (r_node) {
+ *r_node = node;
+ }
+ if (r_socket) {
+ *r_socket = socket;
+ }
+}
+
static void standard_node_socket_interface_init_socket(bNodeTree *UNUSED(ntree),
bNodeSocket *stemp,
bNode *UNUSED(node),
diff --git a/source/blender/nodes/intern/node_tree_dependencies.cc b/source/blender/nodes/intern/node_tree_dependencies.cc
index efe75a10f7e..9d279dd4d75 100644
--- a/source/blender/nodes/intern/node_tree_dependencies.cc
+++ b/source/blender/nodes/intern/node_tree_dependencies.cc
@@ -28,7 +28,7 @@ static void add_dependencies_of_node_tree(bNodeTree &ntree, NodeTreeDependencies
LISTBASE_FOREACH (bNode *, node, &ntree.nodes) {
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
if (socket->type == SOCK_OBJECT) {
- Object *object = ((bNodeSocketValueObject *)socket->default_value)->value;
+ Object *object = reinterpret_cast<bNodeSocketValueObject *>(socket->default_value)->value;
if (object != nullptr) {
r_dependencies.add_transform_dependency(object);
if (object->type == OB_MESH) {
@@ -39,7 +39,7 @@ static void add_dependencies_of_node_tree(bNodeTree &ntree, NodeTreeDependencies
}
if (node->type == NODE_GROUP) {
- bNodeTree *group = (bNodeTree *)node->id;
+ bNodeTree *group = reinterpret_cast<bNodeTree *>(node->id);
if (group != nullptr) {
add_dependencies_of_node_tree(*group, r_dependencies);
}
diff --git a/source/blender/nodes/intern/node_tree_multi_function.cc b/source/blender/nodes/intern/node_tree_multi_function.cc
index 82842c4ef32..09a80fd23f4 100644
--- a/source/blender/nodes/intern/node_tree_multi_function.cc
+++ b/source/blender/nodes/intern/node_tree_multi_function.cc
@@ -176,13 +176,12 @@ static fn::MFOutputSocket *try_find_origin(CommonMFNetworkBuilderData &common,
}
return nullptr;
}
- else {
- const DGroupInput &from_group_input = *from_group_inputs[0];
- if (is_multi_function_data_socket(from_group_input.bsocket())) {
- return &common.network_map.lookup(from_group_input);
- }
- return nullptr;
+
+ const DGroupInput &from_group_input = *from_group_inputs[0];
+ if (is_multi_function_data_socket(from_group_input.bsocket())) {
+ return &common.network_map.lookup(from_group_input);
}
+ return nullptr;
}
using ImplicitConversionsMap =
diff --git a/source/blender/nodes/intern/node_tree_ref.cc b/source/blender/nodes/intern/node_tree_ref.cc
index 47669bc5ca2..96ad1e0280e 100644
--- a/source/blender/nodes/intern/node_tree_ref.cc
+++ b/source/blender/nodes/intern/node_tree_ref.cc
@@ -101,9 +101,9 @@ InputSocketRef &NodeTreeRef::find_input_socket(Map<bNode *, NodeRef *> &node_map
bNodeSocket *bsocket)
{
NodeRef *node = node_mapping.lookup(bnode);
- for (SocketRef *socket : node->inputs_) {
+ for (InputSocketRef *socket : node->inputs_) {
if (socket->bsocket_ == bsocket) {
- return *(InputSocketRef *)socket;
+ return *socket;
}
}
BLI_assert(false);
@@ -115,9 +115,9 @@ OutputSocketRef &NodeTreeRef::find_output_socket(Map<bNode *, NodeRef *> &node_m
bNodeSocket *bsocket)
{
NodeRef *node = node_mapping.lookup(bnode);
- for (SocketRef *socket : node->outputs_) {
+ for (OutputSocketRef *socket : node->outputs_) {
if (socket->bsocket_ == bsocket) {
- return *(OutputSocketRef *)socket;
+ return *socket;
}
}
BLI_assert(false);
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index 9efbdc079e6..b2309abe32e 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -73,7 +73,7 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context),
bNode *node,
bNodeInstanceKey UNUSED(key))
{
- BKE_curvemapping_initialize(node->storage);
+ BKE_curvemapping_init(node->storage);
return NULL; /* unused return */
}
diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h
index 61f8fe6809d..1b542a9420a 100644
--- a/source/blender/nodes/intern/node_util.h
+++ b/source/blender/nodes/intern/node_util.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_UTIL_H__
-#define __NODE_UTIL_H__
+#pragma once
#include "DNA_listBase.h"
@@ -110,5 +109,3 @@ void node_socket_set_vector(struct bNodeTree *ntree,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 179a92ec7bd..758f7edfe49 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -344,15 +344,23 @@ static void ntree_shader_unlink_hidden_value_sockets(bNode *group_node, bNodeSoc
bool removed_link = false;
for (node = group_ntree->nodes.first; node; node = node->next) {
+ const bool is_group = ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP) && (node->id != NULL);
+
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
- if ((sock->flag & SOCK_HIDE_VALUE) == 0) {
+ if (!is_group && (sock->flag & SOCK_HIDE_VALUE) == 0) {
continue;
}
/* If socket is linked to a group input node and sockets id match. */
if (sock && sock->link && sock->link->fromnode->type == NODE_GROUP_INPUT) {
if (STREQ(isock->identifier, sock->link->fromsock->identifier)) {
- nodeRemLink(group_ntree, sock->link);
- removed_link = true;
+ if (is_group) {
+ /* Recursively unlink sockets within the nested group. */
+ ntree_shader_unlink_hidden_value_sockets(node, sock);
+ }
+ else {
+ nodeRemLink(group_ntree, sock->link);
+ removed_link = true;
+ }
}
}
}
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index b0ba1ea194f..de192f51a5f 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_SHADER_UTIL_H__
-#define __NODE_SHADER_UTIL_H__
+#pragma once
#include <float.h>
#include <math.h>
@@ -116,5 +115,3 @@ void ntreeExecGPUNodes(struct bNodeTreeExec *exec,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c
index 6b5d46e250b..116bc181997 100644
--- a/source/blender/nodes/shader/nodes/node_shader_attribute.c
+++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c
@@ -55,17 +55,16 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
return 1;
}
- else {
- GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name);
- GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr);
- /* for each output. */
- for (int i = 0; sh_node_attribute_out[i].type != -1; i++) {
- node_shader_gpu_bump_tex_coord(mat, node, &out[i].link);
- }
+ GPUNodeLink *cd_attr = GPU_attribute(mat, CD_AUTO_FROM_NAME, attr->name);
+ GPU_stack_link(mat, node, "node_attribute", in, out, cd_attr);
- return 1;
+ /* for each output. */
+ for (int i = 0; sh_node_attribute_out[i].type != -1; i++) {
+ node_shader_gpu_bump_tex_coord(mat, node, &out[i].link);
}
+
+ return 1;
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_clamp.cc b/source/blender/nodes/shader/nodes/node_shader_clamp.cc
index 1077f616a62..d3a893e1d76 100644
--- a/source/blender/nodes/shader/nodes/node_shader_clamp.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_clamp.cc
@@ -60,9 +60,8 @@ static void sh_node_clamp_expand_in_mf_network(blender::nodes::NodeMFNetworkBuil
if (a < b) {
return clamp_f(value, a, b);
}
- else {
- return clamp_f(value, b, a);
- }
+
+ return clamp_f(value, b, a);
}};
int clamp_type = builder.bnode().custom1;
diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c
index 68f252cb092..42299a193e2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_curves.c
+++ b/source/blender/nodes/shader/nodes/node_shader_curves.c
@@ -168,7 +168,7 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat,
CurveMapping *cumap = node->storage;
- BKE_curvemapping_initialize(cumap);
+ BKE_curvemapping_init(cumap);
BKE_curvemapping_table_RGBA(cumap, &array, &size);
GPUNodeLink *tex = GPU_color_band(mat, size, array, &layer);
@@ -215,20 +215,19 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat,
GPU_uniform(range_rgba),
GPU_uniform(ext_rgba[3]));
}
- else {
- return GPU_stack_link(mat,
- node,
- "curves_rgb",
- in,
- out,
- tex,
- GPU_constant(&layer),
- GPU_uniform(range_rgba),
- GPU_uniform(ext_rgba[0]),
- GPU_uniform(ext_rgba[1]),
- GPU_uniform(ext_rgba[2]),
- GPU_uniform(ext_rgba[3]));
- }
+
+ return GPU_stack_link(mat,
+ node,
+ "curves_rgb",
+ in,
+ out,
+ tex,
+ GPU_constant(&layer),
+ GPU_uniform(range_rgba),
+ GPU_uniform(ext_rgba[0]),
+ GPU_uniform(ext_rgba[1]),
+ GPU_uniform(ext_rgba[2]),
+ GPU_uniform(ext_rgba[3]));
}
void register_node_type_sh_curve_rgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_displacement.c b/source/blender/nodes/shader/nodes/node_shader_displacement.c
index 22fbe4e4da6..649aad370c0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_displacement.c
+++ b/source/blender/nodes/shader/nodes/node_shader_displacement.c
@@ -64,10 +64,9 @@ static int gpu_shader_displacement(GPUMaterial *mat,
return GPU_stack_link(
mat, node, "node_displacement_object", in, out, GPU_builtin(GPU_OBJECT_MATRIX));
}
- else {
- return GPU_stack_link(
- mat, node, "node_displacement_world", in, out, GPU_builtin(GPU_OBJECT_MATRIX));
- }
+
+ return GPU_stack_link(
+ mat, node, "node_displacement_world", in, out, GPU_builtin(GPU_OBJECT_MATRIX));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c
index deb0ee9037c..f66633e64c8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_geometry.c
+++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c
@@ -42,9 +42,12 @@ static int node_shader_gpu_geometry(GPUMaterial *mat,
{
/* HACK: Don't request GPU_BARYCENTRIC_TEXCO if not used because it will
* trigger the use of geometry shader (and the performance penalty it implies). */
- float val[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ const float val[4] = {0.0f, 0.0f, 0.0f, 0.0f};
GPUNodeLink *bary_link = (!out[5].hasoutput) ? GPU_constant(val) :
GPU_builtin(GPU_BARYCENTRIC_TEXCO);
+ if (out[5].hasoutput) {
+ GPU_material_flag_set(mat, GPU_MATFLAG_BARYCENTRIC);
+ }
/* Opti: don't request orco if not needed. */
GPUNodeLink *orco_link = (!out[2].hasoutput) ? GPU_constant(val) :
GPU_attribute(mat, CD_ORCO, "");
diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c
index 6750acf5ee1..774e7fed029 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mapping.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c
@@ -53,9 +53,8 @@ static int gpu_shader_mapping(GPUMaterial *mat,
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
return GPU_stack_link(mat, node, names[node->custom1], in, out);
}
- else {
- return 0;
- }
+
+ return 0;
}
static void node_shader_update_mapping(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc
index c7035da8c70..e7bbadfbcb0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_math.cc
@@ -141,9 +141,8 @@ static int gpu_shader_math(GPUMaterial *mat,
}
return ret;
}
- else {
- return 0;
- }
+
+ return 0;
}
static const blender::fn::MultiFunction &get_base_multi_function(
diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
index 93e88664d1a..8725122b12c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c
@@ -91,16 +91,15 @@ static int gpu_shader_mix_rgb(GPUMaterial *mat,
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
int ret = GPU_stack_link(mat, node, names[node->custom1], in, out);
if (ret && node->custom2 & SHD_MIXRGB_CLAMP) {
- float min[3] = {0.0f, 0.0f, 0.0f};
- float max[3] = {1.0f, 1.0f, 1.0f};
+ const float min[3] = {0.0f, 0.0f, 0.0f};
+ const float max[3] = {1.0f, 1.0f, 1.0f};
GPU_link(
mat, "clamp_color", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link);
}
return ret;
}
- else {
- return 0;
- }
+
+ return 0;
}
void register_node_type_sh_mix_rgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
index e8bedde0a62..2c12bf9bc01 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tangent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -45,28 +45,27 @@ static int node_shader_gpu_tangent(GPUMaterial *mat,
return GPU_stack_link(
mat, node, "node_tangentmap", in, out, GPU_attribute(mat, CD_TANGENT, attr->uv_map));
}
- else {
- GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, "");
- if (attr->axis == SHD_TANGENT_AXIS_X) {
- GPU_link(mat, "tangent_orco_x", orco, &orco);
- }
- else if (attr->axis == SHD_TANGENT_AXIS_Y) {
- GPU_link(mat, "tangent_orco_y", orco, &orco);
- }
- else {
- GPU_link(mat, "tangent_orco_z", orco, &orco);
- }
+ GPUNodeLink *orco = GPU_attribute(mat, CD_ORCO, "");
- return GPU_stack_link(mat,
- node,
- "node_tangent",
- in,
- out,
- GPU_builtin(GPU_WORLD_NORMAL),
- orco,
- GPU_builtin(GPU_OBJECT_MATRIX));
+ if (attr->axis == SHD_TANGENT_AXIS_X) {
+ GPU_link(mat, "tangent_orco_x", orco, &orco);
+ }
+ else if (attr->axis == SHD_TANGENT_AXIS_Y) {
+ GPU_link(mat, "tangent_orco_y", orco, &orco);
}
+ else {
+ GPU_link(mat, "tangent_orco_z", orco, &orco);
+ }
+
+ return GPU_stack_link(mat,
+ node,
+ "node_tangent",
+ in,
+ out,
+ GPU_builtin(GPU_WORLD_NORMAL),
+ orco,
+ GPU_builtin(GPU_OBJECT_MATRIX));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
index 0cf4b51f307..38e79ebe94d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -19,8 +19,6 @@
#include "../node_shader_util.h"
-#include "GPU_draw.h"
-
/* **************** OUTPUT ******************** */
static bNodeSocketTemplate sh_node_tex_environment_in[] = {
@@ -59,7 +57,8 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat,
NodeTexImage *tex_original = node_original->storage;
ImageUser *iuser = &tex_original->iuser;
eGPUSamplerState sampler = GPU_SAMPLER_REPEAT | GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER;
- if (GPU_get_mipmap()) {
+ /* TODO(fclem) For now assume mipmap is always enabled. */
+ if (true) {
sampler |= GPU_SAMPLER_MIPMAP;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index cbda72cd228..1a78d2f5bf2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -19,8 +19,6 @@
#include "../node_shader_util.h"
-#include "GPU_draw.h"
-
/* **************** OUTPUT ******************** */
static bNodeSocketTemplate sh_node_tex_image_in[] = {
@@ -95,7 +93,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
if (tex->interpolation != SHD_INTERP_CLOSEST) {
sampler_state |= GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER;
- sampler_state |= GPU_get_mipmap() ? GPU_SAMPLER_MIPMAP : 0;
+ /* TODO(fclem) For now assume mipmap is always enabled. */
+ sampler_state |= true ? GPU_SAMPLER_MIPMAP : 0;
}
const bool use_cubic = ELEM(tex->interpolation, SHD_INTERP_CUBIC, SHD_INTERP_SMART);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
index 94ffbbe0c55..9ef05d781bd 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
@@ -170,7 +170,7 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat,
GPU_uniform(xyz_to_rgb.g),
GPU_uniform(xyz_to_rgb.b));
}
- else if (tex->sky_model == 1) {
+ if (tex->sky_model == 1) {
/* Hosek / Wilkie */
sun_angles[0] = fmin(M_PI_2, sun_angles[0]); /* clamp to horizon */
SKY_ArHosekSkyModelState *sky_state = SKY_arhosek_xyz_skymodelstate_alloc_init(
@@ -210,9 +210,8 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat,
GPU_uniform(xyz_to_rgb.g),
GPU_uniform(xyz_to_rgb.b));
}
- else {
- return GPU_stack_link(mat, node, "node_tex_sky_nishita", in, out);
- }
+
+ return GPU_stack_link(mat, node, "node_tex_sky_nishita", in, out);
}
static void node_shader_update_sky(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c
index 817ccdc8b6a..56ecb6d4476 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.c
@@ -54,9 +54,8 @@ static int gpu_shader_tex_white_noise(GPUMaterial *mat,
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
return GPU_stack_link(mat, node, names[node->custom1], in, out);
}
- else {
- return 0;
- }
+
+ return 0;
}
static void node_shader_update_tex_white_noise(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
index 7f712b0db40..7b4e568e923 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
@@ -121,9 +121,8 @@ static int gpu_shader_valtorgb(GPUMaterial *mat,
if (coba->ipotype == COLBAND_INTERP_CONSTANT) {
return GPU_stack_link(mat, node, "valtorgb_nearest", in, out, tex, GPU_constant(&layer));
}
- else {
- return GPU_stack_link(mat, node, "valtorgb", in, out, tex, GPU_constant(&layer));
- }
+
+ return GPU_stack_link(mat, node, "valtorgb", in, out, tex, GPU_constant(&layer));
}
class ColorBandFunction : public blender::fn::MultiFunction {
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
index c9f79293328..0e82f346529 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.c
@@ -55,13 +55,12 @@ static int gpu_shader_vector_displacement(GPUMaterial *mat,
GPU_builtin(GPU_OBJECT_MATRIX),
GPU_builtin(GPU_VIEW_MATRIX));
}
- else if (node->custom1 == SHD_SPACE_OBJECT) {
+ if (node->custom1 == SHD_SPACE_OBJECT) {
return GPU_stack_link(
mat, node, "node_vector_displacement_object", in, out, GPU_builtin(GPU_OBJECT_MATRIX));
}
- else {
- return GPU_stack_link(mat, node, "node_vector_displacement_world", in, out);
- }
+
+ return GPU_stack_link(mat, node, "node_vector_displacement_world", in, out);
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
index c18ad8bb244..e8396c7cfc1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc
@@ -103,9 +103,8 @@ static int gpu_shader_vector_math(GPUMaterial *mat,
if (name != nullptr) {
return GPU_stack_link(mat, node, name, in, out);
}
- else {
- return 0;
- }
+
+ return 0;
}
static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c
index 46a6ff1f353..b2132c59cde 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.c
@@ -53,9 +53,8 @@ static int gpu_shader_vector_rotate(GPUMaterial *mat,
float invert = (node->custom2) ? -1.0 : 1.0;
return GPU_stack_link(mat, node, names[node->custom1], in, out, GPU_constant(&invert));
}
- else {
- return 0;
- }
+
+ return 0;
}
static void node_shader_update_vector_rotate(bNodeTree *UNUSED(ntree), bNode *node)
diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.c b/source/blender/nodes/shader/nodes/node_shader_wireframe.c
index e1da1cd34e4..37e60ddb205 100644
--- a/source/blender/nodes/shader/nodes/node_shader_wireframe.c
+++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.c
@@ -36,20 +36,20 @@ static int node_shader_gpu_wireframe(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
+ GPU_material_flag_set(mat, GPU_MATFLAG_BARYCENTRIC);
/* node->custom1 is use_pixel_size */
if (node->custom1) {
return GPU_stack_link(
mat, node, "node_wireframe_screenspace", in, out, GPU_builtin(GPU_BARYCENTRIC_TEXCO));
}
- else {
- return GPU_stack_link(mat,
- node,
- "node_wireframe",
- in,
- out,
- GPU_builtin(GPU_BARYCENTRIC_TEXCO),
- GPU_builtin(GPU_BARYCENTRIC_DIST));
- }
+
+ return GPU_stack_link(mat,
+ node,
+ "node_wireframe",
+ in,
+ out,
+ GPU_builtin(GPU_BARYCENTRIC_TEXCO),
+ GPU_builtin(GPU_BARYCENTRIC_DIST));
}
/* node type definition */
diff --git a/source/blender/nodes/simulation/node_simulation_tree.cc b/source/blender/nodes/simulation/node_simulation_tree.cc
index 3f0e70259d6..eb3257d7e66 100644
--- a/source/blender/nodes/simulation/node_simulation_tree.cc
+++ b/source/blender/nodes/simulation/node_simulation_tree.cc
@@ -32,8 +32,8 @@ bNodeTreeType *ntreeType_Simulation;
void register_node_tree_type_sim(void)
{
- bNodeTreeType *tt = ntreeType_Simulation = (bNodeTreeType *)MEM_callocN(
- sizeof(bNodeTreeType), "simulation node tree type");
+ bNodeTreeType *tt = ntreeType_Simulation = static_cast<bNodeTreeType *>(
+ MEM_callocN(sizeof(bNodeTreeType), "simulation node tree type"));
tt->type = NTREE_SIMULATION;
strcpy(tt->idname, "SimulationNodeTree");
strcpy(tt->ui_name, N_("Simulation Editor"));
diff --git a/source/blender/nodes/simulation/node_simulation_util.h b/source/blender/nodes/simulation/node_simulation_util.h
index adbe2ad5e8f..76a10715cff 100644
--- a/source/blender/nodes/simulation/node_simulation_util.h
+++ b/source/blender/nodes/simulation/node_simulation_util.h
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __NODE_SIM_UTIL_H__
-#define __NODE_SIM_UTIL_H__
+#pragma once
#include <string.h>
@@ -36,5 +35,3 @@
void sim_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
bool sim_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
-
-#endif /* __NODE_SIM_UTIL_H__ */
diff --git a/source/blender/nodes/simulation/nodes/node_sim_age_reached_event.cc b/source/blender/nodes/simulation/nodes/node_sim_age_reached_event.cc
new file mode 100644
index 00000000000..add8c4eba4d
--- /dev/null
+++ b/source/blender/nodes/simulation/nodes/node_sim_age_reached_event.cc
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_age_reached_event_in[] = {
+ {SOCK_FLOAT, N_("Age"), 3, 0, 0, 0, 0, 10000000},
+ {SOCK_CONTROL_FLOW, N_("Execute")},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_age_reached_event_out[] = {
+ {SOCK_EVENTS, N_("Event")},
+ {-1, ""},
+};
+
+void register_node_type_sim_age_reached_event()
+{
+ static bNodeType ntype;
+
+ sim_node_type_base(&ntype, SIM_NODE_AGE_REACHED_EVENT, "Age Reached Event", 0, 0);
+ node_type_socket_templates(
+ &ntype, sim_node_age_reached_event_in, sim_node_age_reached_event_out);
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_kill_particle.cc b/source/blender/nodes/simulation/nodes/node_sim_kill_particle.cc
new file mode 100644
index 00000000000..793b40d9365
--- /dev/null
+++ b/source/blender/nodes/simulation/nodes/node_sim_kill_particle.cc
@@ -0,0 +1,36 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "node_simulation_util.h"
+
+static bNodeSocketTemplate sim_node_kill_particle_in[] = {
+ {SOCK_CONTROL_FLOW, N_("Execute")},
+ {-1, ""},
+};
+
+static bNodeSocketTemplate sim_node_kill_particle_out[] = {
+ {SOCK_CONTROL_FLOW, N_("Execute")},
+ {-1, ""},
+};
+
+void register_node_type_sim_kill_particle()
+{
+ static bNodeType ntype;
+
+ sim_node_type_base(&ntype, SIM_NODE_KILL_PARTICLE, "Kill Particle", 0, 0);
+ node_type_socket_templates(&ntype, sim_node_kill_particle_in, sim_node_kill_particle_out);
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc b/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc
index 859ad81656b..5e1a6c35d52 100644
--- a/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc
+++ b/source/blender/nodes/simulation/nodes/node_sim_particle_mesh_emitter.cc
@@ -21,6 +21,7 @@
static bNodeSocketTemplate sim_node_particle_mesh_emitter_in[] = {
{SOCK_OBJECT, N_("Object")},
{SOCK_FLOAT, N_("Rate"), 100.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
+ {SOCK_CONTROL_FLOW, N_("Execute")},
{-1, ""},
};
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index 1d7641753e0..981fc4e308a 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -145,14 +145,13 @@ void tex_output(bNode *node,
/* do not add a delegate if the node is muted */
return;
}
+
+ if (!out->data) {
+ /* Freed in tex_end_exec (node.c) */
+ dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate");
+ }
else {
- if (!out->data) {
- /* Freed in tex_end_exec (node.c) */
- dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate");
- }
- else {
- dg = out->data;
- }
+ dg = out->data;
}
dg->cdata = cdata;
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index 7b8581c1f89..17a88ddaf5b 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -21,8 +21,7 @@
* \ingroup nodes
*/
-#ifndef __NODE_TEXTURE_UTIL_H__
-#define __NODE_TEXTURE_UTIL_H__
+#pragma once
#include <math.h>
#include <string.h>
@@ -131,5 +130,3 @@ void params_from_cdata(TexParams *out, TexCallData *in);
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index d42985ba041..70f7e731720 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.c
@@ -39,7 +39,7 @@ static void time_colorfn(
fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
}
- BKE_curvemapping_initialize(node->storage);
+ BKE_curvemapping_init(node->storage);
fac = BKE_curvemapping_evaluateF(node->storage, 0, fac);
out[0] = CLAMPIS(fac, 0.0f, 1.0f);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c
index 825f9d56147..06eb632378c 100644
--- a/source/blender/nodes/texture/nodes/node_texture_rotate.c
+++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c
@@ -38,7 +38,7 @@ static bNodeSocketTemplate outputs[] = {
{-1, ""},
};
-static void rotate(float new_co[3], float a, float ax[3], const float co[3])
+static void rotate(float new_co[3], float a, const float ax[3], const float co[3])
{
float para[3];
float perp[3];