[Bf-blender-cvs] [0050d6d3990] master: Cleanup: move function to file where it is used
Germano Cavalcante
noreply at git.blender.org
Fri Jan 27 18:09:56 CET 2023
Commit: 0050d6d39906649159a3d8f0bb95b3fc60dd2da7
Author: Germano Cavalcante
Date: Fri Jan 27 14:10:43 2023 -0300
Branches: master
https://developer.blender.org/rB0050d6d39906649159a3d8f0bb95b3fc60dd2da7
Cleanup: move function to file where it is used
`drawLine` is only used for constraint, so it should be in
`transform_constraints.c`
===================================================================
M source/blender/editors/transform/transform.h
M source/blender/editors/transform/transform_constraints.c
M source/blender/editors/transform/transform_generics.c
===================================================================
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 637e4ef3b6e..82ab9039db5 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -809,8 +809,6 @@ void postTrans(struct bContext *C, TransInfo *t);
void resetTransModal(TransInfo *t);
void resetTransRestrictions(TransInfo *t);
-void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options);
-
/* DRAWLINE options flags */
#define DRAWLIGHT 1
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index f8e116e77b8..095c59f783b 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -735,6 +735,61 @@ void setUserConstraint(TransInfo *t, int mode, const char text_[])
/** \name Drawing Constraints
* \{ */
+static void drawLine(
+ TransInfo *t, const float center[3], const float dir[3], char axis, short options)
+{
+ if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_SEQ)) {
+ return;
+ }
+
+ float v1[3], v2[3], v3[3];
+ uchar col[3], col2[3];
+
+ if (t->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = t->view;
+
+ copy_v3_v3(v3, dir);
+ mul_v3_fl(v3, v3d->clip_end);
+
+ sub_v3_v3v3(v2, center, v3);
+ add_v3_v3v3(v1, center, v3);
+ }
+ else if (t->spacetype == SPACE_SEQ) {
+ View2D *v2d = t->view;
+
+ copy_v3_v3(v3, dir);
+ float max_dist = max_ff(BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur));
+ mul_v3_fl(v3, max_dist);
+
+ sub_v3_v3v3(v2, center, v3);
+ add_v3_v3v3(v1, center, v3);
+ }
+
+ GPU_matrix_push();
+
+ if (options & DRAWLIGHT) {
+ col[0] = col[1] = col[2] = 220;
+ }
+ else {
+ UI_GetThemeColor3ubv(TH_GRID, col);
+ }
+ UI_make_axis_color(col, col2, axis);
+
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+ immUniformColor3ubv(col2);
+
+ immBegin(GPU_PRIM_LINES, 2);
+ immVertex3fv(pos, v1);
+ immVertex3fv(pos, v2);
+ immEnd();
+
+ immUnbindProgram();
+
+ GPU_matrix_pop();
+}
+
void drawConstraint(TransInfo *t)
{
TransCon *tc = &(t->con);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index f09c919c8b7..53e346ee86a 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -55,60 +55,6 @@
/* ************************** GENERICS **************************** */
-void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)
-{
- if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_SEQ)) {
- return;
- }
-
- float v1[3], v2[3], v3[3];
- uchar col[3], col2[3];
-
- if (t->spacetype == SPACE_VIEW3D) {
- View3D *v3d = t->view;
-
- copy_v3_v3(v3, dir);
- mul_v3_fl(v3, v3d->clip_end);
-
- sub_v3_v3v3(v2, center, v3);
- add_v3_v3v3(v1, center, v3);
- }
- else if (t->spacetype == SPACE_SEQ) {
- View2D *v2d = t->view;
-
- copy_v3_v3(v3, dir);
- float max_dist = max_ff(BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur));
- mul_v3_fl(v3, max_dist);
-
- sub_v3_v3v3(v2, center, v3);
- add_v3_v3v3(v1, center, v3);
- }
-
- GPU_matrix_push();
-
- if (options & DRAWLIGHT) {
- col[0] = col[1] = col[2] = 220;
- }
- else {
- UI_GetThemeColor3ubv(TH_GRID, col);
- }
- UI_make_axis_color(col, col2, axis);
-
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- immUniformColor3ubv(col2);
-
- immBegin(GPU_PRIM_LINES, 2);
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
- immEnd();
-
- immUnbindProgram();
-
- GPU_matrix_pop();
-}
-
void resetTransModal(TransInfo *t)
{
freeTransCustomDataForMode(t);
More information about the Bf-blender-cvs
mailing list