Orientation for 3D cursor
Currently set when setting the cursor location, optionally used as an orientation type. Intended for use by tools too. See: D3208
This commit is contained in:
parent
53a56b7b6c
commit
a48186c5d7
|
@ -7355,7 +7355,8 @@ void blo_lib_link_restore(Main *newmain, wmWindowManager *curwm, Scene *curscene
|
|||
BKE_workspace_active_set(win->workspace_hook, workspace);
|
||||
|
||||
/* keep cursor location through undo */
|
||||
copy_v3_v3(win->scene->cursor, oldscene->cursor);
|
||||
copy_v3_v3(win->scene->cursor.location, oldscene->cursor.location);
|
||||
copy_qt_qt(win->scene->cursor.rotation, oldscene->cursor.rotation);
|
||||
lib_link_workspace_scene_data_restore(win, win->scene);
|
||||
|
||||
BLI_assert(win->screen == NULL);
|
||||
|
@ -10039,7 +10040,7 @@ static void give_base_to_groups(
|
|||
/* Assign the group. */
|
||||
ob->dup_group = group;
|
||||
ob->transflag |= OB_DUPLIGROUP;
|
||||
copy_v3_v3(ob->loc, scene->cursor);
|
||||
copy_v3_v3(ob->loc, scene->cursor.location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1099,5 +1099,21 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!DNA_struct_find(fd->filesdna, "View3DCursor")) {
|
||||
for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
|
||||
unit_qt(scene->cursor.rotation);
|
||||
}
|
||||
for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
|
||||
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = (View3D *)sl;
|
||||
unit_qt(v3d->cursor.rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
static struct DRWShapeCache {
|
||||
Gwn_Batch *drw_single_vertice;
|
||||
Gwn_Batch *drw_cursor;
|
||||
Gwn_Batch *drw_cursor_only_circle;
|
||||
Gwn_Batch *drw_fullscreen_quad;
|
||||
Gwn_Batch *drw_quad;
|
||||
Gwn_Batch *drw_sphere;
|
||||
|
@ -3021,9 +3022,11 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type)
|
|||
}
|
||||
|
||||
/* 3D cursor */
|
||||
Gwn_Batch *DRW_cache_cursor_get(void)
|
||||
Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines)
|
||||
{
|
||||
if (!SHC.drw_cursor) {
|
||||
Gwn_Batch **drw_cursor = crosshair_lines ? &SHC.drw_cursor : &SHC.drw_cursor_only_circle;
|
||||
|
||||
if (*drw_cursor == NULL) {
|
||||
const float f5 = 0.25f;
|
||||
const float f10 = 0.5f;
|
||||
const float f20 = 1.0f;
|
||||
|
@ -3034,8 +3037,6 @@ Gwn_Batch *DRW_cache_cursor_get(void)
|
|||
|
||||
unsigned char red[3] = {255, 0, 0};
|
||||
unsigned char white[3] = {255, 255, 255};
|
||||
unsigned char crosshair_color[3];
|
||||
UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color);
|
||||
|
||||
static Gwn_VertFormat format = { 0 };
|
||||
static struct { uint pos, color; } attr_id;
|
||||
|
@ -3065,45 +3066,51 @@ Gwn_Batch *DRW_cache_cursor_get(void)
|
|||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
}
|
||||
GWN_indexbuf_add_generic_vert(&elb, 0);
|
||||
GWN_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
if (crosshair_lines) {
|
||||
unsigned char crosshair_color[3];
|
||||
UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color);
|
||||
|
||||
GWN_indexbuf_add_primitive_restart(&elb);
|
||||
GWN_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
|
||||
GWN_indexbuf_add_primitive_restart(&elb);
|
||||
GWN_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
|
||||
GWN_indexbuf_add_primitive_restart(&elb);
|
||||
GWN_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
|
||||
GWN_indexbuf_add_primitive_restart(&elb);
|
||||
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20});
|
||||
GWN_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
|
||||
GWN_indexbuf_add_generic_vert(&elb, v++);
|
||||
}
|
||||
|
||||
Gwn_IndexBuf *ibo = GWN_indexbuf_build(&elb);
|
||||
|
||||
SHC.drw_cursor = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, ibo, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
|
||||
*drw_cursor = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, ibo, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX);
|
||||
}
|
||||
return SHC.drw_cursor;
|
||||
return *drw_cursor;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ struct ModifierData;
|
|||
void DRW_shape_cache_free(void);
|
||||
|
||||
/* 3D cursor */
|
||||
struct Gwn_Batch *DRW_cache_cursor_get(void);
|
||||
struct Gwn_Batch *DRW_cache_cursor_get(bool crosshair_lines);
|
||||
|
||||
/* Common Shapes */
|
||||
struct Gwn_Batch *DRW_cache_fullscreen_quad_get(void);
|
||||
|
|
|
@ -659,21 +659,66 @@ void DRW_draw_cursor(void)
|
|||
|
||||
if (is_cursor_visible(draw_ctx, scene, view_layer)) {
|
||||
int co[2];
|
||||
if (ED_view3d_project_int_global(ar, ED_view3d_cursor3d_get(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
|
||||
|
||||
ED_region_pixelspace(ar);
|
||||
gpuTranslate2f(co[0] + 0.5f, co[1] + 0.5f);
|
||||
gpuScale2f(U.widget_unit, U.widget_unit);
|
||||
|
||||
Gwn_Batch *cursor_batch = DRW_cache_cursor_get();
|
||||
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR);
|
||||
GWN_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader));
|
||||
const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
if (ED_view3d_project_int_global(
|
||||
ar, cursor->location, co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)
|
||||
{
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
/* Draw nice Anti Aliased cursor. */
|
||||
glLineWidth(1.0f);
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
float eps = 1e-5f;
|
||||
rv3d->viewquat[0] = -rv3d->viewquat[0];
|
||||
const bool is_aligned = compare_v4v4(cursor->rotation, rv3d->viewquat, eps);
|
||||
rv3d->viewquat[0] = -rv3d->viewquat[0];
|
||||
|
||||
/* Draw lines */
|
||||
if (is_aligned == false) {
|
||||
uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformThemeColor3(TH_VIEW_OVERLAY);
|
||||
immBegin(GWN_PRIM_LINES, 12);
|
||||
|
||||
const float scale = ED_view3d_pixel_size(rv3d, cursor->location) * U.dpi_fac * 20;
|
||||
|
||||
#define CURSOR_VERT(axis_vec, axis, fac) \
|
||||
immVertex3f( \
|
||||
pos, \
|
||||
cursor->location[0] + axis_vec[0] * (fac), \
|
||||
cursor->location[1] + axis_vec[1] * (fac), \
|
||||
cursor->location[2] + axis_vec[2] * (fac))
|
||||
|
||||
#define CURSOR_EDGE(axis_vec, axis, sign) { \
|
||||
CURSOR_VERT(axis_vec, axis, sign 1.0f); \
|
||||
CURSOR_VERT(axis_vec, axis, sign 0.3f); \
|
||||
}
|
||||
|
||||
for (int axis = 0; axis < 3; axis++) {
|
||||
float axis_vec[3] = {0};
|
||||
axis_vec[axis] = scale;
|
||||
mul_qt_v3(cursor->rotation, axis_vec);
|
||||
CURSOR_EDGE(axis_vec, axis, +);
|
||||
CURSOR_EDGE(axis_vec, axis, -);
|
||||
}
|
||||
|
||||
#undef CURSOR_VERT
|
||||
#undef CURSOR_EDGE
|
||||
|
||||
immEnd();
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
ED_region_pixelspace(ar);
|
||||
gpuTranslate2f(co[0] + 0.5f, co[1] + 0.5f);
|
||||
gpuScale2f(U.widget_unit, U.widget_unit);
|
||||
|
||||
Gwn_Batch *cursor_batch = DRW_cache_cursor_get(is_aligned);
|
||||
GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR);
|
||||
GWN_batch_program_set(cursor_batch, GPU_shader_get_program(shader), GPU_shader_get_interface(shader));
|
||||
|
||||
GWN_batch_draw(cursor_batch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,6 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
bArmature *arm;
|
||||
EditBone *ebone, *newbone, *flipbone;
|
||||
float mat[3][3], imat[3][3];
|
||||
const float *curs;
|
||||
int a, to_root = 0;
|
||||
Object *obedit;
|
||||
Scene *scene;
|
||||
|
@ -188,8 +187,8 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
newbone->flag |= BONE_CONNECTED;
|
||||
}
|
||||
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d);
|
||||
copy_v3_v3(newbone->tail, curs);
|
||||
const View3DCursor *curs = ED_view3d_cursor3d_get(scene, v3d);
|
||||
copy_v3_v3(newbone->tail, curs->location);
|
||||
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
|
||||
|
||||
if (a == 1)
|
||||
|
@ -221,26 +220,26 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv
|
|||
Scene *scene;
|
||||
ARegion *ar;
|
||||
View3D *v3d;
|
||||
float *fp, tvec[3], oldcurs[3], mval_f[2];
|
||||
float tvec[3], oldcurs[3], mval_f[2];
|
||||
int retv;
|
||||
|
||||
scene = CTX_data_scene(C);
|
||||
ar = CTX_wm_region(C);
|
||||
v3d = CTX_wm_view3d(C);
|
||||
|
||||
fp = ED_view3d_cursor3d_get(scene, v3d);
|
||||
View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
|
||||
copy_v3_v3(oldcurs, fp);
|
||||
copy_v3_v3(oldcurs, cursor->location);
|
||||
|
||||
VECCOPY2D(mval_f, event->mval);
|
||||
ED_view3d_win_to_3d(v3d, ar, fp, mval_f, tvec);
|
||||
copy_v3_v3(fp, tvec);
|
||||
ED_view3d_win_to_3d(v3d, ar, cursor->location, mval_f, tvec);
|
||||
copy_v3_v3(cursor->location, tvec);
|
||||
|
||||
/* extrude to the where new cursor is and store the operation result */
|
||||
retv = armature_click_extrude_exec(C, op);
|
||||
|
||||
/* restore previous 3d cursor position */
|
||||
copy_v3_v3(fp, oldcurs);
|
||||
copy_v3_v3(cursor->location, oldcurs);
|
||||
|
||||
return retv;
|
||||
}
|
||||
|
@ -1013,7 +1012,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
|
|||
|
||||
RNA_string_get(op->ptr, "name", name);
|
||||
|
||||
copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C)));
|
||||
copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C))->location);
|
||||
|
||||
/* Get inverse point for head and orientation for tail */
|
||||
invert_m4_m4(obedit->imat, obedit->obmat);
|
||||
|
|
|
@ -318,10 +318,10 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
|
|||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
|
||||
float cursor_local[3];
|
||||
const float *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
copy_v3_v3(cursor_local, cursor);
|
||||
copy_v3_v3(cursor_local, cursor->location);
|
||||
mul_m4_v3(ob->imat, cursor_local);
|
||||
|
||||
|
||||
|
@ -705,7 +705,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* Get points - cursor (tail) */
|
||||
invert_m4_m4(obedit->imat, obedit->obmat);
|
||||
mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d));
|
||||
mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
|
||||
/* Create a bone */
|
||||
newbone = add_points_bone(obedit, ebp->vec, curs);
|
||||
|
@ -743,7 +743,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* get cursor location */
|
||||
invert_m4_m4(obedit->imat, obedit->obmat);
|
||||
mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d));
|
||||
mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
|
||||
/* get distances */
|
||||
dist_sq_a = len_squared_v3v3(ebp_a->vec, curs);
|
||||
|
|
|
@ -4528,7 +4528,7 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
|
|||
if (rv3d)
|
||||
copy_v3_v3(axis, rv3d->viewinv[2]);
|
||||
|
||||
RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d));
|
||||
RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
RNA_float_set_array(op->ptr, "axis", axis);
|
||||
|
||||
return spin_exec(C, op);
|
||||
|
@ -5004,7 +5004,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
mul_v3_m4v3(location, vc.obedit->obmat, bp->vec);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(location, ED_view3d_cursor3d_get(vc.scene, vc.v3d));
|
||||
copy_v3_v3(location, ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location);
|
||||
}
|
||||
|
||||
ED_view3d_win_to_3d_int(vc.v3d, vc.ar, location, event->mval, location);
|
||||
|
|
|
@ -1117,7 +1117,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
|
||||
/* use view plane (when set or as fallback when surface can't be found) */
|
||||
if (cdd->project.use_depth == false) {
|
||||
plane_co = ED_view3d_cursor3d_get(cdd->vc.scene, v3d);
|
||||
plane_co = ED_view3d_cursor3d_get(cdd->vc.scene, v3d)->location;
|
||||
plane_no = rv3d->viewinv[2];
|
||||
cdd->project.use_plane = true;
|
||||
}
|
||||
|
|
|
@ -404,7 +404,7 @@ static void gp_brush_grab_calc_dvec(tGP_BrushEditData *gso)
|
|||
if (gso->sa->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = gso->sa->spacedata.first;
|
||||
RegionView3D *rv3d = gso->ar->regiondata;
|
||||
float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d);
|
||||
float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location;
|
||||
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
|
||||
|
||||
float mval_f[2];
|
||||
|
@ -504,7 +504,7 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso)
|
|||
*/
|
||||
View3D *v3d = gso->sa->spacedata.first;
|
||||
RegionView3D *rv3d = gso->ar->regiondata;
|
||||
float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d);
|
||||
float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location;
|
||||
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
|
||||
|
||||
float mval_f[2] = {UNPACK2(gso->mval)};
|
||||
|
|
|
@ -176,7 +176,7 @@ static void gp_strokepoint_convertcoords(
|
|||
copy_v3_v3(p3d, &pt->x);
|
||||
}
|
||||
else {
|
||||
const float *fp = ED_view3d_cursor3d_get(scene, v3d);
|
||||
const float *fp = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
float mvalf[2];
|
||||
|
||||
/* get screen coordinate */
|
||||
|
|
|
@ -1464,7 +1464,7 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
|
|||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
|
||||
const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d);
|
||||
const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
|
||||
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
||||
/* only editable and visible layers are considered */
|
||||
|
@ -1551,7 +1551,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
|
|||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
float *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
float centroid[3] = {0.0f};
|
||||
float min[3], max[3];
|
||||
size_t count = 0;
|
||||
|
|
|
@ -236,7 +236,7 @@ static bool gpencil_project_check(tGPsdata *p)
|
|||
static void gp_get_3d_reference(tGPsdata *p, float vec[3])
|
||||
{
|
||||
View3D *v3d = p->sa->spacedata.first;
|
||||
const float *fp = ED_view3d_cursor3d_get(p->scene, v3d);
|
||||
const float *fp = ED_view3d_cursor3d_get(p->scene, v3d)->location;
|
||||
|
||||
/* the reference point used depends on the owner... */
|
||||
#if 0 /* XXX: disabled for now, since we can't draw relative to the owner yet */
|
||||
|
|
|
@ -745,7 +745,7 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen
|
|||
{
|
||||
View3D *v3d = gsc->sa->spacedata.first;
|
||||
RegionView3D *rv3d = gsc->ar->regiondata;
|
||||
float *rvec = ED_view3d_cursor3d_get(scene, v3d);
|
||||
float *rvec = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
float ref[3] = {rvec[0], rvec[1], rvec[2]};
|
||||
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ typedef struct ViewDepths {
|
|||
bool damaged;
|
||||
} ViewDepths;
|
||||
|
||||
float *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d);
|
||||
struct View3DCursor *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d);
|
||||
void ED_view3d_cursor3d_position(struct bContext *C, float fp[3], const int mval[2]);
|
||||
void ED_view3d_cursor3d_update(struct bContext *C, const int mval[2]);
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op)
|
|||
RNA_property_float_get_array(op->ptr, prop_plane_co, plane_co);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(plane_co, ED_view3d_cursor3d_get(scene, v3d));
|
||||
copy_v3_v3(plane_co, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
RNA_property_float_set_array(op->ptr, prop_plane_co, plane_co);
|
||||
}
|
||||
|
||||
|
|
|
@ -973,7 +973,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
|
|||
BM_ELEM_SELECT, ofs);
|
||||
}
|
||||
else {
|
||||
const float *cursor = ED_view3d_cursor3d_get(vc.scene, vc.v3d);
|
||||
const float *cursor = ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location;
|
||||
BMOperator bmop;
|
||||
BMOIter oiter;
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
|
|||
PropertyRNA *prop;
|
||||
prop = RNA_struct_find_property(op->ptr, "center");
|
||||
if (!RNA_property_is_set(op->ptr, prop)) {
|
||||
RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d));
|
||||
RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
}
|
||||
if (rv3d) {
|
||||
prop = RNA_struct_find_property(op->ptr, "axis");
|
||||
|
|
|
@ -487,7 +487,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
|
|||
PropertyRNA *prop;
|
||||
prop = RNA_struct_find_property(op->ptr, "center");
|
||||
if (!RNA_property_is_set(op->ptr, prop)) {
|
||||
RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d));
|
||||
RNA_property_float_set_array(op->ptr, prop, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
}
|
||||
if (rv3d) {
|
||||
prop = RNA_struct_find_property(op->ptr, "axis");
|
||||
|
|
|
@ -89,7 +89,7 @@ static int edbm_polybuild_face_at_cursor_invoke(
|
|||
|
||||
if (ele_act == NULL || ele_act->head.htype == BM_FACE) {
|
||||
/* Just add vert */
|
||||
copy_v3_v3(center, ED_view3d_cursor3d_get(vc.scene, vc.v3d));
|
||||
copy_v3_v3(center, ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location);
|
||||
mul_v3_m4v3(center, vc.obedit->obmat, center);
|
||||
ED_view3d_win_to_3d_int(vc.v3d, vc.ar, center, event->mval, center);
|
||||
mul_m4_v3(vc.obedit->imat, center);
|
||||
|
|
|
@ -2608,7 +2608,7 @@ static bool merge_target(
|
|||
const float *vco = NULL;
|
||||
|
||||
if (use_cursor) {
|
||||
vco = ED_view3d_cursor3d_get(scene, v3d);
|
||||
vco = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
copy_v3_v3(co, vco);
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
mul_m4_v3(ob->imat, co);
|
||||
|
@ -5469,9 +5469,9 @@ static void sort_bmelem_flag(
|
|||
float fact = reverse ? -1.0 : 1.0;
|
||||
|
||||
if (v3d && v3d->localvd)
|
||||
copy_v3_v3(cur, v3d->cursor);
|
||||
copy_v3_v3(cur, v3d->cursor.location);
|
||||
else
|
||||
copy_v3_v3(cur, scene->cursor);
|
||||
copy_v3_v3(cur, scene->cursor.location);
|
||||
invert_m4_m4(mat, ob->obmat);
|
||||
mul_m4_v3(mat, cur);
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ void ED_object_location_from_view(bContext *C, float loc[3])
|
|||
Scene *scene = CTX_data_scene(C);
|
||||
const float *cursor;
|
||||
|
||||
cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
|
||||
copy_v3_v3(loc, cursor);
|
||||
}
|
||||
|
|
|
@ -781,7 +781,7 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op)
|
|||
copy_m3_m4(bmat, ob->obmat);
|
||||
invert_m3_m3(imat, bmat);
|
||||
|
||||
sub_v3_v3v3(hmd->cent, scene->cursor, ob->obmat[3]);
|
||||
sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->obmat[3]);
|
||||
mul_m3_v3(imat, hmd->cent);
|
||||
|
||||
DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
|
|
|
@ -787,7 +787,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
|
|||
else {
|
||||
/* get the view settings if 'around' isn't set and the view is available */
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
copy_v3_v3(cursor, ED_view3d_cursor3d_get(scene, v3d));
|
||||
copy_v3_v3(cursor, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
if (v3d && !RNA_struct_property_is_set(op->ptr, "center"))
|
||||
around = v3d->around;
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ static int object_warp_verts_exec(bContext *C, wmOperator *op)
|
|||
View3D *v3d = CTX_wm_view3d(C);
|
||||
const float *cursor;
|
||||
|
||||
cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
copy_v3_v3(center, cursor);
|
||||
|
||||
RNA_property_float_set_array(op->ptr, prop_center, center);
|
||||
|
|
|
@ -3905,7 +3905,7 @@ static void paint_proj_begin_clone(ProjPaintState *ps, const float mouse[2])
|
|||
/* setup clone offset */
|
||||
if (ps->tool == PAINT_TOOL_CLONE) {
|
||||
float projCo[4];
|
||||
copy_v3_v3(projCo, ED_view3d_cursor3d_get(ps->scene, ps->v3d));
|
||||
copy_v3_v3(projCo, ED_view3d_cursor3d_get(ps->scene, ps->v3d)->location);
|
||||
mul_m4_v3(ps->obmat_imat, projCo);
|
||||
|
||||
projCo[3] = 1.0f;
|
||||
|
@ -5015,7 +5015,7 @@ void paint_proj_stroke(
|
|||
struct Depsgraph *graph = CTX_data_depsgraph(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
float *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
int mval_i[2] = {(int)pos[0], (int)pos[1]};
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
|
|
@ -550,7 +550,7 @@ static void group_instance_cb(
|
|||
{
|
||||
Group *group = (Group *)tselem->id;
|
||||
|
||||
Object *ob = ED_object_add_type(C, OB_EMPTY, group->id.name + 2, scene->cursor, NULL, false, scene->layact);
|
||||
Object *ob = ED_object_add_type(C, OB_EMPTY, group->id.name + 2, scene->cursor.location, NULL, false, scene->layact);
|
||||
ob->dup_group = group;
|
||||
ob->transflag |= OB_DUPLIGROUP;
|
||||
id_lib_extern(&group->id);
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
#include "ED_mesh.h"
|
||||
#include "ED_gpencil.h"
|
||||
#include "ED_view3d.h"
|
||||
#include "ED_transform_snap_object_context.h"
|
||||
|
||||
#include "UI_resources.h"
|
||||
|
||||
|
@ -2706,7 +2707,6 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
|
|||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
Base *base;
|
||||
float *curs;
|
||||
const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
|
||||
const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) ||
|
||||
/* any one of the regions may be locked */
|
||||
|
@ -2719,10 +2719,11 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
|
|||
|
||||
if (center) {
|
||||
/* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d);
|
||||
View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
zero_v3(min);
|
||||
zero_v3(max);
|
||||
zero_v3(curs);
|
||||
zero_v3(cursor->location);
|
||||
unit_qt(cursor->rotation);
|
||||
}
|
||||
else {
|
||||
INIT_MINMAX(min, max);
|
||||
|
@ -3038,7 +3039,7 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* non camera center */
|
||||
float new_ofs[3];
|
||||
negate_v3_v3(new_ofs, ED_view3d_cursor3d_get(scene, v3d));
|
||||
negate_v3_v3(new_ofs, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
ED_view3d_smooth_view(
|
||||
C, v3d, ar, smooth_viewtx,
|
||||
&(const V3D_SmoothParams) {.ofs = new_ofs});
|
||||
|
@ -4572,25 +4573,75 @@ void ED_view3d_cursor3d_update(bContext *C, const int mval[2])
|
|||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
float *fp_curr = ED_view3d_cursor3d_get(scene, v3d);
|
||||
float fp_prev[3];
|
||||
View3DCursor *cursor_curr = ED_view3d_cursor3d_get(scene, v3d);
|
||||
View3DCursor cursor_prev = *cursor_curr;
|
||||
|
||||
copy_v3_v3(fp_prev, fp_curr);
|
||||
ED_view3d_cursor3d_position(C, cursor_curr->location, mval);
|
||||
copy_qt_qt(cursor_curr->rotation, rv3d->viewquat);
|
||||
cursor_curr->rotation[0] *= -1.0f;
|
||||
|
||||
ED_view3d_cursor3d_position(C, fp_curr, mval);
|
||||
{
|
||||
struct Main *bmain = CTX_data_main(C);
|
||||
const float mval_fl[2] = {UNPACK2(mval)};
|
||||
float ray_no[3];
|
||||
|
||||
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
|
||||
bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d);
|
||||
|
||||
float obmat[4][4];
|
||||
Object *ob_dummy = NULL;
|
||||
float dist_px = 0;
|
||||
if (ED_transform_snap_object_project_view3d_ex(
|
||||
snap_context,
|
||||
SCE_SNAP_MODE_FACE,
|
||||
&(const struct SnapObjectParams){
|
||||
.snap_select = SNAP_ALL,
|
||||
.use_object_edit_cage = false,
|
||||
},
|
||||
mval_fl, &dist_px, NULL,
|
||||
cursor_curr->location, ray_no, NULL,
|
||||
&ob_dummy, obmat))
|
||||
{
|
||||
float tquat[4];
|
||||
/* Math normal (Z). */
|
||||
{
|
||||
float z_src[3] = {0, 0, 1};
|
||||
mul_qt_v3(cursor_curr->rotation, z_src);
|
||||
rotation_between_vecs_to_quat(tquat, z_src, ray_no);
|
||||
mul_qt_qtqt(cursor_curr->rotation, tquat, cursor_curr->rotation);
|
||||
}
|
||||
|
||||
/* Match object matrix (X). */
|
||||
{
|
||||
const float ortho_axis_dot[3] = {
|
||||
dot_v3v3(ray_no, obmat[0]),
|
||||
dot_v3v3(ray_no, obmat[1]),
|
||||
dot_v3v3(ray_no, obmat[2]),
|
||||
};
|
||||
const int ortho_axis = axis_dominant_v3_ortho_single(ortho_axis_dot);
|
||||
float x_src[3] = {1, 0, 0};
|
||||
float x_dst[3];
|
||||
mul_qt_v3(cursor_curr->rotation, x_src);
|
||||
project_plane_v3_v3v3(x_dst, obmat[ortho_axis], ray_no);
|
||||
normalize_v3(x_dst);
|
||||
rotation_between_vecs_to_quat(tquat, x_src, x_dst);
|
||||
mul_qt_qtqt(cursor_curr->rotation, tquat, cursor_curr->rotation);
|
||||
}
|
||||
}
|
||||
ED_transform_snap_object_context_destroy(snap_context);
|
||||
}
|
||||
|
||||
/* offset the cursor lock to avoid jumping to new offset */
|
||||
if (v3d->ob_centre_cursor) {
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
if (U.uiflag & USER_LOCK_CURSOR_ADJUST) {
|
||||
|
||||
float co_curr[2], co_prev[2];
|
||||
|
||||
if ((ED_view3d_project_float_global(ar, fp_prev, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
|
||||
(ED_view3d_project_float_global(ar, fp_curr, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
|
||||
if ((ED_view3d_project_float_global(ar, cursor_prev.location, co_prev, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) &&
|
||||
(ED_view3d_project_float_global(ar, cursor_curr->location, co_curr, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK))
|
||||
{
|
||||
rv3d->ofs_lock[0] += (co_curr[0] - co_prev[0]) / (ar->winx * 0.5f);
|
||||
rv3d->ofs_lock[1] += (co_curr[1] - co_prev[1]) / (ar->winy * 0.5f);
|
||||
|
|
|
@ -407,7 +407,7 @@ static int snap_selected_to_cursor_exec(bContext *C, wmOperator *op)
|
|||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
const float *snap_target_global = ED_view3d_cursor3d_get(scene, v3d);
|
||||
const float *snap_target_global = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
|
||||
return snap_selected_to_location(C, snap_target_global, use_offset);
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
float gridf, *curs;
|
||||
|
||||
gridf = rv3d->gridview;
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d);
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
|
||||
curs[0] = gridf * floorf(0.5f + curs[0] / gridf);
|
||||
curs[1] = gridf * floorf(0.5f + curs[1] / gridf);
|
||||
|
@ -651,7 +651,7 @@ static int snap_curs_to_sel_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
View3D *v3d = CTX_wm_view3d(C);
|
||||
float *curs;
|
||||
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d);
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
|
||||
if (snap_curs_to_sel_ex(C, curs)) {
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
|
@ -725,7 +725,7 @@ static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
View3D *v3d = CTX_wm_view3d(C);
|
||||
float *curs;
|
||||
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d);
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
|
||||
if (snap_calc_active_center(C, false, curs)) {
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
|
@ -758,7 +758,7 @@ static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
float *curs;
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d);
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
|
||||
zero_v3(curs);
|
||||
|
||||
|
|
|
@ -71,10 +71,14 @@
|
|||
*
|
||||
* \{ */
|
||||
|
||||
float *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d)
|
||||
View3DCursor *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d)
|
||||
{
|
||||
if (v3d && v3d->localvd) return v3d->cursor;
|
||||
else return scene->cursor;
|
||||
if (v3d && v3d->localvd) {
|
||||
return &v3d->cursor;
|
||||
}
|
||||
else {
|
||||
return &scene->cursor;
|
||||
}
|
||||
}
|
||||
|
||||
Camera *ED_view3d_camera_data_get(View3D *v3d, RegionView3D *rv3d)
|
||||
|
|
|
@ -791,7 +791,7 @@ void view3d_viewmatrix_set(
|
|||
}
|
||||
else if (v3d->ob_centre_cursor) {
|
||||
float vec[3];
|
||||
copy_v3_v3(vec, ED_view3d_cursor3d_get(scene, (View3D *)v3d));
|
||||
copy_v3_v3(vec, ED_view3d_cursor3d_get(scene, (View3D *)v3d)->location);
|
||||
translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]);
|
||||
use_lock_ofs = true;
|
||||
}
|
||||
|
|
|
@ -2953,7 +2953,7 @@ static void initBend(TransInfo *t)
|
|||
|
||||
data = MEM_callocN(sizeof(*data), __func__);
|
||||
|
||||
curs = ED_view3d_cursor3d_get(t->scene, t->view);
|
||||
curs = ED_view3d_cursor3d_get(t->scene, t->view)->location;
|
||||
copy_v3_v3(data->warp_sta, curs);
|
||||
ED_view3d_win_to_3d(t->sa->spacedata.first, t->ar, curs, mval_fl, data->warp_end);
|
||||
|
||||
|
|
|
@ -689,6 +689,10 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
|
|||
BLI_snprintf(text, sizeof(text), ftext, IFACE_("view"));
|
||||
setConstraint(t, t->spacemtx, mode, text);
|
||||
break;
|
||||
case V3D_MANIP_CURSOR:
|
||||
BLI_snprintf(text, sizeof(text), ftext, IFACE_("cursor"));
|
||||
setConstraint(t, t->spacemtx, mode, text);
|
||||
break;
|
||||
case V3D_MANIP_GIMBAL:
|
||||
BLI_snprintf(text, sizeof(text), ftext, IFACE_("gimbal"));
|
||||
setConstraint(t, t->spacemtx, mode, text);
|
||||
|
|
|
@ -1791,7 +1791,7 @@ void calculateCenterCursor(TransInfo *t, float r_center[3])
|
|||
{
|
||||
const float *cursor;
|
||||
|
||||
cursor = ED_view3d_cursor3d_get(t->scene, t->view);
|
||||
cursor = ED_view3d_cursor3d_get(t->scene, t->view)->location;
|
||||
copy_v3_v3(r_center, cursor);
|
||||
|
||||
/* If edit or pose mode, move cursor in local space */
|
||||
|
|
|
@ -669,6 +669,13 @@ int ED_transform_calc_manipulator_stats(
|
|||
copy_m4_m3(rv3d->twmat, mat);
|
||||
break;
|
||||
}
|
||||
case V3D_MANIP_CURSOR:
|
||||
{
|
||||
float mat[3][3];
|
||||
quat_to_mat3(mat, ED_view3d_cursor3d_get(scene, v3d)->rotation);
|
||||
copy_m4_m3(rv3d->twmat, mat);
|
||||
break;
|
||||
}
|
||||
case V3D_MANIP_CUSTOM:
|
||||
{
|
||||
TransformOrientation *custom_orientation = BKE_scene_transform_orientation_find(
|
||||
|
@ -1083,7 +1090,7 @@ static void manipulator_prepare_mat(
|
|||
copy_v3_v3(rv3d->twmat[3], tbounds->center);
|
||||
break;
|
||||
case V3D_AROUND_CURSOR:
|
||||
copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d));
|
||||
copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -481,6 +481,13 @@ void initTransformOrientation(bContext *C, TransInfo *t)
|
|||
unit_m3(t->spacemtx);
|
||||
}
|
||||
break;
|
||||
case V3D_MANIP_CURSOR:
|
||||
{
|
||||
const View3DCursor *cursor = ED_view3d_cursor3d_get(t->scene, CTX_wm_view3d(C));
|
||||
BLI_strncpy(t->spacename, IFACE_("cursor"), sizeof(t->spacename));
|
||||
quat_to_mat3(t->spacemtx, cursor->rotation);
|
||||
break;
|
||||
}
|
||||
case V3D_MANIP_CUSTOM:
|
||||
BLI_strncpy(t->spacename, t->custom_orientation->name, sizeof(t->spacename));
|
||||
|
||||
|
|
|
@ -1039,7 +1039,7 @@ static void uv_map_transform_center(
|
|||
case V3D_AROUND_CURSOR: /* cursor center */
|
||||
{
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
mul_v3_m4v3(r_center, ob->imat, ED_view3d_cursor3d_get(scene, v3d));
|
||||
mul_v3_m4v3(r_center, ob->imat, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
break;
|
||||
}
|
||||
case V3D_AROUND_ACTIVE:
|
||||
|
|
|
@ -50,6 +50,7 @@ extern "C" {
|
|||
#include "DNA_layer_types.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
struct CurveMapping;
|
||||
struct Object;
|
||||
|
@ -1368,8 +1369,7 @@ typedef struct Scene {
|
|||
struct Base *basact DNA_DEPRECATED; /* active base */
|
||||
void *_pad1;
|
||||
|
||||
float cursor[3]; /* 3d cursor location */
|
||||
char _pad[4];
|
||||
View3DCursor cursor; /* 3d cursor location */
|
||||
|
||||
unsigned int lay; /* bitflags for layer visibility */
|
||||
int layact; /* active layer */
|
||||
|
|
|
@ -131,6 +131,12 @@ typedef struct RegionView3D {
|
|||
float rot_axis[3];
|
||||
} RegionView3D;
|
||||
|
||||
typedef struct View3DCursor {
|
||||
float location[3];
|
||||
float rotation[4];
|
||||
char _pad[4];
|
||||
} View3DCursor;
|
||||
|
||||
/* 3D Viewport Shading setings */
|
||||
typedef struct View3DShading {
|
||||
short flag;
|
||||
|
@ -197,7 +203,10 @@ typedef struct View3D {
|
|||
float lens, grid;
|
||||
float near, far;
|
||||
float ofs[3] DNA_DEPRECATED; /* XXX deprecated */
|
||||
float cursor[3];
|
||||
|
||||
View3DCursor cursor;
|
||||
|
||||
char _pad[4];
|
||||
|
||||
short matcap_icon; /* icon id */
|
||||
|
||||
|
@ -401,7 +410,8 @@ enum {
|
|||
#define V3D_MANIP_NORMAL 2
|
||||
#define V3D_MANIP_VIEW 3
|
||||
#define V3D_MANIP_GIMBAL 4
|
||||
#define V3D_MANIP_CUSTOM 5
|
||||
#define V3D_MANIP_CURSOR 5
|
||||
#define V3D_MANIP_CUSTOM 1024
|
||||
|
||||
/* View3d->twflag (also) */
|
||||
enum {
|
||||
|
|
|
@ -449,6 +449,7 @@ static const EnumPropertyItem transform_orientation_items[] = {
|
|||
"(bone Y axis for pose mode)"},
|
||||
{V3D_MANIP_GIMBAL, "GIMBAL", 0, "Gimbal", "Align each axis to the Euler rotation axis as used for input"},
|
||||
{V3D_MANIP_VIEW, "VIEW", 0, "View", "Align the transformation axes to the window"},
|
||||
{V3D_MANIP_CURSOR, "CURSOR", 0, "Cursor", "Align the transformation axes to the 3D cursor"},
|
||||
// {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
@ -5700,11 +5701,16 @@ void RNA_def_scene(BlenderRNA *brna)
|
|||
RNA_def_property_update(prop, NC_SCENE | ND_WORLD, "rna_Scene_world_update");
|
||||
|
||||
prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH);
|
||||
RNA_def_property_float_sdna(prop, NULL, "cursor");
|
||||
RNA_def_property_float_sdna(prop, NULL, "cursor.location");
|
||||
RNA_def_property_ui_text(prop, "Cursor Location", "3D cursor location");
|
||||
RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "cursor_rotation", PROP_FLOAT, PROP_QUATERNION);
|
||||
RNA_def_property_float_sdna(prop, NULL, "cursor.rotation");
|
||||
RNA_def_property_ui_text(prop, "Cursor Rotation", "3D cursor rotation in quaternions (keep normalized)");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, "Object");
|
||||
RNA_def_property_ui_text(prop, "Objects", "");
|
||||
|
|
|
@ -443,24 +443,37 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, int valu
|
|||
}
|
||||
}
|
||||
|
||||
static void rna_View3D_CursorLocation_get(PointerRNA *ptr, float *values)
|
||||
|
||||
static View3DCursor *rna_View3D_Cursor_get_from_scene_or_localview(PointerRNA *ptr)
|
||||
{
|
||||
View3D *v3d = (View3D *)(ptr->data);
|
||||
bScreen *screen = ptr->id.data;
|
||||
Scene *scene = ED_screen_scene_find(screen, G.main->wm.first);
|
||||
const float *loc = ED_view3d_cursor3d_get(scene, v3d);
|
||||
|
||||
copy_v3_v3(values, loc);
|
||||
return ED_view3d_cursor3d_get(scene, v3d);
|
||||
}
|
||||
|
||||
static void rna_View3D_CursorLocation_set(PointerRNA *ptr, const float *values)
|
||||
static void rna_View3D_Cursor_location_get(PointerRNA *ptr, float *values)
|
||||
{
|
||||
View3D *v3d = (View3D *)(ptr->data);
|
||||
bScreen *screen = ptr->id.data;
|
||||
Scene *scene = ED_screen_scene_find(screen, G.main->wm.first);
|
||||
float *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
const View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr);
|
||||
copy_v3_v3(values, cursor->location);
|
||||
}
|
||||
|
||||
copy_v3_v3(cursor, values);
|
||||
static void rna_View3D_Cursor_location_set(PointerRNA *ptr, const float *values)
|
||||
{
|
||||
View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr);
|
||||
copy_v3_v3(cursor->location, values);
|
||||
}
|
||||
|
||||
static void rna_View3D_Cursor_rotation_get(PointerRNA *ptr, float *values)
|
||||
{
|
||||
const View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr);
|
||||
copy_qt_qt(values, cursor->rotation);
|
||||
}
|
||||
|
||||
static void rna_View3D_Cursor_rotation_set(PointerRNA *ptr, const float *values)
|
||||
{
|
||||
View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr);
|
||||
copy_qt_qt(cursor->rotation, values);
|
||||
}
|
||||
|
||||
static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr)
|
||||
|
@ -2508,12 +2521,19 @@ static void rna_def_space_view3d(BlenderRNA *brna)
|
|||
|
||||
prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_float_funcs(prop, "rna_View3D_CursorLocation_get", "rna_View3D_CursorLocation_set", NULL);
|
||||
RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_location_get", "rna_View3D_Cursor_location_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "3D Cursor Location",
|
||||
"3D cursor location for this view (dependent on local view setting)");
|
||||
RNA_def_property_ui_range(prop, -10000.0, 10000.0, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "cursor_rotation", PROP_FLOAT, PROP_QUATERNION);
|
||||
RNA_def_property_array(prop, 4);
|
||||
RNA_def_property_float_funcs(prop, "rna_View3D_Cursor_rotation_get", "rna_View3D_Cursor_rotation_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "3D Cursor Rotation",
|
||||
"Rotation in quaternions (keep normalized)");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_UNIT_CAMERA);
|
||||
RNA_def_property_float_sdna(prop, NULL, "lens");
|
||||
RNA_def_property_ui_text(prop, "Lens", "Viewport lens angle");
|
||||
|
|
Loading…
Reference in New Issue