Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2020-12-23 18:39:36 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-12-24 14:00:58 +0300
commit0b4fae7a51fb869c27d9407b8b5eadeb418d0bfc (patch)
treedfcaaa1048f91bbe766a8314325ea97c8493b534 /source/blender/render/intern/bake.c
parent58c697a9ecebdebfec2c50de49946908bd444070 (diff)
Cleanup: refactoring of bake code in preparation of vertex color baking
Split of internal/external image bake target code off into smaller functions and refactor associated data structures for clarity. Designed so that a vertex color bake target is easy to fit in. Also avoid passing in a huge number of arguments into the main baking function, pass a struct instead.
Diffstat (limited to 'source/blender/render/intern/bake.c')
-rw-r--r--source/blender/render/intern/bake.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/render/intern/bake.c b/source/blender/render/intern/bake.c
index 6f5db4986f2..caf81870fac 100644
--- a/source/blender/render/intern/bake.c
+++ b/source/blender/render/intern/bake.c
@@ -691,7 +691,7 @@ static void bake_differentials(BakeDataZSpan *bd,
void RE_bake_pixels_populate(Mesh *me,
BakePixel pixel_array[],
const size_t num_pixels,
- const BakeImages *bake_images,
+ const BakeTargets *targets,
const char *uv_layer)
{
const MLoopUV *mloopuv;
@@ -709,7 +709,7 @@ void RE_bake_pixels_populate(Mesh *me,
BakeDataZSpan bd;
bd.pixel_array = pixel_array;
- bd.zspan = MEM_callocN(sizeof(ZSpan) * bake_images->size, "bake zspan");
+ bd.zspan = MEM_callocN(sizeof(ZSpan) * targets->num_images, "bake zspan");
/* initialize all pixel arrays so we know which ones are 'blank' */
for (int i = 0; i < num_pixels; i++) {
@@ -717,8 +717,8 @@ void RE_bake_pixels_populate(Mesh *me,
pixel_array[i].object_id = 0;
}
- for (int i = 0; i < bake_images->size; i++) {
- zbuf_alloc_span(&bd.zspan[i], bake_images->data[i].width, bake_images->data[i].height);
+ for (int i = 0; i < targets->num_images; i++) {
+ zbuf_alloc_span(&bd.zspan[i], targets->images[i].width, targets->images[i].height);
}
const int tottri = poly_to_tri_count(me->totpoly, me->totloop);
@@ -731,13 +731,13 @@ void RE_bake_pixels_populate(Mesh *me,
const MPoly *mp = &me->mpoly[lt->poly];
float vec[3][2];
int mat_nr = mp->mat_nr;
- int image_id = bake_images->lookup[mat_nr];
+ int image_id = targets->material_to_image[mat_nr];
if (image_id < 0) {
continue;
}
- bd.bk_image = &bake_images->data[image_id];
+ bd.bk_image = &targets->images[image_id];
bd.primitive_id = i;
for (int a = 0; a < 3; a++) {
@@ -755,7 +755,7 @@ void RE_bake_pixels_populate(Mesh *me,
zspan_scanconvert(&bd.zspan[image_id], (void *)&bd, vec[0], vec[1], vec[2], store_bake_pixel);
}
- for (int i = 0; i < bake_images->size; i++) {
+ for (int i = 0; i < targets->num_images; i++) {
zbuf_free_span(&bd.zspan[i]);
}