Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_remesh.c
| Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | typedef struct QuadriFlowJob { | ||||
| bool use_preserve_sharp; | bool use_preserve_sharp; | ||||
| bool use_preserve_boundary; | bool use_preserve_boundary; | ||||
| bool use_mesh_curvature; | bool use_mesh_curvature; | ||||
| bool preserve_paint_mask; | bool preserve_paint_mask; | ||||
| bool smooth_normals; | bool smooth_normals; | ||||
| int success; | int success; | ||||
| bool is_nonblocking_job; | |||||
| } QuadriFlowJob; | } QuadriFlowJob; | ||||
| static bool mesh_is_manifold_consistent(Mesh *mesh) | static bool mesh_is_manifold_consistent(Mesh *mesh) | ||||
| { | { | ||||
| /* In this check we count boundary edges as manifold. Additionally, we also | /* In this check we count boundary edges as manifold. Additionally, we also | ||||
| * check that the direction of the faces are consistent and doesn't suddenly | * check that the direction of the faces are consistent and doesn't suddenly | ||||
| * flip | * flip | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| QuadriFlowJob *qj = customdata; | QuadriFlowJob *qj = customdata; | ||||
| qj->stop = stop; | qj->stop = stop; | ||||
| qj->do_update = do_update; | qj->do_update = do_update; | ||||
| qj->progress = progress; | qj->progress = progress; | ||||
| qj->success = 1; | qj->success = 1; | ||||
| if (qj->is_nonblocking_job) { | |||||
| G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */ | G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */ | ||||
| } | |||||
| Object *ob = qj->owner; | Object *ob = qj->owner; | ||||
| Mesh *mesh = ob->data; | Mesh *mesh = ob->data; | ||||
| Mesh *new_mesh; | Mesh *new_mesh; | ||||
| Mesh *bisect_mesh; | Mesh *bisect_mesh; | ||||
| /* Check if the mesh is manifold. Quadriflow requires manifold meshes */ | /* Check if the mesh is manifold. Quadriflow requires manifold meshes */ | ||||
| if (!mesh_is_manifold_consistent(mesh)) { | if (!mesh_is_manifold_consistent(mesh)) { | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void quadriflow_end_job(void *customdata) | static void quadriflow_end_job(void *customdata) | ||||
| { | { | ||||
| QuadriFlowJob *qj = customdata; | QuadriFlowJob *qj = customdata; | ||||
| Object *ob = qj->owner; | Object *ob = qj->owner; | ||||
| if (qj->is_nonblocking_job) { | |||||
| WM_set_locked_interface(G_MAIN->wm.first, false); | WM_set_locked_interface(G_MAIN->wm.first, false); | ||||
| } | |||||
| switch (qj->success) { | switch (qj->success) { | ||||
| case 1: | case 1: | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | ||||
| WM_reportf(RPT_INFO, "QuadriFlow: Remeshing completed"); | WM_reportf(RPT_INFO, "QuadriFlow: Remeshing completed"); | ||||
| break; | break; | ||||
| case 0: | case 0: | ||||
| WM_reportf(RPT_ERROR, "QuadriFlow: Remeshing failed"); | WM_reportf(RPT_ERROR, "QuadriFlow: Remeshing failed"); | ||||
| Show All 40 Lines | for (char i = 0; i < 3; i++) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| job->use_paint_symmetry = false; | job->use_paint_symmetry = false; | ||||
| job->symmetry_axes = 0; | job->symmetry_axes = 0; | ||||
| } | } | ||||
| if (op->flag == 0) { | |||||
| /* This is called directly from the exec operator, this operation is now blocking */ | |||||
| job->is_nonblocking_job = false; | |||||
| short stop = 0, do_update = true; | |||||
| float progress; | |||||
| quadriflow_start_job(job, &stop, &do_update, &progress); | |||||
| quadriflow_end_job(job); | |||||
| quadriflow_free_job(job); | |||||
| } | |||||
| else { | |||||
| /* Non blocking call. For when the operator has been called from the gui */ | |||||
| job->is_nonblocking_job = true; | |||||
| wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), | wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), | ||||
| CTX_wm_window(C), | CTX_wm_window(C), | ||||
| CTX_data_scene(C), | CTX_data_scene(C), | ||||
| "QuadriFlow Remesh", | "QuadriFlow Remesh", | ||||
| WM_JOB_PROGRESS, | WM_JOB_PROGRESS, | ||||
| WM_JOB_TYPE_QUADRIFLOW_REMESH); | WM_JOB_TYPE_QUADRIFLOW_REMESH); | ||||
| WM_jobs_customdata_set(wm_job, job, quadriflow_free_job); | WM_jobs_customdata_set(wm_job, job, quadriflow_free_job); | ||||
| WM_jobs_timer(wm_job, 0.1, NC_GEOM | ND_DATA, NC_GEOM | ND_DATA); | WM_jobs_timer(wm_job, 0.1, NC_GEOM | ND_DATA, NC_GEOM | ND_DATA); | ||||
| WM_jobs_callbacks(wm_job, quadriflow_start_job, NULL, NULL, quadriflow_end_job); | WM_jobs_callbacks(wm_job, quadriflow_start_job, NULL, NULL, quadriflow_end_job); | ||||
| WM_set_locked_interface(CTX_wm_manager(C), true); | WM_set_locked_interface(CTX_wm_manager(C), true); | ||||
| WM_jobs_start(CTX_wm_manager(C), wm_job); | WM_jobs_start(CTX_wm_manager(C), wm_job); | ||||
| } | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static bool quadriflow_check(bContext *C, wmOperator *op) | static bool quadriflow_check(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| int mode = RNA_enum_get(op->ptr, "mode"); | int mode = RNA_enum_get(op->ptr, "mode"); | ||||
| if (mode == QUADRIFLOW_REMESH_EDGE_LENGTH) { | if (mode == QUADRIFLOW_REMESH_EDGE_LENGTH) { | ||||
| ▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines | |||||