Fix T96401: Broken multires baked normals result

A 7 year old commit, 2ec00ea0c1, used incorrect indexing for
the optional array of precomputed poly normals. Apparently that code
path was never used, or this issue would have been discovered earlier.
Recent changes calculate normals on a temporary mesh and use those
for the "low-res" layer, meaning the precomputed path was always taken.
This commit is contained in:
Hans Goudey 2022-03-21 16:55:55 -05:00
parent 923b28aab8
commit 3a8a7d93f9
Notes: blender-bot 2023-06-07 10:31:13 +02:00
Referenced by issue #96401, Bake normals for multi-resolution object is broken
Referenced by issue #96241, 3.1: Potential candidates for corrective releases
1 changed files with 3 additions and 3 deletions

View File

@ -66,7 +66,7 @@ typedef struct {
MLoopUV *mloopuv;
const MLoopTri *mlooptri;
float *pvtangent;
const float *precomputed_normals;
const float (*precomputed_normals)[3];
int w, h;
int tri_index;
DerivedMesh *lores_dm, *hires_dm;
@ -116,7 +116,7 @@ static void multiresbake_get_normal(const MResolvePixelData *data,
if (!smoothnormal) { /* flat */
if (data->precomputed_normals) {
copy_v3_v3(norm, &data->precomputed_normals[poly_index]);
copy_v3_v3(norm, data->precomputed_normals[poly_index]);
}
else {
BKE_mesh_calc_poly_normal(mp, &data->mloop[mp->loopstart], data->mvert, norm);
@ -542,7 +542,7 @@ static void do_multires_bake(MultiresBakeRender *bkr,
handle->data.mlooptri = mlooptri;
handle->data.mloop = mloop;
handle->data.pvtangent = pvtangent;
handle->data.precomputed_normals = (float *)poly_normals; /* don't strictly need this */
handle->data.precomputed_normals = poly_normals; /* don't strictly need this */
handle->data.w = ibuf->x;
handle->data.h = ibuf->y;
handle->data.lores_dm = dm;