[Bf-blender-cvs] [df2c96e8a98] virtual-array-attributes: progress
Jacques Lucke
noreply at git.blender.org
Mon Apr 12 18:27:56 CEST 2021
Commit: df2c96e8a98a34956c51f84962eee515f94a8a77
Author: Jacques Lucke
Date: Mon Apr 12 17:35:38 2021 +0200
Branches: virtual-array-attributes
https://developer.blender.org/rBdf2c96e8a98a34956c51f84962eee515f94a8a77
progress
===================================================================
M source/blender/blenkernel/BKE_attribute_access.hh
M source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
M source/blender/nodes/NOD_geometry_exec.hh
M source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_clamp.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh
index c4fa16c626e..78e758e94f0 100644
--- a/source/blender/blenkernel/BKE_attribute_access.hh
+++ b/source/blender/blenkernel/BKE_attribute_access.hh
@@ -83,6 +83,11 @@ class MaybeUnsavedWriteAttribute {
return varray_.get() != nullptr;
}
+ GVMutableArray &operator*()
+ {
+ return *varray_;
+ }
+
GVMutableArray &varray()
{
return *varray_;
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index 337e1e68f1a..52b5d3101cb 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -76,35 +76,36 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values(
{
std::lock_guard lock{mutex_};
- bke::ReadAttributePtr attribute_ptr = component_->attribute_try_get_for_read(column_id.name);
- if (!attribute_ptr) {
+ bke::ReadAttributeLookup attribute = component_->attribute_try_get_for_read(column_id.name);
+ if (!attribute) {
return {};
}
- const bke::ReadAttribute *attribute = scope_.add(std::move(attribute_ptr), __func__);
- if (attribute->domain() != domain_) {
+ const fn::GVArray *varray = scope_.add(std::move(attribute.varray), __func__);
+ if (attribute.domain != domain_) {
return {};
}
- int domain_size = attribute->size();
- switch (attribute->custom_data_type()) {
+ int domain_size = varray->size();
+ const CustomDataType type = bke::cpp_type_to_custom_data_type(varray->type());
+ switch (type) {
case CD_PROP_FLOAT:
return column_values_from_function(
- column_id.name, domain_size, [attribute](int index, CellValue &r_cell_value) {
+ column_id.name, domain_size, [varray](int index, CellValue &r_cell_value) {
float value;
- attribute->get(index, &value);
+ varray->get(index, &value);
r_cell_value.value_float = value;
});
case CD_PROP_INT32:
return column_values_from_function(
- column_id.name, domain_size, [attribute](int index, CellValue &r_cell_value) {
+ column_id.name, domain_size, [varray](int index, CellValue &r_cell_value) {
int value;
- attribute->get(index, &value);
+ varray->get(index, &value);
r_cell_value.value_int = value;
});
case CD_PROP_BOOL:
return column_values_from_function(
- column_id.name, domain_size, [attribute](int index, CellValue &r_cell_value) {
+ column_id.name, domain_size, [varray](int index, CellValue &r_cell_value) {
bool value;
- attribute->get(index, &value);
+ varray->get(index, &value);
r_cell_value.value_bool = value;
});
case CD_PROP_FLOAT2: {
@@ -114,11 +115,9 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values(
const std::array<const char *, 2> suffixes = {" X", " Y"};
const std::string name = StringRef(column_id.name) + suffixes[column_id.index];
return column_values_from_function(
- name,
- domain_size,
- [attribute, axis = column_id.index](int index, CellValue &r_cell_value) {
+ name, domain_size, [varray, axis = column_id.index](int index, CellValue &r_cell_value) {
float2 value;
- attribute->get(index, &value);
+ varray->get(index, &value);
r_cell_value.value_float = value[axis];
});
}
@@ -129,11 +128,9 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values(
const std::array<const char *, 3> suffixes = {" X", " Y", " Z"};
const std::string name = StringRef(column_id.name) + suffixes[column_id.index];
return column_values_from_function(
- name,
- domain_size,
- [attribute, axis = column_id.index](int index, CellValue &r_cell_value) {
+ name, domain_size, [varray, axis = column_id.index](int index, CellValue &r_cell_value) {
float3 value;
- attribute->get(index, &value);
+ varray->get(index, &value);
r_cell_value.value_float = value[axis];
});
}
@@ -144,11 +141,9 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values(
const std::array<const char *, 4> suffixes = {" R", " G", " B", " A"};
const std::string name = StringRef(column_id.name) + suffixes[column_id.index];
return column_values_from_function(
- name,
- domain_size,
- [attribute, axis = column_id.index](int index, CellValue &r_cell_value) {
+ name, domain_size, [varray, axis = column_id.index](int index, CellValue &r_cell_value) {
Color4f value;
- attribute->get(index, &value);
+ varray->get(index, &value);
r_cell_value.value_float = value[axis];
});
}
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh
index 5d1a217db9b..4cbdf5d9d9d 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -33,29 +33,19 @@ struct ModifierData;
namespace blender::nodes {
-using bke::BooleanReadAttribute;
-using bke::BooleanWriteAttribute;
-using bke::Color4fReadAttribute;
-using bke::Color4fWriteAttribute;
-using bke::Float2ReadAttribute;
-using bke::Float2WriteAttribute;
-using bke::Float3ReadAttribute;
-using bke::Float3WriteAttribute;
-using bke::FloatReadAttribute;
-using bke::FloatWriteAttribute;
using bke::geometry_set_realize_instances;
-using bke::Int32ReadAttribute;
-using bke::Int32WriteAttribute;
+using bke::MaybeUnsavedWriteAttribute;
using bke::PersistentDataHandleMap;
using bke::PersistentObjectHandle;
-using bke::ReadAttribute;
-using bke::ReadAttributePtr;
-using bke::WriteAttribute;
-using bke::WriteAttributePtr;
+using bke::ReadAttributeLookup;
+using bke::WriteAttributeLookup;
using fn::CPPType;
using fn::GMutablePointer;
using fn::GPointer;
using fn::GValueMap;
+using fn::GVArray;
+using fn::GVArray_Typed;
+using fn::GVMutableArray_Typed;
class GeoNodeExecParams {
private:
@@ -217,17 +207,17 @@ class GeoNodeExecParams {
* \note This will add an error message if the string socket is active and
* the input attribute does not exist.
*/
- ReadAttributePtr get_input_attribute(const StringRef name,
- const GeometryComponent &component,
- const AttributeDomain domain,
- const CustomDataType type,
- const void *default_value) const;
+ std::unique_ptr<GVArray> get_input_attribute(const StringRef name,
+ const GeometryComponent &component,
+ const AttributeDomain domain,
+ const CustomDataType type,
+ const void *default_value) const;
template<typename T>
- bke::TypedReadAttribute<T> get_input_attribute(const StringRef name,
- const GeometryComponent &component,
- const AttributeDomain domain,
- const T &default_value) const
+ fn::GVArray_Typed<T> get_input_attribute(const StringRef name,
+ const GeometryComponent &component,
+ const AttributeDomain domain,
+ const T &default_value) const
{
const CustomDataType type = bke::cpp_type_to_custom_data_type(CPPType::get<T>());
return this->get_input_attribute(name, component, domain, type, &default_value);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
index f10b81a33b4..0efa8bdc155 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
@@ -50,10 +50,10 @@ static void geo_node_align_rotation_to_vector_layout(uiLayout *layout,
namespace blender::nodes {
-static void align_rotations_auto_pivot(const Float3ReadAttribute &vectors,
- const FloatReadAttribute &factors,
+static void align_rotations_auto_pivot(const VArray<float3> &vectors,
+ const VArray<float> &factors,
const float3 local_main_axis,
- MutableSpan<float3> rotations)
+ VMutableArray<float3> &rotations)
{
for (const int i : IndexRange(vectors.size())) {
const float3 vector = vectors[i];
@@ -93,11 +93,11 @@ static void align_rotations_auto_pivot(const Float3ReadAttribute &vectors,
}
}
-static void align_rotations_fixed_pivot(const Float3ReadAttribute &vectors,
- const FloatReadAttribute &factors,
+static void align_rotations_fixed_pivot(const VArray<float3> &vectors,
+ const VArray<float> &factors,
const float3 local_main_axis,
const float3 local_pivot_axis,
- MutableSpan<float3> rotations)
+ VMutableArray<float3> &rotations)
{
if (local_main_axis == local_pivot_axis) {
/* Can't compute any meaningful rotation angle in this case. */
@@ -144,30 +144,31 @@ static void align_rotations_on_component(GeometryComponent &component,
const NodeGeometryAlignRotationToVector &storage = *(const NodeGeometryAlignRotationToVector *)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list