Fix Cycles baking active/cage
authorDalai Felinto <dfelinto@gmail.com>
Fri, 7 Dec 2018 19:01:45 +0000 (17:01 -0200)
committerDalai Felinto <dfelinto@gmail.com>
Tue, 11 Dec 2018 23:57:16 +0000 (21:57 -0200)
commit6871402614f48ef9c454d057c544ed43abeb87ae
treed8e97b1993d626c3dfc6004abdb98df9e851f73f
parent174acd9ca376a4fb0e4a50d27359ee5f8ac7f3fe
Fix Cycles baking active/cage

Basically what we address here is to make sure the active object and the cage
are not interferring with the baking result (e.g., when baking Combined).

To do so, we take advantage of the fact that we create our own depsgraph
for baking. So now we can change the cowed objects, instead of the
original ones.

Note: There is still a way to get a crash. If you try to bake from
selected to active when is_cage, but with no cage object, we get an
assert:

```
BLI_assert failed: //source/blender/blenkernel/intern/DerivedMesh.c
mesh_calc_modifiers(), at
(((Mesh *)ob->data)->id.tag & LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT) == 0
```

We can bypass this by passing ob_low instead of ob_low_eval to
bake_mesh_new_from_object on object_bake_api.c:847 . But then the edge
split modifier change will take no effect.
source/blender/editors/object/object_bake_api.c
source/blender/render/extern/include/RE_bake.h