Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/paint.c
| Show First 20 Lines • Show All 2,015 Lines • ▼ Show 20 Lines | |||||
| void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg) | void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg) | ||||
| { | { | ||||
| BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(mesh); | BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(mesh); | ||||
| BKE_sculpt_sync_face_sets_visibility_to_base_mesh(mesh); | BKE_sculpt_sync_face_sets_visibility_to_base_mesh(mesh); | ||||
| BKE_sculpt_sync_face_sets_visibility_to_grids(mesh, subdiv_ccg); | BKE_sculpt_sync_face_sets_visibility_to_grids(mesh, subdiv_ccg); | ||||
| } | } | ||||
| /** | |||||
| * Ensures we do have expected mesh data in original mesh for the sculpt mode. | |||||
| * | |||||
| * \note IDs are expected to be original ones here, and calling code should ensure it updates its | |||||
| * depsgraph properly after calling this function if it needs up-to-date evaluated data. | |||||
| */ | |||||
| void BKE_sculpt_ensure_orig_mesh_data(Scene *scene, Object *object) | |||||
| { | |||||
| Mesh *mesh = BKE_mesh_from_object(object); | |||||
| MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, object); | |||||
| BLI_assert(object->mode == OB_MODE_SCULPT); | |||||
| /* Copy the current mesh visibility to the Face Sets. */ | |||||
| BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(mesh); | |||||
| if (object->sculpt != NULL) { | |||||
| /* If a sculpt session is active, ensure we have its faceset data porperly up-to-date. */ | |||||
| object->sculpt->face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS); | |||||
| } | |||||
| /* Mask layer is required for Multires. */ | |||||
| if (mmd != NULL) { | |||||
| BKE_sculpt_mask_layers_ensure(object, mmd); | |||||
pablodp606: This needs be called both for all PBVH tyes. The CD_PAINT_MASK datalayers also needs to be… | |||||
mont29AuthorUnsubmitted Done Inline ActionsAre you sure about that? original code did not create it in non-multires case, and from a quick try here (default cube, switch to sculpt, draw mask), it seems to be handled properly? mont29: Are you sure about that? original code did not create it in non-multires case, and from a… | |||||
pablodp606Unsubmitted Not Done Inline ActionsYes. I get a crash doing those same steps. That function also allocates the mask for the base mesh if it does not exists. The original code in sculpt_update_object was the following if (mmd == NULL) {
if (!CustomData_has_layer(&me->vdata, CD_PAINT_MASK)) {
BKE_sculpt_mask_layers_ensure(ob, NULL);
}
}
else {
if (!CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) {
BKE_sculpt_mask_layers_ensure(ob, mmd);
}
}pablodp606: Yes. I get a crash doing those same steps. That function also allocates the mask for the base… | |||||
mont29AuthorUnsubmitted Done Inline ActionsUuuuuh yes... butoriginal code did not when called from from sculpt_init_session (i.e. ED_object_sculptmode_enter_ex)... OK, will add it back systematically, original code was horribly confusing and wrong anyway, we can always try to optimize this later if it's really worth it, but for now let's aim at security. mont29: Uuuuuh yes... butoriginal code did not when called from from `sculpt_init_session` (i.e. | |||||
| } | |||||
| /* Tessfaces aren't used and will become invalid. */ | |||||
| BKE_mesh_tessface_clear(mesh); | |||||
| /* We always need to flush updates from depsgraph here, since at the very least | |||||
| * `BKE_sculpt_face_sets_ensure_from_base_mesh_visibility()` will have updated some data layer of | |||||
| * the mesh. | |||||
| * | |||||
| * All known potential sources of updates: | |||||
| * - Addition of, or changes to, the `CD_SCULPT_FACE_SETS` data layer | |||||
| * (`BKE_sculpt_face_sets_ensure_from_base_mesh_visibility`). | |||||
| * - Addition of a `CD_PAINT_MASK` data layer (`BKE_sculpt_mask_layers_ensure`). | |||||
| * - Object has any active modifier (modifier stack can be different in Sculpt mode). | |||||
| * - Multires: | |||||
| * + Differences of subdiv levels between sculpt and object modes | |||||
| * (`mmd->sculptlvl != mmd->lvl`). | |||||
| * + Addition of a `CD_GRID_PAINT_MASK` data layer (`BKE_sculpt_mask_layers_ensure`). | |||||
| */ | |||||
| DEG_id_tag_update(&object->id, ID_RECALC_GEOMETRY); | |||||
| } | |||||
| static PBVH *build_pbvh_for_dynamic_topology(Object *ob) | static PBVH *build_pbvh_for_dynamic_topology(Object *ob) | ||||
| { | { | ||||
| PBVH *pbvh = BKE_pbvh_new(); | PBVH *pbvh = BKE_pbvh_new(); | ||||
| BKE_pbvh_build_bmesh(pbvh, | BKE_pbvh_build_bmesh(pbvh, | ||||
| ob->sculpt->bm, | ob->sculpt->bm, | ||||
| ob->sculpt->bm_smooth_shading, | ob->sculpt->bm_smooth_shading, | ||||
| ob->sculpt->bm_log, | ob->sculpt->bm_log, | ||||
| ob->sculpt->cd_vert_node_offset, | ob->sculpt->cd_vert_node_offset, | ||||
| ▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines | |||||
This needs be called both for all PBVH tyes. The CD_PAINT_MASK datalayers also needs to be created when multires is not being used, otherwise it will crash.