[Bf-blender-cvs] [87215bbae4c] blender2.8: Merge branch 'master' into blender2.8
Campbell Barton
noreply at git.blender.org
Sun Jan 28 05:58:35 CET 2018
Commit: 87215bbae4cd581229ad1890ed599cebda421b38
Author: Campbell Barton
Date: Sun Jan 28 15:20:19 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB87215bbae4cd581229ad1890ed599cebda421b38
Merge branch 'master' into blender2.8
===================================================================
===================================================================
diff --cc source/blender/editors/include/ED_view3d.h
index 68cd3763f93,6e01245e6dc..7eee053061e
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@@ -431,9 -403,12 +431,12 @@@ char ED_view3d_axis_view_opposite(char
bool ED_view3d_lock(struct RegionView3D *rv3d);
uint64_t ED_view3d_datamask(const struct Scene *scene, const struct View3D *v3d);
-uint64_t ED_view3d_screen_datamask(const struct bScreen *screen);
+uint64_t ED_view3d_screen_datamask(const struct Scene *scene, const struct bScreen *screen);
bool ED_view3d_offset_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d);
+ void ED_view3d_persp_switch_from_camera(struct View3D *v3d, struct RegionView3D *rv3d, const char persp);
+ bool ED_view3d_persp_ensure(struct View3D *v3d, struct ARegion *ar);
+
/* camera lock functions */
bool ED_view3d_camera_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d);
diff --cc source/blender/editors/space_view3d/view3d_edit.c
index 647a8b9de3a,861808118cd..1e368e2d171
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@@ -59,13 -54,13 +57,11 @@@
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_report.h"
--#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_action.h"
+#include "DEG_depsgraph.h"
--#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "WM_api.h"
#include "WM_types.h"
@@@ -82,8 -76,6 +77,7 @@@
#include "ED_gpencil.h"
#include "ED_view3d.h"
- #include "DEG_depsgraph_query.h"
+
#include "UI_resources.h"
#include "PIL_time.h" /* smoothview */
@@@ -2963,9 -2446,18 +2458,16 @@@ void VIEW3D_OT_dolly(wmOperatorType *ot
RNA_def_int(ot->srna, "my", 0, 0, INT_MAX, "Zoom Position Y", "", 0, INT_MAX);
}
+ /** \} */
+
+ /* -------------------------------------------------------------------- */
+ /** \name View All Operator
+ *
+ * Move & Zoom the view to fit all of it's contents.
+ * \{ */
-
-static void view3d_from_minmax(
- bContext *C, View3D *v3d, ARegion *ar,
- const float min[3], const float max[3],
- bool ok_dist, const int smooth_viewtx)
+static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar,
+ const float min[3], const float max[3],
+ bool ok_dist, const int smooth_viewtx)
{
RegionView3D *rv3d = ar->regiondata;
float afm[3];
diff --cc source/blender/editors/space_view3d/view3d_utils.c
index 00000000000,e40a4b3f9f6..cb9c7f02db9
mode 000000,100644..100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@@ -1,0 -1,1477 +1,1407 @@@
+ /*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+ /** \file blender/editors/space_view3d/view3d_utils.c
+ * \ingroup spview3d
+ *
+ * 3D View checks and manipulation (no operators).
+ */
+
+ #include <string.h>
+ #include <stdio.h>
+ #include <math.h>
+ #include <float.h>
+
+ #include "DNA_camera_types.h"
+ #include "DNA_curve_types.h"
+ #include "DNA_object_types.h"
+ #include "DNA_scene_types.h"
+
+ #include "MEM_guardedalloc.h"
+
+ #include "BLI_bitmap_draw_2d.h"
+ #include "BLI_blenlib.h"
+ #include "BLI_math.h"
+ #include "BLI_utildefines.h"
+
+ #include "BKE_camera.h"
+ #include "BKE_context.h"
+ #include "BKE_object.h"
+ #include "BKE_screen.h"
-#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */
++
++#include "DEG_depsgraph.h"
++#include "DEG_depsgraph_query.h"
+
+ #include "BIF_gl.h"
+ #include "BIF_glutil.h"
+
+ #include "WM_api.h"
+ #include "WM_types.h"
+
+ #include "ED_keyframing.h"
+ #include "ED_screen.h"
+ #include "ED_view3d.h"
+
+ #include "view3d_intern.h" /* own include */
+
+ /* -------------------------------------------------------------------- */
+ /** \name View Data Access Utilities
+ *
+ * \{ */
+
+ float *ED_view3d_cursor3d_get(Scene *scene, View3D *v3d)
+ {
+ if (v3d && v3d->localvd) return v3d->cursor;
+ else return scene->cursor;
+ }
+
+ Camera *ED_view3d_camera_data_get(View3D *v3d, RegionView3D *rv3d)
+ {
+ /* establish the camera object, so we can default to view mapping if anything is wrong with it */
+ if ((rv3d->persp == RV3D_CAMOB) && v3d->camera && (v3d->camera->type == OB_CAMERA)) {
+ return v3d->camera->data;
+ }
+ else {
+ return NULL;
+ }
+ }
+
+ void ED_view3d_dist_range_get(
+ const View3D *v3d,
+ float r_dist_range[2])
+ {
+ r_dist_range[0] = v3d->grid * 0.001f;
+ r_dist_range[1] = v3d->far * 10.0f;
+ }
+
+ /**
+ * \note copies logic of #ED_view3d_viewplane_get(), keep in sync.
+ */
+ bool ED_view3d_clip_range_get(
++ const Depsgraph *depsgraph,
+ const View3D *v3d, const RegionView3D *rv3d,
+ float *r_clipsta, float *r_clipend,
+ const bool use_ortho_factor)
+ {
+ CameraParams params;
+
+ BKE_camera_params_init(¶ms);
- BKE_camera_params_from_view3d(¶ms, v3d, rv3d);
++ BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d);
+
+ if (use_ortho_factor && params.is_ortho) {
+ const float fac = 2.0f / (params.clipend - params.clipsta);
+ params.clipsta *= fac;
+ params.clipend *= fac;
+ }
+
+ if (r_clipsta) *r_clipsta = params.clipsta;
+ if (r_clipend) *r_clipend = params.clipend;
+
+ return params.is_ortho;
+ }
+
+ bool ED_view3d_viewplane_get(
++ const Depsgraph *depsgraph,
+ const View3D *v3d, const RegionView3D *rv3d, int winx, int winy,
+ rctf *r_viewplane, float *r_clipsta, float *r_clipend, float *r_pixsize)
+ {
+ CameraParams params;
+
+ BKE_camera_params_init(¶ms);
- BKE_camera_params_from_view3d(¶ms, v3d, rv3d);
++ BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d);
+ BKE_camera_params_compute_viewplane(¶ms, winx, winy, 1.0f, 1.0f);
+
+ if (r_viewplane) *r_viewplane = params.viewplane;
+ if (r_clipsta) *r_clipsta = params.clipsta;
+ if (r_clipend) *r_clipend = params.clipend;
+ if (r_pixsize) *r_pixsize = params.viewdx;
+
+ return params.is_ortho;
+ }
+
+ /** \} */
+
+
+ /* -------------------------------------------------------------------- */
+ /** \name View State/Context Utilities
+ *
+ * \{ */
+
+ /**
+ * Use instead of: ``bglPolygonOffset(rv3d->dist, ...)`` see bug [#37727]
+ */
+ void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist)
+ {
+ float viewdist;
+
+ if (rv3d->rflag & RV3D_ZOFFSET_DISABLED) {
+ return;
+ }
+
+ viewdist = rv3d->dist;
+
+ /* special exception for ortho camera (viewdist isnt used for perspective cameras) */
+ if (dist != 0.0f) {
+ if (rv3d->persp == RV3D_CAMOB) {
+ if (rv3d->is_persp == false) {
+ viewdist = 1.0f / max_ff(fabsf(rv3d->winmat[0][0]), fabsf(rv3d->winmat[1][1]));
+ }
+ }
+ }
+
+ bglPolygonOffset(viewdist, dist);
+ }
+
+ bool ED_view3d_context_activate(bContext *C)
+ {
+ bScreen *sc = CTX_wm_screen(C);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar;
+
+ /* sa can be NULL when called from python */
+ if (sa == NULL || sa->spacetype != SPACE_VIEW3D) {
+ sa = BKE_screen_find_big_area(sc, SPACE_VIEW3D, 0);
+ }
+
+ if (sa == NULL) {
+ return false;
+ }
+
+ ar = BKE_area_find_region_active_win(sa);
+ if (ar == NULL) {
+ return false;
+ }
+
+ /* bad context switch .. */
+ CTX_wm_area_set(C, sa);
+ CTX_wm_region_set(C, ar);
+
+ return true;
+ }
+
+ /** \} */
+
+ /* -------------------------------------------------------------------- */
+ /** \name View Clipping Utilities
+ *
+ * \{ */
++
+ void ED_view3d_clipping_calc_from_boundbox(float clip[4][4], const BoundBox *bb, const bool is_flip)
+ {
+ int val;
+
+ for (val = 0; val < 4; val++) {
+ normal_tri_v3(clip[val], bb->vec[val], bb->vec[val == 3 ? 0 : val + 1], bb->vec[val + 4]);
+ if (UNLIKELY(is_flip)) {
+ negate_v3(clip[val]);
+ }
+
+ clip[val][3] = -dot_v3v3(clip[val], bb->vec[val]);
+ }
+ }
+
-void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect)
++void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], const ARegion *ar, const Object *ob, const rcti *rect)
+ {
- float modelview[4][4];
- double xs, ys, p[3];
- int val, flip_sign, a;
-
- /* near zero floating point values can give issues with gluUnProject
- * in side view on some implementations */
- if (fabs(mats->modelview[0]) < 1e-6) mats->modelview[0] = 0.0;
- if (fabs(mats->modelview[5]) < 1e-6) mats->modelview[5] = 0.0;
-
- /* Set up viewport so that gluUnProject will give correct values */
- mats->viewport[0] = 0;
- mats->viewport[1] = 0;
++ /* init in case unproject fails */
++ memset(bb->vec, 0, sizeof(bb->vec));
+
+ /* four clipping planes and bounding volume */
+ /* first do the bounding volume */
- for (val = 0; val < 4; val++) {
- xs = (val == 0 || val == 3) ? rect->xmin : rect->xmax;
- ys = (val == 0 || val == 1) ? rect->ymin : rect->ymax;
++ for (int val = 0; val < 4; val++) {
++ float xs = (val == 0 || val == 3) ? rect->xmin : rect->xmax;
++ float ys = (val == 0 || val == 1) ? rect->ymin : rect->ymax;
+
- gluUnProject(xs, ys, 0.0, mats->modelview, mats->projection, mats->viewport, &p[0], &p[1], &p[2]);
- copy_v3fl_v3db(bb->vec[val], p);
++ ED_view3d_unproject(ar, xs, ys,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list