diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-09-20 08:56:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-09-20 08:56:24 +0400 |
commit | edb78d090cca36110290f8f37d27767d75894a1a (patch) | |
tree | 792844cfe7e78cbf8a679328a742ae4fee73fab4 /source/blender/editors/include/ED_view3d.h | |
parent | f169643d46ce05d1ac1054d15e280e15b8d78abc (diff) |
code cleanup:
- make view3d project names more consistent.
- remove apply_project_float() its not needed.
- update comments referencing an old function name.
- move doxygen docs into the C file, prefer they are kept here to avoid getting out of sync with code.
Diffstat (limited to 'source/blender/editors/include/ED_view3d.h')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 131 |
1 files changed, 19 insertions, 112 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index b1bccfa32c5..9536dd76581 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -89,139 +89,45 @@ float *give_cursor(struct Scene *scene, struct View3D *v3d); int initgrabz(struct RegionView3D *rv3d, float x, float y, float z); -/** - * Calculate a 3d location from 2d window coordinates. - * \param ar The region (used for the window width and height). - * \param depth_pt The reference location used to calculate the Z depth. - * \param mval The area relative location (such as event->mval converted to floats). - * \param out The resulting world-space location. - */ void ED_view3d_win_to_3d(struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]); - -/** - * Calculate a 3d difference vector from 2d window offset. - * note that initgrabz() must be called first to determine - * the depth used to calculate the delta. - * \param ar The region (used for the window width and height). - * \param mval The area relative 2d difference (such as event->mval[0] - other_x). - * \param out The resulting world-space delta. - */ void ED_view3d_win_to_delta(struct ARegion *ar, const float mval[2], float out[3]); - -/** - * Calculate a 3d direction vector from 2d window coordinates. - * This direction vector starts and the view in the direction of the 2d window coordinates. - * In orthographic view all window coordinates yield the same vector. - * \param ar The region (used for the window width and height). - * \param mval The area relative 2d location (such as event->mval converted to floats). - * \param out The resulting normalized world-space direction vector. - */ void ED_view3d_win_to_vector(struct ARegion *ar, const float mval[2], float out[3]); - -/** - * Calculate a 3d segment from 2d window coordinates. - * This ray_start is located at the viewpoint, ray_end is a far point. - * ray_start and ray_end are clipped by the view near and far limits - * so points along this line are always in view. - * In orthographic view all resulting segments will be parallel. - * \param ar The region (used for the window width and height). - * \param v3d The 3d viewport (used for near and far clipping range). - * \param mval The area relative 2d location (such as event->mval, converted into float[2]). - * \param ray_start The world-space starting point of the segment. - * \param ray_end The world-space end point of the segment. - */ void ED_view3d_win_to_segment_clip(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); - -/** - * Calculate a 3d viewpoint and direction vector from 2d window coordinates. - * This ray_start is located at the viewpoint, ray_normal is the direction towards mval. - * ray_start is clipped by the view near limit so points in front of it are always in view. - * In orthographic view the resulting ray_normal will match the view vector. - * \param ar The region (used for the window width and height). - * \param v3d The 3d viewport (used for near clipping value). - * \param mval The area relative 2d location (such as event->mval, converted into float[2]). - * \param ray_start The world-space starting point of the segment. - * \param ray_normal The normalized world-space direction of towards mval. - */ void ED_view3d_win_to_ray(struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3]); -/** - * Calculate a normalized 3d direction vector from the viewpoint towards a global location. - * In orthographic view the resulting vector will match the view vector. - * \param rv3d The region (used for the window width and height). - * \param coord The world-space location. - * \param vec The resulting normalized vector. - */ void ED_view3d_global_to_vector(struct RegionView3D *rv3d, const float coord[3], float vec[3]); - -/** - * Calculate the view transformation matrix from RegionView3D input. - * The resulting matrix is equivalent to RegionView3D.viewinv - * \param mat The view 4x4 transformation matrix to calculate. - * \param ofs The view offset, normally from RegionView3D.ofs. - * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. - * \param dist The view distance from ofs, normally from RegionView3D.dist. - */ void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist); - -/** - * Set the view transformation from a 4x4 matrix. - * \param mat The view 4x4 transformation matrix to assign. - * \param ofs The view offset, normally from RegionView3D.ofs. - * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. - * \param dist The view distance from ofs, normally from RegionView3D.dist. - */ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist); -/** - * Set the RegionView3D members from an objects transformation and optionally lens. - * \param ob The object to set the view to. - * \param ofs The view offset to be set, normally from RegionView3D.ofs. - * \param quat The view rotation to be set, quaternion normally from RegionView3D.viewquat. - * \param dist The view distance from ofs to be set, normally from RegionView3D.dist. - * \param lens The view lens angle set for cameras and lamps, normally from View3D.lens. - */ void ED_view3d_from_object(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens); - -/** - * Set the object transformation from RegionView3D members. - * \param ob The object which has the transformation assigned. - * \param ofs The view offset, normally from RegionView3D.ofs. - * \param quat The view rotation, quaternion normally from RegionView3D.viewquat. - * \param dist The view distance from ofs, normally from RegionView3D.dist. - */ void ED_view3d_to_object(struct Object *ob, const float ofs[3], const float quat[4], const float dist); -//#if 0 /* UNUSED */ -void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z); -//#endif - /* Depth buffer */ -void ED_view3d_depth_update(struct ARegion *ar); +void ED_view3d_depth_update(struct ARegion *ar); float ED_view3d_depth_read_cached(struct ViewContext *vc, int x, int y); -void ED_view3d_depth_tag_update(struct RegionView3D *rv3d); +void ED_view3d_depth_tag_update(struct RegionView3D *rv3d); /* Projection */ #define IS_CLIPPED 12000 -void ED_view3d_calc_clipping(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect); - -void project_short(struct ARegion *ar, const float vec[3], short adr[2]); -void project_short_noclip(struct ARegion *ar, const float vec[3], short adr[2]); - -void project_int(struct ARegion *ar, const float vec[3], int adr[2]); -void project_int_noclip(struct ARegion *ar, const float vec[3], int adr[2]); - -void apply_project_float(float persmat[4][4], int winx, int winy, const float vec[], float adr[2]); -void project_float(struct ARegion *ar, const float vec[3], float adr[2]); -void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]); - -int ED_view3d_clip_range_get(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); -int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend); +/* 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]); +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]); +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]); +void ED_view3d_project_float_v3_m4(struct ARegion *a, const float co[3], float r_co[3], float mat[4][4]); + +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); +int ED_view3d_viewplane_get(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend); void ED_view3d_ob_project_mat_get(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); void ED_view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, struct rctf *viewborder_r, short no_shift); -void ED_view3d_project_float_v2(const struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]); -void ED_view3d_project_float_v3(struct ARegion *a, const float vec[3], float adr[3], float mat[4][4]); void ED_view3d_calc_camera_border_size(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, struct RegionView3D *rv3d, float size_r[2]); /* drawobject.c iterators */ @@ -231,6 +137,7 @@ void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, int x, int y), void *userData); void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData); +void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect); void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]); int ED_view3d_clipping_test(struct RegionView3D *rv3d, const float vec[3], const int is_local); void ED_view3d_clipping_set(struct RegionView3D *rv3d); |