Fix T58235: broken baking of tangent space normals.
This commit is contained in:
parent
cedbaec468
commit
ed5202ac6a
Notes:
blender-bot
2023-02-14 04:53:10 +01:00
Referenced by issue #58235, Broken Baking in 2.8
|
@ -45,6 +45,7 @@
|
|||
#include "BKE_global.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_mesh_tangent.h"
|
||||
#include "BKE_mesh_runtime.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "BLI_strict_flags.h"
|
||||
|
@ -695,6 +696,8 @@ void BKE_mesh_calc_loop_tangents(
|
|||
Mesh *me_eval, bool calc_active_tangent,
|
||||
const char (*tangent_names)[MAX_NAME], int tangent_names_len)
|
||||
{
|
||||
BKE_mesh_runtime_looptri_ensure(me_eval);
|
||||
|
||||
/* TODO(campbell): store in Mesh.runtime to avoid recalculation. */
|
||||
short tangent_mask = 0;
|
||||
BKE_mesh_calc_loop_tangent_ex(
|
||||
|
|
|
@ -432,8 +432,7 @@ static TriTessFace *mesh_calc_tri_tessface(
|
|||
me->totloop, me->totpoly,
|
||||
looptri);
|
||||
|
||||
|
||||
const float *precomputed_normals = me_eval ? CustomData_get_layer(&me_eval->pdata, CD_NORMAL) : NULL;
|
||||
const float *precomputed_normals = me ? CustomData_get_layer(&me->pdata, CD_NORMAL) : NULL;
|
||||
const bool calculate_normal = precomputed_normals ? false : true;
|
||||
|
||||
for (i = 0; i < tottri; i++) {
|
||||
|
@ -514,11 +513,11 @@ bool RE_bake_pixels_populate_from_objects(
|
|||
tris_high[i] = mesh_calc_tri_tessface(highpoly[i].me, false, NULL);
|
||||
|
||||
me_highpoly[i] = highpoly[i].me;
|
||||
BKE_mesh_tessface_ensure(me_highpoly[i]);
|
||||
BKE_mesh_runtime_looptri_ensure(me_highpoly[i]);
|
||||
|
||||
if (me_highpoly[i]->totface != 0) {
|
||||
if (me_highpoly[i]->runtime.looptris.len != 0) {
|
||||
/* Create a bvh-tree for each highpoly object */
|
||||
BKE_bvhtree_from_mesh_get(&treeData[i], me_highpoly[i], BVHTREE_FROM_FACES, 2);
|
||||
BKE_bvhtree_from_mesh_get(&treeData[i], me_highpoly[i], BVHTREE_FROM_LOOPTRI, 2);
|
||||
|
||||
if (treeData[i].tree == NULL) {
|
||||
printf("Baking: out of memory while creating BHVTree for object \"%s\"\n", highpoly[i].ob->id.name + 2);
|
||||
|
|
Loading…
Reference in New Issue