Sculpt: Fix backwards normals in PBVH_GRIDS raycasting
Winding order of grid quads was backwards.
This commit is contained in:
parent
2d0877ed7e
commit
eaec01cad5
Notes:
blender-bot
2023-02-14 05:52:32 +01:00
Referenced by issue #99209, [Sculpt] Masking crashes Blender when used after applying Remesh modifier in Sculpt mode Referenced by issue #98661, 3.2: Potential candidates for corrective releases
|
@ -680,7 +680,7 @@ void BKE_sculpt_update_object_for_edit(struct Depsgraph *depsgraph,
|
|||
bool need_pmap,
|
||||
bool need_mask,
|
||||
bool need_colors);
|
||||
void BKE_sculpt_update_object_before_eval(struct Object *ob_eval);
|
||||
void BKE_sculpt_update_object_before_eval(const struct Scene *scene, struct Object *ob_eval);
|
||||
void BKE_sculpt_update_object_after_eval(struct Depsgraph *depsgraph, struct Object *ob_eval);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1771,7 +1771,7 @@ void makeDerivedMesh(struct Depsgraph *depsgraph,
|
|||
|
||||
BKE_object_free_derived_caches(ob);
|
||||
if (DEG_is_active(depsgraph)) {
|
||||
BKE_sculpt_update_object_before_eval(ob);
|
||||
BKE_sculpt_update_object_before_eval(scene, ob);
|
||||
}
|
||||
|
||||
/* NOTE: Access the `edit_mesh` after freeing the derived caches, so that `ob->data` is restored
|
||||
|
|
|
@ -1798,22 +1798,39 @@ static void sculpt_update_object(Depsgraph *depsgraph,
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_sculpt_update_object_before_eval(Object *ob)
|
||||
static void sculpt_face_sets_ensure(Mesh *mesh)
|
||||
{
|
||||
if (CustomData_has_layer(&mesh->pdata, CD_SCULPT_FACE_SETS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int *new_face_sets = CustomData_add_layer(
|
||||
&mesh->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, mesh->totpoly);
|
||||
|
||||
/* Initialize the new Face Set data-layer with a default valid visible ID and set the default
|
||||
* color to render it white. */
|
||||
for (int i = 0; i < mesh->totpoly; i++) {
|
||||
new_face_sets[i] = 1;
|
||||
}
|
||||
mesh->face_sets_color_default = 1;
|
||||
}
|
||||
|
||||
void BKE_sculpt_update_object_before_eval(const Scene *scene, Object *ob_eval)
|
||||
{
|
||||
/* Update before mesh evaluation in the dependency graph. */
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = ob_eval->sculpt;
|
||||
|
||||
if (ss && ss->building_vp_handle == false) {
|
||||
if (!ss->cache && !ss->filter_cache && !ss->expand_cache) {
|
||||
/* We free pbvh on changes, except in the middle of drawing a stroke
|
||||
* since it can't deal with changing PVBH node organization, we hope
|
||||
* topology does not change in the meantime .. weak. */
|
||||
sculptsession_free_pbvh(ob);
|
||||
sculptsession_free_pbvh(ob_eval);
|
||||
|
||||
BKE_sculptsession_free_deformMats(ob->sculpt);
|
||||
BKE_sculptsession_free_deformMats(ob_eval->sculpt);
|
||||
|
||||
/* In vertex/weight paint, force maps to be rebuilt. */
|
||||
BKE_sculptsession_free_vwpaint_data(ob->sculpt);
|
||||
BKE_sculptsession_free_vwpaint_data(ob_eval->sculpt);
|
||||
}
|
||||
else {
|
||||
PBVHNode **nodes;
|
||||
|
@ -1828,6 +1845,16 @@ void BKE_sculpt_update_object_before_eval(Object *ob)
|
|||
MEM_freeN(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
if (ss) {
|
||||
Object *ob_orig = DEG_get_original_object(ob_eval);
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob_orig);
|
||||
MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob_orig);
|
||||
|
||||
/* Ensure attribute layout is still correct. */
|
||||
sculpt_face_sets_ensure(mesh);
|
||||
BKE_sculpt_mask_layers_ensure(ob_orig, mmd);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_sculpt_update_object_after_eval(Depsgraph *depsgraph, Object *ob_eval)
|
||||
|
|
Loading…
Reference in New Issue