Blender
V3.3
|
#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 "UI_view2d.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 (const TransInfo *t) |
int | getConstraintSpaceDimension (const TransInfo *t) |
#define CONSTRAIN_EPSILON 0.0001f |
Definition at line 83 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 601 of file transform_constraints.c.
References CON_APPLY, constraints_rotation_impl(), and t.
Referenced by setConstraint().
|
static |
Generic callback for constant spatial constraints applied to resize motion.
Definition at line 499 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 387 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(), usdtokens::out(), planeProjection(), SCE_SNAP_MODE_EDGE, SCE_SNAP_MODE_FACE_RAYCAST, 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 625 of file transform_constraints.c.
References TransData::axismtx, BLI_assert, CON_APPLY, constraints_rotation_impl(), TransDataContainer::data, float(), TransDataContainer::mat3_unit, mul_m3_m3m3(), NULL, t, T_EDIT, TRANS_DATA_CONTAINER_FIRST_OK, and transform_object_axismtx_get().
Referenced by setAxisMatrixConstraint().
|
static |
Callback for object based spatial constraints applied to resize motion.
Definition at line 525 of file transform_constraints.c.
References CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, float(), invert_m3_m3(), TransDataContainer::mat3_unit, mul_m3_m3m3(), t, T_EDIT, and transform_object_axismtx_get().
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 473 of file transform_constraints.c.
References applyAxisConstraintVec(), CON_APPLY, copy_v3_v3(), float(), TransDataContainer::mat3_unit, mul_m3_v3(), usdtokens::out(), t, T_EDIT, and transform_object_axismtx_get().
Referenced by setAxisMatrixConstraint().
|
static |
Axis calculation taking the view into account, correcting view-aligned axis.
Definition at line 176 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, usdtokens::out(), project_v3_v3v3(), sub_v3_v3v3(), t, v, view_vector_calc(), and viewAxisCorrectCenter().
Referenced by applyAxisConstraintVec().
Definition at line 85 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 271 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 1117 of file transform_constraints.c.
References CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, and t.
Referenced by saveTransform().
Definition at line 104 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 555 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().
Definition at line 739 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_SEQ, SPACE_VIEW3D, t, and T_NO_CONSTRAINT.
Referenced by drawTransformView().
Definition at line 876 of file transform_constraints.c.
References TransData::axismtx, CON_AXIS0, CON_AXIS1, CON_AXIS2, copy_v3_v3(), CTX_GPENCIL_STROKES, CTX_POSE_BONE, CTX_SEQUENCER_IMAGE, DRAWLIGHT, drawLine(), TransData::factor, float(), FOREACH_TRANS_DATA_CONTAINER, mul_m3_m3m3(), mul_v3_m4v3(), options, t, T_EDIT, T_PROP_EDIT, and transform_object_axismtx_get().
Referenced by setAxisMatrixConstraint().
Called from drawview.c, as an extra per-window draw option.
Definition at line 810 of file transform_constraints.c.
References 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_matrix_translate_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(), NULL, pos, SPACE_ACTION, SPACE_GRAPH, SPACE_IMAGE, SPACE_VIEW3D, t, T_PROP_EDIT, TH_GRID, UI_view2d_scale_get(), unit_m4(), and RegionView3D::viewmat.
Referenced by drawTransformView().
int getConstraintSpaceDimension | ( | const 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 1156 of file transform_constraints.c.
References CON_AXIS0, CON_AXIS1, CON_AXIS2, and t.
Referenced by applyAxisConstraintVec(), constraintNumInput(), and startConstraint().
Definition at line 977 of file transform_constraints.c.
References CON_APPLY, CON_SELECT, setUserConstraint(), t, and transform_orientations_current_set().
Referenced by transformEvent().
Definition at line 1137 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 331 of file transform_constraints.c.
References dot_v3v3(), eps, fabsf, t, and view_vector_calc().
Referenced by applyAxisConstraintVec().
|
static |
Definition at line 341 of file transform_constraints.c.
References add_v3_v3v3(), isect_ray_plane_v3(), madd_v3_v3v3fl(), usdtokens::out(), pos, t, and view_vector_calc().
Referenced by applyAxisConstraintVec().
Definition at line 994 of file transform_constraints.c.
References CON_APPLY, CON_AXIS0, CON_AXIS1, CON_AXIS2, CON_SELECT, and t.
Referenced by transformEvent().
Definition at line 50 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().
Definition at line 986 of file transform_constraints.c.
References CON_SELECT, setNearestAxis(), startConstraint(), and t.
Referenced by transformApply().
Applies individual td->axismtx
constraints.
Definition at line 675 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().
Definition at line 660 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().
Definition at line 690 of file transform_constraints.c.
References setAxisMatrixConstraint(), setConstraint(), t, and T_EDIT.
Referenced by setUserConstraint(), and transformEvent().
Definition at line 1091 of file transform_constraints.c.
References CON_AXIS0, CON_AXIS1, CON_AXIS2, projection_matrix_calc(), setNearestAxis2d(), setNearestAxis3d(), SPACE_VIEW3D, and t.
Referenced by selectConstraint().
Definition at line 1002 of file transform_constraints.c.
References blender::math::abs(), BLI_strncpy(), CON_AXIS0, CON_AXIS1, t, and TIP_.
Referenced by setNearestAxis().
Definition at line 1015 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().
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 702 of file transform_constraints.c.
References ATTR_FALLTHROUGH, BLI_snprintf(), checkUseAxisMatrix(), CON_USER, setAxisMatrixConstraint(), setConstraint(), setLocalConstraint(), t, transform_orientation_or_default(), 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().
Definition at line 953 of file transform_constraints.c.
References CON_APPLY, getConstraintSpaceDimension(), min_ii(), and t.
Referenced by InplaceSolverIslandCallback::processIsland(), MultiBodyInplaceSolverIslandCallback::processIsland(), selectConstraint(), setAxisMatrixConstraint(), and setConstraint().
Definition at line 960 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 298 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 312 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 |
Definition at line 367 of file transform_constraints.c.
References BLI_assert, CTX_OBJECT, CTX_POSE_BONE, t, transform_orientation_or_default(), and V3D_ORIENT_GIMBAL.
Referenced by applyObjectConstraintRot(), applyObjectConstraintSize(), applyObjectConstraintVec(), and drawObjectConstraint().
|
static |
Definition at line 357 of file transform_constraints.c.
References t, and V3D_ORIENT_CUSTOM_MATRIX.
Referenced by setUserConstraint(), and transform_object_axismtx_get().
|
static |
Definition at line 283 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 71 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 149 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().