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 <brechtvanlommel@gmail.com>2016-02-06 21:12:22 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2016-02-06 21:14:04 +0300
commit3867bef904d5b1fbe7ac6d0f5fc02c19033e2177 (patch)
tree6ae148a400f6832308abd82169579acdd982b60a /source/blender/editors/object/object_bake_api.c
parent2dba2b3d71d9781bce452c78a4f2c686169418b4 (diff)
Fix T47320: Cycles baking in edit mode uses outdated mesh.
Diffstat (limited to 'source/blender/editors/object/object_bake_api.c')
-rw-r--r--source/blender/editors/object/object_bake_api.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 1cf8614004f..51affb3e1fc 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -612,6 +612,18 @@ static size_t initialize_internal_images(BakeImages *bake_images, ReportList *re
return tot_size;
}
+/* create new mesh with edit mode changes and modifiers applied */
+static Mesh *bake_mesh_new_from_object(Main *bmain, Scene *scene, Object *ob)
+{
+ if (ob->mode & OB_MODE_EDIT)
+ ED_object_editmode_load(ob);
+
+ Mesh *me = BKE_mesh_new_from_object(bmain, scene, ob, 1, 2, 0, 0);
+ BKE_mesh_split_faces(me);
+
+ return me;
+}
+
static int bake(
Render *re, Main *bmain, Scene *scene, Object *ob_low, ListBase *selected_objects, ReportList *reports,
const ScenePassType pass_type, const int pass_filter, const int margin,
@@ -751,8 +763,7 @@ static int bake(
result = MEM_callocN(sizeof(float) * depth * num_pixels, "bake return pixels");
/* get the mesh as it arrives in the renderer */
- me_low = BKE_mesh_new_from_object(bmain, scene, ob_low, 1, 2, 0, 0);
- BKE_mesh_split_faces(me_low);
+ me_low = bake_mesh_new_from_object(bmain, scene, ob_low);
/* populate the pixel array with the face data */
if ((is_selected_to_active && (ob_cage == NULL) && is_cage) == false)
@@ -767,8 +778,7 @@ static int bake(
/* prepare cage mesh */
if (ob_cage) {
- me_cage = BKE_mesh_new_from_object(bmain, scene, ob_cage, 1, 2, 0, 0);
- BKE_mesh_split_faces(me_cage);
+ me_cage = bake_mesh_new_from_object(bmain, scene, ob_cage);
if ((me_low->totpoly != me_cage->totpoly) || (me_low->totloop != me_cage->totloop)) {
BKE_report(reports, RPT_ERROR,
"Invalid cage object, the cage mesh must have the same number "
@@ -800,8 +810,7 @@ static int bake(
ob_low->modifiers = modifiers_tmp;
/* get the cage mesh as it arrives in the renderer */
- me_cage = BKE_mesh_new_from_object(bmain, scene, ob_low, 1, 2, 0, 0);
- BKE_mesh_split_faces(me_cage);
+ me_cage = bake_mesh_new_from_object(bmain, scene, ob_low);
RE_bake_pixels_populate(me_cage, pixel_array_low, num_pixels, &bake_images, uv_layer);
}
@@ -827,9 +836,8 @@ static int bake(
tmd->quad_method = MOD_TRIANGULATE_QUAD_FIXED;
tmd->ngon_method = MOD_TRIANGULATE_NGON_EARCLIP;
- highpoly[i].me = BKE_mesh_new_from_object(bmain, scene, highpoly[i].ob, 1, 2, 0, 0);
+ highpoly[i].me = bake_mesh_new_from_object(bmain, scene, highpoly[i].ob);
highpoly[i].ob->restrictflag &= ~OB_RESTRICT_RENDER;
- BKE_mesh_split_faces(highpoly[i].me);
/* lowpoly to highpoly transformation matrix */
copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->obmat);
@@ -931,8 +939,7 @@ cage_cleanup:
md->mode &= ~eModifierMode_Render;
}
- me_nores = BKE_mesh_new_from_object(bmain, scene, ob_low, 1, 2, 0, 0);
- BKE_mesh_split_faces(me_nores);
+ me_nores = bake_mesh_new_from_object(bmain, scene, ob_low);
RE_bake_pixels_populate(me_nores, pixel_array_low, num_pixels, &bake_images, uv_layer);
RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_nores, normal_swizzle, ob_low->obmat);