diff options
author | Martin Poirier <theeth@yahoo.com> | 2009-07-09 05:48:08 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2009-07-09 05:48:08 +0400 |
commit | 304cbc09ab5027893bbc0b96b17f84b6f03fdb85 (patch) | |
tree | 059c7d3d29b7cd34f35da0216866c544eec4b8ee /source/blender/editors | |
parent | 93428ff82a7cc53e6f684f3607306b213f1b954c (diff) |
Cosmetic changes in etch-a-ton drawing code, mostly.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/armature/editarmature_generate.c | 25 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature_sketch.c | 1118 | ||||
-rw-r--r-- | source/blender/editors/armature/reeb.c | 3 | ||||
-rw-r--r-- | source/blender/editors/armature/reeb.h | 1 |
4 files changed, 635 insertions, 512 deletions
diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index 6d271375c64..6c0eab16af0 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -285,6 +285,8 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase * EditBone *lastBone = NULL; EditBone *child = NULL; EditBone *parent = NULL; + float *normal = NULL; + float size_buffer = 1.2; int bone_start = 0; int end = iter->length; int index; @@ -294,6 +296,13 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase * parent = addEditBone(arm, "Bone"); VECCOPY(parent->head, iter->p); + if (iter->size > 0) + { + parent->rad_head = iter->size * size_buffer; + } + + normal = iter->no; + index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail); while (index != -1) { @@ -304,21 +313,33 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase * child->parent = parent; child->flag |= BONE_CONNECTED; + if (iter->size > 0) + { + child->rad_head = iter->size * size_buffer; + parent->rad_tail = iter->size * size_buffer; + } + /* going to next bone, fix parent */ Mat4MulVecfl(invmat, parent->tail); Mat4MulVecfl(invmat, parent->head); - setBoneRollFromNormal(parent, iter->no, invmat, tmat); + setBoneRollFromNormal(parent, normal, invmat, tmat); parent = child; // new child is next parent bone_start = index; // start next bone from current index + normal = iter->no; /* use normal at head, not tail */ + index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail); } iter->tail(iter); VECCOPY(parent->tail, iter->p); - + if (iter->size > 0) + { + parent->rad_tail = iter->size * size_buffer; + } + /* fix last bone */ Mat4MulVecfl(invmat, parent->tail); Mat4MulVecfl(invmat, parent->head); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 816df0f81c9..6e6e61dafc2 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -90,6 +90,7 @@ typedef struct SK_Point { float p[3]; float no[3]; + float size; SK_PType type; SK_PMode mode; } SK_Point; @@ -136,6 +137,7 @@ typedef struct SK_Intersection typedef struct SK_Sketch { ListBase strokes; + ListBase depth_peels; SK_Stroke *active_stroke; SK_Stroke *gesture; SK_Point next_point; @@ -150,9 +152,10 @@ typedef struct SK_StrokeIterator { NextNFct nextN; PreviousFct previous; StoppedFct stopped; - + float *p, *no; - + float size; + int length; int index; /*********************************/ @@ -251,19 +254,19 @@ void BIF_makeListTemplates(bContext *C) { BLI_ghash_free(TEMPLATES_HASH, NULL, NULL); } - + TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp); TEMPLATES_CURRENT = 0; for ( base = FIRSTBASE; base; base = base->next ) { Object *ob = base->object; - + if (ob != obedit && ob->type == OB_ARMATURE) { index++; BLI_ghash_insert(TEMPLATES_HASH, SET_INT_IN_POINTER(index), ob); - + if (ob == ts->skgen_template) { TEMPLATES_CURRENT = index; @@ -277,30 +280,30 @@ char *BIF_listTemplates(bContext *C) GHashIterator ghi; char menu_header[] = "Template%t|None%x0|"; char *p; - + if (TEMPLATES_MENU != NULL) { MEM_freeN(TEMPLATES_MENU); } - + TEMPLATES_MENU = MEM_callocN(sizeof(char) * (BLI_ghash_size(TEMPLATES_HASH) * 32 + 30), "skeleton template menu"); - + p = TEMPLATES_MENU; - + p += sprintf(TEMPLATES_MENU, "%s", menu_header); - + BLI_ghashIterator_init(&ghi, TEMPLATES_HASH); - + while (!BLI_ghashIterator_isDone(&ghi)) { Object *ob = BLI_ghashIterator_getValue(&ghi); int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi)); - + p += sprintf(p, "|%s%%x%i", ob->id.name+2, key); - + BLI_ghashIterator_step(&ghi); } - + return TEMPLATES_MENU; } @@ -312,22 +315,22 @@ int BIF_currentTemplate(bContext *C) { GHashIterator ghi; BLI_ghashIterator_init(&ghi, TEMPLATES_HASH); - + while (!BLI_ghashIterator_isDone(&ghi)) { Object *ob = BLI_ghashIterator_getValue(&ghi); int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi)); - + if (ob == ts->skgen_template) { TEMPLATES_CURRENT = key; break; } - + BLI_ghashIterator_step(&ghi); } } - + return TEMPLATES_CURRENT; } @@ -338,7 +341,7 @@ RigGraph* sk_makeTemplateGraph(bContext *C, Object *ob) { return NULL; } - + if (ob != NULL) { if (TEMPLATE_RIGG && TEMPLATE_RIGG->ob != ob) @@ -346,17 +349,17 @@ RigGraph* sk_makeTemplateGraph(bContext *C, Object *ob) RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG); TEMPLATE_RIGG = NULL; } - + if (TEMPLATE_RIGG == NULL) { bArmature *arm; arm = ob->data; - + TEMPLATE_RIGG = RIG_graphFromArmature(C, ob, arm); } } - + return TEMPLATE_RIGG; } @@ -364,14 +367,14 @@ int BIF_nbJointsTemplate(bContext *C) { ToolSettings *ts = CTX_data_tool_settings(C); RigGraph *rg = sk_makeTemplateGraph(C, ts->skgen_template); - + if (rg) { return RIG_nbJoints(rg); } else { - return -1; + return -1; } } @@ -386,9 +389,9 @@ char * BIF_nameBoneTemplate(bContext *C) { index = stk->active_stroke->nb_points; } - + rg = sk_makeTemplateGraph(C, ts->skgen_template); - + if (rg == NULL) { return ""; @@ -404,13 +407,13 @@ void BIF_freeTemplates(bContext *C) MEM_freeN(TEMPLATES_MENU); TEMPLATES_MENU = NULL; } - + if (TEMPLATES_HASH != NULL) { BLI_ghash_free(TEMPLATES_HASH, NULL, NULL); TEMPLATES_HASH = NULL; } - + if (TEMPLATE_RIGG != NULL) { RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG); @@ -428,14 +431,14 @@ void BIF_setTemplate(bContext *C, int index) else { ts->skgen_template = NULL; - + if (TEMPLATE_RIGG != NULL) { RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG); } TEMPLATE_RIGG = NULL; } -} +} /*********************** CONVERSION ***************************/ @@ -456,7 +459,7 @@ void sk_autoname(bContext *C, ReebArc *arc) char *side = ts->skgen_side_string; int valid = 0; int caps = 0; - + if (BLI_streq(side, "")) { valid = 1; @@ -471,7 +474,7 @@ void sk_autoname(bContext *C, ReebArc *arc) valid = 1; caps = 0; } - + if (valid) { if (arc->head->p[0] < 0) @@ -490,14 +493,14 @@ void sk_autoname(bContext *C, ReebArc *arc) ReebNode *sk_pointToNode(SK_Point *pt, float imat[][4], float tmat[][3]) { ReebNode *node; - + node = MEM_callocN(sizeof(ReebNode), "reeb node"); VECCOPY(node->p, pt->p); Mat4MulVecfl(imat, node->p); - + VECCOPY(node->no, pt->no); Mat3MulVecfl(tmat, node->no); - + return node; } @@ -505,14 +508,14 @@ ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[][4], float tmat[][3]) { ReebArc *arc; int i; - + arc = MEM_callocN(sizeof(ReebArc), "reeb arc"); arc->head = sk_pointToNode(stk->points, imat, tmat); arc->tail = sk_pointToNode(sk_lastStrokePoint(stk), imat, tmat); - + arc->bcount = stk->nb_points - 2; /* first and last are nodes, don't count */ arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "Buckets"); - + for (i = 0; i < arc->bcount; i++) { VECCOPY(arc->buckets[i].p, stk->points[i + 1].p); @@ -521,7 +524,7 @@ ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[][4], float tmat[][3]) VECCOPY(arc->buckets[i].no, stk->points[i + 1].no); Mat3MulVecfl(tmat, arc->buckets[i].no); } - + return arc; } @@ -533,22 +536,22 @@ void sk_retargetStroke(bContext *C, SK_Stroke *stk) float tmat[3][3]; ReebArc *arc; RigGraph *rg; - + Mat4Invert(imat, obedit->obmat); - + Mat3CpyMat4(tmat, obedit->obmat); Mat3Transp(tmat); arc = sk_strokeToArc(stk, imat, tmat); - + sk_autoname(C, arc); - + rg = sk_makeTemplateGraph(C, ts->skgen_template); BIF_retargetArc(C, arc, rg); - + sk_autoname(C, NULL); - + MEM_freeN(arc->head); MEM_freeN(arc->tail); REEB_freeArc((BArc*)arc); @@ -559,29 +562,31 @@ void sk_retargetStroke(bContext *C, SK_Stroke *stk) void sk_freeSketch(SK_Sketch *sketch) { SK_Stroke *stk, *next; - + for (stk = sketch->strokes.first; stk; stk = next) { next = stk->next; - + sk_freeStroke(stk); } - + + BLI_freelistN(&sketch->depth_peels); + MEM_freeN(sketch); } SK_Sketch* sk_createSketch() { SK_Sketch *sketch; - + sketch = MEM_callocN(sizeof(SK_Sketch), "SK_Sketch"); - + sketch->active_stroke = NULL; sketch->gesture = NULL; sketch->strokes.first = NULL; sketch->strokes.last = NULL; - + return sketch; } @@ -614,15 +619,15 @@ void sk_freeStroke(SK_Stroke *stk) SK_Stroke* sk_createStroke() { SK_Stroke *stk; - + stk = MEM_callocN(sizeof(SK_Stroke), "SK_Stroke"); - + stk->selected = 0; stk->nb_points = 0; stk->buf_size = SK_Stroke_BUFFER_INIT_SIZE; - + sk_allocStrokeBuffer(stk); - + return stk; } @@ -631,13 +636,13 @@ void sk_shrinkStrokeBuffer(SK_Stroke *stk) if (stk->nb_points < stk->buf_size) { SK_Point *old_points = stk->points; - + stk->buf_size = stk->nb_points; - sk_allocStrokeBuffer(stk); - + sk_allocStrokeBuffer(stk); + memcpy(stk->points, old_points, sizeof(SK_Point) * stk->nb_points); - + MEM_freeN(old_points); } } @@ -647,13 +652,13 @@ void sk_growStrokeBuffer(SK_Stroke *stk) if (stk->nb_points == stk->buf_size) { SK_Point *old_points = stk->points; - + stk->buf_size *= 2; - + sk_allocStrokeBuffer(stk); - + memcpy(stk->points, old_points, sizeof(SK_Point) * stk->nb_points); - + MEM_freeN(old_points); } } @@ -663,16 +668,16 @@ void sk_growStrokeBufferN(SK_Stroke *stk, int n) if (stk->nb_points + n > stk->buf_size) { SK_Point *old_points = stk->points; - + while (stk->nb_points + n > stk->buf_size) { stk->buf_size *= 2; } - + sk_allocStrokeBuffer(stk); - + memcpy(stk->points, old_points, sizeof(SK_Point) * stk->nb_points); - + MEM_freeN(old_points); } } @@ -686,52 +691,52 @@ void sk_replaceStrokePoint(SK_Stroke *stk, SK_Point *pt, int n) void sk_insertStrokePoint(SK_Stroke *stk, SK_Point *pt, int n) { int size = stk->nb_points - n; - + sk_growStrokeBuffer(stk); - + memmove(stk->points + n + 1, stk->points + n, size * sizeof(SK_Point)); - + memcpy(stk->points + n, pt, sizeof(SK_Point)); - + stk->nb_points++; } void sk_appendStrokePoint(SK_Stroke *stk, SK_Point *pt) { sk_growStrokeBuffer(stk); - + memcpy(stk->points + stk->nb_points, pt, sizeof(SK_Point)); - + stk->nb_points++; } void sk_insertStrokePoints(SK_Stroke *stk, SK_Point *pts, int len, int start, int end) { int size = end - start + 1; - + sk_growStrokeBufferN(stk, len - size); - + if (len != size) { int tail_size = stk->nb_points - end + 1; - + memmove(stk->points + start + len, stk->points + end + 1, tail_size * sizeof(SK_Point)); } - + memcpy(stk->points + start, pts, len * sizeof(SK_Point)); - + stk->nb_points += len - size; } void sk_trimStroke(SK_Stroke *stk, int start, int end) { int size = end - start + 1; - + if (start > 0) { memmove(stk->points, stk->points + start, size * sizeof(SK_Point)); } - + stk->nb_points = size; } @@ -741,27 +746,27 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f SK_Point *prev, *next; float delta_p[3]; int i, total; - + total = end - start; VecSubf(delta_p, p_end, p_start); - + prev = stk->points + start; next = stk->points + end; - + VECCOPY(pt1.p, p_start); VECCOPY(pt1.no, prev->no); pt1.mode = prev->mode; pt1.type = prev->type; - + VECCOPY(pt2.p, p_end); VECCOPY(pt2.no, next->no); pt2.mode = next->mode; pt2.type = next->type; - + sk_insertStrokePoint(stk, &pt1, start + 1); /* insert after start */ sk_insertStrokePoint(stk, &pt2, end + 1); /* insert before end (since end was pushed back already) */ - + for (i = 1; i < total; i++) { float delta = (float)i / (float)total; @@ -770,14 +775,14 @@ void sk_straightenStroke(SK_Stroke *stk, int start, int end, float p_start[3], f VECCOPY(p, delta_p); VecMulf(p, delta); VecAddf(p, p, p_start); - } + } } void sk_polygonizeStroke(SK_Stroke *stk, int start, int end) { int offset; int i; - + /* find first exact points outside of range */ for (;start > 0; start--) { @@ -786,7 +791,7 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end) break; } } - + for (;end < stk->nb_points - 1; end++) { if (stk->points[end].type == PT_EXACT) @@ -794,9 +799,9 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end) break; } } - + offset = start + 1; - + for (i = start + 1; i < end; i++) { if (stk->points[i].type == PT_EXACT) @@ -809,7 +814,7 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end) offset++; } } - + /* some points were removes, move end of array */ if (offset < end) { @@ -824,15 +829,15 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) float normal[3], distance[3]; float limit; int i, total; - + total = end - start + 1; - + VECCOPY(normal, stk->points[start].no); - + VecSubf(distance, stk->points[end].p, stk->points[start].p); Projf(normal, distance, normal); limit = Normalize(normal); - + for (i = 1; i < total - 1; i++) { float d = limit * i / total; @@ -841,13 +846,13 @@ void sk_flattenStroke(SK_Stroke *stk, int start, int end) VecSubf(distance, p, stk->points[start].p); Projf(distance, distance, normal); - + VECCOPY(offset, normal); VecMulf(offset, d); - + VecSubf(p, p, distance); VecAddf(p, p, offset); - } + } } void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk) @@ -856,7 +861,7 @@ void sk_removeStroke(SK_Sketch *sketch, SK_Stroke *stk) { sketch->active_stroke = NULL; } - + BLI_remlink(&sketch->strokes, stk); sk_freeStroke(stk); } @@ -865,14 +870,14 @@ void sk_reverseStroke(SK_Stroke *stk) { SK_Point *old_points = stk->points; int i = 0; - + sk_allocStrokeBuffer(stk); - + for (i = 0; i < stk->nb_points; i++) { sk_copyPoint(stk->points + i, old_points + stk->nb_points - 1 - i); } - + MEM_freeN(old_points); } @@ -893,9 +898,9 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) SK_Point *old_points = stk->points; int nb_points = stk->nb_points; int i, j; - + return; - + if (start == -1) { start = 0; @@ -904,30 +909,30 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) sk_allocStrokeBuffer(stk); stk->nb_points = 0; - + /* adding points before range */ for (i = 0; i < start; i++) { sk_appendStrokePoint(stk, old_points + i); } - + for (i = start, j = start; i <= end; i++) { if (i - j == 3) { SK_Point pt; float vec[3]; - + sk_copyPoint(&pt, &old_points[j+1]); pt.p[0] = 0; pt.p[1] = 0; pt.p[2] = 0; - + VECCOPY(vec, old_points[j].p); VecMulf(vec, -0.25); VecAddf(pt.p, pt.p, vec); - + VECCOPY(vec, old_points[j+1].p); VecMulf(vec, 0.75); VecAddf(pt.p, pt.p, vec); @@ -939,20 +944,22 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) VECCOPY(vec, old_points[j+3].p); VecMulf(vec, -0.25); VecAddf(pt.p, pt.p, vec); - + + pt.size = -0.25 * old_points[j].size + 0.75 * old_points[j+1].size + 0.75 * old_points[j+2].size - 0.25 * old_points[j+3].size; + sk_appendStrokePoint(stk, &pt); j += 2; } - + /* this might be uneeded when filtering last continuous stroke */ if (old_points[i].type == PT_EXACT) { sk_appendStrokePoint(stk, old_points + i); j = i; } - } - + } + /* adding points after range */ for (i = end + 1; i < nb_points; i++) { @@ -967,14 +974,14 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end) void sk_filterLastContinuousStroke(SK_Stroke *stk) { int start, end; - + end = stk->nb_points -1; - + for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) { /* nothing to do here*/ } - + if (end - start > 1) { sk_filterStroke(stk, start, end); @@ -984,46 +991,118 @@ void sk_filterLastContinuousStroke(SK_Stroke *stk) SK_Point *sk_lastStrokePoint(SK_Stroke *stk) { SK_Point *pt = NULL; - + if (stk->nb_points > 0) { pt = stk->points + (stk->nb_points - 1); } - + return pt; } +float sk_clampPointSize(SK_Point *pt, float size) +{ + return MAX2(size * pt->size, size / 2); +} + +void sk_drawPoint(GLUquadric *quad, SK_Point *pt, float size) +{ + glTranslatef(pt->p[0], pt->p[1], pt->p[2]); + gluSphere(quad, sk_clampPointSize(pt, size), 8, 8); +} + +void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float size) +{ + float vec1[3], vec2[3] = {0, 0, 1}, axis[3]; + float angle, length; + + VecSubf(vec1, pt1->p, pt0->p); + length = Normalize(vec1); + Crossf(axis, vec2, vec1); + + if (VecIsNull(axis)) + { + axis[1] = 1; + } + + angle = NormalizedVecAngle2(vec2, vec1); + + glRotatef(angle * 180 / M_PI + 180, axis[0], axis[1], axis[2]); + + gluCylinder(quad, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8); +} + +void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float height) +{ + float vec2[3] = {0, 0, 1}, axis[3]; + float angle; + + glPushMatrix(); + + Crossf(axis, vec2, pt->no); + + if (VecIsNull(axis)) + { + axis[1] = 1; + } + + angle = NormalizedVecAngle2(vec2, pt->no); + + glRotatef(angle * 180 / M_PI, axis[0], axis[1], axis[2]); + + glColor3f(0, 1, 1); + gluCylinder(quad, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2); + + glPopMatrix(); +} + void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end) { float rgb[3]; int i; - + GLUquadric *quad = gluNewQuadric(); + gluQuadricNormals(quad, GLU_SMOOTH); + if (id != -1) { glLoadName(id); - - glBegin(GL_LINE_STRIP); - + for (i = 0; i < stk->nb_points; i++) { - glVertex3fv(stk->points[i].p); + glPushMatrix(); + + sk_drawPoint(quad, stk->points + i, 0.1); + + if (i > 0) + { + sk_drawEdge(quad, stk->points + i - 1, stk->points + i, 0.1); + } + + glPopMatrix(); } - - glEnd(); - + } else { float d_rgb[3] = {1, 1, 1}; - + VECCOPY(rgb, color); VecSubf(d_rgb, d_rgb, rgb); VecMulf(d_rgb, 1.0f / (float)stk->nb_points); - - glBegin(GL_LINE_STRIP); for (i = 0; i < stk->nb_points; i++) { + SK_Point *pt = stk->points + i; + + glPushMatrix(); + + if (pt->type == PT_EXACT) + { + glColor3f(0, 0, 0); + sk_drawPoint(quad, pt, 0.15); + sk_drawNormal(quad, pt, 0.05, 0.9); + } + if (i >= start && i <= end) { glColor3f(0.3, 0.3, 0.3); @@ -1032,99 +1111,78 @@ void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end) { glColor3fv(rgb); } - glVertex3fv(stk->points[i].p); - VecAddf(rgb, rgb, d_rgb); - } - - glEnd(); -#if 0 - glColor3f(0, 0, 1); - glBegin(GL_LINES); + if (pt->type != PT_EXACT) + { - for (i = 0; i < stk->nb_points; i++) - { - float *p = stk->points[i].p; - float *no = stk->points[i].no; - glVertex3fv(p); - glVertex3f(p[0] + no[0], p[1] + no[1], p[2] + no[2]); - } - - glEnd(); -#endif + sk_drawPoint(quad, pt, 0.1); + } - glColor3f(0, 0, 0); - glBegin(GL_POINTS); - - for (i = 0; i < stk->nb_points; i++) - { - if (stk->points[i].type == PT_EXACT) + if (i > 0) { - glVertex3fv(stk->points[i].p); + sk_drawEdge(quad, pt - 1, pt, 0.1); } + + glPopMatrix(); + + VecAddf(rgb, rgb, d_rgb); } - - glEnd(); } -// glColor3f(1, 1, 1); -// glBegin(GL_POINTS); -// -// for (i = 0; i < stk->nb_points; i++) -// { -// if (stk->points[i].type == PT_CONTINUOUS) -// { -// glVertex3fv(stk->points[i].p); -// } -// } -// -// glEnd(); + gluDeleteQuadric(quad); } void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *iter, NextSubdivisionFunc next_subdividion) { + SK_Stroke *stk = ((SK_StrokeIterator*)iter)->stroke; float head[3], tail[3]; int bone_start = 0; int end = iter->length; int index; + GLUquadric *quad = gluNewQuadric(); + gluQuadricNormals(quad, GLU_SMOOTH); iter->head(iter); VECCOPY(head, iter->p); - - glColor3f(0, 1, 0); - glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE) * 2); - glBegin(GL_POINTS); - + index = next_subdividion(toolsettings, iter, bone_start, end, head, tail); while (index != -1) { - glVertex3fv(tail); - + SK_Point *pt = stk->points + index; + + glPushMatrix(); + + glColor3f(0, 1, 0); + sk_drawPoint(quad, pt, 0.15); + + sk_drawNormal(quad, pt, 0.05, 0.9); + + glPopMatrix(); + VECCOPY(head, tail); bone_start = index; // start next bone from current index index = next_subdividion(toolsettings, iter, bone_start, end, head, tail); } - - glEnd(); - glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); + + gluDeleteQuadric(quad); } void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk) { int head_index = -1; int i; - + if (toolsettings->bone_sketching_convert == SK_CONVERT_RETARGET) { return; } - + for (i = 0; i < stk->nb_points; i++) { SK_Point *pt = stk->points + i; - + if (pt->type == PT_EXACT || i == stk->nb_points - 1) /* stop on exact or on last point */ { if (head_index == -1) @@ -1137,7 +1195,7 @@ void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk) { SK_StrokeIterator sk_iter; BArcIterator *iter = (BArcIterator*)&sk_iter; - + initStrokeIterator(iter, stk, head_index, i); if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_ADAPTATIVE) @@ -1152,13 +1210,13 @@ void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk) { drawSubdividedStrokeBy(toolsettings, iter, nextFixedSubdivision); } - + } head_index = i; } } - } + } } SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, short mval[2], int *dist, int *index, int all_pts) @@ -1166,23 +1224,23 @@ SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, short mval[2], int *di ARegion *ar = CTX_wm_region(C); SK_Point *pt = NULL; int i; - + for (i = 0; i < stk->nb_points; i++) { if (all_pts || stk->points[i].type == PT_EXACT) { short pval[2]; int pdist; - + project_short_noclip(ar, stk->points[i].p, pval); - + pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); - + if (pdist < *dist) { *dist = pdist; pt = stk->points + i; - + if (index != NULL) { *index = i; @@ -1190,7 +1248,7 @@ SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, short mval[2], int *di } } } - + return pt; } @@ -1199,21 +1257,21 @@ SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short ARegion *ar = CTX_wm_region(C); SK_Point *pt = NULL; EditBone *bone; - + for (bone = ebones->first; bone; bone = bone->next) { float vec[3]; short pval[2]; int pdist; - + if ((bone->flag & BONE_CONNECTED) == 0) { VECCOPY(vec, bone->head); Mat4MulVecfl(ob->obmat, vec); project_short_noclip(ar, vec, pval); - + pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); - + if (pdist < *dist) { *dist = pdist; @@ -1222,14 +1280,14 @@ SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short pt->type = PT_EXACT; } } - - + + VECCOPY(vec, bone->tail); Mat4MulVecfl(ob->obmat, vec); project_short_noclip(ar, vec, pval); - + pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); - + if (pdist < *dist) { *dist = pdist; @@ -1238,7 +1296,7 @@ SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short pt->type = PT_EXACT; } } - + return pt; } @@ -1265,21 +1323,21 @@ void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawDa SK_Stroke *target; int closest_index = -1; int dist = SNAP_MIN_DISTANCE * 2; - + // /* If snapping, don't start overdraw */ Can't do that, snap is embed too now // if (sk_lastStrokePoint(stk)->mode == PT_SNAP) // { // return; // } - + for (target = sketch->strokes.first; target; target = target->next) { if (target != stk) { int index; - + SK_Point *spt = sk_snapPointStroke(C, target, dd->mval, &dist, &index, 1); - + if (spt != NULL) { sketch->over.target = target; @@ -1287,7 +1345,7 @@ void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawDa } } } - + if (sketch->over.target != NULL) { if (closest_index > -1) @@ -1319,7 +1377,7 @@ void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawDa int index; closest_pt = sk_snapPointStroke(C, sketch->over.target, dd->mval, &dist, &index, 1); - + if (closest_pt != NULL) { if (sk_lastStrokePoint(stk)->type == PT_EXACT) @@ -1330,7 +1388,7 @@ void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawDa { sketch->over.count++; } - + sketch->over.end = index; } else @@ -1347,17 +1405,17 @@ int sk_adjustIndexes(SK_Sketch *sketch, int *start, int *end) *start = sketch->over.start; *end = sketch->over.end; - + if (*start == -1) { *start = 0; } - + if (*end == -1) { *end = sketch->over.target->nb_points - 1; } - + if (*end < *start) { int tmp = *start; @@ -1365,34 +1423,34 @@ int sk_adjustIndexes(SK_Sketch *sketch, int *start, int *end) *end = tmp; retval = 1; } - + return retval; } void sk_endOverdraw(SK_Sketch *sketch) { SK_Stroke *stk = sketch->active_stroke; - + if (sk_hasOverdraw(sketch, NULL)) { int start; int end; - + if (sk_adjustIndexes(sketch, &start, &end)) { sk_reverseStroke(stk); } - + if (stk->nb_points > 1) { stk->points->type = sketch->over.target->points[start].type; sk_lastStrokePoint(stk)->type = sketch->over.target->points[end].type; } - + sk_insertStrokePoints(sketch->over.target, stk->points, stk->nb_points, start, end); - + sk_removeStroke(sketch, stk); - + sk_resetOverdraw(sketch); } } @@ -1401,11 +1459,11 @@ void sk_endOverdraw(SK_Sketch *sketch) void sk_startStroke(SK_Sketch *sketch) { SK_Stroke *stk = sk_createStroke(); - + BLI_addtail(&sketch->strokes, stk); sketch->active_stroke = stk; - sk_resetOverdraw(sketch); + sk_resetOverdraw(sketch); } void sk_endStroke(bContext *C, SK_Sketch *sketch) @@ -1424,7 +1482,7 @@ void sk_endStroke(bContext *C, SK_Sketch *sketch) void sk_updateDrawData(SK_DrawData *dd) { dd->type = PT_CONTINUOUS; - + dd->previous_mval[0] = dd->mval[0]; dd->previous_mval[1] = dd->mval[1]; } @@ -1435,19 +1493,19 @@ float sk_distanceDepth(bContext *C, float p1[3], float p2[3]) RegionView3D *rv3d = ar->regiondata; float vec[3]; float distance; - + VecSubf(vec, p1, p2); - + Projf(vec, vec, rv3d->viewinv[2]); - + distance = VecLength(vec); - + if (Inpf(rv3d->viewinv[2], vec) > 0) { distance *= -1; } - - return distance; + + return distance; } void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float length, float distance) @@ -1458,18 +1516,18 @@ void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float float progress = 0; int i; - + progress = VecLenf(stk->points[start].p, stk->points[start - 1].p); - + for (i = start; i <= end; i++) { float ray_start[3], ray_normal[3]; float delta = VecLenf(stk->points[i].p, stk->points[i + 1].p); short pval[2]; - + project_short_noclip(ar, stk->points[i].p, pval); viewray(ar, v3d, pval, ray_start, ray_normal); - + VecMulf(ray_normal, distance * progress / length); VecAddf(stk->points[i].p, stk->points[i].p, ray_normal); @@ -1480,19 +1538,19 @@ void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_DrawData *dd) { ARegion *ar = CTX_wm_region(C); - /* copied from grease pencil, need fixing */ + /* copied from grease pencil, need fixing */ SK_Point *last = sk_lastStrokePoint(stk); short cval[2]; float fp[3] = {0, 0, 0}; float dvec[3]; - + if (last != NULL) { VECCOPY(fp, last->p); } - + initgrabz(ar->regiondata, fp[0], fp[1], fp[2]); - + /* method taken from editview.c - mouse_cursor() */ project_short_noclip(ar, fp, cval); window_to_3d_delta(ar, dvec, cval[0] - dd->mval[0], cval[1] - dd->mval[1]); @@ -1504,20 +1562,20 @@ int sk_getStrokeDrawPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok pt->type = dd->type; pt->mode = PT_PROJECT; sk_projectDrawPoint(C, pt->p, stk, dd); - + return 1; } int sk_addStrokeDrawPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd) { SK_Point pt; - + sk_initPoint(C, &pt); - + sk_getStrokeDrawPoint(C, &pt, sketch, stk, dd); sk_appendStrokePoint(stk, &pt); - + return 1; } @@ -1528,16 +1586,16 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok if (ts->snap_mode == SCE_SNAP_MODE_VOLUME) { - ListBase depth_peels; DepthPeel *p1, *p2; float *last_p = NULL; float dist = FLT_MAX; float p[3]; - - depth_peels.first = depth_peels.last = NULL; - - peelObjectsContext(C, &depth_peels, dd->mval); - + float size = 0; + + sketch->depth_peels.first = sketch->depth_peels.last = NULL; + + peelObjectsContext(C, &sketch->depth_peels, dd->mval); + if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS) { last_p = stk->points[stk->nb_points - 1].p; @@ -1546,19 +1604,20 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok { last_p = LAST_SNAP_POINT; } - - - for (p1 = depth_peels.first; p1; p1 = p1->next) + + + for (p1 = sketch->depth_peels.first; p1; p1 = p1->next) { if (p1->flag == 0) { float vec[3]; float new_dist; - + float new_size = 0; + p2 = NULL; p1->flag = 1; - - /* if peeling objects, take the first and last from each object */ + + /* if peeling objects, take the first and last from each object */ if (ts->snap_flag & SCE_SNAP_PEEL_OBJECT) { DepthPeel *peel; @@ -1579,46 +1638,50 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok /* nothing to do here */ } } - + if (p2) { p2->flag = 1; - + VecAddf(vec, p1->p, p2->p); VecMulf(vec, 0.5f); + new_size = VecLenf(p1->p, p2->p); } else { VECCOPY(vec, p1->p); } - + if (last_p == NULL) { VECCOPY(p, vec); + size = new_size; dist = 0; break; } - + new_dist = VecLenf(last_p, vec); - + if (new_dist < dist) { VECCOPY(p, vec); dist = new_dist; + size = new_size; } } } - + if (dist != FLT_MAX) { pt->type = dd->type; pt->mode = PT_SNAP; + pt->size = size / 2; VECCOPY(pt->p, p); - + point_added = 1; } - - BLI_freelistN(&depth_peels); + + //BLI_freelistN(&depth_peels); } else { @@ -1641,7 +1704,7 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok { spt = sk_snapPointStroke(C, snap_stk, dd->mval, &dist, NULL, 1); } - + if (spt != NULL) { VECCOPY(pt->p, spt->p); @@ -1656,11 +1719,11 @@ int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Strok pt->type = dd->type; pt->mode = PT_SNAP; VECCOPY(pt->p, vec); - + point_added = 1; } } - + return point_added; } @@ -1668,23 +1731,23 @@ int sk_addStrokeSnapPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_Dra { int point_added; SK_Point pt; - + sk_initPoint(C, &pt); point_added = sk_getStrokeSnapPoint(C, &pt, sketch, stk, dd); - + if (point_added) { float final_p[3]; float length, distance; int total; int i; - + VECCOPY(final_p, pt.p); - + sk_projectDrawPoint(C, pt.p, stk, dd); sk_appendStrokePoint(stk, &pt); - + /* update all previous point to give smooth Z progresion */ total = 0; length = 0; @@ -1697,19 +1760,19 @@ int sk_addStrokeSnapPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_Dra break; } } - + if (total > 1) { distance = sk_distanceDepth(C, final_p, stk->points[i].p); - + sk_interpolateDepth(C, stk, i + 1, stk->nb_points - 2, length, distance); } - + VECCOPY(stk->points[stk->nb_points - 1].p, final_p); - + point_added = 1; } - + return point_added; } @@ -1717,17 +1780,17 @@ void sk_addStrokePoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawDa { ToolSettings *ts = CTX_data_tool_settings(C); int point_added = 0; - + if (snap) { point_added = sk_addStrokeSnapPoint(C, sketch, stk, dd); } - + if (point_added == 0) { point_added = sk_addStrokeDrawPoint(C, sketch, stk, dd); } - + if (stk == sketch->active_stroke && ts->bone_sketching & BONE_SKETCHING_ADJUST) { sk_updateOverdraw(C, sketch, stk, dd); @@ -1737,7 +1800,7 @@ void sk_addStrokePoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawDa void sk_getStrokePoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, short snap) { int point_added = 0; - + if (snap) { point_added = sk_getStrokeSnapPoint(C, pt, sketch, stk, dd); @@ -1748,11 +1811,11 @@ void sk_getStrokePoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_Stroke * { LAST_SNAP_POINT_VALID = 0; } - + if (point_added == 0) { point_added = sk_getStrokeDrawPoint(C, pt, sketch, stk, dd); - } + } } void sk_endContinuousStroke(SK_Stroke *stk) @@ -1775,7 +1838,7 @@ int sk_stroke_filtermval(SK_DrawData *dd) { retval = 1; } - + return retval; } @@ -1805,25 +1868,27 @@ static void initIteratorFct(SK_StrokeIterator *iter) iter->next = nextPoint; iter->nextN = nextNPoint; iter->previous = previousPoint; - iter->stopped = iteratorStopped; + iter->stopped = iteratorStopped; } static SK_Point* setIteratorValues(SK_StrokeIterator *iter, int index) { SK_Point *pt = NULL; - + if (index >= 0 && index < iter->length) { pt = &(iter->stroke->points[iter->start + (iter->stride * index)]); iter->p = pt->p; iter->no = pt->no; + iter->size = pt->size; } else { iter->p = NULL; iter->no = NULL; + iter->size = 0; } - + return pt; } @@ -1833,7 +1898,7 @@ void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end) initIteratorFct(iter); iter->stroke = stk; - + if (start < end) { iter->start = start + 1; @@ -1846,9 +1911,9 @@ void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end) iter->end = end + 1; iter->stride = -1; } - + iter->length = iter->stride * (iter->end - iter->start + 1); - + iter->index = -1; } @@ -1857,11 +1922,12 @@ static void* headPoint(void *arg) { SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; SK_Point *result = NULL; - + result = &(iter->stroke->points[iter->start - iter->stride]); iter->p = result->p; iter->no = result->no; - + iter->size = result->size; + return result; } @@ -1869,11 +1935,12 @@ static void* tailPoint(void *arg) { SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; SK_Point *result = NULL; - + result = &(iter->stroke->points[iter->end + iter->stride]); iter->p = result->p; iter->no = result->no; - + iter->size = result->size; + return result; } @@ -1881,7 +1948,7 @@ static void* nextPoint(void *arg) { SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; SK_Point *result = NULL; - + iter->index++; if (iter->index < iter->length) { @@ -1895,7 +1962,7 @@ static void* nextNPoint(void *arg, int n) { SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; SK_Point *result = NULL; - + iter->index += n; /* check if passed end */ @@ -1926,7 +1993,7 @@ static void* previousPoint(void *arg) { SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; SK_Point *result = NULL; - + if (iter->index > 0) { iter->index--; @@ -1961,18 +2028,18 @@ void sk_convertStroke(bContext *C, SK_Stroke *stk) float tmat[3][3]; int head_index = 0; int i; - + head = NULL; - + Mat4Invert(invmat, obedit->obmat); - + Mat3CpyMat4(tmat, obedit->obmat); Mat3Transp(tmat); - + for (i = 0; i < stk->nb_points; i++) { SK_Point *pt = stk->points + i; - + if (pt->type == PT_EXACT) { if (head == NULL) @@ -1984,14 +2051,14 @@ void sk_convertStroke(bContext *C, SK_Stroke *stk) { EditBone *bone = NULL; EditBone *new_parent; - + if (i - head_index > 1) { SK_StrokeIterator sk_iter; BArcIterator *iter = (BArcIterator*)&sk_iter; initStrokeIterator(iter, stk, head_index, i); - + if (ts->bone_sketching_convert == SK_CONVERT_CUT_ADAPTATIVE) { bone = subdivideArcBy(ts, arm, arm->edbo, iter, invmat, tmat, nextAdaptativeSubdivision); @@ -2005,11 +2072,11 @@ void sk_convertStroke(bContext *C, SK_Stroke *stk) bone = subdivideArcBy(ts, arm, arm->edbo, iter, invmat, tmat, nextFixedSubdivision); } } - + if (bone == NULL) { bone = addEditBone(arm, "Bone"); - + VECCOPY(bone->head, head->p); VECCOPY(bone->tail, pt->p); @@ -2017,10 +2084,10 @@ void sk_convertStroke(bContext *C, SK_Stroke *stk) Mat4MulVecfl(invmat, bone->tail); setBoneRollFromNormal(bone, head->no, invmat, tmat); } - + new_parent = bone; bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; - + /* move to end of chain */ while (bone->parent != NULL) { @@ -2031,9 +2098,9 @@ void sk_convertStroke(bContext *C, SK_Stroke *stk) if (parent != NULL) { bone->parent = parent; - bone->flag |= BONE_CONNECTED; + bone->flag |= BONE_CONNECTED; } - + parent = new_parent; head_index = i; head = pt; @@ -2046,7 +2113,7 @@ void sk_convert(bContext *C, SK_Sketch *sketch) { ToolSettings *ts = CTX_data_tool_settings(C); SK_Stroke *stk; - + for (stk = sketch->strokes.first; stk; stk = stk->next) { if (stk->selected == 1) @@ -2079,7 +2146,7 @@ int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture) float s_p1[3] = {0, 0, 0}; float s_p2[3] = {0, 0, 0}; int g_i; - + project_float(ar, gesture->points[s_i].p, s_p1); project_float(ar, gesture->points[s_i + 1].p, s_p2); @@ -2090,37 +2157,37 @@ int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture) float g_p2[3] = {0, 0, 0}; float vi[3]; float lambda; - + project_float(ar, gesture->points[g_i].p, g_p1); project_float(ar, gesture->points[g_i + 1].p, g_p2); - + if (LineIntersectLineStrict(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); - + isect->gesture_index = g_i; isect->before = s_i; isect->after = s_i + 1; isect->stroke = gesture; - + VecSubf(isect->p, gesture->points[s_i + 1].p, gesture->points[s_i].p); VecMulf(isect->p, lambda); VecAddf(isect->p, isect->p, gesture->points[s_i].p); - + BLI_addtail(list, isect); added++; } } } - + return added; } int cmpIntersections(void *i1, void *i2) { SK_Intersection *isect1 = i1, *isect2 = i2; - + if (isect1->stroke == isect2->stroke) { if (isect1->before < isect2->before) @@ -2143,7 +2210,7 @@ int cmpIntersections(void *i1, void *i2) } } } - + return 0; } @@ -2161,13 +2228,13 @@ int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Strok { int s_added = 0; int s_i; - + for (s_i = 0; s_i < stk->nb_points - 1; s_i++) { float s_p1[3] = {0, 0, 0}; float s_p2[3] = {0, 0, 0}; int g_i; - + project_float(ar, stk->points[s_i].p, s_p1); project_float(ar, stk->points[s_i + 1].p, s_p2); @@ -2177,45 +2244,45 @@ int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, SK_Strok float g_p2[3] = {0, 0, 0}; float vi[3]; float lambda; - + project_float(ar, gesture->points[g_i].p, g_p1); project_float(ar, gesture->points[g_i + 1].p, g_p2); - + if (LineIntersectLineStrict(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) { SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection"); float ray_start[3], ray_end[3]; short mval[2]; - + isect->gesture_index = g_i; isect->before = s_i; isect->after = s_i + 1; isect->stroke = stk; isect->lambda = lambda; - + mval[0] = (short)(vi[0]); mval[1] = (short)(vi[1]); viewline(ar, v3d, mval, ray_start, ray_end); - + LineIntersectLine( stk->points[s_i].p, stk->points[s_i + 1].p, ray_start, ray_end, isect->p, vi); - + BLI_addtail(list, isect); s_added++; } } } - + added = MAX2(s_added, added); } - + BLI_sortlist(list, cmpIntersections); - + return added; } @@ -2223,23 +2290,23 @@ int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture) { SK_StrokeIterator sk_iter; BArcIterator *iter = (BArcIterator*)&sk_iter; - + float CORRELATION_THRESHOLD = 0.99f; float *vec; int i, j; - + sk_appendStrokePoint(segments, &gesture->points[0]); vec = segments->points[segments->nb_points - 1].p; initStrokeIterator(iter, gesture, 0, gesture->nb_points - 1); for (i = 1, j = 0; i < gesture->nb_points; i++) - { + { float n[3]; - + /* Calculate normal */ VecSubf(n, gesture->points[i].p, vec); - + if (calcArcCorrelation(iter, j, i, vec, n) < CORRELATION_THRESHOLD) { j = i - 1; @@ -2250,7 +2317,7 @@ int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture) } sk_appendStrokePoint(segments, &gesture->points[gesture->nb_points - 1]); - + return segments->nb_points - 1; } @@ -2267,16 +2334,16 @@ int sk_detectCutGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) void sk_applyCutGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { SK_Intersection *isect; - + for (isect = gest->intersections.first; isect; isect = isect->next) { SK_Point pt; - + pt.type = PT_EXACT; pt.mode = PT_PROJECT; /* take mode from neighbouring points */ VECCOPY(pt.p, isect->p); VECCOPY(pt.no, isect->stroke->points[isect->before].no); - + sk_insertStrokePoint(isect->stroke, &pt, isect->after); } } @@ -2287,12 +2354,12 @@ int sk_detectTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { float s1[3], s2[3]; float angle; - + VecSubf(s1, gest->segments->points[1].p, gest->segments->points[0].p); VecSubf(s2, gest->segments->points[2].p, gest->segments->points[1].p); - + angle = VecAngle2(s1, s2); - + if (angle > 60 && angle < 120) { return 1; @@ -2306,21 +2373,21 @@ void sk_applyTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { SK_Intersection *isect; float trim_dir[3]; - + VecSubf(trim_dir, gest->segments->points[2].p, gest->segments->points[1].p); - + for (isect = gest->intersections.first; isect; isect = isect->next) { SK_Point pt; float stroke_dir[3]; - + pt.type = PT_EXACT; pt.mode = PT_PROJECT; /* take mode from neighbouring points */ VECCOPY(pt.p, isect->p); VECCOPY(pt.no, isect->stroke->points[isect->before].no); - + VecSubf(stroke_dir, isect->stroke->points[isect->after].p, isect->stroke->points[isect->before].p); - + /* same direction, trim end */ if (Inpf(stroke_dir, trim_dir) > 0) { @@ -2333,7 +2400,7 @@ void sk_applyTrimGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) sk_replaceStrokePoint(isect->stroke, &pt, isect->before); sk_trimStroke(isect->stroke, isect->before, isect->stroke->nb_points - 1); } - + } } @@ -2342,7 +2409,7 @@ int sk_detectCommandGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 1) { SK_Intersection *isect, *self_isect; - + /* get the the last intersection of the first pair */ for( isect = gest->intersections.first; isect; isect = isect->next ) { @@ -2352,15 +2419,15 @@ int sk_detectCommandGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) break; } } - + self_isect = gest->self_intersections.first; - + if (isect && isect->gesture_index < self_isect->gesture_index) { return 1; } } - + return 0; } @@ -2368,7 +2435,7 @@ void sk_applyCommandGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { SK_Intersection *isect; int command = 1; - + // XXX // command = pupmenu("Action %t|Flatten %x1|Straighten %x2|Polygonize %x3"); if(command < 1) return; @@ -2376,9 +2443,9 @@ void sk_applyCommandGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) for (isect = gest->intersections.first; isect; isect = isect->next) { SK_Intersection *i2; - + i2 = isect->next; - + if (i2 && i2->stroke == isect->stroke) { switch (command) @@ -2405,32 +2472,32 @@ int sk_detectDeleteGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { float s1[3], s2[3]; float angle; - + VecSubf(s1, gest->segments->points[1].p, gest->segments->points[0].p); VecSubf(s2, gest->segments->points[2].p, gest->segments->points[1].p); - + angle = VecAngle2(s1, s2); - + if (angle > 120) { return 1; } } - + return 0; } void sk_applyDeleteGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { SK_Intersection *isect; - + for (isect = gest->intersections.first; isect; isect = isect->next) { /* only delete strokes that are crossed twice */ if (isect->next && isect->next->stroke == isect->stroke) { isect = isect->next; - + sk_removeStroke(sketch, isect->stroke); } } @@ -2443,17 +2510,17 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { short start_val[2], end_val[2]; short dist; - + project_short_noclip(ar, gest->stk->points[0].p, start_val); project_short_noclip(ar, sk_lastStrokePoint(gest->stk)->p, end_val); - + 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; - + /* check if it circled around an exact point */ for (isect = gest->intersections.first; isect; isect = isect->next) { @@ -2462,10 +2529,10 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { int start_index, end_index; int i; - + 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) @@ -2473,21 +2540,21 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) return 1; /* at least one exact point found, stop detect here */ } } - - /* skip next */ + + /* skip next */ isect = isect->next; } } } } - + return 0; } void sk_applyMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { SK_Intersection *isect; - + /* check if it circled around an exact point */ for (isect = gest->intersections.first; isect; isect = isect->next) { @@ -2496,7 +2563,7 @@ void sk_applyMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { int start_index, end_index; int i; - + start_index = MIN2(isect->after, isect->next->after); end_index = MAX2(isect->before, isect->next->before); @@ -2509,7 +2576,7 @@ void sk_applyMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) } } - /* skip next */ + /* skip next */ isect = isect->next; } } @@ -2520,7 +2587,7 @@ int sk_detectReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 0) { SK_Intersection *isect; - + /* check if it circled around an exact point */ for (isect = gest->intersections.first; isect; isect = isect->next) { @@ -2529,7 +2596,7 @@ int sk_detectReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { float start_v[3], end_v[3]; float angle; - + if (isect->gesture_index < isect->next->gesture_index) { VecSubf(start_v, isect->p, gest->stk->points[0].p); @@ -2540,27 +2607,27 @@ int sk_detectReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) VecSubf(start_v, isect->next->p, gest->stk->points[0].p); VecSubf(end_v, sk_lastStrokePoint(gest->stk)->p, isect->p); } - + angle = VecAngle2(start_v, end_v); - + if (angle > 120) { return 1; } - - /* skip next */ + + /* skip next */ isect = isect->next; } } } - + return 0; } void sk_applyReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { SK_Intersection *isect; - + for (isect = gest->intersections.first; isect; isect = isect->next) { /* only reverse strokes that are crossed twice */ @@ -2568,7 +2635,7 @@ void sk_applyReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { sk_reverseStroke(isect->stroke); - /* skip next */ + /* skip next */ isect = isect->next; } } @@ -2592,7 +2659,7 @@ static void sk_initGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { gest->intersections.first = gest->intersections.last = NULL; gest->self_intersections.first = gest->self_intersections.last = NULL; - + gest->segments = sk_createStroke(); gest->stk = sketch->gesture; @@ -2612,9 +2679,9 @@ void sk_applyGesture(bContext *C, SK_Sketch *sketch) { SK_Gesture gest; SK_GestureAction *act; - + sk_initGesture(C, &gest, sketch); - + /* detect and apply */ for (act = GESTURE_ACTIONS; act->apply != NULL; act++) { @@ -2624,7 +2691,7 @@ void sk_applyGesture(bContext *C, SK_Sketch *sketch) break; } } - + sk_freeGesture(&gest); } @@ -2633,11 +2700,11 @@ void sk_applyGesture(bContext *C, SK_Sketch *sketch) void sk_deleteSelectedStrokes(SK_Sketch *sketch) { SK_Stroke *stk, *next; - + for (stk = sketch->strokes.first; stk; stk = next) { next = stk->next; - + if (stk->selected == 1) { sk_removeStroke(sketch, stk); @@ -2648,7 +2715,7 @@ void sk_deleteSelectedStrokes(SK_Sketch *sketch) void sk_selectAllSketch(SK_Sketch *sketch, int mode) { SK_Stroke *stk = NULL; - + if (mode == -1) { for (stk = sketch->strokes.first; stk; stk = stk->next) @@ -2666,12 +2733,12 @@ void sk_selectAllSketch(SK_Sketch *sketch, int mode) else if (mode == 1) { int selected = 1; - + for (stk = sketch->strokes.first; stk; stk = stk->next) { selected &= stk->selected; } - + selected ^= 1; for (stk = sketch->strokes.first; stk; stk = stk->next) @@ -2687,20 +2754,20 @@ void sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend) rcti rect; unsigned int buffer[MAXPICKBUF]; short hits; - + view3d_set_viewcontext(C, &vc); - + rect.xmin= mval[0]-5; rect.xmax= mval[0]+5; rect.ymin= mval[1]-5; rect.ymax= mval[1]+5; - + hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); if (hits>0) { int besthitresult = -1; - + if(hits == 1) { besthitresult = buffer[3]; } @@ -2708,23 +2775,23 @@ void sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend) besthitresult = buffer[3]; /* loop and get best hit */ } - + if (besthitresult > 0) { SK_Stroke *selected_stk = BLI_findlink(&sketch->strokes, besthitresult - 1); - + if (extend == 0) { sk_selectAllSketch(sketch, -1); - + selected_stk->selected = 1; } else { selected_stk->selected ^= 1; } - - + + } } } @@ -2734,7 +2801,7 @@ void sk_queueRedrawSketch(SK_Sketch *sketch) if (sketch->active_stroke != NULL) { SK_Point *last = sk_lastStrokePoint(sketch->active_stroke); - + if (last != NULL) { // XXX @@ -2743,16 +2810,14 @@ void sk_queueRedrawSketch(SK_Sketch *sketch) } } -void sk_drawSketch(Scene *scene, SK_Sketch *sketch, int with_names) +void sk_drawSketch(Scene *scene, View3D *v3d, SK_Sketch *sketch, int with_names) { ToolSettings *ts= scene->toolsettings; SK_Stroke *stk; - - glDisable(GL_DEPTH_TEST); - glLineWidth(UI_GetThemeValuef(TH_VERTEX_SIZE)); - glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); - + glClear(GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + if (with_names) { int id; @@ -2760,61 +2825,51 @@ void sk_drawSketch(Scene *scene, SK_Sketch *sketch, int with_names) { sk_drawStroke(stk, id, NULL, -1, -1); } - + glLoadName(-1); } else { float selected_rgb[3] = {1, 0, 0}; float unselected_rgb[3] = {1, 0.5, 0}; - + for (stk = sketch->strokes.first; stk; stk = stk->next) { int start = -1; int end = -1; - + if (sk_hasOverdraw(sketch, stk)) { sk_adjustIndexes(sketch, &start, &end); } - + sk_drawStroke(stk, -1, (stk->selected==1?selected_rgb:unselected_rgb), start, end); - + if (stk->selected == 1) { sk_drawStrokeSubdivision(ts, stk); } } - - /* only draw gesture in active area */ - if (sketch->gesture != NULL /*&& area_is_active_area(G.vd->area)*/) - { - float gesture_rgb[3] = {0, 0.5, 1}; - sk_drawStroke(sketch->gesture, -1, gesture_rgb, -1, -1); - } - + if (sketch->active_stroke != NULL) { SK_Point *last = sk_lastStrokePoint(sketch->active_stroke); - + if (ts->bone_sketching & BONE_SKETCHING_QUICK) { sk_drawStrokeSubdivision(ts, sketch->active_stroke); } - + if (last != NULL) { - glEnable(GL_LINE_STIPPLE); - glColor3fv(selected_rgb); - glBegin(GL_LINE_STRIP); - - glVertex3fv(last->p); - glVertex3fv(sketch->next_point.p); - - glEnd(); - - glDisable(GL_LINE_STIPPLE); - + GLUquadric *quad = gluNewQuadric(); + gluQuadricNormals(quad, GLU_SMOOTH); + + glPushMatrix(); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + switch (sketch->next_point.mode) { case PT_SNAP: @@ -2824,20 +2879,63 @@ void sk_drawSketch(Scene *scene, SK_Sketch *sketch, int with_names) glColor3f(0, 0, 0); break; } - - glBegin(GL_POINTS); - - glVertex3fv(sketch->next_point.p); - - glEnd(); + + sk_drawPoint(quad, &sketch->next_point, 0.1); + + glColor4f(selected_rgb[0], selected_rgb[1], selected_rgb[2], 0.3); + + sk_drawEdge(quad, last, &sketch->next_point, 0.1); + + glDisable(GL_BLEND); + + glPopMatrix(); + + gluDeleteQuadric(quad); } } } - - glLineWidth(1.0); - glPointSize(1.0); - glEnable(GL_DEPTH_TEST); +#if 0 + if (sketch->depth_peels.first != NULL) + { + float colors[8][3] = { + {1, 0, 0}, + {0, 1, 0}, + {0, 0, 1}, + {1, 1, 0}, + {1, 0, 1}, + {0, 1, 1}, + {1, 1, 1}, + {0, 0, 0} + }; + DepthPeel *p; + GLUquadric *quad = gluNewQuadric(); + gluQuadricNormals(quad, GLU_SMOOTH); + + for (p = sketch->depth_peels.first; p; p = p->next) + { + int index = (int)(p->ob); + index = (index >> 5) & 7; + + glColor3fv(colors[index]); + glPushMatrix(); + glTranslatef(p->p[0], p->p[1], p->p[2]); + gluSphere(quad, 0.02, 8, 8); + glPopMatrix(); + } + + gluDeleteQuadric(quad); + } +#endif + + glDisable(GL_DEPTH_TEST); + + /* only draw gesture in active area */ + if (sketch->gesture != NULL /*&& area_is_active_area(G.vd->area)*/) + { + float gesture_rgb[3] = {0, 0.5, 1}; + sk_drawStroke(sketch->gesture, -1, gesture_rgb, -1, -1); + } } int sk_finish_stroke(bContext *C, SK_Sketch *sketch) @@ -2847,9 +2945,9 @@ int sk_finish_stroke(bContext *C, SK_Sketch *sketch) if (sketch->active_stroke != NULL) { SK_Stroke *stk = sketch->active_stroke; - + sk_endStroke(C, sketch); - + if (ts->bone_sketching & BONE_SKETCHING_QUICK) { if (ts->bone_sketching_convert == SK_CONVERT_RETARGET) @@ -2867,11 +2965,11 @@ int sk_finish_stroke(bContext *C, SK_Sketch *sketch) // allqueue(REDRAWBUTSEDIT, 0); } -// XXX +// XXX // allqueue(REDRAWVIEW3D, 0); return 1; } - + return 0; } @@ -2881,7 +2979,7 @@ void sk_start_draw_stroke(SK_Sketch *sketch) { sk_startStroke(sketch); sk_selectAllSketch(sketch, -1); - + sketch->active_stroke->selected = 1; } } @@ -2900,7 +2998,7 @@ int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData * sk_updateNextPoint(sketch, stk); return 1; } - + return 0; } @@ -2908,9 +3006,9 @@ static int ValidSketchViewContext(ViewContext *vc) { Object *obedit = vc->obedit; Scene *scene= vc->scene; - - if (obedit && - obedit->type == OB_ARMATURE && + + if (obedit && + obedit->type == OB_ARMATURE && scene->toolsettings->bone_sketching & BONE_SKETCHING) { return 1; @@ -2927,11 +3025,11 @@ int BDR_drawSketchNames(ViewContext *vc) { if (GLOBAL_sketch != NULL) { - sk_drawSketch(vc->scene, GLOBAL_sketch, 1); + sk_drawSketch(vc->scene, vc->v3d, GLOBAL_sketch, 1); return 1; } } - + return 0; } @@ -2941,7 +3039,7 @@ void BDR_drawSketch(bContext *C) { if (GLOBAL_sketch != NULL) { - sk_drawSketch(CTX_data_scene(C), GLOBAL_sketch, 0); + sk_drawSketch(CTX_data_scene(C), CTX_wm_view3d(C), GLOBAL_sketch, 0); } } } @@ -3045,14 +3143,14 @@ static int sketch_select(bContext *C, wmOperator *op, wmEvent *event) sk_selectStroke(C, GLOBAL_sketch, event->mval, extend); ED_area_tag_redraw(CTX_wm_area(C)); } - + return OPERATOR_FINISHED; } static int sketch_draw_stroke_cancel(bContext *C, wmOperator *op) { sk_cancelStroke(GLOBAL_sketch); - MEM_freeN(op->customdata); + MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -3060,19 +3158,19 @@ static int sketch_draw_stroke(bContext *C, wmOperator *op, wmEvent *event) { short snap = RNA_boolean_get(op->ptr, "snap"); SK_DrawData *dd; - + if (GLOBAL_sketch == NULL) { GLOBAL_sketch = sk_createSketch(); } - + op->customdata = dd = MEM_callocN(sizeof("SK_DrawData"), "SketchDrawData"); sk_initDrawData(dd, event->mval); - + sk_start_draw_stroke(GLOBAL_sketch); - + sk_draw_stroke(C, GLOBAL_sketch, GLOBAL_sketch->active_stroke, dd, snap); - + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); return OPERATOR_RUNNING_MODAL; @@ -3081,7 +3179,7 @@ static int sketch_draw_stroke(bContext *C, wmOperator *op, wmEvent *event) static int sketch_draw_gesture_cancel(bContext *C, wmOperator *op) { sk_cancelStroke(GLOBAL_sketch); - MEM_freeN(op->customdata); + MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -3089,18 +3187,18 @@ static int sketch_draw_gesture(bContext *C, wmOperator *op, wmEvent *event) { short snap = RNA_boolean_get(op->ptr, "snap"); SK_DrawData *dd; - + if (GLOBAL_sketch == NULL) { GLOBAL_sketch = sk_createSketch(); } - + op->customdata = dd = MEM_callocN(sizeof("SK_DrawData"), "SketchDrawData"); sk_initDrawData(dd, event->mval); - + sk_start_draw_gesture(GLOBAL_sketch); sk_draw_stroke(C, GLOBAL_sketch, GLOBAL_sketch->gesture, dd, snap); - + WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); return OPERATOR_RUNNING_MODAL; @@ -3111,7 +3209,7 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short short snap = RNA_boolean_get(op->ptr, "snap"); SK_DrawData *dd = op->customdata; int retval = OPERATOR_RUNNING_MODAL; - + switch (event->type) { case LEFTCTRLKEY: @@ -3139,31 +3237,31 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short sk_filterLastContinuousStroke(stk); sk_updateNextPoint(GLOBAL_sketch, stk); ED_area_tag_redraw(CTX_wm_area(C)); - MEM_freeN(op->customdata); + MEM_freeN(op->customdata); retval = OPERATOR_FINISHED; } else { sk_endContinuousStroke(stk); sk_filterLastContinuousStroke(stk); - - if (stk->nb_points > 1) + + if (stk->nb_points > 1) { /* apply gesture here */ sk_applyGesture(C, GLOBAL_sketch); } - + sk_freeStroke(stk); GLOBAL_sketch->gesture = NULL; - + ED_area_tag_redraw(CTX_wm_area(C)); - MEM_freeN(op->customdata); + MEM_freeN(op->customdata); retval = OPERATOR_FINISHED; } } break; } - + return retval; } @@ -3180,17 +3278,17 @@ static int sketch_draw_gesture_modal(bContext *C, wmOperator *op, wmEvent *event static int sketch_draw_preview(bContext *C, wmOperator *op, wmEvent *event) { short snap = RNA_boolean_get(op->ptr, "snap"); - + if (GLOBAL_sketch != NULL) { SK_Sketch *sketch = GLOBAL_sketch; SK_DrawData dd; - + sk_initDrawData(&dd, event->mval); sk_getStrokePoint(C, &sketch->next_point, sketch, sketch->active_stroke, &dd, snap); ED_area_tag_redraw(CTX_wm_area(C)); } - + return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; } @@ -3200,9 +3298,9 @@ int ED_operator_sketch_mode_active_stroke(bContext *C) { Object *obedit = CTX_data_edit_object(C); ToolSettings *ts = CTX_data_tool_settings(C); - - if (obedit && - obedit->type == OB_ARMATURE && + + if (obedit && + obedit->type == OB_ARMATURE && ts->bone_sketching & BONE_SKETCHING && GLOBAL_sketch != NULL && GLOBAL_sketch->active_stroke != NULL) @@ -3219,9 +3317,9 @@ int ED_operator_sketch_mode_gesture(bContext *C) { Object *obedit = CTX_data_edit_object(C); ToolSettings *ts = CTX_data_tool_settings(C); - - if (obedit && - obedit->type == OB_ARMATURE && + + if (obedit && + obedit->type == OB_ARMATURE && ts->bone_sketching & BONE_SKETCHING && (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0 && GLOBAL_sketch != NULL && @@ -3239,10 +3337,10 @@ int ED_operator_sketch_full_mode(bContext *C) { Object *obedit = CTX_data_edit_object(C); ToolSettings *ts = CTX_data_tool_settings(C); - - if (obedit && - obedit->type == OB_ARMATURE && - ts->bone_sketching & BONE_SKETCHING && + + if (obedit && + obedit->type == OB_ARMATURE && + ts->bone_sketching & BONE_SKETCHING && (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0) { return 1; @@ -3257,9 +3355,9 @@ int ED_operator_sketch_mode(bContext *C) { Object *obedit = CTX_data_edit_object(C); ToolSettings *ts = CTX_data_tool_settings(C); - - if (obedit && - obedit->type == OB_ARMATURE && + + if (obedit && + obedit->type == OB_ARMATURE && ts->bone_sketching & BONE_SKETCHING) { return 1; @@ -3277,12 +3375,12 @@ void SKETCH_OT_delete(wmOperatorType *ot) /* identifiers */ ot->name= "delete"; ot->idname= "SKETCH_OT_delete"; - + /* api callbacks */ ot->invoke= sketch_delete; - + ot->poll= ED_operator_sketch_full_mode; - + /* flags */ // ot->flag= OPTYPE_UNDO; } @@ -3292,12 +3390,12 @@ void SKETCH_OT_select(wmOperatorType *ot) /* identifiers */ ot->name= "select"; ot->idname= "SKETCH_OT_select"; - + /* api callbacks */ ot->invoke= sketch_select; - + ot->poll= ED_operator_sketch_full_mode; - + /* flags */ // ot->flag= OPTYPE_UNDO; } @@ -3307,12 +3405,12 @@ void SKETCH_OT_cancel_stroke(wmOperatorType *ot) /* identifiers */ ot->name= "cancel stroke"; ot->idname= "SKETCH_OT_cancel_stroke"; - + /* api callbacks */ ot->invoke= sketch_cancel; - + ot->poll= ED_operator_sketch_mode_active_stroke; - + /* flags */ // ot->flag= OPTYPE_UNDO; } @@ -3322,12 +3420,12 @@ void SKETCH_OT_finish_stroke(wmOperatorType *ot) /* identifiers */ ot->name= "end stroke"; ot->idname= "SKETCH_OT_finish_stroke"; - + /* api callbacks */ ot->invoke= sketch_finish; - + ot->poll= ED_operator_sketch_mode_active_stroke; - + /* flags */ // ot->flag= OPTYPE_UNDO; } @@ -3337,12 +3435,12 @@ void SKETCH_OT_draw_preview(wmOperatorType *ot) /* identifiers */ ot->name= "draw preview"; ot->idname= "SKETCH_OT_draw_preview"; - + /* api callbacks */ ot->invoke= sketch_draw_preview; - + ot->poll= ED_operator_sketch_mode_active_stroke; - + RNA_def_boolean(ot->srna, "snap", 0, "Snap", ""); /* flags */ @@ -3354,16 +3452,16 @@ void SKETCH_OT_draw_stroke(wmOperatorType *ot) /* identifiers */ ot->name= "draw stroke"; ot->idname= "SKETCH_OT_draw_stroke"; - + /* api callbacks */ ot->invoke = sketch_draw_stroke; ot->modal = sketch_draw_stroke_modal; ot->cancel = sketch_draw_stroke_cancel; - + ot->poll= ED_operator_sketch_mode; - + RNA_def_boolean(ot->srna, "snap", 0, "Snap", ""); - + /* flags */ // ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -3373,16 +3471,16 @@ void SKETCH_OT_gesture(wmOperatorType *ot) /* identifiers */ ot->name= "gesture"; ot->idname= "SKETCH_OT_gesture"; - + /* api callbacks */ ot->invoke = sketch_draw_gesture; ot->modal = sketch_draw_gesture_modal; ot->cancel = sketch_draw_gesture_cancel; - + ot->poll= ED_operator_sketch_mode_gesture; - + RNA_def_boolean(ot->srna, "snap", 0, "Snap", ""); - + /* flags */ // ot->flag= OPTYPE_UNDO; } diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index ea794b2c7c1..132d9edf8d0 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -3179,6 +3179,7 @@ static void setIteratorValues(ReebArcIterator *iter, EmbedBucket *bucket) iter->p = NULL; iter->no = NULL; } + iter->size = 0; } void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head) @@ -3276,6 +3277,7 @@ static void* headNode(void *arg) iter->p = node->p; iter->no = node->no; + iter->size = 0; return node; } @@ -3296,6 +3298,7 @@ static void* tailNode(void *arg) iter->p = node->p; iter->no = node->no; + iter->size = 0; return node; } diff --git a/source/blender/editors/armature/reeb.h b/source/blender/editors/armature/reeb.h index 3bdd55509ad..6a3a261cb10 100644 --- a/source/blender/editors/armature/reeb.h +++ b/source/blender/editors/armature/reeb.h @@ -126,6 +126,7 @@ typedef struct ReebArcIterator { StoppedFct stopped; float *p, *no; + float size; int length; int index; |