diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-20 13:16:20 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-20 13:16:20 +0300 |
commit | 8cbbdedaf4dfec9e320e7e2be58b75d256950df1 (patch) | |
tree | 496b9620e11ac44e515b0bb4ca52c05834d557f9 /source/blender/simulation/intern/simulation_collect_influences.cc | |
parent | 686ab4c9401a90b22fb17e46c992eb513fe4f693 (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/simulation/intern/simulation_collect_influences.cc')
-rw-r--r-- | source/blender/simulation/intern/simulation_collect_influences.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/simulation/intern/simulation_collect_influences.cc b/source/blender/simulation/intern/simulation_collect_influences.cc index 98b055802c9..c1b936d9aa3 100644 --- a/source/blender/simulation/intern/simulation_collect_influences.cc +++ b/source/blender/simulation/intern/simulation_collect_influences.cc @@ -53,7 +53,7 @@ static Span<const nodes::DNode *> get_particle_simulation_nodes(const nodes::Der static std::optional<Array<std::string>> compute_global_string_inputs( nodes::MFNetworkTreeMap &network_map, Span<const fn::MFInputSocket *> sockets) { - uint amount = sockets.size(); + int amount = sockets.size(); if (amount == 0) { return Array<std::string>(); } @@ -67,7 +67,7 @@ static std::optional<Array<std::string>> compute_global_string_inputs( fn::MFParamsBuilder params{network_fn, 1}; Array<std::string> strings(amount, NoInitialization()); - for (uint i : IndexRange(amount)) { + for (int i : IndexRange(amount)) { params.add_uninitialized_single_output( fn::GMutableSpan(fn::CPPType::get<std::string>(), strings.data() + i, 1)); } @@ -101,7 +101,7 @@ static void find_and_deduplicate_particle_attribute_nodes(nodes::MFNetworkTreeMa Map<std::pair<std::string, fn::MFDataType>, Vector<fn::MFNode *>> attribute_nodes_by_name_and_type; - for (uint i : attribute_names->index_range()) { + for (int i : attribute_names->index_range()) { attribute_nodes_by_name_and_type .lookup_or_add_default( {(*attribute_names)[i], name_sockets[i]->node().output(0).data_type()}) @@ -207,7 +207,7 @@ class ParticleFunctionForce : public ParticleForce { evaluator.compute(); fn::VSpan<float3> forces = evaluator.get<float3>(0, "Force"); - for (uint i : mask) { + for (int64_t i : mask) { r_combined_force[i] += forces[i]; } } @@ -273,13 +273,13 @@ class MyBasicEmitter : public ParticleEmitter { } fn::MutableAttributesRef attributes = allocator->allocate(10); - RandomNumberGenerator rng{(uint)context.simulation_time_interval().start() ^ - DefaultHash<std::string>{}(name_)}; + RandomNumberGenerator rng{(uint32_t)context.simulation_time_interval().start() ^ + (uint32_t)DefaultHash<std::string>{}(name_)}; MutableSpan<float3> positions = attributes.get<float3>("Position"); MutableSpan<float3> velocities = attributes.get<float3>("Velocity"); - for (uint i : IndexRange(attributes.size())) { + for (int i : IndexRange(attributes.size())) { positions[i] = rng.get_unit_float3(); velocities[i] = rng.get_unit_float3(); } |