Cleanup: getting rid of G.main.

Sometimes one needs a *lot* of changes for a single G.main... :/
This commit is contained in:
Bastien Montagne 2018-06-08 12:16:37 +02:00
parent 55606dbdbc
commit 7b6af843c2
Notes: blender-bot 2023-02-14 05:44:19 +01:00
Referenced by issue #55452, Crash on saving with visible particle system
26 changed files with 197 additions and 151 deletions

View File

@ -434,7 +434,8 @@ enum {
};
typedef struct ImBuf *(*SequencerDrawView)(
struct Scene *scene, struct Object *camera, int width, int height,
struct Main *bmain, struct Scene *scene,
struct Object *camera, int width, int height,
unsigned int flag, unsigned int draw_flags, int drawtype, int alpha_mode,
int samples, const char *viewname,
struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]);

View File

@ -3326,7 +3326,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
BKE_scene_update_for_newframe(context->eval_ctx, context->bmain, scene, scene->lay);
ibuf = sequencer_view3d_cb(
/* set for OpenGL render (NULL when scrubbing) */
scene, camera, width, height, IB_rect, draw_flags, context->scene->r.seq_prev_type,
context->bmain, scene, camera, width, height, IB_rect, draw_flags, context->scene->r.seq_prev_type,
scene->r.alphamode, context->gpu_samples, viewname,
context->gpu_fx, context->gpu_offscreen, err_out);
if (ibuf == NULL) {

View File

@ -35,6 +35,7 @@
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "WM_api.h"
@ -589,6 +590,7 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
}
}
else {
cdd->vc.bmain = CTX_data_main(C);
cdd->vc.scene = CTX_data_scene(C);
cdd->vc.obedit = CTX_data_edit_object(C);
}
@ -1078,7 +1080,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* needed or else the draw matrix can be incorrect */
view3d_operator_needs_opengl(C);
ED_view3d_autodist_init(cdd->vc.scene, cdd->vc.ar, cdd->vc.v3d, 0);
ED_view3d_autodist_init(cdd->vc.bmain, cdd->vc.scene, cdd->vc.ar, cdd->vc.v3d, 0);
if (cdd->vc.rv3d->depths) {
cdd->vc.rv3d->depths->damaged = true;

View File

@ -57,6 +57,7 @@
#include "BKE_context.h"
#include "BKE_gpencil.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_screen.h"
@ -2098,6 +2099,7 @@ static int gp_strokes_reproject_poll(bContext *C)
static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
GP_SpaceConversion gsc = {NULL};
eGP_ReprojectModes mode = RNA_boolean_get(op->ptr, "type");
@ -2108,7 +2110,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
/* 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);
ED_view3d_autodist_init(bmain, scene, gsc.ar, CTX_wm_view3d(C), 0);
}
// TODO: For deforming geometry workflow, create new frames?

View File

@ -46,14 +46,15 @@
#include "PIL_time.h"
#include "BKE_paint.h"
#include "BKE_gpencil.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_main.h"
#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_screen.h"
#include "BKE_tracking.h"
#include "BKE_colortools.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@ -111,6 +112,7 @@ typedef enum eGPencil_PaintFlags {
* "p" = op->customdata
*/
typedef struct tGPsdata {
Main *bmain;
Scene *scene; /* current scene from context */
wmWindow *win; /* window where painting originated */
@ -638,7 +640,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure,
View3D *v3d = p->sa->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->ar);
ED_view3d_autodist_init(p->scene, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
ED_view3d_autodist_init(p->bmain, p->scene, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
}
/* convert screen-coordinates to appropriate coordinates (and store them) */
@ -1240,7 +1242,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
View3D *v3d = p->sa->spacedata.first;
view3d_region_operator_needs_opengl(p->win, p->ar);
ED_view3d_autodist_init(p->scene, p->ar, v3d, 0);
ED_view3d_autodist_init(p->bmain, p->scene, p->ar, v3d, 0);
}
}
@ -1393,6 +1395,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
}
/* pass on current scene and window */
p->bmain = CTX_data_main(C);
p->scene = CTX_data_scene(C);
p->win = CTX_wm_window(C);
@ -1805,7 +1808,7 @@ static void gp_paint_strokeend(tGPsdata *p)
/* need to restore the original projection settings before packing up */
view3d_region_operator_needs_opengl(p->win, p->ar);
ED_view3d_autodist_init(p->scene, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
ED_view3d_autodist_init(p->bmain, p->scene, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
}
/* check if doing eraser or not */

View File

@ -47,10 +47,11 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "BKE_action.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
#include "BKE_main.h"
#include "BKE_tracking.h"
#include "BKE_action.h"
#include "WM_api.h"
@ -520,6 +521,7 @@ bGPDpalettecolor *ED_gpencil_stroke_getcolor(bGPdata *gpd, bGPDstroke *gps)
*/
void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
{
Main *bmain = CTX_data_main(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@ -543,7 +545,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
view3d_operator_needs_opengl(C);
view3d_region_operator_needs_opengl(win, ar);
ED_view3d_autodist_init(scene, ar, v3d, 0);
ED_view3d_autodist_init(bmain, scene, ar, v3d, 0);
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {

View File

@ -140,7 +140,7 @@ void ED_object_wpaintmode_exit_ex(struct Object *ob);
void ED_object_wpaintmode_exit(struct bContext *C);
void ED_object_sculptmode_enter_ex(
struct Scene *scene, struct Object *ob,
struct Main *bmain, struct Scene *scene, struct Object *ob,
struct ReportList *reports);
void ED_object_sculptmode_enter(struct bContext *C, struct ReportList *reports);
void ED_object_sculptmode_exit_ex(

View File

@ -70,6 +70,7 @@ enum eGPUFXFlags;
/* for derivedmesh drawing callbacks, for view3d_select, .... */
typedef struct ViewContext {
struct Main *bmain;
struct Scene *scene;
struct Object *obact;
struct Object *obedit;
@ -298,12 +299,12 @@ int ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float
unsigned int ED_view3d_backbuf_sample(struct ViewContext *vc, int x, int y);
bool ED_view3d_autodist(
struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
struct Main *bmain, struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
const int mval[2], float mouse_worldloc[3],
const bool alphaoverride, const float fallback_depth_pt[3]);
/* only draw so ED_view3d_autodist_simple can be called many times after */
void ED_view3d_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);
void ED_view3d_autodist_init(struct Main *bmain, struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);
bool ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
bool ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
bool ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth);
@ -359,7 +360,7 @@ struct RV3DMatrixStore *ED_view3d_mats_rv3d_backup(struct RegionView3D *rv3d);
void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixStore *rv3dmat);
bool ED_view3d_context_activate(struct bContext *C);
void ED_view3d_draw_offscreen_init(struct Scene *scene, struct View3D *v3d);
void ED_view3d_draw_offscreen_init(struct Main *bmain, struct Scene *scene, struct View3D *v3d);
void ED_view3d_draw_offscreen(
struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
float winmat[4][4], bool do_bgpic, bool do_sky, bool is_persp, const char *viewname,
@ -382,12 +383,14 @@ enum {
};
struct ImBuf *ED_view3d_draw_offscreen_imbuf(
struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey,
struct Main *bmain, struct Scene *scene,
struct View3D *v3d, struct ARegion *ar, int sizex, int sizey,
unsigned int flag, unsigned int draw_flags,
int alpha_mode, int samples, const char *viewname,
struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]);
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
struct Scene *scene, struct Object *camera, int width, int height,
struct Main *bmain, struct Scene *scene,
struct Object *camera, int width, int height,
unsigned int flag, unsigned int draw_flags, int drawtype, int alpha_mode,
int samples, const char *viewname,
struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]);

View File

@ -807,7 +807,7 @@ void UI_popup_handlers_remove_all(struct bContext *C, struct ListBase *handlers)
* be used to reinitialize some internal state if user preferences change. */
void UI_init(void);
void UI_init_userdef(void);
void UI_init_userdef(struct Main *bmain);
void UI_reinit_font(void);
void UI_reinit_gl_state(void);
void UI_exit(void);

View File

@ -51,10 +51,11 @@
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "BKE_unit.h"
#include "BKE_idprop.h"
#include "BKE_main.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_idprop.h"
#include "BKE_unit.h"
#include "BIF_gl.h"
@ -4735,10 +4736,10 @@ void UI_init(void)
}
/* after reading userdef file */
void UI_init_userdef(void)
void UI_init_userdef(Main *bmain)
{
/* fix saved themes */
init_userdef_do_versions();
init_userdef_do_versions(bmain);
uiStyleInit();
}

View File

@ -41,6 +41,7 @@
#include "BLI_math_vector.h"
#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_screen.h"
#include "BKE_unit.h"
@ -151,6 +152,7 @@ static void depthdropper_exit(bContext *C, wmOperator *op)
static void depthdropper_depth_sample_pt(bContext *C, DepthDropper *ddr, int mx, int my, float *r_depth)
{
/* we could use some clever */
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
ScrArea *sa = BKE_screen_find_area_xy(win->screen, SPACE_TYPE_ANY, mx, my);
Scene *scene = win->screen->scene;
@ -183,7 +185,7 @@ static void depthdropper_depth_sample_pt(bContext *C, DepthDropper *ddr, int mx,
view3d_operator_needs_opengl(C);
if (ED_view3d_autodist(scene, ar, v3d, mval, co, true, NULL)) {
if (ED_view3d_autodist(bmain, scene, ar, v3d, mval, co, true, NULL)) {
const float mval_center_fl[2] = {
(float)ar->winx / 2,
(float)ar->winy / 2};

View File

@ -726,7 +726,7 @@ void ui_icon_ensure_deferred(const struct bContext *C, const int icon_id, const
int ui_id_icon_get(const struct bContext *C, struct ID *id, const bool big);
/* resources.c */
void init_userdef_do_versions(void);
void init_userdef_do_versions(struct Main *bmain);
void ui_theme_init_default(void);
void ui_style_init_default(void);
void ui_resources_init(void);

View File

@ -1631,10 +1631,8 @@ void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3]
/* ************************************************************* */
/* patching UserDef struct and Themes */
void init_userdef_do_versions(void)
void init_userdef_do_versions(Main *bmain)
{
Main *bmain = G.main;
#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(bmain, ver, subver)
/* the UserDef struct is not corrected with do_versions() .... ugh! */

View File

@ -360,7 +360,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
draw_flags |= (draw_bgpic) ? V3D_OFSDRAW_USE_BACKGROUND : 0;
ibuf_view = ED_view3d_draw_offscreen_imbuf(
scene, v3d, ar, sizex, sizey,
oglrender->bmain, scene, v3d, ar, sizex, sizey,
IB_rect, draw_flags, alpha_mode, oglrender->ofs_samples, viewname,
oglrender->fx, oglrender->ofs, err_out);
@ -372,7 +372,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
else {
draw_flags |= (V3D_OFSDRAW_USE_GPENCIL | V3D_OFSDRAW_USE_BACKGROUND);
ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(
scene, scene->camera, oglrender->sizex, oglrender->sizey,
oglrender->bmain, scene, scene->camera, oglrender->sizex, oglrender->sizey,
IB_rect, draw_flags, OB_SOLID,
alpha_mode, oglrender->ofs_samples, viewname,
oglrender->fx, oglrender->ofs, err_out);

View File

@ -5025,6 +5025,7 @@ void paint_proj_stroke(
/* clone gets special treatment here to avoid going through image initialization */
if (ps_handle->is_clone_cursor_pick) {
Main *bmain = CTX_data_main(C);
Scene *scene = ps_handle->scene;
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
@ -5033,7 +5034,7 @@ void paint_proj_stroke(
view3d_operator_needs_opengl(C);
if (!ED_view3d_autodist(scene, ar, v3d, mval_i, cursor, false, NULL))
if (!ED_view3d_autodist(bmain, scene, ar, v3d, mval_i, cursor, false, NULL))
return;
ED_region_tag_redraw(ar);
@ -5445,6 +5446,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
ImBuf *ibuf;
char filename[FILE_MAX];
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
int w = settings->imapaint.screen_grab_size[0];
@ -5460,7 +5462,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
if (h > maxsize) h = maxsize;
ibuf = ED_view3d_draw_offscreen_imbuf(
scene, CTX_wm_view3d(C), CTX_wm_region(C),
bmain, scene, CTX_wm_view3d(C), CTX_wm_region(C),
w, h, IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL,
NULL, NULL, err_out);
if (!ibuf) {

View File

@ -5630,7 +5630,7 @@ static int ed_object_sculptmode_flush_recalc_flag(Scene *scene, Object *ob, Mult
}
void ED_object_sculptmode_enter_ex(
Scene *scene, Object *ob,
Main *bmain, Scene *scene, Object *ob,
ReportList *reports)
{
const int mode_flag = OB_MODE_SCULPT;
@ -5674,7 +5674,7 @@ void ED_object_sculptmode_enter_ex(
Paint *paint = BKE_paint_get_active_from_paintmode(scene, ePaintSculpt);
BKE_paint_init(scene, ePaintSculpt, PAINT_CURSOR_SCULPT);
paint_cursor_start_explicit(paint, G.main->wm.first, sculpt_poll_view3d);
paint_cursor_start_explicit(paint, bmain->wm.first, sculpt_poll_view3d);
/* Check dynamic-topology flag; re-enter dynamic-topology mode when changing modes,
* As long as no data was added that is not supported. */
@ -5730,9 +5730,10 @@ void ED_object_sculptmode_enter_ex(
void ED_object_sculptmode_enter(struct bContext *C, ReportList *reports)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
ED_object_sculptmode_enter_ex(scene, ob, reports);
ED_object_sculptmode_enter_ex(bmain, scene, ob, reports);
}
void ED_object_sculptmode_exit_ex(
@ -5790,6 +5791,7 @@ void ED_object_sculptmode_exit(bContext *C)
static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_SCULPT;
@ -5805,7 +5807,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
ED_object_sculptmode_exit_ex(scene, ob);
}
else {
ED_object_sculptmode_enter_ex(scene, ob, op->reports);
ED_object_sculptmode_enter_ex(bmain, scene, ob, op->reports);
}
WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);

View File

@ -2289,7 +2289,7 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i
}
#ifdef SEQUENCER_DAG_WORKAROUND
static void ensure_curve_cache(Scene *scene, Object *object)
static void ensure_curve_cache(Main *bmain, Scene *scene, Object *object)
{
bool need_recalc = object->curve_cache == NULL;
/* Render thread might have freed the curve cache if the
@ -2321,7 +2321,7 @@ static void ensure_curve_cache(Scene *scene, Object *object)
BKE_displist_make_curveTypes(scene, object, false);
break;
case OB_MBALL:
BKE_displist_make_mball(G.main->eval_ctx, scene, object);
BKE_displist_make_mball(bmain->eval_ctx, scene, object);
break;
case OB_LATTICE:
BKE_lattice_modifiers_calc(scene, object);
@ -4729,7 +4729,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3
return false;
}
static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
static bool drawDispList(Main *bmain, Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const short dflag, const unsigned char ob_wire_col[4])
{
bool retval;
@ -4742,7 +4742,7 @@ static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *ba
}
#ifdef SEQUENCER_DAG_WORKAROUND
ensure_curve_cache(scene, base->object);
ensure_curve_cache(bmain, scene, base->object);
#endif
if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == false) {
@ -6353,7 +6353,7 @@ static void draw_editnurb_splines(Object *ob, Nurb *nurb, const bool sel)
}
static void draw_editnurb(
Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb,
Main *bmain, Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb,
const char dt, const short dflag, const unsigned char ob_wire_col[4])
{
ToolSettings *ts = scene->toolsettings;
@ -6368,7 +6368,7 @@ static void draw_editnurb(
UI_GetThemeColor3ubv(TH_WIRE_EDIT, wire_col);
glColor3ubv(wire_col);
drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
drawDispList(bmain, scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
/* for shadows only show solid faces */
if (v3d->flag2 & V3D_RENDER_SHADOW)
@ -6463,8 +6463,9 @@ static void draw_editfont_textcurs(RegionView3D *rv3d, float textcurs[4][2])
ED_view3d_polygon_offset(rv3d, 0.0);
}
static void draw_editfont(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const short dflag, const unsigned char ob_wire_col[4])
static void draw_editfont(
Main *bmain, Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const short dflag, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
Curve *cu = ob->data;
@ -6476,11 +6477,11 @@ static void draw_editfont(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *b
if (cu->flag & CU_FAST) {
cpack(0xFFFFFF);
set_inverted_drawing(1);
drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
drawDispList(bmain, scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
set_inverted_drawing(0);
}
else {
drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
drawDispList(bmain, scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
if (cu->linewidth != 0.0f) {
@ -6772,8 +6773,9 @@ static void drawcone(const float vec[3], float radius, float height, float tmat[
}
/* return true if nothing was drawn */
static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const short dflag, const unsigned char ob_wire_col[4])
static bool drawmball(
Main *bmain, Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const short dflag, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
MetaElem *ml;
@ -6788,13 +6790,13 @@ static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
UI_GetThemeColor4ubv(TH_WIRE_EDIT, wire_col);
glColor3ubv(wire_col);
drawDispList(scene, v3d, rv3d, base, dt, dflag, wire_col);
drawDispList(bmain, scene, v3d, rv3d, base, dt, dflag, wire_col);
}
ml = mb->editelems->first;
}
else {
if ((base->flag & OB_FROMDUPLI) == 0) {
drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
drawDispList(bmain, scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
ml = mb->elems.first;
}
@ -7164,7 +7166,7 @@ static void drawtexspace(Object *ob)
/* draws wire outline */
static void draw_object_selected_outline(
Scene *scene, View3D *v3d, ARegion *ar, Base *base,
Main *bmain, Scene *scene, View3D *v3d, ARegion *ar, Base *base,
const unsigned char ob_wire_col[4])
{
RegionView3D *rv3d = ar->regiondata;
@ -7176,7 +7178,7 @@ static void draw_object_selected_outline(
bool has_faces = false;
#ifdef SEQUENCER_DAG_WORKAROUND
ensure_curve_cache(scene, ob);
ensure_curve_cache(bmain, scene, ob);
#endif
DerivedMesh *dm = ob->derivedFinal;
@ -7455,7 +7457,7 @@ static void draw_rigidbody_shape(Object *ob)
* main object drawing function, draws in selection
* \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET
*/
void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag)
void draw_object(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag)
{
ModifierData *md = NULL;
Object *ob = base->object;
@ -7638,7 +7640,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) {
if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
draw_object_selected_outline(scene, v3d, ar, base, ob_wire_col);
draw_object_selected_outline(bmain, scene, v3d, ar, base, ob_wire_col);
}
}
}
@ -7655,18 +7657,18 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
case OB_FONT:
cu = ob->data;
if (cu->editfont) {
draw_editfont(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
draw_editfont(bmain, scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
else if (dt == OB_BOUNDBOX) {
if ((render_override && v3d->drawtype >= OB_WIRE) == 0) {
#ifdef SEQUENCER_DAG_WORKAROUND
ensure_curve_cache(scene, base->object);
ensure_curve_cache(bmain, scene, base->object);
#endif
draw_bounding_volume(ob, ob->boundtype);
}
}
else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
empty_object = drawDispList(bmain, scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
break;
@ -7676,18 +7678,18 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (cu->editnurb) {
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
draw_editnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
draw_editnurb(bmain, scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
}
else if (dt == OB_BOUNDBOX) {
if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
#ifdef SEQUENCER_DAG_WORKAROUND
ensure_curve_cache(scene, base->object);
ensure_curve_cache(bmain, scene, base->object);
#endif
draw_bounding_volume(ob, ob->boundtype);
}
}
else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
empty_object = drawDispList(bmain, scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
}
break;
case OB_MBALL:
@ -7695,17 +7697,17 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
MetaBall *mb = ob->data;
if (mb->editelems)
drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
drawmball(bmain, scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
else if (dt == OB_BOUNDBOX) {
if ((render_override && (v3d->drawtype >= OB_WIRE)) == 0) {
#ifdef SEQUENCER_DAG_WORKAROUND
ensure_curve_cache(scene, base->object);
ensure_curve_cache(bmain, scene, base->object);
#endif
draw_bounding_volume(ob, ob->boundtype);
}
}
else
empty_object = drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
empty_object = drawmball(bmain, scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
break;
}
case OB_EMPTY:
@ -7744,7 +7746,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
else {
#ifdef SEQUENCER_DAG_WORKAROUND
ensure_curve_cache(scene, ob);
ensure_curve_cache(bmain, scene, ob);
#endif
drawlattice(v3d, ob);
}
@ -8172,10 +8174,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
* Drawing for selection picking,
* caller must have called 'GPU_select_load_id(base->selcode)' first.
*/
void draw_object_select(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag)
void draw_object_select(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag)
{
BLI_assert(dflag & DRAW_PICKING && dflag & DRAW_CONSTCOLOR);
draw_object(scene, ar, v3d, base, dflag);
draw_object(bmain, scene, ar, v3d, base, dflag);
/* we draw duplicators for selection too */
if ((base->object->transflag & OB_DUPLI)) {
@ -8200,7 +8202,7 @@ void draw_object_select(Scene *scene, ARegion *ar, View3D *v3d, Base *base, cons
dt = tbase.object->dt; tbase.object->dt = MIN2(tbase.object->dt, base->object->dt);
dtx = tbase.object->dtx; tbase.object->dtx = base->object->dtx;
draw_object(scene, ar, v3d, &tbase, dflag);
draw_object(bmain, scene, ar, v3d, &tbase, dflag);
tbase.object->dt = dt;
tbase.object->dtx = dtx;

View File

@ -1968,7 +1968,7 @@ void ED_view3d_after_add(ListBase *lb, Base *base, const short dflag)
}
/* disables write in zbuffer and draws it over */
static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d)
static void view3d_draw_transp(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d)
{
View3DAfter *v3da;
@ -1976,7 +1976,7 @@ static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d)
v3d->transp = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_transp))) {
draw_object(scene, ar, v3d, v3da->base, v3da->dflag);
draw_object(bmain, scene, ar, v3d, v3da->base, v3da->dflag);
MEM_freeN(v3da);
}
v3d->transp = false;
@ -1986,7 +1986,7 @@ static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d)
}
/* clears zbuffer and draws it over */
static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, bool *clear)
static void view3d_draw_xray(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, bool *clear)
{
View3DAfter *v3da;
@ -1997,7 +1997,7 @@ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, bool *clear
v3d->xray = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
draw_object(scene, ar, v3d, v3da->base, v3da->dflag);
draw_object(bmain, scene, ar, v3d, v3da->base, v3da->dflag);
MEM_freeN(v3da);
}
v3d->xray = false;
@ -2005,7 +2005,7 @@ static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, bool *clear
/* clears zbuffer and draws it over */
static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, const bool clear)
static void view3d_draw_xraytransp(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, const bool clear)
{
View3DAfter *v3da;
@ -2018,7 +2018,7 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, const
glDepthMask(GL_FALSE);
while ((v3da = BLI_pophead(&v3d->afterdraw_xraytransp))) {
draw_object(scene, ar, v3d, v3da->base, v3da->dflag);
draw_object(bmain, scene, ar, v3d, v3da->base, v3da->dflag);
MEM_freeN(v3da);
}
@ -2030,7 +2030,7 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, const
/* clears zbuffer and draws it over,
* note that in the select version we don't care about transparent flag as with regular drawing */
static void view3d_draw_xray_select(Scene *scene, ARegion *ar, View3D *v3d, bool *clear)
static void view3d_draw_xray_select(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, bool *clear)
{
/* Not ideal, but we need to read from the previous depths before clearing
* otherwise we could have a function to load the depths after drawing.
@ -2050,7 +2050,7 @@ static void view3d_draw_xray_select(Scene *scene, ARegion *ar, View3D *v3d, bool
v3d->xray = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
if (GPU_select_load_id(v3da->base->selcol)) {
draw_object_select(scene, ar, v3d, v3da->base, v3da->dflag);
draw_object_select(bmain, scene, ar, v3d, v3da->base, v3da->dflag);
}
MEM_freeN(v3da);
}
@ -2086,7 +2086,7 @@ static DupliObject *dupli_step(DupliObject *dob)
}
static void draw_dupli_objects_color(
Scene *scene, ARegion *ar, View3D *v3d, Base *base,
Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, Base *base,
const short dflag, const int color)
{
RegionView3D *rv3d = ar->regiondata;
@ -2115,7 +2115,7 @@ static void draw_dupli_objects_color(
}
tbase.flag = OB_FROMDUPLI | base->flag;
lb = object_duplilist(G.main->eval_ctx, scene, base->object);
lb = object_duplilist(bmain->eval_ctx, scene, base->object);
// BLI_listbase_sort(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */
apply_data = duplilist_apply(base->object, scene, lb);
@ -2207,7 +2207,7 @@ static void draw_dupli_objects_color(
displist = glGenLists(1);
glNewList(displist, GL_COMPILE);
draw_object(scene, ar, v3d, &tbase, dflag_dupli);
draw_object(bmain, scene, ar, v3d, &tbase, dflag_dupli);
glEndList();
use_displist = true;
@ -2224,7 +2224,7 @@ static void draw_dupli_objects_color(
else {
copy_m4_m4(dob->ob->obmat, dob->mat);
GPU_begin_dupli_object(dob);
draw_object(scene, ar, v3d, &tbase, dflag_dupli);
draw_object(bmain, scene, ar, v3d, &tbase, dflag_dupli);
GPU_end_dupli_object();
}
}
@ -2246,7 +2246,7 @@ static void draw_dupli_objects_color(
glDeleteLists(displist, 1);
}
static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *base)
static void draw_dupli_objects(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, Base *base)
{
/* define the color here so draw_dupli_objects_color can be called
* from the set loop */
@ -2256,7 +2256,7 @@ static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *bas
if (base->object->dup_group && base->object->dup_group->id.us < 1)
color = TH_REDALERT;
draw_dupli_objects_color(scene, ar, v3d, base, 0, color);
draw_dupli_objects_color(bmain, scene, ar, v3d, base, 0, color);
}
/* XXX warning, not using gpu offscreen here */
@ -2390,7 +2390,7 @@ void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
v3d->zbuf = zbuf;
}
static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
static void view3d_draw_depth_loop(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d)
{
Base *base;
@ -2402,9 +2402,9 @@ static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
Scene *sce_iter;
for (SETLOOPER(scene->set, sce_iter, base)) {
if (v3d->lay & base->lay) {
draw_object(scene, ar, v3d, base, 0);
draw_object(bmain, scene, ar, v3d, base, 0);
if (base->object->transflag & OB_DUPLI) {
draw_dupli_objects_color(scene, ar, v3d, base, dflag_depth, TH_UNDEFINED);
draw_dupli_objects_color(bmain, scene, ar, v3d, base, dflag_depth, TH_UNDEFINED);
}
}
}
@ -2414,9 +2414,9 @@ static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
if (v3d->lay & base->lay) {
/* dupli drawing */
if (base->object->transflag & OB_DUPLI) {
draw_dupli_objects_color(scene, ar, v3d, base, dflag_depth, TH_UNDEFINED);
draw_dupli_objects_color(bmain, scene, ar, v3d, base, dflag_depth, TH_UNDEFINED);
}
draw_object(scene, ar, v3d, base, dflag_depth);
draw_object(bmain, scene, ar, v3d, base, dflag_depth);
}
}
@ -2437,7 +2437,7 @@ static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
if (v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) {
glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */
for (v3da = v3d->afterdraw_xray.first; v3da; v3da = v3da->next) {
draw_object(scene, ar, v3d, v3da->base, dflag_depth);
draw_object(bmain, scene, ar, v3d, v3da->base, dflag_depth);
}
glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */
}
@ -2446,21 +2446,21 @@ static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
v3d->xray = false;
v3d->transp = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_transp))) {
draw_object(scene, ar, v3d, v3da->base, dflag_depth);
draw_object(bmain, scene, ar, v3d, v3da->base, dflag_depth);
MEM_freeN(v3da);
}
v3d->xray = true;
v3d->transp = false;
while ((v3da = BLI_pophead(&v3d->afterdraw_xray))) {
draw_object(scene, ar, v3d, v3da->base, dflag_depth);
draw_object(bmain, scene, ar, v3d, v3da->base, dflag_depth);
MEM_freeN(v3da);
}
v3d->xray = true;
v3d->transp = true;
while ((v3da = BLI_pophead(&v3d->afterdraw_xraytransp))) {
draw_object(scene, ar, v3d, v3da->base, dflag_depth);
draw_object(bmain, scene, ar, v3d, v3da->base, dflag_depth);
MEM_freeN(v3da);
}
@ -2472,7 +2472,7 @@ static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d)
}
}
void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaoverride)
void ED_view3d_draw_depth(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, bool alphaoverride)
{
struct bThemeState theme_state;
RegionView3D *rv3d = ar->regiondata;
@ -2505,7 +2505,7 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover
v3d->zbuf = true;
glEnable(GL_DEPTH_TEST);
view3d_draw_depth_loop(scene, ar, v3d);
view3d_draw_depth_loop(bmain, scene, ar, v3d);
if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_disable();
@ -2530,12 +2530,12 @@ void ED_view3d_draw_select_loop(
const short dflag = DRAW_PICKING | DRAW_CONSTCOLOR;
if (vc->obedit && vc->obedit->type == OB_MBALL) {
draw_object(scene, ar, v3d, BASACT, dflag);
draw_object(vc->bmain, scene, ar, v3d, BASACT, dflag);
}
else if ((vc->obedit && vc->obedit->type == OB_ARMATURE)) {
/* if not drawing sketch, draw bones */
if (!BDR_drawSketchNames(vc)) {
draw_object(scene, ar, v3d, BASACT, dflag);
draw_object(vc->bmain, scene, ar, v3d, BASACT, dflag);
}
}
else {
@ -2557,7 +2557,7 @@ void ED_view3d_draw_select_loop(
}
else {
if (GPU_select_load_id(code)) {
draw_object_select(scene, ar, v3d, base, dflag);
draw_object_select(vc->bmain, scene, ar, v3d, base, dflag);
}
}
code++;
@ -2568,7 +2568,7 @@ void ED_view3d_draw_select_loop(
if (use_nearest) {
bool xrayclear = true;
if (v3d->afterdraw_xray.first) {
view3d_draw_xray_select(scene, ar, v3d, &xrayclear);
view3d_draw_xray_select(vc->bmain, scene, ar, v3d, &xrayclear);
}
}
}
@ -2611,7 +2611,7 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d,
}
}
static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d)
static void gpu_update_lamps_shadows_world(Main *bmain, Scene *scene, View3D *v3d)
{
ListBase shadows;
View3DShadow *shadow;
@ -2632,7 +2632,7 @@ static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d)
if (ob->transflag & OB_DUPLI) {
DupliObject *dob;
ListBase *lb = object_duplilist(G.main->eval_ctx, scene, ob);
ListBase *lb = object_duplilist(bmain->eval_ctx, scene, ob);
for (dob = lb->first; dob; dob = dob->next)
if (dob->ob->type == OB_LAMP)
@ -2831,6 +2831,7 @@ static void view3d_draw_objects(
const char **grid_unit,
const bool do_bgpic, const bool draw_offscreen, GPUFX *fx)
{
Main *bmain = CTX_data_main(C);
RegionView3D *rv3d = ar->regiondata;
Base *base;
const bool do_camera_frame = !draw_offscreen;
@ -2907,10 +2908,10 @@ static void view3d_draw_objects(
for (SETLOOPER(scene->set, sce_iter, base)) {
if (v3d->lay & base->lay) {
UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
draw_object(scene, ar, v3d, base, dflag);
draw_object(bmain, scene, ar, v3d, base, dflag);
if (base->object->transflag & OB_DUPLI) {
draw_dupli_objects_color(scene, ar, v3d, base, dflag, TH_UNDEFINED);
draw_dupli_objects_color(bmain, scene, ar, v3d, base, dflag, TH_UNDEFINED);
}
}
}
@ -2924,9 +2925,9 @@ static void view3d_draw_objects(
if (v3d->lay & base->lay) {
/* dupli drawing */
if (base->object->transflag & OB_DUPLI)
draw_dupli_objects(scene, ar, v3d, base);
draw_dupli_objects(bmain, scene, ar, v3d, base);
draw_object(scene, ar, v3d, base, 0);
draw_object(bmain, scene, ar, v3d, base, 0);
}
}
}
@ -2941,11 +2942,11 @@ static void view3d_draw_objects(
/* dupli drawing */
if (base->object->transflag & OB_DUPLI) {
draw_dupli_objects(scene, ar, v3d, base);
draw_dupli_objects(bmain, scene, ar, v3d, base);
}
if ((base->flag & SELECT) == 0) {
if (base->object != scene->obedit)
draw_object(scene, ar, v3d, base, 0);
draw_object(bmain, scene, ar, v3d, base, 0);
}
}
}
@ -2957,7 +2958,7 @@ static void view3d_draw_objects(
for (base = scene->base.first; base; base = base->next) {
if (v3d->lay & base->lay) {
if (base->object == scene->obedit || (base->flag & SELECT)) {
draw_object(scene, ar, v3d, base, 0);
draw_object(bmain, scene, ar, v3d, base, 0);
}
}
}
@ -2979,7 +2980,7 @@ static void view3d_draw_objects(
}
/* transp and X-ray afterdraw stuff */
if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
if (v3d->afterdraw_transp.first) view3d_draw_transp(bmain, scene, ar, v3d);
/* always do that here to cleanup depth buffers if none needed */
if (fx) {
@ -2987,8 +2988,8 @@ static void view3d_draw_objects(
GPU_fx_compositor_setup_XRay_pass(fx, do_composite_xray);
}
if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, &xrayclear);
if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, xrayclear);
if (v3d->afterdraw_xray.first) view3d_draw_xray(bmain, scene, ar, v3d, &xrayclear);
if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(bmain, scene, ar, v3d, xrayclear);
if (fx && do_composite_xray) {
GPU_fx_compositor_XRay_resolve(fx);
@ -3075,11 +3076,11 @@ void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, struct RV3DMatrixSto
rv3d->pixsize = rv3dmat->pixsize;
}
void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d)
void ED_view3d_draw_offscreen_init(Main *bmain, Scene *scene, View3D *v3d)
{
/* shadow buffers, before we setup matrices */
if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype))
gpu_update_lamps_shadows_world(scene, v3d);
gpu_update_lamps_shadows_world(bmain, scene, v3d);
}
/*
@ -3295,7 +3296,8 @@ void ED_view3d_draw_setup_view(
* (avoids re-creating when doing multiple GL renders).
*/
ImBuf *ED_view3d_draw_offscreen_imbuf(
Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey,
Main *bmain, Scene *scene,
View3D *v3d, ARegion *ar, int sizex, int sizey,
unsigned int flag, unsigned int draw_flags,
int alpha_mode, int samples, const char *viewname,
/* output vars */
@ -3327,7 +3329,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
}
}
ED_view3d_draw_offscreen_init(scene, v3d);
ED_view3d_draw_offscreen_init(bmain, scene, v3d);
GPU_offscreen_bind(ofs, true);
@ -3465,7 +3467,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
* \note used by the sequencer
*/
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
Scene *scene, Object *camera, int width, int height,
Main *bmain, Scene *scene,
Object *camera, int width, int height,
unsigned int flag, unsigned int draw_flags, int drawtype,
int alpha_mode, int samples, const char *viewname,
GPUFX *fx, GPUOffScreen *ofs, char err_out[256])
@ -3526,7 +3529,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
return ED_view3d_draw_offscreen_imbuf(
scene, &v3d, &ar, width, height, flag, draw_flags,
bmain, scene, &v3d, &ar, width, height, flag, draw_flags,
alpha_mode, samples, viewname, fx, ofs, err_out);
}
@ -3858,6 +3861,7 @@ static void update_lods(Scene *scene, float camera_pos[3])
static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, View3D *v3d,
ARegion *ar, const char **grid_unit)
{
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
RegionView3D *rv3d = ar->regiondata;
unsigned int lay_used = v3d->lay_used;
@ -3867,7 +3871,7 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie
/* shadow buffers, before we setup matrices */
if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype))
gpu_update_lamps_shadows_world(scene, v3d);
gpu_update_lamps_shadows_world(bmain, scene, v3d);
/* reset default OpenGL lights if needed (i.e. after preferences have been altered) */
if (rv3d->rflag & RV3D_GPULIGHT_UPDATE) {

View File

@ -127,6 +127,7 @@ static void view3d_operator_properties_common(wmOperatorType *ot, const enum eV3
typedef struct ViewOpsData {
/** Context pointers (assigned by #viewops_data_alloc). */
Main *bmain;
Scene *scene;
ScrArea *sa;
ARegion *ar;
@ -216,6 +217,7 @@ static void viewops_data_alloc(bContext *C, wmOperator *op)
/* store data */
op->customdata = vod;
vod->bmain = CTX_data_main(C);
vod->scene = CTX_data_scene(C);
vod->sa = CTX_wm_area(C);
vod->ar = CTX_wm_region(C);
@ -381,7 +383,7 @@ static void viewops_data_create(
negate_v3_v3(fallback_depth_pt, rv3d->ofs);
vod->use_dyn_ofs = ED_view3d_autodist(
vod->scene, vod->ar, vod->v3d,
vod->bmain, vod->scene, vod->ar, vod->v3d,
event->mval, vod->dyn_ofs, true, fallback_depth_pt);
}
else {
@ -3049,6 +3051,7 @@ void VIEW3D_OT_view_center_cursor(wmOperatorType *ot)
static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
Scene *scene = CTX_data_scene(C);
@ -3062,7 +3065,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
view3d_operator_needs_opengl(C);
if (ED_view3d_autodist(scene, ar, v3d, event->mval, new_ofs, false, NULL)) {
if (ED_view3d_autodist(bmain, scene, ar, v3d, event->mval, new_ofs, false, NULL)) {
/* pass */
}
else {
@ -3339,6 +3342,7 @@ void VIEW3D_OT_clear_render_border(wmOperatorType *ot)
static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@ -3372,7 +3376,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
/* Get Z Depths, needed for perspective, nice for ortho */
bgl_get_mats(&mats);
ED_view3d_draw_depth(scene, ar, v3d, true);
ED_view3d_draw_depth(bmain, scene, ar, v3d, true);
{
/* avoid allocating the whole depth buffer */
@ -4527,6 +4531,7 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot)
/* note: cannot use event->mval here (called by object_add() */
void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
@ -4550,7 +4555,7 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2])
if (U.uiflag & USER_DEPTH_CURSOR) { /* maybe this should be accessed some other way */
view3d_operator_needs_opengl(C);
if (ED_view3d_autodist(scene, ar, v3d, mval, fp, true, NULL))
if (ED_view3d_autodist(bmain, scene, ar, v3d, mval, fp, true, NULL))
depth_used = true;
}

View File

@ -144,10 +144,10 @@ void draw_motion_paths_cleanup(View3D *v3d);
/* drawobject.c */
void draw_object(
Scene *scene, struct ARegion *ar, View3D *v3d,
struct Main *bmain, Scene *scene, struct ARegion *ar, View3D *v3d,
Base *base, const short dflag);
void draw_object_select(
Scene *scene, ARegion *ar, View3D *v3d,
struct Main *bmain, Scene *scene, ARegion *ar, View3D *v3d,
Base *base, const short dflag);
bool draw_glsl_material(Scene *scene, struct Object *ob, View3D *v3d, const char dt);
@ -203,7 +203,7 @@ void draw_sim_debug_data(Scene *scene, View3D *v3d, ARegion *ar);
void view3d_main_region_draw(const struct bContext *C, struct ARegion *ar);
void ED_view3d_draw_depth(
Scene *scene,
struct Main *bmain, struct Scene *scene,
struct ARegion *ar, View3D *v3d, bool alphaoverride);
void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d);
void ED_view3d_draw_select_loop(

View File

@ -109,6 +109,7 @@ void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc)
{
memset(vc, 0, sizeof(ViewContext));
vc->ar = CTX_wm_region(C);
vc->bmain = CTX_data_main(C);
vc->scene = CTX_data_scene(C);
vc->v3d = CTX_wm_view3d(C);
vc->win = CTX_wm_window(C);

View File

@ -46,9 +46,10 @@
#include "BKE_camera.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */
#include "BKE_main.h"
#include "BKE_object.h"
#include "BKE_screen.h"
#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */
#include "BIF_gl.h"
#include "BIF_glutil.h"
@ -877,7 +878,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg
* \param fallback_depth_pt: Use this points depth when no depth can be found.
*/
bool ED_view3d_autodist(
Scene *scene, ARegion *ar, View3D *v3d,
Main *bmain, Scene *scene, ARegion *ar, View3D *v3d,
const int mval[2], float mouse_worldloc[3],
const bool alphaoverride, const float fallback_depth_pt[3])
{
@ -889,7 +890,7 @@ bool ED_view3d_autodist(
bool depth_ok = false;
/* Get Z Depths, needed for perspective, nice for ortho */
ED_view3d_draw_depth(scene, ar, v3d, alphaoverride);
ED_view3d_draw_depth(bmain, scene, ar, v3d, alphaoverride);
/* call after in case settings have been modified since last drawing, see: T47089 */
bgl_get_mats(&mats);
@ -924,12 +925,12 @@ bool ED_view3d_autodist(
}
}
void ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode)
void ED_view3d_autodist_init(Main *bmain, Scene *scene, ARegion *ar, View3D *v3d, int mode)
{
/* Get Z Depths, needed for perspective, nice for ortho */
switch (mode) {
case 0:
ED_view3d_draw_depth(scene, ar, v3d, true);
ED_view3d_draw_depth(bmain, scene, ar, v3d, true);
break;
case 1:
ED_view3d_draw_depth_gpencil(scene, ar, v3d);

View File

@ -807,6 +807,8 @@ static bool pchan_autoik_adjust(bPoseChannel *pchan, short chainlen)
/* change the chain-length of auto-ik */
void transform_autoik_update(TransInfo *t, short mode)
{
Main *bmain = CTX_data_main(t->context);
short *chainlen = &t->settings->autoik_chainlen;
bPoseChannel *pchan;
@ -842,13 +844,13 @@ void transform_autoik_update(TransInfo *t, short mode)
{
if (changed) {
/* TODO(sergey): Consider doing partial update only. */
DAG_relations_tag_update(G.main);
DAG_relations_tag_update(bmain);
}
}
}
/* frees temporal IKs */
static void pose_grab_with_ik_clear(Object *ob)
static void pose_grab_with_ik_clear(Main *bmain, Object *ob)
{
bKinematicConstraint *data;
bPoseChannel *pchan;
@ -892,7 +894,7 @@ static void pose_grab_with_ik_clear(Object *ob)
#endif
{
/* TODO(sergey): Consider doing partial update only. */
DAG_relations_tag_update(G.main);
DAG_relations_tag_update(bmain);
}
}
@ -1000,7 +1002,7 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone)
}
/* main call which adds temporal IK chains */
static short pose_grab_with_ik(Object *ob)
static short pose_grab_with_ik(Main *bmain, Object *ob)
{
bArmature *arm;
bPoseChannel *pchan, *parent;
@ -1050,8 +1052,8 @@ static short pose_grab_with_ik(Object *ob)
if (!DEG_depsgraph_use_legacy())
#endif
{
/* TODO(sergey): Consuder doing partial update only. */
DAG_relations_tag_update(G.main);
/* TODO(sergey): Consider doing partial update only. */
DAG_relations_tag_update(bmain);
}
}
@ -1062,6 +1064,7 @@ static short pose_grab_with_ik(Object *ob)
/* only called with pose mode active object now */
static void createTransPose(TransInfo *t, Object *ob)
{
Main *bmain = CTX_data_main(t->context);
bArmature *arm;
bPoseChannel *pchan;
TransData *td;
@ -1084,7 +1087,7 @@ static void createTransPose(TransInfo *t, Object *ob)
/* do we need to add temporal IK chains? */
if ((arm->flag & ARM_AUTO_IK) && t->mode == TFM_TRANSLATION) {
ik_on = pose_grab_with_ik(ob);
ik_on = pose_grab_with_ik(bmain, ob);
if (ik_on) t->flag |= T_AUTOIK;
}
@ -5608,6 +5611,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
/* it deselects Bases, so we have to call the clear function always after */
static void set_trans_object_base_flags(TransInfo *t)
{
Main *bmain = CTX_data_main(t->context);
Scene *scene = t->scene;
View3D *v3d = t->view;
@ -5625,13 +5629,13 @@ static void set_trans_object_base_flags(TransInfo *t)
BKE_scene_base_flag_to_objects(t->scene);
/* Make sure depsgraph is here. */
DAG_scene_relations_update(G.main, t->scene);
DAG_scene_relations_update(bmain, t->scene);
/* handle pending update events, otherwise they got copied below */
for (base = scene->base.first; base; base = base->next) {
if (base->object->recalc & OB_RECALC_ALL) {
/* TODO(sergey): Ideally, it's not needed. */
BKE_object_handle_update(G.main->eval_ctx, t->scene, base->object);
BKE_object_handle_update(bmain->eval_ctx, t->scene, base->object);
}
}
@ -5672,7 +5676,7 @@ static void set_trans_object_base_flags(TransInfo *t)
}
/* all recalc flags get flushed to all layers, so a layer flip later on works fine */
DAG_scene_flush_update(G.main, t->scene, -1, 0);
DAG_scene_flush_update(bmain, t->scene, -1, 0);
/* and we store them temporal in base (only used for transform code) */
/* this because after doing updates, the object->recalc is cleared */
@ -5701,6 +5705,7 @@ static bool mark_children(Object *ob)
static int count_proportional_objects(TransInfo *t)
{
int total = 0;
Main *bmain = CTX_data_main(t->context);
Scene *scene = t->scene;
View3D *v3d = t->view;
Base *base;
@ -5749,8 +5754,8 @@ static int count_proportional_objects(TransInfo *t)
/* all recalc flags get flushed to all layers, so a layer flip later on works fine */
DAG_scene_relations_update(G.main, t->scene);
DAG_scene_flush_update(G.main, t->scene, -1, 0);
DAG_scene_relations_update(bmain, t->scene);
DAG_scene_flush_update(bmain, t->scene, -1, 0);
/* and we store them temporal in base (only used for transform code) */
/* this because after doing updates, the object->recalc is cleared */
@ -6175,6 +6180,9 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t)
* */
void special_aftertrans_update(bContext *C, TransInfo *t)
{
Main *bmain = CTX_data_main(t->context);
BLI_assert(bmain == CTX_data_main(C));
Object *ob;
// short redrawipo=0, resetslowpar=1;
const bool canceled = (t->state == TRANS_CANCEL);
@ -6360,7 +6368,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// XXX: BAD! this get gpencil datablocks directly from main db...
// but that's how this currently works :/
for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
for (gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
if (ID_REAL_USERS(gpd))
posttrans_gpd_clean(gpd);
}
@ -6380,7 +6388,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// XXX: BAD! this get gpencil datablocks directly from main db...
// but that's how this currently works :/
for (mask = G.main->mask.first; mask; mask = mask->id.next) {
for (mask = bmain->mask.first; mask; mask = mask->id.next) {
if (ID_REAL_USERS(mask))
posttrans_mask_clean(mask);
}
@ -6537,7 +6545,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
if (t->mode == TFM_TRANSLATION)
pose_grab_with_ik_clear(ob);
pose_grab_with_ik_clear(bmain, ob);
/* automatic inserting of keys and unkeyed tagging - only if transform wasn't canceled (or TFM_DUMMY) */
if (!canceled && (t->mode != TFM_DUMMY)) {

View File

@ -284,6 +284,8 @@ eRedrawFlag handleSnapping(TransInfo *t, const wmEvent *event)
void applyProject(TransInfo *t)
{
Main *bmain = CTX_data_main(t->context);
/* XXX FLICKER IN OBJECT MODE */
if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0) {
TransData *td = t->data;
@ -316,7 +318,7 @@ void applyProject(TransInfo *t)
mul_m4_v3(ob->obmat, iloc);
}
else if (t->flag & T_OBJECT) {
BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob);
BKE_object_eval_transform_all(bmain->eval_ctx, t->scene, td->ob);
copy_v3_v3(iloc, td->ob->obmat[3]);
}
@ -359,6 +361,8 @@ void applyProject(TransInfo *t)
void applyGridAbsolute(TransInfo *t)
{
Main *bmain = CTX_data_main(t->context);
float grid_size = 0.0f;
GearsType grid_action;
TransData *td;
@ -405,7 +409,7 @@ void applyGridAbsolute(TransInfo *t)
mul_m4_v3(obmat, iloc);
}
else if (t->flag & T_OBJECT) {
BKE_object_eval_transform_all(G.main->eval_ctx, t->scene, td->ob);
BKE_object_eval_transform_all(bmain->eval_ctx, t->scene, td->ob);
copy_v3_v3(iloc, td->ob->obmat[3]);
}
@ -514,6 +518,7 @@ static bool bm_face_is_snap_target(BMFace *f, void *UNUSED(user_data))
static void initSnappingMode(TransInfo *t)
{
Main *bmain = CTX_data_main(t->context);
ToolSettings *ts = t->settings;
Object *obedit = t->obedit;
Scene *scene = t->scene;
@ -598,7 +603,7 @@ static void initSnappingMode(TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
if (t->tsnap.object_context == NULL) {
t->tsnap.object_context = ED_transform_snap_object_context_create_view3d(
G.main, t->scene, 0,
bmain, t->scene, 0,
t->ar, t->view);
ED_transform_snap_object_context_set_editmesh_callbacks(

View File

@ -35,6 +35,8 @@
#include "WM_types.h"
#include "BKE_global.h"
#include "ED_screen.h"
#include "GPU_compositing.h"
@ -192,7 +194,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *a
fx_settings = v3d->fx_settings; /* full copy */
ED_view3d_draw_offscreen_init(scene, v3d);
ED_view3d_draw_offscreen_init(G.main, scene, v3d);
rv3d_mats = ED_view3d_mats_rv3d_backup(ar->regiondata);

View File

@ -323,7 +323,7 @@ static void wm_window_match_do(Main *bmain, bContext *C, ListBase *oldwmlist)
static void wm_init_userdef(Main *bmain, const bool read_userdef_from_memory)
{
/* versioning is here */
UI_init_userdef();
UI_init_userdef(bmain);
MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024);
BKE_sound_init(bmain);
@ -1007,7 +1007,7 @@ static void wm_history_file_update(void)
/* screen can be NULL */
static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, BlendThumbnail **thumb_pt)
static ImBuf *blend_file_thumb(Main *bmain, Scene *scene, bScreen *screen, BlendThumbnail **thumb_pt)
{
/* will be scaled down, but gives some nice oversampling */
ImBuf *ibuf;
@ -1044,14 +1044,14 @@ static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, BlendThumbnail **t
/* gets scaled to BLEN_THUMB_SIZE */
if (scene->camera) {
ibuf = ED_view3d_draw_offscreen_imbuf_simple(
scene, scene->camera,
bmain, scene, scene->camera,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
IB_rect, V3D_OFSDRAW_NONE, OB_SOLID, R_ALPHAPREMUL, 0, NULL,
NULL, NULL, err_out);
}
else {
ibuf = ED_view3d_draw_offscreen_imbuf(
scene, v3d, ar,
bmain, scene, v3d, ar,
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL,
NULL, NULL, err_out);
@ -1148,7 +1148,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
/* Main now can store a .blend thumbnail, usefull for background mode or thumbnail customization. */
main_thumb = thumb = CTX_data_main(C)->blen_thumb;
if ((U.flag & USER_SAVE_PREVIEWS) && BLI_thread_is_main()) {
ibuf_thumb = blend_file_thumb(CTX_data_scene(C), CTX_wm_screen(C), &thumb);
ibuf_thumb = blend_file_thumb(bmain, CTX_data_scene(C), CTX_wm_screen(C), &thumb);
}
/* operator now handles overwrite checks */