3D View: show selected object axis when affect origins is enabled
This replaces temporarily enabling draw-axis.
This commit is contained in:
parent
487cd7237c
commit
7fee153bf5
Notes:
blender-bot
2023-02-14 01:04:18 +01:00
Referenced by issue #69132, Transform object origins design task
|
@ -307,6 +307,7 @@ data_to_c_simple(modes/shaders/overlay_face_wireframe_geom.glsl SRC)
|
|||
data_to_c_simple(modes/shaders/overlay_face_wireframe_frag.glsl SRC)
|
||||
data_to_c_simple(modes/shaders/object_camera_image_frag.glsl SRC)
|
||||
data_to_c_simple(modes/shaders/object_camera_image_vert.glsl SRC)
|
||||
data_to_c_simple(modes/shaders/object_color_axes_vert.glsl SRC)
|
||||
data_to_c_simple(modes/shaders/object_empty_axes_vert.glsl SRC)
|
||||
data_to_c_simple(modes/shaders/object_empty_image_frag.glsl SRC)
|
||||
data_to_c_simple(modes/shaders/object_empty_image_vert.glsl SRC)
|
||||
|
|
|
@ -243,6 +243,7 @@ extern char datatoc_gpu_shader_point_varying_color_frag_glsl[];
|
|||
|
||||
extern char datatoc_object_mball_handles_vert_glsl[];
|
||||
extern char datatoc_object_empty_axes_vert_glsl[];
|
||||
extern char datatoc_object_color_axes_vert_glsl[];
|
||||
|
||||
typedef struct COMMON_Shaders {
|
||||
struct GPUShader *shape_outline;
|
||||
|
@ -262,6 +263,7 @@ typedef struct COMMON_Shaders {
|
|||
struct GPUShader *volume_velocity_needle_sh;
|
||||
struct GPUShader *volume_velocity_sh;
|
||||
struct GPUShader *empty_axes_sh;
|
||||
struct GPUShader *color_axes_sh;
|
||||
|
||||
struct GPUShader *mball_handles;
|
||||
} COMMON_Shaders;
|
||||
|
@ -549,6 +551,37 @@ struct DRWCallBuffer *buffer_instance_empty_axes(DRWPass *pass,
|
|||
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_sized, geom);
|
||||
}
|
||||
|
||||
struct DRWCallBuffer *buffer_instance_color_axes(DRWPass *pass,
|
||||
struct GPUBatch *geom,
|
||||
DRWShadingGroup **r_grp,
|
||||
eGPUShaderConfig sh_cfg)
|
||||
{
|
||||
COMMON_Shaders *sh_data = &g_shaders[sh_cfg];
|
||||
if (sh_data->color_axes_sh == NULL) {
|
||||
const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[sh_cfg];
|
||||
sh_data->color_axes_sh = GPU_shader_create_from_arrays({
|
||||
.vert = (const char *[]){sh_cfg_data->lib, datatoc_object_color_axes_vert_glsl, NULL},
|
||||
.frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL},
|
||||
.defs = (const char *[]){sh_cfg_data->def, NULL},
|
||||
});
|
||||
}
|
||||
|
||||
DRW_shgroup_instance_format(g_formats.instance_sized,
|
||||
{
|
||||
{"color", DRW_ATTR_FLOAT, 3},
|
||||
{"size", DRW_ATTR_FLOAT, 1},
|
||||
{"InstanceModelMatrix", DRW_ATTR_FLOAT, 16},
|
||||
});
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(sh_data->color_axes_sh, pass);
|
||||
DRW_shgroup_uniform_vec3(grp, "screenVecs[0]", DRW_viewport_screenvecs_get(), 2);
|
||||
if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
|
||||
DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
|
||||
}
|
||||
*r_grp = grp;
|
||||
return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_sized, geom);
|
||||
}
|
||||
|
||||
struct DRWCallBuffer *buffer_instance_outline(DRWPass *pass,
|
||||
struct GPUBatch *geom,
|
||||
const int *baseid,
|
||||
|
|
|
@ -160,6 +160,10 @@ struct DRWCallBuffer *buffer_instance_screen_aligned(struct DRWPass *pass,
|
|||
struct DRWCallBuffer *buffer_instance_empty_axes(struct DRWPass *pass,
|
||||
struct GPUBatch *geom,
|
||||
eGPUShaderConfig sh_cfg);
|
||||
struct DRWCallBuffer *buffer_instance_color_axes(struct DRWPass *pass,
|
||||
struct GPUBatch *geom,
|
||||
struct DRWShadingGroup **r_grp,
|
||||
eGPUShaderConfig sh_cfg);
|
||||
struct DRWCallBuffer *buffer_instance_scaled(struct DRWPass *pass,
|
||||
struct GPUBatch *geom,
|
||||
eGPUShaderConfig sh_cfg);
|
||||
|
|
|
@ -234,6 +234,7 @@ typedef struct OBJECT_ShadingGroupList {
|
|||
/* Helpers */
|
||||
DRWCallBuffer *relationship_lines;
|
||||
DRWCallBuffer *constraint_lines;
|
||||
DRWCallBuffer *origin_xform;
|
||||
|
||||
/* Camera */
|
||||
DRWCallBuffer *camera;
|
||||
|
@ -1735,6 +1736,16 @@ static void OBJECT_cache_init(void *vedata)
|
|||
sgl->constraint_lines = buffer_dynlines_dashed_uniform_color(
|
||||
sgl->non_meshes, gb->colorGridAxisZ, draw_ctx->sh_cfg);
|
||||
|
||||
{
|
||||
DRWShadingGroup *grp_axes;
|
||||
sgl->origin_xform = buffer_instance_color_axes(
|
||||
sgl->non_meshes, DRW_cache_bone_arrows_get(), &grp_axes, draw_ctx->sh_cfg);
|
||||
|
||||
DRW_shgroup_state_disable(grp_axes, DRW_STATE_DEPTH_LESS_EQUAL);
|
||||
DRW_shgroup_state_enable(grp_axes, DRW_STATE_DEPTH_ALWAYS);
|
||||
DRW_shgroup_state_enable(grp_axes, DRW_STATE_WIRE_SMOOTH);
|
||||
}
|
||||
|
||||
/* Force Field Curve Guide End (here because of stipple) */
|
||||
/* TODO port to shader stipple */
|
||||
geom = DRW_cache_screenspace_circle_get();
|
||||
|
@ -3675,6 +3686,15 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
|
|||
DRW_shgroup_bounds(sgl, ob, theme_id);
|
||||
}
|
||||
|
||||
/* Helpers for when we're transforming origins. */
|
||||
if (scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) {
|
||||
if (ob->base_flag & BASE_SELECTED) {
|
||||
const float color[4] = {0.75, 0.75, 0.75, 0.5};
|
||||
float axes_size = 1.0f;
|
||||
DRW_buffer_add_entry(sgl->origin_xform, color, &axes_size, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
/* don't show object extras in set's */
|
||||
if ((ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) == 0) {
|
||||
if ((draw_ctx->object_mode & (OB_MODE_ALL_PAINT | OB_MODE_ALL_PAINT_GPENCIL)) == 0) {
|
||||
|
|
|
@ -7693,7 +7693,6 @@ int special_transform_moving(TransInfo *t)
|
|||
struct XFormObjectData_Extra {
|
||||
Object *ob;
|
||||
float obmat_orig[4][4];
|
||||
bool ob_dtx_axis_orig;
|
||||
struct XFormObjectData *xod;
|
||||
};
|
||||
|
||||
|
@ -7710,10 +7709,6 @@ static void trans_obdata_in_obmode_ensure_object(TransInfo *t, Object *ob)
|
|||
xf->ob = ob;
|
||||
/* Result may be NULL, that's OK. */
|
||||
xf->xod = ED_object_data_xform_create(ob->data);
|
||||
if (xf->xod) {
|
||||
xf->ob_dtx_axis_orig = ob->dtx & OB_AXIS;
|
||||
ob->dtx |= OB_AXIS;
|
||||
}
|
||||
*xf_p = xf;
|
||||
}
|
||||
}
|
||||
|
@ -7747,10 +7742,6 @@ static void trans_obdata_in_obmode_free_elem(void *xf_p)
|
|||
{
|
||||
struct XFormObjectData_Extra *xf = xf_p;
|
||||
if (xf->xod) {
|
||||
if (!xf->ob_dtx_axis_orig) {
|
||||
xf->ob->dtx &= ~OB_AXIS;
|
||||
DEG_id_tag_update(&xf->ob->id, ID_RECALC_COPY_ON_WRITE);
|
||||
}
|
||||
ED_object_data_xform_destroy(xf->xod);
|
||||
}
|
||||
MEM_freeN(xf);
|
||||
|
|
|
@ -2936,12 +2936,12 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
|||
RNA_def_property_boolean_sdna(prop, NULL, "transform_flag", SCE_XFORM_AXIS_ALIGN);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Only Locations", "Manipulate origins (object, pose and weight paint mode only)");
|
||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_transform_data_origin", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "transform_flag", SCE_XFORM_DATA_ORIGIN);
|
||||
RNA_def_property_ui_text(prop, "Data Origins", "Manipulate object data");
|
||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_mesh_automerge", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "automerge", 0);
|
||||
|
|
Loading…
Reference in New Issue