Changeset View
Standalone View
source/blender/editors/include/ED_transform_snap_object_context.h
| Show All 26 Lines | |||||
| /* ED_transform_snap_object_*** API */ | /* ED_transform_snap_object_*** API */ | ||||
| typedef enum eSnapEditType { | typedef enum eSnapEditType { | ||||
| SNAP_GEOM_FINAL = 0, | SNAP_GEOM_FINAL = 0, | ||||
| SNAP_GEOM_CAGE = 1, | SNAP_GEOM_CAGE = 1, | ||||
| SNAP_GEOM_EDIT = 2, /* Bmesh for mesh-type. */ | SNAP_GEOM_EDIT = 2, /* Bmesh for mesh-type. */ | ||||
| } eSnapEditType; | } eSnapEditType; | ||||
| /** used for storing multiple hits */ | /** used for storing multiple hits */ | ||||
| struct SnapObjectHitDepth { | struct SnapObjectHitDepth { | ||||
campbellbarton: With similar options like this I normally try use a shared prefix to make things easier to… | |||||
Done Inline Actions(done) gfxcoder: (done) | |||||
| struct SnapObjectHitDepth *next, *prev; | struct SnapObjectHitDepth *next, *prev; | ||||
| float depth; | float depth; | ||||
| float co[3]; | float co[3]; | ||||
| float no[3]; | float no[3]; | ||||
| int index; | int index; | ||||
Not Done Inline ActionsThis kind of change affects a large portion of the patch. mano-wii: This kind of change affects a large portion of the patch.
I still think it would be better… | |||||
Done Inline Actionsi'm fine pulling this out as separate patch/proposal. it was helpful for understanding how the snapping code all worked together, because most of the code lacked any notion of spaces but switched back and forth, so i left these notes in. gfxcoder: i'm fine pulling this out as separate patch/proposal. it was helpful for understanding how the… | |||||
| struct Object *ob_eval; | struct Object *ob_eval; | ||||
| float obmat[4][4]; | float obmat[4][4]; | ||||
| /* needed to tell which ray-cast this was part of, | /* needed to tell which ray-cast this was part of, | ||||
| * the same object may be part of many ray-casts when dupli's are used. */ | * the same object may be part of many ray-casts when dupli's are used. */ | ||||
| unsigned int ob_uuid; | unsigned int ob_uuid; | ||||
| }; | }; | ||||
| /** parameters that define which objects will be used to snap. */ | /** parameters that define which objects will be used to snap. */ | ||||
Not Done Inline ActionsThis seems overcomplicated, can't we just add different parameters with the same flags? mano-wii: This seems overcomplicated, can't we just add different parameters with the same flags? | |||||
Done Inline Actionswe could. i haven't seen a consensus on how to approach this... whether using one "uber" attribute to store many related (or even sometimes disparate) flags, or to split it across many attributes. i'm fine with however it's most understandable to the rest of the community. gfxcoder: we could. i haven't seen a consensus on how to approach this... whether using one "uber"… | |||||
| struct SnapObjectParams { | struct SnapObjectParams { | ||||
| /* Special context sensitive handling for the active or selected object. */ | /* Special context sensitive handling for the active or selected object. */ | ||||
| eSnapTargetSelect snap_target_select; | eSnapTargetSelect snap_target_select; | ||||
| /* Geometry for snapping in edit mode. */ | /* Geometry for snapping in edit mode. */ | ||||
| eSnapEditType edit_mode_type; | eSnapEditType edit_mode_type; | ||||
| /* snap to the closest element, use when using more than one snap type */ | /* snap to the closest element, use when using more than one snap type */ | ||||
| bool use_occlusion_test : true; | bool use_occlusion_test : true; | ||||
| /* exclude back facing geometry from snapping */ | /* exclude back facing geometry from snapping */ | ||||
| bool use_backface_culling : true; | bool use_backface_culling : true; | ||||
| /* Break nearest face snapping into steps to improve transformations across U-shaped targets. */ | |||||
| short face_nearest_steps; | |||||
| /* Enable to force nearest face snapping to snap to target the source was initially near. */ | |||||
| bool keep_on_same_target; | |||||
| }; | }; | ||||
| typedef struct SnapObjectContext SnapObjectContext; | typedef struct SnapObjectContext SnapObjectContext; | ||||
| SnapObjectContext *ED_transform_snap_object_context_create(struct Scene *scene, int flag); | SnapObjectContext *ED_transform_snap_object_context_create(struct Scene *scene, int flag); | ||||
| void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx); | void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx); | ||||
| /* callbacks to filter how snap works */ | /* callbacks to filter how snap works */ | ||||
| void ED_transform_snap_object_context_set_editmesh_callbacks( | void ED_transform_snap_object_context_set_editmesh_callbacks( | ||||
| SnapObjectContext *sctx, | SnapObjectContext *sctx, | ||||
| bool (*test_vert_fn)(struct BMVert *, void *user_data), | bool (*test_vert_fn)(struct BMVert *, void *user_data), | ||||
| bool (*test_edge_fn)(struct BMEdge *, void *user_data), | bool (*test_edge_fn)(struct BMEdge *, void *user_data), | ||||
| bool (*test_face_fn)(struct BMFace *, void *user_data), | bool (*test_face_fn)(struct BMFace *, void *user_data), | ||||
| void *user_data); | void *user_data); | ||||
| bool ED_transform_snap_object_project_ray_ex(struct SnapObjectContext *sctx, | bool ED_transform_snap_object_project_ray_ex(struct SnapObjectContext *sctx, | ||||
Not Done Inline ActionsNice to see the documentation being improved, but I think it could be reviewed separately. mano-wii: Nice to see the documentation being improved, but I think it could be reviewed separately. | |||||
Done Inline ActionsI can pull this out as a separate patch if there is benefit in doing so. gfxcoder: I can pull this out as a separate patch if there is benefit in doing so. | |||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| const View3D *v3d, | const View3D *v3d, | ||||
| const struct SnapObjectParams *params, | const struct SnapObjectParams *params, | ||||
| const float ray_start[3], | const float ray_start[3], | ||||
| const float ray_normal[3], | const float ray_normal[3], | ||||
| float *ray_depth, | float *ray_depth, | ||||
| /* return args */ | /* return args */ | ||||
| float r_loc[3], | float r_loc[3], | ||||
| Show All 23 Lines | bool ED_transform_snap_object_project_ray_all(SnapObjectContext *sctx, | ||||
| const View3D *v3d, | const View3D *v3d, | ||||
| const struct SnapObjectParams *params, | const struct SnapObjectParams *params, | ||||
| const float ray_start[3], | const float ray_start[3], | ||||
| const float ray_normal[3], | const float ray_normal[3], | ||||
| float ray_depth, | float ray_depth, | ||||
| bool sort, | bool sort, | ||||
| struct ListBase *r_hit_list); | struct ListBase *r_hit_list); | ||||
| /** | |||||
| * Perform snapping. | |||||
| * | |||||
| * Given a 2D region value, snap to vert/edge/face/grid. | |||||
| * | |||||
| * \param sctx: Snap context. | |||||
| * \param snap_to: Target elements to snap source to. | |||||
| * \param params: Addition snapping options. | |||||
| * \param init_co: Initial world-space coordinate of source (optional). | |||||
| * \param mval: Current transformed screen-space coordinate or mouse position (optional). | |||||
| * \param prev_co: Current transformed world-space coordinate of source (optional). | |||||
| * \param dist_px: Maximum distance to snap (in pixels). | |||||
| * \param r_loc: Snapped world-space coordinate. | |||||
| * \param r_no: Snapped world-space normal (optional). | |||||
| * \param r_index: Index of snapped-to target element (optional). | |||||
| * \param r_ob: Snapped-to target object (optional). | |||||
| * \param r_obmat: Matrix of snapped-to target object (optional). | |||||
| * \param r_face_nor: World-space normal of snapped-to target face (optional). | |||||
| * \return Snapped-to element, #eSnapMode. | |||||
| */ | |||||
| eSnapMode ED_transform_snap_object_project_view3d_ex(struct SnapObjectContext *sctx, | eSnapMode ED_transform_snap_object_project_view3d_ex(struct SnapObjectContext *sctx, | ||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| const ARegion *region, | const ARegion *region, | ||||
| const View3D *v3d, | const View3D *v3d, | ||||
| eSnapMode snap_to, | const eSnapMode snap_to, | ||||
| const struct SnapObjectParams *params, | const struct SnapObjectParams *params, | ||||
| const float init_co[3], | |||||
| const float mval[2], | const float mval[2], | ||||
| const float prev_co[3], | const float prev_co[3], | ||||
| float *dist_px, | float *dist_px, | ||||
| float r_loc[3], | float r_loc[3], | ||||
| float r_no[3], | float r_no[3], | ||||
| int *r_index, | int *r_index, | ||||
| struct Object **r_ob, | struct Object **r_ob, | ||||
| float r_obmat[4][4], | float r_obmat[4][4], | ||||
| float r_face_nor[3]); | float r_face_nor[3]); | ||||
| /** | /** | ||||
| * Convenience function for performing snapping. | * Convenience function for performing snapping. | ||||
| * | * | ||||
| * Given a 2D region value, snap to vert/edge/face. | * Given a 2D region value, snap to vert/edge/face. | ||||
| * | * | ||||
| * \param sctx: Snap context. | * \param sctx: Snap context. | ||||
| * \param mval: Screenspace coordinate. | * \param snap_to: Target elements to snap source to. | ||||
| * \param prev_co: Coordinate for perpendicular point calculation (optional). | * \param params: Addition snapping options. | ||||
| * \param init_co: Initial world-space coordinate of source (optional). | |||||
| * \param mval: Current transformed screen-space coordinate or mouse position (optional). | |||||
| * \param prev_co: Current transformed world-space coordinate of source (optional). | |||||
| * \param dist_px: Maximum distance to snap (in pixels). | * \param dist_px: Maximum distance to snap (in pixels). | ||||
| * \param r_loc: hit location. | * \param r_loc: Snapped world-space coordinate. | ||||
| * \param r_no: hit normal (optional). | * \param r_no: Snapped world-space normal (optional). | ||||
| * \return Snap success. | * \return Snapped-to element, #eSnapMode. | ||||
| */ | */ | ||||
| eSnapMode ED_transform_snap_object_project_view3d(struct SnapObjectContext *sctx, | eSnapMode ED_transform_snap_object_project_view3d(struct SnapObjectContext *sctx, | ||||
| struct Depsgraph *depsgraph, | struct Depsgraph *depsgraph, | ||||
| const ARegion *region, | const ARegion *region, | ||||
| const View3D *v3d, | const View3D *v3d, | ||||
| eSnapMode snap_to, | const eSnapMode snap_to, | ||||
| const struct SnapObjectParams *params, | const struct SnapObjectParams *params, | ||||
| const float init_co[3], | |||||
| const float mval[2], | const float mval[2], | ||||
Not Done Inline ActionsDoc-string should include init_co and how it's used differently to prev_co. campbellbarton: Doc-string should include `init_co` and how it's used differently to `prev_co`. | |||||
Done Inline Actions(done) gfxcoder: (done) | |||||
| const float prev_co[3], | const float prev_co[3], | ||||
| float *dist_px, | float *dist_px, | ||||
| /* return args */ | /* return args */ | ||||
| float r_loc[3], | float r_loc[3], | ||||
| float r_no[3]); | float r_no[3]); | ||||
| /** | /** | ||||
| * see: #ED_transform_snap_object_project_ray_all | * see: #ED_transform_snap_object_project_ray_all | ||||
| Show All 14 Lines | |||||
With similar options like this I normally try use a shared prefix to make things easier to follow.