[Bf-blender-cvs] [dabf96f732d] master: Attributes: support bool attribute in rna

Jacques Lucke noreply at git.blender.org
Thu Feb 11 13:45:49 CET 2021


Commit: dabf96f732d1ce5f44f53230317ff0d0b8a380df
Author: Jacques Lucke
Date:   Thu Feb 11 13:44:58 2021 +0100
Branches: master
https://developer.blender.org/rBdabf96f732d1ce5f44f53230317ff0d0b8a380df

Attributes: support bool attribute in rna

Differential Revision: https://developer.blender.org/D10387

===================================================================

M	source/blender/makesdna/DNA_meshdata_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_attribute.c

===================================================================

diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index f9af7a011e0..05be31262a6 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -271,6 +271,9 @@ typedef struct MIntProperty {
 typedef struct MStringProperty {
   char s[255], s_len;
 } MStringProperty;
+typedef struct MBoolProperty {
+  uint8_t b;
+} MBoolProperty;
 
 /** \} */
 
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 35b174f0da8..eaa2675573c 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -91,6 +91,7 @@ extern StructRNA RNA_BoidSettings;
 extern StructRNA RNA_BoidState;
 extern StructRNA RNA_Bone;
 extern StructRNA RNA_BoneGroup;
+extern StructRNA RNA_BoolAttribute;
 extern StructRNA RNA_BoolProperty;
 extern StructRNA RNA_BooleanModifier;
 extern StructRNA RNA_Brush;
diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c
index 7cd6e375a82..21b26b51e0a 100644
--- a/source/blender/makesrna/intern/rna_attribute.c
+++ b/source/blender/makesrna/intern/rna_attribute.c
@@ -169,6 +169,9 @@ static void rna_Attribute_data_begin(CollectionPropertyIterator *iter, PointerRN
     case CD_PROP_STRING:
       struct_size = sizeof(MStringProperty);
       break;
+    case CD_PROP_BOOL:
+      struct_size = sizeof(MBoolProperty);
+      break;
     default:
       struct_size = 0;
       length = 0;
@@ -299,6 +302,9 @@ PointerRNA rna_AttributeGroup_iterator_get(CollectionPropertyIterator *iter)
     case CD_PROP_STRING:
       type = &RNA_StringAttribute;
       break;
+    case CD_PROP_BOOL:
+      type = &RNA_BoolAttribute;
+      break;
     default:
       return PointerRNA_NULL;
   }
@@ -555,6 +561,34 @@ static void rna_def_attribute_string(BlenderRNA *brna)
   RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
 }
 
+static void rna_def_attribute_bool(BlenderRNA *brna)
+{
+  StructRNA *srna;
+  PropertyRNA *prop;
+
+  srna = RNA_def_struct(brna, "BoolAttribute", "Attribute");
+  RNA_def_struct_sdna(srna, "CustomDataLayer");
+  RNA_def_struct_ui_text(srna, "Bool Attribute", "Bool geometry attribute");
+
+  prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
+  RNA_def_property_struct_type(prop, "BoolAttributeValue");
+  RNA_def_property_collection_funcs(prop,
+                                    "rna_Attribute_data_begin",
+                                    "rna_iterator_array_next",
+                                    "rna_iterator_array_end",
+                                    "rna_iterator_array_get",
+                                    "rna_Attribute_data_length",
+                                    NULL,
+                                    NULL,
+                                    NULL);
+
+  srna = RNA_def_struct(brna, "BoolAttributeValue", NULL);
+  RNA_def_struct_sdna(srna, "MBoolProperty");
+  RNA_def_struct_ui_text(srna, "Bool Attribute Value", "Bool value in geometry attribute");
+  prop = RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "b", 0x01);
+}
+
 static void rna_def_attribute(BlenderRNA *brna)
 {
   PropertyRNA *prop;
@@ -592,6 +626,7 @@ static void rna_def_attribute(BlenderRNA *brna)
   rna_def_attribute_byte_color(brna);
   rna_def_attribute_int(brna);
   rna_def_attribute_string(brna);
+  rna_def_attribute_bool(brna);
 }
 
 /* Mesh/PointCloud/Hair.attributes */



More information about the Bf-blender-cvs mailing list