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:
authorJacques Lucke <jacques@blender.org>2020-07-20 13:16:20 +0300
committerJacques Lucke <jacques@blender.org>2020-07-20 13:16:20 +0300
commit8cbbdedaf4dfec9e320e7e2be58b75d256950df1 (patch)
tree496b9620e11ac44e515b0bb4ca52c05834d557f9 /source/blender/nodes
parent686ab4c9401a90b22fb17e46c992eb513fe4f693 (diff)
Refactor: Update integer type usage
This updates the usage of integer types in code I wrote according to our new style guides. Major changes: * Use signed instead of unsigned integers in many places. * C++ containers in blenlib use `int64_t` for size and indices now (instead of `uint`). * Hash values for C++ containers are 64 bit wide now (instead of 32 bit). I do hope that I broke no builds, but it is quite likely that some compiler reports slightly different errors. Please let me know when there are any errors. If the fix is small, feel free to commit it yourself. I compiled successfully on linux with gcc and on windows.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/NOD_derived_node_tree.hh44
-rw-r--r--source/blender/nodes/NOD_node_tree_multi_function.hh6
-rw-r--r--source/blender/nodes/NOD_node_tree_ref.hh26
-rw-r--r--source/blender/nodes/intern/derived_node_tree.cc18
-rw-r--r--source/blender/nodes/intern/node_tree_multi_function.cc4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_map_range.cc4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.cc2
9 files changed, 54 insertions, 54 deletions
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh
index 84370dcd399..d79bd9031b8 100644
--- a/source/blender/nodes/NOD_derived_node_tree.hh
+++ b/source/blender/nodes/NOD_derived_node_tree.hh
@@ -46,15 +46,15 @@ class DSocket : NonCopyable, NonMovable {
protected:
DNode *node_;
const SocketRef *socket_ref_;
- uint id_;
+ int id_;
friend DerivedNodeTree;
public:
const DNode &node() const;
- uint id() const;
- uint index() const;
+ int id() const;
+ int index() const;
bool is_input() const;
bool is_output() const;
@@ -105,7 +105,7 @@ class DGroupInput : NonCopyable, NonMovable {
const InputSocketRef *socket_ref_;
DParentNode *parent_;
Vector<DInputSocket *> linked_sockets_;
- uint id_;
+ int id_;
friend DerivedNodeTree;
@@ -114,7 +114,7 @@ class DGroupInput : NonCopyable, NonMovable {
bNodeSocket *bsocket() const;
const DParentNode *parent() const;
Span<const DInputSocket *> linked_sockets() const;
- uint id() const;
+ int id() const;
StringRefNull name() const;
};
@@ -126,7 +126,7 @@ class DNode : NonCopyable, NonMovable {
Span<DInputSocket *> inputs_;
Span<DOutputSocket *> outputs_;
- uint id_;
+ int id_;
friend DerivedNodeTree;
@@ -137,13 +137,13 @@ class DNode : NonCopyable, NonMovable {
Span<const DInputSocket *> inputs() const;
Span<const DOutputSocket *> outputs() const;
- const DInputSocket &input(uint index) const;
- const DOutputSocket &output(uint index) const;
+ const DInputSocket &input(int index) const;
+ const DOutputSocket &output(int index) const;
- const DInputSocket &input(uint index, StringRef expected_name) const;
- const DOutputSocket &output(uint index, StringRef expected_name) const;
+ const DInputSocket &input(int index, StringRef expected_name) const;
+ const DOutputSocket &output(int index, StringRef expected_name) const;
- uint id() const;
+ int id() const;
PointerRNA *rna() const;
StringRefNull idname() const;
@@ -157,14 +157,14 @@ class DParentNode : NonCopyable, NonMovable {
private:
const NodeRef *node_ref_;
DParentNode *parent_;
- uint id_;
+ int id_;
friend DerivedNodeTree;
public:
const DParentNode *parent() const;
const NodeRef &node_ref() const;
- uint id() const;
+ int id() const;
};
using NodeTreeRefMap = Map<bNodeTree *, std::unique_ptr<const NodeTreeRef>>;
@@ -240,12 +240,12 @@ inline const DNode &DSocket::node() const
return *node_;
}
-inline uint DSocket::id() const
+inline int DSocket::id() const
{
return id_;
}
-inline uint DSocket::index() const
+inline int DSocket::index() const
{
return socket_ref_->index();
}
@@ -367,7 +367,7 @@ inline Span<const DInputSocket *> DGroupInput::linked_sockets() const
return linked_sockets_;
}
-inline uint DGroupInput::id() const
+inline int DGroupInput::id() const
{
return id_;
}
@@ -401,17 +401,17 @@ inline Span<const DOutputSocket *> DNode::outputs() const
return outputs_;
}
-inline const DInputSocket &DNode::input(uint index) const
+inline const DInputSocket &DNode::input(int index) const
{
return *inputs_[index];
}
-inline const DOutputSocket &DNode::output(uint index) const
+inline const DOutputSocket &DNode::output(int index) const
{
return *outputs_[index];
}
-inline const DInputSocket &DNode::input(uint index, StringRef expected_name) const
+inline const DInputSocket &DNode::input(int index, StringRef expected_name) const
{
const DInputSocket &socket = *inputs_[index];
BLI_assert(socket.name() == expected_name);
@@ -419,7 +419,7 @@ inline const DInputSocket &DNode::input(uint index, StringRef expected_name) con
return socket;
}
-inline const DOutputSocket &DNode::output(uint index, StringRef expected_name) const
+inline const DOutputSocket &DNode::output(int index, StringRef expected_name) const
{
const DOutputSocket &socket = *outputs_[index];
BLI_assert(socket.name() == expected_name);
@@ -427,7 +427,7 @@ inline const DOutputSocket &DNode::output(uint index, StringRef expected_name) c
return socket;
}
-inline uint DNode::id() const
+inline int DNode::id() const
{
return id_;
}
@@ -461,7 +461,7 @@ inline const NodeRef &DParentNode::node_ref() const
return *node_ref_;
}
-inline uint DParentNode::id() const
+inline int DParentNode::id() const
{
return id_;
}
diff --git a/source/blender/nodes/NOD_node_tree_multi_function.hh b/source/blender/nodes/NOD_node_tree_multi_function.hh
index f7a1fbb114d..79c2b3c7ce8 100644
--- a/source/blender/nodes/NOD_node_tree_multi_function.hh
+++ b/source/blender/nodes/NOD_node_tree_multi_function.hh
@@ -106,7 +106,7 @@ class MFNetworkTreeMap {
void add(Span<const DInputSocket *> dsockets, Span<fn::MFInputSocket *> sockets)
{
assert_same_size(dsockets, sockets);
- for (uint i : dsockets.index_range()) {
+ for (int i : dsockets.index_range()) {
this->add(*dsockets[i], *sockets[i]);
}
}
@@ -114,7 +114,7 @@ class MFNetworkTreeMap {
void add(Span<const DOutputSocket *> dsockets, Span<fn::MFOutputSocket *> sockets)
{
assert_same_size(dsockets, sockets);
- for (uint i : dsockets.index_range()) {
+ for (int i : dsockets.index_range()) {
this->add(*dsockets[i], *sockets[i]);
}
}
@@ -133,7 +133,7 @@ class MFNetworkTreeMap {
void add_try_match(Span<const DSocket *> dsockets, Span<fn::MFSocket *> sockets)
{
- uint used_sockets = 0;
+ int used_sockets = 0;
for (const DSocket *dsocket : dsockets) {
if (!dsocket->is_available()) {
continue;
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh
index 907184125b8..ebf5709ef50 100644
--- a/source/blender/nodes/NOD_node_tree_ref.hh
+++ b/source/blender/nodes/NOD_node_tree_ref.hh
@@ -71,8 +71,8 @@ class SocketRef : NonCopyable, NonMovable {
NodeRef *node_;
bNodeSocket *bsocket_;
bool is_input_;
- uint id_;
- uint index_;
+ int id_;
+ int index_;
PointerRNA rna_;
Vector<SocketRef *> linked_sockets_;
Vector<SocketRef *> directly_linked_sockets_;
@@ -87,8 +87,8 @@ class SocketRef : NonCopyable, NonMovable {
const NodeRef &node() const;
const NodeTreeRef &tree() const;
- uint id() const;
- uint index() const;
+ int id() const;
+ int index() const;
bool is_input() const;
bool is_output() const;
@@ -124,7 +124,7 @@ class NodeRef : NonCopyable, NonMovable {
NodeTreeRef *tree_;
bNode *bnode_;
PointerRNA rna_;
- uint id_;
+ int id_;
Vector<InputSocketRef *> inputs_;
Vector<OutputSocketRef *> outputs_;
@@ -136,8 +136,8 @@ class NodeRef : NonCopyable, NonMovable {
Span<const InputSocketRef *> inputs() const;
Span<const OutputSocketRef *> outputs() const;
- const InputSocketRef &input(uint index) const;
- const OutputSocketRef &output(uint index) const;
+ const InputSocketRef &input(int index) const;
+ const OutputSocketRef &output(int index) const;
bNode *bnode() const;
bNodeTree *btree() const;
@@ -146,7 +146,7 @@ class NodeRef : NonCopyable, NonMovable {
StringRefNull idname() const;
StringRefNull name() const;
- uint id() const;
+ int id() const;
bool is_reroute_node() const;
bool is_group_node() const;
@@ -220,12 +220,12 @@ inline const NodeTreeRef &SocketRef::tree() const
return node_->tree();
}
-inline uint SocketRef::id() const
+inline int SocketRef::id() const
{
return id_;
}
-inline uint SocketRef::index() const
+inline int SocketRef::index() const
{
return index_;
}
@@ -334,12 +334,12 @@ inline Span<const OutputSocketRef *> NodeRef::outputs() const
return outputs_;
}
-inline const InputSocketRef &NodeRef::input(uint index) const
+inline const InputSocketRef &NodeRef::input(int index) const
{
return *inputs_[index];
}
-inline const OutputSocketRef &NodeRef::output(uint index) const
+inline const OutputSocketRef &NodeRef::output(int index) const
{
return *outputs_[index];
}
@@ -369,7 +369,7 @@ inline StringRefNull NodeRef::name() const
return bnode_->name;
}
-inline uint NodeRef::id() const
+inline int NodeRef::id() const
{
return id_;
}
diff --git a/source/blender/nodes/intern/derived_node_tree.cc b/source/blender/nodes/intern/derived_node_tree.cc
index daec67b53a9..b7c78cb1499 100644
--- a/source/blender/nodes/intern/derived_node_tree.cc
+++ b/source/blender/nodes/intern/derived_node_tree.cc
@@ -83,7 +83,7 @@ DNode &DerivedNodeTree::create_node(const NodeRef &node_ref,
node.outputs_ = allocator_.construct_elements_and_pointer_array<DOutputSocket>(
node_ref.outputs().size());
- for (uint i : node.inputs_.index_range()) {
+ for (int i : node.inputs_.index_range()) {
const InputSocketRef &socket_ref = node_ref.input(i);
DInputSocket &socket = *node.inputs_[i];
@@ -94,7 +94,7 @@ DNode &DerivedNodeTree::create_node(const NodeRef &node_ref,
r_sockets_map[socket_ref.id()] = &socket;
}
- for (uint i : node.outputs_.index_range()) {
+ for (int i : node.outputs_.index_range()) {
const OutputSocketRef &socket_ref = node_ref.output(i);
DOutputSocket &socket = *node.outputs_[i];
@@ -113,7 +113,7 @@ BLI_NOINLINE void DerivedNodeTree::expand_groups(Vector<DNode *> &all_nodes,
Vector<DParentNode *> &all_parent_nodes,
NodeTreeRefMap &node_tree_refs)
{
- for (uint i = 0; i < all_nodes.size(); i++) {
+ for (int i = 0; i < all_nodes.size(); i++) {
DNode &node = *all_nodes[i];
if (node.node_ref_->is_group_node()) {
this->expand_group_node(node, all_nodes, all_group_inputs, all_parent_nodes, node_tree_refs);
@@ -181,10 +181,10 @@ BLI_NOINLINE void DerivedNodeTree::relink_group_inputs(const NodeTreeRef &group_
const NodeRef &input_node_ref = *node_refs[0];
DNode &input_node = *nodes_by_id[input_node_ref.id()];
- uint input_amount = group_node.inputs().size();
+ int input_amount = group_node.inputs().size();
BLI_assert(input_amount == input_node_ref.outputs().size() - 1);
- for (uint input_index : IndexRange(input_amount)) {
+ for (int input_index : IndexRange(input_amount)) {
DInputSocket *outside_group = group_node.inputs_[input_index];
DOutputSocket *inside_group = input_node.outputs_[input_index];
@@ -228,10 +228,10 @@ BLI_NOINLINE void DerivedNodeTree::relink_group_outputs(const NodeTreeRef &group
const NodeRef &output_node_ref = *node_refs[0];
DNode &output_node = *nodes_by_id[output_node_ref.id()];
- uint output_amount = group_node.outputs().size();
+ int output_amount = group_node.outputs().size();
BLI_assert(output_amount == output_node_ref.inputs().size() - 1);
- for (uint output_index : IndexRange(output_amount)) {
+ for (int output_index : IndexRange(output_amount)) {
DOutputSocket *outside_group = group_node.outputs_[output_index];
DInputSocket *inside_group = output_node.inputs_[output_index];
@@ -316,7 +316,7 @@ BLI_NOINLINE void DerivedNodeTree::store_in_this_and_init_ids(
group_inputs_ = std::move(all_group_inputs);
parent_nodes_ = std::move(all_parent_nodes);
- for (uint node_index : nodes_by_id_.index_range()) {
+ for (int node_index : nodes_by_id_.index_range()) {
DNode *node = nodes_by_id_[node_index];
node->id_ = node_index;
@@ -333,7 +333,7 @@ BLI_NOINLINE void DerivedNodeTree::store_in_this_and_init_ids(
}
}
- for (uint i : group_inputs_.index_range()) {
+ for (int i : group_inputs_.index_range()) {
group_inputs_[i]->id_ = i;
}
}
diff --git a/source/blender/nodes/intern/node_tree_multi_function.cc b/source/blender/nodes/intern/node_tree_multi_function.cc
index f77b19354a4..82842c4ef32 100644
--- a/source/blender/nodes/intern/node_tree_multi_function.cc
+++ b/source/blender/nodes/intern/node_tree_multi_function.cc
@@ -62,7 +62,7 @@ const fn::MultiFunction &NodeMFNetworkBuilder::get_default_fn(StringRef name)
static void insert_dummy_node(CommonMFNetworkBuilderData &common, const DNode &dnode)
{
- constexpr uint stack_capacity = 10;
+ constexpr int stack_capacity = 10;
Vector<fn::MFDataType, stack_capacity> input_types;
Vector<StringRef, stack_capacity> input_names;
@@ -159,7 +159,7 @@ static fn::MFOutputSocket *try_find_origin(CommonMFNetworkBuilderData &common,
{
Span<const DOutputSocket *> from_dsockets = to_dsocket.linked_sockets();
Span<const DGroupInput *> from_group_inputs = to_dsocket.linked_group_inputs();
- uint total_linked_amount = from_dsockets.size() + from_group_inputs.size();
+ int total_linked_amount = from_dsockets.size() + from_group_inputs.size();
BLI_assert(total_linked_amount <= 1);
if (total_linked_amount == 0) {
diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc
index b026499ec4b..4a6c9ec9a4d 100644
--- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc
@@ -115,13 +115,13 @@ class MapRangeFunction : public blender::fn::MultiFunction {
blender::fn::VSpan<float> to_max = params.readonly_single_input<float>(4, "To Max");
blender::MutableSpan<float> results = params.uninitialized_single_output<float>(5, "Result");
- for (uint i : mask) {
+ for (int64_t i : mask) {
float factor = safe_divide(values[i] - from_min[i], from_max[i] - from_min[i]);
results[i] = to_min[i] + factor * (to_max[i] - to_min[i]);
}
if (clamp_) {
- for (uint i : mask) {
+ for (int64_t i : mask) {
CLAMP(results[i], 0.0f, 1.0f);
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
index 4b4b80ea1ad..c1543f791f1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
@@ -80,7 +80,7 @@ class SeparateRGBFunction : public blender::fn::MultiFunction {
blender::MutableSpan<float> gs = params.uninitialized_single_output<float>(2, "G");
blender::MutableSpan<float> bs = params.uninitialized_single_output<float>(3, "B");
- for (uint i : mask) {
+ for (int64_t i : mask) {
blender::Color4f color = colors[i];
rs[i] = color.r;
gs[i] = color.g;
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc
index 03e18acc245..8b23327460f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc
@@ -65,7 +65,7 @@ class MF_SeparateXYZ : public blender::fn::MultiFunction {
blender::MutableSpan<float> ys = params.uninitialized_single_output<float>(2, "Y");
blender::MutableSpan<float> zs = params.uninitialized_single_output<float>(3, "Z");
- for (uint i : mask) {
+ for (int64_t i : mask) {
blender::float3 xyz = vectors[i];
xs[i] = xyz.x;
ys[i] = xyz.y;
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
index 21f15bcf6f4..7f712b0db40 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
@@ -148,7 +148,7 @@ class ColorBandFunction : public blender::fn::MultiFunction {
params.uninitialized_single_output<blender::Color4f>(1, "Color");
blender::MutableSpan<float> alphas = params.uninitialized_single_output<float>(2, "Alpha");
- for (uint i : mask) {
+ for (int64_t i : mask) {
blender::Color4f color;
BKE_colorband_evaluate(&color_band_, values[i], color);
colors[i] = color;