Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh.cc
| Show First 20 Lines • Show All 992 Lines • ▼ Show 20 Lines | |||||
| const Mesh *me_settings) | const Mesh *me_settings) | ||||
| { | { | ||||
| Mesh *mesh = (Mesh *)BKE_id_new_nomain(ID_ME, nullptr); | Mesh *mesh = (Mesh *)BKE_id_new_nomain(ID_ME, nullptr); | ||||
| BM_mesh_bm_to_me_for_eval(bm, mesh, cd_mask_extra); | BM_mesh_bm_to_me_for_eval(bm, mesh, cd_mask_extra); | ||||
| BKE_mesh_copy_parameters_for_eval(mesh, me_settings); | BKE_mesh_copy_parameters_for_eval(mesh, me_settings); | ||||
| return mesh; | return mesh; | ||||
| } | } | ||||
| static void ensure_orig_index_layer(CustomData &data, const int size) | |||||
| { | |||||
| if (CustomData_has_layer(&data, CD_ORIGINDEX)) { | |||||
| return; | |||||
| } | |||||
| int *indices = (int *)CustomData_add_layer(&data, CD_ORIGINDEX, CD_DEFAULT, nullptr, size); | |||||
| range_vn_i(indices, size, 0); | |||||
| } | |||||
| void BKE_mesh_ensure_default_orig_index_layers(Mesh *mesh) | |||||
| { | |||||
| BLI_assert(mesh->runtime.wrapper_type == ME_WRAPPER_TYPE_MDATA); | |||||
| ensure_orig_index_layer(mesh->vdata, mesh->totvert); | |||||
| ensure_orig_index_layer(mesh->edata, mesh->totedge); | |||||
| ensure_orig_index_layer(mesh->pdata, mesh->totpoly); | |||||
| } | |||||
| BoundBox *BKE_mesh_boundbox_get(Object *ob) | BoundBox *BKE_mesh_boundbox_get(Object *ob) | ||||
| { | { | ||||
| /* This is Object-level data access, | /* This is Object-level data access, | ||||
| * DO NOT touch to Mesh's bb, would be totally thread-unsafe. */ | * DO NOT touch to Mesh's bb, would be totally thread-unsafe. */ | ||||
| if (ob->runtime.bb == nullptr || ob->runtime.bb->flag & BOUNDBOX_DIRTY) { | if (ob->runtime.bb == nullptr || ob->runtime.bb->flag & BOUNDBOX_DIRTY) { | ||||
| Mesh *me = (Mesh *)ob->data; | Mesh *me = (Mesh *)ob->data; | ||||
| float min[3], max[3]; | float min[3], max[3]; | ||||
sergey: Suggest to split it into 2 lines to make it easier to follow what's going on. | |||||
| INIT_MINMAX(min, max); | INIT_MINMAX(min, max); | ||||
| if (!BKE_mesh_wrapper_minmax(me, min, max)) { | if (!BKE_mesh_wrapper_minmax(me, min, max)) { | ||||
| min[0] = min[1] = min[2] = -1.0f; | min[0] = min[1] = min[2] = -1.0f; | ||||
| max[0] = max[1] = max[2] = 1.0f; | max[0] = max[1] = max[2] = 1.0f; | ||||
| } | } | ||||
| if (ob->runtime.bb == nullptr) { | if (ob->runtime.bb == nullptr) { | ||||
| ob->runtime.bb = (BoundBox *)MEM_mallocN(sizeof(*ob->runtime.bb), __func__); | ob->runtime.bb = (BoundBox *)MEM_mallocN(sizeof(*ob->runtime.bb), __func__); | ||||
| ▲ Show 20 Lines • Show All 984 Lines • Show Last 20 Lines | |||||
Suggest to split it into 2 lines to make it easier to follow what's going on.