diff options
author | Brecht Van Lommel <brecht@blender.org> | 2020-08-04 13:52:04 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-09-09 18:01:17 +0300 |
commit | a1397a3cc69382a64ab97bb71e4769fc0add0791 (patch) | |
tree | 3ed860ff99a6a2469e6a11bc5de9304284d502d8 /source/blender/blenkernel/intern/pointcloud.c | |
parent | 565510bd7fd87ae146cabafb27f1dfd550450f58 (diff) |
Geometry: use generic attributes for Hair and Point Clouds
Instead of custom data layer with special types, using general Vector and Float
attributes.
Ref T76659
Differential Revision: https://developer.blender.org/D8635
Diffstat (limited to 'source/blender/blenkernel/intern/pointcloud.c')
-rw-r--r-- | source/blender/blenkernel/intern/pointcloud.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c index fb10c9f03e3..087bf123575 100644 --- a/source/blender/blenkernel/intern/pointcloud.c +++ b/source/blender/blenkernel/intern/pointcloud.c @@ -51,6 +51,9 @@ static void pointcloud_random(PointCloud *pointcloud); +const char *POINTCLOUD_ATTR_POSITION = "Position"; +const char *POINTCLOUD_ATTR_RADIUS = "Radius"; + static void pointcloud_init_data(ID *id) { PointCloud *pointcloud = (PointCloud *)id; @@ -59,8 +62,18 @@ static void pointcloud_init_data(ID *id) MEMCPY_STRUCT_AFTER(pointcloud, DNA_struct_default_get(PointCloud), id); CustomData_reset(&pointcloud->pdata); - CustomData_add_layer(&pointcloud->pdata, CD_LOCATION, CD_CALLOC, NULL, pointcloud->totpoint); - CustomData_add_layer(&pointcloud->pdata, CD_RADIUS, CD_CALLOC, NULL, pointcloud->totpoint); + CustomData_add_layer_named(&pointcloud->pdata, + CD_PROP_FLOAT3, + CD_CALLOC, + NULL, + pointcloud->totpoint, + POINTCLOUD_ATTR_POSITION); + CustomData_add_layer_named(&pointcloud->pdata, + CD_PROP_FLOAT, + CD_CALLOC, + NULL, + pointcloud->totpoint, + POINTCLOUD_ATTR_RADIUS); BKE_pointcloud_update_customdata_pointers(pointcloud); pointcloud_random(pointcloud); @@ -189,8 +202,15 @@ BoundBox *BKE_pointcloud_boundbox_get(Object *ob) void BKE_pointcloud_update_customdata_pointers(PointCloud *pointcloud) { - pointcloud->co = CustomData_get_layer(&pointcloud->pdata, CD_LOCATION); - pointcloud->radius = CustomData_get_layer(&pointcloud->pdata, CD_RADIUS); + pointcloud->co = CustomData_get_layer_named( + &pointcloud->pdata, CD_PROP_FLOAT3, POINTCLOUD_ATTR_POSITION); + pointcloud->radius = CustomData_get_layer_named( + &pointcloud->pdata, CD_PROP_FLOAT, POINTCLOUD_ATTR_RADIUS); +} + +bool BKE_pointcloud_customdata_required(PointCloud *UNUSED(pointcloud), CustomDataLayer *layer) +{ + return layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, POINTCLOUD_ATTR_POSITION); } /* Dependency Graph */ @@ -259,7 +279,8 @@ static PointCloud *pointcloud_evaluate_modifiers(struct Depsgraph *depsgraph, } /* Ensure we are not overwriting referenced data. */ - CustomData_duplicate_referenced_layer(&pointcloud->pdata, CD_LOCATION, pointcloud->totpoint); + CustomData_duplicate_referenced_layer_named( + &pointcloud->pdata, CD_PROP_FLOAT3, POINTCLOUD_ATTR_POSITION, pointcloud->totpoint); BKE_pointcloud_update_customdata_pointers(pointcloud); /* Created deformed coordinates array on demand. */ |