Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_mesh.c
| Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
| BLI_INLINE void mesh_cd_layers_type_clear(DRW_MeshCDMask *a) | BLI_INLINE void mesh_cd_layers_type_clear(DRW_MeshCDMask *a) | ||||
| { | { | ||||
| *((uint64_t *)a) = 0; | *((uint64_t *)a) = 0; | ||||
| } | } | ||||
| BLI_INLINE const Mesh *editmesh_final_or_this(const Mesh *me) | BLI_INLINE const Mesh *editmesh_final_or_this(const Mesh *me) | ||||
| { | { | ||||
| return (me->edit_mesh && me->edit_mesh->mesh_eval_final) ? me->edit_mesh->mesh_eval_final : me; | EditMeshData *emd = me->runtime.edit_data; | ||||
| return (me->edit_mesh && emd && emd->eval.mesh_eval_final) ? emd->eval.mesh_eval_final : me; | |||||
| } | } | ||||
| static void mesh_cd_calc_edit_uv_layer(const Mesh *UNUSED(me), DRW_MeshCDMask *cd_used) | static void mesh_cd_calc_edit_uv_layer(const Mesh *UNUSED(me), DRW_MeshCDMask *cd_used) | ||||
| { | { | ||||
| cd_used->edit_uv = 1; | cd_used->edit_uv = 1; | ||||
| } | } | ||||
| BLI_INLINE const CustomData *mesh_cd_ldata_get_from_mesh(const Mesh *me) | BLI_INLINE const CustomData *mesh_cd_ldata_get_from_mesh(const Mesh *me) | ||||
| ▲ Show 20 Lines • Show All 1,078 Lines • ▼ Show 20 Lines | void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, | ||||
| if (cache->batch_requested == 0) { | if (cache->batch_requested == 0) { | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| drw_mesh_batch_cache_check_available(task_graph, me); | drw_mesh_batch_cache_check_available(task_graph, me); | ||||
| #endif | #endif | ||||
| return; | return; | ||||
| } | } | ||||
| /* Sanity check. */ | /* Sanity check. */ | ||||
| if ((me->edit_mesh != NULL) && (ob->mode & OB_MODE_EDIT)) { | if ((me->edit_mesh != NULL) && (me->runtime.edit_data != NULL) && (ob->mode & OB_MODE_EDIT)) { | ||||
| BLI_assert(me->edit_mesh->mesh_eval_final != NULL); | BLI_assert(me->runtime.edit_data->eval.mesh_eval_final != NULL); | ||||
| } | } | ||||
| /* Don't check `DRW_object_is_in_edit_mode(ob)` here because it means the same mesh | /* Don't check `DRW_object_is_in_edit_mode(ob)` here because it means the same mesh | ||||
| * may draw with edit-mesh data and regular mesh data. | * may draw with edit-mesh data and regular mesh data. | ||||
| * In this case the custom-data layers used wont always match in `me->runtime.batch_cache`. | * In this case the custom-data layers used wont always match in `me->runtime.batch_cache`. | ||||
| * If we want to display regular mesh data, we should have a separate cache for the edit-mesh. | * If we want to display regular mesh data, we should have a separate cache for the edit-mesh. | ||||
| * See T77359. */ | * See T77359. */ | ||||
| const bool is_editmode = (me->edit_mesh != NULL) && | const bool is_editmode = (me->edit_mesh != NULL) && (me->runtime.edit_data != NULL) && | ||||
| /* In rare cases we have the edit-mode data but not the generated cache. | /* In rare cases we have the edit-mode data but not the generated cache. | ||||
| * This can happen when switching an objects data to a mesh which | * This can happen when switching an objects data to a mesh which | ||||
| * happens to be in edit-mode in another scene, see: T82952. */ | * happens to be in edit-mode in another scene, see: T82952. */ | ||||
| (me->edit_mesh->mesh_eval_final != | (me->runtime.edit_data->eval.mesh_eval_final != | ||||
| NULL) /* && DRW_object_is_in_edit_mode(ob) */; | NULL) /* && DRW_object_is_in_edit_mode(ob) */; | ||||
| /* This could be set for paint mode too, currently it's only used for edit-mode. */ | /* This could be set for paint mode too, currently it's only used for edit-mode. */ | ||||
| const bool is_mode_active = is_editmode && DRW_object_is_in_edit_mode(ob); | const bool is_mode_active = is_editmode && DRW_object_is_in_edit_mode(ob); | ||||
| DRWBatchFlag batch_requested = cache->batch_requested; | DRWBatchFlag batch_requested = cache->batch_requested; | ||||
| cache->batch_requested = 0; | cache->batch_requested = 0; | ||||
| Show All 10 Lines | #endif | ||||
| } | } | ||||
| if (batch_requested & | if (batch_requested & | ||||
| (MBC_SURFACE | MBC_WIRE_LOOPS_UVS | MBC_EDITUV_FACES_STRETCH_AREA | | (MBC_SURFACE | MBC_WIRE_LOOPS_UVS | MBC_EDITUV_FACES_STRETCH_AREA | | ||||
| MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS)) { | MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS)) { | ||||
| /* Modifiers will only generate an orco layer if the mesh is deformed. */ | /* Modifiers will only generate an orco layer if the mesh is deformed. */ | ||||
| if (cache->cd_needed.orco != 0) { | if (cache->cd_needed.orco != 0) { | ||||
| /* Orco is always extracted from final mesh. */ | /* Orco is always extracted from final mesh. */ | ||||
| Mesh *me_final = (me->edit_mesh) ? me->edit_mesh->mesh_eval_final : me; | Mesh *me_final = (me->edit_mesh && me->runtime.edit_data) ? | ||||
| me->runtime.edit_data->eval.mesh_eval_final : | |||||
| me; | |||||
| if (CustomData_get_layer(&me_final->vdata, CD_ORCO) == NULL) { | if (CustomData_get_layer(&me_final->vdata, CD_ORCO) == NULL) { | ||||
| /* Skip orco calculation */ | /* Skip orco calculation */ | ||||
| cache->cd_needed.orco = 0; | cache->cd_needed.orco = 0; | ||||
| } | } | ||||
| } | } | ||||
| /* Verify that all surface batches have needed attribute layers. | /* Verify that all surface batches have needed attribute layers. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | #endif | ||||
| const bool do_update_sculpt_normals = ob->sculpt && ob->sculpt->pbvh; | const bool do_update_sculpt_normals = ob->sculpt && ob->sculpt->pbvh; | ||||
| if (do_update_sculpt_normals) { | if (do_update_sculpt_normals) { | ||||
| Mesh *mesh = ob->data; | Mesh *mesh = ob->data; | ||||
| BKE_pbvh_update_normals(ob->sculpt->pbvh, mesh->runtime.subdiv_ccg); | BKE_pbvh_update_normals(ob->sculpt->pbvh, mesh->runtime.subdiv_ccg); | ||||
| } | } | ||||
| cache->batch_ready |= batch_requested; | cache->batch_ready |= batch_requested; | ||||
| const bool do_cage = (is_editmode && | const bool do_cage = (is_editmode && (me->runtime.edit_data->eval.mesh_eval_final != | ||||
| (me->edit_mesh->mesh_eval_final != me->edit_mesh->mesh_eval_cage)); | me->runtime.edit_data->eval.mesh_eval_cage)); | ||||
| const bool do_uvcage = is_editmode && !me->edit_mesh->mesh_eval_final->runtime.is_original; | const bool do_uvcage = is_editmode && | ||||
| !me->runtime.edit_data->eval.mesh_eval_final->runtime.is_original; | |||||
| MeshBufferCache *mbufcache = &cache->final; | MeshBufferCache *mbufcache = &cache->final; | ||||
| /* Initialize batches and request VBO's & IBO's. */ | /* Initialize batches and request VBO's & IBO's. */ | ||||
| if (DRW_batch_requested(cache->batch.surface, GPU_PRIM_TRIS)) { | if (DRW_batch_requested(cache->batch.surface, GPU_PRIM_TRIS)) { | ||||
| DRW_ibo_request(cache->batch.surface, &mbufcache->ibo.tris); | DRW_ibo_request(cache->batch.surface, &mbufcache->ibo.tris); | ||||
| /* Order matters. First ones override latest VBO's attributes. */ | /* Order matters. First ones override latest VBO's attributes. */ | ||||
| DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.lnor); | DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.lnor); | ||||
| ▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines | |||||