[Bf-blender-cvs] [0d97c0dfa60] geometry-nodes: Geometry Nodes: use attribute span api in random attribute node
Jacques Lucke
noreply at git.blender.org
Thu Nov 26 18:22:50 CET 2020
Commit: 0d97c0dfa60696866a08014d962d39fd5881977e
Author: Jacques Lucke
Date: Thu Nov 26 18:22:21 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rB0d97c0dfa60696866a08014d962d39fd5881977e
Geometry Nodes: use attribute span api in random attribute node
This results in a ~30% speedup. The execution time is bounded
by the random number generator here.
===================================================================
M source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc
===================================================================
diff --git a/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc
index 0eea9c221e4..68ea5481028 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc
@@ -64,10 +64,12 @@ static void randomize_attribute(FloatWriteAttribute &attribute,
float max,
RandomNumberGenerator &rng)
{
+ MutableSpan<float> attribute_span = attribute.get_span();
for (const int i : IndexRange(attribute.size())) {
const float value = rng.get_float() * (max - min) + min;
- attribute.set(i, value);
+ attribute_span[i] = value;
}
+ attribute.apply_span();
}
static void randomize_attribute(Float3WriteAttribute &attribute,
@@ -75,13 +77,15 @@ static void randomize_attribute(Float3WriteAttribute &attribute,
float3 max,
RandomNumberGenerator &rng)
{
+ MutableSpan<float3> attribute_span = attribute.get_span();
for (const int i : IndexRange(attribute.size())) {
const float x = rng.get_float();
const float y = rng.get_float();
const float z = rng.get_float();
const float3 value = float3(x, y, z) * (max - min) + min;
- attribute.set(i, value);
+ attribute_span[i] = value;
}
+ attribute.apply_span();
}
static void randomize_attribute(GeometryComponent &component,
More information about the Bf-blender-cvs
mailing list