diff options
44 files changed, 1229 insertions, 1131 deletions
diff --git a/intern/smoke/intern/WTURBULENCE.cpp b/intern/smoke/intern/WTURBULENCE.cpp index 83bec466c9f..671198065e8 100644 --- a/intern/smoke/intern/WTURBULENCE.cpp +++ b/intern/smoke/intern/WTURBULENCE.cpp @@ -511,7 +511,7 @@ void WTURBULENCE::computeEnergy(float *_energy, float* xvel, float* yvel, float* if (obstacles[index]) obstacles[index] = 1; // DG TODO ? animated obstacle flag? - free(obstacles); + delete [] obstacles; } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 1cef4624a04..9ab8fcb5655 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -261,6 +261,7 @@ class CLIP_PT_tools_tracking(CLIP_PT_tracking_panel, Panel): props = row.operator("clip.track_markers", text="", icon='FRAME_PREV') props.backwards = True + props.sequence = False props = row.operator("clip.track_markers", text="", icon='PLAY_REVERSE') props.backwards = True @@ -268,7 +269,9 @@ class CLIP_PT_tools_tracking(CLIP_PT_tracking_panel, Panel): props = row.operator("clip.track_markers", text="", icon='PLAY') props.backwards = False props.sequence = True - row.operator("clip.track_markers", text="", icon='FRAME_NEXT') + props = row.operator("clip.track_markers", text="", icon='FRAME_NEXT') + props.backwards = False + props.sequence = False col = layout.column(align=True) props = col.operator("clip.clear_track_path", text="Clear After") diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index 58697225811..6646da4a91a 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -217,7 +217,9 @@ class InputKeyMapPanel: km = km.active() layout.context_pointer_set("keymap", km) - filtered_items = [kmi for kmi in km.keymap_items if filter_text in kmi.name.lower()] + filtered_items = [kmi for kmi in km.keymap_items + if filter_text in kmi.idname.lower() or + filter_text in kmi.name.lower()] if filtered_items: col = layout.column() diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 0150646a96c..9d36a66843b 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3278,6 +3278,15 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t switch (data->from) { case 2: /* scale */ mat4_to_size(dvec, ct->matrix); + + if (is_negative_m4(ct->matrix)) { + /* Bugfix [#27886] + * We can't be sure which axis/axes are negative, though we know that something is negative. + * Assume we don't care about negativity of separate axes. <--- This is a limitation that + * riggers will have to live with for now. + */ + negate_v3(dvec); + } break; case 1: /* rotation (convert to degrees first) */ mat4_to_eulO(dvec, cob->rotOrder, ct->matrix); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 4cbfb4f0f3e..cb6f6823f48 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -548,13 +548,6 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl) } } -static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3]) -{ - copy_v3_v3(mat[0], v1); - copy_v3_v3(mat[1], v2); - copy_v3_v3(mat[2], v3); -} - static void multires_copy_grid(float (*gridA)[3], float (*gridB)[3], int sizeA, int sizeB) { int x, y, j, skip; @@ -962,7 +955,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updat multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple); } -void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, float t[3]) +static void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, float t[3]) { if (axis == 0) { if (x == key->grid_size - 1) { @@ -986,6 +979,19 @@ void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, floa } } +/* Construct 3x3 tangent-space matrix in 'mat' */ +static void grid_tangent_matrix(float mat[3][3], const CCGKey *key, + int x, int y, CCGElem *grid) +{ + grid_tangent(key, x, y, 0, grid, mat[0]); + normalize_v3(mat[0]); + + grid_tangent(key, x, y, 1, grid, mat[1]); + normalize_v3(mat[1]); + + copy_v3_v3(mat[2], CCG_grid_elem_no(key, grid, x, y)); +} + static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, CCGElem **oldGridData, int totlvl) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; @@ -1067,22 +1073,11 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm for (x = 0; x < gridSize; x++) { float *co = CCG_grid_elem_co(&key, grid, x, y); float *sco = CCG_grid_elem_co(&key, subgrid, x, y); - float *no = CCG_grid_elem_no(&key, subgrid, x, y); float *data = dispgrid[dGridSize * y * dSkip + x * dSkip]; - float mat[3][3], tx[3], ty[3], disp[3], d[3], mask; + float mat[3][3], disp[3], d[3], mask; /* construct tangent space matrix */ - grid_tangent(&key, x, y, 0, subGridData[gIndex], tx); - normalize_v3(tx); - - grid_tangent(&key, x, y, 1, subGridData[gIndex], ty); - normalize_v3(ty); - - //mul_v3_fl(tx, 1.0f/(gridSize-1)); - //mul_v3_fl(ty, 1.0f/(gridSize-1)); - //cross_v3_v3v3(no, tx, ty); - - column_vectors_to_mat3(mat, tx, ty, no); + grid_tangent_matrix(mat, &key, x, y, subgrid); switch (op) { case APPLY_DISPLACEMENTS: @@ -1344,17 +1339,11 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to) for (y = 0; y < gridSize; y++) { for (x = 0; x < gridSize; x++) { float *data = dispgrid[dGridSize * y * dSkip + x * dSkip]; - float *no = CCG_grid_elem_no(&key, subgrid, x, y); float *co = CCG_grid_elem_co(&key, subgrid, x, y); - float mat[3][3], tx[3], ty[3], dco[3]; + float mat[3][3], dco[3]; /* construct tangent space matrix */ - grid_tangent(&key, x, y, 0, subGridData[gIndex], tx); - normalize_v3(tx); - - grid_tangent(&key, x, y, 1, subGridData[gIndex], ty); - normalize_v3(ty); - column_vectors_to_mat3(mat, tx, ty, no); + grid_tangent_matrix(mat, &key, x, y, subgrid); /* convert to absolute coordinates in space */ if (from == MULTIRES_SPACE_TANGENT) { @@ -1368,8 +1357,6 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to) copy_v3_v3(dco, data); } - column_vectors_to_mat3(mat, tx, ty, no); - /*now, convert to desired displacement type*/ if (to == MULTIRES_SPACE_TANGENT) { invert_m3(mat); @@ -2142,7 +2129,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) { DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL; CCGElem **gridData, **subGridData; - CCGKey key; + CCGKey dm_key, subdm_key; Mesh *me = (Mesh *)ob->data; MPoly *mpoly = me->mpoly; /* MLoop *mloop = me->mloop; */ /* UNUSED */ @@ -2180,12 +2167,12 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) dm = subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0); cddm->release(cddm); - /*numGrids = dm->getNumGrids(dm);*/ /*UNUSED*/ gridSize = dm->getGridSize(dm); gridData = dm->getGridData(dm); gridOffset = dm->getGridOffset(dm); - dm->getGridKey(dm, &key); + dm->getGridKey(dm, &dm_key); subGridData = subdm->getGridData(subdm); + subdm->getGridKey(subdm, &subdm_key); dGridSize = multires_side_tot[high_mmd.totlvl]; dSkip = (dGridSize - 1) / (gridSize - 1); @@ -2203,20 +2190,13 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) for (y = 0; y < gridSize; y++) { for (x = 0; x < gridSize; x++) { - float *co = CCG_grid_elem_co(&key, grid, x, y); - float *sco = CCG_grid_elem_co(&key, subgrid, x, y); - float *no = CCG_grid_elem_no(&key, grid, x, y); + float *co = CCG_grid_elem_co(&dm_key, grid, x, y); + float *sco = CCG_grid_elem_co(&subdm_key, subgrid, x, y); float *data = dispgrid[dGridSize * y * dSkip + x * dSkip]; - float mat[3][3], tx[3], ty[3], disp[3]; + float mat[3][3], disp[3]; /* construct tangent space matrix */ - grid_tangent(&key, x, y, 0, gridData[gIndex], tx); - normalize_v3(tx); - - grid_tangent(&key, x, y, 1, gridData[gIndex], ty); - normalize_v3(ty); - - column_vectors_to_mat3(mat, tx, ty, no); + grid_tangent_matrix(mat, &dm_key, x, y, grid); /* scale subgrid coord and calculate displacement */ mul_m3_v3(smat, sco); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index b4ee4f733e7..a3d66012303 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1767,24 +1767,20 @@ int BKE_tracking_next(MovieTrackingContext *context) marker_new.flag |= MARKER_TRACKED; marker_new.framenr = nextfra; - if (context->first_time) { - #pragma omp critical - { + #pragma omp critical + { + if (context->first_time) { /* check if there's no keyframe/tracked markers before tracking marker. * if so -- create disabled marker before currently tracking "segment" */ + put_disabled_marker(track, &marker_new, !context->backwards, 0); } - } - #pragma omp critical - { + /* insert currently tracked marker */ BKE_tracking_insert_marker(track, &marker_new); - } - /* make currently tracked segment be finished with disabled marker */ - #pragma omp critical - { + /* make currently tracked segment be finished with disabled marker */ put_disabled_marker(track, &marker_new, context->backwards, 0); } } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3c7389ceba9..3531611e173 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5288,6 +5288,14 @@ static void lib_link_screen(FileData *fd, Main *main) */ sima->gpd = newlibadr_us(fd, sc->id.lib, sima->gpd); } + else if (sl->spacetype == SPACE_SEQ) { + SpaceSeq *sseq = (SpaceSeq *)sl; + + /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data + * so fingers crossed this works fine! + */ + sseq->gpd = newlibadr_us(fd, sc->id.lib, sseq->gpd); + } else if (sl->spacetype == SPACE_NLA) { SpaceNla *snla= (SpaceNla *)sl; bDopeSheet *ads= snla->ads; @@ -5358,15 +5366,20 @@ static void lib_link_screen(FileData *fd, Main *main) } else if (sl->spacetype == SPACE_CLIP) { SpaceClip *sclip = (SpaceClip *)sl; - + sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip); sclip->mask = newlibadr_us(fd, sc->id.lib, sclip->mask); - + sclip->scopes.track_search = NULL; sclip->scopes.track_preview = NULL; sclip->draw_context = NULL; sclip->scopes.ok = 0; } + else if (sl->spacetype == SPACE_LOGIC) { + SpaceLogic *slogic = (SpaceLogic *)sl; + + slogic->gpd = newlibadr_us(fd, sc->id.lib, slogic->gpd); + } } } sc->id.flag -= LIB_NEEDLINK; @@ -5538,6 +5551,12 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) if (saction->ads.filter_grp) saction->ads.filter_grp= restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, 0); + + + /* force recalc of list of channels, potentially updating the active action + * while we're at it (as it can only be updated that way) [#28962] + */ + saction->flag |= SACTION_TEMP_NEEDCHANSYNC; } else if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; @@ -5559,6 +5578,14 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) */ sima->gpd = restore_pointer_by_name(newmain, (ID *)sima->gpd, 1); } + else if (sl->spacetype == SPACE_SEQ) { + SpaceSeq *sseq = (SpaceSeq *)sl; + + /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data + * so assume that here we're doing for undo only... + */ + sseq->gpd = restore_pointer_by_name(newmain, (ID *)sseq->gpd, 1); + } else if (sl->spacetype == SPACE_NLA) { SpaceNla *snla = (SpaceNla *)sl; bDopeSheet *ads = snla->ads; @@ -5623,12 +5650,17 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) } else if (sl->spacetype == SPACE_CLIP) { SpaceClip *sclip = (SpaceClip *)sl; - + sclip->clip = restore_pointer_by_name(newmain, (ID *)sclip->clip, 1); sclip->mask = restore_pointer_by_name(newmain, (ID *)sclip->mask, 1); - + sclip->scopes.ok = 0; } + else if (sl->spacetype == SPACE_LOGIC) { + SpaceLogic *slogic = (SpaceLogic *)sl; + + slogic->gpd = restore_pointer_by_name(newmain, (ID *)slogic->gpd, 1); + } } } } @@ -5869,7 +5901,8 @@ static void direct_link_screen(FileData *fd, bScreen *sc) } else if (sl->spacetype == SPACE_LOGIC) { SpaceLogic *slogic = (SpaceLogic *)sl; - + + /* XXX: this is new stuff, which shouldn't be directly linking to gpd... */ if (slogic->gpd) { slogic->gpd = newdataadr(fd, slogic->gpd); direct_link_gpencil(fd, slogic->gpd); @@ -8068,7 +8101,7 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old) /* Update: the issue is that in file reading, the oldnewmap is OK, but for existing data, it has to be * inserted in the map to be found! */ - + /* Update: previously it was checking for id->flag & LIB_PRE_EXISTING, however that does not affect file * reading. For file reading we may need to insert it into the libmap as well, because you might have * two files indirectly linking the same datablock, and in that case we need this in the libmap for the @@ -8477,6 +8510,7 @@ static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb) } } +#if 0 /* Disabled as it doesn't actually do anything except recurse... */ static void expand_bones(FileData *fd, Main *mainvar, Bone *bone) { Bone *curBone; @@ -8485,6 +8519,7 @@ static void expand_bones(FileData *fd, Main *mainvar, Bone *bone) expand_bones(fd, mainvar, curBone); } } +#endif static void expand_pose(FileData *fd, Main *mainvar, bPose *pose) { @@ -8500,15 +8535,19 @@ static void expand_pose(FileData *fd, Main *mainvar, bPose *pose) } static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm) -{ - Bone *curBone; - +{ if (arm->adt) expand_animdata(fd, mainvar, arm->adt); - for (curBone = arm->bonebase.first; curBone; curBone=curBone->next) { - expand_bones(fd, mainvar, curBone); +#if 0 /* Disabled as this currently only recurses down the chain doing nothing */ + { + Bone *curBone; + + for (curBone = arm->bonebase.first; curBone; curBone=curBone->next) { + expand_bones(fd, mainvar, curBone); + } } +#endif } static void expand_object_expandModifiers(void *userData, Object *UNUSED(ob), @@ -8718,7 +8757,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce) #ifdef DURIAN_CAMERA_SWITCH { TimeMarker *marker; - + for (marker = sce->markers.first; marker; marker = marker->next) { if (marker->camera) { expand_doit(fd, mainvar, marker->camera); diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index c1c5dd73bb7..3ec4c51bcb1 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -754,6 +754,7 @@ void BM_edge_ordered_verts_ex(BMEdge *edge, BMVert **r_v1, BMVert **r_v2, BMLoop *edge_loop) { BLI_assert(edge_loop->e == edge); + (void)edge; /* quiet warning in release build */ *r_v1 = edge_loop->v; *r_v2 = edge_loop->next->v; } diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp index d9cf2c2fef0..b27b6323f49 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BlurNode.cpp @@ -45,9 +45,6 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * c CompositorQuality quality = context->getQuality(); - if (data->filtertype == R_FILTER_MITCH || data->filtertype == R_FILTER_CATROM) { - quality = COM_QUALITY_HIGH; - } if (data->filtertype == R_FILTER_FAST_GAUSS) { FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation(); operationfgb->setData(data); diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp index 9fec75abafe..2720a0a4146 100644 --- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp @@ -61,7 +61,7 @@ void ConvolutionFilterOperation::deinitExecution() this->inputOperation = NULL; this->inputValueOperation = NULL; if (this->filter) { - delete this->filter; + delete [] this->filter; this->filter = NULL; } } diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index 9e911e7ba40..40f492b0f10 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -1220,7 +1220,7 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float do_createEdgeLocationBuffer(t,rw,lres,res,gbuf,&innerEdgeOffset,&outerEdgeOffset,isz,gsz); do_fillGradientBuffer(rw,res,gbuf,isz,osz,gsz,innerEdgeOffset,outerEdgeOffset); - delete gbuf; // free the gradient index buffer + delete [] gbuf; // free the gradient index buffer } } diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index e522d334d8b..07cc07880e7 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -131,10 +131,11 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); - int index = 0; + int index; int step = QualityStepHelper::getStep(); int offsetadd = QualityStepHelper::getOffsetAdd(); for (int ny = miny ; ny < maxy ; ny +=step) { + index = ((ny-y)+this->rady) * (this->radx*2+1) + (minx-x+this->radx); int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth); for (int nx = minx ; nx < maxx ; nx +=step) { float multiplyer = gausstab[index]; diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp index 2eb51b4577f..a7e443838a9 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp @@ -93,12 +93,13 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); - int index = 0; + int index; int step = getStep(); int offsetadd = getOffsetAdd(); int bufferindex = ((minx - bufferstartx)*4)+((miny-bufferstarty)*4*bufferwidth); for (int nx = minx ; nx < maxx ; nx +=step) { - float multiplyer = gausstab[index++]; + index = (nx-x)+this->rad; + float multiplyer = gausstab[index]; tempColor[0] += multiplyer * buffer[bufferindex]; tempColor[1] += multiplyer * buffer[bufferindex+1]; tempColor[2] += multiplyer * buffer[bufferindex+2]; diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp index 28e8e548530..c7da43fc20f 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp @@ -91,10 +91,11 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff maxx = min(maxx, inputBuffer->getRect()->xmax); int step = getStep(); - int index = 0; + int index; for (int ny = miny ; ny < maxy ; ny +=step) { + index = (ny-y)+this->rad; int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth); - float multiplyer = gausstab[index++]; + float multiplyer = gausstab[index]; tempColor[0] += multiplyer * buffer[bufferindex]; tempColor[1] += multiplyer * buffer[bufferindex+1]; tempColor[2] += multiplyer * buffer[bufferindex+2]; diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 14bee00a72a..f29be418941 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -184,7 +184,7 @@ void clean_fcurve(FCurve *fcu, float thresh) int totCount, i; /* check if any points */ - if ((fcu == NULL) || (fcu->totvert <= 1)) + if ((fcu == NULL) || (fcu->bezt == NULL) || (fcu->totvert <= 1)) return; /* make a copy of the old BezTriples, and clear IPO curve */ @@ -286,7 +286,11 @@ void smooth_fcurve(FCurve *fcu) { BezTriple *bezt; int i, x, totSel = 0; - + + if (fcu->bezt == NULL) { + return; + } + /* first loop through - count how many verts are selected */ bezt = fcu->bezt; for (i = 0; i < fcu->totvert; i++, bezt++) { diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 1823bbce3a1..fa555b0ddb8 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -37,10 +37,8 @@ #include "BLO_sys_types.h" -#include "IMB_imbuf_types.h" - -#include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_math.h" #include "BLI_utildefines.h" #include "DNA_gpencil_types.h" @@ -53,8 +51,6 @@ #include "BKE_global.h" #include "BKE_gpencil.h" - - #include "WM_api.h" #include "BIF_gl.h" @@ -64,7 +60,6 @@ #include "ED_sequencer.h" #include "ED_view3d.h" - #include "gpencil_intern.h" /* ************************************************** */ @@ -225,7 +220,7 @@ static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness /* need to roll-back one point to ensure that there are no gaps in the stroke */ if (i != 0) glVertex3fv(&(pt - 1)->x); - + /* now the point we want... */ glVertex3fv(&pt->x); @@ -340,7 +335,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, mt[1] = m2[1] * pthick * 0.5f; sc[0] = s0[0] - (m1[0] * pthick * 0.75f); sc[1] = s0[1] - (m1[1] * pthick * 0.75f); - + t0[0] = sc[0] - mt[0]; t0[1] = sc[1] - mt[1]; t1[0] = sc[0] + mt[0]; @@ -382,7 +377,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, mt[1] = mb[1] * pthick; athick = len_v2(mt); dfac = pthick - (athick * 2); - + if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) { mt[0] += (mb[0] * dfac); mt[1] += (mb[1] * dfac); @@ -429,7 +424,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, mt[1] = m2[1] * pthick * 0.5f; sc[0] = s1[0] + (m1[0] * pthick * 0.75f); sc[1] = s1[1] + (m1[1] * pthick * 0.75f); - + t0[0] = sc[0] - mt[0]; t0[1] = sc[1] - mt[1]; t1[0] = sc[0] + mt[0]; @@ -669,7 +664,7 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, // ............................ /* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */ -void draw_gpencil_2dimage(bContext *C /* , ImBuf *ibuf */) +void draw_gpencil_2dimage(const bContext *C) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); @@ -699,35 +694,20 @@ void draw_gpencil_2dimage(bContext *C /* , ImBuf *ibuf */) dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK; } break; -#if 0 /* removed since 2.5x, needs to be added back */ case SPACE_SEQ: /* sequence */ { - SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first; - float zoom, zoomx, zoomy; - - /* check that we have grease-pencil stuff to draw */ - if (ELEM(NULL, sa, ibuf)) return; - - /* calculate accessory values */ - zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom)); - if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { - /* XXX sequencer zoom should store it? */ - zoomx = zoom; // * (G.scene->r.xasp / G.scene->r.yasp); - zoomy = zoom; - } - else - zoomx = zoomy = zoom; - - /* calculate transforms (Note: we use ibuf here, as we have it) */ - sizex = (int)(zoomx * ibuf->x); - sizey = (int)(zoomy * ibuf->y); - offsx = (int)( (ar->winx - sizex) / 2 + sseq->xof); - offsy = (int)( (ar->winy - sizey) / 2 + sseq->yof); + /* just draw using standard scaling (settings here are currently ignored anyways) */ + offsx = 0; + offsy = 0; + sizex = ar->winx; + sizey = ar->winy; - dflag |= GP_DRAWDATA_ONLYI2D; + /* NOTE: I2D was used in 2.4x, but the old settings for that have been deprecated + * and everything moved to standard View2d + */ + dflag |= GP_DRAWDATA_ONLYV2D; } break; -#endif default: /* for spacetype not yet handled */ offsx = 0; offsy = 0; @@ -746,7 +726,7 @@ void draw_gpencil_2dimage(bContext *C /* , ImBuf *ibuf */) /* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly * Note: this gets called twice - first time with onlyv2d=1 to draw 'canvas' strokes, second time with onlyv2d=0 for screen-aligned strokes */ -void draw_gpencil_view2d(bContext *C, short onlyv2d) +void draw_gpencil_view2d(const bContext *C, short onlyv2d) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 71cbabe9114..7708d99e990 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -78,8 +78,9 @@ /* Context Wrangling... */ /* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it */ -bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr) +bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) { + ID *screen_id = (ID *)CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); @@ -122,9 +123,12 @@ bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr) case SPACE_SEQ: /* Sequencer */ { - //SpaceSeq *sseq= (SpaceSeq *)CTX_wm_space_data(C); + SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C); - /* return the GP data for the active strips/image/etc. */ + /* for now, Grease Pencil data is associated with the space (actually preview region only) */ + // XXX our convention for everything else is to link to data though... + if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, ptr); + return &sseq->gpd; } break; @@ -134,7 +138,7 @@ bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr) /* for now, Grease Pencil data is associated with the space... */ // XXX our convention for everything else is to link to data though... - if (ptr) RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_SpaceImageEditor, sima, ptr); + if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, ptr); return &sima->gpd; } break; @@ -143,7 +147,7 @@ bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr) { SpaceClip *sc = (SpaceClip *)CTX_wm_space_data(C); MovieClip *clip = ED_space_clip(sc); - + if (clip) { if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { MovieTrackingTrack *track = BKE_tracking_active_track(&clip->tracking); @@ -177,7 +181,7 @@ bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr) } /* Get the active Grease Pencil datablock */ -bGPdata *gpencil_data_get_active(bContext *C) +bGPdata *gpencil_data_get_active(const bContext *C) { bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); return (gpd_ptr) ? *(gpd_ptr) : NULL; @@ -214,7 +218,7 @@ static int gp_data_add_exec(bContext *C, wmOperator *op) else { /* decrement user count and add new datablock */ bGPdata *gpd = (*gpd_ptr); - + id_us_min(&gpd->id); *gpd_ptr = gpencil_data_addnew("GPencil"); } @@ -479,7 +483,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) if (v3d) { RegionView3D *rv3d = ar->regiondata; - + /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); @@ -523,26 +527,26 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu /* add points */ for (i = 0, bezt = nu->bezt; i < tot; i++, pt++, bezt++) { float h1[3], h2[3]; - + if (i) interp_v3_v3v3(h1, p3d_cur, p3d_prev, 0.3); else interp_v3_v3v3(h1, p3d_cur, p3d_next, -0.3); - + if (i < tot - 1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3); else interp_v3_v3v3(h2, p3d_cur, p3d_prev, -0.3); - + copy_v3_v3(bezt->vec[0], h1); copy_v3_v3(bezt->vec[1], p3d_cur); copy_v3_v3(bezt->vec[2], h2); - + /* set settings */ bezt->h1 = bezt->h2 = HD_FREE; bezt->f1 = bezt->f2 = bezt->f3 = SELECT; bezt->radius = bezt->weight = pt->pressure * gpl->thickness * 0.1f; - + /* shift coord vects */ copy_v3_v3(p3d_prev, p3d_cur); copy_v3_v3(p3d_cur, p3d_next); - + if (i + 2 < tot) { gp_strokepoint_convertcoords(C, gps, pt + 2, p3d_next, subrect); } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 89d8ed9c465..4004efacadc 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -57,9 +57,12 @@ #include "ED_screen.h" #include "ED_view3d.h" -#include "RNA_access.h" +#include "BIF_gl.h" +#include "BIF_glutil.h" +#include "RNA_access.h" #include "RNA_define.h" + #include "WM_api.h" #include "WM_types.h" @@ -79,15 +82,6 @@ typedef struct tGPsdata { rctf *subrect; /* for using the camera rect within the 3d view */ rctf subrect_data; - -#if 0 // XXX review this 2d image stuff... - ImBuf *ibuf; /* needed for GP_STROKE_2DIMAGE */ - struct IBufViewSettings { - int offsx, offsy; /* offsets */ - int sizex, sizey; /* dimensions to use as scale-factor */ - } im2d_settings; /* needed for GP_STROKE_2DIMAGE */ -#endif - PointerRNA ownerPtr; /* pointer to owner of gp-datablock */ bGPdata *gpd; /* gp-datablock layer comes from */ bGPDlayer *gpl; /* layer we're working on */ @@ -107,8 +101,10 @@ typedef struct tGPsdata { float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space * to region space */ - - float custom_color[4]; /* custom color for (?) */ + + float custom_color[4]; /* custom color - hack for enforcing a particular color for track/mask editing */ + + void *erasercursor; /* radial cursor data for drawing eraser */ } tGPsdata; /* values for tGPsdata->status */ @@ -269,7 +265,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] int mval_prj[2]; float rvec[3], dvec[3]; float mval_f[2]; - + /* Current method just converts each point in screen-coordinates to * 3D-coordinates using the 3D-cursor as reference. In general, this * works OK, but it could of course be improved. @@ -283,7 +279,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] /* method taken from editview.c - mouse_cursor() */ project_int_noclip(p->ar, rvec, mval_prj); - + VECSUB2D(mval_f, mval_prj, mval); ED_view3d_win_to_delta(p->ar, mval_f, dvec); sub_v3_v3v3(out, rvec, dvec); @@ -296,25 +292,6 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] mul_v3_m4v3(out, p->imat, out); } -#if 0 - /* 2d - on image 'canvas' (assume that p->v2d is set) */ - else if (gpd->sbuffer_sflag & GP_STROKE_2DIMAGE) { - int sizex, sizey, offsx, offsy; - - /* get stored settings - * - assume that these have been set already (there are checks that set sane 'defaults' just in case) - */ - sizex = p->im2d_settings.sizex; - sizey = p->im2d_settings.sizey; - offsx = p->im2d_settings.offsx; - offsy = p->im2d_settings.offsy; - - /* calculate new points */ - out[0] = (float)(mval[0] - offsx) / (float)sizex; - out[1] = (float)(mval[1] - offsy) / (float)sizey; - } -#endif - /* 2d - relative to screen (viewport area) */ else { if (p->subrect == NULL) { /* normal 3D view */ @@ -393,11 +370,11 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure) else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* get pointer to destination point */ pt = (tGPspoint *)(gpd->sbuffer); - + /* store settings */ copy_v2_v2_int(&pt->x, mval); pt->pressure = pressure; - + /* if there's stroke for this poly line session add (or replace last) point * to stroke. This allows to draw lines more interactively (see new segment * during mouse slide, i.e.) @@ -405,36 +382,36 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure) if (gp_stroke_added_check(p)) { bGPDstroke *gps = p->gpf->strokes.last; bGPDspoint *pts; - + /* first time point is adding to temporary buffer -- need to allocate new point in stroke */ if (gpd->sbuffer_size == 0) { gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); gps->totpoints++; } - + pts = &gps->points[gps->totpoints - 1]; - + /* special case for poly lines: normally, depth is needed only when creating new stroke from buffer, * but poly lines are converting to stroke instantly, so initialize depth buffer before converting coordinates */ if (gpencil_project_check(p)) { View3D *v3d = p->sa->spacedata.first; - + view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0); } - + /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL); - + /* copy pressure */ pts->pressure = pt->pressure; } - + /* increment counters */ if (gpd->sbuffer_size == 0) gpd->sbuffer_size++; - + return GP_STROKEADD_NORMAL; } @@ -482,7 +459,7 @@ static void gp_stroke_smooth(tGPsdata *p) /* second pass: apply smoothed coordinates */ for (i = 0, spc = smoothArray; i < gpd->sbuffer_size; i++, spc++) { tGPspoint *pc = (((tGPspoint *)gpd->sbuffer) + i); - + copy_v2_v2_int(&pc->x, &spc->x); } @@ -639,10 +616,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* first point */ ptc = gpd->sbuffer; - + /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); - + /* copy pressure */ pt->pressure = ptc->pressure; } @@ -656,10 +633,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) int found_depth = 0; depth_arr = MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); - + for (i = 0, ptc = gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { copy_v2_v2_int(mval, &ptc->x); - + if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { @@ -668,7 +645,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) else { found_depth = TRUE; } - + copy_v2_v2_int(mval_prev, mval); } @@ -835,21 +812,6 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor else if (gps->flag & GP_STROKE_2DSPACE) { UI_view2d_view_to_region(p->v2d, gps->points->x, gps->points->y, &x0, &y0); } -#if 0 - else if (gps->flag & GP_STROKE_2DIMAGE) { - int offsx, offsy, sizex, sizey; - - /* get stored settings */ - sizex = p->im2d_settings.sizex; - sizey = p->im2d_settings.sizey; - offsx = p->im2d_settings.offsx; - offsy = p->im2d_settings.offsy; - - /* calculate new points */ - x0 = (int)((gps->points->x * sizex) + offsx); - y0 = (int)((gps->points->y * sizey) + offsy); - } -#endif else { if (p->subrect == NULL) { /* normal 3D view */ x0 = (int)(gps->points->x / 100 * p->ar->winx); @@ -895,24 +857,6 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor UI_view2d_view_to_region(p->v2d, pt2->x, pt2->y, &x1, &y1); } -#if 0 - else if (gps->flag & GP_STROKE_2DIMAGE) { - int offsx, offsy, sizex, sizey; - - /* get stored settings */ - sizex = p->im2d_settings.sizex; - sizey = p->im2d_settings.sizey; - offsx = p->im2d_settings.offsx; - offsy = p->im2d_settings.offsy; - - /* calculate new points */ - x0 = (int)((pt1->x * sizex) + offsx); - y0 = (int)((pt1->y * sizey) + offsy); - - x1 = (int)((pt2->x * sizex) + offsx); - y1 = (int)((pt2->y * sizey) + offsy); - } -#endif else { if (p->subrect == NULL) { /* normal 3D view */ x0 = (int)(pt1->x / 100 * p->ar->winx); @@ -1029,16 +973,6 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) printf("Error: 3D-View active region doesn't have any region data, so cannot be drawable\n"); return 0; } - -#if 0 // XXX will this sort of antiquated stuff be restored? - /* check that gpencil data is allowed to be drawn */ - if ((v3d->flag2 & V3D_DISPGP) == 0) { - p->status = GP_STATUS_ERROR; - if (G.debug & G_DEBUG) - printf("Error: In active view, Grease Pencil not shown\n"); - return 0; - } -#endif } break; @@ -1050,19 +984,8 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; - -#if 0 // XXX will this sort of antiquated stuff be restored? - /* check that gpencil data is allowed to be drawn */ - if ((snode->flag & SNODE_DISPGP) == 0) { - p->status = GP_STATUS_ERROR; - if (G.debug & G_DEBUG) - printf("Error: In active view, Grease Pencil not shown\n"); - return 0; - } -#endif } break; -#if 0 // XXX these other spaces will come over time... case SPACE_SEQ: { SpaceSeq *sseq = curarea->spacedata.first; @@ -1079,15 +1002,8 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil\n"); return 0; } - if ((sseq->flag & SEQ_DRAW_GPENCIL) == 0) { - p->status = GP_STATUS_ERROR; - if (G.debug & G_DEBUG) - printf("Error: In active view, Grease Pencil not shown\n"); - return 0; - } } break; -#endif case SPACE_IMAGE: { //SpaceImage *sima= curarea->spacedata.first; @@ -1096,48 +1012,36 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; - //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); - -#if 0 // XXX disabled for now - /* check that gpencil data is allowed to be drawn */ - if ((sima->flag & SI_DISPGP) == 0) { - p->status = GP_STATUS_ERROR; - if (G.debug & G_DEBUG) - printf("Error: In active view, Grease Pencil not shown\n"); - return 0; - } -#endif } break; case SPACE_CLIP: { SpaceClip *sc = curarea->spacedata.first; - + /* set the current area */ p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; - //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); - + invert_m4_m4(p->imat, sc->unistabmat); - + /* custom color for new layer */ p->custom_color[0] = 1.0f; p->custom_color[1] = 0.0f; p->custom_color[2] = 0.5f; p->custom_color[3] = 0.9f; - + if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { int framenr = sc->user.framenr; MovieTrackingTrack *track = BKE_tracking_active_track(&sc->clip->tracking); MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr); - + p->imat[3][0] -= marker->pos[0]; p->imat[3][1] -= marker->pos[1]; } } break; - + /* unsupported views */ default: { @@ -1173,12 +1077,6 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) /* clear out buffer (stored in gp-data), in case something contaminated it */ gp_session_validatebuffer(p); -#if 0 - /* set 'default' im2d_settings just in case something that uses this doesn't set it */ - p->im2d_settings.sizex = 1; - p->im2d_settings.sizey = 1; -#endif - return 1; } @@ -1224,7 +1122,7 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode) p->gpl = gpencil_layer_getactive(p->gpd); if (p->gpl == NULL) { p->gpl = gpencil_layer_addnew(p->gpd); - + if (p->custom_color[3]) copy_v3_v3(p->gpl->color, p->custom_color); } @@ -1260,7 +1158,7 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode) if (p->sa->spacetype == SPACE_VIEW3D) { View3D *v3d = p->sa->spacedata.first; RegionView3D *rv3d = p->ar->regiondata; - + /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, TRUE); /* no shift */ @@ -1290,41 +1188,13 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode) p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } break; -#if 0 // XXX other spacetypes to be restored in due course + case SPACE_SEQ: { - SpaceSeq *sseq = (SpaceSeq *)p->sa->spacedata.first; - int rectx, recty; - float zoom, zoomx, zoomy; - - /* set draw 2d-stroke flag */ - p->gpd->sbuffer_sflag |= GP_STROKE_2DIMAGE; - - /* calculate zoom factor */ - zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom)); - if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { - zoomx = zoom * (p->scene->r.xasp / p->scene->r.yasp); - zoomy = zoom; - } - else - zoomx = zoomy = zoom; - - /* calculate rect size to use to calculate the size of the drawing area - * - We use the size of the output image not the size of the ibuf being shown - * as it is too messy getting the ibuf (and could be too slow). This should be - * a reasonable for most cases anyway. - */ - rectx = (p->scene->r.size * p->scene->r.xsch) / 100; - recty = (p->scene->r.size * p->scene->r.ysch) / 100; - - /* set offset and scale values for opertations to use */ - p->im2d_settings.sizex = (int)(zoomx * rectx); - p->im2d_settings.sizey = (int)(zoomy * recty); - p->im2d_settings.offsx = (int)((p->sa->winx - p->im2d_settings.sizex) / 2 + sseq->xof); - p->im2d_settings.offsy = (int)((p->sa->winy - p->im2d_settings.sizey) / 2 + sseq->yof); + p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } break; -#endif + case SPACE_IMAGE: { SpaceImage *sima = (SpaceImage *)p->sa->spacedata.first; @@ -1400,6 +1270,49 @@ static void gp_paint_cleanup(tGPsdata *p) /* ------------------------------- */ +/* Helper callback for drawing the cursor itself */ +static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) +{ + tGPsdata *p = (tGPsdata *)p_ptr; + + if (p->paintmode == GP_PAINTMODE_ERASER) { + glPushMatrix(); + + glTranslatef((float)x, (float)y, 0.0f); + + glColor4ub(255, 255, 255, 128); + + glEnable(GL_LINE_SMOOTH); + glEnable(GL_BLEND); + + glutil_draw_lined_arc(0.0, M_PI * 2.0, p->radius, 40); + + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + + glPopMatrix(); + } +} + +/* Turn brush cursor in 3D view on/off */ +static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short enable) +{ + if (p->erasercursor && !enable) { + /* clear cursor */ + WM_paint_cursor_end(CTX_wm_manager(C), p->erasercursor); + p->erasercursor = NULL; + } + else if (enable) { + /* enable cursor */ + p->erasercursor = WM_paint_cursor_activate(CTX_wm_manager(C), + NULL, // XXX + gpencil_draw_eraser, p); + } +} + +/* ------------------------------- */ + + static void gpencil_draw_exit(bContext *C, wmOperator *op) { tGPsdata *p = op->customdata; @@ -1414,8 +1327,12 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op) if (p) { /* check size of buffer before cleanup, to determine if anything happened here */ if (p->paintmode == GP_PAINTMODE_ERASER) { - // TODO clear radial cursor thing - // XXX draw_sel_circle(NULL, p.mvalo, 0, p.radius, 0); + /* turn off radial brush cursor */ + gpencil_draw_toggle_eraser_cursor(C, p, FALSE); + + /* if successful, store the new eraser size to be used again next time */ + if (p->status == GP_STATUS_DONE) + U.gp_eraser = p->radius; } /* cleanup */ @@ -1466,6 +1383,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op) return 1; } + /* ------------------------------- */ /* update UI indicators of status, including cursor and header prints */ @@ -1560,8 +1478,9 @@ static void gpencil_draw_apply_event(wmOperator *op, wmEvent *event) float mousef[2]; int tablet = 0; - /* convert from window-space to area-space mouse coordintes */ - // NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... + /* convert from window-space to area-space mouse coordintes + * NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... + */ p->mval[0] = event->mval[0] + 1; p->mval[1] = event->mval[1] + 1; @@ -1710,7 +1629,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) /* if eraser is on, draw radial aid */ if (p->paintmode == GP_PAINTMODE_ERASER) { - // TODO: this involves mucking around with radial control, so we leave this for now.. + gpencil_draw_toggle_eraser_cursor(C, p, TRUE); } /* set cursor */ @@ -1743,13 +1662,13 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) } /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ -static int gpencil_area_exists(bContext *C, ScrArea *satest) +static int gpencil_area_exists(bContext *C, ScrArea *sa_test) { bScreen *sc = CTX_wm_screen(C); ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { - if (sa == satest) + if (sa == sa_test) return 1; } @@ -1839,7 +1758,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) sketch |= GPENCIL_SKETCH_SESSIONS_ON(p->scene); /* polyline drawing is also 'sketching' -- all knots should be added during one session */ sketch |= p->paintmode == GP_PAINTMODE_DRAW_POLY; - + if (sketch) { /* end stroke only, and then wait to resume painting soon */ //printf("\t\tGP - end stroke only\n"); @@ -1847,7 +1766,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) /* we've just entered idling state, so this event was processed (but no others yet) */ estate = OPERATOR_RUNNING_MODAL; - + /* stroke could be smoothed, send notifier to refresh screen */ WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); } @@ -1860,7 +1779,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) else if (event->val == KM_PRESS) { /* not painting, so start stroke (this should be mouse-button down) */ p = gpencil_stroke_begin(C, op); - + if (p->status == GP_STATUS_ERROR) { estate = OPERATOR_CANCELLED; } @@ -1889,8 +1808,37 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) estate = OPERATOR_RUNNING_MODAL; } } + /* eraser size */ + else if ((p->paintmode == GP_PAINTMODE_ERASER) && + ELEM4(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE, PADPLUSKEY, PADMINUS)) + { + /* just resize the brush (local version) + * TODO: fix the hardcoded size jumps (set to make a visible difference) and hardcoded keys + */ + //printf("\t\tGP - resize eraser\n"); + switch (event->type) { + case WHEELUPMOUSE: /* larger */ + case PADPLUSKEY: + p->radius += 5; + break; + + case WHEELDOWNMOUSE: /* smaller */ + case PADMINUS: + p->radius -= 5; + + if (p->radius < 0) + p->radius = 0; + break; + } + + /* force refresh */ + ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */ + + /* event handled, so just tag as running modal */ + estate = OPERATOR_RUNNING_MODAL; + } /* there shouldn't be any other events, but just in case there are, let's swallow them - * (i.e. to prevent problems with with undo) + * (i.e. to prevent problems with undo) */ else { /* swallow event to save ourselves trouble */ @@ -1916,7 +1864,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) case OPERATOR_CANCELLED: gpencil_draw_exit(C, op); break; - + case OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH: /* event doesn't need to be handled */ //printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE); diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 32eb63a26d5..1d461f797d6 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -64,8 +64,8 @@ typedef struct tGPspoint { /* ----------- Grease Pencil Tools/Context ------------- */ -struct bGPdata **gpencil_data_get_pointers(struct bContext *C, struct PointerRNA *ptr); -struct bGPdata *gpencil_data_get_active(struct bContext *C); +struct bGPdata **gpencil_data_get_pointers(const struct bContext *C, struct PointerRNA *ptr); +struct bGPdata *gpencil_data_get_active(const struct bContext *C); struct bGPdata *gpencil_data_get_active_v3d(struct Scene *scene); /* for offscreen rendering */ /* ----------- Grease Pencil Operators ----------------- */ @@ -76,8 +76,8 @@ void ED_operatortypes_gpencil(void); /* ------------ Grease-Pencil Drawing API ------------------ */ /* drawgpencil.c */ -void draw_gpencil_2dimage(struct bContext *C /* , struct ImBuf *ibuf */); -void draw_gpencil_view2d(struct bContext *C, short onlyv2d); +void draw_gpencil_2dimage(const struct bContext *C); +void draw_gpencil_view2d(const struct bContext *C, short onlyv2d); void draw_gpencil_view3d(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, short only3d); void gpencil_panel_standard(const struct bContext *C, struct Panel *pa); diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h index c731245949e..cea567254de 100644 --- a/source/blender/editors/include/ED_sequencer.h +++ b/source/blender/editors/include/ED_sequencer.h @@ -27,8 +27,6 @@ #ifndef __ED_SEQUENCER_H__ #define __ED_SEQUENCER_H__ -#define SEQ_ZOOM_FAC(szoom) ((szoom) > 0.0f) ? (szoom) : ((szoom) == 0.0f) ? (1.0f) : (-1.0f / (szoom)) - struct Scene; struct Sequence; diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index c8660179945..db1d4ed1155 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -435,6 +435,12 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) break; } break; + case NC_WINDOW: + if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) { + /* force redraw/refresh after undo/redo - [#28962] */ + ED_area_tag_refresh(sa); + } + break; } } @@ -464,9 +470,21 @@ static void action_refresh(const bContext *C, ScrArea *sa) * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled */ if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) { + ARegion *ar; + + /* Perform syncing of channel state incl. selection + * Active action setting also occurs here (as part of anim channel filtering in anim_filter.c) + */ ANIM_sync_animchannels_to_data(C); saction->flag &= ~SACTION_TEMP_NEEDCHANSYNC; + + /* Tag everything for redraw + * - Regions (such as header) need to be manually tagged for redraw too + * or else they don't update [#28962] + */ ED_area_tag_redraw(sa); + for (ar = sa->regionbase.first; ar; ar = ar->next) + ED_region_tag_redraw(ar); } /* region updates? */ diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 998ebac1cb9..ac71eb972f6 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -565,7 +565,6 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d) /* draw in View2D space? */ if (onlyv2d) { /* draw grease-pencil ('image' strokes) */ - //if (sima->flag & SI_DISPGP) draw_gpencil_2dimage(C); } else { @@ -573,7 +572,6 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d) //SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C); /* draw grease-pencil ('screen' strokes) */ - //if (sima->flag & SI_DISPGP) draw_gpencil_view2d(C, 0); } } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 921aceb7b2e..c65bbd6e15f 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1138,15 +1138,15 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) glDisable(GL_BLEND); /* draw grease-pencil ('canvas' strokes) */ - if (/*(snode->flag & SNODE_DISPGP) &&*/ (snode->nodetree)) - draw_gpencil_view2d((bContext*)C, 1); + if (snode->nodetree) + draw_gpencil_view2d(C, 1); /* reset view matrix */ UI_view2d_view_restore(C); /* draw grease-pencil (screen strokes, and also paintbuffer) */ - if (/*(snode->flag & SNODE_DISPGP) && */(snode->nodetree)) - draw_gpencil_view2d((bContext*)C, 0); + if (snode->nodetree) + draw_gpencil_view2d(C, 0); /* scrollers */ scrollers= UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index e5f7b8fd76d..eb740e441b7 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -35,6 +35,7 @@ #include "DNA_group_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "DNA_material_types.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" @@ -48,6 +49,7 @@ #include "BKE_main.h" #include "BKE_report.h" #include "BKE_scene.h" +#include "BKE_material.h" #include "ED_object.h" #include "ED_screen.h" @@ -1816,3 +1818,68 @@ void OUTLINER_OT_scene_drop(wmOperatorType *ot) RNA_def_string(ot->srna, "object", "Object", MAX_ID_NAME, "Object", "Target Object"); RNA_def_string(ot->srna, "scene", "Scene", MAX_ID_NAME, "Scene", "Target Scene"); } + +static int material_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + Main *bmain = CTX_data_main(C); + Material *ma = NULL; + Object *ob = NULL; + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + TreeElement *te = NULL; + TreeElement *te_found = NULL; + char mat_name[MAX_ID_NAME - 2]; + float fmval[2]; + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + + /* Find object hovered over */ + for (te = soops->tree.first; te; te = te->next) { + te_found = outliner_dropzone_parent(C, event, te, fmval); + if (te_found) + break; + } + + if (te_found) { + RNA_string_set(op->ptr, "object", te_found->name); + ob = (Object *)BKE_libblock_find_name(ID_OB, te_found->name); + + RNA_string_get(op->ptr, "material", mat_name); + ma = (Material *)BKE_libblock_find_name(ID_MA, mat_name); + + if (ELEM(NULL, ob, ma)) { + return OPERATOR_CANCELLED; + } + + assign_material(ob, ma, ob->totcol + 1); + + DAG_ids_flush_update(bmain, 0); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, ma); + + return OPERATOR_FINISHED; + } + + return OPERATOR_CANCELLED; +} + +void OUTLINER_OT_material_drop(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Drop Material on Object"; + ot->description = "Drag material to object in Outliner"; + ot->idname = "OUTLINER_OT_material_drop"; + + /* api callbacks */ + ot->invoke = material_drop_invoke; + + ot->poll = ED_operator_outliner_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "object", "Object", MAX_ID_NAME, "Object", "Target Object"); + RNA_def_string(ot->srna, "material", "Material", MAX_ID_NAME, "Material", "Target Material"); +} + diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 5274410214a..65de2a27568 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -221,6 +221,7 @@ void OUTLINER_OT_drivers_delete_selected(struct wmOperatorType *ot); void OUTLINER_OT_parent_drop(struct wmOperatorType *ot); void OUTLINER_OT_parent_clear(struct wmOperatorType *ot); void OUTLINER_OT_scene_drop(struct wmOperatorType *ot); +void OUTLINER_OT_material_drop(struct wmOperatorType *ot); /* outliner_tools.c ---------------------------------------------- */ diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 0b3a226cca1..1dd043409a5 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -77,6 +77,7 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_parent_drop); WM_operatortype_append(OUTLINER_OT_parent_clear); WM_operatortype_append(OUTLINER_OT_scene_drop); + WM_operatortype_append(OUTLINER_OT_material_drop); } void outliner_keymap(wmKeyConfig *keyconf) diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index c78be8bd223..489a4efe891 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -194,6 +194,35 @@ static void outliner_scene_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "object", id->name + 2); } +static int outliner_material_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeElement *te = NULL; + float fmval[2]; + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + + if (drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if (GS(id->name) == ID_MA) { + /* Ensure item under cursor is valid drop target */ + /* Find object hovered over */ + for (te = soops->tree.first; te; te = te->next) { + if (outliner_dropzone_parent(C, event, te, fmval)) + return 1; + } + } + } + return 0; +} + +static void outliner_material_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + ID *id = (ID *)drag->poin; + + RNA_string_set(drop->ptr, "material", id->name + 2); +} + /* region dropbox definition */ static void outliner_dropboxes(void) { @@ -202,6 +231,7 @@ static void outliner_dropboxes(void) WM_dropbox_add(lb, "OUTLINER_OT_parent_drop", outliner_parent_drop_poll, outliner_parent_drop_copy); WM_dropbox_add(lb, "OUTLINER_OT_parent_clear", outliner_parent_clear_poll, outliner_parent_clear_copy); WM_dropbox_add(lb, "OUTLINER_OT_scene_drop", outliner_scene_drop_poll, outliner_scene_drop_copy); + WM_dropbox_add(lb, "OUTLINER_OT_material_drop", outliner_material_drop_poll, outliner_material_drop_copy); } static void outliner_main_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index bfd9ed95ee4..7bee8c2bebf 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../include + ../../blenfont ../../blenkernel ../../blenlib ../../blenloader diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index 65aadfa1c8a..ec06eacae9c 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -5,7 +5,7 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../blenfont ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' -incs += ' ../../makesrna ../../blenloader' +incs += ' ../../makesrna ../../blenloader ../../blenfont' incs += ' #/intern/audaspace/intern' if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index aeedafa9992..1e452f2052d 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -25,8 +25,6 @@ * \ingroup spseq */ - - #include <string.h> #include <stdio.h> @@ -36,10 +34,13 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_context.h" #include "BKE_screen.h" #include "ED_screen.h" +#include "ED_gpencil.h" #include "WM_api.h" #include "WM_types.h" @@ -48,6 +49,19 @@ #include "sequencer_intern.h" +/* **************************** buttons ********************************* */ + +void sequencer_buttons_register(ARegionType *art) +{ + PanelType *pt; + + pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil"); + strcpy(pt->idname, "SEQUENCER_PT_gpencil"); + strcpy(pt->label, N_("Grease Pencil")); + pt->draw= gpencil_panel_standard; + BLI_addtail(&art->paneltypes, pt); +} + /* **************** operator to open/close properties view ************* */ static int sequencer_properties(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index b674943b2dc..e48450e93bd 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -58,6 +58,7 @@ #include "BIF_glutil.h" #include "ED_anim_api.h" +#include "ED_gpencil.h" #include "ED_markers.h" #include "ED_mask.h" #include "ED_types.h" @@ -975,17 +976,15 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq } /* draw grease-pencil (image aligned) */ -// if (sseq->flag & SEQ_DRAW_GPENCIL) -// XXX draw_gpencil_2dimage(sa, ibuf); + draw_gpencil_2dimage(C); IMB_freeImBuf(ibuf); - /* draw grease-pencil (screen aligned) */ -// if (sseq->flag & SEQ_DRAW_GPENCIL) -// XXX draw_gpencil_view2d(sa, 0); - /* ortho at pixel level */ UI_view2d_view_restore(C); + + /* draw grease-pencil (screen aligned) */ + draw_gpencil_view2d(C, 0); //if (sc->mode == SC_MODE_MASKEDIT) { if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 25a322c6905..14d2ccdbbbe 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -174,7 +174,7 @@ struct ImBuf *make_zebra_view_from_ibuf(struct ImBuf * ibuf, float perc); struct ImBuf *make_histogram_view_from_ibuf(struct ImBuf * ibuf); /* sequencer_buttons.c */ - +void sequencer_buttons_register(struct ARegionType *art); void SEQUENCER_OT_properties(struct wmOperatorType *ot); #endif /* __SEQUENCER_INTERN_H__ */ diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 3643f92d334..dbfc554007a 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -485,6 +485,11 @@ static void sequencer_preview_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { + case NC_SCREEN: + if (wmn->data == ND_GPENCIL) { + ED_region_tag_redraw(ar); + } + break; case NC_SCENE: switch (wmn->data) { case ND_FRAME: @@ -534,6 +539,11 @@ static void sequencer_buttons_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { + case NC_SCREEN: + if (wmn->data == ND_GPENCIL) { + ED_region_tag_redraw(ar); + } + break; case NC_SCENE: switch (wmn->data) { case ND_FRAME: @@ -590,7 +600,7 @@ void ED_spacetype_sequencer(void) art->init = sequencer_preview_area_init; art->draw = sequencer_preview_area_draw; art->listener = sequencer_preview_area_listener; - art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_ANIMATION; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL; BLI_addhead(&st->regiontypes, art); /* regions: listview/buttons */ @@ -602,6 +612,8 @@ void ED_spacetype_sequencer(void) art->init = sequencer_buttons_area_init; art->draw = sequencer_buttons_area_draw; BLI_addhead(&st->regiontypes, art); + + sequencer_buttons_register(art); /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype sequencer region"); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 3710ef1d30d..9e7facf1b6f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1607,7 +1607,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->state = TRANS_STARTING; - if ( (prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) { + if ((prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) { if (RNA_property_boolean_get(op->ptr, prop)) { options |= CTX_TEXTURE; } @@ -2071,7 +2071,9 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu mul_qt_fl(quat, qlen); /* quaternions flip w sign to accumulate rotations correctly */ - if ( (nquat[0] < 0.0f && quat[0] > 0.0f) || (nquat[0] > 0.0f && quat[0] < 0.0f) ) { + if ((nquat[0] < 0.0f && quat[0] > 0.0f) || + (nquat[0] > 0.0f && quat[0] < 0.0f)) + { mul_qt_fl(quat, -1.0f); } } @@ -2818,9 +2820,9 @@ int Resize(TransInfo *t, const int mval[2]) float ratio; int i; char str[200]; - + /* for manipulator, center handle, the scaling can't be done relative to center */ - if ( (t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) { + if ((t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) { ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1])) / 100.0f; } else { diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index b18d132f8df..d2910c5b602 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -77,7 +77,7 @@ static void constraintAutoValues(TransInfo *t, float vec[3]) { int mode = t->con.mode; if (mode & CON_APPLY) { - float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f; + float nval = (t->flag & T_NULL_ONE) ? 1.0f : 0.0f; if ((mode & CON_AXIS0) == 0) { vec[0] = nval; @@ -95,21 +95,21 @@ void constraintNumInput(TransInfo *t, float vec[3]) { int mode = t->con.mode; if (mode & CON_APPLY) { - float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f; + float nval = (t->flag & T_NULL_ONE) ? 1.0f : 0.0f; if (getConstraintSpaceDimension(t) == 2) { - int axis = mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2); - if (axis == (CON_AXIS0|CON_AXIS1)) { + int axis = mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2); + if (axis == (CON_AXIS0 | CON_AXIS1)) { /* vec[0] = vec[0]; */ /* same */ /* vec[1] = vec[1]; */ /* same */ vec[2] = nval; } - else if (axis == (CON_AXIS1|CON_AXIS2)) { + else if (axis == (CON_AXIS1 | CON_AXIS2)) { vec[2] = vec[1]; vec[1] = vec[0]; vec[0] = nval; } - else if (axis == (CON_AXIS0|CON_AXIS2)) { + else if (axis == (CON_AXIS0 | CON_AXIS2)) { /* vec[0] = vec[0]; */ /* same */ vec[2] = vec[1]; vec[1] = nval; @@ -184,7 +184,7 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3]) { if (t->spacetype == SPACE_VIEW3D) { // View3D *v3d = t->sa->spacedata.first; - const float min_dist= 1.0f; // v3d->near; + const float min_dist = 1.0f; /* v3d->near; */ float dir[3]; float l; @@ -194,7 +194,7 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3]) } project_v3_v3v3(dir, dir, t->viewinv[2]); - l= len_v3(dir); + l = len_v3(dir); if (l < min_dist) { float diff[3]; @@ -211,7 +211,7 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 float norm[3], vec[3], factor, angle; float t_con_center[3]; - if (in[0]==0.0f && in[1]==0.0f && in[2]==0.0f) + if (in[0] == 0.0f && in[1] == 0.0f && in[2] == 0.0f) return; copy_v3_v3(t_con_center, t->con.center); @@ -232,12 +232,12 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 project_v3_v3v3(vec, in, t->viewinv[1]); factor = dot_v3v3(t->viewinv[1], vec) * 2.0f; /* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */ - if (factor<0.0f) factor*= -factor; - else factor*= factor; + if (factor < 0.0f) factor *= -factor; + else factor *= factor; copy_v3_v3(out, axis); normalize_v3(out); - mul_v3_fl(out, -factor); /* -factor makes move down going backwards */ + mul_v3_fl(out, -factor); /* -factor makes move down going backwards */ } else { float v[3], i1[3], i2[3]; @@ -276,10 +276,10 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 sub_v3_v3v3(out, i1, t_con_center); /* possible some values become nan when - * viewpoint and object are both zero */ - if (!finite(out[0])) out[0]= 0.0f; - if (!finite(out[1])) out[1]= 0.0f; - if (!finite(out[2])) out[2]= 0.0f; + * viewpoint and object are both zero */ + if (!finite(out[0])) out[0] = 0.0f; + if (!finite(out[1])) out[1] = 0.0f; + if (!finite(out[2])) out[2] = 0.0f; } } } @@ -386,7 +386,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], f copy_v3_v3(out, pvec); } else { - int i=0; + int i = 0; out[0] = out[1] = out[2] = 0.0f; if (t->con.mode & CON_AXIS0) { @@ -475,21 +475,21 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3] static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle) { if (!td && t->con.mode & CON_APPLY) { - int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2); + int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2); switch (mode) { - case CON_AXIS0: - case (CON_AXIS1|CON_AXIS2): - copy_v3_v3(vec, t->con.mtx[0]); - break; - case CON_AXIS1: - case (CON_AXIS0|CON_AXIS2): - copy_v3_v3(vec, t->con.mtx[1]); - break; - case CON_AXIS2: - case (CON_AXIS0|CON_AXIS1): - copy_v3_v3(vec, t->con.mtx[2]); - break; + case CON_AXIS0: + case (CON_AXIS1 | CON_AXIS2): + copy_v3_v3(vec, t->con.mtx[0]); + break; + case CON_AXIS1: + case (CON_AXIS0 | CON_AXIS2): + copy_v3_v3(vec, t->con.mtx[1]); + break; + case CON_AXIS2: + case (CON_AXIS0 | CON_AXIS1): + copy_v3_v3(vec, t->con.mtx[2]); + break; } /* don't flip axis if asked to or if num input */ if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) { @@ -517,26 +517,26 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle) { if (t->con.mode & CON_APPLY) { - int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2); + int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2); /* on setup call, use first object */ if (td == NULL) { - td= t->data; + td = t->data; } switch (mode) { - case CON_AXIS0: - case (CON_AXIS1|CON_AXIS2): - copy_v3_v3(vec, td->axismtx[0]); - break; - case CON_AXIS1: - case (CON_AXIS0|CON_AXIS2): - copy_v3_v3(vec, td->axismtx[1]); - break; - case CON_AXIS2: - case (CON_AXIS0|CON_AXIS1): - copy_v3_v3(vec, td->axismtx[2]); - break; + case CON_AXIS0: + case (CON_AXIS1 | CON_AXIS2): + copy_v3_v3(vec, td->axismtx[0]); + break; + case CON_AXIS1: + case (CON_AXIS0 | CON_AXIS2): + copy_v3_v3(vec, td->axismtx[1]); + break; + case CON_AXIS2: + case (CON_AXIS0 | CON_AXIS1): + copy_v3_v3(vec, td->axismtx[2]); + break; } if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) { if (dot_v3v3(vec, t->viewinv[2]) > 0.0f) { @@ -604,33 +604,33 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte char text[40]; switch (orientation) { - case V3D_MANIP_GLOBAL: + case V3D_MANIP_GLOBAL: { - float mtx[3][3]= MAT3_UNITY; + float mtx[3][3] = MAT3_UNITY; BLI_snprintf(text, sizeof(text), ftext, "global"); setConstraint(t, mtx, mode, text); } break; - case V3D_MANIP_LOCAL: - BLI_snprintf(text, sizeof(text), ftext, "local"); - setLocalConstraint(t, mode, text); - break; - case V3D_MANIP_NORMAL: - BLI_snprintf(text, sizeof(text), ftext, "normal"); - setConstraint(t, t->spacemtx, mode, text); - break; - case V3D_MANIP_VIEW: - BLI_snprintf(text, sizeof(text), ftext, "view"); - setConstraint(t, t->spacemtx, mode, text); - break; - case V3D_MANIP_GIMBAL: - BLI_snprintf(text, sizeof(text), ftext, "gimbal"); - setConstraint(t, t->spacemtx, mode, text); - break; - default: /* V3D_MANIP_CUSTOM */ - BLI_snprintf(text, sizeof(text), ftext, t->spacename); - setConstraint(t, t->spacemtx, mode, text); - break; + case V3D_MANIP_LOCAL: + BLI_snprintf(text, sizeof(text), ftext, "local"); + setLocalConstraint(t, mode, text); + break; + case V3D_MANIP_NORMAL: + BLI_snprintf(text, sizeof(text), ftext, "normal"); + setConstraint(t, t->spacemtx, mode, text); + break; + case V3D_MANIP_VIEW: + BLI_snprintf(text, sizeof(text), ftext, "view"); + setConstraint(t, t->spacemtx, mode, text); + break; + case V3D_MANIP_GIMBAL: + BLI_snprintf(text, sizeof(text), ftext, "gimbal"); + setConstraint(t, t->spacemtx, mode, text); + break; + default: /* V3D_MANIP_CUSTOM */ + BLI_snprintf(text, sizeof(text), ftext, t->spacename); + setConstraint(t, t->spacemtx, mode, text); + break; } t->con.orientation = orientation; @@ -682,8 +682,8 @@ void drawConstraint(TransInfo *t) setlinestyle(1); glBegin(GL_LINE_STRIP); - glVertex3fv(tc->center); - glVertex3fv(vec); + glVertex3fv(tc->center); + glVertex3fv(vec); glEnd(); setlinestyle(0); @@ -733,7 +733,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) float aspx, aspy; ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); - glScalef(1.0f/aspx, 1.0f/aspy, 1.0); + glScalef(1.0f / aspx, 1.0f / aspy, 1.0); } set_inverted_drawing(1); @@ -747,7 +747,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) static void drawObjectConstraint(TransInfo *t) { int i; - TransData * td = t->data; + TransData *td = t->data; /* Draw the first one lighter because that's the one who controls the others. * Meaning the transformation is projected on that one and just copied on the others @@ -767,7 +767,7 @@ static void drawObjectConstraint(TransInfo *t) td++; - for (i=1; i < t->total; i++, td++) { + for (i = 1; i < t->total; i++, td++) { if (t->con.mode & CON_AXIS0) { drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', 0); } @@ -791,7 +791,7 @@ void startConstraint(TransInfo *t) void stopConstraint(TransInfo *t) { - t->con.mode &= ~(CON_APPLY|CON_SELECT); + t->con.mode &= ~(CON_APPLY | CON_SELECT); *t->con.text = '\0'; t->num.idx_max = t->idx_max; } @@ -803,21 +803,21 @@ void getConstraintMatrix(TransInfo *t) unit_m3(t->con.pmtx); if (!(t->con.mode & CON_AXIS0)) { - t->con.pmtx[0][0] = - t->con.pmtx[0][1] = - t->con.pmtx[0][2] = 0.0f; + t->con.pmtx[0][0] = + t->con.pmtx[0][1] = + t->con.pmtx[0][2] = 0.0f; } if (!(t->con.mode & CON_AXIS1)) { - t->con.pmtx[1][0] = - t->con.pmtx[1][1] = - t->con.pmtx[1][2] = 0.0f; + t->con.pmtx[1][0] = + t->con.pmtx[1][1] = + t->con.pmtx[1][2] = 0.0f; } if (!(t->con.mode & CON_AXIS2)) { - t->con.pmtx[2][0] = - t->con.pmtx[2][1] = - t->con.pmtx[2][2] = 0.0f; + t->con.pmtx[2][0] = + t->con.pmtx[2][1] = + t->con.pmtx[2][2] = 0.0f; } mul_m3_m3m3(mat, t->con.pmtx, t->con.imtx); @@ -866,7 +866,7 @@ void postSelectConstraint(TransInfo *t) static void setNearestAxis2d(TransInfo *t) { /* no correction needed... just use whichever one is lower */ - if ( abs(t->mval[0]-t->con.imval[0]) < abs(t->mval[1]-t->con.imval[1]) ) { + if (abs(t->mval[0] - t->con.imval[0]) < abs(t->mval[1] - t->con.imval[1]) ) { t->con.mode |= CON_AXIS1; BLI_snprintf(t->con.text, sizeof(t->con.text), " along Y axis"); } @@ -895,10 +895,10 @@ static void setNearestAxis3d(TransInfo *t) * of two 2D points 30 pixels apart (that's the last factor in the formula) after * projecting them with window_to_3d_delta and then get the length of that vector. */ - zfac= t->persmat[0][3]*t->center[0]+ t->persmat[1][3]*t->center[1]+ t->persmat[2][3]*t->center[2]+ t->persmat[3][3]; - zfac = len_v3(t->persinv[0]) * 2.0f/t->ar->winx * zfac * 30.0f; + zfac = t->persmat[0][3] * t->center[0] + t->persmat[1][3] * t->center[1] + t->persmat[2][3] * t->center[2] + t->persmat[3][3]; + zfac = len_v3(t->persinv[0]) * 2.0f / t->ar->winx * zfac * 30.0f; - for (i = 0; i<3; i++) { + for (i = 0; i < 3; i++) { copy_v3_v3(axis, t->con.mtx[i]); mul_v3_fl(axis, zfac); @@ -922,7 +922,7 @@ static void setNearestAxis3d(TransInfo *t) if (len[0] <= len[1] && len[0] <= len[2]) { if (t->modifiers & MOD_CONSTRAINT_PLANE) { - t->con.mode |= (CON_AXIS1|CON_AXIS2); + t->con.mode |= (CON_AXIS1 | CON_AXIS2); BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s X axis", t->spacename); } else { @@ -932,7 +932,7 @@ static void setNearestAxis3d(TransInfo *t) } else if (len[1] <= len[0] && len[1] <= len[2]) { if (t->modifiers & MOD_CONSTRAINT_PLANE) { - t->con.mode |= (CON_AXIS0|CON_AXIS2); + t->con.mode |= (CON_AXIS0 | CON_AXIS2); BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Y axis", t->spacename); } else { @@ -942,7 +942,7 @@ static void setNearestAxis3d(TransInfo *t) } else if (len[2] <= len[1] && len[2] <= len[0]) { if (t->modifiers & MOD_CONSTRAINT_PLANE) { - t->con.mode |= (CON_AXIS0|CON_AXIS1); + t->con.mode |= (CON_AXIS0 | CON_AXIS1); BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Z axis", t->spacename); } else { @@ -976,21 +976,21 @@ void setNearestAxis(TransInfo *t) char constraintModeToChar(TransInfo *t) { - if ((t->con.mode & CON_APPLY)==0) { + if ((t->con.mode & CON_APPLY) == 0) { return '\0'; } - switch (t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2)) { - case (CON_AXIS0): - case (CON_AXIS1|CON_AXIS2): - return 'X'; - case (CON_AXIS1): - case (CON_AXIS0|CON_AXIS2): - return 'Y'; - case (CON_AXIS2): - case (CON_AXIS0|CON_AXIS1): - return 'Z'; - default: - return '\0'; + switch (t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2)) { + case (CON_AXIS0): + case (CON_AXIS1 | CON_AXIS2): + return 'X'; + case (CON_AXIS1): + case (CON_AXIS0 | CON_AXIS2): + return 'Y'; + case (CON_AXIS2): + case (CON_AXIS0 | CON_AXIS1): + return 'Z'; + default: + return '\0'; } } @@ -999,13 +999,13 @@ int isLockConstraint(TransInfo *t) { int mode = t->con.mode; - if ( (mode & (CON_AXIS0|CON_AXIS1)) == (CON_AXIS0|CON_AXIS1)) + if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1)) return 1; - if ( (mode & (CON_AXIS1|CON_AXIS2)) == (CON_AXIS1|CON_AXIS2)) + if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2)) return 1; - if ( (mode & (CON_AXIS0|CON_AXIS2)) == (CON_AXIS0|CON_AXIS2)) + if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2)) return 1; return 0; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 95a9ab5900a..5a38bf607d9 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1909,7 +1909,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx // Setting normals copy_v3_v3(td->axismtx[2], eve->no); - td->axismtx[0][0] = + td->axismtx[0][0] = td->axismtx[0][1] = td->axismtx[0][2] = td->axismtx[1][0] = diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index f21e0a0515d..8682b866742 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -828,7 +828,7 @@ static void recalcData_view3d(TransInfo *t) DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ } } - else if ( (t->flag & T_POSE) && t->poseobj) { + else if ((t->flag & T_POSE) && t->poseobj) { Object *ob = t->poseobj; bArmature *arm = ob->data; diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 9c485e17dc7..7e05fdae364 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -64,18 +64,18 @@ static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], /* calculate ratio for shiftkey pos, and for total, and blend these for precision */ dx = (float)(mi->center[0] - mi->precision_mval[0]); dy = (float)(mi->center[1] - mi->precision_mval[1]); - ratio = (float)sqrt( dx*dx + dy*dy); + ratio = sqrtf(dx * dx + dy * dy); - dx= (float)(mi->center[0] - mval[0]); - dy= (float)(mi->center[1] - mval[1]); - precise_ratio = (float)sqrt( dx*dx + dy*dy); + dx = (float)(mi->center[0] - mval[0]); + dy = (float)(mi->center[1] - mval[1]); + precise_ratio = (float)sqrt(dx * dx + dy * dy); ratio = (ratio + (precise_ratio - ratio) / 10.0f) / mi->factor; } else { dx = (float)(mi->center[0] - mval[0]); dy = (float)(mi->center[1] - mval[1]); - ratio = (float)sqrt( dx*dx + dy*dy) / mi->factor; + ratio = sqrtf(dx * dx + dy * dy) / mi->factor; } output[0] = ratio; @@ -98,12 +98,12 @@ static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const int mval[ { if (mi->precision) { - output[0] = ( mi->imval[1] - mi->precision_mval[1] ) + ( mi->precision_mval[1] - mval[1] ) * 0.1f; - output[1] = ( mi->precision_mval[0] - mi->imval[0] ) + ( mval[0] - mi->precision_mval[0] ) * 0.1f; + output[0] = (mi->imval[1] - mi->precision_mval[1]) + (mi->precision_mval[1] - mval[1]) * 0.1f; + output[1] = (mi->precision_mval[0] - mi->imval[0]) + (mval[0] - mi->precision_mval[0]) * 0.1f; } else { - output[0] = (float)( mi->imval[1] - mval[1] ); - output[1] = (float)( mval[0] - mi->imval[0] ); + output[0] = (float)(mi->imval[1] - mval[1]); + output[1] = (float)(mval[0] - mi->imval[0]); } output[0] *= mi->factor; @@ -191,7 +191,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva dx = data[2] - data[0]; dy = data[3] - data[1]; - length = sqrt(dx*dx + dy*dy); + length = sqrt(dx * dx + dy * dy); if (mi->precision) { /* deal with Shift key by adding motion / 10 to motion before shift press */ @@ -199,7 +199,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2]; mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3]; - distance = (length != 0.0) ? (mdx * dx + mdy * dy) / length: 0.0; + distance = (length != 0.0) ? (mdx * dx + mdy * dy) / length : 0.0; } else { int mdx, mdy; @@ -217,11 +217,11 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], { double dx2 = mval[0] - mi->center[0]; double dy2 = mval[1] - mi->center[1]; - double B = sqrt(dx2*dx2+dy2*dy2); + double B = sqrt(dx2 * dx2 + dy2 * dy2); double dx1 = mi->imval[0] - mi->center[0]; double dy1 = mi->imval[1] - mi->center[1]; - double A = sqrt(dx1*dx1+dy1*dy1); + double A = sqrt(dx1 * dx1 + dy1 * dy1); double dx3 = mval[0] - mi->imval[0]; double dy3 = mval[1] - mi->imval[1]; @@ -237,7 +237,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float dphi; dphi = saacos((float)deler); - if ( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi; + if ((dx1 * dy2 - dx2 * dy1) > 0.0) dphi = -dphi; /* If the angle is zero, because of lack of precision close to the 1.0 value in acos * approximate the angle with the opposite side of the normalized triangle @@ -256,12 +256,12 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], dx = dx1 - dx2; dy = dy1 - dy2; - dphi = sqrt(dx*dx + dy*dy); - if ( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi; + dphi = sqrt(dx * dx + dy * dy); + if ((dx1 * dy2 - dx2 * dy1) > 0.0) dphi = -dphi; } if (mi->precision) { - dphi = dphi/30.0f; + dphi = dphi / 30.0f; } /* if no delta angle, don't update initial position */ @@ -295,7 +295,7 @@ static void calcSpringFactor(MouseInput *mi) ((float)(mi->center[0] - mi->imval[0])) * ((float)(mi->center[0] - mi->imval[0]))); if (mi->factor == 0.0f) { - mi->factor= 1.0f; /* prevent Inf */ + mi->factor = 1.0f; /* prevent Inf */ } } @@ -307,68 +307,68 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) #if 0 if (mi->data) { MEM_freeN(mi->data); - mi->data= NULL; + mi->data = NULL; } #endif switch (mode) { - case INPUT_VECTOR: - mi->apply = InputVector; - t->helpline = HLP_NONE; - break; - case INPUT_SPRING: - calcSpringFactor(mi); - mi->apply = InputSpring; - t->helpline = HLP_SPRING; - break; - case INPUT_SPRING_FLIP: - calcSpringFactor(mi); - mi->apply = InputSpringFlip; - t->helpline = HLP_SPRING; - break; - case INPUT_ANGLE: - mi->data = MEM_callocN(sizeof(double), "angle accumulator"); - mi->apply = InputAngle; - t->helpline = HLP_ANGLE; - break; - case INPUT_TRACKBALL: - /* factor has to become setting or so */ - mi->factor = 0.01f; - mi->apply = InputTrackBall; - t->helpline = HLP_TRACKBALL; - break; - case INPUT_HORIZONTAL_RATIO: - mi->factor = (float)(mi->center[0] - mi->imval[0]); - mi->apply = InputHorizontalRatio; - t->helpline = HLP_HARROW; - break; - case INPUT_HORIZONTAL_ABSOLUTE: - mi->apply = InputHorizontalAbsolute; - t->helpline = HLP_HARROW; - break; - case INPUT_VERTICAL_RATIO: - mi->apply = InputVerticalRatio; - t->helpline = HLP_VARROW; - break; - case INPUT_VERTICAL_ABSOLUTE: - mi->apply = InputVerticalAbsolute; - t->helpline = HLP_VARROW; - break; - case INPUT_CUSTOM_RATIO: - mi->apply = InputCustomRatio; - t->helpline = HLP_NONE; - break; - case INPUT_NONE: - default: - mi->apply = NULL; - break; + case INPUT_VECTOR: + mi->apply = InputVector; + t->helpline = HLP_NONE; + break; + case INPUT_SPRING: + calcSpringFactor(mi); + mi->apply = InputSpring; + t->helpline = HLP_SPRING; + break; + case INPUT_SPRING_FLIP: + calcSpringFactor(mi); + mi->apply = InputSpringFlip; + t->helpline = HLP_SPRING; + break; + case INPUT_ANGLE: + mi->data = MEM_callocN(sizeof(double), "angle accumulator"); + mi->apply = InputAngle; + t->helpline = HLP_ANGLE; + break; + case INPUT_TRACKBALL: + /* factor has to become setting or so */ + mi->factor = 0.01f; + mi->apply = InputTrackBall; + t->helpline = HLP_TRACKBALL; + break; + case INPUT_HORIZONTAL_RATIO: + mi->factor = (float)(mi->center[0] - mi->imval[0]); + mi->apply = InputHorizontalRatio; + t->helpline = HLP_HARROW; + break; + case INPUT_HORIZONTAL_ABSOLUTE: + mi->apply = InputHorizontalAbsolute; + t->helpline = HLP_HARROW; + break; + case INPUT_VERTICAL_RATIO: + mi->apply = InputVerticalRatio; + t->helpline = HLP_VARROW; + break; + case INPUT_VERTICAL_ABSOLUTE: + mi->apply = InputVerticalAbsolute; + t->helpline = HLP_VARROW; + break; + case INPUT_CUSTOM_RATIO: + mi->apply = InputCustomRatio; + t->helpline = HLP_NONE; + break; + case INPUT_NONE: + default: + mi->apply = NULL; + break; } /* bootstrap mouse input with initial values */ applyMouseInput(t, mi, mi->imval, t->values); } -void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3])) +void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float[3])) { mi->post = post; } @@ -389,21 +389,21 @@ int handleMouseInput(TransInfo *t, MouseInput *mi, wmEvent *event) int redraw = TREDRAW_NOTHING; switch (event->type) { - case LEFTSHIFTKEY: - case RIGHTSHIFTKEY: - if (event->val == KM_PRESS) { - t->modifiers |= MOD_PRECISION; - /* shift is modifier for higher precision transform - * store the mouse position where the normal movement ended */ - copy_v2_v2_int(mi->precision_mval, event->mval); - mi->precision = 1; - } - else { - t->modifiers &= ~MOD_PRECISION; - mi->precision = 0; - } - redraw = TREDRAW_HARD; - break; + case LEFTSHIFTKEY: + case RIGHTSHIFTKEY: + if (event->val == KM_PRESS) { + t->modifiers |= MOD_PRECISION; + /* shift is modifier for higher precision transform + * store the mouse position where the normal movement ended */ + copy_v2_v2_int(mi->precision_mval, event->mval); + mi->precision = 1; + } + else { + t->modifiers &= ~MOD_PRECISION; + mi->precision = 0; + } + redraw = TREDRAW_HARD; + break; } return redraw; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 7d0e9dd6005..e02ad00ac7f 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -84,35 +84,35 @@ /* return codes for select, and drawing flags */ -#define MAN_TRANS_X 1 -#define MAN_TRANS_Y 2 -#define MAN_TRANS_Z 4 -#define MAN_TRANS_C 7 - -#define MAN_ROT_X 8 -#define MAN_ROT_Y 16 -#define MAN_ROT_Z 32 -#define MAN_ROT_V 64 -#define MAN_ROT_T 128 -#define MAN_ROT_C 248 - -#define MAN_SCALE_X 256 -#define MAN_SCALE_Y 512 -#define MAN_SCALE_Z 1024 -#define MAN_SCALE_C 1792 +#define MAN_TRANS_X 1 +#define MAN_TRANS_Y 2 +#define MAN_TRANS_Z 4 +#define MAN_TRANS_C 7 + +#define MAN_ROT_X 8 +#define MAN_ROT_Y 16 +#define MAN_ROT_Z 32 +#define MAN_ROT_V 64 +#define MAN_ROT_T 128 +#define MAN_ROT_C 248 + +#define MAN_SCALE_X 256 +#define MAN_SCALE_Y 512 +#define MAN_SCALE_Z 1024 +#define MAN_SCALE_C 1792 /* color codes */ -#define MAN_RGB 0 -#define MAN_GHOST 1 -#define MAN_MOVECOL 2 +#define MAN_RGB 0 +#define MAN_GHOST 1 +#define MAN_MOVECOL 2 /* transform widget center calc helper for below */ static void calc_tw_center(Scene *scene, float *co) { - float *twcent= scene->twcent; - float *min= scene->twmin; - float *max= scene->twmax; + float *twcent = scene->twcent; + float *min = scene->twmin; + float *max = scene->twmax; minmax_v3v3_v3(min, max, co); add_v3_v3(twcent, co); @@ -145,7 +145,7 @@ static void protectflag_to_drawflags(short protectflag, short *drawflags) /* for pose mode */ static void stats_pose(Scene *scene, RegionView3D *rv3d, bPoseChannel *pchan) { - Bone *bone= pchan->bone; + Bone *bone = pchan->bone; if (bone) { if (bone->flag & BONE_TRANSFORM) { @@ -159,7 +159,7 @@ static void stats_pose(Scene *scene, RegionView3D *rv3d, bPoseChannel *pchan) static void stats_editbone(RegionView3D *rv3d, EditBone *ebo) { if (ebo->flag & BONE_EDITMODE_LOCKED) - protectflag_to_drawflags(OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE, &rv3d->twdrawflag); + protectflag_to_drawflags(OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE, &rv3d->twdrawflag); } /* could move into BLI_math however this is only useful for display/editing purposes */ @@ -172,9 +172,9 @@ static void axis_angle_to_gimbal_axis(float gmat[3][3], float axis[3], float ang /* this is an un-scientific method to get a vector to cross with * XYZ intentionally YZX */ - cross_vec[0]= axis[1]; - cross_vec[1]= axis[2]; - cross_vec[2]= axis[0]; + cross_vec[0] = axis[1]; + cross_vec[1] = axis[2]; + cross_vec[2] = axis[0]; /* X-axis */ cross_v3_v3v3(gmat[0], cross_vec, axis); @@ -183,7 +183,7 @@ static void axis_angle_to_gimbal_axis(float gmat[3][3], float axis[3], float ang mul_qt_v3(quat, gmat[0]); /* Y-axis */ - axis_angle_to_quat(quat, axis, M_PI/2.0); + axis_angle_to_quat(quat, axis, M_PI / 2.0); copy_v3_v3(gmat[1], gmat[0]); mul_qt_v3(quat, gmat[1]); @@ -196,14 +196,14 @@ static void axis_angle_to_gimbal_axis(float gmat[3][3], float axis[3], float ang static int test_rotmode_euler(short rotmode) { - return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0:1; + return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0 : 1; } int gimbal_axis(Object *ob, float gmat[][3]) { if (ob) { if (ob->mode & OB_MODE_POSE) { - bPoseChannel *pchan= BKE_pose_channel_active(ob); + bPoseChannel *pchan = BKE_pose_channel_active(ob); if (pchan) { float mat[3][3], tmat[3][3], obmat[3][3]; @@ -270,40 +270,40 @@ int gimbal_axis(Object *ob, float gmat[][3]) /* returns total items selected */ int calc_manipulator_stats(const bContext *C) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); ToolSettings *ts = CTX_data_tool_settings(C); - View3D *v3d= sa->spacedata.first; - RegionView3D *rv3d= ar->regiondata; + View3D *v3d = sa->spacedata.first; + RegionView3D *rv3d = ar->regiondata; Base *base; - Object *ob= OBACT; - int a, totsel= 0; + Object *ob = OBACT; + int a, totsel = 0; /* transform widget matrix */ unit_m4(rv3d->twmat); - rv3d->twdrawflag= 0xFFFF; + rv3d->twdrawflag = 0xFFFF; /* transform widget centroid/center */ INIT_MINMAX(scene->twmin, scene->twmax); zero_v3(scene->twcent); if (obedit) { - ob= obedit; - if ((ob->lay & v3d->lay)==0) return 0; + ob = obedit; + if ((ob->lay & v3d->lay) == 0) return 0; - if (obedit->type==OB_MESH) { + if (obedit->type == OB_MESH) { BMEditMesh *em = BMEdit_FromObject(obedit); BMEditSelection ese; - float vec[3]= {0, 0, 0}; + float vec[3] = {0, 0, 0}; /* USE LAST SELECTE WITH ACTIVE */ if ((v3d->around == V3D_ACTIVE) && BM_select_history_active_get(em->bm, &ese)) { BM_editselection_center(&ese, vec); calc_tw_center(scene, vec); - totsel= 1; + totsel = 1; } else { BMesh *bm = em->bm; @@ -358,10 +358,10 @@ int calc_manipulator_stats(const bContext *C) } } } /* end editmesh */ - else if (obedit->type==OB_ARMATURE) { - bArmature *arm= obedit->data; + else if (obedit->type == OB_ARMATURE) { + bArmature *arm = obedit->data; EditBone *ebo; - for (ebo= arm->edbo->first; ebo; ebo=ebo->next) { + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { if (EBONE_VISIBLE(arm, ebo)) { if (ebo->flag & BONE_TIPSEL) { calc_tw_center(scene, ebo->tail); @@ -378,24 +378,24 @@ int calc_manipulator_stats(const bContext *C) } } else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; float center[3]; - if (v3d->around==V3D_ACTIVE && ED_curve_actSelection(cu, center)) { - calc_tw_center(scene, center); + if (v3d->around == V3D_ACTIVE && ED_curve_actSelection(cu, center)) { + calc_tw_center(scene, center); totsel++; } else { Nurb *nu; BezTriple *bezt; BPoint *bp; - ListBase *nurbs= BKE_curve_editNurbs_get(cu); + ListBase *nurbs = BKE_curve_editNurbs_get(cu); - nu= nurbs->first; + nu = nurbs->first; while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { /* exceptions * if handles are hidden then only check the center points. @@ -425,8 +425,8 @@ int calc_manipulator_stats(const bContext *C) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if (bp->f1 & SELECT) { calc_tw_center(scene, bp->vec); @@ -435,31 +435,31 @@ int calc_manipulator_stats(const bContext *C) bp++; } } - nu= nu->next; + nu = nu->next; } } } - else if (obedit->type==OB_MBALL) { - MetaBall *mb = (MetaBall*)obedit->data; + else if (obedit->type == OB_MBALL) { + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml /* , *ml_sel=NULL */ /* UNUSED */; - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { if (ml->flag & SELECT) { calc_tw_center(scene, &ml->x); /* ml_sel = ml; */ /* UNUSED */ totsel++; } - ml= ml->next; + ml = ml->next; } } - else if (obedit->type==OB_LATTICE) { + else if (obedit->type == OB_LATTICE) { BPoint *bp; - Lattice *lt= obedit->data; + Lattice *lt = obedit->data; - bp= lt->editlatt->latt->def; + bp = lt->editlatt->latt->def; - a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; while (a--) { if (bp->f1 & SELECT) { calc_tw_center(scene, bp->vec); @@ -471,7 +471,7 @@ int calc_manipulator_stats(const bContext *C) /* selection center */ if (totsel) { - mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! + mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid! mul_m4_v3(obedit->obmat, scene->twcent); mul_m4_v3(obedit->obmat, scene->twmin); mul_m4_v3(obedit->obmat, scene->twmax); @@ -481,17 +481,17 @@ int calc_manipulator_stats(const bContext *C) bPoseChannel *pchan; int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed - if ((ob->lay & v3d->lay)==0) return 0; + if ((ob->lay & v3d->lay) == 0) return 0; totsel = count_set_pose_transflags(&mode, 0, ob); if (totsel) { /* use channels to get stats */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { stats_pose(scene, rv3d, pchan); } - mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! + mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid! mul_m4_v3(ob->obmat, scene->twcent); mul_m4_v3(ob->obmat, scene->twmin); mul_m4_v3(ob->obmat, scene->twmax); @@ -501,17 +501,17 @@ int calc_manipulator_stats(const bContext *C) ; } else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { - PTCacheEdit *edit= PE_get_current(scene, ob); + PTCacheEdit *edit = PE_get_current(scene, ob); PTCacheEditPoint *point; PTCacheEditKey *ek; int k; if (edit) { point = edit->points; - for (a=0; a<edit->totpoint; a++, point++) { + for (a = 0; a < edit->totpoint; a++, point++) { if (point->flag & PEP_HIDE) continue; - for (k=0, ek=point->keys; k<point->totkey; k++, ek++) { + for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) { if (ek->flag & PEK_SELECT) { calc_tw_center(scene, ek->flag & PEK_USE_WCO ? ek->world_co : ek->co); totsel++; @@ -521,19 +521,19 @@ int calc_manipulator_stats(const bContext *C) /* selection center */ if (totsel) - mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! + mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid! } } else { /* we need the one selected object, if its not active */ - ob= OBACT; - if (ob && !(ob->flag & SELECT)) ob= NULL; + ob = OBACT; + if (ob && !(ob->flag & SELECT)) ob = NULL; - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (TESTBASELIB(v3d, base)) { - if (ob==NULL) - ob= base->object; + if (ob == NULL) + ob = base->object; calc_tw_center(scene, base->object->obmat[3]); protectflag_to_drawflags(base->object->protectflag, &rv3d->twdrawflag); totsel++; @@ -542,7 +542,7 @@ int calc_manipulator_stats(const bContext *C) /* selection center */ if (totsel) { - mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! + mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid! } } @@ -551,32 +551,32 @@ int calc_manipulator_stats(const bContext *C) switch (v3d->twmode) { - case V3D_MANIP_GLOBAL: - break; /* nothing to do */ + case V3D_MANIP_GLOBAL: + break; /* nothing to do */ - case V3D_MANIP_GIMBAL: - { - float mat[3][3]; - if (gimbal_axis(ob, mat)) { - copy_m4_m3(rv3d->twmat, mat); - break; - } - /* if not gimbal, fall through to normal */ - } - case V3D_MANIP_NORMAL: - if (obedit || ob->mode & OB_MODE_POSE) { + case V3D_MANIP_GIMBAL: + { float mat[3][3]; - ED_getTransformOrientationMatrix(C, mat, (v3d->around == V3D_ACTIVE)); - copy_m4_m3(rv3d->twmat, mat); - break; + if (gimbal_axis(ob, mat)) { + copy_m4_m3(rv3d->twmat, mat); + break; + } + /* if not gimbal, fall through to normal */ } + case V3D_MANIP_NORMAL: + if (obedit || ob->mode & OB_MODE_POSE) { + float mat[3][3]; + ED_getTransformOrientationMatrix(C, mat, (v3d->around == V3D_ACTIVE)); + copy_m4_m3(rv3d->twmat, mat); + break; + } /* no break we define 'normal' as 'local' in Object mode */ - case V3D_MANIP_LOCAL: - copy_m4_m4(rv3d->twmat, ob->obmat); - normalize_m4(rv3d->twmat); - break; + case V3D_MANIP_LOCAL: + copy_m4_m4(rv3d->twmat, ob->obmat); + normalize_m4(rv3d->twmat); + break; - case V3D_MANIP_VIEW: + case V3D_MANIP_VIEW: { float mat[3][3]; copy_m3_m4(mat, rv3d->viewinv); @@ -584,7 +584,7 @@ int calc_manipulator_stats(const bContext *C) copy_m4_m3(rv3d->twmat, mat); } break; - default: /* V3D_MANIP_CUSTOM */ + default: /* V3D_MANIP_CUSTOM */ { float mat[3][3]; applyTransformOrientation(C, mat, NULL); @@ -601,7 +601,7 @@ int calc_manipulator_stats(const bContext *C) /* don't draw axis perpendicular to the view */ static void test_manipulator_axis(const bContext *C) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); float angle; float vec[3]; @@ -613,7 +613,7 @@ static void test_manipulator_axis(const bContext *C) } angle = rv3d->twangle[0] = RAD2DEGF(angle); if (angle < 5.0f) { - rv3d->twdrawflag &= ~(MAN_TRANS_X|MAN_SCALE_X); + rv3d->twdrawflag &= ~(MAN_TRANS_X | MAN_SCALE_X); } angle = fabs(angle_v3v3(rv3d->twmat[1], vec)); @@ -622,7 +622,7 @@ static void test_manipulator_axis(const bContext *C) } angle = rv3d->twangle[1] = RAD2DEGF(angle); if (angle < 5.0f) { - rv3d->twdrawflag &= ~(MAN_TRANS_Y|MAN_SCALE_Y); + rv3d->twdrawflag &= ~(MAN_TRANS_Y | MAN_SCALE_Y); } angle = fabs(angle_v3v3(rv3d->twmat[2], vec)); @@ -631,7 +631,7 @@ static void test_manipulator_axis(const bContext *C) } angle = rv3d->twangle[2] = RAD2DEGF(angle); if (angle < 5.0f) { - rv3d->twdrawflag &= ~(MAN_TRANS_Z|MAN_SCALE_Z); + rv3d->twdrawflag &= ~(MAN_TRANS_Z | MAN_SCALE_Z); } } @@ -643,7 +643,7 @@ static float screen_aligned(RegionView3D *rv3d, float mat[][4]) glTranslatef(mat[3][0], mat[3][1], mat[3][2]); /* sets view screen aligned */ - glRotatef(-360.0f*saacos(rv3d->viewquat[0])/(float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]); + glRotatef(-360.0f * saacos(rv3d->viewquat[0]) / (float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]); return len_v3(mat[0]); /* draw scale */ } @@ -666,43 +666,43 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i if (start == 0 && end == nrings) do_caps = FALSE; - ring_delta= 2.0f*(float)M_PI/(float)nrings; - side_delta= 2.0f*(float)M_PI/(float)nsides; + ring_delta = 2.0f * (float)M_PI / (float)nrings; + side_delta = 2.0f * (float)M_PI / (float)nsides; - theta= (float)M_PI+0.5f*ring_delta; - cos_theta= (float)cos(theta); - sin_theta= (float)sin(theta); + theta = (float)M_PI + 0.5f * ring_delta; + cos_theta = (float)cos(theta); + sin_theta = (float)sin(theta); - for (i= nrings - 1; i >= 0; i--) { - theta1= theta + ring_delta; - cos_theta1= (float)cos(theta1); - sin_theta1= (float)sin(theta1); + for (i = nrings - 1; i >= 0; i--) { + theta1 = theta + ring_delta; + cos_theta1 = (float)cos(theta1); + sin_theta1 = (float)sin(theta1); - if (do_caps && i==start) { // cap + if (do_caps && i == start) { // cap glBegin(GL_POLYGON); - phi= 0.0; - for (j= nsides; j >= 0; j--) { + phi = 0.0; + for (j = nsides; j >= 0; j--) { float cos_phi, sin_phi, dist; phi += side_delta; - cos_phi= (float)cos(phi); - sin_phi= (float)sin(phi); - dist= radhole + radring * cos_phi; + cos_phi = (float)cos(phi); + sin_phi = (float)sin(phi); + dist = radhole + radring * cos_phi; glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi); } glEnd(); } - if (i>=start && i<=end) { + if (i >= start && i <= end) { glBegin(GL_QUAD_STRIP); - phi= 0.0; - for (j= nsides; j >= 0; j--) { + phi = 0.0; + for (j = nsides; j >= 0; j--) { float cos_phi, sin_phi, dist; phi += side_delta; - cos_phi= (float)cos(phi); - sin_phi= (float)sin(phi); - dist= radhole + radring * cos_phi; + cos_phi = (float)cos(phi); + sin_phi = (float)sin(phi); + dist = radhole + radring * cos_phi; glVertex3f(cos_theta1 * dist, -sin_theta1 * dist, radring * sin_phi); glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi); @@ -710,16 +710,16 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i glEnd(); } - if (do_caps && i==end) { // cap + if (do_caps && i == end) { // cap glBegin(GL_POLYGON); - phi= 0.0; - for (j= nsides; j >= 0; j--) { + phi = 0.0; + for (j = nsides; j >= 0; j--) { float cos_phi, sin_phi, dist; phi -= side_delta; - cos_phi= (float)cos(phi); - sin_phi= (float)sin(phi); - dist= radhole + radring * cos_phi; + cos_phi = (float)cos(phi); + sin_phi = (float)sin(phi); + dist = radhole + radring * cos_phi; glVertex3f(cos_theta * dist, -sin_theta * dist, radring * sin_phi); } @@ -727,9 +727,9 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i } - theta= theta1; - cos_theta= cos_theta1; - sin_theta= sin_theta1; + theta = theta1; + cos_theta = cos_theta1; + sin_theta = sin_theta1; } } @@ -751,43 +751,43 @@ static char axisBlendAngle(float angle) */ static void manipulator_setcolor(View3D *v3d, char axis, int colcode, unsigned char alpha) { - unsigned char col[4]= {0}; - col[3]= alpha; + unsigned char col[4] = {0}; + col[3] = alpha; - if (colcode==MAN_GHOST) { - col[3]= 70; + if (colcode == MAN_GHOST) { + col[3] = 70; } - else if (colcode==MAN_MOVECOL) { + else if (colcode == MAN_MOVECOL) { UI_GetThemeColor3ubv(TH_TRANSFORM, col); } else { switch (axis) { - case 'C': - UI_GetThemeColor3ubv(TH_TRANSFORM, col); - if (v3d->twmode == V3D_MANIP_LOCAL) { - col[0]= col[0]>200?255:col[0]+55; - col[1]= col[1]>200?255:col[1]+55; - col[2]= col[2]>200?255:col[2]+55; - } - else if (v3d->twmode == V3D_MANIP_NORMAL) { - col[0]= col[0]<55?0:col[0]-55; - col[1]= col[1]<55?0:col[1]-55; - col[2]= col[2]<55?0:col[2]-55; - } - break; - case 'X': - col[0]= 220; - break; - case 'Y': - col[1]= 220; - break; - case 'Z': - col[0]= 30; - col[1]= 30; - col[2]= 220; - break; - default: - BLI_assert(!"invalid axis arg"); + case 'C': + UI_GetThemeColor3ubv(TH_TRANSFORM, col); + if (v3d->twmode == V3D_MANIP_LOCAL) { + col[0] = col[0] > 200 ? 255 : col[0] + 55; + col[1] = col[1] > 200 ? 255 : col[1] + 55; + col[2] = col[2] > 200 ? 255 : col[2] + 55; + } + else if (v3d->twmode == V3D_MANIP_NORMAL) { + col[0] = col[0] < 55 ? 0 : col[0] - 55; + col[1] = col[1] < 55 ? 0 : col[1] - 55; + col[2] = col[2] < 55 ? 0 : col[2] - 55; + } + break; + case 'X': + col[0] = 220; + break; + case 'Y': + col[1] = 220; + break; + case 'Z': + col[0] = 30; + col[1] = 30; + col[2] = 220; + break; + default: + BLI_assert(!"invalid axis arg"); } } @@ -836,7 +836,7 @@ static void preOrthoFront(int ortho, float twmat[][4], int axis) orthogonalize_m4(omat, axis); glPushMatrix(); glMultMatrixf(omat); - glFrontFace(is_negative_m4(omat) ? GL_CW:GL_CCW); + glFrontFace(is_negative_m4(omat) ? GL_CW : GL_CCW); } } @@ -853,42 +853,42 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, double plane[4]; float matt[4][4]; float size, unitmat[4][4]; - float cywid= 0.33f*0.01f*(float)U.tw_handlesize; - float cusize= cywid*0.65f; - int arcs= (G.rt!=2); + float cywid = 0.33f * 0.01f * (float)U.tw_handlesize; + float cusize = cywid * 0.65f; + int arcs = (G.rt != 2); int colcode; int ortho; - if (moving) colcode= MAN_MOVECOL; - else colcode= MAN_RGB; + if (moving) colcode = MAN_MOVECOL; + else colcode = MAN_RGB; /* when called while moving in mixed mode, do not draw when... */ - if ((drawflags & MAN_ROT_C)==0) return; + if ((drawflags & MAN_ROT_C) == 0) return; /* Init stuff */ glDisable(GL_DEPTH_TEST); unit_m4(unitmat); - qobj= gluNewQuadric(); + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); /* prepare for screen aligned draw */ - size= len_v3(rv3d->twmat[0]); + size = len_v3(rv3d->twmat[0]); glPushMatrix(); glTranslatef(rv3d->twmat[3][0], rv3d->twmat[3][1], rv3d->twmat[3][2]); if (arcs) { /* clipplane makes nice handles, calc here because of multmatrix but with translate! */ copy_v3db_v3fl(plane, rv3d->viewinv[2]); - plane[3]= -0.02f*size; // clip just a bit more + plane[3] = -0.02f * size; // clip just a bit more glClipPlane(GL_CLIP_PLANE0, plane); } /* sets view screen aligned */ - glRotatef(-360.0f*saacos(rv3d->viewquat[0])/(float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]); + glRotatef(-360.0f * saacos(rv3d->viewquat[0]) / (float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]); /* Screen aligned help circle */ if (arcs) { - if ((G.f & G_PICKSEL)==0) { + if ((G.f & G_PICKSEL) == 0) { UI_ThemeColorShade(TH_BACK, -30); drawcircball(GL_LINE_LOOP, unitmat[3], size, unitmat); } @@ -899,22 +899,22 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, if (G.f & G_PICKSEL) glLoadName(MAN_ROT_T); UI_ThemeColor(TH_TRANSFORM); - drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f*size, unitmat); + drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat); } /* Screen aligned view rot circle */ if (drawflags & MAN_ROT_V) { if (G.f & G_PICKSEL) glLoadName(MAN_ROT_V); UI_ThemeColor(TH_TRANSFORM); - drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f*size, unitmat); + drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f * size, unitmat); if (moving) { float vec[3]; - vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]); - vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]); - vec[2]= 0.0f; + vec[0] = 0; // XXX (float)(t->imval[0] - t->center2d[0]); + vec[1] = 0; // XXX (float)(t->imval[1] - t->center2d[1]); + vec[2] = 0.0f; normalize_v3(vec); - mul_v3_fl(vec, 1.2f*size); + mul_v3_fl(vec, 1.2f * size); glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3fv(vec); @@ -932,22 +932,22 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); if (ortho) { glMultMatrixf(matt); - glFrontFace(is_negative_m4(matt) ? GL_CW:GL_CCW); + glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW); } } else { if (ortho) { - glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW:GL_CCW); + glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW); glMultMatrixf(rv3d->twmat); } } /* axes */ - if (arcs==0) { + if (arcs == 0) { if (!(G.f & G_PICKSEL)) { - if ( (combo & V3D_MANIP_SCALE)==0) { + if ((combo & V3D_MANIP_SCALE) == 0) { /* axis */ - if ( (drawflags & MAN_ROT_X) || (moving && (drawflags & MAN_ROT_Z)) ) { + if ((drawflags & MAN_ROT_X) || (moving && (drawflags & MAN_ROT_Z))) { preOrthoFront(ortho, rv3d->twmat, 2); manipulator_setcolor(v3d, 'X', colcode, 255); glBegin(GL_LINES); @@ -956,7 +956,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glEnd(); postOrtho(ortho); } - if ( (drawflags & MAN_ROT_Y) || (moving && (drawflags & MAN_ROT_X)) ) { + if ((drawflags & MAN_ROT_Y) || (moving && (drawflags & MAN_ROT_X))) { preOrthoFront(ortho, rv3d->twmat, 0); manipulator_setcolor(v3d, 'Y', colcode, 255); glBegin(GL_LINES); @@ -965,7 +965,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glEnd(); postOrtho(ortho); } - if ( (drawflags & MAN_ROT_Z) || (moving && (drawflags & MAN_ROT_Y)) ) { + if ((drawflags & MAN_ROT_Z) || (moving && (drawflags & MAN_ROT_Y))) { preOrthoFront(ortho, rv3d->twmat, 1); manipulator_setcolor(v3d, 'Z', colcode, 255); glBegin(GL_LINES); @@ -978,7 +978,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, } } - if (arcs==0 && moving) { + if (arcs == 0 && moving) { /* Z circle */ if (drawflags & MAN_ROT_Z) { @@ -1020,7 +1020,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, preOrthoFront(ortho, rv3d->twmat, 2); if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); manipulator_setcolor(v3d, 'Z', colcode, 255); - partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48); + partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48); postOrtho(ortho); } /* X circle */ @@ -1029,7 +1029,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X); glRotatef(90.0, 0.0, 1.0, 0.0); manipulator_setcolor(v3d, 'X', colcode, 255); - partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48); + partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48); glRotatef(-90.0, 0.0, 1.0, 0.0); postOrtho(ortho); } @@ -1039,7 +1039,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y); glRotatef(-90.0, 1.0, 0.0, 0.0); manipulator_setcolor(v3d, 'Y', colcode, 255); - partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48); + partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48); glRotatef(90.0, 1.0, 0.0, 0.0); postOrtho(ortho); } @@ -1047,7 +1047,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glDisable(GL_CLIP_PLANE0); } - if (arcs==0) { + if (arcs == 0) { /* Z handle on X axis */ if (drawflags & MAN_ROT_Z) { @@ -1056,7 +1056,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); manipulator_setcolor(v3d, 'Z', colcode, 255); - partial_doughnut(0.7f*cusize, 1.0f, 31, 33, 8, 64); + partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64); glPopMatrix(); postOrtho(ortho); @@ -1071,7 +1071,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glRotatef(90.0, 1.0, 0.0, 0.0); glRotatef(90.0, 0.0, 0.0, 1.0); - partial_doughnut(0.7f*cusize, 1.0f, 31, 33, 8, 64); + partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64); glPopMatrix(); postOrtho(ortho); @@ -1086,7 +1086,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glRotatef(-90.0, 0.0, 1.0, 0.0); glRotatef(90.0, 0.0, 0.0, 1.0); - partial_doughnut(0.7f*cusize, 1.0f, 31, 33, 8, 64); + partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64); glPopMatrix(); postOrtho(ortho); @@ -1104,56 +1104,57 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, static void drawsolidcube(float size) { static float cube[8][3] = { - {-1.0, -1.0, -1.0}, - {-1.0, -1.0, 1.0}, - {-1.0, 1.0, 1.0}, - {-1.0, 1.0, -1.0}, - { 1.0, -1.0, -1.0}, - { 1.0, -1.0, 1.0}, - { 1.0, 1.0, 1.0}, - { 1.0, 1.0, -1.0}, }; + {-1.0, -1.0, -1.0}, + {-1.0, -1.0, 1.0}, + {-1.0, 1.0, 1.0}, + {-1.0, 1.0, -1.0}, + { 1.0, -1.0, -1.0}, + { 1.0, -1.0, 1.0}, + { 1.0, 1.0, 1.0}, + { 1.0, 1.0, -1.0}, + }; float n[3] = {0.0f}; glPushMatrix(); glScalef(size, size, size); glBegin(GL_QUADS); - n[0]= -1.0; + n[0] = -1.0; glNormal3fv(n); glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); - n[0]=0; + n[0] = 0; glEnd(); glBegin(GL_QUADS); - n[1]= -1.0; + n[1] = -1.0; glNormal3fv(n); glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[1]); - n[1]=0; + n[1] = 0; glEnd(); glBegin(GL_QUADS); - n[0]= 1.0; + n[0] = 1.0; glNormal3fv(n); glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[6]); glVertex3fv(cube[5]); - n[0]=0; + n[0] = 0; glEnd(); glBegin(GL_QUADS); - n[1]= 1.0; + n[1] = 1.0; glNormal3fv(n); glVertex3fv(cube[7]); glVertex3fv(cube[3]); glVertex3fv(cube[2]); glVertex3fv(cube[6]); - n[1]=0; + n[1] = 0; glEnd(); glBegin(GL_QUADS); - n[2]= 1.0; + n[2] = 1.0; glNormal3fv(n); glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[2]); - n[2]=0; + n[2] = 0; glEnd(); glBegin(GL_QUADS); - n[2]= -1.0; + n[2] = -1.0; glNormal3fv(n); glVertex3fv(cube[7]); glVertex3fv(cube[4]); glVertex3fv(cube[0]); glVertex3fv(cube[3]); glEnd(); @@ -1164,32 +1165,32 @@ static void drawsolidcube(float size) static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode) { - float cywid= 0.25f*0.01f*(float)U.tw_handlesize; - float cusize= cywid*0.75f, dz; + float cywid = 0.25f * 0.01f * (float)U.tw_handlesize; + float cusize = cywid * 0.75f, dz; /* when called while moving in mixed mode, do not draw when... */ - if ((drawflags & MAN_SCALE_C)==0) return; + if ((drawflags & MAN_SCALE_C) == 0) return; glDisable(GL_DEPTH_TEST); /* not in combo mode */ - if ( (combo & (V3D_MANIP_TRANSLATE|V3D_MANIP_ROTATE))==0) { + if ((combo & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) == 0) { float size, unitmat[4][4]; - int shift= 0; // XXX + int shift = 0; // XXX /* center circle, do not add to selection when shift is pressed (planar constraint) */ - if ( (G.f & G_PICKSEL) && shift==0) glLoadName(MAN_SCALE_C); + if ((G.f & G_PICKSEL) && shift == 0) glLoadName(MAN_SCALE_C); manipulator_setcolor(v3d, 'C', colcode, 255); glPushMatrix(); - size= screen_aligned(rv3d, rv3d->twmat); + size = screen_aligned(rv3d, rv3d->twmat); unit_m4(unitmat); - drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f*size, unitmat); + drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat); glPopMatrix(); - dz= 1.0; + dz = 1.0; } - else dz= 1.0f-4.0f*cusize; + else dz = 1.0f - 4.0f * cusize; if (moving) { float matt[4][4]; @@ -1197,11 +1198,11 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); glMultMatrixf(matt); - glFrontFace(is_negative_m4(matt) ? GL_CW:GL_CCW); + glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW); } else { glMultMatrixf(rv3d->twmat); - glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW:GL_CCW); + glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW); } /* axis */ @@ -1233,7 +1234,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, /* if shiftkey, center point as last, for selectbuffer order */ if (G.f & G_PICKSEL) { - int shift= 0; // XXX + int shift = 0; // XXX if (shift) { glTranslatef(0.0, -dz, 0.0); @@ -1254,55 +1255,55 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, static void draw_cone(GLUquadricObj *qobj, float len, float width) { - glTranslatef(0.0, 0.0, -0.5f*len); + glTranslatef(0.0, 0.0, -0.5f * len); gluCylinder(qobj, width, 0.0, len, 8, 1); gluQuadricOrientation(qobj, GLU_INSIDE); gluDisk(qobj, 0.0, width, 8, 1); gluQuadricOrientation(qobj, GLU_OUTSIDE); - glTranslatef(0.0, 0.0, 0.5f*len); + glTranslatef(0.0, 0.0, 0.5f * len); } static void draw_cylinder(GLUquadricObj *qobj, float len, float width) { - width*= 0.8f; // just for beauty + width *= 0.8f; // just for beauty - glTranslatef(0.0, 0.0, -0.5f*len); + glTranslatef(0.0, 0.0, -0.5f * len); gluCylinder(qobj, width, width, len, 8, 1); gluQuadricOrientation(qobj, GLU_INSIDE); gluDisk(qobj, 0.0, width, 8, 1); gluQuadricOrientation(qobj, GLU_OUTSIDE); glTranslatef(0.0, 0.0, len); gluDisk(qobj, 0.0, width, 8, 1); - glTranslatef(0.0, 0.0, -0.5f*len); + glTranslatef(0.0, 0.0, -0.5f * len); } static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUSED(moving), int drawflags, int combo, int colcode) { GLUquadricObj *qobj; - float cylen= 0.01f*(float)U.tw_handlesize; - float cywid= 0.25f*cylen, dz, size; + float cylen = 0.01f * (float)U.tw_handlesize; + float cywid = 0.25f * cylen, dz, size; float unitmat[4][4]; - int shift= 0; // XXX + int shift = 0; // XXX /* when called while moving in mixed mode, do not draw when... */ - if ((drawflags & MAN_TRANS_C)==0) return; + if ((drawflags & MAN_TRANS_C) == 0) return; // XXX if (moving) glTranslatef(t->vec[0], t->vec[1], t->vec[2]); glDisable(GL_DEPTH_TEST); - qobj= gluNewQuadric(); + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); /* center circle, do not add to selection when shift is pressed (planar constraint) */ - if ( (G.f & G_PICKSEL) && shift==0) glLoadName(MAN_TRANS_C); + if ((G.f & G_PICKSEL) && shift == 0) glLoadName(MAN_TRANS_C); manipulator_setcolor(v3d, 'C', colcode, 255); glPushMatrix(); - size= screen_aligned(rv3d, rv3d->twmat); + size = screen_aligned(rv3d, rv3d->twmat); unit_m4(unitmat); - drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f*size, unitmat); + drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat); glPopMatrix(); /* and now apply matrix, we move to local matrix drawing */ @@ -1312,14 +1313,14 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUS glLoadName(-1); // translate drawn as last, only axis when no combo with scale, or for ghosting - if ((combo & V3D_MANIP_SCALE)==0 || colcode==MAN_GHOST) + if ((combo & V3D_MANIP_SCALE) == 0 || colcode == MAN_GHOST) draw_manipulator_axes(v3d, rv3d, colcode, drawflags & MAN_TRANS_X, drawflags & MAN_TRANS_Y, drawflags & MAN_TRANS_Z); /* offset in combo mode, for rotate a bit more */ - if (combo & (V3D_MANIP_ROTATE)) dz= 1.0f+2.0f*cylen; - else if (combo & (V3D_MANIP_SCALE)) dz= 1.0f+0.5f*cylen; - else dz= 1.0f; + if (combo & (V3D_MANIP_ROTATE)) dz = 1.0f + 2.0f * cylen; + else if (combo & (V3D_MANIP_SCALE)) dz = 1.0f + 0.5f * cylen; + else dz = 1.0f; /* Z Cone */ glTranslatef(0.0, 0.0, dz); @@ -1357,35 +1358,35 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov { GLUquadricObj *qobj; float size; - float cylen= 0.01f*(float)U.tw_handlesize; - float cywid= 0.25f*cylen; + float cylen = 0.01f * (float)U.tw_handlesize; + float cywid = 0.25f * cylen; /* when called while moving in mixed mode, do not draw when... */ - if ((drawflags & MAN_ROT_C)==0) return; + if ((drawflags & MAN_ROT_C) == 0) return; /* prepare for screen aligned draw */ glPushMatrix(); - size= screen_aligned(rv3d, rv3d->twmat); + size = screen_aligned(rv3d, rv3d->twmat); glDisable(GL_DEPTH_TEST); - qobj= gluNewQuadric(); + qobj = gluNewQuadric(); /* Screen aligned view rot circle */ if (drawflags & MAN_ROT_V) { - float unitmat[4][4]= MAT4_UNITY; + float unitmat[4][4] = MAT4_UNITY; if (G.f & G_PICKSEL) glLoadName(MAN_ROT_V); UI_ThemeColor(TH_TRANSFORM); - drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f*size, unitmat); + drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f * size, unitmat); if (moving) { float vec[3]; - vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]); - vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]); - vec[2]= 0.0f; + vec[0] = 0; // XXX (float)(t->imval[0] - t->center2d[0]); + vec[1] = 0; // XXX (float)(t->imval[1] - t->center2d[1]); + vec[2] = 0.0f; normalize_v3(vec); - mul_v3_fl(vec, 1.2f*size); + mul_v3_fl(vec, 1.2f * size); glBegin(GL_LINES); glVertex3f(0.0, 0.0, 0.0); glVertex3fv(vec); @@ -1398,8 +1399,8 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov if (moving) { float matt[4][4]; copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] - // XXX if (t->flag & T_USES_MANIPULATOR) { - // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); + // XXX if (t->flag & T_USES_MANIPULATOR) { + // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); // XXX } glMultMatrixf(matt); } @@ -1407,13 +1408,13 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov glMultMatrixf(rv3d->twmat); } - glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW:GL_CCW); + glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW); /* axis */ - if ( (G.f & G_PICKSEL)==0 ) { + if ((G.f & G_PICKSEL) == 0) { // only draw axis when combo didn't draw scale axes - if ((combo & V3D_MANIP_SCALE)==0) + if ((combo & V3D_MANIP_SCALE) == 0) draw_manipulator_axes(v3d, rv3d, colcode, drawflags & MAN_ROT_X, drawflags & MAN_ROT_Y, drawflags & MAN_ROT_Z); /* only has to be set when not in picking */ @@ -1459,15 +1460,15 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov /* main call, does calc centers & orientation too */ /* uses global G.moving */ -static int drawflags= 0xFFFF; // only for the calls below, belongs in scene...? +static int drawflags = 0xFFFF; // only for the calls below, belongs in scene...? void BIF_draw_manipulator(const bContext *C) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); - View3D *v3d= sa->spacedata.first; - RegionView3D *rv3d= ar->regiondata; + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = sa->spacedata.first; + RegionView3D *rv3d = ar->regiondata; int totsel; if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return; @@ -1477,38 +1478,38 @@ void BIF_draw_manipulator(const bContext *C) { v3d->twflag &= ~V3D_DRAW_MANIPULATOR; - totsel= calc_manipulator_stats(C); - if (totsel==0) return; + totsel = calc_manipulator_stats(C); + if (totsel == 0) return; v3d->twflag |= V3D_DRAW_MANIPULATOR; /* now we can define center */ switch (v3d->around) { - case V3D_CENTER: - case V3D_ACTIVE: - rv3d->twmat[3][0]= (scene->twmin[0] + scene->twmax[0])/2.0f; - rv3d->twmat[3][1]= (scene->twmin[1] + scene->twmax[1])/2.0f; - rv3d->twmat[3][2]= (scene->twmin[2] + scene->twmax[2])/2.0f; - if (v3d->around==V3D_ACTIVE && scene->obedit==NULL) { - Object *ob= OBACT; - if (ob && !(ob->mode & OB_MODE_POSE)) - copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); - } - break; - case V3D_LOCAL: - case V3D_CENTROID: - copy_v3_v3(rv3d->twmat[3], scene->twcent); - break; - case V3D_CURSOR: - copy_v3_v3(rv3d->twmat[3], give_cursor(scene, v3d)); - break; + case V3D_CENTER: + case V3D_ACTIVE: + rv3d->twmat[3][0] = (scene->twmin[0] + scene->twmax[0]) / 2.0f; + rv3d->twmat[3][1] = (scene->twmin[1] + scene->twmax[1]) / 2.0f; + rv3d->twmat[3][2] = (scene->twmin[2] + scene->twmax[2]) / 2.0f; + if (v3d->around == V3D_ACTIVE && scene->obedit == NULL) { + Object *ob = OBACT; + if (ob && !(ob->mode & OB_MODE_POSE)) + copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); + } + break; + case V3D_LOCAL: + case V3D_CENTROID: + copy_v3_v3(rv3d->twmat[3], scene->twcent); + break; + case V3D_CURSOR: + copy_v3_v3(rv3d->twmat[3], give_cursor(scene, v3d)); + break; } mul_mat3_m4_fl(rv3d->twmat, ED_view3d_pixel_size(rv3d, rv3d->twmat[3]) * U.tw_size * 5.0f); } test_manipulator_axis(C); - drawflags= rv3d->twdrawflag; /* set in calc_manipulator_stats */ + drawflags = rv3d->twdrawflag; /* set in calc_manipulator_stats */ if (v3d->twflag & V3D_DRAW_MANIPULATOR) { @@ -1516,7 +1517,7 @@ void BIF_draw_manipulator(const bContext *C) glEnable(GL_BLEND); if (v3d->twtype & V3D_MANIP_ROTATE) { - if (G.rt==3) { + if (G.rt == 3) { if (G.moving) draw_manipulator_rotate_cyl(v3d, rv3d, 1, drawflags, v3d->twtype, MAN_MOVECOL); else draw_manipulator_rotate_cyl(v3d, rv3d, 0, drawflags, v3d->twtype, MAN_RGB); } @@ -1536,31 +1537,31 @@ void BIF_draw_manipulator(const bContext *C) static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], float hotspot) { - View3D *v3d= sa->spacedata.first; - RegionView3D *rv3d= ar->regiondata; + View3D *v3d = sa->spacedata.first; + RegionView3D *rv3d = ar->regiondata; rctf rect; - GLuint buffer[64]; // max 4 items per select, so large enuf + GLuint buffer[64]; // max 4 items per select, so large enuf short hits; extern void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); // XXX check a bit later on this... (ton) G.f |= G_PICKSEL; - rect.xmin = mval[0]-hotspot; - rect.xmax = mval[0]+hotspot; - rect.ymin = mval[1]-hotspot; - rect.ymax = mval[1]+hotspot; + rect.xmin = mval[0] - hotspot; + rect.xmax = mval[0] + hotspot; + rect.ymin = mval[1] - hotspot; + rect.ymax = mval[1] + hotspot; setwinmatrixview3d(ar, v3d, &rect); mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); glSelectBuffer(64, buffer); glRenderMode(GL_SELECT); - glInitNames(); /* these two calls whatfor? It doesnt work otherwise */ + glInitNames(); /* these two calls whatfor? It doesnt work otherwise */ glPushName(-2); /* do the drawing */ if (v3d->twtype & V3D_MANIP_ROTATE) { - if (G.rt==3) draw_manipulator_rotate_cyl(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB); + if (G.rt == 3) draw_manipulator_rotate_cyl(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB); else draw_manipulator_rotate(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype); } if (v3d->twtype & V3D_MANIP_SCALE) @@ -1569,37 +1570,37 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl draw_manipulator_translate(v3d, rv3d, 0, MAN_TRANS_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB); glPopName(); - hits= glRenderMode(GL_RENDER); + hits = glRenderMode(GL_RENDER); G.f &= ~G_PICKSEL; setwinmatrixview3d(ar, v3d, NULL); mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); - if (hits==1) return buffer[3]; - else if (hits>1) { - GLuint val, dep, mindep=0, mindeprot=0, minval=0, minvalrot=0; + if (hits == 1) return buffer[3]; + else if (hits > 1) { + GLuint val, dep, mindep = 0, mindeprot = 0, minval = 0, minvalrot = 0; int a; /* we compare the hits in buffer, but value centers highest */ /* we also store the rotation hits separate (because of arcs) and return hits on other widgets if there are */ - for (a=0; a<hits; a++) { - dep= buffer[4*a + 1]; - val= buffer[4*a + 3]; + for (a = 0; a < hits; a++) { + dep = buffer[4 * a + 1]; + val = buffer[4 * a + 3]; - if (val==MAN_TRANS_C) return MAN_TRANS_C; - else if (val==MAN_SCALE_C) return MAN_SCALE_C; + if (val == MAN_TRANS_C) return MAN_TRANS_C; + else if (val == MAN_SCALE_C) return MAN_SCALE_C; else { if (val & MAN_ROT_C) { - if (minvalrot==0 || dep<mindeprot) { - mindeprot= dep; - minvalrot= val; + if (minvalrot == 0 || dep < mindeprot) { + mindeprot = dep; + minvalrot = val; } } else { - if (minval==0 || dep<mindep) { - mindep= dep; - minval= val; + if (minval == 0 || dep < mindep) { + mindep = dep; + minval = val; } } } @@ -1617,9 +1618,9 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl /* return 0; nothing happened */ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - ARegion *ar= CTX_wm_region(C); + ScrArea *sa = CTX_wm_area(C); + View3D *v3d = sa->spacedata.first; + ARegion *ar = CTX_wm_region(C); int constraint_axis[3] = {0, 0, 0}; int val; int shift = event->shift; @@ -1631,41 +1632,41 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) RNA_enum_set(op->ptr, "constraint_orientation", v3d->twmode); // find the hotspots first test narrow hotspot - val= manipulator_selectbuf(sa, ar, event->mval, 0.5f*(float)U.tw_hotspot); + val = manipulator_selectbuf(sa, ar, event->mval, 0.5f * (float)U.tw_hotspot); if (val) { // drawflags still global, for drawing call above - drawflags= manipulator_selectbuf(sa, ar, event->mval, 0.2f*(float)U.tw_hotspot); - if (drawflags==0) drawflags= val; + drawflags = manipulator_selectbuf(sa, ar, event->mval, 0.2f * (float)U.tw_hotspot); + if (drawflags == 0) drawflags = val; if (drawflags & MAN_TRANS_C) { switch (drawflags) { - case MAN_TRANS_C: - break; - case MAN_TRANS_X: - if (shift) { - constraint_axis[1] = 1; - constraint_axis[2] = 1; - } - else - constraint_axis[0] = 1; - break; - case MAN_TRANS_Y: - if (shift) { - constraint_axis[0] = 1; - constraint_axis[2] = 1; - } - else - constraint_axis[1] = 1; - break; - case MAN_TRANS_Z: - if (shift) { - constraint_axis[0] = 1; - constraint_axis[1] = 1; - } - else - constraint_axis[2] = 1; - break; + case MAN_TRANS_C: + break; + case MAN_TRANS_X: + if (shift) { + constraint_axis[1] = 1; + constraint_axis[2] = 1; + } + else + constraint_axis[0] = 1; + break; + case MAN_TRANS_Y: + if (shift) { + constraint_axis[0] = 1; + constraint_axis[2] = 1; + } + else + constraint_axis[1] = 1; + break; + case MAN_TRANS_Z: + if (shift) { + constraint_axis[0] = 1; + constraint_axis[1] = 1; + } + else + constraint_axis[2] = 1; + break; } RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, op->ptr); @@ -1673,30 +1674,30 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) } else if (drawflags & MAN_SCALE_C) { switch (drawflags) { - case MAN_SCALE_X: - if (shift) { - constraint_axis[1] = 1; - constraint_axis[2] = 1; - } - else - constraint_axis[0] = 1; - break; - case MAN_SCALE_Y: - if (shift) { - constraint_axis[0] = 1; - constraint_axis[2] = 1; - } - else - constraint_axis[1] = 1; - break; - case MAN_SCALE_Z: - if (shift) { - constraint_axis[0] = 1; - constraint_axis[1] = 1; - } - else - constraint_axis[2] = 1; - break; + case MAN_SCALE_X: + if (shift) { + constraint_axis[1] = 1; + constraint_axis[2] = 1; + } + else + constraint_axis[0] = 1; + break; + case MAN_SCALE_Y: + if (shift) { + constraint_axis[0] = 1; + constraint_axis[2] = 1; + } + else + constraint_axis[1] = 1; + break; + case MAN_SCALE_Z: + if (shift) { + constraint_axis[0] = 1; + constraint_axis[1] = 1; + } + else + constraint_axis[2] = 1; + break; } RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); WM_operator_name_call(C, "TRANSFORM_OT_resize", WM_OP_INVOKE_DEFAULT, op->ptr); @@ -1708,15 +1709,15 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) } else if (drawflags & MAN_ROT_C) { switch (drawflags) { - case MAN_ROT_X: - constraint_axis[0] = 1; - break; - case MAN_ROT_Y: - constraint_axis[1] = 1; - break; - case MAN_ROT_Z: - constraint_axis[2] = 1; - break; + case MAN_ROT_X: + constraint_axis[0] = 1; + break; + case MAN_ROT_Y: + constraint_axis[1] = 1; + break; + case MAN_ROT_Z: + constraint_axis[2] = 1; + break; } RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); WM_operator_name_call(C, "TRANSFORM_OT_rotate", WM_OP_INVOKE_DEFAULT, op->ptr); @@ -1724,7 +1725,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) } } /* after transform, restore drawflags */ - drawflags= 0xFFFF; + drawflags = 0xFFFF; return val; } diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 91f62291450..97fc173f9a1 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -75,16 +75,16 @@ void BIF_clearTransformOrientation(bContext *C) // Need to loop over all view3d if (v3d && v3d->twmode >= V3D_MANIP_CUSTOM) { - v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */ + v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */ } } -static TransformOrientation* findOrientationName(ListBase *lb, const char *name) +static TransformOrientation *findOrientationName(ListBase *lb, const char *name) { - TransformOrientation *ts= NULL; + TransformOrientation *ts = NULL; - for (ts= lb->first; ts; ts = ts->next) { - if (strncmp(ts->name, name, sizeof(ts->name)-1) == 0) { + for (ts = lb->first; ts; ts = ts->next) { + if (strncmp(ts->name, name, sizeof(ts->name) - 1) == 0) { return ts; } } @@ -115,7 +115,7 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports, char *name ts = createBoneSpace(C, reports, name, overwrite); } else if (ob && (ob->mode & OB_MODE_POSE)) { - ts = createBoneSpace(C, reports, name, overwrite); + ts = createBoneSpace(C, reports, name, overwrite); } else { ts = createObjectSpace(C, reports, name, overwrite); @@ -143,7 +143,7 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports) /* use object name if no name is given */ if (name[0] == 0) { - strncpy(name, ob->id.name+2, MAX_ID_NAME-2); + strncpy(name, ob->id.name + 2, MAX_ID_NAME - 2); } return addMatrixSpace(C, mat, name, overwrite); @@ -262,7 +262,7 @@ int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3]) return 1; } -TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[], int overwrite) +TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3], char name[], int overwrite) { ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces; TransformOrientation *ts = NULL; @@ -301,7 +301,7 @@ void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target) // Transform_fix_me NEED TO DO THIS FOR ALL VIEW3D if (selected_index == i) { - v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */ + v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */ } else if (selected_index > i) { v3d->twmode--; @@ -318,7 +318,7 @@ void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target) void BIF_removeTransformOrientationIndex(bContext *C, int index) { ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces; - TransformOrientation *ts= BLI_findlink(transform_spaces, index); + TransformOrientation *ts = BLI_findlink(transform_spaces, index); if (ts) { View3D *v3d = CTX_wm_view3d(C); @@ -327,7 +327,7 @@ void BIF_removeTransformOrientationIndex(bContext *C, int index) // Transform_fix_me NEED TO DO THIS FOR ALL VIEW3D if (selected_index == index) { - v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */ + v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */ } else if (selected_index > index) { v3d->twmode--; @@ -365,15 +365,15 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C) { Scene *scene; ListBase *transform_spaces; - TransformOrientation *ts= NULL; + TransformOrientation *ts = NULL; - EnumPropertyItem global = {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""}; + EnumPropertyItem global = {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""}; EnumPropertyItem normal = {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""}; EnumPropertyItem local = {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""}; EnumPropertyItem view = {V3D_MANIP_VIEW, "VIEW", 0, "View", ""}; EnumPropertyItem tmp = {0, "", 0, "", ""}; - EnumPropertyItem *item= NULL; - int i = V3D_MANIP_CUSTOM, totitem= 0; + EnumPropertyItem *item = NULL; + int i = V3D_MANIP_CUSTOM, totitem = 0; RNA_enum_item_add(&item, &totitem, &global); RNA_enum_item_add(&item, &totitem, &normal); @@ -381,7 +381,7 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C) RNA_enum_item_add(&item, &totitem, &view); if (C) { - scene= CTX_data_scene(C); + scene = CTX_data_scene(C); if (scene) { transform_spaces = &scene->transform_spaces; @@ -394,7 +394,7 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C) for (; ts; ts = ts->next) { tmp.identifier = "CUSTOM"; - tmp.name= ts->name; + tmp.name = ts->name; tmp.value = i++; RNA_enum_item_add(&item, &totitem, &tmp); } @@ -404,9 +404,9 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C) return item; } -const char * BIF_menustringTransformOrientation(const bContext *C, const char *title) +const char *BIF_menustringTransformOrientation(const bContext *C, const char *title) { - const char* menu = IFACE_("%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3"); + const char *menu = IFACE_("%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3"); ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces; TransformOrientation *ts; int i = V3D_MANIP_CUSTOM; @@ -459,7 +459,7 @@ void applyTransformOrientation(const bContext *C, float mat[3][3], char *name) break; } } - } + } } static int count_bone_select(bArmature *arm, ListBase *lb, int do_it) @@ -468,7 +468,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it) int do_next; int total = 0; - for (bone= lb->first; bone; bone= bone->next) { + for (bone = lb->first; bone; bone = bone->next) { bone->flag &= ~BONE_TRANSFORM; do_next = do_it; if (do_it) { @@ -476,7 +476,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it) if (bone->flag & BONE_SELECTED) { bone->flag |= BONE_TRANSFORM; total++; - do_next = FALSE; // no transform on children if one parent bone is selected + do_next = FALSE; // no transform on children if one parent bone is selected } } } @@ -493,55 +493,55 @@ void initTransformOrientation(bContext *C, TransInfo *t) Object *obedit = CTX_data_active_object(C); switch (t->current_orientation) { - case V3D_MANIP_GLOBAL: - unit_m3(t->spacemtx); - strcpy(t->spacename, "global"); - break; - - case V3D_MANIP_GIMBAL: - unit_m3(t->spacemtx); - if (gimbal_axis(ob, t->spacemtx)) { - strcpy(t->spacename, "gimbal"); + case V3D_MANIP_GLOBAL: + unit_m3(t->spacemtx); + strcpy(t->spacename, "global"); break; - } + + case V3D_MANIP_GIMBAL: + unit_m3(t->spacemtx); + if (gimbal_axis(ob, t->spacemtx)) { + strcpy(t->spacename, "gimbal"); + break; + } /* no gimbal fallthrough to normal */ - case V3D_MANIP_NORMAL: - if (obedit || (ob && ob->mode & OB_MODE_POSE)) { - strcpy(t->spacename, "normal"); - ED_getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE)); - break; - } + case V3D_MANIP_NORMAL: + if (obedit || (ob && ob->mode & OB_MODE_POSE)) { + strcpy(t->spacename, "normal"); + ED_getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE)); + break; + } /* no break we define 'normal' as 'local' in Object mode */ - case V3D_MANIP_LOCAL: - strcpy(t->spacename, "local"); + case V3D_MANIP_LOCAL: + strcpy(t->spacename, "local"); - if (ob) { - copy_m3_m4(t->spacemtx, ob->obmat); - normalize_m3(t->spacemtx); - } - else { - unit_m3(t->spacemtx); - } + if (ob) { + copy_m3_m4(t->spacemtx, ob->obmat); + normalize_m3(t->spacemtx); + } + else { + unit_m3(t->spacemtx); + } - break; + break; - case V3D_MANIP_VIEW: - if (t->ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d = t->ar->regiondata; - float mat[3][3]; - - strcpy(t->spacename, "view"); - copy_m3_m4(mat, rv3d->viewinv); - normalize_m3(mat); - copy_m3_m3(t->spacemtx, mat); - } - else { - unit_m3(t->spacemtx); - } - break; - default: /* V3D_MANIP_CUSTOM */ - applyTransformOrientation(C, t->spacemtx, t->spacename); - break; + case V3D_MANIP_VIEW: + if (t->ar->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = t->ar->regiondata; + float mat[3][3]; + + strcpy(t->spacename, "view"); + copy_m3_m4(mat, rv3d->viewinv); + normalize_m3(mat); + copy_m3_m3(t->spacemtx, mat); + } + else { + unit_m3(t->spacemtx); + } + break; + default: /* V3D_MANIP_CUSTOM */ + applyTransformOrientation(C, t->spacemtx, t->spacename); + break; } } @@ -549,7 +549,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); Base *base; Object *ob = OBACT; int result = ORIENTATION_NONE; @@ -566,14 +566,14 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], invert_m3_m3(mat, imat); transpose_m3(mat); - ob= obedit; + ob = obedit; - if (ob->type==OB_MESH) { - Mesh *me= ob->data; + if (ob->type == OB_MESH) { + Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; BMVert *eve; BMEditSelection ese; - float vec[3]= {0, 0, 0}; + float vec[3] = {0, 0, 0}; /* USE LAST SELECTED WITH ACTIVE */ if (activeOnly && BM_select_history_active_get(em->bm, &ese)) { @@ -711,17 +711,17 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], } } /* end editmesh */ else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; Nurb *nu; BezTriple *bezt; int a; - ListBase *nurbs= BKE_curve_editNurbs_get(cu); + ListBase *nurbs = BKE_curve_editNurbs_get(cu); for (nu = nurbs->first; nu; nu = nu->next) { /* only bezier has a normal */ if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { /* exception */ if ((bezt->f1 & SELECT) + (bezt->f2 & SELECT) + (bezt->f3 & SELECT) > SELECT) { @@ -747,7 +747,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], result = ORIENTATION_NORMAL; } } - else if (obedit->type==OB_MBALL) { + else if (obedit->type == OB_MBALL) { #if 0 // XXX /* editmball.c */ MetaElem *ml, *ml_sel = NULL; @@ -784,7 +784,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], bArmature *arm = obedit->data; EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (arm->layer & ebone->layer) { if (ebone->flag & BONE_SELECTED) { float tmat[3][3]; @@ -819,7 +819,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], } } else if (ob && (ob->mode & OB_MODE_POSE)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; int totsel; @@ -828,7 +828,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], float imat[3][3], mat[3][3]; /* use channels to get stats */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) { add_v3_v3(normal, pchan->pose_mat[2]); add_v3_v3(plane, pchan->pose_mat[1]); @@ -847,7 +847,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], result = ORIENTATION_EDGE; } } - else if (ob && (ob->mode & (OB_MODE_ALL_PAINT|OB_MODE_PARTICLE_EDIT))) { + else if (ob && (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) { /* pass */ } else { @@ -855,10 +855,10 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], ob = OBACT; if (ob && !(ob->flag & SELECT)) ob = NULL; - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (TESTBASELIB(v3d, base)) { if (ob == NULL) { - ob= base->object; + ob = base->object; break; } } @@ -876,8 +876,8 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[][3], int activeOnly) { - float normal[3]={0.0, 0.0, 0.0}; - float plane[3]={0.0, 0.0, 0.0}; + float normal[3] = {0.0, 0.0, 0.0}; + float plane[3] = {0.0, 0.0, 0.0}; int type; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index a04ce1ca213..9ebd43cd0d1 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -129,13 +129,13 @@ int BIF_snappingSupported(Object *obedit) int validSnap(TransInfo *t) { - return (t->tsnap.status & (POINT_INIT|TARGET_INIT)) == (POINT_INIT|TARGET_INIT) || - (t->tsnap.status & (MULTI_POINTS|TARGET_INIT)) == (MULTI_POINTS|TARGET_INIT); + return (t->tsnap.status & (POINT_INIT | TARGET_INIT)) == (POINT_INIT | TARGET_INIT) || + (t->tsnap.status & (MULTI_POINTS | TARGET_INIT)) == (MULTI_POINTS | TARGET_INIT); } int activeSnap(TransInfo *t) { - return (t->modifiers & (MOD_SNAP|MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP|MOD_SNAP_INVERT)) == MOD_SNAP_INVERT; + return (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT; } void drawSnapping(const struct bContext *C, TransInfo *t) @@ -144,13 +144,13 @@ void drawSnapping(const struct bContext *C, TransInfo *t) unsigned char col[4], selectedCol[4], activeCol[4]; UI_GetThemeColor3ubv(TH_TRANSFORM, col); - col[3]= 128; + col[3] = 128; UI_GetThemeColor3ubv(TH_SELECT, selectedCol); - selectedCol[3]= 128; + selectedCol[3] = 128; UI_GetThemeColor3ubv(TH_ACTIVE, activeCol); - activeCol[3]= 192; + activeCol[3] = 192; if (t->spacetype == SPACE_VIEW3D) { TransSnapPoint *p; @@ -187,31 +187,31 @@ void drawSnapping(const struct bContext *C, TransInfo *t) glColor4ubv(activeCol); glBegin(GL_LINES); - glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]); - glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0], - t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1], - t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]); - glEnd(); + glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]); + glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0], + t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1], + t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]); + glEnd(); } if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } - else if (t->spacetype==SPACE_IMAGE) { + else if (t->spacetype == SPACE_IMAGE) { /* This will not draw, and Im nor sure why - campbell */ #if 0 float xuser_asp, yuser_asp; int wi, hi; float w, h; - calc_image_view(G.sima, 'f'); // float + calc_image_view(G.sima, 'f'); // float myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax); glLoadIdentity(); ED_space_image_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp); ED_space_image_width(t->sa->spacedata.first, &wi, &hi); - w = (((float)wi)/256.0f)*G.sima->zoom * xuser_asp; - h = (((float)hi)/256.0f)*G.sima->zoom * yuser_asp; + w = (((float)wi) / 256.0f) * G.sima->zoom * xuser_asp; + h = (((float)hi) / 256.0f) * G.sima->zoom * yuser_asp; cpack(0xFFFFFF); glTranslatef(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], 0.0f); @@ -220,10 +220,10 @@ void drawSnapping(const struct bContext *C, TransInfo *t) setlinestyle(0); cpack(0x0); - fdrawline(-0.020/w, 0, -0.1/w, 0); - fdrawline(0.1/w, 0, .020/w, 0); - fdrawline(0, -0.020/h, 0, -0.1/h); - fdrawline(0, 0.1/h, 0, 0.020/h); + fdrawline(-0.020 / w, 0, -0.1 / w, 0); + fdrawline(0.1 / w, 0, .020 / w, 0); + fdrawline(0, -0.020 / h, 0, -0.1 / h); + fdrawline(0, 0.1 / h, 0, 0.020 / h); glTranslatef(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f); setlinestyle(0); @@ -261,12 +261,12 @@ void applyProject(TransInfo *t) float imat[4][4]; int i; - if (t->flag & (T_EDIT|T_POSE)) { - Object *ob = t->obedit?t->obedit:t->poseobj; + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; invert_m4_m4(imat, ob->obmat); } - for (i = 0 ; i < t->total; i++, td++) { + for (i = 0; i < t->total; i++, td++) { float iloc[3], loc[3], no[3]; float mval[2]; int dist = 1000; @@ -278,12 +278,12 @@ void applyProject(TransInfo *t) continue; copy_v3_v3(iloc, td->loc); - if (t->flag & (T_EDIT|T_POSE)) { - Object *ob = t->obedit?t->obedit:t->poseobj; + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, iloc); } else if (t->flag & T_OBJECT) { - td->ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + td->ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; BKE_object_handle_update(t->scene, td->ob); copy_v3_v3(iloc, td->ob->obmat[3]); } @@ -387,7 +387,7 @@ static void initSnappingMode(TransInfo *t) /* Edit mode */ if (t->tsnap.applySnap != NULL && // A snapping function actually exist - (obedit != NULL && ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) ) // Temporary limited to edit mode meshes, armature, curves + (obedit != NULL && ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) ) // Temporary limited to edit mode meshes, armature, curves { /* Exclude editmesh if using proportional edit */ if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT)) { @@ -399,13 +399,13 @@ static void initSnappingMode(TransInfo *t) } /* Particles edit mode*/ else if (t->tsnap.applySnap != NULL && // A snapping function actually exist - (obedit == NULL && BASACT && BASACT->object && BASACT->object->mode & OB_MODE_PARTICLE_EDIT )) + (obedit == NULL && BASACT && BASACT->object && BASACT->object->mode & OB_MODE_PARTICLE_EDIT)) { t->tsnap.modeSelect = SNAP_ALL; } /* Object mode */ else if (t->tsnap.applySnap != NULL && // A snapping function actually exist - (obedit == NULL) ) // Object Mode + (obedit == NULL) ) // Object Mode { t->tsnap.modeSelect = SNAP_NOT_SELECTED; } @@ -438,7 +438,7 @@ void initSnapping(TransInfo *t, wmOperator *op) if (RNA_struct_property_is_set(op->ptr, "snap_point")) { RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint); - t->tsnap.status |= SNAP_FORCED|POINT_INIT; + t->tsnap.status |= SNAP_FORCED | POINT_INIT; } /* snap align only defined in specific cases */ @@ -497,33 +497,33 @@ static void setSnappingCallback(TransInfo *t) } switch (t->mode) { - case TFM_TRANSLATION: - t->tsnap.applySnap = ApplySnapTranslation; - t->tsnap.distance = TranslationBetween; - break; - case TFM_ROTATION: - t->tsnap.applySnap = ApplySnapRotation; - t->tsnap.distance = RotationBetween; - - // Can't do TARGET_CENTER with rotation, use TARGET_MEDIAN instead - if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) { - t->tsnap.target = SCE_SNAP_TARGET_MEDIAN; - t->tsnap.targetSnap = TargetSnapMedian; - } - break; - case TFM_RESIZE: - t->tsnap.applySnap = ApplySnapResize; - t->tsnap.distance = ResizeBetween; - - // Can't do TARGET_CENTER with resize, use TARGET_MEDIAN instead - if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) { - t->tsnap.target = SCE_SNAP_TARGET_MEDIAN; - t->tsnap.targetSnap = TargetSnapMedian; - } - break; - default: - t->tsnap.applySnap = NULL; - break; + case TFM_TRANSLATION: + t->tsnap.applySnap = ApplySnapTranslation; + t->tsnap.distance = TranslationBetween; + break; + case TFM_ROTATION: + t->tsnap.applySnap = ApplySnapRotation; + t->tsnap.distance = RotationBetween; + + // Can't do TARGET_CENTER with rotation, use TARGET_MEDIAN instead + if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) { + t->tsnap.target = SCE_SNAP_TARGET_MEDIAN; + t->tsnap.targetSnap = TargetSnapMedian; + } + break; + case TFM_RESIZE: + t->tsnap.applySnap = ApplySnapResize; + t->tsnap.distance = ResizeBetween; + + // Can't do TARGET_CENTER with resize, use TARGET_MEDIAN instead + if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) { + t->tsnap.target = SCE_SNAP_TARGET_MEDIAN; + t->tsnap.targetSnap = TargetSnapMedian; + } + break; + default: + t->tsnap.applySnap = NULL; + break; } } @@ -550,7 +550,7 @@ int updateSelectedSnapPoint(TransInfo *t) int closest_dist = 0; int screen_loc[2]; - for ( p = t->tsnap.points.first; p; p = p->next ) { + for (p = t->tsnap.points.first; p; p = p->next) { int dx, dy; int dist; @@ -663,8 +663,8 @@ static float RotationBetween(TransInfo *t, float p1[3], float p2[3]) float angle, start[3], end[3], center[3]; copy_v3_v3(center, t->center); - if (t->flag & (T_EDIT|T_POSE)) { - Object *ob= t->obedit?t->obedit:t->poseobj; + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, center); } @@ -719,8 +719,8 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]) float d1[3], d2[3], center[3], len_d1; copy_v3_v3(center, t->center); - if (t->flag & (T_EDIT|T_POSE)) { - Object *ob= t->obedit?t->obedit:t->poseobj; + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, center); } @@ -739,7 +739,7 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]) /********************** CALC **************************/ -static void UNUSED_FUNCTION(CalcSnapGrid)(TransInfo *t, float *UNUSED(vec)) +static void UNUSED_FUNCTION(CalcSnapGrid) (TransInfo * t, float *UNUSED(vec)) { snapGridAction(t, t->tsnap.snapPoint, BIG_GEARS); } @@ -830,9 +830,9 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) if (max_dist != FLT_MAX) { copy_v3_v3(loc, p); /* XXX, is there a correct normal in this case ???, for now just z up */ - no[0]= 0.0; - no[1]= 0.0; - no[2]= 1.0; + no[0] = 0.0; + no[1] = 0.0; + no[2] = 1.0; found = 1; } @@ -861,12 +861,12 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) t->tsnap.status &= ~POINT_INIT; } } - else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type==OB_MESH) { + else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type == OB_MESH) { /* same as above but for UV's */ - Image *ima= ED_space_image(t->sa->spacedata.first); + Image *ima = ED_space_image(t->sa->spacedata.first); float aspx, aspy, co[2]; - UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co+1); + UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co + 1); if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) { ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); @@ -888,8 +888,8 @@ static void TargetSnapCenter(TransInfo *t) /* Only need to calculate once */ if ((t->tsnap.status & TARGET_INIT) == 0) { copy_v3_v3(t->tsnap.snapTarget, t->center); - if (t->flag & (T_EDIT|T_POSE)) { - Object *ob= t->obedit?t->obedit:t->poseobj; + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } @@ -905,7 +905,7 @@ static void TargetSnapActive(TransInfo *t) TransData *active_td = NULL; int i; - for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { + for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { if (td->flag & TD_ACTIVE) { active_td = td; break; @@ -915,8 +915,8 @@ static void TargetSnapActive(TransInfo *t) if (active_td) { copy_v3_v3(t->tsnap.snapTarget, active_td->center); - if (t->flag & (T_EDIT|T_POSE)) { - Object *ob= t->obedit?t->obedit:t->poseobj; + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } @@ -942,14 +942,14 @@ static void TargetSnapMedian(TransInfo *t) t->tsnap.snapTarget[1] = 0; t->tsnap.snapTarget[2] = 0; - for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { + for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { add_v3_v3(t->tsnap.snapTarget, td->center); } mul_v3_fl(t->tsnap.snapTarget, 1.0 / i); - if (t->flag & (T_EDIT|T_POSE)) { - Object *ob= t->obedit?t->obedit:t->poseobj; + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } @@ -966,7 +966,7 @@ static void TargetSnapClosest(TransInfo *t) /* Object mode */ if (t->flag & T_OBJECT) { int i; - for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { + for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { struct BoundBox *bb = BKE_object_boundbox_get(td->ob); /* use boundbox if possible */ @@ -1008,14 +1008,14 @@ static void TargetSnapClosest(TransInfo *t) } else { int i; - for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { + for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) { float loc[3]; float dist; copy_v3_v3(loc, td->center); - if (t->flag & (T_EDIT|T_POSE)) { - Object *ob= t->obedit?t->obedit:t->poseobj; + if (t->flag & (T_EDIT | T_POSE)) { + Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, loc); } @@ -1230,10 +1230,10 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm if (arm->edbo) { EditBone *eBone; - for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { if (eBone->layer & arm->layer) { /* skip hidden or moving (selected) bones */ - if ((eBone->flag & (BONE_HIDDEN_A|BONE_ROOTSEL|BONE_TIPSEL))==0) { + if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) { switch (snap_mode) { case SCE_SNAP_MODE_VERTEX: retval |= snapVertex(ar, eBone->head, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth); @@ -1251,10 +1251,10 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm bPoseChannel *pchan; Bone *bone; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - bone= pchan->bone; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + bone = pchan->bone; /* skip hidden bones */ - if (bone && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) { + if (bone && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) { float *head_vec = pchan->pose_head; float *tail_vec = pchan->pose_tail; @@ -1313,22 +1313,22 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh switch (snap_mode) { case SCE_SNAP_MODE_FACE: { -#ifdef USE_BVH_FACE_SNAP // Added for durian +#ifdef USE_BVH_FACE_SNAP // Added for durian BVHTreeRayHit hit; BVHTreeFromMesh treeData; /* local scale in normal direction */ float local_scale = len_v3(ray_normal_local); - treeData.em_evil= em; + treeData.em_evil = em; bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6); hit.index = -1; hit.dist = *r_depth * (*r_depth == FLT_MAX ? 1.0f : local_scale); if (treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) { - if (hit.dist/local_scale <= *r_depth) { - *r_depth= hit.dist/local_scale; + if (hit.dist / local_scale <= *r_depth) { + *r_depth = hit.dist / local_scale; copy_v3_v3(r_loc, hit.co); copy_v3_v3(r_no, hit.no); @@ -1356,7 +1356,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh EDBM_index_arrays_init(em, 0, 0, 1); } - for ( i = 0; i < totface; i++) { + for (i = 0; i < totface; i++) { BMFace *efa = NULL; MFace *f = faces + i; @@ -1384,7 +1384,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh BMLoop *l; l = BM_iter_new(&iter, em->bm, BM_LOOPS_OF_FACE, efa); - for ( ; l; l=BM_iter_step(&iter)) { + for (; l; l = BM_iter_step(&iter)) { if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) { test = 0; break; @@ -1430,7 +1430,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh EDBM_index_arrays_init(em, 1, 0, 0); } - for ( i = 0; i < totvert; i++) { + for (i = 0; i < totvert; i++) { BMVert *eve = NULL; MVert *v = verts + i; @@ -1481,7 +1481,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh EDBM_index_arrays_init(em, 0, 1, 0); } - for ( i = 0; i < totedge; i++) { + for (i = 0; i < totedge; i++) { BMEdge *eed = NULL; MEdge *e = edges + i; @@ -1502,8 +1502,8 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh eed = EDBM_edge_at_index(em, index); if (eed && (BM_elem_flag_test(eed, BM_ELEM_HIDDEN) || - BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || - BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))) + BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || + BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))) { test = 0; } @@ -1531,7 +1531,7 @@ static int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, flo const float ray_start[3], const float ray_normal[3], const float mval[2], float r_loc[3], float r_no[3], int *r_dist, float *r_depth) { - ToolSettings *ts= scene->toolsettings; + ToolSettings *ts = scene->toolsettings; int retval = 0; if (ob->type == OB_MESH) { @@ -1580,18 +1580,18 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, c * * To solve that problem, we do it first as an exception. * */ - base= BASACT; + base = BASACT; if (base && base->object && base->object->mode & OB_MODE_PARTICLE_EDIT) { Object *ob = base->object; retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth); } - for ( base = FIRSTBASE; base != NULL; base = base->next ) { - if ( (BASE_VISIBLE(v3d, base)) && - (base->flag & (BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA)) == 0 && + for (base = FIRSTBASE; base != NULL; base = base->next) { + if ((BASE_VISIBLE(v3d, base)) && + (base->flag & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 && - ( (mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) || - (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)) ) + ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) || + (ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT))) { Object *ob = base->object; @@ -1719,7 +1719,7 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], MFace *faces = dm->getTessFaceArray(dm); int i; - for ( i = 0; i < totface; i++) { + for (i = 0; i < totface; i++) { MFace *f = faces + i; float lambda; int result; @@ -1837,7 +1837,7 @@ static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, L if (ob->type == OB_MESH) { int val = 0; - if (ob != obedit && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) || ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT))) { + if (ob != obedit && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) || ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT))) { DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); val = peelDerivedMesh(ob, dm, ob->obmat, ray_start, ray_normal, mval, depth_peels); @@ -1918,7 +1918,7 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea if (max_index > 2) { printf("applyGrid: invalid index %d, clamping\n", max_index); - max_index= 2; + max_index = 2; } // Early bailing out if no need to snap @@ -1926,11 +1926,11 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea return; /* evil hack - snapping needs to be adapted for image aspect ratio */ - if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) { - ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp+1); + if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) { + ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp + 1); } - for (i=0; i<=max_index; i++) { - val[i]= fac[action]*asp[i]*(float)floor(val[i]/(fac[action]*asp[i]) +0.5f); + for (i = 0; i <= max_index; i++) { + val[i] = fac[action] * asp[i] * (float)floor(val[i] / (fac[action] * asp[i]) + 0.5f); } } diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 4c0e96426e7..16cd95a2f70 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -3596,7 +3596,7 @@ typedef struct SmoothNode { int axis, ntri; } SmoothNode; -static void p_barycentric_2d(const float v1[2], const float v2[2], const float v3[2], float p[2], float b[2]) +static void p_barycentric_2d(const float v1[2], const float v2[2], const float v3[2], const float p[2], float b[3]) { float a[2], c[2], h[2], div; @@ -3624,7 +3624,7 @@ static void p_barycentric_2d(const float v1[2], const float v2[2], const float v } } -static PBool p_triangle_inside(SmoothTriangle *t, float *co) +static PBool p_triangle_inside(SmoothTriangle *t, float co[2]) { float b[3]; @@ -3706,7 +3706,7 @@ static void p_node_delete(SmoothNode *node) MEM_freeN(node->tri); } -static PBool p_node_intersect(SmoothNode *node, float *co) +static PBool p_node_intersect(SmoothNode *node, float co[2]) { int i; @@ -3726,7 +3726,7 @@ static PBool p_node_intersect(SmoothNode *node, float *co) } -/* smooothing */ +/* smoothing */ static int p_compare_float(const void *a, const void *b) { diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 0b5b2177342..cb905d7f768 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -491,7 +491,7 @@ typedef enum eSpaceSeq_Flag { SEQ_MARKER_TRANS = (1 << 1), SEQ_DRAW_COLOR_SEPARATED = (1 << 2), SEQ_DRAW_SAFE_MARGINS = (1 << 3), - SEQ_DRAW_GPENCIL = (1 << 4), /* DEPRECATED */ +/* SEQ_DRAW_GPENCIL = (1 << 4), */ /* DEPRECATED */ SEQ_NO_DRAW_CFRANUM = (1 << 5), } eSpaceSeq_Flag; @@ -746,7 +746,7 @@ typedef enum eSpaceImage_Flag { SI_DRAW_TILE = (1 << 19), SI_SMOOTH_UV = (1 << 20), SI_DRAW_STRETCH = (1 << 21), - SI_DISPGP = (1 << 22), /* DEPRECATED */ +/* SI_DISPGP = (1 << 22), */ /* DEPRECATED */ SI_DRAW_OTHER = (1 << 23), SI_COLOR_CORRECTION = (1 << 24), @@ -876,7 +876,7 @@ typedef struct SpaceNode { /* snode->flag */ typedef enum eSpaceNode_Flag { SNODE_BACKDRAW = (1 << 1), - SNODE_DISPGP = (1 << 2), /* XXX: Grease Pencil - deprecated? */ +/* SNODE_DISPGP = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */ SNODE_USE_ALPHA = (1 << 3), SNODE_SHOW_ALPHA = (1 << 4), SNODE_AUTO_RENDER = (1 << 5), diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 3d01f5ba082..81538d20a50 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1969,12 +1969,7 @@ static void rna_def_space_image(BlenderRNA *brna) RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); - - prop = RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DISPGP); - RNA_def_property_ui_text(prop, "Use Grease Pencil", - "Display and edit the grease pencil freehand annotations overlay"); - + /* update */ prop = RNA_def_property(srna, "use_realtime_update", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "lock", 0); @@ -2050,7 +2045,7 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Display Mode", "View mode to use for displaying sequencer output"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - /* flag's */ + /* flags */ prop = RNA_def_property(srna, "show_frame_indicator", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_NO_DRAW_CFRANUM); RNA_def_property_ui_text(prop, "Show Frame Number Indicator", @@ -2077,23 +2072,10 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Safe Margin", "Draw title safe margins in preview"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - prop = RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_DRAW_GPENCIL); - RNA_def_property_ui_text(prop, "Use Grease Pencil", - "Display and edit the grease pencil freehand annotations overlay"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_DRAWFRAMES); RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - - /* grease pencil */ - prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "gpd"); - RNA_def_property_struct_type(prop, "UnknownType"); - RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); prop = RNA_def_property(srna, "display_channel", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "chanshown"); @@ -2114,6 +2096,14 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Proxy render size", "Draw preview using full resolution or different proxy resolutions"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + + /* grease pencil */ + prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "gpd"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); } static void rna_def_space_text(BlenderRNA *brna) |