[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51062] trunk/blender/source/blender/ editors: add ED_view3d_project_float_global, ED_view3d_project_float_object , ED_view3d_project_float_ex function calls and cleanup cursor3d set function which had some odd logic .
Campbell Barton
ideasman42 at gmail.com
Fri Oct 5 03:27:30 CEST 2012
Revision: 51062
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51062
Author: campbellbarton
Date: 2012-10-05 01:27:28 +0000 (Fri, 05 Oct 2012)
Log Message:
-----------
add ED_view3d_project_float_global, ED_view3d_project_float_object, ED_view3d_project_float_ex function calls and cleanup cursor3d set function which had some odd logic.
Modified Paths:
--------------
trunk/blender/source/blender/editors/include/ED_view3d.h
trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
trunk/blender/source/blender/editors/space_view3d/view3d_view.c
Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h 2012-10-05 00:05:21 UTC (rev 51061)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h 2012-10-05 01:27:28 UTC (rev 51062)
@@ -144,6 +144,12 @@
eV3DProjStatus ED_view3d_project_int_global(struct ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag);
eV3DProjStatus ED_view3d_project_int_object(struct ARegion *ar, const float co[3], int r_co[2], eV3DProjTest flag);
+/* *** float *** */
+eV3DProjStatus ED_view3d_project_float_ex(struct ARegion *ar, float perspmat[4][4], const int is_local,
+ const float co[3], float r_co[2], eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_float_global(struct ARegion *ar, const float co[3], float r_co[2], eV3DProjTest flag);
+eV3DProjStatus ED_view3d_project_float_object(struct ARegion *ar, const float co[3], float r_co[2], eV3DProjTest flag);
+
void ED_view3d_project_float(struct ARegion *ar, const float co[3], float r_co[2]);
void ED_view3d_project_float_noclip(struct ARegion *ar, const float co[3], float r_co[2]);
void ED_view3d_project_float_v2_m4(const struct ARegion *a, const float co[3], float r_co[2], float mat[4][4]);
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c 2012-10-05 00:05:21 UTC (rev 51061)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c 2012-10-05 01:27:28 UTC (rev 51062)
@@ -3514,61 +3514,50 @@
/* ***************** 3d cursor cursor op ******************* */
/* mx my in region coords */
-static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
+static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
- float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3];
- int mval[2];
-// short ctrl= 0; // XXX
+ float *fp = NULL;
+ float mval_fl[2];
int flip;
- eV3DProjStatus ret;
fp = give_cursor(scene, v3d);
-// if (obedit && ctrl) lr_click= 1;
- copy_v3_v3(oldcurs, fp);
-
- mval[0] = IS_CLIPPED;
- ret = ED_view3d_project_int_global(ar, fp, mval, V3D_PROJ_TEST_NOP);
flip = initgrabz(rv3d, fp[0], fp[1], fp[2]);
- /* reset the depth based on the view offset */
+ /* reset the depth based on the view offset (we _know_ the offset is infront of us) */
if (flip) {
negate_v3_v3(fp, rv3d->ofs);
-
- /* re initialize */
- mval[0] = IS_CLIPPED;
- ED_view3d_project_int_global(ar, fp, mval, V3D_PROJ_TEST_NOP);
- flip = initgrabz(rv3d, fp[0], fp[1], fp[2]);
- (void)flip;
+ /* re initialize, no need to check flip again */
+ /* flip = */ initgrabz(rv3d, fp[0], fp[1], fp[2]);
}
- if (mval[0] != IS_CLIPPED) {
- short depth_used = 0;
+ if (ED_view3d_project_float_global(ar, fp, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ short depth_used = FALSE;
if (U.uiflag & USER_ZBUF_CURSOR) { /* maybe this should be accessed some other way */
view3d_operator_needs_opengl(C);
if (ED_view3d_autodist(scene, ar, v3d, event->mval, fp))
- depth_used = 1;
+ depth_used = TRUE;
}
- if (depth_used == 0) {
- float mval_f[2];
- VECSUB2D(mval_f, mval, event->mval);
- ED_view3d_win_to_delta(ar, mval_f, dvec);
+ if (depth_used == FALSE) {
+ float dvec[3];
+ VECSUB2D(mval_fl, mval_fl, event->mval);
+ ED_view3d_win_to_delta(ar, mval_fl, dvec);
sub_v3_v3(fp, dvec);
}
}
else {
+ const float dx = ((float)(event->mval[0] - (ar->winx / 2))) * rv3d->zfac / (ar->winx / 2);
+ const float dy = ((float)(event->mval[1] - (ar->winy / 2))) * rv3d->zfac / (ar->winy / 2);
+ const float fz = (rv3d->persmat[0][3] * fp[0] +
+ rv3d->persmat[1][3] * fp[1] +
+ rv3d->persmat[2][3] * fp[2] +
+ rv3d->persmat[3][3]) / rv3d->zfac;
- dx = ((float)(event->mval[0] - (ar->winx / 2))) * rv3d->zfac / (ar->winx / 2);
- dy = ((float)(event->mval[1] - (ar->winy / 2))) * rv3d->zfac / (ar->winy / 2);
-
- fz = rv3d->persmat[0][3] * fp[0] + rv3d->persmat[1][3] * fp[1] + rv3d->persmat[2][3] * fp[2] + rv3d->persmat[3][3];
- fz = fz / rv3d->zfac;
-
fp[0] = (rv3d->persinv[0][0] * dx + rv3d->persinv[1][0] * dy + rv3d->persinv[2][0] * fz) - rv3d->ofs[0];
fp[1] = (rv3d->persinv[0][1] * dx + rv3d->persinv[1][1] * dy + rv3d->persinv[2][1] * fz) - rv3d->ofs[1];
fp[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy + rv3d->persinv[2][2] * fz) - rv3d->ofs[2];
@@ -3591,7 +3580,7 @@
ot->idname = "VIEW3D_OT_cursor3d";
/* api callbacks */
- ot->invoke = set_3dcursor_invoke;
+ ot->invoke = view3d_cursor3d_invoke;
ot->poll = ED_operator_view3d_active;
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_view.c 2012-10-05 00:05:21 UTC (rev 51061)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_view.c 2012-10-05 01:27:28 UTC (rev 51062)
@@ -965,7 +965,7 @@
r_co[1] = (short)floor(tvec[1]);
}
else {
- return V3D_PROJ_RET_OVERFLOW;
+ ret = V3D_PROJ_RET_OVERFLOW;
}
}
return ret;
@@ -984,12 +984,30 @@
r_co[1] = (int)floor(tvec[1]);
}
else {
- return V3D_PROJ_RET_OVERFLOW;
+ ret = V3D_PROJ_RET_OVERFLOW;
}
}
return ret;
}
+eV3DProjStatus ED_view3d_project_float_ex(ARegion *ar, float perspmat[4][4], const int is_local,
+ const float co[3], float r_co[2], eV3DProjTest flag)
+{
+ float tvec[2];
+ eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
+ if (ret == V3D_PROJ_RET_SUCCESS) {
+ if (finite(tvec[0]) &&
+ finite(tvec[1]))
+ {
+ copy_v2_v2(r_co, tvec);
+ }
+ else {
+ ret = V3D_PROJ_RET_OVERFLOW;
+ }
+ }
+ return ret;
+}
+
/* --- short --- */
eV3DProjStatus ED_view3d_project_short_global(ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag)
{
@@ -1016,6 +1034,20 @@
return ED_view3d_project_int_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
}
+/* --- float --- */
+eV3DProjStatus ED_view3d_project_float_global(ARegion *ar, const float co[3], float r_co[2], eV3DProjTest flag)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ return ED_view3d_project_float_ex(ar, rv3d->persmat, FALSE, co, r_co, flag);
+}
+/* object space, use ED_view3d_init_mats_rv3d before calling */
+eV3DProjStatus ED_view3d_project_float_object(ARegion *ar, const float co[3], float r_co[2], eV3DProjTest flag)
+{
+ RegionView3D *rv3d = ar->regiondata;
+ return ED_view3d_project_float_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag);
+}
+
+
void ED_view3d_project_float(ARegion *ar, const float co[3], float r_co[2])
{
RegionView3D *rv3d = ar->regiondata;
More information about the Bf-blender-cvs
mailing list