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