Commit: 9fda23389758c80d97439a0f5ee718d0f898ff79 Author: Hans Goudey Date: Tue Jun 7 18:55:56 2022 +0200 Branches: master https://developer.blender.org/rB9fda23389758c80d97439a0f5ee718d0f898ff79
Cleanup: Use const pointers in attribute API =================================================================== M source/blender/blenkernel/BKE_attribute.h M source/blender/blenkernel/BKE_curves.h M source/blender/blenkernel/BKE_pointcloud.h M source/blender/blenkernel/intern/attribute.cc M source/blender/blenkernel/intern/curves.cc M source/blender/blenkernel/intern/material.c M source/blender/blenkernel/intern/pointcloud.cc M source/blender/draw/intern/draw_cache_impl_mesh.cc M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc M source/blender/editors/geometry/geometry_attributes.cc M source/blender/editors/mesh/editmesh_tools.c M source/blender/editors/sculpt_paint/paint_vertex.cc M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_undo.c M source/blender/makesrna/intern/rna_attribute.c =================================================================== diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index 78edb6b95ed..65d93089002 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -50,7 +50,7 @@ typedef enum eAttrDomainMask { /* Attributes. */ -bool BKE_id_attributes_supported(struct ID *id); +bool BKE_id_attributes_supported(const struct ID *id); bool BKE_attribute_allow_procedural_access(const char *attribute_name); /** @@ -74,7 +74,7 @@ struct CustomDataLayer *BKE_id_attribute_search(const struct ID *id, eAttrDomain BKE_id_attribute_domain(const struct ID *id, const struct CustomDataLayer *layer); int BKE_id_attribute_data_length(struct ID *id, struct CustomDataLayer *layer); -bool BKE_id_attribute_required(struct ID *id, struct CustomDataLayer *layer); +bool BKE_id_attribute_required(const struct ID *id, struct CustomDataLayer *layer); bool BKE_id_attribute_rename(struct ID *id, struct CustomDataLayer *layer, const char *new_name, diff --git a/source/blender/blenkernel/BKE_curves.h b/source/blender/blenkernel/BKE_curves.h index 88bb1c67fd1..f86df8b7434 100644 --- a/source/blender/blenkernel/BKE_curves.h +++ b/source/blender/blenkernel/BKE_curves.h @@ -25,7 +25,7 @@ void *BKE_curves_add(struct Main *bmain, const char *name); struct BoundBox *BKE_curves_boundbox_get(struct Object *ob); -bool BKE_curves_customdata_required(struct Curves *curves, struct CustomDataLayer *layer); +bool BKE_curves_customdata_required(const struct Curves *curves, struct CustomDataLayer *layer); /* Depsgraph */ diff --git a/source/blender/blenkernel/BKE_pointcloud.h b/source/blender/blenkernel/BKE_pointcloud.h index c238a24f173..50537d982ef 100644 --- a/source/blender/blenkernel/BKE_pointcloud.h +++ b/source/blender/blenkernel/BKE_pointcloud.h @@ -30,7 +30,7 @@ struct BoundBox *BKE_pointcloud_boundbox_get(struct Object *ob); bool BKE_pointcloud_minmax(const struct PointCloud *pointcloud, float r_min[3], float r_max[3]); void BKE_pointcloud_update_customdata_pointers(struct PointCloud *pointcloud); -bool BKE_pointcloud_customdata_required(struct PointCloud *pointcloud, +bool BKE_pointcloud_customdata_required(const struct PointCloud *pointcloud, struct CustomDataLayer *layer); /* Dependency Graph */ diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 1818befba4c..509161386cd 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -105,7 +105,7 @@ static CustomData *attribute_customdata_find(ID *id, CustomDataLayer *layer) return nullptr; } -bool BKE_id_attributes_supported(ID *id) +bool BKE_id_attributes_supported(const ID *id) { DomainInfo info[ATTR_DOMAIN_NUM]; get_domains(id, info); @@ -382,14 +382,14 @@ int BKE_id_attribute_data_length(ID *id, CustomDataLayer *layer) return 0; } -bool BKE_id_attribute_required(ID *id, CustomDataLayer *layer) +bool BKE_id_attribute_required(const ID *id, CustomDataLayer *layer) { switch (GS(id->name)) { case ID_PT: { - return BKE_pointcloud_customdata_required((PointCloud *)id, layer); + return BKE_pointcloud_customdata_required((const PointCloud *)id, layer); } case ID_CV: { - return BKE_curves_customdata_required((Curves *)id, layer); + return BKE_curves_customdata_required((const Curves *)id, layer); } default: return false; diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 9abd5a7fdf0..a348e546e46 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -273,7 +273,7 @@ BoundBox *BKE_curves_boundbox_get(Object *ob) return ob->runtime.bb; } -bool BKE_curves_customdata_required(Curves *UNUSED(curves), CustomDataLayer *layer) +bool BKE_curves_customdata_required(const Curves *UNUSED(curves), CustomDataLayer *layer) { return layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, ATTR_POSITION); } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e5b875cadf9..04a07fb42be 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1448,7 +1448,7 @@ static bool fill_texpaint_slots_cb(bNode *node, void *userdata) slot->attribute_name = storage->name; if (storage->type == SHD_ATTRIBUTE_GEOMETRY) { const Mesh *mesh = (const Mesh *)fill_data->ob->data; - CustomDataLayer *layer = BKE_id_attributes_color_find(&mesh->id, storage->name); + const CustomDataLayer *layer = BKE_id_attributes_color_find(&mesh->id, storage->name); slot->valid = layer != NULL; } diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc index 9720c61e3b9..3e94a865de3 100644 --- a/source/blender/blenkernel/intern/pointcloud.cc +++ b/source/blender/blenkernel/intern/pointcloud.cc @@ -315,7 +315,8 @@ void BKE_pointcloud_update_customdata_pointers(PointCloud *pointcloud) CustomData_get_layer_named(&pointcloud->pdata, CD_PROP_FLOAT, POINTCLOUD_ATTR_RADIUS)); } -bool BKE_pointcloud_customdata_required(PointCloud *UNUSED(pointcloud), CustomDataLayer *layer) +bool BKE_pointcloud_customdata_required(const PointCloud *UNUSED(pointcloud), + CustomDataLayer *layer) { return layer->type == CD_PROP_FLOAT3 && STREQ(layer->name, POINTCLOUD_ATTR_POSITION); } diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc index 1f83e0e3fce..ec71250b63b 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.cc +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -353,7 +353,7 @@ static void mesh_cd_calc_active_mloopcol_layer(const Object *object, BKE_id_attribute_copy_domains_temp(ID_ME, cd_vdata, NULL, cd_ldata, NULL, NULL, &me_query.id); - CustomDataLayer *layer = BKE_id_attributes_active_color_get(&me_query.id); + const CustomDataLayer *layer = BKE_id_attributes_active_color_get(&me_query.id); int layer_i = BKE_id_attribute_to_index( &me_query.id, layer, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL); @@ -367,7 +367,7 @@ static uint mesh_cd_calc_gpu_layers_vcol_used(const Mesh *me_query, const CustomData *cd_ldata, const char name[]) { - CustomDataLayer *layer = NULL; + const CustomDataLayer *layer = NULL; eAttrDomain domain; if (name[0]) { @@ -1089,8 +1089,8 @@ static void sculpt_request_active_vcol(MeshBatchCache *cache, Object *object, Me Mesh me_query = blender::dna::shallow_zero_initialize(); BKE_id_attribute_copy_domains_temp(ID_ME, cd_vdata, NULL, cd_ldata, NULL, NULL, &me_query.id); - CustomDataLayer *active = BKE_id_attributes_active_color_get(&me_query.id); - CustomDataLayer *render = BKE_id_attributes_render_color_get(&me_query.id); + const CustomDataLayer *active = BKE_id_attributes_active_color_get(&me_query.id); + const CustomDataLayer *render = BKE_id_attributes_render_color_get(&me_query.id); int active_i = BKE_id_attribute_to_index( &me_query.id, active, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc index 0e192e34dff..3095d9f7c84 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc @@ -73,10 +73,10 @@ namespace blender::draw { /* Initialize the common vertex format for vcol for coarse and subdivided meshes. */ static void init_vcol_format(GPUVertFormat *format, const MeshBatchCache *cache, - CustomData *cd_vdata, - CustomData *cd_ldata, - CustomDataLayer *active, - CustomDataLayer *render) + const CustomData *cd_vdata, + const CustomData *cd_ldata, + const CustomDataLayer *active, + const CustomDataLayer *render) { GPU_vertformat_deinterleave(format); @@ -130,16 +130,18 @@ static void extract_vcol_init(const MeshRenderData *mr, GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf); GPUVertFormat format = {0}; - CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata; - CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata; + const CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : + &mr->me->vdata; + const CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : + &mr->me->ldata; Mesh me_query = blender::dna::shallow_zero_initialize(); BKE_id_attribute_copy_domains_temp( ID_ME, cd_vdata, nullptr, cd_ldata, nullptr, nullptr, &me_query.id); - CustomDataLayer *active_color = BKE_id_attributes_active_color_get(&me_query.id); - CustomDataLayer *render_color = BKE_id_attributes_render_color_get(&me_query.id); + const CustomDataLayer *active_color = BKE_id_attributes_active_color_get(&me_query.id); + const CustomDataLayer *render_color = BKE_id_attributes_render_color_get(&me_query.id); const uint32_t vcol_layers = cache->cd_used.vcol; init_vcol_format(&format, cache, cd_vdata, cd_ldata, active_color, render_color); @@ -152,7 +154,7 @@ static void extract_vcol_init(const MeshRenderData *mr, blender::Vector<VColRef> refs = get_vcol_refs(cd_vdata, cd_ldata, vcol_layers); for (const VColRef &ref : refs) { - CustomData *cdata = ref.domain == ATTR_DOMAIN_POINT ? cd_vdata : cd_ldata; + cons @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs