Object Mode: Add to EvaluationContext & DRWContextState
This commit is contained in:
		@@ -1273,8 +1273,10 @@ void CTX_data_eval_ctx(const bContext *C, EvaluationContext *eval_ctx)
 | 
			
		||||
 | 
			
		||||
	Scene *scene = CTX_data_scene(C);
 | 
			
		||||
	ViewLayer *view_layer = CTX_data_view_layer(C);
 | 
			
		||||
	Object *obact = OBACT(view_layer);
 | 
			
		||||
	RenderEngineType *engine_type = CTX_data_engine_type(C);
 | 
			
		||||
	DEG_evaluation_context_init_from_scene(eval_ctx,
 | 
			
		||||
	                                       scene, view_layer, engine_type,
 | 
			
		||||
	                                       DAG_EVAL_VIEWPORT);
 | 
			
		||||
	DEG_evaluation_context_init_from_scene(
 | 
			
		||||
	        eval_ctx,
 | 
			
		||||
	        scene, view_layer, engine_type,
 | 
			
		||||
	        obact ? obact->mode : OB_MODE_OBJECT, DAG_EVAL_VIEWPORT);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -83,6 +83,7 @@ typedef enum eEvaluationMode {
 | 
			
		||||
typedef struct EvaluationContext {
 | 
			
		||||
	eEvaluationMode mode;
 | 
			
		||||
	float ctime;
 | 
			
		||||
	short object_mode;
 | 
			
		||||
 | 
			
		||||
	struct Depsgraph *depsgraph;
 | 
			
		||||
	struct ViewLayer *view_layer;
 | 
			
		||||
@@ -213,11 +214,13 @@ struct EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode);
 | 
			
		||||
 */
 | 
			
		||||
void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx,
 | 
			
		||||
                                 eEvaluationMode mode);
 | 
			
		||||
void DEG_evaluation_context_init_from_scene(struct EvaluationContext *eval_ctx,
 | 
			
		||||
                                            struct Scene *scene,
 | 
			
		||||
                                            struct ViewLayer *view_layer,
 | 
			
		||||
                                            struct RenderEngineType *engine_type,
 | 
			
		||||
                                            eEvaluationMode mode);
 | 
			
		||||
void DEG_evaluation_context_init_from_scene(
 | 
			
		||||
        struct EvaluationContext *eval_ctx,
 | 
			
		||||
        struct Scene *scene,
 | 
			
		||||
        struct ViewLayer *view_layer,
 | 
			
		||||
        struct RenderEngineType *engine_type,
 | 
			
		||||
        const short object_mode,
 | 
			
		||||
        eEvaluationMode mode);
 | 
			
		||||
 | 
			
		||||
/* Free evaluation context. */
 | 
			
		||||
void DEG_evaluation_context_free(struct EvaluationContext *eval_ctx);
 | 
			
		||||
 
 | 
			
		||||
@@ -76,17 +76,20 @@ void DEG_evaluation_context_init(EvaluationContext *eval_ctx,
 | 
			
		||||
	eval_ctx->mode = mode;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DEG_evaluation_context_init_from_scene(EvaluationContext *eval_ctx,
 | 
			
		||||
                                            Scene *scene,
 | 
			
		||||
                                            ViewLayer *view_layer,
 | 
			
		||||
                                            RenderEngineType *engine_type,
 | 
			
		||||
                                            eEvaluationMode mode)
 | 
			
		||||
void DEG_evaluation_context_init_from_scene(
 | 
			
		||||
        EvaluationContext *eval_ctx,
 | 
			
		||||
        Scene *scene,
 | 
			
		||||
        ViewLayer *view_layer,
 | 
			
		||||
        RenderEngineType *engine_type,
 | 
			
		||||
        short object_mode,
 | 
			
		||||
        eEvaluationMode mode)
 | 
			
		||||
{
 | 
			
		||||
	DEG_evaluation_context_init(eval_ctx, mode);
 | 
			
		||||
	eval_ctx->depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
 | 
			
		||||
	eval_ctx->view_layer = view_layer;
 | 
			
		||||
	eval_ctx->engine_type = engine_type;
 | 
			
		||||
	eval_ctx->ctime = BKE_scene_frame_get(scene);
 | 
			
		||||
	eval_ctx->object_mode = object_mode;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Free evaluation context. */
 | 
			
		||||
 
 | 
			
		||||
@@ -91,25 +91,25 @@ void DRW_draw_view(const struct bContext *C);
 | 
			
		||||
void DRW_draw_render_loop_ex(
 | 
			
		||||
        struct Depsgraph *depsgraph,
 | 
			
		||||
        struct RenderEngineType *engine_type,
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d,
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d, const short object_mode,
 | 
			
		||||
        const struct bContext *evil_C);
 | 
			
		||||
void DRW_draw_render_loop(
 | 
			
		||||
        struct Depsgraph *depsgraph,
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d);
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d, const short object_mode);
 | 
			
		||||
void DRW_draw_render_loop_offscreen(
 | 
			
		||||
        struct Depsgraph *depsgraph,
 | 
			
		||||
        struct RenderEngineType *engine_type,
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d,
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d, const short object_mode,
 | 
			
		||||
        const bool draw_background,
 | 
			
		||||
        struct GPUOffScreen *ofs,
 | 
			
		||||
        struct GPUViewport *viewport);
 | 
			
		||||
void DRW_draw_select_loop(
 | 
			
		||||
        struct Depsgraph *depsgraph,
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d,
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d, const short object_mode,
 | 
			
		||||
        bool use_obedit_skip, bool use_nearest, const struct rcti *rect);
 | 
			
		||||
void DRW_draw_depth_loop(
 | 
			
		||||
        struct Depsgraph *depsgraph,
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d);
 | 
			
		||||
        struct ARegion *ar, struct View3D *v3d, const short object_mode);
 | 
			
		||||
 | 
			
		||||
/* This is here because GPUViewport needs it */
 | 
			
		||||
void DRW_pass_free(struct DRWPass *pass);
 | 
			
		||||
 
 | 
			
		||||
@@ -820,7 +820,7 @@ static void clay_cache_populate(void *vedata, Object *ob)
 | 
			
		||||
	if (geom) {
 | 
			
		||||
		IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
 | 
			
		||||
		const bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
 | 
			
		||||
		const bool is_sculpt_mode = is_active && (ob->mode & OB_MODE_SCULPT) != 0;
 | 
			
		||||
		const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
 | 
			
		||||
		const bool is_default_mode_shader = is_sculpt_mode;
 | 
			
		||||
 | 
			
		||||
		/* Depth Prepass */
 | 
			
		||||
 
 | 
			
		||||
@@ -1241,7 +1241,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
 | 
			
		||||
	IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
 | 
			
		||||
	const bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
 | 
			
		||||
	const bool is_active = (ob == draw_ctx->obact);
 | 
			
		||||
	const bool is_sculpt_mode = is_active && (ob->mode & OB_MODE_SCULPT) != 0;
 | 
			
		||||
	const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
 | 
			
		||||
#if 0
 | 
			
		||||
	const bool is_sculpt_mode_draw = is_sculpt_mode && (draw_ctx->v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0;
 | 
			
		||||
#else
 | 
			
		||||
 
 | 
			
		||||
@@ -79,6 +79,7 @@ static void eevee_motion_blur_camera_get_matrix_at_time(
 | 
			
		||||
	        scene,
 | 
			
		||||
	        draw_ctx->view_layer,
 | 
			
		||||
	        draw_ctx->engine_type,
 | 
			
		||||
	        draw_ctx->object_mode,
 | 
			
		||||
	        DAG_EVAL_VIEWPORT);
 | 
			
		||||
	eval_ctx.ctime = time;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -455,6 +455,7 @@ struct DRWTextStore *DRW_state_text_cache_get(void);
 | 
			
		||||
 | 
			
		||||
/* Avoid too many lookups while drawing */
 | 
			
		||||
typedef struct DRWContextState {
 | 
			
		||||
 | 
			
		||||
	struct ARegion *ar;         /* 'CTX_wm_region(C)' */
 | 
			
		||||
	struct RegionView3D *rv3d;  /* 'CTX_wm_region_view3d(C)' */
 | 
			
		||||
	struct View3D *v3d;     /* 'CTX_wm_view3d(C)' */
 | 
			
		||||
@@ -469,9 +470,12 @@ typedef struct DRWContextState {
 | 
			
		||||
 | 
			
		||||
	struct Depsgraph *depsgraph;
 | 
			
		||||
 | 
			
		||||
	short object_mode;
 | 
			
		||||
 | 
			
		||||
	/* Last resort (some functions take this as an arg so we can't easily avoid).
 | 
			
		||||
	 * May be NULL when used for selection or depth buffer. */
 | 
			
		||||
	const struct bContext *evil_C;
 | 
			
		||||
 | 
			
		||||
} DRWContextState;
 | 
			
		||||
 | 
			
		||||
const DRWContextState *DRW_context_state_get(void);
 | 
			
		||||
 
 | 
			
		||||
@@ -1308,7 +1308,9 @@ static void draw_armature_pose(Object *ob, const float const_color[4])
 | 
			
		||||
 | 
			
		||||
	// if (!(base->flag & OB_FROMDUPLI)) // TODO
 | 
			
		||||
	{
 | 
			
		||||
		if (ob->mode & OB_MODE_POSE) {
 | 
			
		||||
		const DRWContextState *draw_ctx = DRW_context_state_get();
 | 
			
		||||
 | 
			
		||||
		if (draw_ctx->object_mode & OB_MODE_POSE) {
 | 
			
		||||
			arm->flag |= ARM_POSEMODE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,6 @@
 | 
			
		||||
 | 
			
		||||
#include "draw_common.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
#define UI_COLOR_RGB_FROM_U8(r, g, b, v4) \
 | 
			
		||||
	ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 1.0)
 | 
			
		||||
@@ -386,7 +385,8 @@ DRWShadingGroup *shgroup_instance_mball_helpers(DRWPass *pass, struct Gwn_Batch
 | 
			
		||||
 */
 | 
			
		||||
int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color)
 | 
			
		||||
{
 | 
			
		||||
	const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
 | 
			
		||||
	const DRWContextState *draw_ctx = DRW_context_state_get();
 | 
			
		||||
	const bool is_edit = (draw_ctx->object_mode & OB_MODE_EDIT) != 0;
 | 
			
		||||
	const bool active = (view_layer->basact && view_layer->basact->object == ob);
 | 
			
		||||
	/* confusing logic here, there are 2 methods of setting the color
 | 
			
		||||
	 * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
 | 
			
		||||
 
 | 
			
		||||
@@ -120,7 +120,8 @@ struct DRWShadingGroup *shgroup_instance_bone_envelope_wire(struct DRWPass *pass
 | 
			
		||||
struct DRWShadingGroup *shgroup_instance_bone_envelope_solid(struct DRWPass *pass, struct Gwn_Batch *geom);
 | 
			
		||||
struct DRWShadingGroup *shgroup_instance_mball_helpers(struct DRWPass *pass, struct Gwn_Batch *geom);
 | 
			
		||||
 | 
			
		||||
int DRW_object_wire_theme_get(struct Object *ob, struct ViewLayer *view_layer, float **r_color);
 | 
			
		||||
int DRW_object_wire_theme_get(
 | 
			
		||||
        struct Object *ob, struct ViewLayer *view_layer, float **r_color);
 | 
			
		||||
float *DRW_color_background_blend_get(int theme_id);
 | 
			
		||||
 | 
			
		||||
/* draw_armature.c */
 | 
			
		||||
 
 | 
			
		||||
@@ -2257,8 +2257,8 @@ bool DRW_object_is_flat_normal(const Object *ob)
 | 
			
		||||
int DRW_object_is_mode_shade(const Object *ob)
 | 
			
		||||
{
 | 
			
		||||
	BLI_assert(ob == DST.draw_ctx.obact);
 | 
			
		||||
	if ((ob->mode & OB_MODE_EDIT) == 0) {
 | 
			
		||||
		if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
 | 
			
		||||
	if ((DST.draw_ctx.object_mode & OB_MODE_EDIT) == 0) {
 | 
			
		||||
		if (DST.draw_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
 | 
			
		||||
			if ((DST.draw_ctx.v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0) {
 | 
			
		||||
				return true;
 | 
			
		||||
			}
 | 
			
		||||
@@ -3329,7 +3329,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
 | 
			
		||||
 | 
			
		||||
	DST.viewport = rv3d->viewport;
 | 
			
		||||
	DST.draw_ctx = (DRWContextState){
 | 
			
		||||
		ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph,
 | 
			
		||||
		ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, OB_MODE_OBJECT,
 | 
			
		||||
		NULL,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
@@ -3376,7 +3376,7 @@ void DRW_notify_id_update(const DRWUpdateContext *update_ctx, ID *id)
 | 
			
		||||
	memset(&DST, 0x0, sizeof(DST));
 | 
			
		||||
	DST.viewport = rv3d->viewport;
 | 
			
		||||
	DST.draw_ctx = (DRWContextState){
 | 
			
		||||
		ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, NULL,
 | 
			
		||||
		ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, OB_MODE_OBJECT, NULL,
 | 
			
		||||
	};
 | 
			
		||||
	drw_engines_enable(scene, view_layer, engine_type);
 | 
			
		||||
	for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
 | 
			
		||||
@@ -3402,14 +3402,15 @@ void DRW_notify_id_update(const DRWUpdateContext *update_ctx, ID *id)
 | 
			
		||||
 * for each relevant engine / mode engine. */
 | 
			
		||||
void DRW_draw_view(const bContext *C)
 | 
			
		||||
{
 | 
			
		||||
	struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
 | 
			
		||||
	EvaluationContext eval_ctx;
 | 
			
		||||
	CTX_data_eval_ctx(C, &eval_ctx);
 | 
			
		||||
	RenderEngineType *engine_type = CTX_data_engine_type(C);
 | 
			
		||||
	ARegion *ar = CTX_wm_region(C);
 | 
			
		||||
	View3D *v3d = CTX_wm_view3d(C);
 | 
			
		||||
 | 
			
		||||
	/* Reset before using it. */
 | 
			
		||||
	memset(&DST, 0x0, sizeof(DST));
 | 
			
		||||
	DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, C);
 | 
			
		||||
	DRW_draw_render_loop_ex(eval_ctx.depsgraph, engine_type, ar, v3d, eval_ctx.object_mode, C);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -3419,7 +3420,7 @@ void DRW_draw_view(const bContext *C)
 | 
			
		||||
void DRW_draw_render_loop_ex(
 | 
			
		||||
        struct Depsgraph *depsgraph,
 | 
			
		||||
        RenderEngineType *engine_type,
 | 
			
		||||
        ARegion *ar, View3D *v3d,
 | 
			
		||||
        ARegion *ar, View3D *v3d, const short object_mode,
 | 
			
		||||
        const bContext *evil_C)
 | 
			
		||||
{
 | 
			
		||||
	Scene *scene = DEG_get_evaluated_scene(depsgraph);
 | 
			
		||||
@@ -3435,7 +3436,7 @@ void DRW_draw_render_loop_ex(
 | 
			
		||||
	GPU_viewport_engines_data_validate(DST.viewport, DRW_engines_get_hash());
 | 
			
		||||
 | 
			
		||||
	DST.draw_ctx = (DRWContextState){
 | 
			
		||||
	    ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph,
 | 
			
		||||
	    ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, object_mode,
 | 
			
		||||
 | 
			
		||||
	    /* reuse if caller sets */
 | 
			
		||||
	    DST.draw_ctx.evil_C,
 | 
			
		||||
@@ -3544,7 +3545,7 @@ void DRW_draw_render_loop_ex(
 | 
			
		||||
 | 
			
		||||
void DRW_draw_render_loop(
 | 
			
		||||
        struct Depsgraph *depsgraph,
 | 
			
		||||
        ARegion *ar, View3D *v3d)
 | 
			
		||||
        ARegion *ar, View3D *v3d, const short object_mode)
 | 
			
		||||
{
 | 
			
		||||
	/* Reset before using it. */
 | 
			
		||||
	memset(&DST, 0x0, sizeof(DST));
 | 
			
		||||
@@ -3552,13 +3553,14 @@ void DRW_draw_render_loop(
 | 
			
		||||
	Scene *scene = DEG_get_evaluated_scene(depsgraph);
 | 
			
		||||
	RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
 | 
			
		||||
 | 
			
		||||
	DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, NULL);
 | 
			
		||||
	DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, object_mode, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* @viewport CAN be NULL, in this case we create one. */
 | 
			
		||||
void DRW_draw_render_loop_offscreen(
 | 
			
		||||
        struct Depsgraph *depsgraph, RenderEngineType *engine_type,
 | 
			
		||||
        ARegion *ar, View3D *v3d, const bool draw_background, GPUOffScreen *ofs,
 | 
			
		||||
        ARegion *ar, View3D *v3d, const short object_mode,
 | 
			
		||||
        const bool draw_background, GPUOffScreen *ofs,
 | 
			
		||||
        GPUViewport *viewport)
 | 
			
		||||
{
 | 
			
		||||
	RegionView3D *rv3d = ar->regiondata;
 | 
			
		||||
@@ -3579,7 +3581,7 @@ void DRW_draw_render_loop_offscreen(
 | 
			
		||||
	memset(&DST, 0x0, sizeof(DST));
 | 
			
		||||
	DST.options.is_image_render = true;
 | 
			
		||||
	DST.options.draw_background = draw_background;
 | 
			
		||||
	DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, NULL);
 | 
			
		||||
	DRW_draw_render_loop_ex(depsgraph, engine_type, ar, v3d, object_mode, NULL);
 | 
			
		||||
 | 
			
		||||
	/* restore */
 | 
			
		||||
	{
 | 
			
		||||
@@ -3605,6 +3607,7 @@ void DRW_render_to_image(RenderEngine *re, struct Depsgraph *depsgraph)
 | 
			
		||||
	DrawEngineType *draw_engine_type = engine_type->draw_engine;
 | 
			
		||||
	RenderData *r = &scene->r;
 | 
			
		||||
	Render *render = re->re;
 | 
			
		||||
	const EvaluationContext *eval_ctx = RE_GetEvalCtx(render);
 | 
			
		||||
 | 
			
		||||
	/* Reset before using it. */
 | 
			
		||||
	memset(&DST, 0x0, sizeof(DST));
 | 
			
		||||
@@ -3613,7 +3616,7 @@ void DRW_render_to_image(RenderEngine *re, struct Depsgraph *depsgraph)
 | 
			
		||||
	DST.options.draw_background = scene->r.alphamode == R_ADDSKY;
 | 
			
		||||
 | 
			
		||||
	DST.draw_ctx = (DRWContextState){
 | 
			
		||||
	    NULL, NULL, NULL, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, NULL
 | 
			
		||||
	    NULL, NULL, NULL, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, eval_ctx->object_mode, NULL,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	DST.viewport = GPU_viewport_create();
 | 
			
		||||
@@ -3681,7 +3684,7 @@ void DRW_render_object_iter(
 | 
			
		||||
 */
 | 
			
		||||
void DRW_draw_select_loop(
 | 
			
		||||
        struct Depsgraph *depsgraph,
 | 
			
		||||
        ARegion *ar, View3D *v3d,
 | 
			
		||||
        ARegion *ar, View3D *v3d, const short object_mode,
 | 
			
		||||
        bool UNUSED(use_obedit_skip), bool UNUSED(use_nearest), const rcti *rect)
 | 
			
		||||
{
 | 
			
		||||
	Scene *scene = DEG_get_evaluated_scene(depsgraph);
 | 
			
		||||
@@ -3737,7 +3740,8 @@ void DRW_draw_select_loop(
 | 
			
		||||
 | 
			
		||||
	/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
 | 
			
		||||
	DST.draw_ctx = (DRWContextState){
 | 
			
		||||
		ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, (bContext *)NULL,
 | 
			
		||||
		ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, object_mode,
 | 
			
		||||
		(bContext *)NULL,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	drw_viewport_var_init();
 | 
			
		||||
@@ -3802,7 +3806,7 @@ void DRW_draw_select_loop(
 | 
			
		||||
 */
 | 
			
		||||
void DRW_draw_depth_loop(
 | 
			
		||||
        Depsgraph *depsgraph,
 | 
			
		||||
        ARegion *ar, View3D *v3d)
 | 
			
		||||
        ARegion *ar, View3D *v3d, const short object_mode)
 | 
			
		||||
{
 | 
			
		||||
	Scene *scene = DEG_get_evaluated_scene(depsgraph);
 | 
			
		||||
	RenderEngineType *engine_type = RE_engines_find(scene->view_render.engine_id);
 | 
			
		||||
@@ -3836,7 +3840,8 @@ void DRW_draw_depth_loop(
 | 
			
		||||
 | 
			
		||||
	/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
 | 
			
		||||
	DST.draw_ctx = (DRWContextState){
 | 
			
		||||
		ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, (bContext *)NULL,
 | 
			
		||||
		ar, rv3d, v3d, scene, view_layer, OBACT(view_layer), engine_type, depsgraph, object_mode,
 | 
			
		||||
		(bContext *)NULL,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	drw_viewport_var_init();
 | 
			
		||||
 
 | 
			
		||||
@@ -611,20 +611,20 @@ void DRW_draw_background(void)
 | 
			
		||||
 | 
			
		||||
/* **************************** 3D Cursor ******************************** */
 | 
			
		||||
 | 
			
		||||
static bool is_cursor_visible(Scene *scene, ViewLayer *view_layer)
 | 
			
		||||
static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, ViewLayer *view_layer)
 | 
			
		||||
{
 | 
			
		||||
	Object *ob = OBACT(view_layer);
 | 
			
		||||
 | 
			
		||||
	/* don't draw cursor in paint modes, but with a few exceptions */
 | 
			
		||||
	if (ob && ob->mode & OB_MODE_ALL_PAINT) {
 | 
			
		||||
	if (ob && draw_ctx->object_mode & OB_MODE_ALL_PAINT) {
 | 
			
		||||
		/* exception: object is in weight paint and has deforming armature in pose mode */
 | 
			
		||||
		if (ob->mode & OB_MODE_WEIGHT_PAINT) {
 | 
			
		||||
		if (draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) {
 | 
			
		||||
			if (BKE_object_pose_armature_get(ob) != NULL) {
 | 
			
		||||
				return true;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		/* exception: object in texture paint mode, clone brush, use_clone_layer disabled */
 | 
			
		||||
		else if (ob->mode & OB_MODE_TEXTURE_PAINT) {
 | 
			
		||||
		else if (draw_ctx->object_mode & OB_MODE_TEXTURE_PAINT) {
 | 
			
		||||
			const Paint *p = BKE_paint_get_active(scene, view_layer);
 | 
			
		||||
 | 
			
		||||
			if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) {
 | 
			
		||||
@@ -654,7 +654,7 @@ void DRW_draw_cursor(void)
 | 
			
		||||
	glDisable(GL_DEPTH_TEST);
 | 
			
		||||
	glLineWidth(1.0f);
 | 
			
		||||
 | 
			
		||||
	if (is_cursor_visible(scene, view_layer)) {
 | 
			
		||||
	if (is_cursor_visible(draw_ctx, scene, view_layer)) {
 | 
			
		||||
		float *co = ED_view3d_cursor3d_get(scene, v3d);
 | 
			
		||||
		unsigned char crosshair_color[3];
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1811,7 +1811,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
 | 
			
		||||
 | 
			
		||||
	if (do_outlines) {
 | 
			
		||||
		Object *obedit = scene->obedit;
 | 
			
		||||
		if (ob != obedit && !((ob == draw_ctx->obact) && (ob->mode & OB_MODE_ALL_PAINT))) {
 | 
			
		||||
		if (ob != obedit && !((ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_ALL_PAINT))) {
 | 
			
		||||
			struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
 | 
			
		||||
			if (geom) {
 | 
			
		||||
				theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
 | 
			
		||||
 
 | 
			
		||||
@@ -136,13 +136,15 @@ static void POSE_cache_populate(void *vedata, Object *ob)
 | 
			
		||||
 */
 | 
			
		||||
bool DRW_pose_mode_armature(Object *ob, Object *active_ob)
 | 
			
		||||
{
 | 
			
		||||
	const DRWContextState *draw_ctx = DRW_context_state_get();
 | 
			
		||||
 | 
			
		||||
	/* Pode armature is handled by pose mode engine. */
 | 
			
		||||
	if ((ob == active_ob) && ((ob->mode & OB_MODE_POSE) != 0)) {
 | 
			
		||||
	if ((ob == active_ob) && ((draw_ctx->object_mode & OB_MODE_POSE) != 0)) {
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Armature parent is also handled by pose mode engine. */
 | 
			
		||||
	if ((active_ob != NULL) && ((active_ob->mode & OB_MODE_WEIGHT_PAINT) != 0)) {
 | 
			
		||||
	if ((active_ob != NULL) && ((draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) != 0)) {
 | 
			
		||||
		if (active_ob->parent == ob) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -752,7 +752,7 @@ void ED_view3d_draw_depth(
 | 
			
		||||
	else
 | 
			
		||||
#endif /* WITH_OPENGL_LEGACY */
 | 
			
		||||
	{
 | 
			
		||||
		DRW_draw_depth_loop(graph, ar, v3d);
 | 
			
		||||
		DRW_draw_depth_loop(graph, ar, v3d, eval_ctx->object_mode);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (rv3d->rflag & RV3D_CLIPPING) {
 | 
			
		||||
@@ -2076,7 +2076,9 @@ void ED_view3d_draw_offscreen(
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
		DRW_draw_render_loop_offscreen(depsgraph, eval_ctx->engine_type, ar, v3d, do_sky, ofs, viewport);
 | 
			
		||||
		DRW_draw_render_loop_offscreen(
 | 
			
		||||
		        depsgraph, eval_ctx->engine_type, ar, v3d, eval_ctx->object_mode,
 | 
			
		||||
		        do_sky, ofs, viewport);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* restore size */
 | 
			
		||||
 
 | 
			
		||||
@@ -954,7 +954,9 @@ int view3d_opengl_select(
 | 
			
		||||
	else
 | 
			
		||||
#else
 | 
			
		||||
	{
 | 
			
		||||
		DRW_draw_select_loop(graph, ar, v3d, use_obedit_skip, use_nearest, &rect);
 | 
			
		||||
		DRW_draw_select_loop(
 | 
			
		||||
		        graph, ar, v3d, eval_ctx->object_mode,
 | 
			
		||||
		        use_obedit_skip, use_nearest, &rect);
 | 
			
		||||
	}
 | 
			
		||||
#endif /* WITH_OPENGL_LEGACY */
 | 
			
		||||
 | 
			
		||||
@@ -971,7 +973,9 @@ int view3d_opengl_select(
 | 
			
		||||
		else
 | 
			
		||||
#else
 | 
			
		||||
		{
 | 
			
		||||
			DRW_draw_select_loop(graph, ar, v3d, use_obedit_skip, use_nearest, &rect);
 | 
			
		||||
			DRW_draw_select_loop(
 | 
			
		||||
			        graph, ar, v3d, eval_ctx->object_mode,
 | 
			
		||||
			        use_obedit_skip, use_nearest, &rect);
 | 
			
		||||
		}
 | 
			
		||||
#endif /* WITH_OPENGL_LEGACY */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2482,9 +2482,10 @@ static void createTransEditVerts(TransInfo *t)
 | 
			
		||||
	int island_info_tot;
 | 
			
		||||
	int *island_vert_map = NULL;
 | 
			
		||||
 | 
			
		||||
	DEG_evaluation_context_init_from_scene(&eval_ctx,
 | 
			
		||||
	                                       t->scene, t->view_layer, t->engine_type,
 | 
			
		||||
	                                       DAG_EVAL_VIEWPORT);
 | 
			
		||||
	DEG_evaluation_context_init_from_scene(
 | 
			
		||||
	        &eval_ctx,
 | 
			
		||||
	        t->scene, t->view_layer, t->engine_type, t->obedit->mode,
 | 
			
		||||
	        DAG_EVAL_VIEWPORT);
 | 
			
		||||
 | 
			
		||||
	/* Even for translation this is needed because of island-orientation, see: T51651. */
 | 
			
		||||
	const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS);
 | 
			
		||||
 
 | 
			
		||||
@@ -2096,7 +2096,11 @@ SnapObjectContext *ED_transform_snap_object_context_create(
 | 
			
		||||
	sctx->bmain = bmain;
 | 
			
		||||
	sctx->scene = scene;
 | 
			
		||||
 | 
			
		||||
	DEG_evaluation_context_init_from_scene(&sctx->eval_ctx, scene, view_layer, engine_type, DAG_EVAL_VIEWPORT);
 | 
			
		||||
	Object *obact = OBACT(view_layer);
 | 
			
		||||
 | 
			
		||||
	DEG_evaluation_context_init_from_scene(
 | 
			
		||||
	        &sctx->eval_ctx, scene, view_layer, engine_type,
 | 
			
		||||
	        obact ? obact->mode : OB_MODE_OBJECT, DAG_EVAL_VIEWPORT);
 | 
			
		||||
 | 
			
		||||
	sctx->cache.object_map = BLI_ghash_ptr_new(__func__);
 | 
			
		||||
	sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user