[Bf-blender-cvs] [03fc433e18] render-layers: Fix unittest for cases where we set render_layer but not scene_collection
Commit: 03fc433e183a78f4b888ac07fce75d43272b102c Author: Dalai Felinto Date: Wed Jan 18 11:59:26 2017 +0100 Branches: render-layers https://developer.blender.org/rB03fc433e183a78f4b888ac07fce75d43272b102c Fix unittest for cases where we set render_layer but not scene_collection === M tests/python/bl_render_layer.py === diff --git a/tests/python/bl_render_layer.py b/tests/python/bl_render_layer.py index 1b85b0da0b..be3b8befcb 100644 --- a/tests/python/bl_render_layer.py +++ b/tests/python/bl_render_layer.py @@ -823,6 +823,7 @@ class UnitsTesting(unittest.TestCase): subzero.objects.link(three_b) scorpion.objects.link(three_c) layer = scene.render_layers.new('Fresh new Layer') +layer.collections.unlink(layer.collections.active) layer.collections.link(subzero) layer.collections.active_index = 3 self.assertEqual(layer.collections.active.name, 'scorpion') @@ -883,6 +884,7 @@ class UnitsTesting(unittest.TestCase): # change active layer override = bpy.context.copy() override["render_layer"] = layer +override["scene_collection"] = layer.collections.active.collection # add new objects if add_mode == 'EMPTY': ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [597cafb873] render-layers: Fix context operator test
Commit: 597cafb873867ba599e8a496fc8ebd5fdbe0e0be Author: Dalai Felinto Date: Wed Jan 18 11:56:28 2017 +0100 Branches: render-layers https://developer.blender.org/rB597cafb873867ba599e8a496fc8ebd5fdbe0e0be Fix context operator test We needed a fallback for the cases where the layer was specified but not a scene_collection === M source/blender/blenkernel/intern/context.c === diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 9beeeac628..592adfc578 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -912,12 +912,27 @@ SceneLayer *CTX_data_scene_layer(const bContext *C) } } +/** + * This is tricky. Sometimes the user overrides the render_layer + * but not the scene_collection. In this case what to do? + * + * If the scene_collection is linked to the SceneLayer we use it. + * Otherwise we fallback to the active one of the SceneLayer. + */ SceneCollection *CTX_data_scene_collection(const bContext *C) { + SceneLayer *sl = CTX_data_scene_layer(C); SceneCollection *sc; if (ctx_data_pointer_verify(C, "scene_collection", (void *)&sc)) { - return sc; + if (BKE_scene_layer_has_collection(sl, sc)) { + return sc; + } + else { + /* fallback */ + LayerCollection *lc = BKE_layer_collection_active(sl); + return lc->scene_collection; + } } else { return C->data.scene_collection; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [53eabca4e8] render-layers: BKE_scene_layer_has_collection
Commit: 53eabca4e86c1f4c47132da01bd81e348de1ac10 Author: Dalai Felinto Date: Wed Jan 18 11:48:35 2017 +0100 Branches: render-layers https://developer.blender.org/rB53eabca4e86c1f4c47132da01bd81e348de1ac10 BKE_scene_layer_has_collection Util function to check if a SceneCollection is linked to a SceneLayer This is needed for corner cases of bpy.context.scene_collection when the context render_layer mismatches the context scene_collection. === M source/blender/blenkernel/BKE_layer.h M source/blender/blenkernel/intern/layer.c === diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index bd925b735d..9ae9cdb3e3 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -78,6 +78,7 @@ struct LayerCollection *BKE_collection_link(struct SceneLayer *sl, struct SceneC void BKE_collection_unlink(struct SceneLayer *sl, struct LayerCollection *lc); +bool BKE_scene_layer_has_collection(struct SceneLayer *sl, struct SceneCollection *sc); bool BKE_scene_has_object(struct Scene *scene, struct Object *ob); /* syncing */ diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index b92624e4c1..14739c88ca 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -44,8 +44,9 @@ #include "MEM_guardedalloc.h" /* prototype */ -LayerCollection *layer_collection_add(SceneLayer *sl, ListBase *lb, SceneCollection *sc); void layer_collection_free(SceneLayer *sl, LayerCollection *lc); +LayerCollection *layer_collection_add(SceneLayer *sl, ListBase *lb, SceneCollection *sc); +LayerCollection *find_layer_collection_by_scene_collection(LayerCollection *lc, const SceneCollection *sc); /* RenderLayer */ @@ -463,6 +464,19 @@ LayerCollection *layer_collection_add(SceneLayer *sl, ListBase *lb, SceneCollect /* -- */ /** + * See if render layer has the scene collection linked directly, or indirectly (nested) + */ +bool BKE_scene_layer_has_collection(struct SceneLayer *sl, struct SceneCollection *sc) +{ + for (LayerCollection *lc = sl->layer_collections.first; lc; lc = lc->next) { + if (find_layer_collection_by_scene_collection(lc, sc) != NULL) { + return true; + } + } + return false; +} + +/** * See if the object is in any of the scene layers of the scene */ bool BKE_scene_has_object(Scene *scene, Object *ob) @@ -480,7 +494,7 @@ bool BKE_scene_has_object(Scene *scene, Object *ob) /* -- */ /* Syncing */ -static LayerCollection *find_layer_collection_by_scene_collection(LayerCollection *lc, const SceneCollection *sc) +LayerCollection *find_layer_collection_by_scene_collection(LayerCollection *lc, const SceneCollection *sc) { if (lc->scene_collection == sc) { return lc; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/repos/bf-blender [61777] trunk/lib/tests/layers: Unittest for render layers (2.8): object add tests
Revision: 61777 https://developer.blender.org/rBL61777 Author: dfelinto Date: 2017-01-18 12:01:14 +0100 (Wed, 18 Jan 2017) Log Message: --- Unittest for render layers (2.8): object add tests Modified Paths: -- trunk/lib/tests/layers/layers_object_add_cylinder.json trunk/lib/tests/layers/layers_object_add_empty.json trunk/lib/tests/layers/layers_object_add_torus.json Modified: trunk/lib/tests/layers/layers_object_add_cylinder.json === --- trunk/lib/tests/layers/layers_object_add_cylinder.json 2017-01-13 15:44:32 UTC (rev 61776) +++ trunk/lib/tests/layers/layers_object_add_cylinder.json 2017-01-18 11:01:14 UTC (rev 61777) @@ -133,7 +133,8 @@ "T.1a", "T.2a", "T.3b", -"T.3c" +"T.3c", +"Cylinder" ] }, "1-3": { @@ -206,7 +207,8 @@ "T.3d", "T.3c", "T.3b", -"T.3a" +"T.3a", +"Cylinder" ] }, "3": { @@ -363,7 +365,8 @@ "T.3b", "T.3a", "T.4a", -"T.5a" +"T.5a", +"Cylinder" ] }, "Fresh new Layer": { @@ -490,7 +493,8 @@ "T.3d", "T.3a", "T.4a", -"T.5a" +"T.5a", +"Cylinder" ] }, "Render Layer": { @@ -595,7 +599,8 @@ "T.3b", "T.3a", "T.4a", -"T.5a" +"T.5a", +"Cylinder" ] } -} +} \ No newline at end of file Modified: trunk/lib/tests/layers/layers_object_add_empty.json === --- trunk/lib/tests/layers/layers_object_add_empty.json 2017-01-13 15:44:32 UTC (rev 61776) +++ trunk/lib/tests/layers/layers_object_add_empty.json 2017-01-18 11:01:14 UTC (rev 61777) @@ -133,7 +133,8 @@ "T.1a", "T.2a", "T.3b", -"T.3c" +"T.3c", +"Empty" ] }, "1-3": { @@ -206,7 +207,8 @@ "T.3d", "T.3c", "T.3b", -"T.3a" +"T.3a", +"Empty" ] }, "3": { @@ -363,7 +365,8 @@ "T.3b", "T.3a", "T.4a", -"T.5a" +"T.5a", +"Empty" ] }, "Fresh new Layer": { @@ -490,7 +493,8 @@ "T.3d", "T.3a", "T.4a", -"T.5a" +"T.5a", +"Empty" ] }, "Render Layer": { @@ -595,7 +599,8 @@ "T.3b", "T.3a", "T.4a", -"T.5a" +"T.5a", +"Empty" ] } -} +} \ No newline at end of file Modified: trunk/lib/tests/layers/layers_object_add_torus.json === --- trunk/lib/tests/layers/layers_object_add_torus.json 2017-01-13 15:44:32 UTC (rev 61776) +++ trunk/lib/tests/layers/layers_object_add_torus.json 2017-01-18 11:01:14 UTC (rev 61777) @@ -133,7 +133,8 @@ "T.1a", "T.2a", "T.3b", -"T.3c" +"T.3c", +"Torus" ] }, "1-3": { @@ -206,7 +207,8 @@ "T.3d", "T.3c", "T.3b", -"T.3a" +"T.3a", +"Torus" ] }, "3": { @@ -363,7 +365,8 @@ "T.3b", "T.3a", "T.4a", -"T.5a" +"T.5a", +"Torus" ] }, "Fresh new Layer": { @@ -490,7 +493,8 @@ "T.3d", "T.3a", "T.4a", -"T.5a" +"T.5a", +"Torus" ] }, "Render Layer": { @@ -595,7 +599,8 @@ "T.3b", "T.3a", "T.4a", -"T.5a" +"T.5a", +"Torus" ] } -} +} \ No newline at end of file ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e138cdeeb6] master: Transform manipulator: Allow first clicking Shift before selecting axis
Commit: e138cdeeb637bb63f2a66728db1c3281ac1fca09 Author: Sergey Sharybin Date: Thu Dec 15 11:12:43 2016 +0100 Branches: master https://developer.blender.org/rBe138cdeeb637bb63f2a66728db1c3281ac1fca09 Transform manipulator: Allow first clicking Shift before selecting axis Avoids possible jumps when one is trying to do some really preciese tweak. Quite striaghtforward change for mouse input initialization: take Shift state into account. However, this will interfere with the axis exclusion which is currently also uses Shift (the feature to move something in a plane which doesn't have selected axis). This is probably not so commonly used feature (nobody in the studio even knew of it) and the only downside now would be that such a constrainted movement will become accurate by default. That's easy to deal from user side by just unholding Shift key. Reviewers: brecht, mont29, Severin Differential Revision: https://developer.blender.org/D2418 === M source/blender/editors/transform/transform.c M source/blender/editors/transform/transform.h M source/blender/editors/transform/transform_input.c === diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 20c62e91d0..31ffa019e4 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2176,7 +2176,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve calculateCenter(t); if (event) { - initMouseInput(t, &t->mouse, t->center2d, event->mval); + initMouseInput(t, &t->mouse, t->center2d, event->mval, event->shift); } switch (mode) { @@ -8495,7 +8495,7 @@ static void initTimeScale(TransInfo *t) center[1] = t->mouse.imval[1]; /* force a reinit with the center2d used here */ - initMouseInput(t, &t->mouse, center, t->mouse.imval); + initMouseInput(t, &t->mouse, center, t->mouse.imval, false); initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index a59f9dc43d..7ea4448a44 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -728,7 +728,7 @@ typedef enum { INPUT_CUSTOM_RATIO_FLIP, } MouseInputMode; -void initMouseInput(TransInfo *t, MouseInput *mi, const float center[2], const int mval[2]); +void initMouseInput(TransInfo *t, MouseInput *mi, const float center[2], const int mval[2], const bool precision); void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode); eRedrawFlag handleMouseInput(struct TransInfo *t, struct MouseInput *mi, const struct wmEvent *event); void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, const int mval[2], float output[3]); diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 9b7d19eacd..42cc918ec8 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -234,10 +234,10 @@ static void InputAngleSpring(TransInfo *t, MouseInput *mi, const double mval[2], output[1] = toutput[0]; } -void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, const float center[2], const int mval[2]) +void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, const float center[2], const int mval[2], const bool precision) { mi->factor = 0; - mi->precision = 0; + mi->precision = precision; mi->center[0] = center[0]; mi->center[1] = center[1]; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d216313732] master: Cleanup: Strict compiler flags
Commit: d216313732e69317a77de2a9368483f5c922c32c Author: Sergey Sharybin Date: Wed Jan 18 12:20:53 2017 +0100 Branches: master https://developer.blender.org/rBd216313732e69317a77de2a9368483f5c922c32c Cleanup: Strict compiler flags Also seems the new file forced trailing whitespace, which goes against https://wiki.blender.org/index.php/Dev:Doc/Code_Style#Trailing_Space === M source/blender/editors/gpencil/gpencil_interpolate.c === diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 22aa92e6d7..0d3fa1fc90 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -1052,7 +1052,7 @@ static int gpencil_interpolate_reverse_poll(bContext *C) return 1; } -static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *op) +static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op)) { /* Go through each layer, deleting the breakdowns around the current frame, * but only if there is a keyframe nearby to stop at ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [196520fe7d] master: GPencil: Fix unreported error in animation after rename items
Commit: 196520fe7d813996193423f896c5aa38c084cac2 Author: Antonio Vazquez Date: Wed Jan 18 12:25:49 2017 +0100 Branches: master https://developer.blender.org/rB196520fe7d813996193423f896c5aa38c084cac2 GPencil: Fix unreported error in animation after rename items If the layers or the colors were renamed, the animation data was wrong because the data path was not updated. I also have fixed a possible stroke color name update if the name was duplicated moving the rename function call after checking unique name. === M source/blender/makesrna/intern/rna_gpencil.c === diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 9c66a86dce..95d567698d 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -31,6 +31,8 @@ #include "MEM_guardedalloc.h" +#include "BKE_animsys.h" + #include "BLI_string_utils.h" #include "BLI_utildefines.h" @@ -353,10 +355,16 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) bGPdata *gpd = ptr->id.data; bGPDlayer *gpl = ptr->data; + char oldname[128] = ""; + BLI_strncpy(oldname, gpl->info, sizeof(oldname)); + /* copy the new name into the name slot */ BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info)); BLI_uniquename(&gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); + + /* now fix animation paths */ + BKE_animdata_fix_paths_rename_all(&gpd->id, "layers", oldname, gpl->info); } static void rna_GPencil_use_onion_skinning_set(PointerRNA *ptr, const int value) @@ -814,14 +822,20 @@ static void rna_GPencilPaletteColor_info_set(PointerRNA *ptr, const char *value) bGPdata *gpd = ptr->id.data; bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); bGPDpalettecolor *palcolor = ptr->data; - - /* rename all strokes */ - BKE_gpencil_palettecolor_changename(gpd, palcolor->info, value); + + char oldname[64] = ""; + BLI_strncpy(oldname, palcolor->info, sizeof(oldname)); /* copy the new name into the name slot */ BLI_strncpy_utf8(palcolor->info, value, sizeof(palcolor->info)); BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), '.', offsetof(bGPDpalettecolor, info), sizeof(palcolor->info)); + + /* rename all strokes */ + BKE_gpencil_palettecolor_changename(gpd, oldname, palcolor->info); + + /* now fix animation paths */ + BKE_animdata_fix_paths_rename_all(&gpd->id, "colors", oldname, palcolor->info); } static void rna_GPencilStrokeColor_info_set(PointerRNA *ptr, const char *value) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [86b6006ef8] master: GPencil: Cleanup - move include line to correct scope
Commit: 86b6006ef8461149e37c868b1ef2e6c9f2957a39 Author: Antonio Vazquez Date: Wed Jan 18 13:00:09 2017 +0100 Branches: master https://developer.blender.org/rB86b6006ef8461149e37c868b1ef2e6c9f2957a39 GPencil: Cleanup - move include line to correct scope === M source/blender/makesrna/intern/rna_gpencil.c === diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 95d567698d..25cd7265c3 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -31,8 +31,6 @@ #include "MEM_guardedalloc.h" -#include "BKE_animsys.h" - #include "BLI_string_utils.h" #include "BLI_utildefines.h" @@ -62,6 +60,7 @@ static EnumPropertyItem parent_type_items[] = { #include "WM_api.h" +#include "BKE_animsys.h" #include "BKE_gpencil.h" #include "BKE_action.h" ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [259447300f] master: GPencil: "Add Blank Frame" operator (D+B)
Commit: 259447300f67e66169211950137b862e8a018d0e Author: Joshua Leung Date: Thu Jan 19 02:11:51 2017 +1300 Branches: master https://developer.blender.org/rB259447300f67e66169211950137b862e8a018d0e GPencil: "Add Blank Frame" operator (D+B) This operator adds a new frame with nothing in it on the current frame. If there is already a frame there, all existing frames are shifted one frame later. Quite often when animating, you may want a quick way to get a blank frame, ready to start drawing something new. Or maybe you just need a quick way to add a "placeholder" frame so that a suddenly-appearing element does not show up before its time. === M release/scripts/startup/bl_ui/properties_grease_pencil_common.py M source/blender/editors/gpencil/gpencil_edit.c M source/blender/editors/gpencil/gpencil_intern.h M source/blender/editors/gpencil/gpencil_ops.c === diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index 3d68930e63..3df60584d3 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -115,6 +115,12 @@ class GreasePencilDrawingToolsPanel: row.operator("gpencil.draw", icon='LINE_DATA', text="Line").mode = 'DRAW_STRAIGHT' row.operator("gpencil.draw", icon='MESH_DATA', text="Poly").mode = 'DRAW_POLY' +col.separator() + +sub = col.column(align=True) +sub.operator("gpencil.blank_frame_add", icon='NEW') +sub.operator("gpencil.active_frames_delete_all", icon='X', text="Delete Frame(s)") + sub = col.column(align=True) sub.prop(context.tool_settings, "use_gpencil_additive_drawing", text="Additive Drawing") sub.prop(context.tool_settings, "use_gpencil_continuous_drawing", text="Continuous Drawing") diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 36c7ef78d9..1f351657c2 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -682,6 +682,80 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot) RNA_def_enum_funcs(ot->prop, ED_gpencil_layers_with_new_enum_itemf); } +/* * Add Blank Frame *** */ + +/* Basically the same as the drawing op */ +static int gp_blank_frame_add_poll(bContext *C) +{ + if (ED_operator_regionactive(C)) { + /* check if current context can support GPencil data */ + if (ED_gpencil_data_get_pointers(C, NULL) != NULL) { + return 1; + } + else { + CTX_wm_operator_poll_msg_set(C, "Failed to find Grease Pencil data to draw into"); + } + } + else { + CTX_wm_operator_poll_msg_set(C, "Active region not set"); + } + + return 0; +} + +static int gp_blank_frame_add_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + bGPdata *gpd = ED_gpencil_data_get_active(C); + bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); + + /* Initialise datablock and an active layer if nothing exists yet */ + if (ELEM(NULL, gpd, gpl)) { + /* let's just be lazy, and call the "Add New Layer" operator, which sets everything up as required */ + WM_operator_name_call(C, "GPENCIL_OT_layer_add", WM_OP_EXEC_DEFAULT, NULL); + } + + /* Go through each layer, adding a frame after the active one +* and/or shunting all the others out of the way +*/ + CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) + { + /* 1) Check for an existing frame on the current frame */ + bGPDframe *gpf = BKE_gpencil_layer_find_frame(gpl, CFRA); + if (gpf) { + /* Shunt all frames after (and including) the existing one later by 1-frame */ + for (; gpf; gpf = gpf->next) { + gpf->framenum += 1; + } + } + + /* 2) Now add a new frame, with nothing in it */ + gpl->actframe = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_NEW); + } + CTX_DATA_END; + + /* notifiers */ + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + + return OPERATOR_FINISHED; +} + +void GPENCIL_OT_blank_frame_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Blank Frame"; + ot->idname = "GPENCIL_OT_blank_frame_add"; + ot->description = "Add a new frame with nothing in it on the current fram
[Bf-blender-cvs] [7452af0f86] master: Fix: Avoid creating redundant frames when erasing
Commit: 7452af0f868b061a63648e9c351090462d7b01e8 Author: Joshua Leung Date: Thu Jan 19 02:57:08 2017 +1300 Branches: master https://developer.blender.org/rB7452af0f868b061a63648e9c351090462d7b01e8 Fix: Avoid creating redundant frames when erasing Now the eraser checks if there's an active frame with some strokes in it before creating a new frame. There's no point in creating a new frame if there are no strokes in the active frame (if one exists). This still doesn't help much if there were strokes but they weren't touched though... === M source/blender/editors/gpencil/gpencil_paint.c === diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index c2228a932f..74c7a45a24 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1631,8 +1631,14 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) /* Add a new frame if needed (and based off the active frame, * as we need some existing strokes to erase) +* +* Note: We don't add a new frame if there's nothing there now, so +* -> If there are no frames at all, don't add one +* -> If there are no strokes in that frame, don't add a new empty frame */ - gpl->actframe = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_COPY); + if (gpl->actframe && gpl->actframe->strokes.first) { + gpl->actframe = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_COPY); + } /* XXX: we omit GP_FRAME_PAINT here for now, * as it is only really useful for doing @@ -1655,7 +1661,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) if (p->gpf == NULL) { p->status = GP_STATUS_ERROR; //if (G.debug & G_DEBUG) - printf("Error: No frame created (gpencil_paint_init)\n"); + printf("Error: No frame created for eraser on active layer (gpencil_paint_init)\n"); return; } } @@ -2602,7 +2608,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } else if (p->status != GP_STATUS_ERROR) { /* User clicked outside bounds of window while idling, so exit paintmode -* NOTE: Don't eter this case if an error occurred while finding the +* NOTE: Don't enter this case if an error occurred while finding the * region (as above) */ /* if drawing polygon and enable on back, must move stroke */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a93881d704] master: GPencil: Pressing 'B' while in 'Continuous Drawing' mode will create a blank frame
Commit: a93881d70433853c2f77a13bb176a9758316811b Author: Joshua Leung Date: Thu Jan 19 02:24:41 2017 +1300 Branches: master https://developer.blender.org/rBa93881d70433853c2f77a13bb176a9758316811b GPencil: Pressing 'B' while in 'Continuous Drawing' mode will create a blank frame This is a hardcoded keymapping that just calls the "Add Blank Frame" operator introduced in the previous commit. === M source/blender/editors/gpencil/gpencil_paint.c === diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index c23bfb1ff6..c2228a932f 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -2432,6 +2432,14 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* enable continuous if release D key in mid drawing */ p->scene->toolsettings->gpencil_flags |= GP_TOOL_FLAG_PAINTSESSIONS_ON; } + else if ((event->type == BKEY) && (event->val == KM_RELEASE)) { + /* Add Blank Frame +* - Since this operator is non-modal, we can just call it here, and keep going... +* - This operator is especially useful when animating +*/ + WM_operator_name_call(C, "GPENCIL_OT_blank_frame_add", WM_OP_EXEC_DEFAULT, NULL); + estate = OPERATOR_RUNNING_MODAL; + } else { estate = OPERATOR_RUNNING_MODAL; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [00edc600b0] master: Fix: Make it possible to erase strokes (on other layers) even if the active layer doesn't have any frames
Commit: 00edc600b0319fc239ae4cb9c0a98452b2d6c74e Author: Joshua Leung Date: Thu Jan 19 03:00:33 2017 +1300 Branches: master https://developer.blender.org/rB00edc600b0319fc239ae4cb9c0a98452b2d6c74e Fix: Make it possible to erase strokes (on other layers) even if the active layer doesn't have any frames === M source/blender/editors/gpencil/gpencil_paint.c === diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 74c7a45a24..5879306b06 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1623,8 +1623,9 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) * 2) Ensure that p->gpf refers to the frame used for the active layer *(to avoid problems with other tools which expect it to exist) */ - bGPDlayer *gpl; - for (gpl = p->gpd->layers.first; gpl; gpl = gpl->next) { + bool has_layer_to_erase = false; + + for (bGPDlayer *gpl = p->gpd->layers.first; gpl; gpl = gpl->next) { /* Skip if layer not editable */ if (gpencil_layer_is_editable(gpl) == false) continue; @@ -1638,6 +1639,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) */ if (gpl->actframe && gpl->actframe->strokes.first) { gpl->actframe = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_COPY); + has_layer_to_erase = true; } /* XXX: we omit GP_FRAME_PAINT here for now, @@ -1658,10 +1660,10 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) } } - if (p->gpf == NULL) { + if (has_layer_to_erase == false) { p->status = GP_STATUS_ERROR; //if (G.debug & G_DEBUG) - printf("Error: No frame created for eraser on active layer (gpencil_paint_init)\n"); + printf("Error: Eraser will not be affecting anything (gpencil_paint_init)\n"); return; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6d868d9f48] master: Reproject Strokes - To Surface/Geometry
Commit: 6d868d9f48a35a0576e9e4e7b6442bdc0fc8d282 Author: Joshua Leung Date: Thu Jan 19 03:20:44 2017 +1300 Branches: master https://developer.blender.org/rB6d868d9f48a35a0576e9e4e7b6442bdc0fc8d282 Reproject Strokes - To Surface/Geometry Experimental option for the Reproject Strokes operator to project strokes on to geometry, instead of only doing this in a planar (i.e. parallel to viewplane) way. The current implementation is quite rough, and may need to be improved before it is really ready for use. Potential issues: * Loss of precision (i.e. stairstepping artifacts) from the 3D -> 2D -> 3D conversion as we don't have float version of one of the projection funcs * Jagged depth if there are gaps, since it will default back to the 3d-cursor plane if no geometry was found (instead of doing some fancy interpolation scheme) * I'm not sure if it's that useful for adapting GP strokes to deforming geometry yet... === M release/scripts/startup/bl_ui/properties_grease_pencil_common.py M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index 3df60584d3..4529c12783 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -248,7 +248,7 @@ class GreasePencilStrokeEditPanel: if is_3d_view: layout.separator() -layout.operator("gpencil.reproject") +layout.operator_menu_enum("gpencil.reproject", text="Reproject Strokes...", property="type") class GreasePencilInterpolatePanel: diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 1f351657c2..8470cd78d9 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1971,6 +1971,13 @@ void GPENCIL_OT_stroke_flip(wmOperatorType *ot) /* * Reproject Strokes ** */ +typedef enum eGP_ReprojectModes { + /* On same plane, parallel to viewplane */ + GP_REPROJECT_PLANAR = 0, + /* Reprojected on to the scene geometry */ + GP_REPROJECT_SURFACE, +} eGP_ReprojectModes; + static int gp_strokes_reproject_poll(bContext *C) { /* 2 Requirements: @@ -1980,14 +1987,23 @@ static int gp_strokes_reproject_poll(bContext *C) return (gp_stroke_edit_poll(C) && ED_operator_view3d_active(C)); } -static int gp_strokes_reproject_exec(bContext *C, wmOperator *UNUSED(op)) +static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); GP_SpaceConversion gsc = {NULL}; + eGP_ReprojectModes mode = RNA_boolean_get(op->ptr, "type"); /* init space conversion stuff */ gp_point_conversion_init(C, &gsc); + /* init autodist for geometry projection */ + if (mode == GP_REPROJECT_SURFACE) { + view3d_region_operator_needs_opengl(CTX_wm_window(C), gsc.ar); + ED_view3d_autodist_init(scene, gsc.ar, CTX_wm_view3d(C), 0); + } + + // TODO: For deforming geometry workflow, create new frames? + /* Go through each editable + selected stroke, adjusting each of its points one by one... */ GP_EDITABLE_STROKES_BEGIN(C, gpl, gps) { @@ -2023,7 +2039,27 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *UNUSED(op)) /* Project screenspace back to 3D space (from current perspective) * so that all points have been treated the same way */ - gp_point_xy_to_3d(&gsc, scene, xy, &pt->x); + if (mode == GP_REPROJECT_PLANAR) { + /* Planar - All on same plane parallel to the viewplane */ + gp_point_xy_to_3d(&gsc, scene, xy, &pt->x); + } + else { + /* Geometry - Snap to surfaces of visible geometry */ + /* XXX: There will be precision loss (possible stairstep artifacts) from this conversion to satisfy the API's */ + const int screen_co[2] = {(int)xy[0], (int)xy[1]}; + + int depth_margin = 0; // XXX: 4 for strokes, 0 for normal + float depth; + + /* XXX: The proper procedure computes the depths into an array, to have s
[Bf-blender-cvs] [10db593060] render-layers: Merge remote-tracking branch 'origin/blender2.8' into render-layers
Commit: 10db593060798424cd4f5ac0f2be98c97d4fee55 Author: Dalai Felinto Date: Wed Jan 18 12:51:49 2017 +0100 Branches: render-layers https://developer.blender.org/rB10db593060798424cd4f5ac0f2be98c97d4fee55 Merge remote-tracking branch 'origin/blender2.8' into render-layers Manual fix: collection.c layer.c === === diff --cc source/blender/blenkernel/intern/collection.c index aa22801e48,00..5357589d0e mode 100644,00..100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@@ -1,426 -1,0 +1,427 @@@ +/* + * * BEGIN GPL LICENSE BLOCK * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Dalai Felinto + * + * * END GPL LICENSE BLOCK * + */ + +/** \file blender/blenkernel/intern/collection.c + * \ingroup bke + */ + +#include "BLI_blenlib.h" +#include "BLI_ghash.h" +#include "BLI_iterator.h" +#include "BLI_listbase.h" +#include "BLT_translation.h" ++#include "BLI_string_utils.h" + +#include "BKE_collection.h" +#include "BKE_layer.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_scene.h" + +#include "DNA_ID.h" +#include "DNA_layer_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +/** + * Add a collection to a collection ListBase and syncronize all render layers + * The ListBase is NULL when the collection is to be added to the master collection + */ +SceneCollection *BKE_collection_add(Scene *scene, SceneCollection *sc_parent, const char *name) +{ + SceneCollection *sc = MEM_callocN(sizeof(SceneCollection), "New Collection"); + SceneCollection *sc_master = BKE_collection_master(scene); + + BLI_strncpy(sc->name, name, sizeof(sc->name)); + BLI_uniquename(&sc_master->scene_collections, sc, DATA_("Collection"), '.', offsetof(SceneCollection, name), sizeof(sc->name)); + + BLI_addtail(&sc_parent->scene_collections, sc); + + BKE_layer_sync_new_scene_collection(scene, sc_parent, sc); + return sc; +} + +/** + * Free the collection items recursively + */ +static void collection_free(SceneCollection *sc) +{ + for (LinkData *link = sc->objects.first; link; link = link->next) { + id_us_min(link->data); + } + BLI_freelistN(&sc->objects); + + for (LinkData *link = sc->filter_objects.first; link; link = link->next) { + id_us_min(link->data); + } + BLI_freelistN(&sc->filter_objects); + + for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { + collection_free(nsc); + } + BLI_freelistN(&sc->scene_collections); +} + +/** + * Unlink the collection recursively + * return true if unlinked + */ +static bool collection_remlink(SceneCollection *sc_parent, SceneCollection *sc_gone) +{ + for (SceneCollection *sc = sc_parent->scene_collections.first; sc; sc = sc->next) + { + if (sc == sc_gone) { + BLI_remlink(&sc_parent->scene_collections, sc_gone); + return true; + } + + if (collection_remlink(sc, sc_gone)) { + return true; + } + } + return false; +} + +/** + * Recursively remove any instance of this SceneCollection + */ +static void layer_collection_remove(SceneLayer *sl, ListBase *lb, const SceneCollection *sc) +{ + LayerCollection *lc = lb->first; + while(lc) { + if (lc->scene_collection == sc) { + BKE_layer_collection_free(sl, lc); + BLI_remlink(lb, lc); + + LayerCollection *lc_next = lc->next; + MEM_freeN(lc); + lc = lc_next; + + /* only the "top-level" layer collections may have the + * same SceneCollection in a sibling tree. + */ + if (lb != &sl->layer_collections) { + return; + } +
[Bf-blender-cvs] [550446bade] render-layers: Tag areas of code that require TODO_LAYER_COPY
Commit: 550446bade47ae55234f38c1590d9bbad3674dd7 Author: Dalai Felinto Date: Wed Jan 18 15:41:27 2017 +0100 Branches: render-layers https://developer.blender.org/rB550446bade47ae55234f38c1590d9bbad3674dd7 Tag areas of code that require TODO_LAYER_COPY === M source/blender/editors/armature/armature_relations.c M source/blender/editors/curve/editcurve.c M source/blender/editors/mesh/editmesh_tools.c === diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index ad53b4c478..c1821a8781 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -578,7 +578,7 @@ static void separate_armature_bones(Object *ob, short sel) /* separate selected bones into their armature */ static int separate_armature_exec(bContext *C, wmOperator *op) { -#if 0 /* TODO_LAYER */ +#if 0 Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); SceneLayer *sl = CTX_data_scene_layer(C); @@ -661,10 +661,13 @@ static int separate_armature_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; #else + TODO_LAYER_COPY; + (void)C; (void)op; (void)separate_armature_bones; (void)separated_armature_fix_links; + BKE_report(op->reports, RPT_ERROR, "ARMATURE_OT_separate not supported at the moment"); return OPERATOR_CANCELLED; #endif } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 448d6db510..63c67b1016 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1331,7 +1331,8 @@ static int separate_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; #else /* need to refactor this to use ObjectBase and create a new object in the correct SceneCollection */ - TODO_LAYER_BASE + TODO_LAYER_COPY; + TODO_LAYER_BASE; (void)C; BKE_report(op->reports, RPT_ERROR, "CURVE_OT_separate not supported at the moment"); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 87b7b25f16..e97b230470 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3360,7 +3360,8 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; #else /* need to refactor this to use ObjectBase and create a new object in the correct SceneCollection */ - TODO_LAYER_BASE + TODO_LAYER_BASE; + TODO_LAYER_COPY; (void)C; (void)mesh_separate_loose; (void)mesh_separate_material; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b059a71655] master: GPencil: Avoid variable shadowing
Commit: b059a7165549893f629ed189622745e675659d53 Author: Sergey Sharybin Date: Wed Jan 18 15:56:04 2017 +0100 Branches: master https://developer.blender.org/rBb059a7165549893f629ed189622745e675659d53 GPencil: Avoid variable shadowing === M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 8470cd78d9..3ac085e23d 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -707,10 +707,10 @@ static int gp_blank_frame_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); bGPdata *gpd = ED_gpencil_data_get_active(C); - bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); + bGPDlayer *active_gpl = BKE_gpencil_layer_getactive(gpd); /* Initialise datablock and an active layer if nothing exists yet */ - if (ELEM(NULL, gpd, gpl)) { + if (ELEM(NULL, gpd, active_gpl)) { /* let's just be lazy, and call the "Add New Layer" operator, which sets everything up as required */ WM_operator_name_call(C, "GPENCIL_OT_layer_add", WM_OP_EXEC_DEFAULT, NULL); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a48d3417b5] master: Fix strict compiler warning message
Commit: a48d3417b566236ad48a107e6d0b98687f96c4fd Author: Sergey Sharybin Date: Wed Jan 18 15:56:40 2017 +0100 Branches: master https://developer.blender.org/rBa48d3417b566236ad48a107e6d0b98687f96c4fd Fix strict compiler warning message === M source/blender/editors/gpencil/gpencil_edit.c === diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 3ac085e23d..d6381b 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -685,7 +685,7 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot) /* * Add Blank Frame *** */ /* Basically the same as the drawing op */ -static int gp_blank_frame_add_poll(bContext *C) +static int UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C) { if (ED_operator_regionactive(C)) { /* check if current context can support GPencil data */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f81ead6c38] HMD_viewport: Fix blenderplayer build
Commit: f81ead6c387b6d5a586a550432ce25fafa9f2cb5 Author: Dalai Felinto Date: Wed Jan 18 16:34:01 2017 +0100 Branches: HMD_viewport https://developer.blender.org/rBf81ead6c387b6d5a586a550432ce25fafa9f2cb5 Fix blenderplayer build === M source/blenderplayer/bad_level_call_stubs/stubs.c === diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index babcc1fa72..ed43d21c00 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -398,6 +398,7 @@ void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *s void ED_uvedit_get_aspect(struct Scene *scene, struct Object *ob, struct BMesh *em, float *aspx, float *aspy) RET_NONE +bool ED_screen_is_editable(const struct bScreen *screen) RET_ZERO void ED_screen_set_scene(struct bContext *C, struct bScreen *screen, struct Scene *scene) RET_NONE struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc) RET_NULL void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip) RET_NONE ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [76dead8603] clay-engine: Basic Implementation of GTAO : There is still artifacts to remove and optimisation to do.
Commit: 76dead8603141f1f38a600701f2c6597318774a0 Author: Clément Foucault Date: Wed Jan 18 18:55:56 2017 +0100 Branches: clay-engine https://developer.blender.org/rB76dead8603141f1f38a600701f2c6597318774a0 Basic Implementation of GTAO : There is still artifacts to remove and optimisation to do. === M source/blender/draw/engines/clay/clay.c M source/blender/draw/engines/clay/shaders/clay_frag.glsl M source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl M source/blender/draw/engines/clay/shaders/ssao_groundtruth.glsl === diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 7cfe156339..32d18e8da1 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -111,6 +111,8 @@ typedef struct CLAY_PassList{ struct DRWPass *mode_ob_center_pass; } CLAY_PassList; +// #define GTAO + /* Functions */ static void add_icon_to_rect(PreviewImage *prv, float *final_rect, int layer) @@ -210,9 +212,14 @@ static struct GPUTexture *create_jitter_texture(void) /* TODO replace by something more evenly distributed like blue noise */ for (i = 0; i < 64 * 64; i++) { +#ifdef GTAO + jitter[i][0] = BLI_frand(); + jitter[i][1] = BLI_frand(); +#else jitter[i][0] = 2.0f * BLI_frand() - 1.0f; jitter[i][1] = 2.0f * BLI_frand() - 1.0f; normalize_v2(jitter[i]); +#endif } return DRW_texture_create_2D(64, 64, DRW_TEX_RG_16, DRW_TEX_FILTER | DRW_TEX_WRAP, &jitter[0][0]); @@ -291,7 +298,11 @@ static void clay_engine_init(void) char *matcap_with_ao; BLI_dynstr_append(ds, datatoc_clay_frag_glsl); +#ifdef GTAO + BLI_dynstr_append(ds, datatoc_ssao_groundtruth_glsl); +#else BLI_dynstr_append(ds, datatoc_ssao_alchemy_glsl); +#endif matcap_with_ao = BLI_dynstr_get_cstring(ds); diff --git a/source/blender/draw/engines/clay/shaders/clay_frag.glsl b/source/blender/draw/engines/clay/shaders/clay_frag.glsl index 16178a48eb..9bc4a4ef3b 100644 --- a/source/blender/draw/engines/clay/shaders/clay_frag.glsl +++ b/source/blender/draw/engines/clay/shaders/clay_frag.glsl @@ -40,7 +40,7 @@ out vec4 fragColor; /* TODO Move this to SSAO modules */ /* simple depth reconstruction, see http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer * we change the factors from the article to fit the OpennGL model. */ -vec3 get_view_space_from_depth(in vec2 uvcoords, in vec3 viewvec_origin, in vec3 viewvec_diff, in float depth) +vec3 get_view_space_from_depth(in vec2 uvcoords, in float depth) { if (WinMatrix[3][3] == 0.0) { /* Perspective */ @@ -48,13 +48,13 @@ vec3 get_view_space_from_depth(in vec2 uvcoords, in vec3 viewvec_origin, in vec3 float zview = -WinMatrix[3][2] / (d + WinMatrix[2][2]); - return zview * (viewvec_origin + vec3(uvcoords, 0.0) * viewvec_diff); + return zview * (viewvecs[0].xyz + vec3(uvcoords, 0.0) * viewvecs[1].xyz); } else { /* Orthographic */ vec3 offset = vec3(uvcoords, depth); - return vec3(viewvec_origin + offset * viewvec_diff); + return viewvecs[0].xyz + offset * viewvecs[1].xyz; } } @@ -163,7 +163,7 @@ void main() { vec2 screenco = vec2(gl_FragCoord.xy) / vec2(screenres); float depth = texture(depthtex, screenco).r; - vec3 position = get_view_space_from_depth(screenco, viewvecs[0].xyz, viewvecs[1].xyz, depth); + vec3 position = get_view_space_from_depth(screenco, depth); vec3 normal = calculate_view_space_normal(position); /* Manual Depth test */ diff --git a/source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl b/source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl index 0f216bf5a3..ff6728185b 100644 --- a/source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl +++ b/source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl @@ -38,7 +38,7 @@ void ssao_factors(in float depth, in vec3 normal, in vec3 position, in vec2 scre bool is_background = (depth_new == 1.0); /* This trick provide good edge effect even if no neighboor is found. */ - vec3 pos_new = get_view_space_from_depth(uvcoords, viewvecs[0].xyz, viewvecs[1].xyz, (is_background) ? depth : depth_new); + vec3 pos_new = get_view_space_from_depth(uvcoords, (is_background) ? depth : depth_new); if (is_background) pos_new.z -= ssao_distance; diff --git a/source/blender/draw/engines/clay/shaders/ssao_groundtruth.glsl b/source/blender/draw/engines/clay/shaders/ssao_groundtruth.
[Bf-blender-cvs] [e6bba9fa3a] clay-engine: Edge AO improvement when geometry is over the background.
Commit: e6bba9fa3a9c0368a550c6cc6413d756fe8a149b Author: Clément Foucault Date: Tue Jan 17 12:59:39 2017 +0100 Branches: clay-engine https://developer.blender.org/rBe6bba9fa3a9c0368a550c6cc6413d756fe8a149b Edge AO improvement when geometry is over the background. === M source/blender/draw/engines/clay/clay.c M source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl === diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 8aaafb635d..7cfe156339 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -53,10 +53,8 @@ typedef struct CLAY_BatchStorage { static struct CLAY_data { /* Depth Pre Pass */ struct GPUShader *depth_sh; - struct DRWInterface *depth_itf; /* Shading Pass */ struct GPUShader *clay_sh[8]; - struct DRWInterface *clay_itf; /* Matcap textures */ struct GPUTexture *matcap_array; diff --git a/source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl b/source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl index f1ca611428..0f216bf5a3 100644 --- a/source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl +++ b/source/blender/draw/engines/clay/shaders/ssao_alchemy.glsl @@ -21,6 +21,7 @@ void ssao_factors(in float depth, in vec3 normal, in vec3 position, in vec2 scre int num_samples = int(ssao_samples_num); for (x = 0; x < num_samples; x++) { + /* TODO : optimisation replace by constant */ vec2 dir_sample = texture1D(ssao_samples, (float(x) + 0.5) / ssao_samples_num).rg; /* rotate with random direction to get jittered result */ @@ -32,24 +33,30 @@ void ssao_factors(in float depth, in vec3 normal, in vec3 position, in vec2 scre continue; float depth_new = texture2D(depthtex, uvcoords).r; + /* Handle Background case */ - if (depth_new != 1.0) { - vec3 pos_new = get_view_space_from_depth(uvcoords, viewvecs[0].xyz, viewvecs[1].xyz, depth_new); - vec3 dir = pos_new - position; - float len = length(dir); - float f_cavities = dot(dir, normal); - float f_edge = dot(dir, -normal); - float f_bias = 0.05 * len + 0.0001; - - float attenuation = 1.0 / (len * (1.0 + len * len * ssao_attenuation)); - - /* use minor bias here to avoid self shadowing */ - if (f_cavities > f_bias) - cavities += f_cavities * attenuation; - - if (f_edge > f_bias) - edges += f_edge * attenuation; - } + bool is_background = (depth_new == 1.0); + + /* This trick provide good edge effect even if no neighboor is found. */ + vec3 pos_new = get_view_space_from_depth(uvcoords, viewvecs[0].xyz, viewvecs[1].xyz, (is_background) ? depth : depth_new); + + if (is_background) + pos_new.z -= ssao_distance; + + vec3 dir = pos_new - position; + float len = length(dir); + float f_cavities = dot(dir, normal); + float f_edge = -f_cavities; + float f_bias = 0.05 * len + 0.0001; + + float attenuation = 1.0 / (len * (1.0 + len * len * ssao_attenuation)); + + /* use minor bias here to avoid self shadowing */ + if (f_cavities > -f_bias) + cavities += f_cavities * attenuation; + + if (f_edge > f_bias) + edges += f_edge * attenuation; } cavities /= ssao_samples_num; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fd4728c85a] master: BMesh: Use angle_signed_on_axis_v3v3v3_v3
Commit: fd4728c85a6e3a7041f6ff62d73b15e432b84f92 Author: Campbell Barton Date: Thu Jan 19 07:59:32 2017 +1100 Branches: master https://developer.blender.org/rBfd4728c85a6e3a7041f6ff62d73b15e432b84f92 BMesh: Use angle_signed_on_axis_v3v3v3_v3 === M source/blender/bmesh/intern/bmesh_construct.c === diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 132a7ccd4f..af7ef01da7 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -470,25 +470,7 @@ BMFace *BM_face_create_ngon_vcloud( /* now calculate every points angle around the normal (signed) */ for (i = 0; i < len; i++) { - float co[3]; - float proj_vec[3]; - float angle; - - /* center relative vec */ - sub_v3_v3v3(co, vert_arr[i]->co, cent); - - /* align to plane */ - project_v3_v3v3(proj_vec, co, nor); - sub_v3_v3(co, proj_vec); - - /* now 'co' is valid - we can compare its angle against the far vec */ - angle = angle_v3v3(far_vec, co); - - if (dot_v3v3(co, sign_vec) < 0.0f) { - angle = -angle; - } - - vang[i].sort_value = angle; + vang[i].sort_value = angle_signed_on_axis_v3v3v3_v3(far, cent, vert_arr[i]->co, nor); vang[i].data = i; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [11187e8628] master: Fix face-creation with existing hidden geometry
Commit: 11187e86283a2bada088f718dd6012e0c7d6d19e Author: Campbell Barton Date: Thu Jan 19 09:04:50 2017 +1100 Branches: master https://developer.blender.org/rB11187e86283a2bada088f718dd6012e0c7d6d19e Fix face-creation with existing hidden geometry - face-create-extend option could add hidden verts and edges into the selection history (invalid state). - faces could be created that included existing hidden edges that remained hidden (invalid state too). - newly created faces could copy hidden flag from surrounding faces, giving very confusing results (looks as if face creation failed). Surprising nobody noticed these years old bugs! === M source/blender/editors/mesh/editmesh_tools.c === diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index c57b0215d4..8f004bcf72 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -684,27 +684,38 @@ static void edbm_add_edge_face_exec__tricky_finalize_sel(BMesh *bm, BMElem *ele_ /* now we need to find the edge that isnt connected to this element */ BM_select_history_clear(bm); + /* Notes on hidden geometry: +* - un-hide the face since its possible hidden was copied when copying surrounding face attributes. +* - un-hide before adding to select history +* since we may extend into an existing, hidden vert/edge. +*/ + + BM_elem_flag_disable(f, BM_ELEM_HIDDEN); + BM_face_select_set(bm, f, false); + if (ele_desel->head.htype == BM_VERT) { BMLoop *l = BM_face_vert_share_loop(f, (BMVert *)ele_desel); BLI_assert(f->len == 3); - BM_face_select_set(bm, f, false); BM_vert_select_set(bm, (BMVert *)ele_desel, false); - BM_edge_select_set(bm, l->next->e, true); BM_select_history_store(bm, l->next->e); } else { BMLoop *l = BM_face_edge_share_loop(f, (BMEdge *)ele_desel); BLI_assert(f->len == 4 || f->len == 3); - BM_face_select_set(bm, f, false); + BM_edge_select_set(bm, (BMEdge *)ele_desel, false); if (f->len == 4) { - BM_edge_select_set(bm, l->next->next->e, true); - BM_select_history_store(bm, l->next->next->e); + BMEdge *e_active = l->next->next->e; + BM_elem_flag_disable(e_active, BM_ELEM_HIDDEN); + BM_edge_select_set(bm, e_active, true); + BM_select_history_store(bm, e_active); } else { - BM_vert_select_set(bm, l->next->next->v, true); - BM_select_history_store(bm, l->next->next->v); + BMVert *v_active = l->next->next->v; + BM_elem_flag_disable(v_active, BM_ELEM_HIDDEN); + BM_vert_select_set(bm, v_active, true); + BM_select_history_store(bm, v_active); } } } @@ -758,6 +769,14 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op) else #endif { + /* Newly created faces may include existing hidden edges, +* copying face data from surrounding, may have copied hidden face flag too. +* +* Important that faces use flushing since 'edges.out' wont include hidden edges that already existed. +*/ + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_HIDDEN, true); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_HIDDEN, false); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true); BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1455023e64] master: Fix T49807: Inset faces edge rail bug
Commit: 1455023e643044a6d1d220a0a27a67e344c699a9 Author: Campbell Barton Date: Thu Jan 19 10:35:10 2017 +1100 Branches: master https://developer.blender.org/rB1455023e643044a6d1d220a0a27a67e344c699a9 Fix T49807: Inset faces edge rail bug === M source/blender/bmesh/operators/bmo_inset.c === diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index c52c608e67..e2ff09669d 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -647,6 +647,10 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op) } (void)0 #define VERT_ORIG_GET(_v) \ (const float *)BLI_ghash_lookup_default(vert_coords, (_v), (_v)->co) + /* memory for the coords isn't given back to the arena, +* acceptable in this case since it runs a fixed number of times. */ +#define VERT_ORIG_REMOVE(_v) \ + BLI_ghash_remove(vert_coords, (_v), NULL, NULL) for (i = 0, es = edge_info; i < edge_info_len; i++, es++) { @@ -972,7 +976,11 @@ void bmo_inset_region_exec(BMesh *bm, BMOperator *op) v_glue = v_split; } else { - BM_vert_splice(bm, v_glue, v_split); + if (BM_vert_splice(bm, v_glue, v_split)) { + if (use_vert_coords_orig) { + VERT_ORIG_REMOVE(v_split); + } + } } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4a19112277] master: Cycles: Fix amount of rendered samples not being shown while rendering the last tile on CPU
Commit: 4a1911227798e067c09f101d552112724b999a3d Author: Lukas Stockner Date: Thu Jan 19 00:39:52 2017 +0100 Branches: master https://developer.blender.org/rB4a1911227798e067c09f101d552112724b999a3d Cycles: Fix amount of rendered samples not being shown while rendering the last tile on CPU === M intern/cycles/render/session.cpp === diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 73caf93ea0..7c01934cfd 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -458,6 +458,8 @@ void Session::release_tile(RenderTile& rtile) { thread_scoped_lock tile_lock(tile_mutex); + progress.add_finished_tile(); + if(write_render_tile_cb) { if(params.progressive_refine == false) { /* todo: optimize this by making it thread safe and removing lock */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b76dbf5e65] master: UI: Fix capitalization inconsistency
Commit: b76dbf5e65b89b1f276a6c007c6c9541910c3f5c Author: Aaron Carlisle Date: Wed Jan 18 19:38:55 2017 -0500 Branches: master https://developer.blender.org/rBb76dbf5e65b89b1f276a6c007c6c9541910c3f5c UI: Fix capitalization inconsistency === M release/scripts/startup/bl_ui/properties_game.py === diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py index 98b7a76e54..4d54817a21 100644 --- a/release/scripts/startup/bl_ui/properties_game.py +++ b/release/scripts/startup/bl_ui/properties_game.py @@ -714,7 +714,7 @@ class WORLD_PT_game_physics(WorldButtonsPanel, Panel): class WORLD_PT_game_physics_obstacles(WorldButtonsPanel, Panel): -bl_label = "Obstacle simulation" +bl_label = "Obstacle Simulation" COMPAT_ENGINES = {'BLENDER_GAME'} @classmethod ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8aa8165e85] blender2.8: OpenGL: convert legacy calls in transform.c
Commit: 8aa8165e85d4abcf9025c687863d0c41bc41a348 Author: Mike Erwin Date: Thu Jan 19 00:46:01 2017 -0500 Branches: blender2.8 https://developer.blender.org/rB8aa8165e85d4abcf9025c687863d0c41bc41a348 OpenGL: convert legacy calls in transform.c Took pieces from D2316 and D2359, changed a few more things. - use new immediate mode - use new matrix stack - remove state push/pop Part of T49043 and T49450 === M source/blender/editors/transform/transform.c === diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 20c62e91d0..6a21592db2 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -64,9 +64,11 @@ #include "BKE_mask.h" #include "BKE_report.h" -#include "BIF_gl.h" #include "BIF_glutil.h" +#include "GPU_immediate.h" +#include "GPU_matrix.h" + #include "ED_image.h" #include "ED_keyframing.h" #include "ED_screen.h" @@ -1598,8 +1600,16 @@ typedef enum { LEFT, RIGHT } ArrowDirection; + +#define POS_INDEX 0 +/* NOTE: this --^ is a bit hackish, but simplifies VertexFormat usage among functions + * private to this file - merwin + */ + static void drawArrow(ArrowDirection d, short offset, short length, short size) { + immBegin(PRIM_LINES, 6); + switch (d) { case LEFT: offset = -offset; @@ -1607,14 +1617,12 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size) size = -size; /* fall-through */ case RIGHT: - glBegin(GL_LINES); - glVertex2s(offset, 0); - glVertex2s(offset + length, 0); - glVertex2s(offset + length, 0); - glVertex2s(offset + length - size, -size); - glVertex2s(offset + length, 0); - glVertex2s(offset + length - size, size); - glEnd(); + immVertex2f(POS_INDEX, offset, 0); + immVertex2f(POS_INDEX, offset + length, 0); + immVertex2f(POS_INDEX, offset + length, 0); + immVertex2f(POS_INDEX, offset + length - size, -size); + immVertex2f(POS_INDEX, offset + length, 0); + immVertex2f(POS_INDEX, offset + length - size, size); break; case DOWN: @@ -1623,45 +1631,45 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size) size = -size; /* fall-through */ case UP: - glBegin(GL_LINES); - glVertex2s(0, offset); - glVertex2s(0, offset + length); - glVertex2s(0, offset + length); - glVertex2s(-size, offset + length - size); - glVertex2s(0, offset + length); - glVertex2s(size, offset + length - size); - glEnd(); + immVertex2f(POS_INDEX, 0, offset); + immVertex2f(POS_INDEX, 0, offset + length); + immVertex2f(POS_INDEX, 0, offset + length); + immVertex2f(POS_INDEX, -size, offset + length - size); + immVertex2f(POS_INDEX, 0, offset + length); + immVertex2f(POS_INDEX, size, offset + length - size); break; } + + immEnd(); } static void drawArrowHead(ArrowDirection d, short size) { + immBegin(PRIM_LINES, 4); + switch (d) { case LEFT: size = -size; /* fall-through */ case RIGHT: - glBegin(GL_LINES); - glVertex2s(0, 0); - glVertex2s(-size, -size); - glVertex2s(0, 0); - glVertex2s(-size, size); - glEnd(); + immVertex2f(POS_INDEX, 0, 0); + immVertex2f(POS_INDEX, -size, -size); + immVertex2f(POS_INDEX, 0, 0); + immVertex2f(POS_INDEX, -size, size); break; case DOWN: size = -size; /* fall-through */ case UP: - glBegin(GL_LINES); - glVertex2s(0, 0); - glVertex2s(-size, -size); - glVertex2s(0, 0); - glVertex2s(size, -size); - glEnd(); + immVertex2f(POS_INDEX, 0,