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>2021-10-03 16:01:02 +0300
committerJacques Lucke <jacques@blender.org>2021-10-03 16:01:02 +0300
commit0998856c923f28b1cf2199b945e3eb70cbface96 (patch)
treea575b3cc60e8ca74f11aa4e7521df7e114ed48fe
parent8fc97a871fa34a0413093bb12c2825e963482a45 (diff)
Cleanup: use movable output attribute instead of optional
This simplifies the code a bit and improves compile times a bit.
-rw-r--r--source/blender/blenkernel/BKE_attribute_access.hh11
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc30
2 files changed, 26 insertions, 15 deletions
diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh
index 25ee4d3c132..ef43e21b739 100644
--- a/source/blender/blenkernel/BKE_attribute_access.hh
+++ b/source/blender/blenkernel/BKE_attribute_access.hh
@@ -248,6 +248,7 @@ template<typename T> class OutputAttribute_Typed {
VMutableArray<T> *varray_ = nullptr;
public:
+ OutputAttribute_Typed() = default;
OutputAttribute_Typed(OutputAttribute attribute) : attribute_(std::move(attribute))
{
if (attribute_) {
@@ -259,6 +260,16 @@ template<typename T> class OutputAttribute_Typed {
OutputAttribute_Typed(OutputAttribute_Typed &&other) = default;
~OutputAttribute_Typed() = default;
+ OutputAttribute_Typed &operator=(OutputAttribute_Typed &&other)
+ {
+ if (this == &other) {
+ return *this;
+ }
+ this->~OutputAttribute_Typed();
+ new (this) OutputAttribute_Typed(std::move(other));
+ return *this;
+ }
+
operator bool() const
{
return varray_ != nullptr;
diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
index 1a4c5d84dbf..0c8db0d8912 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
@@ -331,28 +331,28 @@ BLI_NOINLINE static void compute_attribute_outputs(const MeshComponent &mesh_com
const Span<int> looptri_indices,
const AttributeOutputs &attribute_outputs)
{
- std::optional<OutputAttribute_Typed<int>> id_attribute;
- std::optional<OutputAttribute_Typed<float3>> normal_attribute;
- std::optional<OutputAttribute_Typed<float3>> rotation_attribute;
+ OutputAttribute_Typed<int> id_attribute;
+ OutputAttribute_Typed<float3> normal_attribute;
+ OutputAttribute_Typed<float3> rotation_attribute;
MutableSpan<int> ids;
MutableSpan<float3> normals;
MutableSpan<float3> rotations;
if (attribute_outputs.stable_id_id) {
- id_attribute.emplace(point_component.attribute_try_get_for_output_only<int>(
- attribute_outputs.stable_id_id.get(), ATTR_DOMAIN_POINT));
- ids = id_attribute->as_span();
+ id_attribute = point_component.attribute_try_get_for_output_only<int>(
+ attribute_outputs.stable_id_id.get(), ATTR_DOMAIN_POINT);
+ ids = id_attribute.as_span();
}
if (attribute_outputs.normal_id) {
- normal_attribute.emplace(point_component.attribute_try_get_for_output_only<float3>(
- attribute_outputs.normal_id.get(), ATTR_DOMAIN_POINT));
- normals = normal_attribute->as_span();
+ normal_attribute = point_component.attribute_try_get_for_output_only<float3>(
+ attribute_outputs.normal_id.get(), ATTR_DOMAIN_POINT);
+ normals = normal_attribute.as_span();
}
if (attribute_outputs.rotation_id) {
- rotation_attribute.emplace(point_component.attribute_try_get_for_output_only<float3>(
- attribute_outputs.rotation_id.get(), ATTR_DOMAIN_POINT));
- rotations = rotation_attribute->as_span();
+ rotation_attribute = point_component.attribute_try_get_for_output_only<float3>(
+ attribute_outputs.rotation_id.get(), ATTR_DOMAIN_POINT);
+ rotations = rotation_attribute.as_span();
}
const Mesh &mesh = *mesh_component.get_for_read();
@@ -387,13 +387,13 @@ BLI_NOINLINE static void compute_attribute_outputs(const MeshComponent &mesh_com
}
if (id_attribute) {
- id_attribute->save();
+ id_attribute.save();
}
if (normal_attribute) {
- normal_attribute->save();
+ normal_attribute.save();
}
if (rotation_attribute) {
- rotation_attribute->save();
+ rotation_attribute.save();
}
}