Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_bake_api.c
| Show First 20 Lines • Show All 516 Lines • ▼ Show 20 Lines | if (use_selected_to_active) { | ||||
| tot_highpoly = 0; | tot_highpoly = 0; | ||||
| for (link = selected_objects->first; link; link = link->next) { | for (link = selected_objects->first; link; link = link->next) { | ||||
| Object *ob_iter = link->ptr.data; | Object *ob_iter = link->ptr.data; | ||||
| if (ob_iter == ob_low) | if (ob_iter == ob_low) | ||||
| continue; | continue; | ||||
| if (!is_uniform_scaled_m4(ob_iter->obmat)) { | |||||
| BKE_reportf(reports, RPT_INFO, "Selected objects must have uniform scale " | |||||
| "(apply scale to object \"%s\" for correct results)", ob_iter->id.name + 2); | |||||
| } | |||||
| tot_highpoly ++; | tot_highpoly ++; | ||||
| } | } | ||||
| if (tot_highpoly == 0) { | if (tot_highpoly == 0) { | ||||
| BKE_report(reports, RPT_ERROR, "No valid selected objects"); | BKE_report(reports, RPT_ERROR, "No valid selected objects"); | ||||
| goto cleanup; | goto cleanup; | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | else { | ||||
| me_low = BKE_mesh_new_from_object(bmain, scene, ob_low, 1, 2, 1, 0); | me_low = BKE_mesh_new_from_object(bmain, scene, ob_low, 1, 2, 1, 0); | ||||
| copy_m4_m4(mat_low, ob_low->obmat); | copy_m4_m4(mat_low, ob_low->obmat); | ||||
| } | } | ||||
| /* populate highpoly array */ | /* populate highpoly array */ | ||||
| for (link = selected_objects->first; link; link = link->next) { | for (link = selected_objects->first; link; link = link->next) { | ||||
| TriangulateModifierData *tmd; | TriangulateModifierData *tmd; | ||||
| Object *ob_iter = link->ptr.data; | Object *ob_iter = link->ptr.data; | ||||
campbellbarton: This doesn't need to be initialized. | |||||
| if (ob_iter == ob_low) | if (ob_iter == ob_low) | ||||
| continue; | continue; | ||||
| /* initialize highpoly_data */ | /* initialize highpoly_data */ | ||||
| highpoly[i].ob = ob_iter; | highpoly[i].ob = ob_iter; | ||||
| highpoly[i].me = NULL; | highpoly[i].me = NULL; | ||||
| highpoly[i].tri_mod = NULL; | highpoly[i].tri_mod = NULL; | ||||
| highpoly[i].restrict_flag = ob_iter->restrictflag; | highpoly[i].restrict_flag = ob_iter->restrictflag; | ||||
| highpoly[i].pixel_array = MEM_callocN(sizeof(BakePixel) * num_pixels, "bake pixels high poly"); | highpoly[i].pixel_array = MEM_callocN(sizeof(BakePixel) * num_pixels, "bake pixels high poly"); | ||||
| /* triangulating so BVH returns the primitive_id that will be used for rendering */ | /* triangulating so BVH returns the primitive_id that will be used for rendering */ | ||||
| highpoly[i].tri_mod = ED_object_modifier_add( | highpoly[i].tri_mod = ED_object_modifier_add( | ||||
| reports, bmain, scene, highpoly[i].ob, | reports, bmain, scene, highpoly[i].ob, | ||||
| "TmpTriangulate", eModifierType_Triangulate); | "TmpTriangulate", eModifierType_Triangulate); | ||||
| tmd = (TriangulateModifierData *)highpoly[i].tri_mod; | tmd = (TriangulateModifierData *)highpoly[i].tri_mod; | ||||
| tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED; | tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED; | ||||
| tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP; | tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP; | ||||
| highpoly[i].me = BKE_mesh_new_from_object(bmain, scene, highpoly[i].ob, 1, 2, 1, 0); | highpoly[i].me = BKE_mesh_new_from_object(bmain, scene, highpoly[i].ob, 1, 2, 1, 0); | ||||
| highpoly[i].ob->restrictflag &= ~OB_RESTRICT_RENDER; | highpoly[i].ob->restrictflag &= ~OB_RESTRICT_RENDER; | ||||
| /* lowpoly to highpoly transformation matrix */ | /* lowpoly to highpoly transformation matrix */ | ||||
| copy_m4_m4(highpoly[i].mat_high, highpoly[i].ob->obmat); | copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->obmat); | ||||
| invert_m4_m4(highpoly[i].imat_high, highpoly[i].mat_high); | invert_m4_m4(highpoly[i].imat, highpoly[i].obmat); | ||||
| highpoly[i].scale = mat4_to_scale(highpoly[i].mat_high); | |||||
| /* rotation */ | |||||
| normalize_m4_m4(highpoly[i].rotmat, highpoly[i].imat); | |||||
| zero_v3(highpoly[i].rotmat[3]); | |||||
| if (is_negative_m4(highpoly[i].rotmat)) | |||||
| negate_m3(highpoly[i].rotmat); | |||||
| i++; | i++; | ||||
| } | } | ||||
| BLI_assert(i == tot_highpoly); | BLI_assert(i == tot_highpoly); | ||||
| /* populate the pixel array with the face data */ | /* populate the pixel array with the face data */ | ||||
| RE_bake_pixels_populate(me_low, pixel_array_low, num_pixels, &bake_images); | RE_bake_pixels_populate(me_low, pixel_array_low, num_pixels, &bake_images); | ||||
| ▲ Show 20 Lines • Show All 492 Lines • Show Last 20 Lines | |||||
This doesn't need to be initialized.