|
Blender
V2.93
|
#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "DNA_object_types.h"#include "DNA_scene_types.h"#include "DNA_screen_types.h"#include "DNA_space_types.h"#include "DNA_view3d_types.h"#include "GPU_immediate.h"#include "GPU_matrix.h"#include "GPU_state.h"#include "BLI_math.h"#include "BLI_rect.h"#include "BLI_string.h"#include "BLI_utildefines.h"#include "BKE_context.h"#include "ED_view3d.h"#include "BLT_translation.h"#include "UI_resources.h"#include "transform.h"#include "transform_orientations.h"#include "transform_snap.h"#include "transform_constraints.h"Go to the source code of this file.
Functions | |
Drawing Constraints | |
| static void | drawObjectConstraint (TransInfo *t) |
| void | drawConstraint (TransInfo *t) |
| void | drawPropCircle (const struct bContext *C, TransInfo *t) |
Internal Setup Calls | |
| void | setConstraint (TransInfo *t, int mode, const char text[]) |
| void | setAxisMatrixConstraint (TransInfo *t, int mode, const char text[]) |
| void | setLocalConstraint (TransInfo *t, int mode, const char text[]) |
| void | setUserConstraint (TransInfo *t, int mode, const char ftext[]) |
Start / Stop Constraints | |
| void | startConstraint (TransInfo *t) |
| void | stopConstraint (TransInfo *t) |
Middle Mouse Button Select | |
| void | initSelectConstraint (TransInfo *t) |
| void | selectConstraint (TransInfo *t) |
| void | postSelectConstraint (TransInfo *t) |
| static void | setNearestAxis2d (TransInfo *t) |
| static void | setNearestAxis3d (TransInfo *t) |
| void | setNearestAxis (TransInfo *t) |
Helper Functions | |
| int | constraintModeToIndex (const TransInfo *t) |
| bool | isLockConstraint (TransInfo *t) |
| int | getConstraintSpaceDimension (TransInfo *t) |
| #define CONSTRAIN_EPSILON 0.0001f |
Definition at line 98 of file transform_constraints.c.
|
static |
Generic callback for constant spatial constraints applied to rotations
The rotation axis is copied into vec.
In the case of single axis constraints, the rotation axis is directly the one constrained to. For planar constraints (2 axis), the rotation axis is the normal of the plane.
The following only applies when CON_NOFLIP is not set. The vector is then modified to always point away from the screen (in global space) This insures that the rotation is always logically following the mouse. (ie: not doing counterclockwise rotations when the mouse moves clockwise).
Definition at line 598 of file transform_constraints.c.
References angle(), CON_APPLY, constraints_rotation_impl(), and t.
Referenced by setConstraint().
|
static |
Generic callback for constant spatial constraints applied to resize motion.
Definition at line 497 of file transform_constraints.c.
References CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, mul_m3_m3m3(), and t.
Referenced by setConstraint().
|
static |
Generic callback for constant spatial constraints applied to linear motion
The in vector in projected into the constrained space and then further projected along the view vector. (in perspective mode, the view vector is relative to the position on screen)
Definition at line 394 of file transform_constraints.c.
References activeSnap(), axisProjection(), BLI_assert, Freestyle::c, CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, constraint_plane_calc(), constraint_snap_plane_to_edge(), copy_v3_v3(), getConstraintSpaceDimension(), is_zero_v3(), isPlaneProjectionViewAligned(), mul_m3_v3(), planeProjection(), SCE_SNAP_MODE_EDGE, SCE_SNAP_MODE_FACE, SCE_SNAP_MODE_GRID, t, transform_constraint_snap_axis_to_edge(), transform_constraint_snap_axis_to_face(), and validSnap().
Referenced by applyObjectConstraintVec(), and setConstraint().
|
static |
Callback for object based spatial constraints applied to rotations
The rotation axis is copied into vec.
In the case of single axis constraints, the rotation axis is directly the one constrained to. For planar constraints (2 axis), the rotation axis is the normal of the plane.
The following only applies when CON_NOFLIP is not set. The vector is then modified to always point away from the screen (in global space) This insures that the rotation is always logically following the mouse. (ie: not doing counterclockwise rotations when the mouse moves clockwise).
Definition at line 619 of file transform_constraints.c.
References angle(), TransData::axismtx, BLI_assert, CON_APPLY, constraints_rotation_impl(), TransDataContainer::data, float(), TransDataContainer::mat3_unit, mul_m3_m3m3(), NULL, t, T_EDIT, and TRANS_DATA_CONTAINER_FIRST_OK.
Referenced by setAxisMatrixConstraint().
|
static |
Callback for object based spatial constraints applied to resize motion.
Definition at line 523 of file transform_constraints.c.
References TransData::axismtx, CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, invert_m3_m3(), TransDataContainer::mat3_unit, mul_m3_m3m3(), t, and T_EDIT.
Referenced by setAxisMatrixConstraint().
|
static |
Generic callback for object based spatial constraints applied to linear motion
At first, the following is applied without orientation The IN vector in projected into the constrained space and then further projected along the view vector. (in perspective mode, the view vector is relative to the position on screen).
Further down, that vector is mapped to each data's space.
Definition at line 475 of file transform_constraints.c.
References applyAxisConstraintVec(), TransData::axismtx, CON_APPLY, copy_v3_v3(), TransDataContainer::mat3_unit, mul_m3_v3(), t, and T_EDIT.
Referenced by setAxisMatrixConstraint().
|
static |
Axis calculation taking the view into account, correcting view-aligned axis.
Definition at line 191 of file transform_constraints.c.
References add_v3_v3v3(), angle(), angle_v3v3(), BLI_assert, copy_v3_v3(), cross_v3_v3v3(), DEG2RADF, dot_v3v3(), fabsf, float(), is_zero_v3(), isect_ray_ray_v3(), CCL_NAMESPACE_BEGIN::isfinite(), M_PI, M_PI_2, mul(), mul_v3_fl(), mul_v3_v3fl(), norm(), normalize_v3_v3_length(), NULL, project_v3_v3v3(), sub_v3_v3v3(), t, v, view_vector_calc(), and viewAxisCorrectCenter().
Referenced by applyAxisConstraintVec().
Definition at line 100 of file transform_constraints.c.
References BLI_assert, CON_AXIS0, cross_v3_v3v3(), dot_v3v3(), normalize_v3(), and t.
Referenced by applyAxisConstraintVec().
|
static |
Snap to the intersection between the edge direction and the constraint plane.
Definition at line 286 of file transform_constraints.c.
References CONSTRAIN_EPSILON, dot_v3v3(), fabsf, blender::tests::is_aligned(), isect_ray_plane_v3(), madd_v3_v3v3fl(), sub_v3_v3(), and t.
Referenced by applyAxisConstraintVec().
| int constraintModeToIndex | ( | const TransInfo * | t | ) |
Definition at line 1121 of file transform_constraints.c.
References CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, and t.
Referenced by saveTransform().
Definition at line 119 of file transform_constraints.c.
References CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, getConstraintSpaceDimension(), t, and T_NULL_ONE.
Referenced by applyBoneSize(), applyResize(), and applySkinResize().
|
static |
Definition at line 552 of file transform_constraints.c.
References BLI_assert, CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, CON_NOFLIP, copy_v3_v3(), dot_v3v3(), hasNumInput(), t, T_INPUT_IS_VALUES_FINAL, and view_vector_calc().
Referenced by applyAxisConstraintRot(), and applyObjectConstraintRot().
| void drawConstraint | ( | TransInfo * | t | ) |
Definition at line 742 of file transform_constraints.c.
References add_v3_v3(), CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, CON_SELECT, convertViewVec(), TransCon::drawExtra, DRAWLIGHT, drawLine(), ELEM, GPU_COMP_F32, GPU_DEPTH_LESS_EQUAL, GPU_DEPTH_NONE, GPU_depth_test(), GPU_depth_test_get(), GPU_FETCH_FLOAT, GPU_PRIM_LINES, GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR, GPU_vertformat_attr_add(), GPU_viewport_size_get_f(), immBegin(), immBindBuiltinProgram(), immEnd(), immUnbindProgram(), immUniform1f(), immUniform1i(), immUniform2f(), immUniformColor4f(), immVertex3fv(), immVertexFormat(), TransCon::mode, SPACE_IMAGE, SPACE_NODE, SPACE_VIEW3D, t, and T_NO_CONSTRAINT.
Referenced by drawTransformView().
|
static |
Definition at line 881 of file transform_constraints.c.
References TransData::axismtx, CON_AXIS0, CON_AXIS1, CON_AXIS2, copy_v3_v3(), CTX_GPENCIL_STROKES, CTX_POSE_BONE, DRAWLIGHT, drawLine(), TransData::factor, float(), FOREACH_TRANS_DATA_CONTAINER, mul_m3_m3m3(), mul_v3_m4v3(), options, t, T_EDIT, and T_PROP_EDIT.
Referenced by setAxisMatrixConstraint().
Definition at line 814 of file transform_constraints.c.
References BLI_rctf_size_x(), BLI_rctf_size_y(), BLI_rcti_size_x(), BLI_rcti_size_y(), C, copy_m4_m4(), CTX_wm_region_view3d(), ELEM, GPU_blend(), GPU_BLEND_ALPHA, GPU_COMP_F32, GPU_DEPTH_LESS_EQUAL, GPU_DEPTH_NONE, GPU_depth_test(), GPU_depth_test_get(), GPU_FETCH_FLOAT, GPU_matrix_pop(), GPU_matrix_push(), GPU_matrix_scale_2f(), GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR, GPU_vertformat_attr_add(), GPU_viewport_size_get_f(), imm_drawcircball(), immBindBuiltinProgram(), immUnbindProgram(), immUniform1f(), immUniform2fv(), immUniformThemeColorShadeAlpha(), immVertexFormat(), invert_m4_m4(), mask(), NULL, pos, SPACE_ACTION, SPACE_GRAPH, SPACE_IMAGE, SPACE_VIEW3D, t, T_PROP_EDIT, TH_GRID, unit_m4(), and RegionView3D::viewmat.
Referenced by drawTransformView().
| int getConstraintSpaceDimension | ( | TransInfo * | t | ) |
Returns the dimension of the constraint space.
For that reason, the flags always needs to be set to properly evaluate here, even if they aren't actually used in the callback function. (Which could happen for weird constraints not yet designed. Along a path for example.)
Definition at line 1167 of file transform_constraints.c.
References CON_AXIS0, CON_AXIS1, CON_AXIS2, and t.
Referenced by applyAxisConstraintVec(), constraintNumInput(), and startConstraint().
| void initSelectConstraint | ( | TransInfo * | t | ) |
Definition at line 971 of file transform_constraints.c.
References CON_APPLY, CON_SELECT, setUserConstraint(), t, and transform_orientations_current_set().
Referenced by transformEvent().
| bool isLockConstraint | ( | TransInfo * | t | ) |
Definition at line 1141 of file transform_constraints.c.
References CON_AXIS0, CON_AXIS1, CON_AXIS2, and t.
Referenced by applyPushPull().
Return true if the 2x axis are both aligned when projected into the view. In this case, we can't usefully project the cursor onto the plane.
Definition at line 356 of file transform_constraints.c.
References dot_v3v3(), eps, fabsf, t, and view_vector_calc().
Referenced by applyAxisConstraintVec().
Definition at line 366 of file transform_constraints.c.
References add_v3_v3v3(), copy_v3_v3(), dot_v3v3(), mul_v3_fl(), norm(), sub_v3_v3v3(), t, and view_vector_calc().
Referenced by applyAxisConstraintVec().
| void postSelectConstraint | ( | TransInfo * | t | ) |
Definition at line 988 of file transform_constraints.c.
References CON_AXIS0, CON_AXIS1, CON_AXIS2, CON_SELECT, setNearestAxis(), startConstraint(), t, and TREDRAW_HARD.
Referenced by transformEvent().
Definition at line 65 of file transform_constraints.c.
References CON_AXIS0, CON_AXIS1, CON_AXIS2, mul_m3_m3m3(), t, unit_m3(), and zero_v3().
Referenced by setAxisMatrixConstraint(), setConstraint(), and setNearestAxis().
| void selectConstraint | ( | TransInfo * | t | ) |
Definition at line 980 of file transform_constraints.c.
References CON_SELECT, setNearestAxis(), startConstraint(), and t.
Referenced by transformApply().
| void setAxisMatrixConstraint | ( | TransInfo * | t, |
| int | mode, | ||
| const char | text[] | ||
| ) |
Definition at line 667 of file transform_constraints.c.
References applyObjectConstraintRot(), applyObjectConstraintSize(), applyObjectConstraintVec(), BLI_strncpy(), drawObjectConstraint(), projection_matrix_calc(), startConstraint(), t, and TREDRAW_HARD.
Referenced by setLocalConstraint(), and setUserConstraint().
| void setConstraint | ( | TransInfo * | t, |
| int | mode, | ||
| const char | text[] | ||
| ) |
Definition at line 651 of file transform_constraints.c.
References applyAxisConstraintRot(), applyAxisConstraintSize(), applyAxisConstraintVec(), BLI_strncpy(), NULL, projection_matrix_calc(), startConstraint(), t, and TREDRAW_HARD.
Referenced by setLocalConstraint(), and setUserConstraint().
| void setLocalConstraint | ( | TransInfo * | t, |
| int | mode, | ||
| const char | text[] | ||
| ) |
Definition at line 682 of file transform_constraints.c.
References setAxisMatrixConstraint(), setConstraint(), t, and T_EDIT.
Referenced by setUserConstraint(), and transformEvent().
| void setNearestAxis | ( | TransInfo * | t | ) |
Definition at line 1095 of file transform_constraints.c.
References CON_AXIS0, CON_AXIS1, CON_AXIS2, projection_matrix_calc(), setNearestAxis2d(), setNearestAxis3d(), SPACE_VIEW3D, and t.
Referenced by postSelectConstraint(), and selectConstraint().
|
static |
Definition at line 1005 of file transform_constraints.c.
References abs(), BLI_strncpy(), CON_AXIS0, CON_AXIS1, t, and TIP_.
Referenced by setNearestAxis().
|
static |
Definition at line 1018 of file transform_constraints.c.
References add_v3_v3(), BLI_snprintf(), CON_AXIS0, CON_AXIS1, CON_AXIS2, copy_v3_v3(), float(), len, len_v3(), MOD_CONSTRAINT_SELECT_PLANE, mul_project_m4_v3_zfac(), mul_v3_fl(), normalize_v3(), project_v3_v3v3(), projectFloatView(), sub_v2_v2v2(), sub_v3_v3v3(), t, and TIP_.
Referenced by setNearestAxis().
| void setUserConstraint | ( | TransInfo * | t, |
| int | mode, | ||
| const char | ftext[] | ||
| ) |
Set the constraint according to the user defined orientation
ftext is a format string passed to BLI_snprintf. It will add the name of the orientation where s is (logically).
Definition at line 700 of file transform_constraints.c.
References ATTR_FALLTHROUGH, BLI_snprintf(), checkUseAxisMatrix(), CON_USER, setAxisMatrixConstraint(), setConstraint(), setLocalConstraint(), t, transform_orientations_spacename_get(), V3D_ORIENT_CURSOR, V3D_ORIENT_CUSTOM, V3D_ORIENT_CUSTOM_MATRIX, V3D_ORIENT_GIMBAL, V3D_ORIENT_GLOBAL, V3D_ORIENT_LOCAL, V3D_ORIENT_NORMAL, and V3D_ORIENT_VIEW.
Referenced by initSelectConstraint(), initTransform(), and transform_event_modal_constraint().
| void startConstraint | ( | TransInfo * | t | ) |
Definition at line 947 of file transform_constraints.c.
References CON_APPLY, getConstraintSpaceDimension(), min_ii(), and t.
Referenced by postSelectConstraint(), InplaceSolverIslandCallback::processIsland(), MultiBodyInplaceSolverIslandCallback::processIsland(), selectConstraint(), setAxisMatrixConstraint(), and setConstraint().
| void stopConstraint | ( | TransInfo * | t | ) |
Definition at line 954 of file transform_constraints.c.
References CON_APPLY, CON_SELECT, t, and transform_orientations_current_set().
Referenced by transform_event_modal_constraint(), and transformEvent().
| void transform_constraint_snap_axis_to_edge | ( | const TransInfo * | t, |
| const float | axis[3], | ||
| float | r_out[3] | ||
| ) |
Snap to the nearest point on the axis to the edge/line element.
Definition at line 320 of file transform_constraints.c.
References CONSTRAIN_EPSILON, dot_v3v3(), fabsf, blender::tests::is_aligned(), isect_ray_ray_v3(), mul_v3_v3fl(), NULL, and t.
Referenced by applyAxisConstraintVec(), edge_slide_snap_apply(), and vert_slide_snap_apply().
| void transform_constraint_snap_axis_to_face | ( | const TransInfo * | t, |
| const float | axis[3], | ||
| float | r_out[3] | ||
| ) |
Snap to the intersection of the axis and the plane defined by the face.
Definition at line 337 of file transform_constraints.c.
References CONSTRAIN_EPSILON, dot_v3v3(), fabsf, blender::tests::is_aligned(), isect_ray_plane_v3(), mul_v3_v3fl(), plane_from_point_normal_v3(), and t.
Referenced by applyAxisConstraintVec(), edge_slide_snap_apply(), and vert_slide_snap_apply().
|
static |
Snap to the nearest point between the snap point and the line that intersects the face plane with the constraint plane.
Definition at line 302 of file transform_constraints.c.
References closest_to_ray_v3(), CONSTRAIN_EPSILON, dot_v3v3(), fabsf, blender::tests::is_aligned(), isect_plane_plane_v3(), plane_from_point_normal_v3(), sub_v3_v3(), and t.
Definition at line 86 of file transform_constraints.c.
References copy_v3_v3(), normalize_v3(), RV3D_ORTHO, sub_v3_v3v3(), and t.
Referenced by axisProjection(), constraints_rotation_impl(), isPlaneProjectionViewAligned(), and planeProjection().
Definition at line 164 of file transform_constraints.c.
References KDL::diff(), dot_v3v3(), l, len_v3(), negate_v3(), normalize_v3_v3_length(), project_v3_v3v3(), SPACE_VIEW3D, sub_v3_v3(), sub_v3_v3v3(), and t.
Referenced by axisProjection().