diff options
Diffstat (limited to 'source/blender/editors/object/object_bake_api.c')
-rw-r--r-- | source/blender/editors/object/object_bake_api.c | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index efcb47f76ab..44f05600d7d 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -180,7 +180,7 @@ static bool write_internal_bake_pixels(Image *image, void *lock; bool is_float; char *mask_buffer = NULL; - const size_t num_pixels = (size_t)width * (size_t)height; + const size_t pixels_num = (size_t)width * (size_t)height; ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); @@ -189,8 +189,8 @@ static bool write_internal_bake_pixels(Image *image, } if (margin > 0 || !is_clear) { - mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask"); - RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer); + mask_buffer = MEM_callocN(sizeof(char) * pixels_num, "Bake Mask"); + RE_bake_mask_fill(pixel_array, pixels_num, mask_buffer); } is_float = (ibuf->rect_float != NULL); @@ -298,7 +298,7 @@ static bool write_internal_bake_pixels(Image *image, /* force OpenGL reload */ static void bake_targets_refresh(BakeTargets *targets) { - for (int i = 0; i < targets->num_images; i++) { + for (int i = 0; i < targets->images_num; i++) { Image *ima = targets->images[i].image; if (ima) { @@ -374,10 +374,10 @@ static bool write_external_bake_pixels(const char *filepath, /* margins */ if (margin > 0) { char *mask_buffer = NULL; - const size_t num_pixels = (size_t)width * (size_t)height; + const size_t pixels_num = (size_t)width * (size_t)height; - mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask"); - RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer); + mask_buffer = MEM_callocN(sizeof(char) * pixels_num, "Bake Mask"); + RE_bake_mask_fill(pixel_array, pixels_num, mask_buffer); RE_bake_margin(ibuf, mask_buffer, margin, margin_type, mesh_eval, uv_layer); if (mask_buffer) { @@ -670,9 +670,9 @@ static bool bake_targets_init_image_textures(const BakeAPIRender *bkr, Object *ob, ReportList *reports) { - int num_materials = ob->totcol; + int materials_num = ob->totcol; - if (num_materials == 0) { + if (materials_num == 0) { if (bkr->save_mode == R_BAKE_SAVE_INTERNAL) { BKE_report( reports, RPT_ERROR, "No active image found, add a material or bake to an external file"); @@ -688,15 +688,15 @@ static bool bake_targets_init_image_textures(const BakeAPIRender *bkr, } /* Over-allocate in case there is more materials than images. */ - targets->num_materials = num_materials; - targets->images = MEM_callocN(sizeof(BakeImage) * targets->num_materials, "BakeTargets.images"); - targets->material_to_image = MEM_callocN(sizeof(int) * targets->num_materials, + targets->materials_num = materials_num; + targets->images = MEM_callocN(sizeof(BakeImage) * targets->materials_num, "BakeTargets.images"); + targets->material_to_image = MEM_callocN(sizeof(int) * targets->materials_num, "BakeTargets.material_to_image"); /* Error handling and tag (in case multiple materials share the same image). */ BKE_main_id_tag_idcode(bkr->main, ID_IM, LIB_TAG_DOIT, false); - for (int i = 0; i < num_materials; i++) { + for (int i = 0; i < materials_num; i++) { Image *image; ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL); @@ -713,10 +713,10 @@ static bool bake_targets_init_image_textures(const BakeAPIRender *bkr, } } else { - targets->material_to_image[i] = targets->num_images; - targets->images[targets->num_images].image = image; + targets->material_to_image[i] = targets->images_num; + targets->images[targets->images_num].image = image; image->id.tag |= LIB_TAG_DOIT; - targets->num_images++; + targets->images_num++; } } @@ -733,7 +733,7 @@ static bool bake_targets_init_internal(const BakeAPIRender *bkr, } /* Saving to image datablocks. */ - for (int i = 0; i < targets->num_images; i++) { + for (int i = 0; i < targets->images_num; i++) { BakeImage *bk_image = &targets->images[i]; void *lock; ImBuf *ibuf = BKE_image_acquire_ibuf(bk_image->image, NULL, &lock); @@ -741,9 +741,9 @@ static bool bake_targets_init_internal(const BakeAPIRender *bkr, if (ibuf) { bk_image->width = ibuf->x; bk_image->height = ibuf->y; - bk_image->offset = targets->num_pixels; + bk_image->offset = targets->pixels_num; - targets->num_pixels += (size_t)ibuf->x * (size_t)ibuf->y; + targets->pixels_num += (size_t)ibuf->x * (size_t)ibuf->y; } else { BKE_image_release_ibuf(bk_image->image, ibuf, lock); @@ -765,12 +765,12 @@ static bool bake_targets_output_internal(const BakeAPIRender *bkr, { bool all_ok = true; - for (int i = 0; i < targets->num_images; i++) { + for (int i = 0; i < targets->images_num; i++) { BakeImage *bk_image = &targets->images[i]; const bool ok = write_internal_bake_pixels(bk_image->image, pixel_array + bk_image->offset, targets->result + - bk_image->offset * targets->num_channels, + bk_image->offset * targets->channels_num, bk_image->width, bk_image->height, bkr->margin, @@ -809,15 +809,15 @@ static bool bake_targets_init_external(const BakeAPIRender *bkr, } /* Saving to disk. */ - for (int i = 0; i < targets->num_images; i++) { + for (int i = 0; i < targets->images_num; i++) { BakeImage *bk_image = &targets->images[i]; bk_image->width = bkr->width; bk_image->height = bkr->height; - bk_image->offset = targets->num_pixels; + bk_image->offset = targets->pixels_num; bk_image->image = NULL; - targets->num_pixels += (size_t)bkr->width * (size_t)bkr->height; + targets->pixels_num += (size_t)bkr->width * (size_t)bkr->height; if (!bkr->is_split_materials) { break; @@ -826,7 +826,7 @@ static bool bake_targets_init_external(const BakeAPIRender *bkr, if (!bkr->is_split_materials) { /* saving a single image */ - for (int i = 0; i < targets->num_materials; i++) { + for (int i = 0; i < targets->materials_num; i++) { targets->material_to_image[i] = 0; } } @@ -844,7 +844,7 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, { bool all_ok = true; - for (int i = 0; i < targets->num_images; i++) { + for (int i = 0; i < targets->images_num; i++) { BakeImage *bk_image = &targets->images[i]; BakeData *bake = &bkr->scene->r.bake; @@ -888,7 +888,7 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, const bool ok = write_external_bake_pixels(name, pixel_array + bk_image->offset, targets->result + - bk_image->offset * targets->num_channels, + bk_image->offset * targets->channels_num, bk_image->width, bk_image->height, bkr->margin, @@ -934,11 +934,11 @@ static bool bake_targets_init_vertex_colors(BakeTargets *targets, Object *ob, Re } targets->images = MEM_callocN(sizeof(BakeImage), "BakeTargets.images"); - targets->num_images = 1; + targets->images_num = 1; targets->material_to_image = MEM_callocN(sizeof(int) * ob->totcol, "BakeTargets.material_to_image"); - targets->num_materials = ob->totcol; + targets->materials_num = ob->totcol; BakeImage *bk_image = &targets->images[0]; bk_image->width = me->totloop; @@ -946,7 +946,7 @@ static bool bake_targets_init_vertex_colors(BakeTargets *targets, Object *ob, Re bk_image->offset = 0; bk_image->image = NULL; - targets->num_pixels = bk_image->width * bk_image->height; + targets->pixels_num = bk_image->width * bk_image->height; return true; } @@ -984,10 +984,10 @@ static void bake_targets_populate_pixels_vertex_colors(BakeTargets *targets, BakePixel *pixel_array) { Mesh *me = ob->data; - const int num_pixels = targets->num_pixels; + const int pixels_num = targets->pixels_num; /* Initialize blank pixels. */ - for (int i = 0; i < num_pixels; i++) { + for (int i = 0; i < pixels_num; i++) { BakePixel *pixel = &pixel_array[i]; pixel->primitive_id = -1; @@ -1059,12 +1059,12 @@ static void bake_targets_populate_pixels_vertex_colors(BakeTargets *targets, MEM_freeN(looptri); } -static void bake_result_add_to_rgba(float rgba[4], const float *result, const int num_channels) +static void bake_result_add_to_rgba(float rgba[4], const float *result, const int channels_num) { - if (num_channels == 4) { + if (channels_num == 4) { add_v4_v4(rgba, result); } - else if (num_channels == 3) { + else if (channels_num == 3) { add_v3_v3(rgba, result); rgba[3] += 1.0f; } @@ -1082,7 +1082,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob) MPropCol *mcol = CustomData_get_layer(&me->vdata, CD_PROP_COLOR); const bool mcol_valid = (mcol != NULL && U.experimental.use_sculpt_vertex_colors); MLoopCol *mloopcol = CustomData_get_layer(&me->ldata, CD_MLOOPCOL); - const int num_channels = targets->num_channels; + const int channels_num = targets->channels_num; const float *result = targets->result; if (mcol_valid) { @@ -1096,7 +1096,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob) MLoop *mloop = me->mloop; for (int i = 0; i < totloop; i++, mloop++) { const int v = mloop->v; - bake_result_add_to_rgba(mcol[v].color, &result[i * num_channels], num_channels); + bake_result_add_to_rgba(mcol[v].color, &result[i * channels_num], channels_num); num_loops_for_vertex[v]++; } @@ -1118,7 +1118,7 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob) for (int i = 0; i < totloop; i++, mloop++, mloopcol++) { float rgba[4]; zero_v4(rgba); - bake_result_add_to_rgba(rgba, &result[i * num_channels], num_channels); + bake_result_add_to_rgba(rgba, &result[i * channels_num], channels_num); if (is_noncolor) { unit_float_to_uchar_clamp_v4(&mloopcol->r, rgba); @@ -1160,13 +1160,13 @@ static bool bake_targets_init(const BakeAPIRender *bkr, } } - if (targets->num_pixels == 0) { + if (targets->pixels_num == 0) { return false; } targets->is_noncolor = is_noncolor_pass(bkr->pass_type); - targets->num_channels = RE_pass_depth(bkr->pass_type); - targets->result = MEM_callocN(sizeof(float) * targets->num_channels * targets->num_pixels, + targets->channels_num = RE_pass_depth(bkr->pass_type); + targets->result = MEM_callocN(sizeof(float) * targets->channels_num * targets->pixels_num, "bake return pixels"); return true; @@ -1182,7 +1182,7 @@ static void bake_targets_populate_pixels(const BakeAPIRender *bkr, bake_targets_populate_pixels_vertex_colors(targets, ob, me_eval, pixel_array); } else { - RE_bake_pixels_populate(me_eval, pixel_array, targets->num_pixels, targets, bkr->uv_layer); + RE_bake_pixels_populate(me_eval, pixel_array, targets->pixels_num, targets, bkr->uv_layer); } } @@ -1329,7 +1329,7 @@ static int bake(const BakeAPIRender *bkr, /* Populate the pixel array with the face data. Except if we use a cage, then * it is populated later with the cage mesh (smoothed version of the mesh). */ - pixel_array_low = MEM_mallocN(sizeof(BakePixel) * targets.num_pixels, "bake pixels low poly"); + pixel_array_low = MEM_mallocN(sizeof(BakePixel) * targets.pixels_num, "bake pixels low poly"); if ((bkr->is_selected_to_active && (ob_cage == NULL) && bkr->is_cage) == false) { bake_targets_populate_pixels(bkr, &targets, ob_low, me_low_eval, pixel_array_low); } @@ -1422,7 +1422,7 @@ static int bake(const BakeAPIRender *bkr, ob_low_eval->base_flag &= ~(BASE_VISIBLE_DEPSGRAPH | BASE_ENABLED_RENDER); /* populate the pixel arrays with the corresponding face data for each high poly object */ - pixel_array_high = MEM_mallocN(sizeof(BakePixel) * targets.num_pixels, + pixel_array_high = MEM_mallocN(sizeof(BakePixel) * targets.pixels_num, "bake pixels high poly"); if (!RE_bake_pixels_populate_from_objects(me_low_eval, @@ -1430,7 +1430,7 @@ static int bake(const BakeAPIRender *bkr, pixel_array_high, highpoly, tot_highpoly, - targets.num_pixels, + targets.pixels_num, ob_cage != NULL, bkr->cage_extrusion, bkr->max_ray_distance, @@ -1491,16 +1491,16 @@ static int bake(const BakeAPIRender *bkr, break; } RE_bake_normal_world_to_world(pixel_array_low, - targets.num_pixels, - targets.num_channels, + targets.pixels_num, + targets.channels_num, targets.result, bkr->normal_swizzle); break; } case R_BAKE_SPACE_OBJECT: { RE_bake_normal_world_to_object(pixel_array_low, - targets.num_pixels, - targets.num_channels, + targets.pixels_num, + targets.channels_num, targets.result, ob_low_eval, bkr->normal_swizzle); @@ -1509,8 +1509,8 @@ static int bake(const BakeAPIRender *bkr, case R_BAKE_SPACE_TANGENT: { if (bkr->is_selected_to_active) { RE_bake_normal_world_to_tangent(pixel_array_low, - targets.num_pixels, - targets.num_channels, + targets.pixels_num, + targets.channels_num, targets.result, me_low_eval, bkr->normal_swizzle, @@ -1535,8 +1535,8 @@ static int bake(const BakeAPIRender *bkr, } RE_bake_normal_world_to_tangent(pixel_array_low, - targets.num_pixels, - targets.num_channels, + targets.pixels_num, + targets.channels_num, targets.result, (me_nores) ? me_nores : me_low_eval, bkr->normal_swizzle, |