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
path: root/source
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-09-11 06:48:49 +0300
committerHans Goudey <h.goudey@me.com>2021-09-11 06:48:49 +0300
commitcb833138633e1c402c87115e504c492a12451810 (patch)
tree1d89905d270e7938796b1ce39918242bf2904e2a /source
parenteab26f13347dca6f14cf961d755b987dcad404fa (diff)
Nodes: Add vector min/max support to new socket builder API
Also use it to fix an incorrect min and max in the cube mesh primitive node.
Diffstat (limited to 'source')
-rw-r--r--source/blender/nodes/NOD_socket_declarations.hh14
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc2
-rw-r--r--source/blender/nodes/intern/node_socket_declarations.cc2
3 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/nodes/NOD_socket_declarations.hh b/source/blender/nodes/NOD_socket_declarations.hh
index 1a5873c37b5..11352111356 100644
--- a/source/blender/nodes/NOD_socket_declarations.hh
+++ b/source/blender/nodes/NOD_socket_declarations.hh
@@ -102,6 +102,8 @@ class Int : public SocketDeclaration {
class Vector : public SocketDeclaration {
private:
float3 default_value_ = {0, 0, 0};
+ float soft_min_value_ = -FLT_MAX;
+ float soft_max_value_ = FLT_MAX;
PropertySubType subtype_ = PROP_NONE;
public:
@@ -117,6 +119,18 @@ class Vector : public SocketDeclaration {
return *this;
}
+ Vector &min(const float min)
+ {
+ soft_min_value_ = min;
+ return *this;
+ }
+
+ Vector &max(const float max)
+ {
+ soft_max_value_ = max;
+ return *this;
+ }
+
bNodeSocket &build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_out) const override;
bool matches(const bNodeSocket &socket) const override;
bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override;
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
index f5d9ed2d6a9..af8ce02b3c1 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
@@ -26,7 +26,7 @@ namespace blender::nodes {
static void geo_node_mesh_primitive_cube_declare(NodeDeclarationBuilder &b)
{
- b.add_input<decl::Vector>("Size").default_value({1.0f, 1.0f, 1.0f}).subtype(PROP_TRANSLATION);
+ b.add_input<decl::Vector>("Size").default_value(float3(1)).min(0.0f).subtype(PROP_TRANSLATION);
b.add_input<decl::Int>("Vertices X").default_value(2).min(2).max(1000);
b.add_input<decl::Int>("Vertices Y").default_value(2).min(2).max(1000);
b.add_input<decl::Int>("Vertices Z").default_value(2).min(2).max(1000);
diff --git a/source/blender/nodes/intern/node_socket_declarations.cc b/source/blender/nodes/intern/node_socket_declarations.cc
index ba9a1870b0c..e17b0fd5579 100644
--- a/source/blender/nodes/intern/node_socket_declarations.cc
+++ b/source/blender/nodes/intern/node_socket_declarations.cc
@@ -148,6 +148,8 @@ bNodeSocket &Vector::build(bNodeTree &ntree, bNode &node, eNodeSocketInOut in_ou
&ntree, &node, in_out, SOCK_VECTOR, subtype_, identifier_.c_str(), name_.c_str());
bNodeSocketValueVector &value = *(bNodeSocketValueVector *)socket.default_value;
copy_v3_v3(value.value, default_value_);
+ value.min = soft_min_value_;
+ value.max = soft_max_value_;
return socket;
}