From fd0b74280e05025d99195bc1ea73815551ecba8a Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 17 Jun 2014 12:16:02 -0300 Subject: Bake-API: allow custom UV to be baked Note: the custom UV option is only available when calling the operator via a script. It's currently not exposed in the UI since it's intended to be used by scripters To test it: bpy.ops.object.bake(type='UV', use_clear=True, uv_layer='MyNewUV') Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D546 --- source/blender/render/extern/include/RE_bake.h | 2 +- source/blender/render/intern/source/bake_api.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'source/blender/render') diff --git a/source/blender/render/extern/include/RE_bake.h b/source/blender/render/extern/include/RE_bake.h index 961ca3fdd6d..8f2a0e382a4 100644 --- a/source/blender/render/extern/include/RE_bake.h +++ b/source/blender/render/extern/include/RE_bake.h @@ -87,7 +87,7 @@ bool RE_bake_pixels_populate_from_objects( void RE_bake_pixels_populate( struct Mesh *me, struct BakePixel *pixel_array, - const int num_pixels, const struct BakeImages *bake_images); + const int num_pixels, const struct BakeImages *bake_images, const char *uv_layer); void RE_bake_mask_fill(const BakePixel pixel_array[], const int num_pixels, char *mask); diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c index 713f7b8f808..28cb916dca1 100644 --- a/source/blender/render/intern/source/bake_api.c +++ b/source/blender/render/intern/source/bake_api.c @@ -594,7 +594,7 @@ static void bake_differentials(BakeDataZSpan *bd, const float *uv1, const float void RE_bake_pixels_populate( Mesh *me, BakePixel pixel_array[], - const int num_pixels, const BakeImages *bake_images) + const int num_pixels, const BakeImages *bake_images, const char *uv_layer) { BakeDataZSpan bd; int i, a; @@ -619,7 +619,14 @@ void RE_bake_pixels_populate( zbuf_alloc_span(&bd.zspan[i], bake_images->data[i].width, bake_images->data[i].height, R.clipcrop); } - mtface = CustomData_get_layer(&me->fdata, CD_MTFACE); + if (uv_layer == NULL) { + mtface = CustomData_get_layer(&me->fdata, CD_MTFACE); + } + else { + int uv_id = CustomData_get_named_layer(&me->fdata, CD_MTFACE, uv_layer); + mtface = CustomData_get_layer_n(&me->fdata, CD_MTFACE, uv_id); + } + mface = CustomData_get_layer(&me->fdata, CD_MFACE); if (mtface == NULL) -- cgit v1.2.3