Use direct access to evaluated mesh from instancing

It is supposed to be already evaluated. If for some reason it's not
doing such direct evaluation will not be reliable anyway (indirect
dependencies for example).

This fixes an assert part of T61431.
This commit is contained in:
Sergey Sharybin 2019-02-12 16:00:46 +01:00
parent 8614f28234
commit 027c356e23
1 changed files with 19 additions and 9 deletions

View File

@ -387,7 +387,6 @@ static void make_child_duplis_verts(const DupliContext *ctx, void *userdata, Obj
static void make_duplis_verts(const DupliContext *ctx)
{
Scene *scene = ctx->scene;
Object *parent = ctx->object;
bool use_texcoords = (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER);
VertexDupliData vdd;
@ -397,16 +396,22 @@ static void make_duplis_verts(const DupliContext *ctx)
/* gather mesh info */
{
CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO : CD_MASK_BAREMESH);
vdd.edit_btmesh = BKE_editmesh_from_object(parent);
/* We do not need any render-smecific handling anymore, depsgraph takes care of that. */
/* We do not need any render-specific handling anymore, depsgraph takes care of that. */
/* NOTE: Do direct access to the evaluated mesh: this function is used
* during meta balls evaluation. But even without those all the objects
* which are needed for correct instancing are already evaluated. */
if (vdd.edit_btmesh != NULL) {
/* XXX TODO replace with equivalent of editbmesh_get_eval_cage when available. */
vdd.me_eval = mesh_get_eval_deform(ctx->depsgraph, scene, parent, dm_mask);
vdd.me_eval = parent->runtime.mesh_deform_eval;
}
else {
vdd.me_eval = mesh_get_eval_final(ctx->depsgraph, scene, parent, dm_mask);
vdd.me_eval = parent->runtime.mesh_eval;
}
if (vdd.me_eval == NULL) {
return;
}
if (use_texcoords) {
@ -658,7 +663,6 @@ static void make_child_duplis_faces(const DupliContext *ctx, void *userdata, Obj
static void make_duplis_faces(const DupliContext *ctx)
{
Scene *scene = ctx->scene;
Object *parent = ctx->object;
bool use_texcoords = (DEG_get_mode(ctx->depsgraph) == DAG_EVAL_RENDER);
FaceDupliData fdd;
@ -668,15 +672,21 @@ static void make_duplis_faces(const DupliContext *ctx)
/* gather mesh info */
{
BMEditMesh *em = BKE_editmesh_from_object(parent);
CustomDataMask dm_mask = (use_texcoords ? CD_MASK_BAREMESH | CD_MASK_ORCO | CD_MASK_MLOOPUV : CD_MASK_BAREMESH);
/* We do not need any render-smecific handling anymore, depsgraph takes care of that. */
/* NOTE: Do direct access to the evaluated mesh: this function is used
* during meta balls evaluation. But even without those all the objects
* which are needed for correct instancing are already evaluated. */
if (em != NULL) {
/* XXX TODO replace with equivalent of editbmesh_get_eval_cage when available. */
fdd.me_eval = mesh_get_eval_deform(ctx->depsgraph, scene, parent, dm_mask);
fdd.me_eval = parent->runtime.mesh_deform_eval;
}
else {
fdd.me_eval = mesh_get_eval_final(ctx->depsgraph, scene, parent, dm_mask);
fdd.me_eval = parent->runtime.mesh_eval;
}
if (fdd.me_eval == NULL) {
return;
}
if (use_texcoords) {