Mesh: Replace auto smooth with node group #108014
|
@ -260,14 +260,15 @@ static void extract_pos_nor_init_subdiv(const DRWSubdivCache *subdiv_cache,
|
|||
|
||||
if (subdiv_cache->use_custom_loop_normals) {
|
||||
const Mesh *coarse_mesh = subdiv_cache->mesh;
|
||||
const Span<float3> corner_normals = coarse_mesh->corner_normals();
|
||||
|
||||
GPUVertBuf *src_custom_normals = GPU_vertbuf_calloc();
|
||||
GPU_vertbuf_init_with_format(src_custom_normals, get_custom_normals_format());
|
||||
GPU_vertbuf_data_alloc(src_custom_normals, coarse_mesh->totloop);
|
||||
|
||||
memcpy(GPU_vertbuf_get_data(src_custom_normals),
|
||||
coarse_mesh->corner_normals().data(),
|
||||
sizeof(float[3]) * coarse_mesh->totloop);
|
||||
corner_normals.data(),
|
||||
corner_normals.size_in_bytes());
|
||||
|
||||
GPUVertBuf *dst_custom_normals = GPU_vertbuf_calloc();
|
||||
GPU_vertbuf_init_build_on_device(
|
||||
|
|
|
@ -743,13 +743,12 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (BMEditMesh *em = me->edit_mesh) {
|
||||
BMesh &bm = *em->bm;
|
||||
if (me->edit_mesh) {
|
||||
BMesh &bm = *me->edit_mesh->bm;
|
||||
BM_data_layer_add(&bm, &bm.ldata, CD_CUSTOMLOOPNORMAL);
|
||||
}
|
||||
else {
|
||||
CustomData_add_layer(&me->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, me->totloop);
|
||||
me->runtime->corner_normals_dirty = true;
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&me->id, 0);
|
||||
|
|
|
@ -524,8 +524,6 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
|
|||
false,
|
||||
op->reports))
|
||||
{
|
||||
|
||||
|
||||
DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY);
|
||||
changed = true;
|
||||
}
|
||||
|
|
|
@ -1598,18 +1598,17 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
|||
continue;
|
||||
}
|
||||
|
||||
Mesh *mesh = reinterpret_cast<Mesh *>(data);
|
||||
bool changed = false;
|
||||
if (ob->type == OB_MESH) {
|
||||
BKE_mesh_smooth_flag_set(mesh, use_smooth);
|
||||
BKE_mesh_smooth_flag_set(static_cast<Mesh *>(ob->data), use_smooth);
|
||||
if (use_smooth) {
|
||||
const bool use_auto_smooth = RNA_boolean_get(op->ptr, "use_auto_smooth");
|
||||
if (use_auto_smooth) {
|
||||
const float auto_smooth_angle = RNA_float_get(op->ptr, "auto_smooth_angle");
|
||||
BKE_mesh_sharp_edges_set_from_angle(mesh, auto_smooth_angle);
|
||||
BKE_mesh_sharp_edges_set_from_angle(static_cast<Mesh *>(ob->data), auto_smooth_angle);
|
||||
}
|
||||
}
|
||||
BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL);
|
||||
BKE_mesh_batch_cache_dirty_tag(static_cast<Mesh *>(ob->data), BKE_MESH_BATCH_DIRTY_ALL);
|
||||
changed = true;
|
||||
}
|
||||
else if (ELEM(ob->type, OB_SURF, OB_CURVES_LEGACY)) {
|
||||
|
|
|
@ -342,10 +342,9 @@ typedef struct Mesh {
|
|||
* normals are enough. With a combination of sharp and smooth, normals may be "split",
|
||||
* requiring face corner storage.
|
||||
*
|
||||
* Depending on the sharp edge and face tags and custom normals, sometimes a less complex
|
||||
* domain is enough. When possible, it's preferred to use face normals over vertex normals and
|
||||
* vertex normals over face corner normals, since there is a 2-4x performance cost increase for
|
||||
* each step.
|
||||
* When possible, it's preferred to use face normals over vertex normals and vertex normals over
|
||||
* face corner normals, since there is a 2-4x performance cost increase for each more complex
|
||||
* domain.
|
||||
*/
|
||||
eAttrDomain normal_domain_all_info() const;
|
||||
/**
|
||||
|
|
|
@ -343,10 +343,9 @@ static void compute_normal_outputs(const Mesh &mesh,
|
|||
break;
|
||||
}
|
||||
case ATTR_DOMAIN_FACE: {
|
||||
const Span<float3> poly_normals = mesh.poly_normals();
|
||||
bke::mesh_surface_sample::sample_face_attribute(mesh.looptri_polys(),
|
||||
looptri_indices,
|
||||
VArray<float3>::ForSpan(poly_normals),
|
||||
VArray<float3>::ForSpan(mesh.poly_normals()),
|
||||
IndexMask(looptri_indices.index_range()),
|
||||
r_normals);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue