[Bf-blender-cvs] [b356288a757] geometry-nodes: Geometry Nodes: change builtin attribute names based on T82693
Jacques Lucke
noreply at git.blender.org
Wed Nov 25 15:55:45 CET 2020
Commit: b356288a7574eda370263ecdc1df26d30b83d9e2
Author: Jacques Lucke
Date: Wed Nov 25 15:55:29 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rBb356288a7574eda370263ecdc1df26d30b83d9e2
Geometry Nodes: change builtin attribute names based on T82693
===================================================================
M source/blender/blenkernel/intern/attribute_access.cc
M source/blender/blenkernel/intern/hair.c
M source/blender/blenkernel/intern/pointcloud.cc
M source/blender/blenloader/intern/versioning_290.c
M source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index c3df7374fb0..ce56118e9ba 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -610,7 +610,7 @@ int PointCloudComponent::attribute_domain_size(const AttributeDomain domain) con
bool PointCloudComponent::attribute_is_builtin(const StringRef attribute_name) const
{
- return attribute_name == "Position";
+ return attribute_name == "position";
}
ReadAttributePtr PointCloudComponent::attribute_try_get_for_read(
@@ -742,7 +742,7 @@ int MeshComponent::attribute_domain_size(const AttributeDomain domain) const
bool MeshComponent::attribute_is_builtin(const StringRef attribute_name) const
{
- return attribute_name == "Position";
+ return attribute_name == "position";
}
ReadAttributePtr MeshComponent::attribute_try_get_for_read(const StringRef attribute_name) const
@@ -751,7 +751,7 @@ ReadAttributePtr MeshComponent::attribute_try_get_for_read(const StringRef attri
return {};
}
- if (attribute_name == "Position") {
+ if (attribute_name == "position") {
auto get_vertex_position = [](const MVert &vert) { return float3(vert.co); };
return std::make_unique<
blender::bke::DerivedArrayReadAttribute<MVert, float3, decltype(get_vertex_position)>>(
@@ -802,7 +802,7 @@ WriteAttributePtr MeshComponent::attribute_try_get_for_write(const StringRef att
BKE_mesh_update_customdata_pointers(mesh, false);
};
- if (attribute_name == "Position") {
+ if (attribute_name == "position") {
CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert);
update_mesh_pointers();
@@ -945,7 +945,7 @@ Set<std::string> MeshComponent::attribute_names() const
}
Set<std::string> names;
- names.add("Position");
+ names.add("position");
for (StringRef name : vertex_group_names_.keys()) {
names.add(name);
}
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 554919ad1a0..a44b054e366 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -49,8 +49,8 @@
#include "BLO_read_write.h"
-static const char *HAIR_ATTR_POSITION = "Position";
-static const char *HAIR_ATTR_RADIUS = "Radius";
+static const char *HAIR_ATTR_POSITION = "position";
+static const char *HAIR_ATTR_RADIUS = "radius";
/* Hair datablock */
diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc
index 108ce390271..dbb0a1bd569 100644
--- a/source/blender/blenkernel/intern/pointcloud.cc
+++ b/source/blender/blenkernel/intern/pointcloud.cc
@@ -54,8 +54,8 @@
static void pointcloud_random(PointCloud *pointcloud);
-const char *POINTCLOUD_ATTR_POSITION = "Position";
-const char *POINTCLOUD_ATTR_RADIUS = "Radius";
+const char *POINTCLOUD_ATTR_POSITION = "position";
+const char *POINTCLOUD_ATTR_RADIUS = "radius";
static void pointcloud_init_data(ID *id)
{
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index b591f57a7f1..68d22b36e5c 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -511,6 +511,20 @@ static void do_versions_point_attributes(CustomData *pdata)
}
}
+static void do_versions_point_attribute_names(CustomData *pdata)
+{
+ /* Change from capital initial letter to lower case (T82693). */
+ for (int i = 0; i < pdata->totlayer; i++) {
+ CustomDataLayer *layer = &pdata->layers[i];
+ if (layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, "Position")) {
+ STRNCPY(layer->name, "position");
+ }
+ else if (layer->type == CD_PROP_FLOAT && STREQ(layer->name, "Radius")) {
+ STRNCPY(layer->name, "radius");
+ }
+ }
+}
+
/* Move FCurve handles towards the control point in such a way that the curve itself doesn't
* change. Since 2.91 FCurves are computed slightly differently, which requires this update to keep
* the same animation result. Previous versions scaled down overlapping handles during evaluation.
@@ -1181,5 +1195,13 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Hair and PointCloud attributes names. */
+ LISTBASE_FOREACH (Hair *, hair, &bmain->hairs) {
+ do_versions_point_attribute_names(&hair->pdata);
+ }
+ LISTBASE_FOREACH (PointCloud *, pointcloud, &bmain->pointclouds) {
+ do_versions_point_attribute_names(&pointcloud->pdata);
+ }
}
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
index f3737ab95f6..2133d5fe65e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
@@ -40,11 +40,11 @@ static void add_instances_from_geometry_component(InstancesComponent &instances,
Object *object)
{
Float3ReadAttribute positions = src_geometry.attribute_get_for_read<float3>(
- "Position", ATTR_DOMAIN_POINT, {0, 0, 0});
+ "position", ATTR_DOMAIN_POINT, {0, 0, 0});
Float3ReadAttribute rotations = src_geometry.attribute_get_for_read<float3>(
- "Rotation", ATTR_DOMAIN_POINT, {0, 0, 0});
+ "rotation", ATTR_DOMAIN_POINT, {0, 0, 0});
Float3ReadAttribute scales = src_geometry.attribute_get_for_read<float3>(
- "Scale", ATTR_DOMAIN_POINT, {1, 1, 1});
+ "scale", ATTR_DOMAIN_POINT, {1, 1, 1});
for (const int i : IndexRange(positions.size())) {
instances.add_instance(object, positions[i], rotations[i], scales[i]);
More information about the Bf-blender-cvs
mailing list