Merge branch 'master' into blender2.8

Conflicts:
	source/blender/modifiers/intern/MOD_wireframe.c
This commit is contained in:
2018-01-24 12:14:59 +01:00
6 changed files with 93 additions and 26 deletions

View File

@@ -310,6 +310,7 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
/* update __data */ /* update __data */
kfilm->exposure = exposure; kfilm->exposure = exposure;
kfilm->pass_flag = 0; kfilm->pass_flag = 0;
kfilm->light_pass_flag = 0;
kfilm->pass_stride = 0; kfilm->pass_stride = 0;
kfilm->use_light_pass = use_light_visibility || use_sample_clamp; kfilm->use_light_pass = use_light_visibility || use_sample_clamp;

View File

@@ -434,6 +434,11 @@ bool modifiers_isParticleEnabled(Object *ob)
return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)); return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render));
} }
/**
* Check whether is enabled.
*
* \param scene Current scene, may be NULL, in which case isDisabled callback of the modifier is never called.
*/
bool modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode) bool modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode)
{ {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type); const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -441,7 +446,7 @@ bool modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode
md->scene = scene; md->scene = scene;
if ((md->mode & required_mode) != required_mode) return false; if ((md->mode & required_mode) != required_mode) return false;
if (mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return false; if (scene != NULL && mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return false;
if (md->mode & eModifierMode_DisableTemporary) return false; if (md->mode & eModifierMode_DisableTemporary) return false;
if ((required_mode & eModifierMode_Editmode) && !(mti->flags & eModifierTypeFlag_SupportsEditmode)) return false; if ((required_mode & eModifierMode_Editmode) && !(mti->flags & eModifierTypeFlag_SupportsEditmode)) return false;

View File

@@ -67,6 +67,7 @@
#include "BKE_global.h" #include "BKE_global.h"
#include "BKE_mesh.h" #include "BKE_mesh.h"
#include "BKE_mesh_mapping.h" #include "BKE_mesh_mapping.h"
#include "BKE_modifier.h"
#include "BKE_multires.h" #include "BKE_multires.h"
#include "BKE_paint.h" #include "BKE_paint.h"
#include "BKE_scene.h" #include "BKE_scene.h"
@@ -4190,7 +4191,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
{ {
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
CCGKey key; CCGKey key;
int numGrids, grid_pbvh; int numGrids;
CCG_key_top_level(&key, ccgdm->ss); CCG_key_top_level(&key, ccgdm->ss);
@@ -4202,35 +4203,85 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
if (!ob->sculpt) if (!ob->sculpt)
return NULL; return NULL;
/* In vwpaint, we always use a grid_pbvh for multires/subsurf */ bool grid_pbvh = ccgDM_use_grid_pbvh(ccgdm);
grid_pbvh = (!(ob->mode & OB_MODE_SCULPT) || ccgDM_use_grid_pbvh(ccgdm)); if ((ob->mode & OB_MODE_SCULPT) == 0) {
/* In vwpaint, we may use a grid_pbvh for multires/subsurf, under certain conditions.
* More complex cases break 'history' trail back to original vertices, in that case we fall back to
* deformed cage only (i.e. original deformed mesh). */
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
grid_pbvh = true;
bool has_one_ccg_modifier = false;
for (; md; md = md->next) {
/* We can only accept to use this ccgdm if:
* - it's the only active ccgdm in the stack.
* - there is no topology-modifying modifier in the stack.
* Otherwise, there is no way to map back to original geometry from grid-generated PBVH.
*/
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (!modifier_isEnabled(NULL, md, eModifierMode_Realtime)) {
continue;
}
if (ELEM(mti->type, eModifierTypeType_OnlyDeform, eModifierTypeType_NonGeometrical)) {
continue;
}
if (ELEM(md->type, eModifierType_Subsurf, eModifierType_Multires)) {
if (has_one_ccg_modifier) {
/* We only allow a single active ccg modifier in the stack. */
grid_pbvh = false;
break;
}
has_one_ccg_modifier = true;
continue;
}
/* Any other non-deforming modifier makes it impossible to use grid pbvh. */
grid_pbvh = false;
break;
}
}
if (ob->sculpt->pbvh) { if (ob->sculpt->pbvh) {
/* Note that we have to clean up exisitng pbvh instead of updating it in case it does not match current
* grid_pbvh status. */
if (grid_pbvh) { if (grid_pbvh) {
/* pbvh's grids, gridadj and gridfaces points to data inside ccgdm if (BKE_pbvh_get_ccgdm(ob->sculpt->pbvh) != NULL) {
* but this can be freed on ccgdm release, this updates the pointers /* pbvh's grids, gridadj and gridfaces points to data inside ccgdm
* when the ccgdm gets remade, the assumption is that the topology * but this can be freed on ccgdm release, this updates the pointers
* does not change. */ * when the ccgdm gets remade, the assumption is that the topology
ccgdm_create_grids(dm); * does not change. */
BKE_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, (void **)ccgdm->gridFaces, ccgdm_create_grids(dm);
ccgdm->gridFlagMats, ccgdm->gridHidden); BKE_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, (void **)ccgdm->gridFaces,
ccgdm->gridFlagMats, ccgdm->gridHidden);
}
else {
BKE_pbvh_free(ob->sculpt->pbvh);
ob->sculpt->pbvh = NULL;
}
}
else if (BKE_pbvh_get_ccgdm(ob->sculpt->pbvh) != NULL) {
BKE_pbvh_free(ob->sculpt->pbvh);
ob->sculpt->pbvh = NULL;
} }
ccgdm->pbvh = ob->sculpt->pbvh; ccgdm->pbvh = ob->sculpt->pbvh;
} }
if (ccgdm->pbvh) { if (ccgdm->pbvh) {
/* For vertex paint, keep track of ccgdm */ /* For grid pbvh, keep track of ccgdm */
if (!(ob->mode & OB_MODE_SCULPT)) { if (grid_pbvh) {
BKE_pbvh_set_ccgdm(ccgdm->pbvh, ccgdm); BKE_pbvh_set_ccgdm(ccgdm->pbvh, ccgdm);
} }
return ccgdm->pbvh; return ccgdm->pbvh;
} }
/* no pbvh exists yet, we need to create one. only in case of multires /* No pbvh exists yet, we need to create one. only in case of multires
* we build a pbvh over the modified mesh, in other cases the base mesh * we build a pbvh over the modified mesh, in other cases the base mesh
* is being sculpted, so we build a pbvh from that. */ * is being sculpted, so we build a pbvh from that. */
/* Note: vwpaint always builds a pbvh over the modified mesh. */ /* Note: vwpaint tries to always build a pbvh over the modified mesh. */
if (grid_pbvh) { if (grid_pbvh) {
ccgdm_create_grids(dm); ccgdm_create_grids(dm);
@@ -4256,6 +4307,18 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
ob->sculpt->pbvh = ccgdm->pbvh = BKE_pbvh_new(); ob->sculpt->pbvh = ccgdm->pbvh = BKE_pbvh_new();
BKE_pbvh_build_mesh(ccgdm->pbvh, me->mpoly, me->mloop, me->mvert, me->totvert, &me->vdata, BKE_pbvh_build_mesh(ccgdm->pbvh, me->mpoly, me->mloop, me->mvert, me->totvert, &me->vdata,
looptri, looptris_num); looptri, looptris_num);
if (ob->sculpt->modifiers_active && ob->derivedDeform != NULL) {
DerivedMesh *deformdm = ob->derivedDeform;
float (*vertCos)[3];
int totvert;
totvert = deformdm->getNumVerts(deformdm);
vertCos = MEM_malloc_arrayN(totvert, sizeof(float[3]), "ccgDM_getPBVH vertCos");
deformdm->getVertCos(deformdm, vertCos);
BKE_pbvh_apply_vertCos(ccgdm->pbvh, vertCos);
MEM_freeN(vertCos);
}
} }
if (ccgdm->pbvh != NULL) { if (ccgdm->pbvh != NULL) {
@@ -4263,8 +4326,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
pbvh_show_mask_set(ccgdm->pbvh, ob->sculpt->show_mask); pbvh_show_mask_set(ccgdm->pbvh, ob->sculpt->show_mask);
} }
/* For vertex paint, keep track of ccgdm */ /* For grid pbvh, keep track of ccgdm. */
if (!(ob->mode & OB_MODE_SCULPT) && ccgdm->pbvh) { if (grid_pbvh && ccgdm->pbvh) {
BKE_pbvh_set_ccgdm(ccgdm->pbvh, ccgdm); BKE_pbvh_set_ccgdm(ccgdm->pbvh, ccgdm);
} }
return ccgdm->pbvh; return ccgdm->pbvh;

View File

@@ -52,11 +52,6 @@ static void copyData(ModifierData *md, ModifierData *target)
modifier_copyData_generic(md, target); modifier_copyData_generic(md, target);
} }
static bool isDisabled(ModifierData *UNUSED(md), int UNUSED(useRenderParams))
{
return false;
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
{ {
WireframeModifierData *wmd = (WireframeModifierData *)md; WireframeModifierData *wmd = (WireframeModifierData *)md;
@@ -132,8 +127,8 @@ ModifierTypeInfo modifierType_Wireframe = {
/* initData */ initData, /* initData */ initData,
/* requiredDataMask */ requiredDataMask, /* requiredDataMask */ requiredDataMask,
/* freeData */ NULL, /* freeData */ NULL,
/* isDisabled */ isDisabled, /* isDisabled */ NULL,
/* updateDepsgraph */ NULL, /* updateDepgraph */ NULL,
/* dependsOnTime */ NULL, /* dependsOnTime */ NULL,
/* dependsOnNormals */ dependsOnNormals, /* dependsOnNormals */ dependsOnNormals,
/* foreachObjectLink */ NULL, /* foreachObjectLink */ NULL,

View File

@@ -34,7 +34,7 @@
/* **************** BUMP ******************** */ /* **************** BUMP ******************** */
static bNodeSocketTemplate sh_node_bump_in[] = { static bNodeSocketTemplate sh_node_bump_in[] = {
{ SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_FLOAT, 1, N_("Distance"), 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, { SOCK_FLOAT, 1, N_("Distance"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, N_("Height"), 1.0f, 1.0f, 1.0f, 1.0f, -1000.0f, 1000.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_FLOAT, 1, N_("Height"), 1.0f, 1.0f, 1.0f, 1.0f, -1000.0f, 1000.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" } { -1, 0, "" }

View File

@@ -3413,11 +3413,14 @@ bool RE_WriteRenderViewsImage(ReportList *reports, RenderResult *rr, Scene *scen
BLI_strncpy(filepath, name, sizeof(filepath)); BLI_strncpy(filepath, name, sizeof(filepath));
for (view_id = 0, rv = rr->views.first; rv; rv = rv->next, view_id++) { for (view_id = 0, rv = rr->views.first; rv; rv = rv->next, view_id++) {
/* Sequencer and OpenGL render can't save multiple EXR layers. */
bool is_float = rv->rect32 == NULL;
if (!is_mono) { if (!is_mono) {
BKE_scene_multiview_view_filepath_get(&scene->r, filepath, rv->name, name); BKE_scene_multiview_view_filepath_get(&scene->r, filepath, rv->name, name);
} }
if (is_exr_rr) { if (is_exr_rr && is_float) {
ok = RE_WriteRenderResult(reports, rr, name, &rd->im_format, rv->name, -1); ok = RE_WriteRenderResult(reports, rr, name, &rd->im_format, rv->name, -1);
render_print_save_message(reports, name, ok, errno); render_print_save_message(reports, name, ok, errno);