From 56534ecdcbd08a32bfa7f2415c25237d44c69a5d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 3 Sep 2012 02:41:12 +0000 Subject: style cleanup: also add debugging print function for derived mesh DM_debug_print_cdlayers() --- source/blender/blenkernel/BKE_DerivedMesh.h | 1 + source/blender/blenkernel/intern/DerivedMesh.c | 21 +++ source/blender/editors/interface/interface_style.c | 2 +- source/blender/editors/mesh/editmesh_knife.c | 151 +++++++++++---------- source/blender/editors/space_view3d/drawobject.c | 14 +- source/blender/editors/transform/transform.c | 4 +- source/blender/makesdna/DNA_ipo_types.h | 4 +- source/blender/makesrna/intern/makesrna.c | 4 +- source/blender/nodes/shader/node_shader_tree.c | 46 +++---- source/blender/nodes/texture/node_texture_tree.c | 60 ++++---- source/blender/quicktime/apple/qtkit_export.m | 51 +++---- 11 files changed, 194 insertions(+), 164 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 64512dcaac8..fa9223ba6e2 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -698,6 +698,7 @@ void DM_init_origspace(DerivedMesh *dm); #ifndef NDEBUG char *DM_debug_info(DerivedMesh *dm); void DM_debug_print(DerivedMesh *dm); +void DM_debug_print_cdlayers(CustomData *cdata); #endif #endif diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index a29484638c0..1aa54307841 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -3187,4 +3187,25 @@ void DM_debug_print(DerivedMesh *dm) MEM_freeN(str); } +void DM_debug_print_cdlayers(CustomData *data) +{ + int i; + CustomDataLayer *layer; + + printf("{\n"); + + for (i = 0, layer = data->layers; i < data->totlayer; i++, layer++) { + + const char *name = CustomData_layertype_name(layer->type); + const int size = CustomData_sizeof(layer->type); + const char *structname; + int structnum; + CustomData_file_write_info(layer->type, &structname, &structnum); + printf(" dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n", + name, structname, layer->type, (void *)layer->data, size, (int)(MEM_allocN_len(layer->data) / size)); + } + + printf("}\n"); +} + #endif /* NDEBUG */ diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index ee0613ea0d0..b16250021d3 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -257,7 +257,7 @@ uiStyle *UI_GetStyle(void) { uiStyle *style = NULL; /* offset is two struct uiStyle pointers */ - /* style = BLI_findstring( &U.uistyles, "Unifont Style", sizeof(style)*2 ) */; + /* style = BLI_findstring(&U.uistyles, "Unifont Style", sizeof(style) * 2) */; return (style != NULL) ? style : U.uistyles.first; } diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 229bbdbefb7..b3d2e9c985b 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -160,7 +160,7 @@ typedef struct KnifeTool_OpData { int totlinehit; /* Data for mouse-position-derived data (cur) and previous click (prev) */ - KnifePosData cur, prev; + KnifePosData curr, prev; int totkedge, totkvert; @@ -368,22 +368,22 @@ static KnifeEdge *get_bm_knife_edge(KnifeTool_OpData *kcd, BMEdge *e) * Copy the current position data into prev. */ static void knife_start_cut(KnifeTool_OpData *kcd) { - kcd->prev = kcd->cur; - kcd->cur.is_space = 0; /*TODO: why do we do this? */ + kcd->prev = kcd->curr; + kcd->curr.is_space = 0; /*TODO: why do we do this? */ if (kcd->prev.vert == NULL && kcd->prev.edge == NULL && is_zero_v3(kcd->prev.cage)) { /* Make prevcage a point on the view ray to mouse closest to a point on model: choose vertex 0 */ float origin[3], ray[3], co[3]; BMVert *v0; - knife_input_ray_cast(kcd, kcd->cur.mval, origin, ray); + knife_input_ray_cast(kcd, kcd->curr.mval, origin, ray); add_v3_v3v3(co, origin, ray); v0 = BM_vert_at_index(kcd->em->bm, 0); if (v0) { closest_to_line_v3(kcd->prev.cage, v0->co, co, origin); copy_v3_v3(kcd->prev.co, kcd->prev.cage); /*TODO: do we need this? */ - copy_v3_v3(kcd->cur.cage, kcd->prev.cage); - copy_v3_v3(kcd->cur.co, kcd->prev.co); + copy_v3_v3(kcd->curr.cage, kcd->prev.cage); + copy_v3_v3(kcd->curr.co, kcd->prev.co); } } } @@ -471,15 +471,15 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd, KnifeEdge *kfe, float return newkfe->v2; } -/* Make a single KnifeEdge for cut from kcd->prev to kcd->cur. +/* Make a single KnifeEdge for cut from kcd->prev to kcd->curr. * and move cur data to prev. */ static void knife_add_single_cut(KnifeTool_OpData *kcd) { KnifeEdge *kfe = new_knife_edge(kcd), *kfe2 = NULL, *kfe3 = NULL; - if (kcd->prev.vert && kcd->prev.vert == kcd->cur.vert) + if (kcd->prev.vert && kcd->prev.vert == kcd->curr.vert) return; - if (kcd->prev.edge && kcd->prev.edge == kcd->cur.edge) + if (kcd->prev.edge && kcd->prev.edge == kcd->curr.edge) return; kfe->draw = 1; @@ -500,25 +500,25 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd) knife_append_list(kcd, &kfe->v1->faces, kcd->prev.bmface); } - if (kcd->cur.vert) { - kfe->v2 = kcd->cur.vert; + if (kcd->curr.vert) { + kfe->v2 = kcd->curr.vert; } - else if (kcd->cur.edge) { - kfe->v2 = knife_split_edge(kcd, kcd->cur.edge, kcd->cur.co, &kfe3); - kcd->cur.vert = kfe->v2; + else if (kcd->curr.edge) { + kfe->v2 = knife_split_edge(kcd, kcd->curr.edge, kcd->curr.co, &kfe3); + kcd->curr.vert = kfe->v2; } else { - kfe->v2 = new_knife_vert(kcd, kcd->cur.co, kcd->cur.co); - kfe->v2->draw = !kcd->cur.is_space; + kfe->v2 = new_knife_vert(kcd, kcd->curr.co, kcd->curr.co); + kfe->v2->draw = !kcd->curr.is_space; kfe->v2->isface = 1; - kfe->v2->inspace = kcd->cur.is_space; - if (kfe->v2->draw && kcd->cur.bmface) - knife_append_list(kcd, &kfe->v2->faces, kcd->cur.bmface); + kfe->v2->inspace = kcd->curr.is_space; + if (kfe->v2->draw && kcd->curr.bmface) + knife_append_list(kcd, &kfe->v2->faces, kcd->curr.bmface); - if (kcd->cur.is_space) + if (kcd->curr.is_space) kfe->draw = 0; - kcd->cur.vert = kfe->v2; + kcd->curr.vert = kfe->v2; } knife_find_basef(kfe); @@ -529,12 +529,12 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd) knife_edge_append_face(kcd, kfe, kfe->basef); /* sanity check to make sure we're in the right edge/face lists */ - if (kcd->cur.bmface) { - if (!find_ref(&kfe->faces, kcd->cur.bmface)) { - knife_edge_append_face(kcd, kfe, kcd->cur.bmface); + if (kcd->curr.bmface) { + if (!find_ref(&kfe->faces, kcd->curr.bmface)) { + knife_edge_append_face(kcd, kfe, kcd->curr.bmface); } - if (kcd->prev.bmface && kcd->prev.bmface != kcd->cur.bmface) { + if (kcd->prev.bmface && kcd->prev.bmface != kcd->curr.bmface) { if (!find_ref(&kfe->faces, kcd->prev.bmface)) { knife_edge_append_face(kcd, kfe, kcd->prev.bmface); } @@ -542,7 +542,7 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd) } /* set up for next cut */ - kcd->prev = kcd->cur; + kcd->prev = kcd->curr; } static int verge_linehit(const void *vlh1, const void *vlh2) @@ -622,25 +622,25 @@ static void knife_cut_through(KnifeTool_OpData *kcd) splitkfe = MEM_callocN(kcd->totlinehit * sizeof(KnifeEdge *), "knife_cut_through"); if (kcd->prev.vert) { - if (kcd->prev.vert == kcd->cur.vert) + if (kcd->prev.vert == kcd->curr.vert) return; firstv = kcd->prev.vert; knife_get_vert_faces(kcd, firstv, kcd->prev.bmface, &firstfaces); } else if (kcd->prev.edge) { - if (kcd->prev.edge == kcd->cur.edge) + if (kcd->prev.edge == kcd->curr.edge) return; firstv = knife_split_edge(kcd, kcd->prev.edge, kcd->prev.co, &kfe3); knife_get_edge_faces(kcd, kcd->prev.edge, &firstfaces); } - if (kcd->cur.vert) { - lastv = kcd->cur.vert; - knife_get_vert_faces(kcd, lastv, kcd->cur.bmface, &lastfaces); + if (kcd->curr.vert) { + lastv = kcd->curr.vert; + knife_get_vert_faces(kcd, lastv, kcd->curr.bmface, &lastfaces); } - else if (kcd->cur.edge) { - lastv = knife_split_edge(kcd, kcd->cur.edge, kcd->cur.co, &kfe3); - knife_get_edge_faces(kcd, kcd->cur.edge, &lastfaces); + else if (kcd->curr.edge) { + lastv = knife_split_edge(kcd, kcd->curr.edge, kcd->curr.co, &kfe3); + knife_get_edge_faces(kcd, kcd->curr.edge, &lastfaces); } if (firstv) { @@ -709,7 +709,7 @@ static void knife_cut_through(KnifeTool_OpData *kcd) kcd->totlinehit = 0; /* set up for next cut */ - kcd->prev = kcd->cur; + kcd->prev = kcd->curr; } /* User has just left-clicked after the first time. @@ -717,7 +717,7 @@ static void knife_cut_through(KnifeTool_OpData *kcd) * If that line crossed edges then kcd->linehits will be non-NULL. */ static void knife_add_cut(KnifeTool_OpData *kcd) { - KnifePosData savcur = kcd->cur; + KnifePosData savcur = kcd->curr; if (kcd->cut_through) { knife_cut_through(kcd); @@ -755,7 +755,7 @@ static void knife_add_cut(KnifeTool_OpData *kcd) if (len_v3v3(kcd->prev.cage, lh->realhit) < FLT_EPSILON * 80) continue; - if (len_v3v3(kcd->cur.cage, lh->realhit) < FLT_EPSILON * 80) + if (len_v3v3(kcd->curr.cage, lh->realhit) < FLT_EPSILON * 80) continue; if (kcd->prev.is_space) { @@ -768,12 +768,12 @@ static void knife_add_cut(KnifeTool_OpData *kcd) continue; } - kcd->cur.is_space = 0; - kcd->cur.edge = lh->kfe; - kcd->cur.bmface = lh->f; - kcd->cur.vert = lh->v; - copy_v3_v3(kcd->cur.co, lh->hit); - copy_v3_v3(kcd->cur.cage, lh->cagehit); + kcd->curr.is_space = 0; + kcd->curr.edge = lh->kfe; + kcd->curr.bmface = lh->f; + kcd->curr.vert = lh->v; + copy_v3_v3(kcd->curr.co, lh->hit); + copy_v3_v3(kcd->curr.cage, lh->cagehit); knife_add_single_cut(kcd); } @@ -782,7 +782,7 @@ static void knife_add_cut(KnifeTool_OpData *kcd) kcd->prev = savcur; } else { - kcd->cur = savcur; + kcd->curr = savcur; knife_add_single_cut(kcd); } @@ -935,38 +935,38 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) glBegin(GL_LINES); glVertex3fv(kcd->prev.cage); - glVertex3fv(kcd->cur.cage); + glVertex3fv(kcd->curr.cage); glEnd(); glLineWidth(1.0); } - if (kcd->cur.edge) { + if (kcd->curr.edge) { glColor3ubv(kcd->colors.edge); glLineWidth(2.0); glBegin(GL_LINES); - glVertex3fv(kcd->cur.edge->v1->cageco); - glVertex3fv(kcd->cur.edge->v2->cageco); + glVertex3fv(kcd->curr.edge->v1->cageco); + glVertex3fv(kcd->curr.edge->v2->cageco); glEnd(); glLineWidth(1.0); } - else if (kcd->cur.vert) { + else if (kcd->curr.vert) { glColor3ubv(kcd->colors.point); glPointSize(11); glBegin(GL_POINTS); - glVertex3fv(kcd->cur.cage); + glVertex3fv(kcd->curr.cage); glEnd(); } - if (kcd->cur.bmface) { + if (kcd->curr.bmface) { glColor3ubv(kcd->colors.curpoint); glPointSize(9); glBegin(GL_POINTS); - glVertex3fv(kcd->cur.cage); + glVertex3fv(kcd->curr.cage); glEnd(); } @@ -1121,13 +1121,17 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, interp_v3_v3v3(p, kfe->v1->cageco, kfe->v2->cageco, lambda); - if (kcd->cur.vert && len_squared_v3v3(kcd->cur.vert->cageco, p) < depsilon_squared) + if (kcd->curr.vert && len_squared_v3v3(kcd->curr.vert->cageco, p) < depsilon_squared) { continue; - if (kcd->prev.vert && len_squared_v3v3(kcd->prev.vert->cageco, p) < depsilon_squared) + } + if (kcd->prev.vert && len_squared_v3v3(kcd->prev.vert->cageco, p) < depsilon_squared) { continue; + } if (len_squared_v3v3(kcd->prev.cage, p) < depsilon_squared || - len_squared_v3v3(kcd->cur.cage, p) < depsilon_squared) + len_squared_v3v3(kcd->curr.cage, p) < depsilon_squared) + { continue; + } knife_project_v3(kcd, p, sp); view3d_unproject(mats, view, sp[0], sp[1], 0.0f); @@ -1135,7 +1139,8 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, if (kcd->cut_through) { hitf = FALSE; - } else { + } + else { /* check if this point is visible in the viewport */ float p1[3], lambda1; @@ -1163,7 +1168,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, if (!hitf && !BLI_smallhash_haskey(ehash, (intptr_t)kfe)) { BMEdgeHit hit; - if (len_squared_v3v3(p, kcd->cur.co) < depsilon_squared || + if (len_squared_v3v3(p, kcd->curr.co) < depsilon_squared || len_squared_v3v3(p, kcd->prev.co) < depsilon_squared) continue; @@ -1239,7 +1244,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) } copy_v3_v3(v1, kcd->prev.cage); - copy_v3_v3(v2, kcd->cur.cage); + copy_v3_v3(v2, kcd->curr.cage); /* project screen line's 3d coordinates back into 2d */ knife_project_v3(kcd, v1, s1); @@ -1435,7 +1440,7 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo copy_v3_v3(p, co); copy_v3_v3(cagep, cageco); - kcd->cur.bmface = f; + kcd->curr.bmface = f; if (f) { KnifeEdge *cure = NULL; @@ -1499,8 +1504,8 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo /* update mouse coordinates to the snapped-to edge's screen coordinates * this is important for angle snap, which uses the previous mouse position */ edgesnap = new_knife_vert(kcd, p, cagep); - kcd->cur.mval[0] = (int)edgesnap->sco[0]; - kcd->cur.mval[1] = (int)edgesnap->sco[1]; + kcd->curr.mval[0] = (int)edgesnap->sco[0]; + kcd->curr.mval[1] = (int)edgesnap->sco[1]; } else { @@ -1532,7 +1537,7 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo /* set p to co, in case we don't find anything, means a face cut */ copy_v3_v3(p, co); copy_v3_v3(cagep, p); - kcd->cur.bmface = f; + kcd->curr.bmface = f; if (f) { ListBase *lst; @@ -1583,8 +1588,8 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo /* update mouse coordinates to the snapped-to vertex's screen coordinates * this is important for angle snap, which uses the previous mouse position */ - kcd->cur.mval[0] = (int)curv->sco[0]; - kcd->cur.mval[1] = (int)curv->sco[1]; + kcd->curr.mval[0] = (int)curv->sco[0]; + kcd->curr.mval[1] = (int)curv->sco[1]; } return curv; @@ -1641,30 +1646,30 @@ static int knife_update_active(KnifeTool_OpData *kcd) if (kcd->angle_snapping != ANGLE_FREE && kcd->mode == MODE_DRAGGING) knife_snap_angle(kcd); - knife_pos_data_clear(&kcd->cur); - kcd->cur.mval[0] = kcd->vc.mval[0]; - kcd->cur.mval[1] = kcd->vc.mval[1]; + knife_pos_data_clear(&kcd->curr); + kcd->curr.mval[0] = kcd->vc.mval[0]; + kcd->curr.mval[1] = kcd->vc.mval[1]; /* XXX knife_snap_angle updates the view coordinate mouse values to constrained angles, * which current mouse values are set to current mouse values are then used * for vertex and edge snap detection, without regard to the exact angle constraint */ - kcd->cur.vert = knife_find_closest_vert(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space); + kcd->curr.vert = knife_find_closest_vert(kcd, kcd->curr.co, kcd->curr.cage, &kcd->curr.bmface, &kcd->curr.is_space); - if (!kcd->cur.vert) { - kcd->cur.edge = knife_find_closest_edge(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space); + if (!kcd->curr.vert) { + kcd->curr.edge = knife_find_closest_edge(kcd, kcd->curr.co, kcd->curr.cage, &kcd->curr.bmface, &kcd->curr.is_space); } /* if no hits are found this would normally default to (0, 0, 0) so instead * get a point at the mouse ray closest to the previous point. * Note that drawing lines in `free-space` isn't properly supported * but theres no guarantee (0, 0, 0) has any geometry either - campbell */ - if (kcd->cur.vert == NULL && kcd->cur.edge == NULL) { + if (kcd->curr.vert == NULL && kcd->curr.edge == NULL) { float origin[3], ray[3], co[3]; knife_input_ray_cast(kcd, kcd->vc.mval, origin, ray); add_v3_v3v3(co, origin, ray); - closest_to_line_v3(kcd->cur.cage, kcd->prev.cage, co, origin); + closest_to_line_v3(kcd->curr.cage, kcd->prev.cage, co, origin); } if (kcd->mode == MODE_DRAGGING) { @@ -2872,7 +2877,7 @@ static int knifetool_init(bContext *C, wmOperator *op, int UNUSED(do_cut)) /* can't usefully select resulting edges in face mode */ kcd->select_result = (kcd->em->selectmode != SCE_SELECT_FACE); - knife_pos_data_clear(&kcd->cur); + knife_pos_data_clear(&kcd->curr); knife_pos_data_clear(&kcd->prev); knife_init_colors(&kcd->colors); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 26fe908f034..9ebd2351142 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3761,12 +3761,14 @@ static int drawDispListwire(ListBase *dlbase) } glEnd(); -/* (ton) this code crashes for me when resolv is 86 or higher... no clue */ -// glVertexPointer(3, GL_FLOAT, sizeof(float)*3*dl->nr, data + 3*nr); -// if (dl->flag & DL_CYCL_V) -// glDrawArrays(GL_LINE_LOOP, 0, dl->parts); -// else -// glDrawArrays(GL_LINE_STRIP, 0, dl->parts); +#if 0 + /* (ton) this code crashes for me when resolv is 86 or higher... no clue */ + glVertexPointer(3, GL_FLOAT, sizeof(float) * 3 * dl->nr, data + 3*nr); + if (dl->flag & DL_CYCL_V) + glDrawArrays(GL_LINE_LOOP, 0, dl->parts); + else + glDrawArrays(GL_LINE_STRIP, 0, dl->parts); +#endif } break; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 685141810fd..fa7964b31ca 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4977,8 +4977,8 @@ static int createSlideVerts(TransInfo *t) zero_v3(dir); maxdist = -1.0f; - loop_dir = MEM_callocN(sizeof(float)*3*loop_nr, "sv loop_dir"); - loop_maxdist = MEM_callocN(sizeof(float)*loop_nr, "sv loop_maxdist"); + loop_dir = MEM_callocN(sizeof(float) * 3 * loop_nr, "sv loop_dir"); + loop_maxdist = MEM_callocN(sizeof(float) * loop_nr, "sv loop_maxdist"); for (j = 0; j < loop_nr; j++) loop_maxdist[j] = -1.0f; diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h index e3ab6b4a7db..6bf8dbbe73a 100644 --- a/source/blender/makesdna/DNA_ipo_types.h +++ b/source/blender/makesdna/DNA_ipo_types.h @@ -65,8 +65,8 @@ typedef struct IpoDriver { typedef struct IpoCurve { struct IpoCurve *next, *prev; - struct BPoint *bp; /* array of BPoints (sizeof(BPoint)*totvert) - i.e. baked/imported data */ - struct BezTriple *bezt; /* array of BezTriples (sizeof(BezTriple)*totvert) - i.e. user-editable keyframes */ + struct BPoint *bp; /* array of BPoints (sizeof(BPoint) * totvert) - i.e. baked/imported data */ + struct BezTriple *bezt; /* array of BezTriples (sizeof(BezTriple) * totvert) - i.e. user-editable keyframes */ rctf maxrct, totrct; /* bounding boxes */ diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 62a09e65191..9f9a975ab9d 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -2881,8 +2881,8 @@ static const char *cpp_classes = "" " T data[Tsize];\n" "\n" " Array() {}\n" -" Array(const Array& other) { memcpy(data, other.data, sizeof(T)*Tsize); }\n" -" const Array& operator=(const Array& other) { memcpy(data, other.data, sizeof(T)*Tsize); " +" Array(const Array& other) { memcpy(data, other.data, sizeof(T) * Tsize); }\n" +" const Array& operator=(const Array& other) { memcpy(data, other.data, sizeof(T) * Tsize); " "return *this; }\n" "\n" " operator T*() { return data; }\n" diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index fa623eaad3d..198c28edfc5 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -66,15 +66,15 @@ static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) Lamp *la; World *wo; - for (ma= main->mat.first; ma; ma= ma->id.next) + for (ma = main->mat.first; ma; ma = ma->id.next) if (ma->nodetree) func(calldata, &ma->id, ma->nodetree); - for (la= main->lamp.first; la; la= la->id.next) + for (la = main->lamp.first; la; la = la->id.next) if (la->nodetree) func(calldata, &la->id, la->nodetree); - for (wo= main->world.first; wo; wo= wo->id.next) + for (wo = main->world.first; wo; wo = wo->id.next) if (wo->nodetree) func(calldata, &wo->id, wo->nodetree); } @@ -101,7 +101,7 @@ static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree)) bNode *node, *node_next; /* replace muted nodes and reroute nodes by internal links */ - for (node= localtree->nodes.first; node; node= node_next) { + for (node = localtree->nodes.first; node; node = node_next) { node_next = node->next; if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) { @@ -116,15 +116,15 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) bNode *lnode; /* copy over contents of previews */ - for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) { + for (lnode = localtree->nodes.first; lnode; lnode = lnode->next) { if (ntreeNodeExists(ntree, lnode->new_node)) { - bNode *node= lnode->new_node; + bNode *node = lnode->new_node; if (node->preview && node->preview->rect) { if (lnode->preview && lnode->preview->rect) { - int xsize= node->preview->xsize; - int ysize= node->preview->ysize; - memcpy(node->preview->rect, lnode->preview->rect, 4*xsize + xsize*ysize*sizeof(char)*4); + int xsize = node->preview->xsize; + int ysize = node->preview->ysize; + memcpy(node->preview->rect, lnode->preview->rect, 4 * xsize + xsize * ysize * sizeof(char) * 4); } } } @@ -176,7 +176,7 @@ void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *); void set_node_shader_lamp_loop(void (*lamp_loop_func)(ShadeInput *, ShadeResult *)) { - node_shader_lamp_loop= lamp_loop_func; + node_shader_lamp_loop = lamp_loop_func; } @@ -203,10 +203,10 @@ bNodeTreeExec *ntreeShaderBeginExecTree(bNodeTree *ntree, int use_tree_data) exec = ntree_exec_begin(ntree); /* allocate the thread stack listbase array */ - exec->threadstack= MEM_callocN(BLENDER_MAX_THREADS*sizeof(ListBase), "thread stack array"); + exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array"); - for (node= exec->nodetree->nodes.first; node; node= node->next) - node->need_exec= 1; + for (node = exec->nodetree->nodes.first; node; node = node->next) + node->need_exec = 1; if (use_tree_data) { /* XXX this should not be necessary, but is still used for cmp/sha/tex nodes, @@ -224,19 +224,19 @@ bNodeTreeExec *ntreeShaderBeginExecTree(bNodeTree *ntree, int use_tree_data) void ntreeShaderEndExecTree(bNodeTreeExec *exec, int use_tree_data) { if (exec) { - bNodeTree *ntree= exec->nodetree; + bNodeTree *ntree = exec->nodetree; bNodeThreadStack *nts; int a; if (exec->threadstack) { - for (a=0; athreadstack[a].first; nts; nts=nts->next) + for (a = 0; a < BLENDER_MAX_THREADS; a++) { + for (nts = exec->threadstack[a].first; nts; nts = nts->next) if (nts->stack) MEM_freeN(nts->stack); BLI_freelistN(&exec->threadstack[a]); } MEM_freeN(exec->threadstack); - exec->threadstack= NULL; + exec->threadstack = NULL; } ntree_exec_end(exec); @@ -260,8 +260,8 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) bNodeTreeExec *exec = ntree->execdata; /* convert caller data to struct */ - scd.shi= shi; - scd.shr= shr; + scd.shi = shi; + scd.shr = shr; /* each material node has own local shaderesult, with optional copying */ memset(shr, 0, sizeof(ShadeResult)); @@ -276,14 +276,14 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) exec = ntree->execdata; } - nts= ntreeGetThreadStack(exec, shi->thread); + nts = ntreeGetThreadStack(exec, shi->thread); ntreeExecThreadNodes(exec, nts, &scd, shi->thread); ntreeReleaseThreadStack(nts); // \note: set material back to preserved material shi->mat = mat; /* better not allow negative for now */ - if (shr->combined[0]<0.0f) shr->combined[0]= 0.0f; - if (shr->combined[1]<0.0f) shr->combined[1]= 0.0f; - if (shr->combined[2]<0.0f) shr->combined[2]= 0.0f; + if (shr->combined[0] < 0.0f) shr->combined[0] = 0.0f; + if (shr->combined[1] < 0.0f) shr->combined[1] = 0.0f; + if (shr->combined[2] < 0.0f) shr->combined[2] = 0.0f; } diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index 063cc31e6f6..9656d93f1b0 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -58,7 +58,7 @@ static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) { Tex *tx; - for (tx= main->tex.first; tx; tx= tx->id.next) { + for (tx = main->tex.first; tx; tx = tx->id.next) { if (tx->nodetree) { func(calldata, &tx->id, tx->nodetree); } @@ -83,7 +83,7 @@ static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree)) bNode *node, *node_next; /* replace muted nodes and reroute nodes by internal links */ - for (node= localtree->nodes.first; node; node= node_next) { + for (node = localtree->nodes.first; node; node = node_next) { node_next = node->next; if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) { @@ -98,15 +98,15 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) bNode *lnode; /* copy over contents of previews */ - for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) { + for (lnode = localtree->nodes.first; lnode; lnode = lnode->next) { if (ntreeNodeExists(ntree, lnode->new_node)) { - bNode *node= lnode->new_node; + bNode *node = lnode->new_node; if (node->preview && node->preview->rect) { if (lnode->preview && lnode->preview->rect) { - int xsize= node->preview->xsize; - int ysize= node->preview->ysize; - memcpy(node->preview->rect, lnode->preview->rect, 4*xsize + xsize*ysize*sizeof(char)*4); + int xsize = node->preview->xsize; + int ysize = node->preview->ysize; + memcpy(node->preview->rect, lnode->preview->rect, 4 * xsize + xsize * ysize * sizeof(char) * 4); } } } @@ -141,15 +141,15 @@ int ntreeTexTagAnimated(bNodeTree *ntree) { bNode *node; - if (ntree==NULL) return 0; + if (ntree == NULL) return 0; - for (node= ntree->nodes.first; node; node= node->next) { - if (node->type==TEX_NODE_CURVE_TIME) { + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == TEX_NODE_CURVE_TIME) { nodeUpdate(ntree, node); return 1; } - else if (node->type==NODE_GROUP) { - if ( ntreeTexTagAnimated((bNodeTree *)node->id) ) { + else if (node->type == NODE_GROUP) { + if (ntreeTexTagAnimated((bNodeTree *)node->id) ) { return 1; } } @@ -178,10 +178,10 @@ bNodeTreeExec *ntreeTexBeginExecTree(bNodeTree *ntree, int use_tree_data) exec = ntree_exec_begin(ntree); /* allocate the thread stack listbase array */ - exec->threadstack= MEM_callocN(BLENDER_MAX_THREADS*sizeof(ListBase), "thread stack array"); + exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array"); - for (node= exec->nodetree->nodes.first; node; node= node->next) - node->need_exec= 1; + for (node = exec->nodetree->nodes.first; node; node = node->next) + node->need_exec = 1; if (use_tree_data) { /* XXX this should not be necessary, but is still used for cmp/sha/tex nodes, @@ -200,9 +200,9 @@ static void tex_free_delegates(bNodeTreeExec *exec) bNodeStack *ns; int th, a; - for (th=0; ththreadstack[th].first; nts; nts=nts->next) - for (ns= nts->stack, a=0; astacksize; a++, ns++) + for (th = 0; th < BLENDER_MAX_THREADS; th++) + for (nts = exec->threadstack[th].first; nts; nts = nts->next) + for (ns = nts->stack, a = 0; a < exec->stacksize; a++, ns++) if (ns->data && !ns->is_copy) MEM_freeN(ns->data); } @@ -213,21 +213,21 @@ static void tex_free_delegates(bNodeTreeExec *exec) void ntreeTexEndExecTree(bNodeTreeExec *exec, int use_tree_data) { if (exec) { - bNodeTree *ntree= exec->nodetree; + bNodeTree *ntree = exec->nodetree; bNodeThreadStack *nts; int a; if (exec->threadstack) { tex_free_delegates(exec); - for (a=0; athreadstack[a].first; nts; nts=nts->next) + for (a = 0; a < BLENDER_MAX_THREADS; a++) { + for (nts = exec->threadstack[a].first; nts; nts = nts->next) if (nts->stack) MEM_freeN(nts->stack); BLI_freelistN(&exec->threadstack[a]); } MEM_freeN(exec->threadstack); - exec->threadstack= NULL; + exec->threadstack = NULL; } ntree_exec_end(exec); @@ -254,10 +254,10 @@ int ntreeTexExecTree( MTex *mtex ) { TexCallData data; - float *nor= texres->nor; + float *nor = texres->nor; int retval = TEX_INT; bNodeThreadStack *nts = NULL; - bNodeTreeExec *exec= nodes->execdata; + bNodeTreeExec *exec = nodes->execdata; data.co = co; data.dxt = dxt; @@ -267,9 +267,9 @@ int ntreeTexExecTree( data.do_preview = preview; data.thread = thread; data.which_output = which_output; - data.cfra= cfra; - data.mtex= mtex; - data.shi= shi; + data.cfra = cfra; + data.mtex = mtex; + data.shi = shi; /* ensure execdata is only initialized once */ if (!exec) { @@ -278,10 +278,10 @@ int ntreeTexExecTree( ntreeTexBeginExecTree(nodes, 1); BLI_unlock_thread(LOCK_NODES); - exec= nodes->execdata; + exec = nodes->execdata; } - nts= ntreeGetThreadStack(exec, thread); + nts = ntreeGetThreadStack(exec, thread); ntreeExecThreadNodes(exec, nts, &data, thread); ntreeReleaseThreadStack(nts); @@ -289,7 +289,7 @@ int ntreeTexExecTree( retval |= TEX_RGB; /* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was set * however, the texture code checks this for other reasons (namely, a normal is required for material) */ - texres->nor= nor; + texres->nor = nor; return retval; } diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m index 47df4c7363f..bb87fe21c49 100644 --- a/source/blender/quicktime/apple/qtkit_export.m +++ b/source/blender/quicktime/apple/qtkit_export.m @@ -318,7 +318,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R if(qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport"); - [QTMovie enterQTKitOnThread]; + [QTMovie enterQTKitOnThread]; /* Check first if the QuickTime 7.2.1 initToWritableFile: method is available */ if ([[[[QTMovie alloc] init] autorelease] respondsToSelector:@selector(initToWritableFile:error:)] != YES) { @@ -328,7 +328,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R else { makeqtstring(rd, name); qtexport->filename = [[NSString alloc] initWithCString:name - encoding:[NSString defaultCStringEncoding]]; + encoding:[NSString defaultCStringEncoding]]; qtexport->movie = nil; qtexport->audioFile = NULL; @@ -354,7 +354,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R strcpy(extension,".aiff"); break; } - + tmpnam(name); strcat(name, extension); outputFileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,(UInt8*) name, strlen(name), false); @@ -362,7 +362,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R if (outputFileURL) { qtexport->audioFileName = [[NSString alloc] initWithCString:name - encoding:[NSString defaultCStringEncoding]]; + encoding:[NSString defaultCStringEncoding]]; qtexport->audioInputFormat.mSampleRate = U.audiorate; qtexport->audioInputFormat.mFormatID = kAudioFormatLinearPCM; @@ -471,7 +471,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R qtexport->audioOutputFormat.mBytesPerFrame = qtexport->audioOutputFormat.mBytesPerPacket; break; } - + err = AudioFileCreateWithURL(outputFileURL, audioFileType, &qtexport->audioOutputFormat, kAudioFileFlags_EraseFile, &qtexport->audioFile); CFRelease(outputFileURL); @@ -489,27 +489,27 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R else { UInt32 prop,propSize; /* Set up codec properties */ - if (rd->qtcodecsettings.audiocodecType == kAudioFormatMPEG4AAC) { /*Lossy compressed format*/ + if (rd->qtcodecsettings.audiocodecType == kAudioFormatMPEG4AAC) { /* Lossy compressed format */ prop = rd->qtcodecsettings.audioBitRate; AudioConverterSetProperty(qtexport->audioConverter, kAudioConverterEncodeBitRate, - sizeof(prop), &prop); + sizeof(prop), &prop); if (rd->qtcodecsettings.audioCodecFlags & QTAUDIO_FLAG_CODEC_ISCBR) prop = kAudioCodecBitRateControlMode_Constant; else prop = kAudioCodecBitRateControlMode_LongTermAverage; AudioConverterSetProperty(qtexport->audioConverter, kAudioCodecPropertyBitRateControlMode, - sizeof(prop), &prop); + sizeof(prop), &prop); } /* Conversion quality : if performance impact then offer degraded option */ - if ((rd->qtcodecsettings.audioCodecFlags & QTAUDIO_FLAG_RESAMPLE_NOHQ) == 0) { + if ((rd->qtcodecsettings.audioCodecFlags & QTAUDIO_FLAG_RESAMPLE_NOHQ) == 0) { prop = kAudioConverterSampleRateConverterComplexity_Mastering; AudioConverterSetProperty(qtexport->audioConverter, kAudioConverterSampleRateConverterComplexity, - sizeof(prop), &prop); + sizeof(prop), &prop); prop = kAudioConverterQuality_Max; AudioConverterSetProperty(qtexport->audioConverter, kAudioConverterSampleRateConverterQuality, - sizeof(prop), &prop); + sizeof(prop), &prop); } write_cookie(qtexport->audioConverter, qtexport->audioFile); @@ -517,29 +517,30 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R /* Allocate output buffer */ if (qtexport->audioOutputFormat.mBytesPerPacket ==0) /* VBR */ AudioConverterGetProperty(qtexport->audioConverter, kAudioConverterPropertyMaximumOutputPacketSize, - &propSize, &qtexport->audioCodecMaxOutputPacketSize); + &propSize, &qtexport->audioCodecMaxOutputPacketSize); else qtexport->audioCodecMaxOutputPacketSize = qtexport->audioOutputFormat.mBytesPerPacket; qtexport->audioInputBuffer = MEM_mallocN(AUDIOOUTPUTBUFFERSIZE, "qt_audio_inputPacket"); qtexport->audioOutputBuffer = MEM_mallocN(AUDIOOUTPUTBUFFERSIZE, "qt_audio_outputPacket"); - qtexport->audioOutputPktDesc = MEM_mallocN(sizeof(AudioStreamPacketDescription)*AUDIOOUTPUTBUFFERSIZE/qtexport->audioCodecMaxOutputPacketSize, - "qt_audio_pktdesc"); + qtexport->audioOutputPktDesc = MEM_mallocN(sizeof(AudioStreamPacketDescription) * AUDIOOUTPUTBUFFERSIZE / qtexport->audioCodecMaxOutputPacketSize, + "qt_audio_pktdesc"); } } } - + if (err == noErr) { - qtexport->videoTempFileName = [[NSString alloc] initWithCString:tmpnam(nil) - encoding:[NSString defaultCStringEncoding]]; - if (qtexport->videoTempFileName) + qtexport->videoTempFileName = [[NSString alloc] initWithCString:tmpnam(nil) + encoding:[NSString defaultCStringEncoding]]; + if (qtexport->videoTempFileName) { qtexport->movie = [[QTMovie alloc] initToWritableFile:qtexport->videoTempFileName error:&error]; + } } } else qtexport->movie = [[QTMovie alloc] initToWritableFile:qtexport->filename error:&error]; - + if(qtexport->movie == nil) { BKE_report(reports, RPT_ERROR, "Unable to create quicktime movie."); success= 0; @@ -585,7 +586,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R specs.rate = U.audiorate; qtexport->audioInputDevice = AUD_openReadDevice(specs); AUD_playDevice(qtexport->audioInputDevice, scene->sound_scene, rd->sfra * rd->frs_sec_base / rd->frs_sec); - + qtexport->audioOutputPktPos = 0; qtexport->audioTotalExportedFrames = 0; qtexport->audioTotalSavedFrames = 0; @@ -655,13 +656,13 @@ int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, in audioPacketsConverted = AUDIOOUTPUTBUFFERSIZE / qtexport->audioCodecMaxOutputPacketSize; err = AudioConverterFillComplexBuffer(qtexport->audioConverter, AudioConverterInputCallback, - NULL, &audioPacketsConverted, &qtexport->audioBufferList, qtexport->audioOutputPktDesc); + NULL, &audioPacketsConverted, &qtexport->audioBufferList, qtexport->audioOutputPktDesc); if (audioPacketsConverted) { AudioFileWritePackets(qtexport->audioFile, false, qtexport->audioBufferList.mBuffers[0].mDataByteSize, - qtexport->audioOutputPktDesc, qtexport->audioOutputPktPos, &audioPacketsConverted, qtexport->audioOutputBuffer); + qtexport->audioOutputPktDesc, qtexport->audioOutputPktPos, &audioPacketsConverted, qtexport->audioOutputBuffer); qtexport->audioOutputPktPos += audioPacketsConverted; - if (qtexport->audioOutputFormat.mFramesPerPacket) { + if (qtexport->audioOutputFormat.mFramesPerPacket) { // this is the common case: format has constant frames per packet qtexport->audioTotalSavedFrames += (audioPacketsConverted * qtexport->audioOutputFormat.mFramesPerPacket); } @@ -751,8 +752,8 @@ void end_qt(void) } /* Save file */ - dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] - forKey:QTMovieFlatten]; + dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] + forKey:QTMovieFlatten]; if (dict) { [qtexport->movie writeToFile:qtexport->filename withAttributes:dict]; -- cgit v1.2.3