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:
authorBrecht Van Lommel <brecht@blender.org>2020-08-04 13:52:04 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-09-09 18:01:17 +0300
commita1397a3cc69382a64ab97bb71e4769fc0add0791 (patch)
tree3ed860ff99a6a2469e6a11bc5de9304284d502d8 /source/blender/blenkernel/intern/hair.c
parent565510bd7fd87ae146cabafb27f1dfd550450f58 (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/hair.c')
-rw-r--r--source/blender/blenkernel/intern/hair.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 8831d09698b..314b7228373 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -47,6 +47,9 @@
#include "DEG_depsgraph_query.h"
+const char *HAIR_ATTR_POSITION = "Position";
+const char *HAIR_ATTR_RADIUS = "Radius";
+
/* Hair datablock */
static void hair_random(Hair *hair);
@@ -61,8 +64,10 @@ static void hair_init_data(ID *id)
CustomData_reset(&hair->pdata);
CustomData_reset(&hair->cdata);
- CustomData_add_layer(&hair->pdata, CD_LOCATION, CD_CALLOC, NULL, hair->totpoint);
- CustomData_add_layer(&hair->pdata, CD_RADIUS, CD_CALLOC, NULL, hair->totpoint);
+ CustomData_add_layer_named(
+ &hair->pdata, CD_PROP_FLOAT3, CD_CALLOC, NULL, hair->totpoint, HAIR_ATTR_POSITION);
+ CustomData_add_layer_named(
+ &hair->pdata, CD_PROP_FLOAT, CD_CALLOC, NULL, hair->totpoint, HAIR_ATTR_RADIUS);
CustomData_add_layer(&hair->cdata, CD_HAIRCURVE, CD_CALLOC, NULL, hair->totcurve);
BKE_hair_update_customdata_pointers(hair);
@@ -222,12 +227,17 @@ BoundBox *BKE_hair_boundbox_get(Object *ob)
void BKE_hair_update_customdata_pointers(Hair *hair)
{
- hair->co = CustomData_get_layer(&hair->pdata, CD_LOCATION);
- hair->radius = CustomData_get_layer(&hair->pdata, CD_RADIUS);
+ hair->co = CustomData_get_layer_named(&hair->pdata, CD_PROP_FLOAT3, HAIR_ATTR_POSITION);
+ hair->radius = CustomData_get_layer_named(&hair->pdata, CD_PROP_FLOAT, HAIR_ATTR_RADIUS);
hair->curves = CustomData_get_layer(&hair->cdata, CD_HAIRCURVE);
hair->mapping = CustomData_get_layer(&hair->cdata, CD_HAIRMAPPING);
}
+bool BKE_hair_customdata_required(Hair *UNUSED(hair), CustomDataLayer *layer)
+{
+ return layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, HAIR_ATTR_POSITION);
+}
+
/* Dependency Graph */
Hair *BKE_hair_new_for_eval(const Hair *hair_src, int totpoint, int totcurve)
@@ -294,7 +304,8 @@ static Hair *hair_evaluate_modifiers(struct Depsgraph *depsgraph,
}
/* Ensure we are not overwriting referenced data. */
- CustomData_duplicate_referenced_layer(&hair->pdata, CD_LOCATION, hair->totpoint);
+ CustomData_duplicate_referenced_layer_named(
+ &hair->pdata, CD_PROP_FLOAT3, HAIR_ATTR_POSITION, hair->totpoint);
BKE_hair_update_customdata_pointers(hair);
/* Created deformed coordinates array on demand. */