From ea5f2f88b34ef92cfba9619439d8a786e5befcaa Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Thu, 8 Oct 2020 11:42:14 -0300 Subject: Cleanup: Move transform_orientations functions to separate header Improves the organization and identification of the API. --- source/blender/editors/transform/CMakeLists.txt | 1 + source/blender/editors/transform/transform.c | 1 + source/blender/editors/transform/transform.h | 38 ------------- .../editors/transform/transform_constraints.c | 1 + .../editors/transform/transform_convert_curve.c | 1 + .../editors/transform/transform_convert_mesh.c | 1 + .../blender/editors/transform/transform_generics.c | 1 + .../editors/transform/transform_orientations.c | 1 + .../editors/transform/transform_orientations.h | 63 ++++++++++++++++++++++ 9 files changed, 70 insertions(+), 38 deletions(-) create mode 100644 source/blender/editors/transform/transform_orientations.h diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index 59fdf1450b3..5bf8450246b 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -107,6 +107,7 @@ set(SRC transform_data.h transform_draw_cursors.h transform_mode.h + transform_orientations.h transform_snap.h ) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 921b6a24312..e2e7611a6b6 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -65,6 +65,7 @@ #include "transform_convert.h" #include "transform_draw_cursors.h" #include "transform_mode.h" +#include "transform_orientations.h" #include "transform_snap.h" /* Disabling, since when you type you know what you are doing, diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index ed4a2945de6..17ef9a3034f 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -692,44 +692,6 @@ void getViewVector(const TransInfo *t, const float coord[3], float vec[3]); void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot); -/*********************** Transform Orientations ******************************/ -short transform_orientation_matrix_get(struct bContext *C, - TransInfo *t, - short orientation, - const float custom[3][3], - float r_spacemtx[3][3]); -const char *transform_orientations_spacename_get(TransInfo *t, const short orient_type); -void transform_orientations_current_set(struct TransInfo *t, const short orient_index); - -/* Those two fill in mat and return non-zero on success */ -bool createSpaceNormal(float mat[3][3], const float normal[3]); -bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const float tangent[3]); - -struct TransformOrientation *addMatrixSpace(struct bContext *C, - float mat[3][3], - const char *name, - const bool overwrite); -void applyTransformOrientation(const struct TransformOrientation *ts, - float r_mat[3][3], - char r_name[64]); - -enum { - ORIENTATION_NONE = 0, - ORIENTATION_NORMAL = 1, - ORIENTATION_VERT = 2, - ORIENTATION_EDGE = 3, - ORIENTATION_FACE = 4, -}; -#define ORIENTATION_USE_PLANE(ty) ELEM(ty, ORIENTATION_NORMAL, ORIENTATION_EDGE, ORIENTATION_FACE) - -int getTransformOrientation_ex(const struct bContext *C, - struct Object *ob, - struct Object *obedit, - float normal[3], - float plane[3], - const short around); -int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3]); - void freeCustomNormalArray(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data); /* TODO. transform_query.c */ diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index ac27f2cd7aa..3a8f53220e2 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -50,6 +50,7 @@ #include "UI_resources.h" #include "transform.h" +#include "transform_orientations.h" #include "transform_snap.h" /* Own include. */ diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c index 65b2c9f9382..90257b28f55 100644 --- a/source/blender/editors/transform/transform_convert_curve.c +++ b/source/blender/editors/transform/transform_convert_curve.c @@ -36,6 +36,7 @@ /* Own include. */ #include "transform_convert.h" +#include "transform_orientations.h" /* -------------------------------------------------------------------- */ /** \name Curve/Surfaces Transform Creation diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 835781d458f..d40a7168af1 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -50,6 +50,7 @@ /* Own include. */ #include "transform_convert.h" +#include "transform_orientations.h" #define USE_FACE_SUBSTITUTE diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 7ad4efd844f..e3ee6f51a26 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -61,6 +61,7 @@ #include "transform.h" #include "transform_mode.h" +#include "transform_orientations.h" #include "transform_snap.h" /* ************************** Functions *************************** */ diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index eabc5ede993..2173df0f208 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -53,6 +53,7 @@ #include "ED_armature.h" #include "transform.h" +#include "transform_orientations.h" /* *********************** TransSpace ************************** */ diff --git a/source/blender/editors/transform/transform_orientations.h b/source/blender/editors/transform/transform_orientations.h new file mode 100644 index 00000000000..7013501ce12 --- /dev/null +++ b/source/blender/editors/transform/transform_orientations.h @@ -0,0 +1,63 @@ +/* + * 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) 2001-2002 by NaN Holding BV. + * All rights reserved. + */ + +/** \file + * \ingroup edtransform + */ + +#pragma once + +struct TransInfo; + +short transform_orientation_matrix_get(struct bContext *C, + struct TransInfo *t, + short orientation, + const float custom[3][3], + float r_spacemtx[3][3]); +const char *transform_orientations_spacename_get(struct TransInfo *t, const short orient_type); +void transform_orientations_current_set(struct TransInfo *t, const short orient_index); + +/* Those two fill in mat and return non-zero on success */ +bool createSpaceNormal(float mat[3][3], const float normal[3]); +bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const float tangent[3]); + +struct TransformOrientation *addMatrixSpace(struct bContext *C, + float mat[3][3], + const char *name, + const bool overwrite); +void applyTransformOrientation(const struct TransformOrientation *ts, + float r_mat[3][3], + char r_name[64]); + +enum { + ORIENTATION_NONE = 0, + ORIENTATION_NORMAL = 1, + ORIENTATION_VERT = 2, + ORIENTATION_EDGE = 3, + ORIENTATION_FACE = 4, +}; +#define ORIENTATION_USE_PLANE(ty) ELEM(ty, ORIENTATION_NORMAL, ORIENTATION_EDGE, ORIENTATION_FACE) + +int getTransformOrientation_ex(const struct bContext *C, + struct Object *ob, + struct Object *obedit, + float normal[3], + float plane[3], + const short around); +int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3]); -- cgit v1.2.3