Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-10-04 20:46:15 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-10-04 20:46:15 +0400
commit709903c6bba4dca12a6f367000f99a83da2af034 (patch)
treed6b84b215f9b84eb4b6ac4a828af59683c03588e /source/blender/editors/armature/editarmature_sketch.c
parent794520a86a83a9eea230563e805480016c0479f0 (diff)
refactor ED_view3d_project_short & ED_view3d_project_short_noclip,
This is apart of a code cleanup to make ED_view3d_project_short/ED_view3d_project_int/ED_view3d_project_float interchangeable. Currently they work very differently in a way thats quite confusing (and cause of bugs in blender that remain uncorrected) - fixes coming. There are also cases where ED_view3d_project_short is used, then the values are converted from shorts into int's after because ED_view3d_project_int() behaves differently, will unify behavior of these functions after this commit. - rather then clip/noclip versions, pass flags (for bound-box clip, window clip). - rather then store the invalid clip-value, return success (or error value clip_near, clip_bb, clip_win, overflow). - remove local copies of project functions from drawobject.c: view3d_project_short_clip, view3d_project_short_noclip, view3d_project_short_clip_persmat. add functions: - ED_view3d_project_short_global() global space projection - ED_view3d_project_short_object() object space projection. - ED_view3d_project_short_ex() take perspective matrix and local space option as args. - ED_view3d_project_base() - special function to set the Object 'Base' screen coords (sx, sy), since this is a common enough operation.
Diffstat (limited to 'source/blender/editors/armature/editarmature_sketch.c')
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c103
1 files changed, 56 insertions, 47 deletions
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 8d8fa730360..b72fad08d1f 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -646,16 +646,17 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in
short pval[2];
int pdist;
- ED_view3d_project_short_noclip(ar, stk->points[i].p, pval);
+ if (ED_view3d_project_short_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
- pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
+ pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
- if (pdist < *dist) {
- *dist = pdist;
- pt = stk->points + i;
+ if (pdist < *dist) {
+ *dist = pdist;
+ pt = stk->points + i;
- if (index != NULL) {
- *index = i;
+ if (index != NULL) {
+ *index = i;
+ }
}
}
}
@@ -681,32 +682,34 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones,
{
copy_v3_v3(vec, bone->head);
mul_m4_v3(ob->obmat, vec);
- ED_view3d_project_short_noclip(ar, vec, pval);
+ if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
- pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
+ pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
- if (pdist < *dist)
- {
- *dist = pdist;
- pt = &boneSnap;
- copy_v3_v3(pt->p, vec);
- pt->type = PT_EXACT;
+ if (pdist < *dist)
+ {
+ *dist = pdist;
+ pt = &boneSnap;
+ copy_v3_v3(pt->p, vec);
+ pt->type = PT_EXACT;
+ }
}
}
copy_v3_v3(vec, bone->tail);
mul_m4_v3(ob->obmat, vec);
- ED_view3d_project_short_noclip(ar, vec, pval);
+ if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
- pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
+ pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
- if (pdist < *dist)
- {
- *dist = pdist;
- pt = &boneSnap;
- copy_v3_v3(pt->p, vec);
- pt->type = PT_EXACT;
+ if (pdist < *dist)
+ {
+ *dist = pdist;
+ pt = &boneSnap;
+ copy_v3_v3(pt->p, vec);
+ pt->type = PT_EXACT;
+ }
}
}
@@ -936,10 +939,14 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr
initgrabz(ar->regiondata, fp[0], fp[1], fp[2]);
/* method taken from editview.c - mouse_cursor() */
- ED_view3d_project_short_noclip(ar, fp, cval);
- VECSUB2D(mval_f, cval, dd->mval);
- ED_view3d_win_to_delta(ar, mval_f, dvec);
- sub_v3_v3v3(vec, fp, dvec);
+ if (ED_view3d_project_short_global(ar, fp, cval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) {
+ VECSUB2D(mval_f, cval, dd->mval);
+ ED_view3d_win_to_delta(ar, mval_f, dvec);
+ sub_v3_v3v3(vec, fp, dvec);
+ }
+ else {
+ zero_v3(vec);
+ }
}
static int sk_getStrokeDrawPoint(bContext *C, SK_Point *pt, SK_Sketch *UNUSED(sketch), SK_Stroke *stk, SK_DrawData *dd)
@@ -1786,33 +1793,35 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc
short start_val[2], end_val[2];
short dist;
- ED_view3d_project_short_noclip(ar, gest->stk->points[0].p, start_val);
- ED_view3d_project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val);
+ if ((ED_view3d_project_short_global(ar, gest->stk->points[0].p, start_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) &&
+ (ED_view3d_project_short_global(ar, sk_lastStrokePoint(gest->stk)->p, end_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS))
+ {
- dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1]));
+ dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1]));
- /* if gesture is a circle */
- if (dist <= 20) {
- SK_Intersection *isect;
+ /* if gesture is a circle */
+ if (dist <= 20) {
+ SK_Intersection *isect;
- /* check if it circled around an exact point */
- for (isect = gest->intersections.first; isect; isect = isect->next) {
- /* only delete strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke) {
- int start_index, end_index;
- int i;
+ /* check if it circled around an exact point */
+ for (isect = gest->intersections.first; isect; isect = isect->next) {
+ /* only delete strokes that are crossed twice */
+ if (isect->next && isect->next->stroke == isect->stroke) {
+ int start_index, end_index;
+ int i;
- start_index = MIN2(isect->after, isect->next->after);
- end_index = MAX2(isect->before, isect->next->before);
+ start_index = MIN2(isect->after, isect->next->after);
+ end_index = MAX2(isect->before, isect->next->before);
- for (i = start_index; i <= end_index; i++) {
- if (isect->stroke->points[i].type == PT_EXACT) {
- return 1; /* at least one exact point found, stop detect here */
+ for (i = start_index; i <= end_index; i++) {
+ if (isect->stroke->points[i].type == PT_EXACT) {
+ return 1; /* at least one exact point found, stop detect here */
+ }
}
- }
- /* skip next */
- isect = isect->next;
+ /* skip next */
+ isect = isect->next;
+ }
}
}
}