diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-10-04 20:46:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-10-04 20:46:15 +0400 |
commit | 709903c6bba4dca12a6f367000f99a83da2af034 (patch) | |
tree | d6b84b215f9b84eb4b6ac4a828af59683c03588e /source/blender/editors/include/ED_view3d.h | |
parent | 794520a86a83a9eea230563e805480016c0479f0 (diff) |
refactor ED_view3d_project_short & ED_view3d_project_short_noclip,
This is apart of a code cleanup to make ED_view3d_project_short/ED_view3d_project_int/ED_view3d_project_float interchangeable. Currently they work very differently in a way thats quite confusing (and cause of bugs in blender that remain uncorrected) - fixes coming.
There are also cases where ED_view3d_project_short is used, then the values are converted from shorts into int's after because ED_view3d_project_int() behaves differently, will unify behavior of these functions after this commit.
- rather then clip/noclip versions, pass flags (for bound-box clip, window clip).
- rather then store the invalid clip-value, return success (or error value clip_near, clip_bb, clip_win, overflow).
- remove local copies of project functions from drawobject.c: view3d_project_short_clip, view3d_project_short_noclip, view3d_project_short_clip_persmat.
add functions:
- ED_view3d_project_short_global() global space projection
- ED_view3d_project_short_object() object space projection.
- ED_view3d_project_short_ex() take perspective matrix and local space option as args.
- ED_view3d_project_base() - special function to set the Object 'Base' screen coords (sx, sy), since this is a common enough operation.
Diffstat (limited to 'source/blender/editors/include/ED_view3d.h')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 9536dd76581..ca5d8691df7 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -113,8 +113,31 @@ void ED_view3d_depth_tag_update(struct RegionView3D *rv3d); /* TODO, these functions work quite differently, we should make them behave in a uniform way * otherwise we can't be sure bugs are not added when we need to move from short->float types for eg * - Campbell */ -void ED_view3d_project_short(struct ARegion *ar, const float co[3], short r_co[2]); -void ED_view3d_project_short_noclip(struct ARegion *ar, const float vec[3], short r_co[2]); + + +/* return values for ED_view3d_project_...() */ +typedef enum { + V3D_PROJ_RET_SUCCESS = 0, + V3D_PROJ_RET_CLIP_NEAR = 1, /* can't avoid this when in perspective mode, (can't avoid) */ + V3D_PROJ_RET_CLIP_BB = 2, /* bounding box clip - RV3D_CLIPPING */ + V3D_PROJ_RET_CLIP_WIN = 3, /* outside window bounds */ + V3D_PROJ_RET_OVERFLOW = 4 /* outside range (mainly for short), (can't avoid) */ +} eV3DProjStatus; + +/* some clipping tests are optional */ +typedef enum { + V3D_PROJ_TEST_NOP = 0, + V3D_PROJ_TEST_CLIP_BB = (1 << 0), + V3D_PROJ_TEST_CLIP_WIN = (1 << 1), +} eV3DProjTest; + + +eV3DProjStatus ED_view3d_project_short_ex(struct ARegion *ar, float perspmat[4][4], const int is_local, + const float co[3], short r_co[2], eV3DProjTest flag); +eV3DProjStatus ED_view3d_project_short_global(struct ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag); +eV3DProjStatus ED_view3d_project_short_object(struct ARegion *ar, const float co[3], short r_co[2], eV3DProjTest flag); +void _ED_view3d_project_short(struct ARegion *ar, const float co[3], short r_co[2]); // V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN +void _ED_view3d_project_short_noclip(struct ARegion *ar, const float vec[3], short r_co[2]); // void ED_view3d_project_int(struct ARegion *ar, const float co[3], int r_co[2]); void ED_view3d_project_int_noclip(struct ARegion *ar, const float co[3], int r_co[2]); void ED_view3d_project_float(struct ARegion *ar, const float co[3], float r_co[2]); @@ -122,6 +145,9 @@ void ED_view3d_project_float_noclip(struct ARegion *ar, const float co[3], float void ED_view3d_project_float_v2_m4(const struct ARegion *a, const float co[3], float r_co[2], float mat[4][4]); void ED_view3d_project_float_v3_m4(struct ARegion *a, const float co[3], float r_co[3], float mat[4][4]); +/* Base's get their own function since its a common operation */ +eV3DProjStatus ED_view3d_project_base(struct ARegion *ar, struct Base *base); + void ED_view3d_unproject(struct bglMats *mats, float out[3], const float x, const float y, const float z); int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); |