GPencil: Get current frame from scene
This change makes it so current frame is queried from a scene rather than from a dependency graph. This makes it possible to avoid the fact that dependency graph might not be fully evaluated yet. There are still some cases where it frame is queried from the graph, but those seems to be in a code path where we need to ensure valid dependency graph anyway. Reviewers: brecht Reviewed By: brecht Differential Revision: https://developer.blender.org/D5349
This commit is contained in:
parent
ad18d331d7
commit
9270c15af8
|
@ -829,8 +829,8 @@ static const ColorTemplate gp_monkey_pct_pupils = {
|
|||
void ED_gpencil_create_monkey(bContext *C, Object *ob, float mat[4][4])
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
bGPDstroke *gps;
|
||||
|
||||
|
|
|
@ -215,8 +215,8 @@ static const ColorTemplate gp_stroke_material_grey = {
|
|||
void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4])
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
bGPDstroke *gps;
|
||||
|
||||
|
|
|
@ -87,7 +87,6 @@
|
|||
typedef struct tGP_BrushEditData {
|
||||
/* Current editor/region/etc. */
|
||||
/* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */
|
||||
Depsgraph *depsgraph;
|
||||
struct Main *bmain;
|
||||
Scene *scene;
|
||||
Object *object;
|
||||
|
@ -1052,8 +1051,8 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
|
|||
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_ADD_NEW);
|
||||
bGPDstroke *gps;
|
||||
|
@ -1224,7 +1223,6 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
|
|||
gso = MEM_callocN(sizeof(tGP_BrushEditData), "tGP_BrushEditData");
|
||||
op->customdata = gso;
|
||||
|
||||
gso->depsgraph = CTX_data_depsgraph(C);
|
||||
gso->bmain = CTX_data_main(C);
|
||||
/* store state */
|
||||
gso->settings = gpsculpt_get_settings(scene);
|
||||
|
@ -1400,7 +1398,8 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
|
|||
bGPdata *gpd = gso->gpd;
|
||||
|
||||
bGPDlayer *gpl;
|
||||
int cfra_eval = (int)DEG_get_ctime(gso->depsgraph);
|
||||
Scene *scene = gso->scene;
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
/* only try to add a new frame if this is the first stroke, or the frame has changed */
|
||||
if ((gpd == NULL) || (cfra_eval == gso->cfra)) {
|
||||
|
|
|
@ -1274,8 +1274,8 @@ static void gp_layer_to_curve(bContext *C,
|
|||
struct Main *bmain = CTX_data_main(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
Collection *collection = CTX_data_collection(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
|
||||
bGPDstroke *gps, *prev_gps = NULL;
|
||||
|
@ -1406,8 +1406,8 @@ static void gp_layer_to_curve(bContext *C,
|
|||
*/
|
||||
static bool gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOperator *op)
|
||||
{
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
bGPDframe *gpf = NULL;
|
||||
bGPDstroke *gps = NULL;
|
||||
|
@ -1468,8 +1468,8 @@ static void gp_convert_set_end_frame(struct Main *UNUSED(main),
|
|||
static bool gp_convert_poll(bContext *C)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
if ((ob == NULL) || (ob->type != OB_GPENCIL)) {
|
||||
return false;
|
||||
|
|
|
@ -594,8 +594,8 @@ static int gp_frame_duplicate_exec(bContext *C, wmOperator *op)
|
|||
{
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
int mode = RNA_enum_get(op->ptr, "mode");
|
||||
|
||||
|
|
|
@ -1237,8 +1237,8 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
|
|||
Object *ob = CTX_data_active_object(C);
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); /* only use active for copy merge */
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
bGPDframe *gpf;
|
||||
|
||||
eGP_PasteMode type = RNA_enum_get(op->ptr, "type");
|
||||
|
@ -1408,8 +1408,8 @@ static int gp_move_to_layer_invoke(bContext *C, wmOperator *op, const wmEvent *U
|
|||
static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata *gpd = CTX_data_gpencil_data(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
bGPDlayer *target_layer = NULL;
|
||||
ListBase strokes = {NULL, NULL};
|
||||
int layer_num = RNA_enum_get(op->ptr, "layer");
|
||||
|
@ -1545,8 +1545,8 @@ static bool UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C)
|
|||
static int gp_blank_frame_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
bGPDlayer *active_gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
|
||||
|
@ -1627,8 +1627,8 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
|
|||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
|
||||
|
||||
|
@ -1681,8 +1681,8 @@ static bool gp_actframe_delete_all_poll(bContext *C)
|
|||
static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
bool success = false;
|
||||
|
||||
|
|
|
@ -511,8 +511,8 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
wmWindow *win = CTX_wm_window(C);
|
||||
bGPdata *gpd = CTX_data_gpencil_data(C);
|
||||
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
bGPDframe *actframe = gpl->actframe;
|
||||
tGPDinterpolate *tgpi = NULL;
|
||||
|
||||
|
@ -949,8 +949,8 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
|
|||
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate;
|
||||
eGP_Interpolate_SettingsFlag flag = ipo_settings->flag;
|
||||
|
|
|
@ -98,11 +98,11 @@ static void gpencil_insert_points_to_stroke(bGPDstroke *gps,
|
|||
static bGPDstroke *gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpoints)
|
||||
{
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
|
||||
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
const bool back = RNA_boolean_get(op->ptr, "back");
|
||||
const bool additive = RNA_boolean_get(op->ptr, "additive");
|
||||
|
|
|
@ -2089,7 +2089,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
|
|||
{
|
||||
Scene *scene = p->scene;
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
int cfra_eval = (int)DEG_get_ctime(p->depsgraph);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
/* get active layer (or add a new one if non-existent) */
|
||||
p->gpl = BKE_gpencil_layer_getactive(p->gpd);
|
||||
|
|
|
@ -305,8 +305,8 @@ static void gpencil_primitive_allocate_memory(tGPDprimitive *tgpi)
|
|||
/* Helper: Create internal strokes primitives data */
|
||||
static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
|
||||
{
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
|
||||
|
||||
|
@ -1096,10 +1096,9 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
|
|||
bGPdata *gpd = CTX_data_gpencil_data(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
Paint *paint = &ts->gp_paint->paint;
|
||||
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
/* create temporary operator data */
|
||||
tGPDprimitive *tgpi = MEM_callocN(sizeof(tGPDprimitive), "GPencil Primitive Data");
|
||||
|
|
|
@ -302,8 +302,8 @@ typedef enum eGP_SelectGrouped {
|
|||
/* On each visible layer, check for selected strokes - if found, select all others */
|
||||
static void gp_select_same_layer(bContext *C)
|
||||
{
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
int cfra_eval = (int)DEG_get_ctime(depsgraph);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int cfra_eval = CFRA;
|
||||
|
||||
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
|
||||
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
|
||||
|
|
Loading…
Reference in New Issue