Changeset View
Changeset View
Standalone View
Standalone View
source/blender/bmesh/intern/bmesh_interp.c
| Show All 9 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "BLI_alloca.h" | #include "BLI_alloca.h" | ||||
| #include "BLI_linklist.h" | #include "BLI_linklist.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_memarena.h" | #include "BLI_memarena.h" | ||||
| #include "BLI_string.h" | |||||
| #include "BLI_task.h" | #include "BLI_task.h" | ||||
| #include "BKE_attribute.h" | |||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| #include "BKE_multires.h" | #include "BKE_multires.h" | ||||
| #include "bmesh.h" | #include "bmesh.h" | ||||
| #include "intern/bmesh_private.h" | #include "intern/bmesh_private.h" | ||||
| /* edge and vertex share, currently there's no need to have different logic */ | /* edge and vertex share, currently there's no need to have different logic */ | ||||
| static void bm_data_interp_from_elem(CustomData *data_layer, | static void bm_data_interp_from_elem(CustomData *data_layer, | ||||
| ▲ Show 20 Lines • Show All 831 Lines • ▼ Show 20 Lines | void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name) | ||||
| CustomData_add_layer_named(data, type, CD_SET_DEFAULT, NULL, 0, name); | CustomData_add_layer_named(data, type, CD_SET_DEFAULT, NULL, 0, name); | ||||
| update_data_blocks(bm, &olddata, data); | update_data_blocks(bm, &olddata, data); | ||||
| if (olddata.layers) { | if (olddata.layers) { | ||||
| MEM_freeN(olddata.layers); | MEM_freeN(olddata.layers); | ||||
| } | } | ||||
| } | } | ||||
| void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, const char *name) | |||||
| { | |||||
| if (CustomData_get_named_layer_index(data, type, name) == -1) { | |||||
| BM_data_layer_add_named(bm, data, type, name); | |||||
| } | |||||
| } | |||||
| void BM_uv_map_ensure_select_and_pin_attrs(BMesh *bm) | |||||
| { | |||||
| const int nr_uv_layers = CustomData_number_of_layers(&bm->ldata, CD_PROP_FLOAT2); | |||||
| for (int l = 0; l < nr_uv_layers; l++) { | |||||
| /* NOTE: you can't re-use the returnvalue of CustomData_get_layer_name() because adding layers | |||||
campbellbarton: *picky* capitalize `NOTE:` see: `Tags` section in https://wiki.blender. | |||||
| * can invalidate that. */ | |||||
| char name[MAX_CUSTOMDATA_LAYER_NAME]; | |||||
| BM_data_layer_ensure_named( | |||||
| bm, | |||||
| &bm->ldata, | |||||
| CD_PROP_BOOL, | |||||
| BKE_uv_map_vert_select_name_get(CustomData_get_layer_name(&bm->ldata, CD_PROP_FLOAT2, l), | |||||
| name)); | |||||
| BM_data_layer_ensure_named( | |||||
| bm, | |||||
| &bm->ldata, | |||||
| CD_PROP_BOOL, | |||||
| BKE_uv_map_edge_select_name_get(CustomData_get_layer_name(&bm->ldata, CD_PROP_FLOAT2, l), | |||||
| name)); | |||||
| BM_data_layer_ensure_named( | |||||
| bm, | |||||
| &bm->ldata, | |||||
| CD_PROP_BOOL, | |||||
| BKE_uv_map_pin_name_get(CustomData_get_layer_name(&bm->ldata, CD_PROP_FLOAT2, l), name)); | |||||
| } | |||||
| } | |||||
| void BM_uv_map_ensure_vert_select_attr(BMesh *bm, const char *uv_map_name) | |||||
| { | |||||
| char name[MAX_CUSTOMDATA_LAYER_NAME]; | |||||
| BM_data_layer_ensure_named( | |||||
| bm, &bm->ldata, CD_PROP_BOOL, BKE_uv_map_vert_select_name_get(uv_map_name, name)); | |||||
| } | |||||
| void BM_uv_map_ensure_edge_select_attr(BMesh *bm, const char *uv_map_name) | |||||
| { | |||||
| char name[MAX_CUSTOMDATA_LAYER_NAME]; | |||||
| BM_data_layer_ensure_named( | |||||
| bm, &bm->ldata, CD_PROP_BOOL, BKE_uv_map_edge_select_name_get(uv_map_name, name)); | |||||
| } | |||||
| void BM_uv_map_ensure_pin_attr(BMesh *bm, const char *uv_map_name) | |||||
| { | |||||
| char name[MAX_CUSTOMDATA_LAYER_NAME]; | |||||
| BM_data_layer_ensure_named( | |||||
| bm, &bm->ldata, CD_PROP_BOOL, BKE_uv_map_pin_name_get(uv_map_name, name)); | |||||
| } | |||||
| void BM_data_layer_free(BMesh *bm, CustomData *data, int type) | void BM_data_layer_free(BMesh *bm, CustomData *data, int type) | ||||
| { | { | ||||
| CustomData olddata = *data; | CustomData olddata = *data; | ||||
| olddata.layers = (olddata.layers) ? MEM_dupallocN(olddata.layers) : NULL; | olddata.layers = (olddata.layers) ? MEM_dupallocN(olddata.layers) : NULL; | ||||
| /* The pool is now owned by `olddata` and must not be shared. */ | /* The pool is now owned by `olddata` and must not be shared. */ | ||||
| data->pool = NULL; | data->pool = NULL; | ||||
| const bool had_layer = CustomData_free_layer_active(data, type, 0); | const bool had_layer = CustomData_free_layer_active(data, type, 0); | ||||
| ▲ Show 20 Lines • Show All 355 Lines • Show Last 20 Lines | |||||
*picky* capitalize NOTE: see: Tags section in https://wiki.blender.org/wiki/Style_Guide/C_Cpp