Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_attribute.c
| Show All 39 Lines | |||||
| const EnumPropertyItem rna_enum_attribute_type_items[] = { | const EnumPropertyItem rna_enum_attribute_type_items[] = { | ||||
| {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"}, | {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"}, | ||||
| {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"}, | {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"}, | ||||
| {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"}, | {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"}, | ||||
| {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with floating-point precisions"}, | {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Color", "RGBA color with floating-point precisions"}, | ||||
| {CD_MLOOPCOL, "BYTE_COLOR", 0, "Byte Color", "RGBA color with 8-bit precision"}, | {CD_MLOOPCOL, "BYTE_COLOR", 0, "Byte Color", "RGBA color with 8-bit precision"}, | ||||
| {CD_PROP_STRING, "STRING", 0, "String", "Text string"}, | {CD_PROP_STRING, "STRING", 0, "String", "Text string"}, | ||||
| {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"}, | {CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"}, | ||||
| {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"}, | |||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| const EnumPropertyItem rna_enum_attribute_domain_items[] = { | const EnumPropertyItem rna_enum_attribute_domain_items[] = { | ||||
| /* Not implement yet */ | /* Not implement yet */ | ||||
| // {ATTR_DOMAIN_GEOMETRY, "GEOMETRY", 0, "Geometry", "Attribute on (whole) geometry"}, | // {ATTR_DOMAIN_GEOMETRY, "GEOMETRY", 0, "Geometry", "Attribute on (whole) geometry"}, | ||||
| {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, | {ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"}, | ||||
| {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, | {ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"}, | ||||
| Show All 35 Lines | switch (type) { | ||||
| case CD_PROP_COLOR: | case CD_PROP_COLOR: | ||||
| return &RNA_FloatColorAttribute; | return &RNA_FloatColorAttribute; | ||||
| case CD_MLOOPCOL: | case CD_MLOOPCOL: | ||||
| return &RNA_ByteColorAttribute; | return &RNA_ByteColorAttribute; | ||||
| case CD_PROP_STRING: | case CD_PROP_STRING: | ||||
| return &RNA_StringAttribute; | return &RNA_StringAttribute; | ||||
| case CD_PROP_BOOL: | case CD_PROP_BOOL: | ||||
| return &RNA_BoolAttribute; | return &RNA_BoolAttribute; | ||||
| case CD_PROP_FLOAT2: | |||||
| return &RNA_Float2Attribute; | |||||
| default: | default: | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| } | } | ||||
| static StructRNA *rna_Attribute_refine(PointerRNA *ptr) | static StructRNA *rna_Attribute_refine(PointerRNA *ptr) | ||||
| { | { | ||||
| CustomDataLayer *layer = ptr->data; | CustomDataLayer *layer = ptr->data; | ||||
| ▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | case CD_MLOOPCOL: | ||||
| struct_size = sizeof(MLoopCol); | struct_size = sizeof(MLoopCol); | ||||
| break; | break; | ||||
| case CD_PROP_STRING: | case CD_PROP_STRING: | ||||
| struct_size = sizeof(MStringProperty); | struct_size = sizeof(MStringProperty); | ||||
| break; | break; | ||||
| case CD_PROP_BOOL: | case CD_PROP_BOOL: | ||||
| struct_size = sizeof(MBoolProperty); | struct_size = sizeof(MBoolProperty); | ||||
| break; | break; | ||||
| case CD_PROP_FLOAT2: | |||||
| struct_size = sizeof(float[2]); | |||||
| break; | |||||
| default: | default: | ||||
| struct_size = 0; | struct_size = 0; | ||||
| length = 0; | length = 0; | ||||
| break; | break; | ||||
| } | } | ||||
| rna_iterator_array_begin(iter, layer->data, struct_size, length, 0, NULL); | rna_iterator_array_begin(iter, layer->data, struct_size, length, 0, NULL); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | static void rna_def_attribute_bool(BlenderRNA *brna) | ||||
| srna = RNA_def_struct(brna, "BoolAttributeValue", NULL); | srna = RNA_def_struct(brna, "BoolAttributeValue", NULL); | ||||
| RNA_def_struct_sdna(srna, "MBoolProperty"); | RNA_def_struct_sdna(srna, "MBoolProperty"); | ||||
| RNA_def_struct_ui_text(srna, "Bool Attribute Value", "Bool value in geometry attribute"); | RNA_def_struct_ui_text(srna, "Bool Attribute Value", "Bool value in geometry attribute"); | ||||
| prop = RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "value", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "b", 0x01); | RNA_def_property_boolean_sdna(prop, NULL, "b", 0x01); | ||||
| } | } | ||||
| static void rna_def_attribute_float2(BlenderRNA *brna) | |||||
| { | |||||
| StructRNA *srna; | |||||
| PropertyRNA *prop; | |||||
| /* Float2 Attribute */ | |||||
| srna = RNA_def_struct(brna, "Float2Attribute", "Attribute"); | |||||
| RNA_def_struct_sdna(srna, "CustomDataLayer"); | |||||
| RNA_def_struct_ui_text( | |||||
| srna, "Float2 Attribute", "2D vector geometry attribute, with floating-point precision"); | |||||
| prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); | |||||
| RNA_def_property_struct_type(prop, "Float2AttributeValue"); | |||||
| 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); | |||||
| /* Float2 Attribute Value */ | |||||
| srna = RNA_def_struct(brna, "Float2AttributeValue", NULL); | |||||
| RNA_def_struct_sdna(srna, "vec2f"); | |||||
| RNA_def_struct_ui_text(srna, "Float2 Attribute Value", "2D Vector value in geometry attribute"); | |||||
| prop = RNA_def_property(srna, "vector", PROP_FLOAT, PROP_DIRECTION); | |||||
| RNA_def_property_ui_text(prop, "Vector", "2D vector"); | |||||
| RNA_def_property_float_sdna(prop, NULL, "x"); | |||||
| RNA_def_property_array(prop, 2); | |||||
| RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); | |||||
| } | |||||
| static void rna_def_attribute(BlenderRNA *brna) | static void rna_def_attribute(BlenderRNA *brna) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| srna = RNA_def_struct(brna, "Attribute", NULL); | srna = RNA_def_struct(brna, "Attribute", NULL); | ||||
| RNA_def_struct_sdna(srna, "CustomDataLayer"); | RNA_def_struct_sdna(srna, "CustomDataLayer"); | ||||
| RNA_def_struct_ui_text(srna, "Attribute", "Geometry attribute"); | RNA_def_struct_ui_text(srna, "Attribute", "Geometry attribute"); | ||||
| Show All 23 Lines | static void rna_def_attribute(BlenderRNA *brna) | ||||
| /* types */ | /* types */ | ||||
| rna_def_attribute_float(brna); | rna_def_attribute_float(brna); | ||||
| rna_def_attribute_float_vector(brna); | rna_def_attribute_float_vector(brna); | ||||
| rna_def_attribute_float_color(brna); | rna_def_attribute_float_color(brna); | ||||
| rna_def_attribute_byte_color(brna); | rna_def_attribute_byte_color(brna); | ||||
| rna_def_attribute_int(brna); | rna_def_attribute_int(brna); | ||||
| rna_def_attribute_string(brna); | rna_def_attribute_string(brna); | ||||
| rna_def_attribute_bool(brna); | rna_def_attribute_bool(brna); | ||||
| rna_def_attribute_float2(brna); | |||||
| } | } | ||||
| /* Mesh/PointCloud/Hair.attributes */ | /* Mesh/PointCloud/Hair.attributes */ | ||||
| static void rna_def_attribute_group(BlenderRNA *brna) | static void rna_def_attribute_group(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| FunctionRNA *func; | FunctionRNA *func; | ||||
| ▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines | |||||