forked from bartvdbraak/blender
3D View: remove 3D cursor
Use 3D cursor from the scene (was previously used for local-view).
This commit is contained in:
parent
b4e037fe14
commit
7493848008
@ -61,10 +61,7 @@ def add_object_align_init(context, operator):
|
||||
if operator and properties.is_property_set("location"):
|
||||
location = Matrix.Translation(Vector(properties.location))
|
||||
else:
|
||||
if space_data: # local view cursor is detected below
|
||||
location = Matrix.Translation(space_data.cursor_location)
|
||||
else:
|
||||
location = Matrix.Translation(context.scene.cursor_location)
|
||||
location = Matrix.Translation(context.scene.cursor_location)
|
||||
|
||||
if operator:
|
||||
properties.location = location.to_translation()
|
||||
|
@ -891,7 +891,7 @@ class LoadImageAsEmpty:
|
||||
def execute(self, context):
|
||||
scene = context.scene
|
||||
space = context.space_data
|
||||
cursor = (space if space and space.type == 'VIEW_3D' else scene).cursor_location
|
||||
cursor = scene.cursor_location
|
||||
|
||||
try:
|
||||
image = bpy.data.images.load(self.filepath, check_existing=True)
|
||||
|
@ -129,9 +129,8 @@ def align_objects(context,
|
||||
|
||||
depsgraph = context.depsgraph
|
||||
scene = context.scene
|
||||
space = context.space_data
|
||||
|
||||
cursor = (space if space and space.type == 'VIEW_3D' else scene).cursor_location
|
||||
cursor = scene.cursor_location
|
||||
|
||||
# We are accessing runtime data such as evaluated bounding box, so we need to
|
||||
# be sure it is properly updated and valid (bounding box might be lost on operator
|
||||
|
@ -4028,9 +4028,9 @@ class VIEW3D_PT_view3d_cursor(Panel):
|
||||
layout = self.layout
|
||||
layout.use_property_split = True
|
||||
|
||||
view = context.space_data
|
||||
scene = context.scene
|
||||
|
||||
layout.column().prop(view, "cursor_location", text="Location")
|
||||
layout.column().prop(scene, "cursor_location", text="Location")
|
||||
|
||||
|
||||
class VIEW3D_PT_collections(Panel):
|
||||
|
@ -1374,16 +1374,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
||||
for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
|
||||
unit_qt(scene->cursor.rotation);
|
||||
}
|
||||
for (bScreen *screen = bmain->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,6 @@ GPUBatch *DRW_gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
|
||||
{
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
Scene *scene = draw_ctx->scene;
|
||||
View3D *v3d = draw_ctx->v3d;
|
||||
ARegion *ar = draw_ctx->ar;
|
||||
RegionView3D *rv3d = draw_ctx->rv3d;
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
@ -274,7 +273,7 @@ GPUBatch *DRW_gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
|
||||
/* get origin to reproject point */
|
||||
float origin[3];
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
ED_gp_get_drawing_reference(v3d, scene, ob, gpl, ts->gpencil_v3d_align, origin);
|
||||
ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, origin);
|
||||
|
||||
for (int i = 0; i < totpoints; i++, tpt++) {
|
||||
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
|
||||
@ -323,7 +322,6 @@ GPUBatch *DRW_gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
|
||||
{
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
Scene *scene = draw_ctx->scene;
|
||||
View3D *v3d = draw_ctx->v3d;
|
||||
ARegion *ar = draw_ctx->ar;
|
||||
RegionView3D *rv3d = draw_ctx->rv3d;
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
@ -352,7 +350,7 @@ GPUBatch *DRW_gpencil_get_buffer_point_geom(bGPdata *gpd, short thickness)
|
||||
/* get origin to reproject point */
|
||||
float origin[3];
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
ED_gp_get_drawing_reference(v3d, scene, ob, gpl, ts->gpencil_v3d_align, origin);
|
||||
ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, origin);
|
||||
|
||||
for (int i = 0; i < totpoints; i++, tpt++) {
|
||||
ED_gpencil_tpoint_to_point(ar, origin, tpt, &pt);
|
||||
@ -384,7 +382,6 @@ GPUBatch *DRW_gpencil_get_buffer_fill_geom(bGPdata *gpd)
|
||||
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
Scene *scene = draw_ctx->scene;
|
||||
View3D *v3d = draw_ctx->v3d;
|
||||
ARegion *ar = draw_ctx->ar;
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
Object *ob = draw_ctx->obact;
|
||||
@ -392,7 +389,7 @@ GPUBatch *DRW_gpencil_get_buffer_fill_geom(bGPdata *gpd)
|
||||
/* get origin to reproject point */
|
||||
float origin[3];
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
ED_gp_get_drawing_reference(v3d, scene, ob, gpl, ts->gpencil_v3d_align, origin);
|
||||
ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, origin);
|
||||
|
||||
int tot_triangles = totpoints - 2;
|
||||
/* allocate memory for temporary areas */
|
||||
|
@ -165,7 +165,6 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie
|
||||
void DRW_draw_cursor(void)
|
||||
{
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
View3D *v3d = draw_ctx->v3d;
|
||||
ARegion *ar = draw_ctx->ar;
|
||||
Scene *scene = draw_ctx->scene;
|
||||
ViewLayer *view_layer = draw_ctx->view_layer;
|
||||
@ -176,7 +175,7 @@ void DRW_draw_cursor(void)
|
||||
|
||||
if (is_cursor_visible(draw_ctx, scene, view_layer)) {
|
||||
int co[2];
|
||||
const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
const View3DCursor *cursor = &scene->cursor;
|
||||
if (ED_view3d_project_int_global(
|
||||
ar, cursor->location, co, V3D_PROJ_TEST_NOP | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
|
||||
{
|
||||
|
@ -131,7 +131,6 @@ EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool
|
||||
*/
|
||||
static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
View3D *v3d;
|
||||
bArmature *arm;
|
||||
EditBone *ebone, *newbone, *flipbone;
|
||||
float mat[3][3], imat[3][3];
|
||||
@ -140,7 +139,6 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
Scene *scene;
|
||||
|
||||
scene = CTX_data_scene(C);
|
||||
v3d = CTX_wm_view3d(C);
|
||||
obedit = CTX_data_edit_object(C);
|
||||
arm = obedit->data;
|
||||
|
||||
@ -196,7 +194,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
newbone->flag |= BONE_CONNECTED;
|
||||
}
|
||||
|
||||
const View3DCursor *curs = ED_view3d_cursor3d_get(scene, v3d);
|
||||
const View3DCursor *curs = &scene->cursor;
|
||||
copy_v3_v3(newbone->tail, curs->location);
|
||||
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
|
||||
|
||||
@ -236,7 +234,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv
|
||||
ar = CTX_wm_region(C);
|
||||
v3d = CTX_wm_view3d(C);
|
||||
|
||||
View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
View3DCursor *cursor = &scene->cursor;
|
||||
|
||||
copy_v3_v3(oldcurs, cursor->location);
|
||||
|
||||
@ -1063,7 +1061,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))->location);
|
||||
copy_v3_v3(curs, CTX_data_scene(C)->cursor.location);
|
||||
|
||||
/* Get inverse point for head and orientation for tail */
|
||||
invert_m4_m4(obedit->imat, obedit->obmat);
|
||||
|
@ -325,9 +325,8 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
|
||||
|
||||
if (type == CALC_ROLL_CURSOR) { /* Cursor */
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
|
||||
float cursor_local[3];
|
||||
const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
const View3DCursor *cursor = &scene->cursor;
|
||||
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
copy_v3_v3(cursor_local, cursor->location);
|
||||
@ -728,7 +727,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)->location);
|
||||
mul_v3_m4v3(curs, obedit->imat, scene->cursor.location);
|
||||
|
||||
/* Create a bone */
|
||||
newbone = add_points_bone(obedit, ebp->vec, curs);
|
||||
@ -766,7 +765,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)->location);
|
||||
mul_v3_m4v3(curs, obedit->imat, scene->cursor.location);
|
||||
|
||||
/* get distances */
|
||||
dist_sq_a = len_squared_v3v3(ebp_a->vec, curs);
|
||||
|
@ -4819,14 +4819,13 @@ static int spin_exec(bContext *C, wmOperator *op)
|
||||
static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
|
||||
float axis[3] = {0.0f, 0.0f, 1.0f};
|
||||
|
||||
if (rv3d)
|
||||
copy_v3_v3(axis, rv3d->viewinv[2]);
|
||||
|
||||
RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
RNA_float_set_array(op->ptr, "center", scene->cursor.location);
|
||||
RNA_float_set_array(op->ptr, "axis", axis);
|
||||
|
||||
return spin_exec(C, op);
|
||||
@ -5303,7 +5302,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)->location);
|
||||
copy_v3_v3(location, vc.scene->cursor.location);
|
||||
}
|
||||
|
||||
ED_view3d_win_to_3d_int(vc.v3d, vc.ar, location, event->mval, location);
|
||||
|
@ -1121,7 +1121,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)->location;
|
||||
plane_co = cdd->vc.scene->cursor.location;
|
||||
plane_no = rv3d->viewinv[2];
|
||||
cdd->project.use_plane = true;
|
||||
}
|
||||
|
@ -232,8 +232,7 @@ static bool gpencil_project_check(tGPsdata *p)
|
||||
/* get the reference point for stroke-point conversions */
|
||||
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)->location;
|
||||
const float *fp = p->scene->cursor.location;
|
||||
|
||||
/* use 3D-cursor */
|
||||
copy_v3_v3(vec, fp);
|
||||
|
@ -479,9 +479,8 @@ static void gp_brush_grab_calc_dvec(tGP_BrushEditData *gso)
|
||||
// TODO: incorporate pressure into this?
|
||||
// XXX: screen-space strokes in 3D space will suffer!
|
||||
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)->location;
|
||||
float *rvec = gso->scene->cursor.location;
|
||||
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
|
||||
|
||||
float mval_f[2];
|
||||
@ -587,9 +586,8 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso)
|
||||
/* Convert mouse position to 3D space
|
||||
* See: gpencil_paint.c :: gp_stroke_convertcoords()
|
||||
*/
|
||||
View3D *v3d = gso->sa->spacedata.first;
|
||||
RegionView3D *rv3d = gso->ar->regiondata;
|
||||
float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d)->location;
|
||||
const float *rvec = gso->scene->cursor.location;
|
||||
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
|
||||
|
||||
float mval_f[2];
|
||||
|
@ -174,7 +174,7 @@ static void gp_strokepoint_convertcoords(
|
||||
copy_v3_v3(p3d, &pt->x);
|
||||
}
|
||||
else {
|
||||
const float *fp = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
const float *fp = scene->cursor.location;
|
||||
float mvalf[2];
|
||||
|
||||
/* get screen coordinate */
|
||||
|
@ -2196,12 +2196,11 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
|
||||
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
|
||||
const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
const float *cursor_global = scene->cursor.location;
|
||||
|
||||
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
||||
/* only editable and visible layers are considered */
|
||||
@ -2288,7 +2287,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
|
||||
float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
float *cursor = scene->cursor.location;
|
||||
float centroid[3] = {0.0f};
|
||||
float min[3], max[3];
|
||||
size_t count = 0;
|
||||
@ -2857,10 +2856,8 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
|
||||
GP_SpaceConversion gsc = {NULL};
|
||||
eGP_ReprojectModes mode = RNA_enum_get(op->ptr, "type");
|
||||
@ -2905,7 +2902,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* Project stroke in one axis */
|
||||
if (ELEM(mode, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE, GP_REPROJECT_TOP)) {
|
||||
ED_gp_get_drawing_reference(v3d, scene, ob, gpl,
|
||||
ED_gp_get_drawing_reference(scene, ob, gpl,
|
||||
ts->gpencil_v3d_align, origin);
|
||||
|
||||
int axis = 0;
|
||||
|
@ -880,10 +880,10 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
|
||||
for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++) {
|
||||
/* convert screen-coordinates to 3D coordinates */
|
||||
gp_stroke_convertcoords_tpoint(
|
||||
tgpf->scene, tgpf->ar, tgpf->v3d, tgpf->ob,
|
||||
tgpf->gpl, point2D,
|
||||
tgpf->depth_arr ? tgpf->depth_arr + i : NULL,
|
||||
&pt->x);
|
||||
tgpf->scene, tgpf->ar, tgpf->ob,
|
||||
tgpf->gpl, point2D,
|
||||
tgpf->depth_arr ? tgpf->depth_arr + i : NULL,
|
||||
&pt->x);
|
||||
|
||||
pt->pressure = 1.0f;
|
||||
pt->strength = 1.0f;
|
||||
@ -920,7 +920,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
|
||||
if ((tgpf->lock_axis > GP_LOCKAXIS_VIEW) && ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) == 0)) {
|
||||
float origin[3];
|
||||
ED_gp_get_drawing_reference(
|
||||
tgpf->v3d, tgpf->scene, tgpf->ob, tgpf->gpl,
|
||||
tgpf->scene, tgpf->ob, tgpf->gpl,
|
||||
ts->gpencil_v3d_align, origin);
|
||||
ED_gp_project_stroke_to_plane(
|
||||
tgpf->ob, tgpf->rv3d, gps, origin,
|
||||
|
@ -221,7 +221,7 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, struct Scene *scene, const float
|
||||
/* helper to convert 2d to 3d */
|
||||
void gp_stroke_convertcoords_tpoint(
|
||||
struct Scene *scene, struct ARegion *ar,
|
||||
struct View3D *v3d, struct Object *ob,
|
||||
struct Object *ob,
|
||||
bGPDlayer *gpl, const struct tGPspoint *point2D,
|
||||
float *depth, float out[3]);
|
||||
|
||||
|
@ -285,12 +285,11 @@ static bool gpencil_project_check(tGPsdata *p)
|
||||
/* get the reference point for stroke-point conversions */
|
||||
static void gp_get_3d_reference(tGPsdata *p, float vec[3])
|
||||
{
|
||||
View3D *v3d = p->sa->spacedata.first;
|
||||
Object *ob = NULL;
|
||||
if (p->ownerPtr.type == &RNA_Object) {
|
||||
ob = (Object *)p->ownerPtr.data;
|
||||
}
|
||||
ED_gp_get_drawing_reference(v3d, p->scene, ob, p->gpl, *p->align_flag, vec);
|
||||
ED_gp_get_drawing_reference(p->scene, ob, p->gpl, *p->align_flag, vec);
|
||||
}
|
||||
|
||||
/* Stroke Editing ---------------------------- */
|
||||
@ -1774,7 +1773,6 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
View3D *v3d = curarea->spacedata.first;
|
||||
|
||||
/* make sure the active view (at the starting time) is a 3d-view */
|
||||
if (curarea == NULL) {
|
||||
@ -1818,7 +1816,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
|
||||
}
|
||||
|
||||
/* if active object doesn't exist or isn't a GP Object, create one */
|
||||
float *cur = ED_view3d_cursor3d_get(p->scene, v3d)->location;
|
||||
const float *cur = p->scene->cursor.location;
|
||||
if ((!obact) || (obact->type != OB_GPENCIL)) {
|
||||
/* create new default object */
|
||||
obact = ED_add_gpencil_object(C, p->scene, cur);
|
||||
|
@ -348,7 +348,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
|
||||
|
||||
|
||||
/* convert screen-coordinates to 3D coordinates */
|
||||
gp_stroke_convertcoords_tpoint(tgpi->scene, tgpi->ar, tgpi->v3d, tgpi->ob, tgpi->gpl, p2d, NULL, &pt->x);
|
||||
gp_stroke_convertcoords_tpoint(tgpi->scene, tgpi->ar, tgpi->ob, tgpi->gpl, p2d, NULL, &pt->x);
|
||||
|
||||
pt->pressure = 1.0f;
|
||||
pt->strength = tgpi->brush->gpencil_settings->draw_strength;
|
||||
@ -365,7 +365,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
|
||||
if (tgpi->lock_axis > GP_LOCKAXIS_VIEW) {
|
||||
bGPDspoint *tpt = gps->points;
|
||||
float origin[3];
|
||||
ED_gp_get_drawing_reference(tgpi->v3d, tgpi->scene, tgpi->ob, tgpi->gpl,
|
||||
ED_gp_get_drawing_reference(tgpi->scene, tgpi->ob, tgpi->gpl,
|
||||
ts->gpencil_v3d_align, origin);
|
||||
|
||||
for (int i = 0; i < gps->totpoints; i++, tpt++) {
|
||||
|
@ -737,9 +737,8 @@ void gp_point_to_xy_fl(
|
||||
*/
|
||||
bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen_co[2], float r_out[3])
|
||||
{
|
||||
View3D *v3d = gsc->sa->spacedata.first;
|
||||
RegionView3D *rv3d = gsc->ar->regiondata;
|
||||
float *rvec = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
const RegionView3D *rv3d = gsc->ar->regiondata;
|
||||
float *rvec = scene->cursor.location;
|
||||
float ref[3] = {rvec[0], rvec[1], rvec[2]};
|
||||
float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL);
|
||||
|
||||
@ -771,7 +770,7 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen
|
||||
* \param[out] r_out: The resulting 2D point data
|
||||
*/
|
||||
void gp_stroke_convertcoords_tpoint(
|
||||
Scene *scene, ARegion *ar, View3D *v3d,
|
||||
Scene *scene, ARegion *ar,
|
||||
Object *ob, bGPDlayer *gpl,
|
||||
const tGPspoint *point2D, float *depth,
|
||||
float r_out[3])
|
||||
@ -793,7 +792,7 @@ void gp_stroke_convertcoords_tpoint(
|
||||
/* Current method just converts each point in screen-coordinates to
|
||||
* 3D-coordinates using the 3D-cursor as reference.
|
||||
*/
|
||||
ED_gp_get_drawing_reference(v3d, scene, ob, gpl, ts->gpencil_v3d_align, rvec);
|
||||
ED_gp_get_drawing_reference(scene, ob, gpl, ts->gpencil_v3d_align, rvec);
|
||||
zfac = ED_view3d_calc_zfac(ar->regiondata, rvec, NULL);
|
||||
|
||||
if (ED_view3d_project_float_global(ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) {
|
||||
@ -812,10 +811,10 @@ void gp_stroke_convertcoords_tpoint(
|
||||
* \param[out] r_vec : Reference point found
|
||||
*/
|
||||
void ED_gp_get_drawing_reference(
|
||||
View3D *v3d, Scene *scene, Object *ob, bGPDlayer *UNUSED(gpl),
|
||||
const Scene *scene, const Object *ob, bGPDlayer *UNUSED(gpl),
|
||||
char align_flag, float r_vec[3])
|
||||
{
|
||||
const float *fp = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
const float *fp = scene->cursor.location;
|
||||
|
||||
/* if using a gpencil object at cursor mode, can use the location of the object */
|
||||
if (align_flag & GP_PROJECT_VIEWSPACE) {
|
||||
@ -841,7 +840,8 @@ void ED_gp_get_drawing_reference(
|
||||
/**
|
||||
* Reproject all points of the stroke to a plane locked to axis to avoid stroke offset
|
||||
*/
|
||||
void ED_gp_project_stroke_to_plane(Object *ob, RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis)
|
||||
void ED_gp_project_stroke_to_plane(
|
||||
const Object *ob, const RegionView3D *rv3d, bGPDstroke *gps, const float origin[3], const int axis)
|
||||
{
|
||||
float plane_normal[3];
|
||||
float vn[3];
|
||||
@ -887,7 +887,8 @@ void ED_gp_project_stroke_to_plane(Object *ob, RegionView3D *rv3d, bGPDstroke *g
|
||||
* Reproject given point to a plane locked to axis to avoid stroke offset
|
||||
* \param[in, out] pt : Point to affect
|
||||
*/
|
||||
void ED_gp_project_point_to_plane(Object *ob, RegionView3D *rv3d, const float origin[3], const int axis, bGPDspoint *pt)
|
||||
void ED_gp_project_point_to_plane(
|
||||
const Object *ob, const RegionView3D *rv3d, const float origin[3], const int axis, bGPDspoint *pt)
|
||||
{
|
||||
float plane_normal[3];
|
||||
float vn[3];
|
||||
|
@ -227,9 +227,15 @@ void ED_gpencil_add_defaults(struct bContext *C);
|
||||
/* set object modes */
|
||||
void ED_gpencil_setup_modes(struct bContext *C, struct bGPdata *gpd, int newmode);
|
||||
|
||||
void ED_gp_project_stroke_to_plane(struct Object *ob, struct RegionView3D *rv3d, struct bGPDstroke *gps, const float origin[3], const int axis);
|
||||
void ED_gp_project_point_to_plane(struct Object *ob, struct RegionView3D *rv3d, const float origin[3], const int axis, struct bGPDspoint *pt);
|
||||
void ED_gp_get_drawing_reference(struct View3D *v3d, struct Scene *scene, struct Object *ob, struct bGPDlayer *gpl, char align_flag, float vec[3]);
|
||||
void ED_gp_project_stroke_to_plane(
|
||||
const struct Object *ob, const struct RegionView3D *rv3d,
|
||||
struct bGPDstroke *gps, const float origin[3], const int axis);
|
||||
void ED_gp_project_point_to_plane(
|
||||
const struct Object *ob, const struct RegionView3D *rv3d,
|
||||
const float origin[3], const int axis, struct bGPDspoint *pt);
|
||||
void ED_gp_get_drawing_reference(
|
||||
const struct Scene *scene, const struct Object *ob,
|
||||
struct bGPDlayer *gpl, char align_flag, float vec[3]);
|
||||
|
||||
/* set sculpt cursor */
|
||||
void ED_gpencil_toggle_brush_cursor(struct bContext *C, bool enable, void *customdata);
|
||||
|
@ -209,7 +209,7 @@ void ED_transform_calc_orientation_from_type(
|
||||
void ED_transform_calc_orientation_from_type_ex(
|
||||
const struct bContext *C, float r_mat[3][3],
|
||||
/* extra args */
|
||||
struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d, struct Object *ob, struct Object *obedit,
|
||||
struct Scene *scene, struct RegionView3D *rv3d, struct Object *ob, struct Object *obedit,
|
||||
const short orientation_type, const int pivot_point);
|
||||
|
||||
struct TransformBounds {
|
||||
|
@ -109,9 +109,8 @@ enum eV3DCursorOrient {
|
||||
};
|
||||
|
||||
void ED_view3d_background_color_get(const struct Scene *scene, const struct View3D *v3d, float r_color[3]);
|
||||
struct View3DCursor *ED_view3d_cursor3d_get(struct Scene *scene, struct View3D *v3d);
|
||||
void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, const struct View3D *v3d, float mat[3][3]);
|
||||
void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, const struct View3D *v3d, float mat[4][4]);
|
||||
void ED_view3d_cursor3d_calc_mat3(const struct Scene *scene, float mat[3][3]);
|
||||
void ED_view3d_cursor3d_calc_mat4(const struct Scene *scene, float mat[4][4]);
|
||||
void ED_view3d_cursor3d_position(
|
||||
struct bContext *C, const int mval[2],
|
||||
const bool use_depth,
|
||||
|
@ -70,7 +70,6 @@ static void calc_initial_placement_point_from_view(
|
||||
{
|
||||
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
@ -78,7 +77,7 @@ static void calc_initial_placement_point_from_view(
|
||||
|
||||
float cursor_matrix[4][4];
|
||||
float orient_matrix[3][3];
|
||||
ED_view3d_cursor3d_calc_mat4(scene, v3d, cursor_matrix);
|
||||
ED_view3d_cursor3d_calc_mat4(scene, cursor_matrix);
|
||||
|
||||
float dots[3] = {
|
||||
dot_v3v3(rv3d->viewinv[2], cursor_matrix[0]),
|
||||
|
@ -242,7 +242,6 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op)
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
/* both can be NULL, fallbacks values are used */
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
|
||||
|
||||
int ret = OPERATOR_CANCELLED;
|
||||
@ -264,7 +263,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)->location);
|
||||
copy_v3_v3(plane_co, scene->cursor.location);
|
||||
RNA_property_float_set_array(op->ptr, prop_plane_co, plane_co);
|
||||
}
|
||||
|
||||
|
@ -823,7 +823,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
|
||||
}
|
||||
else {
|
||||
/* This only runs for the active object. */
|
||||
const float *cursor = ED_view3d_cursor3d_get(vc.scene, vc.v3d)->location;
|
||||
const float *cursor = vc.scene->cursor.location;
|
||||
BMOperator bmop;
|
||||
BMOIter oiter;
|
||||
|
||||
|
@ -171,13 +171,12 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
|
||||
static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
|
||||
|
||||
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)->location);
|
||||
RNA_property_float_set_array(op->ptr, prop, scene->cursor.location);
|
||||
}
|
||||
if (rv3d) {
|
||||
prop = RNA_struct_find_property(op->ptr, "axis");
|
||||
|
@ -130,7 +130,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)->location);
|
||||
RNA_property_float_set_array(op->ptr, prop, scene->cursor.location);
|
||||
}
|
||||
if (rv3d) {
|
||||
prop = RNA_struct_find_property(op->ptr, "axis");
|
||||
|
@ -316,8 +316,7 @@ static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgrou
|
||||
const float *gizmo_center = NULL;
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
const View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
const View3DCursor *cursor = &scene->cursor;
|
||||
gizmo_center = cursor->location;
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,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)->location);
|
||||
copy_v3_v3(center, vc.scene->cursor.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);
|
||||
|
@ -4368,7 +4368,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op)
|
||||
/* 3D view variables may be NULL, (no need to check in poll function). */
|
||||
ED_transform_calc_orientation_from_type_ex(
|
||||
C, axis_mat,
|
||||
scene, CTX_wm_view3d(C), CTX_wm_region_view3d(C), obedit, obedit,
|
||||
scene, CTX_wm_region_view3d(C), obedit, obedit,
|
||||
orientation, V3D_AROUND_ACTIVE);
|
||||
|
||||
const float *axis_vector = axis_mat[axis];
|
||||
|
@ -2723,7 +2723,7 @@ static bool merge_firstlast(BMEditMesh *em, const bool use_first, const bool use
|
||||
}
|
||||
|
||||
static bool merge_target(
|
||||
BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob,
|
||||
BMEditMesh *em, Scene *scene, Object *ob,
|
||||
const bool use_cursor, const bool use_uvmerge, wmOperator *wmop)
|
||||
{
|
||||
BMIter iter;
|
||||
@ -2732,7 +2732,7 @@ static bool merge_target(
|
||||
const float *vco = NULL;
|
||||
|
||||
if (use_cursor) {
|
||||
vco = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
vco = scene->cursor.location;
|
||||
copy_v3_v3(co, vco);
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
mul_m4_v3(ob->imat, co);
|
||||
@ -2773,7 +2773,6 @@ static bool merge_target(
|
||||
static int edbm_merge_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
uint objects_len = 0;
|
||||
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, CTX_wm_view3d(C), &objects_len);
|
||||
@ -2791,10 +2790,10 @@ static int edbm_merge_exec(bContext *C, wmOperator *op)
|
||||
bool ok = false;
|
||||
switch (type) {
|
||||
case MESH_MERGE_CENTER:
|
||||
ok = merge_target(em, scene, v3d, obedit, false, uvs, op);
|
||||
ok = merge_target(em, scene, obedit, false, uvs, op);
|
||||
break;
|
||||
case MESH_MERGE_CURSOR:
|
||||
ok = merge_target(em, scene, v3d, obedit, true, uvs, op);
|
||||
ok = merge_target(em, scene, obedit, true, uvs, op);
|
||||
break;
|
||||
case MESH_MERGE_LAST:
|
||||
ok = merge_firstlast(em, false, uvs, op);
|
||||
@ -5628,7 +5627,7 @@ static int bmelemsort_comp(const void *v1, const void *v2)
|
||||
static void sort_bmelem_flag(
|
||||
bContext *C,
|
||||
Scene *scene, Object *ob,
|
||||
View3D *v3d, RegionView3D *rv3d,
|
||||
RegionView3D *rv3d,
|
||||
const int types, const int flag, const int action,
|
||||
const int reverse, const unsigned int seed)
|
||||
{
|
||||
@ -5730,10 +5729,8 @@ static void sort_bmelem_flag(
|
||||
float mat[4][4];
|
||||
float fact = reverse ? -1.0 : 1.0;
|
||||
|
||||
if (v3d && v3d->localvd)
|
||||
copy_v3_v3(cur, v3d->cursor.location);
|
||||
else
|
||||
copy_v3_v3(cur, scene->cursor.location);
|
||||
copy_v3_v3(cur, scene->cursor.location);
|
||||
|
||||
invert_m4_m4(mat, ob->obmat);
|
||||
mul_m4_v3(mat, cur);
|
||||
|
||||
@ -6067,7 +6064,6 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
|
||||
Object *ob_active = CTX_data_edit_object(C);
|
||||
|
||||
/* may be NULL */
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
RegionView3D *rv3d = ED_view3d_context_rv3d(C);
|
||||
|
||||
const int action = RNA_enum_get(op->ptr, "type");
|
||||
@ -6121,8 +6117,8 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
sort_bmelem_flag(
|
||||
C, scene, ob, v3d, rv3d,
|
||||
elem_types, BM_ELEM_SELECT, action, use_reverse, seed_iter);
|
||||
C, scene, ob, rv3d,
|
||||
elem_types, BM_ELEM_SELECT, action, use_reverse, seed_iter);
|
||||
}
|
||||
MEM_freeN(objects);
|
||||
return OPERATOR_FINISHED;
|
||||
@ -7363,7 +7359,7 @@ static int edbm_point_normals_modal(bContext *C, wmOperator *op, const wmEvent *
|
||||
case EDBM_CLNOR_MODAL_POINTTO_SET_USE_3DCURSOR:
|
||||
new_mode = EDBM_CLNOR_POINTTO_MODE_COORDINATES;
|
||||
ED_view3d_cursor3d_update(C, event->mval, false, V3D_CURSOR_ORIENT_NONE);
|
||||
copy_v3_v3(target, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
copy_v3_v3(target, scene->cursor.location);
|
||||
ret = OPERATOR_RUNNING_MODAL;
|
||||
break;
|
||||
|
||||
@ -7412,7 +7408,7 @@ static int edbm_point_normals_modal(bContext *C, wmOperator *op, const wmEvent *
|
||||
}
|
||||
|
||||
case V3D_AROUND_CURSOR:
|
||||
copy_v3_v3(target, ED_view3d_cursor3d_get(scene, v3d)->location);
|
||||
copy_v3_v3(target, scene->cursor.location);
|
||||
break;
|
||||
|
||||
case V3D_AROUND_ACTIVE:
|
||||
|
@ -163,13 +163,8 @@ static EnumPropertyItem lightprobe_type_items[] = {
|
||||
|
||||
void ED_object_location_from_view(bContext *C, float loc[3])
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
const float *cursor;
|
||||
|
||||
cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
|
||||
copy_v3_v3(loc, cursor);
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
copy_v3_v3(loc, scene->cursor.location);
|
||||
}
|
||||
|
||||
void ED_object_rotation_from_quat(float rot[3], const float viewquat[4], const char align_axis)
|
||||
|
@ -828,7 +828,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)->location);
|
||||
copy_v3_v3(cursor, scene->cursor.location);
|
||||
if (v3d && !RNA_struct_property_is_set(op->ptr, "center"))
|
||||
around = scene->toolsettings->transform_pivot_point;
|
||||
}
|
||||
|
@ -223,12 +223,8 @@ static int object_warp_verts_exec(bContext *C, wmOperator *op)
|
||||
RNA_property_float_get_array(op->ptr, prop_center, center);
|
||||
}
|
||||
else {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
const float *cursor;
|
||||
|
||||
cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
copy_v3_v3(center, cursor);
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
copy_v3_v3(center, scene->cursor.location);
|
||||
|
||||
RNA_property_float_set_array(op->ptr, prop_center, center);
|
||||
}
|
||||
|
@ -3899,7 +3899,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)->location);
|
||||
copy_v3_v3(projCo, ps->scene->cursor.location);
|
||||
mul_m4_v3(ps->obmat_imat, projCo);
|
||||
|
||||
projCo[3] = 1.0f;
|
||||
@ -5013,7 +5013,7 @@ void paint_proj_stroke(
|
||||
struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
float *cursor = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
float *cursor = scene->cursor.location;
|
||||
int mval_i[2] = {(int)pos[0], (int)pos[1]};
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
@ -2712,7 +2712,7 @@ 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). */
|
||||
View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
View3DCursor *cursor = &scene->cursor;
|
||||
zero_v3(min);
|
||||
zero_v3(max);
|
||||
zero_v3(cursor->location);
|
||||
@ -3043,7 +3043,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)->location);
|
||||
negate_v3_v3(new_ofs, scene->cursor.location);
|
||||
ED_view3d_smooth_view(
|
||||
C, v3d, ar, smooth_viewtx,
|
||||
&(const V3D_SmoothParams) {.ofs = new_ofs});
|
||||
@ -4755,7 +4755,7 @@ void ED_view3d_cursor3d_update(
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
View3DCursor *cursor_curr = ED_view3d_cursor3d_get(scene, v3d);
|
||||
View3DCursor *cursor_curr = &scene->cursor;
|
||||
View3DCursor cursor_prev = *cursor_curr;
|
||||
|
||||
ED_view3d_cursor3d_position_rotation(
|
||||
|
@ -454,9 +454,8 @@ static int snap_selected_to_cursor_exec(bContext *C, wmOperator *op)
|
||||
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
|
||||
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
const float *snap_target_global = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
const float *snap_target_global = scene->cursor.location;
|
||||
|
||||
return snap_selected_to_location(C, snap_target_global, use_offset);
|
||||
}
|
||||
@ -521,7 +520,7 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
float gridf, *curs;
|
||||
|
||||
gridf = ED_view3d_grid_scale(scene, v3d, NULL);
|
||||
curs = ED_view3d_cursor3d_get(scene, v3d)->location;
|
||||
curs = scene->cursor.location;
|
||||
|
||||
curs[0] = gridf * floorf(0.5f + curs[0] / gridf);
|
||||
curs[1] = gridf * floorf(0.5f + curs[1] / gridf);
|
||||
@ -724,13 +723,8 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
|
||||
static int snap_curs_to_sel_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)->location;
|
||||
|
||||
if (snap_curs_to_sel_ex(C, curs)) {
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
if (snap_curs_to_sel_ex(C, scene->cursor.location)) {
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@ -805,11 +799,8 @@ static int snap_curs_to_active_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)->location;
|
||||
|
||||
if (snap_calc_active_center(C, false, curs)) {
|
||||
if (snap_calc_active_center(C, false, scene->cursor.location)) {
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
|
||||
|
||||
@ -841,15 +832,12 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
|
||||
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)->location;
|
||||
|
||||
zero_v3(curs);
|
||||
zero_v3(scene->cursor.location);
|
||||
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
|
||||
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
|
||||
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -91,20 +91,15 @@ void ED_view3d_background_color_get(const Scene *scene, const View3D *v3d, float
|
||||
}
|
||||
}
|
||||
|
||||
View3DCursor *ED_view3d_cursor3d_get(Scene *scene, View3D *UNUSED(v3d))
|
||||
void ED_view3d_cursor3d_calc_mat3(const Scene *scene, float mat[3][3])
|
||||
{
|
||||
return &scene->cursor;
|
||||
}
|
||||
|
||||
void ED_view3d_cursor3d_calc_mat3(const Scene *scene, const View3D *v3d, float mat[3][3])
|
||||
{
|
||||
const View3DCursor *cursor = ED_view3d_cursor3d_get((Scene *)scene, (View3D *)v3d);
|
||||
const View3DCursor *cursor = &scene->cursor;
|
||||
quat_to_mat3(mat, cursor->rotation);
|
||||
}
|
||||
|
||||
void ED_view3d_cursor3d_calc_mat4(const Scene *scene, const View3D *v3d, float mat[4][4])
|
||||
void ED_view3d_cursor3d_calc_mat4(const Scene *scene, float mat[4][4])
|
||||
{
|
||||
const View3DCursor *cursor = ED_view3d_cursor3d_get((Scene *)scene, (View3D *)v3d);
|
||||
const View3DCursor *cursor = &scene->cursor;
|
||||
quat_to_mat4(mat, cursor->rotation);
|
||||
copy_v3_v3(mat[3], cursor->location);
|
||||
}
|
||||
|
@ -799,7 +799,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)->location);
|
||||
copy_v3_v3(vec, scene->cursor.location);
|
||||
translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]);
|
||||
use_lock_ofs = true;
|
||||
}
|
||||
|
@ -3134,7 +3134,7 @@ static void initBend(TransInfo *t)
|
||||
|
||||
data = MEM_callocN(sizeof(*data), __func__);
|
||||
|
||||
curs = ED_view3d_cursor3d_get(t->scene, t->view)->location;
|
||||
curs = t->scene->cursor.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);
|
||||
|
||||
|
@ -383,14 +383,12 @@ static void createTransCursor_view3d(TransInfo *t)
|
||||
TransData *td;
|
||||
|
||||
Scene *scene = t->scene;
|
||||
View3D *v3d = ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) ? t->view : NULL;
|
||||
View3DCursor *cursor = ED_view3d_cursor3d_get(scene, v3d);
|
||||
|
||||
if ((cursor == &scene->cursor) && ID_IS_LINKED(scene)) {
|
||||
if (ID_IS_LINKED(scene)) {
|
||||
BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
|
||||
return;
|
||||
}
|
||||
|
||||
View3DCursor *cursor = &scene->cursor;
|
||||
{
|
||||
BLI_assert(t->data_container_len == 1);
|
||||
TransDataContainer *tc = t->data_container;
|
||||
|
@ -1848,9 +1848,7 @@ void calculateCenterLocal(
|
||||
|
||||
void calculateCenterCursor(TransInfo *t, float r_center[3])
|
||||
{
|
||||
const float *cursor;
|
||||
|
||||
cursor = ED_view3d_cursor3d_get(t->scene, t->view)->location;
|
||||
const float *cursor = t->scene->cursor.location;
|
||||
copy_v3_v3(r_center, cursor);
|
||||
|
||||
/* If edit or pose mode, move cursor in local space */
|
||||
|
@ -615,12 +615,10 @@ bool gimbal_axis(Object *ob, float gmat[3][3])
|
||||
void ED_transform_calc_orientation_from_type(
|
||||
const bContext *C, float r_mat[3][3])
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
Object *ob = OBACT(view_layer);
|
||||
const short orientation_type = scene->orientation_type;
|
||||
@ -628,13 +626,13 @@ void ED_transform_calc_orientation_from_type(
|
||||
|
||||
ED_transform_calc_orientation_from_type_ex(
|
||||
C, r_mat,
|
||||
scene, v3d, rv3d, ob, obedit, orientation_type, pivot_point);
|
||||
scene, rv3d, ob, obedit, orientation_type, pivot_point);
|
||||
}
|
||||
|
||||
void ED_transform_calc_orientation_from_type_ex(
|
||||
const bContext *C, float r_mat[3][3],
|
||||
/* extra args (can be accessed from context) */
|
||||
Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, Object *obedit,
|
||||
Scene *scene, RegionView3D *rv3d, Object *ob, Object *obedit,
|
||||
const short orientation_type, const int pivot_point)
|
||||
{
|
||||
bool ok = false;
|
||||
@ -690,7 +688,7 @@ void ED_transform_calc_orientation_from_type_ex(
|
||||
}
|
||||
case V3D_MANIP_CURSOR:
|
||||
{
|
||||
ED_view3d_cursor3d_calc_mat3(scene, v3d, r_mat);
|
||||
ED_view3d_cursor3d_calc_mat3(scene, r_mat);
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
@ -748,7 +746,7 @@ int ED_transform_calc_gizmo_stats(
|
||||
float mat[3][3];
|
||||
ED_transform_calc_orientation_from_type_ex(
|
||||
C, mat,
|
||||
scene, v3d, rv3d, ob, obedit, orientation_type, pivot_point);
|
||||
scene, rv3d, ob, obedit, orientation_type, pivot_point);
|
||||
copy_m4_m3(rv3d->twmat, mat);
|
||||
}
|
||||
|
||||
@ -1184,7 +1182,7 @@ static void gizmo_get_idot(RegionView3D *rv3d, float r_idot[3])
|
||||
}
|
||||
|
||||
static void gizmo_prepare_mat(
|
||||
const bContext *C, View3D *v3d, RegionView3D *rv3d, const struct TransformBounds *tbounds)
|
||||
const bContext *C, RegionView3D *rv3d, const struct TransformBounds *tbounds)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
@ -1213,7 +1211,7 @@ static void gizmo_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)->location);
|
||||
copy_v3_v3(rv3d->twmat[3], scene->cursor.location);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1478,9 +1476,7 @@ static int gizmo_modal(
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
}
|
||||
|
||||
const ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
struct TransformBounds tbounds;
|
||||
|
||||
@ -1490,7 +1486,7 @@ static int gizmo_modal(
|
||||
.use_only_center = true,
|
||||
}, &tbounds))
|
||||
{
|
||||
gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
|
||||
gizmo_prepare_mat(C, rv3d, &tbounds);
|
||||
WM_gizmo_set_matrix_location(widget, rv3d->twmat[3]);
|
||||
}
|
||||
|
||||
@ -1658,9 +1654,7 @@ static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
{
|
||||
GizmoGroup *ggd = gzgroup->customdata;
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
struct TransformBounds tbounds;
|
||||
|
||||
@ -1683,7 +1677,7 @@ static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
return;
|
||||
}
|
||||
|
||||
gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
|
||||
gizmo_prepare_mat(C, rv3d, &tbounds);
|
||||
|
||||
/* *** set properties for axes *** */
|
||||
|
||||
@ -1915,8 +1909,6 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup
|
||||
|
||||
static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
@ -1934,7 +1926,7 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgr
|
||||
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, true);
|
||||
}
|
||||
else {
|
||||
gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
|
||||
gizmo_prepare_mat(C, rv3d, &tbounds);
|
||||
|
||||
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
|
||||
WM_gizmo_set_flag(gz, WM_GIZMO_MOVE_CURSOR, true);
|
||||
@ -2093,8 +2085,6 @@ static void WIDGETGROUP_xform_shear_setup(const bContext *UNUSED(C), wmGizmoGrou
|
||||
|
||||
static void WIDGETGROUP_xform_shear_refresh(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
View3D *v3d = sa->spacedata.first;
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
@ -2114,7 +2104,7 @@ static void WIDGETGROUP_xform_shear_refresh(const bContext *C, wmGizmoGroup *gzg
|
||||
}
|
||||
}
|
||||
else {
|
||||
gizmo_prepare_mat(C, v3d, rv3d, &tbounds);
|
||||
gizmo_prepare_mat(C, rv3d, &tbounds);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
wmGizmo *gz = xgzgroup->gizmo[i][j];
|
||||
|
@ -484,7 +484,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
|
||||
case V3D_MANIP_CURSOR:
|
||||
{
|
||||
BLI_strncpy(t->spacename, IFACE_("cursor"), sizeof(t->spacename));
|
||||
ED_view3d_cursor3d_calc_mat3(t->scene, CTX_wm_view3d(C), t->spacemtx);
|
||||
ED_view3d_cursor3d_calc_mat3(t->scene, t->spacemtx);
|
||||
break;
|
||||
}
|
||||
case V3D_MANIP_CUSTOM_MATRIX:
|
||||
|
@ -1107,7 +1107,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)->location);
|
||||
mul_v3_m4v3(r_center, ob->imat, scene->cursor.location);
|
||||
break;
|
||||
}
|
||||
case V3D_AROUND_ACTIVE:
|
||||
|
@ -246,8 +246,6 @@ typedef struct View3D {
|
||||
float near, far;
|
||||
float ofs[3] DNA_DEPRECATED; /* XXX deprecated */
|
||||
|
||||
View3DCursor cursor;
|
||||
|
||||
char _pad[4];
|
||||
|
||||
short matcap_icon; /* icon id */
|
||||
|
@ -531,47 +531,6 @@ static void rna_SpaceView3D_lock_camera_and_layers_set(PointerRNA *ptr, bool val
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
return ED_view3d_cursor3d_get(scene, v3d);
|
||||
}
|
||||
|
||||
static void rna_View3D_Cursor_location_get(PointerRNA *ptr, float *values)
|
||||
{
|
||||
const View3DCursor *cursor = rna_View3D_Cursor_get_from_scene_or_localview(ptr);
|
||||
copy_v3_v3(values, cursor->location);
|
||||
}
|
||||
|
||||
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 void rna_View3D_Cursor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
View3D *v3d = ptr->data;
|
||||
if (v3d->localvd == NULL) {
|
||||
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
|
||||
}
|
||||
}
|
||||
|
||||
static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr)
|
||||
{
|
||||
View3D *v3d = (View3D *)(ptr->data);
|
||||
@ -3108,21 +3067,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Local View",
|
||||
"Display an isolated sub-set of objects, apart from the scene visibility");
|
||||
|
||||
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_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, "rna_View3D_Cursor_update");
|
||||
|
||||
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, "rna_View3D_Cursor_update");
|
||||
|
||||
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
Block a user