|
|
|
@ -1334,74 +1334,6 @@ static void rna_mesh_color_active_set(PointerRNA *ptr, bool value)
|
|
|
|
|
BKE_id_attributes_active_color_set(&mesh->id, layer->name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sculpt_vertex_color_layers */
|
|
|
|
|
|
|
|
|
|
DEFINE_CUSTOMDATA_LAYER_COLLECTION(sculpt_vertex_color, vdata, CD_PROP_COLOR)
|
|
|
|
|
|
|
|
|
|
static PointerRNA rna_Mesh_sculpt_vertex_color_active_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Mesh *mesh = (Mesh *)ptr->data;
|
|
|
|
|
CustomDataLayer *layer = BKE_id_attribute_search(
|
|
|
|
|
&mesh->id, mesh->active_color_attribute, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_POINT);
|
|
|
|
|
return rna_pointer_inherit_refine(ptr, &RNA_MeshVertColorLayer, layer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Mesh_sculpt_vertex_color_active_set(PointerRNA *ptr,
|
|
|
|
|
const PointerRNA value,
|
|
|
|
|
ReportList *UNUSED(reports))
|
|
|
|
|
{
|
|
|
|
|
Mesh *mesh = (Mesh *)ptr->data;
|
|
|
|
|
CustomDataLayer *layer = (CustomDataLayer *)value.data;
|
|
|
|
|
|
|
|
|
|
if (!layer) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_id_attributes_active_color_set(&mesh->id, layer->name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_Mesh_sculpt_vertex_color_active_index_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Mesh *mesh = (Mesh *)ptr->data;
|
|
|
|
|
CustomDataLayer *layer = BKE_id_attribute_search(
|
|
|
|
|
&mesh->id, mesh->active_color_attribute, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_POINT);
|
|
|
|
|
if (!layer) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
CustomData *vdata = rna_mesh_vdata(ptr);
|
|
|
|
|
return layer - vdata->layers + CustomData_get_layer_index(vdata, CD_PROP_COLOR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Mesh_sculpt_vertex_color_active_index_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
|
|
|
|
Mesh *mesh = (Mesh *)ptr->data;
|
|
|
|
|
CustomData *vdata = rna_mesh_vdata(ptr);
|
|
|
|
|
|
|
|
|
|
if (value < 0 || value >= CustomData_number_of_layers(vdata, CD_PROP_COLOR)) {
|
|
|
|
|
fprintf(stderr, "Invalid loop byte attribute index %d\n", value);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomDataLayer *layer = vdata->layers + CustomData_get_layer_index(vdata, CD_PROP_COLOR) +
|
|
|
|
|
value;
|
|
|
|
|
|
|
|
|
|
BKE_id_attributes_active_color_set(&mesh->id, layer->name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_MeshVertColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Mesh *me = rna_mesh(ptr);
|
|
|
|
|
CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
|
|
|
|
|
rna_iterator_array_begin(
|
|
|
|
|
iter, layer->data, sizeof(MPropCol), (me->edit_mesh) ? 0 : me->totvert, 0, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_MeshVertColorLayer_data_length(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Mesh *me = rna_mesh(ptr);
|
|
|
|
|
return (me->edit_mesh) ? 0 : me->totvert;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_float_layer_check(CollectionPropertyIterator *UNUSED(iter), void *data)
|
|
|
|
|
{
|
|
|
|
|
CustomDataLayer *layer = (CustomDataLayer *)data;
|
|
|
|
@ -2319,19 +2251,6 @@ static char *rna_MeshColor_path(const PointerRNA *ptr)
|
|
|
|
|
return rna_LoopCustomData_data_path(ptr, "vertex_colors", CD_PROP_BYTE_COLOR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *rna_MeshVertColorLayer_path(const PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
const CustomDataLayer *cdl = ptr->data;
|
|
|
|
|
char name_esc[sizeof(cdl->name) * 2];
|
|
|
|
|
BLI_str_escape(name_esc, cdl->name, sizeof(name_esc));
|
|
|
|
|
return BLI_sprintfN("sculpt_vertex_colors[\"%s\"]", name_esc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *rna_MeshVertColor_path(const PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
return rna_VertCustomData_data_path(ptr, "sculpt_vertex_colors", CD_PROP_COLOR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**** Float Property Layer API ****/
|
|
|
|
|
static char *rna_MeshVertexFloatPropertyLayer_path(const PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
@ -2561,32 +2480,6 @@ static void rna_Mesh_vertex_color_remove(struct Mesh *me,
|
|
|
|
|
BKE_id_attribute_remove(&me->id, layer->name, reports);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PointerRNA rna_Mesh_sculpt_vertex_color_new(struct Mesh *me,
|
|
|
|
|
ReportList *reports,
|
|
|
|
|
const char *name,
|
|
|
|
|
const bool do_init)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
CustomData *vdata;
|
|
|
|
|
CustomDataLayer *cdl = NULL;
|
|
|
|
|
int index = ED_mesh_sculpt_color_add(me, name, do_init, reports);
|
|
|
|
|
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
vdata = rna_mesh_vdata_helper(me);
|
|
|
|
|
cdl = &vdata->layers[CustomData_get_layer_index_n(vdata, CD_PROP_COLOR, index)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_pointer_create(&me->id, &RNA_MeshVertColorLayer, cdl, &ptr);
|
|
|
|
|
return ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Mesh_sculpt_vertex_color_remove(struct Mesh *me,
|
|
|
|
|
ReportList *reports,
|
|
|
|
|
CustomDataLayer *layer)
|
|
|
|
|
{
|
|
|
|
|
BKE_id_attribute_remove(&me->id, layer->name, reports);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# define DEFINE_CUSTOMDATA_PROPERTY_API( \
|
|
|
|
|
elemname, datatype, cd_prop_type, cdata, countvar, layertype) \
|
|
|
|
|
static PointerRNA rna_Mesh_##elemname##_##datatype##_property_new(struct Mesh *me, \
|
|
|
|
@ -3319,65 +3212,6 @@ static void rna_def_mloopcol(BlenderRNA *brna)
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_def_MPropCol(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
srna = RNA_def_struct(brna, "MeshVertColorLayer", NULL);
|
|
|
|
|
RNA_def_struct_ui_text(srna,
|
|
|
|
|
"Mesh Sculpt Vertex Color Layer",
|
|
|
|
|
"Layer of sculpt vertex colors in a Mesh data-block");
|
|
|
|
|
RNA_def_struct_sdna(srna, "CustomDataLayer");
|
|
|
|
|
RNA_def_struct_path_func(srna, "rna_MeshVertColorLayer_path");
|
|
|
|
|
RNA_def_struct_ui_icon(srna, ICON_GROUP_VCOL);
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
|
|
|
|
RNA_def_struct_name_property(srna, prop);
|
|
|
|
|
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshVertexLayer_name_set");
|
|
|
|
|
RNA_def_property_string_maxlength(prop, MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Name", "Name of Sculpt Vertex color layer");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_mesh_color_active_get", "rna_mesh_color_active_set");
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Active", "Sets the sculpt vertex color layer as active for display and editing");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
|
|
|
|
|
RNA_def_property_boolean_funcs(
|
|
|
|
|
prop, "rna_mesh_color_active_render_get", "rna_mesh_color_active_render_set");
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Active Render", "Sets the sculpt vertex color layer as active for rendering");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "MeshVertColor");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Data", "");
|
|
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
|
|
|
|
|
RNA_def_property_collection_funcs(prop,
|
|
|
|
|
"rna_MeshVertColorLayer_data_begin",
|
|
|
|
|
"rna_iterator_array_next",
|
|
|
|
|
"rna_iterator_array_end",
|
|
|
|
|
"rna_iterator_array_get",
|
|
|
|
|
"rna_MeshVertColorLayer_data_length",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
srna = RNA_def_struct(brna, "MeshVertColor", NULL);
|
|
|
|
|
RNA_def_struct_sdna(srna, "MPropCol");
|
|
|
|
|
RNA_def_struct_ui_text(srna, "Mesh Sculpt Vertex Color", "Vertex colors in a Mesh");
|
|
|
|
|
RNA_def_struct_path_func(srna, "rna_MeshVertColor_path");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
|
|
|
|
|
RNA_def_property_array(prop, 4);
|
|
|
|
|
RNA_def_property_range(prop, 0.0f, 1.0f);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Color", "");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
|
|
|
|
|
}
|
|
|
|
|
static void rna_def_mproperties(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
@ -3740,61 +3574,6 @@ static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_def_vert_colors(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
|
|
|
|
RNA_def_property_srna(cprop, "VertColors");
|
|
|
|
|
srna = RNA_def_struct(brna, "VertColors", NULL);
|
|
|
|
|
RNA_def_struct_sdna(srna, "Mesh");
|
|
|
|
|
RNA_def_struct_ui_text(srna, "Vert Colors", "Collection of sculpt vertex colors");
|
|
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "new", "rna_Mesh_sculpt_vertex_color_new");
|
|
|
|
|
RNA_def_function_ui_description(func, "Add a sculpt vertex color layer to Mesh");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
|
|
|
RNA_def_string(func, "name", "Col", 0, "", "Sculpt Vertex color name");
|
|
|
|
|
RNA_def_boolean(func,
|
|
|
|
|
"do_init",
|
|
|
|
|
true,
|
|
|
|
|
"",
|
|
|
|
|
"Whether new layer's data should be initialized by copying current active one");
|
|
|
|
|
parm = RNA_def_pointer(func, "layer", "MeshVertColorLayer", "", "The newly created layer");
|
|
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
|
|
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "remove", "rna_Mesh_sculpt_vertex_color_remove");
|
|
|
|
|
RNA_def_function_ui_description(func, "Remove a vertex color layer");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
|
|
|
parm = RNA_def_pointer(func, "layer", "MeshVertColorLayer", "", "The layer to remove");
|
|
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
|
|
|
|
RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "MeshVertColorLayer");
|
|
|
|
|
RNA_def_property_pointer_funcs(prop,
|
|
|
|
|
"rna_Mesh_sculpt_vertex_color_active_get",
|
|
|
|
|
"rna_Mesh_sculpt_vertex_color_active_set",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Active Sculpt Vertex Color Layer", "Active sculpt vertex color layer");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_int_funcs(prop,
|
|
|
|
|
"rna_Mesh_sculpt_vertex_color_active_index_get",
|
|
|
|
|
"rna_Mesh_sculpt_vertex_color_active_index_set",
|
|
|
|
|
"rna_Mesh_sculpt_vertex_color_index_range");
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Active Sculpt Vertex Color Index", "Active sculpt vertex color index");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_edit_active_color");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_def_uv_layers(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
@ -4469,26 +4248,6 @@ static void rna_def_mesh(BlenderRNA *brna)
|
|
|
|
|
"Legacy vertex color layers. Deprecated, use color attributes instead");
|
|
|
|
|
rna_def_loop_colors(brna, prop);
|
|
|
|
|
|
|
|
|
|
/* Sculpt Vertex colors */
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "sculpt_vertex_colors", PROP_COLLECTION, PROP_NONE);
|
|
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
|
|
|
|
|
RNA_def_property_collection_funcs(prop,
|
|
|
|
|
"rna_Mesh_sculpt_vertex_colors_begin",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
"rna_Mesh_sculpt_vertex_colors_length",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
RNA_def_property_struct_type(prop, "MeshVertColorLayer");
|
|
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
|
|
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Sculpt Vertex Colors",
|
|
|
|
|
"Sculpt vertex color layers. Deprecated, use color attributes instead");
|
|
|
|
|
rna_def_vert_colors(brna, prop);
|
|
|
|
|
|
|
|
|
|
/* TODO: edge customdata layers (bmesh py api can access already). */
|
|
|
|
|
prop = RNA_def_property(srna, "vertex_layers_float", PROP_COLLECTION, PROP_NONE);
|
|
|
|
|
RNA_def_property_collection_sdna(prop, NULL, "vdata.layers", "vdata.totlayer");
|
|
|
|
@ -4912,7 +4671,6 @@ void RNA_def_mesh(BlenderRNA *brna)
|
|
|
|
|
rna_def_mpolygon(brna);
|
|
|
|
|
rna_def_mloopuv(brna);
|
|
|
|
|
rna_def_mloopcol(brna);
|
|
|
|
|
rna_def_MPropCol(brna);
|
|
|
|
|
rna_def_mproperties(brna);
|
|
|
|
|
rna_def_face_map(brna);
|
|
|
|
|
}
|
|
|
|
|