Merge branch 'blender2.8' of git.blender.org:blender into blender2.8

This commit is contained in:
Jeroen Bakker 2018-04-18 12:11:59 +02:00
commit ea0630ade6
8 changed files with 74 additions and 34 deletions

View File

@ -65,8 +65,8 @@ void BKE_override_static_property_operation_delete(
bool BKE_override_static_status_check_local(struct ID *local);
bool BKE_override_static_status_check_reference(struct ID *local);
bool BKE_override_static_operations_create(struct ID *local);
void BKE_main_override_static_operations_create(struct Main *bmain);
bool BKE_override_static_operations_create(struct ID *local, const bool force_auto);
void BKE_main_override_static_operations_create(struct Main *bmain, const bool force_auto);
void BKE_override_static_update(struct Main *bmain, struct ID *local);
void BKE_main_override_static_update(struct Main *bmain);

View File

@ -86,7 +86,7 @@ IDOverrideStatic *BKE_override_static_init(ID *local_id, ID *reference_id)
local_id->override_static = MEM_callocN(sizeof(*local_id->override_static), __func__);
local_id->override_static->reference = reference_id;
id_us_plus(local_id->override_static->reference);
local_id->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
local_id->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
/* TODO do we want to add tag or flag to referee to mark it as such? */
return local_id->override_static;
}
@ -125,7 +125,7 @@ void BKE_override_static_copy(ID *dst_id, const ID *src_id)
bke_override_property_copy(op_dst, op_src);
}
dst_id->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
dst_id->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
}
/** Clear any overriding data from given \a override. */
@ -445,7 +445,7 @@ bool BKE_override_static_status_check_local(ID *local)
&rnaptr_local, &rnaptr_reference, NULL, local->override_static,
RNA_OVERRIDE_COMPARE_IGNORE_NON_OVERRIDABLE | RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN, NULL))
{
local->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
local->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
return false;
}
@ -474,12 +474,12 @@ bool BKE_override_static_status_check_reference(ID *local)
BLI_assert(GS(local->name) == GS(reference->name));
if (reference->override_static && (reference->tag & LIB_TAG_OVERRIDESTATIC_OK) == 0) {
if (reference->override_static && (reference->tag & LIB_TAG_OVERRIDESTATIC_REFOK) == 0) {
if (!BKE_override_static_status_check_reference(reference)) {
/* If reference is also override of another data-block, and its status is not OK,
* then this override is not OK either.
* Note that this should only happen when reloading libraries... */
local->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
local->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
return false;
}
}
@ -492,7 +492,7 @@ bool BKE_override_static_status_check_reference(ID *local)
&rnaptr_local, &rnaptr_reference, NULL, local->override_static,
RNA_OVERRIDE_COMPARE_IGNORE_OVERRIDDEN, NULL))
{
local->tag &= ~LIB_TAG_OVERRIDESTATIC_OK;
local->tag &= ~LIB_TAG_OVERRIDESTATIC_REFOK;
return false;
}
@ -511,13 +511,13 @@ bool BKE_override_static_status_check_reference(ID *local)
* are much cheaper.
*
* \return true is new overriding op was created, or some local data was reset. */
bool BKE_override_static_operations_create(ID *local)
bool BKE_override_static_operations_create(ID *local, const bool force_auto)
{
BLI_assert(local->override_static != NULL);
const bool is_template = (local->override_static->reference == NULL);
bool ret = false;
if (!is_template && local->flag & LIB_OVERRIDE_STATIC_AUTO) {
if (!is_template && (force_auto || local->flag & LIB_OVERRIDE_STATIC_AUTO)) {
PointerRNA rnaptr_local, rnaptr_reference;
RNA_id_pointer_create(local, &rnaptr_local);
RNA_id_pointer_create(local->override_static->reference, &rnaptr_reference);
@ -545,7 +545,7 @@ bool BKE_override_static_operations_create(ID *local)
}
/** Check all overrides from given \a bmain and create/update overriding operations as needed. */
void BKE_main_override_static_operations_create(Main *bmain)
void BKE_main_override_static_operations_create(Main *bmain, const bool force_auto)
{
ListBase *lbarray[MAX_LIBARRAY];
int base_count, i;
@ -557,9 +557,11 @@ void BKE_main_override_static_operations_create(Main *bmain)
ID *id;
for (id = lb->first; id; id = id->next) {
/* TODO Maybe we could also add an 'override update' tag e.g. when tagging for DEG update? */
if (id->lib == NULL && id->override_static != NULL && id->override_static->reference != NULL && (id->flag & LIB_OVERRIDE_STATIC_AUTO)) {
BKE_override_static_operations_create(id);
if (force_auto ||
(ID_IS_STATIC_OVERRIDE_AUTO(id) && (id->tag & LIB_TAG_OVERRIDESTATIC_AUTOREFRESH)))
{
BKE_override_static_operations_create(id, force_auto);
id->tag &= ~LIB_TAG_OVERRIDESTATIC_AUTOREFRESH;
}
}
}
@ -573,7 +575,7 @@ void BKE_override_static_update(Main *bmain, ID *local)
}
/* Recursively do 'ancestors' overrides first, if any. */
if (local->override_static->reference->override_static && (local->override_static->reference->tag & LIB_TAG_OVERRIDESTATIC_OK) == 0) {
if (local->override_static->reference->override_static && (local->override_static->reference->tag & LIB_TAG_OVERRIDESTATIC_REFOK) == 0) {
BKE_override_static_update(bmain, local->override_static->reference);
}
@ -624,7 +626,7 @@ void BKE_override_static_update(Main *bmain, ID *local)
local->override_static->storage = NULL;
}
local->tag |= LIB_TAG_OVERRIDESTATIC_OK;
local->tag |= LIB_TAG_OVERRIDESTATIC_REFOK;
/* Full rebuild of Depsgraph! */
DEG_on_visible_update(bmain, true); /* XXX Is this actual valid replacement for old DAG_relations_tag_update(bmain) ? */
@ -686,7 +688,7 @@ ID *BKE_override_static_operations_store_start(OverrideStaticStorage *override_s
}
/* Forcefully ensure we know about all needed override operations. */
BKE_override_static_operations_create(local);
BKE_override_static_operations_create(local, false);
ID *storage_id;
#ifdef DEBUG_OVERRIDE_TIMEIT

View File

@ -395,7 +395,7 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, bContext *C, const char
/* Might not be final place for this to be called - probably only want to call it from some
* undo handlers, not all of them? */
BKE_main_override_static_operations_create(CTX_data_main(C));
BKE_main_override_static_operations_create(CTX_data_main(C), false);
/* Remove all undos after (also when 'ustack->step_active == NULL'). */
while (ustack->steps.last != ustack->step_active) {

View File

@ -241,6 +241,10 @@ void flush_editors_id_update(Main *bmain,
/* Inform editors. */
if (deg_copy_on_write_is_expanded(id_cow)) {
deg_editors_id_update(update_ctx, id_cow);
/* ID may need to get its auto-override operations refreshed. */
if (ID_IS_STATIC_OVERRIDE_AUTO(id_orig)) {
id_orig->tag |= LIB_TAG_OVERRIDESTATIC_AUTOREFRESH;
}
/* Inform draw engines that something was changed. */
flush_engine_data_update(id_cow);
}

View File

@ -886,6 +886,8 @@ static void OBJECT_cache_init(void *vedata)
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
OBJECT_PrivateData *g_data;
/* TODO : use dpi setting for enabling the second pass */
const bool do_outline_expand = false;
if (!stl->g_data) {
/* Alloc transient pointers */
@ -968,15 +970,17 @@ static void OBJECT_cache_init(void *vedata)
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_expand);
DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_blur_tx);
DRW_shgroup_uniform_bool(grp, "doExpand", &bTrue, 1);
DRW_shgroup_uniform_bool(grp, "doExpand", (do_outline_expand) ? &bTrue : &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
psl->outlines_bleed = DRW_pass_create("Outlines Bleed Pass", state);
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_bleed);
DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_color_tx);
DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
if (do_outline_expand) {
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_bleed);
DRW_shgroup_uniform_texture_ref(grp, "outlineColor", &e_data.outlines_color_tx);
DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
}
}
{
@ -984,9 +988,10 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_resolve = DRW_pass_create("Outlines Resolve Pass", state);
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
GPUTexture **outline_tx = (do_outline_expand) ? &e_data.outlines_blur_tx : &e_data.outlines_color_tx;
DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_aa_sh, psl->outlines_resolve);
DRW_shgroup_uniform_texture_ref(grp, "outlineBluredColor", &e_data.outlines_blur_tx);
DRW_shgroup_uniform_texture_ref(grp, "outlineBluredColor", outline_tx);
DRW_shgroup_uniform_vec2(grp, "rcpDimensions", e_data.inv_viewport_size, 1);
DRW_shgroup_call_add(grp, quad, NULL);
}

View File

@ -40,8 +40,8 @@ void main()
#ifdef GL_ARB_texture_gather
vec2 texel_size = 1.0 / vec2(textureSize(outlineId, 0).xy);
vec2 uv1 = floor(gl_FragCoord.xy) * texel_size - texel_size;
vec2 uv2 = floor(gl_FragCoord.xy) * texel_size;
vec2 uv1 = ceil(gl_FragCoord.xy) * texel_size - texel_size;
vec2 uv2 = ceil(gl_FragCoord.xy) * texel_size;
/* Samples order is CW starting from top left. */
uvec4 tmp1 = textureGather(outlineId, uv1);
@ -52,19 +52,36 @@ void main()
#else
uvec4 id;
uint ref_id = texelFetch(outlineId, texel, 0).r;
id.x = texelFetchOffset(outlineId, texel, 0, ivec2( 1, 0)).r;
id.y = texelFetchOffset(outlineId, texel, 0, ivec2( 0, 1)).r;
id.z = texelFetchOffset(outlineId, texel, 0, ivec2(-1, 0)).r;
id.w = texelFetchOffset(outlineId, texel, 0, ivec2( 0, -1)).r;
id.x = texelFetchOffset(outlineId, texel, 0, ivec2(-1, 0)).r;
id.y = texelFetchOffset(outlineId, texel, 0, ivec2( 0, -1)).r;
id.z = texelFetchOffset(outlineId, texel, 0, ivec2( 0, 1)).r;
id.w = texelFetchOffset(outlineId, texel, 0, ivec2( 1, 0)).r;
#endif
float ref_depth = texelFetch(outlineDepth, texel, 0).r;
float scene_depth = texelFetch(sceneDepth, texel, 0).r;
bool outline = any(notEqual(id, uvec4(ref_id)));
ivec2 depth_texel = texel;
/* If texel is an outline but has no valid id ...
* replace id and depth texel by a valid one.
* This keeps the outline thickness consistent everywhere. */
if (ref_id == 0u && outline) {
depth_texel = (id.x != 0u) ? texel + ivec2(-1, 0) : depth_texel;
depth_texel = (id.y != 0u) ? texel + ivec2( 0, -1) : depth_texel;
depth_texel = (id.z != 0u) ? texel + ivec2( 0, 1) : depth_texel;
depth_texel = (id.w != 0u) ? texel + ivec2( 1, 0) : depth_texel;
ref_id = (id.x != 0u) ? id.x : ref_id;
ref_id = (id.y != 0u) ? id.y : ref_id;
ref_id = (id.z != 0u) ? id.z : ref_id;
ref_id = (id.w != 0u) ? id.w : ref_id;
}
float ref_depth = texelFetch(outlineDepth, depth_texel, 0).r;
float scene_depth = texelFetch(sceneDepth, depth_texel, 0).r;
/* Avoid bad cases of zfighting for occlusion only. */
const float epsilon = 3.0 / 8388608.0;
bool occluded = (ref_depth > scene_depth + epsilon);
bool outline = any(notEqual(id, uvec4(ref_id)));
FragColor = convert_id_to_color(int(ref_id));
FragColor.a *= (occluded) ? alphaOcclu : 1.0;

View File

@ -2437,6 +2437,12 @@ static int make_override_static_exec(bContext *C, wmOperator *op)
base = BKE_view_layer_base_find(view_layer, new_ob);
BKE_view_layer_base_select(view_layer, base);
}
else {
/* Disable auto-override tags for non-active objects, will help with performaces... */
new_ob->id.flag &= ~LIB_OVERRIDE_STATIC_AUTO;
}
/* We still want to store all objects' current override status (i.e. change of parent). */
BKE_override_static_operations_create(&new_ob->id, true);
}
}
FOREACH_GROUP_OBJECT_END;

View File

@ -387,6 +387,10 @@ typedef enum ID_Type {
#define ID_IS_STATIC_OVERRIDE_TEMPLATE(_id) (((ID *)(_id))->override_static != NULL && \
((ID *)(_id))->override_static->reference == NULL)
#define ID_IS_STATIC_OVERRIDE_AUTO(_id) (!ID_IS_LINKED((_id)) && \
ID_IS_STATIC_OVERRIDE((_id)) && \
(((ID *)(_id))->flag & LIB_OVERRIDE_STATIC_AUTO))
#ifdef GS
# undef GS
#endif
@ -435,7 +439,9 @@ enum {
LIB_TAG_MISSING = 1 << 6,
/* RESET_NEVER tag datablock as being up-to-date regarding its reference. */
LIB_TAG_OVERRIDESTATIC_OK = 1 << 9,
LIB_TAG_OVERRIDESTATIC_REFOK = 1 << 9,
/* RESET_NEVER tag datablock as needing an auto-override execution, if enabled. */
LIB_TAG_OVERRIDESTATIC_AUTOREFRESH = 1 << 17,
/* tag datablock has having an extra user. */
LIB_TAG_EXTRAUSER = 1 << 2,