main sync #3

Merged
Patrick Busch merged 318 commits from blender/blender:main into main 2023-03-17 15:52:21 +01:00
Showing only changes of commit caf90c6a90 - Show all commits

View File

@ -333,30 +333,26 @@ struct PBVHBatches {
foreach_faces,
GPUVertBufRaw *access)
{
float fno[3];
short no[3];
int last_poly = -1;
const bool *sharp_faces = static_cast<const bool *>(
CustomData_get_layer_named(args->pdata, CD_PROP_BOOL, "sharp_face"));
short no[3];
int last_poly = -1;
bool flat = false;
foreach_faces([&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri *tri) {
bool smooth = false;
if (tri->poly != last_poly) {
last_poly = tri->poly;
if (sharp_faces && sharp_faces[tri->poly]) {
smooth = true;
flat = sharp_faces && sharp_faces[tri->poly];
if (flat) {
const MPoly &poly = args->polys[tri->poly];
float fno[3];
BKE_mesh_calc_poly_normal(
&poly, args->mloop + poly.loopstart, args->vert_positions, fno);
normal_float_to_short_v3(no, fno);
}
else {
smooth = false;
}
}
if (!smooth) {
if (!flat) {
normal_float_to_short_v3(no, args->vert_normals[vertex_i]);
}