diff options
author | Joseph Eagar <joeedh@gmail.com> | 2011-04-15 05:19:13 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2011-04-15 05:19:13 +0400 |
commit | c98148a963d37fc2f25e125afeb4cf21df6fbf14 (patch) | |
tree | 691a051e27f08e35bf09d35b6fb9c88e4c37b8d2 /source/blender/editors/transform | |
parent | 0bba684d08952d0be822f3906ffb2a03b2674cc2 (diff) | |
parent | fa63c297753636c149fbb1a3877d9b3d93601357 (diff) |
=bmesh= merge from trunk at r36153
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 143 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 5 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 19 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 492 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 11 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_input.c | 12 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_manipulator.c | 40 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ndofinput.c | 5 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 106 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 5 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 23 |
12 files changed, 421 insertions, 441 deletions
diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index f31d7ba6449..05f46edb7a4 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -29,6 +29,7 @@ set(INC ../../makesrna ../../windowmanager ../../../../intern/guardedalloc + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 4a920e15e34..363421b0ca3 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/transform/transform.c + * \ingroup edtransform + */ + + #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -49,22 +54,10 @@ #include "RNA_access.h" -//#include "BIF_editview.h" /* arrows_move_cursor */ #include "BIF_gl.h" #include "BIF_glutil.h" -//#include "BIF_mywindow.h" -//#include "BIF_resources.h" -//#include "BIF_screen.h" -//#include "BIF_space.h" /* undo */ -//#include "BIF_toets.h" /* persptoetsen */ -//#include "BIF_mywindow.h" /* warp_pointer */ -//#include "BIF_toolbox.h" /* notice */ -//#include "BIF_editmesh.h" -//#include "BIF_editsima.h" -//#include "BIF_editparticle.h" #include "BKE_nla.h" -//#include "BKE_bad_level_calls.h"/* popmenu and error */ #include "BKE_bmesh.h" #include "BKE_context.h" #include "BKE_constraint.h" @@ -73,8 +66,6 @@ #include "BKE_pointcache.h" #include "BKE_unit.h" -//#include "BSE_view.h" - #include "ED_image.h" #include "ED_keyframing.h" #include "ED_screen.h" @@ -550,9 +541,6 @@ wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, 0, 0, TFM_MODAL_ADD_SNAP); WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, KM_ALT, 0, TFM_MODAL_REMOVE_SNAP); - WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_UP); - WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_PRESS, 0, 0, NUM_MODAL_INCREMENT_DOWN); - WM_modalkeymap_add_item(keymap, PAGEUPKEY, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_UP); WM_modalkeymap_add_item(keymap, PAGEDOWNKEY, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_DOWN); WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, 0, 0, TFM_MODAL_PROPSIZE_UP); @@ -1069,7 +1057,6 @@ int transformEvent(TransInfo *t, wmEvent *event) // Snapping events t->redraw |= handleSnapping(t, event); - //arrows_move_cursor(event->type); } else if (event->val==KM_RELEASE) { switch (event->type){ @@ -1242,6 +1229,15 @@ static void drawArc(float size, float angle_start, float angle_end, int segments glEnd(); } +static int helpline_poll(bContext *C) +{ + ARegion *ar= CTX_wm_region(C); + + if(ar && ar->regiontype==RGN_TYPE_WINDOW) + return 1; + return 0; +} + static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) { TransInfo *t = (TransInfo*)customdata; @@ -1280,7 +1276,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) glEnd(); glTranslatef(mval[0], mval[1], 0); - glRotatef(-180 / M_PI * atan2f(cent[0] - t->mval[0], cent[1] - t->mval[1]), 0, 0, 1); + glRotatef(-RAD2DEGF(atan2f(cent[0] - t->mval[0], cent[1] - t->mval[1])), 0, 0, 1); setlinestyle(0); glLineWidth(3.0); @@ -1314,8 +1310,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1]; float angle = atan2f(dy, dx); float dist = sqrtf(dx*dx + dy*dy); - float delta_angle = MIN2(15 / dist, M_PI/4); - float spacing_angle = MIN2(5 / dist, M_PI/12); + float delta_angle = MIN2(15.0f / dist, (float)M_PI/4.0f); + float spacing_angle = MIN2(5.0f / dist, (float)M_PI/12.0f); UI_ThemeColor(TH_WIRE); setlinestyle(3); @@ -1334,14 +1330,14 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) glPushMatrix(); glTranslatef(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0); - glRotatef(180 / M_PI * (angle - delta_angle), 0, 0, 1); + glRotatef(RAD2DEGF(angle - delta_angle), 0, 0, 1); drawArrowHead(DOWN, 5); glPopMatrix(); glTranslatef(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0); - glRotatef(180 / M_PI * (angle + delta_angle), 0, 0, 1); + glRotatef(RAD2DEGF(angle + delta_angle), 0, 0, 1); drawArrowHead(UP, 5); @@ -1556,7 +1552,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); - t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), NULL, drawHelpline, t); + t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); } else if(t->spacetype == SPACE_IMAGE) { unit_m3(t->spacemtx); @@ -1658,11 +1654,6 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int break; case TFM_EDGE_SLIDE: initEdgeSlide(t); - if(t->state == TRANS_CANCEL) - { - postTrans(C, t); - return 0; - } break; case TFM_BONE_ROLL: initBoneRoll(t); @@ -1676,6 +1667,16 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int case TFM_TIME_SCALE: initTimeScale(t); break; + case TFM_TIME_DUPLICATE: + /* same as TFM_TIME_EXTEND, but we need the mode info for later + * so that duplicate-culling will work properly + */ + if ELEM(t->spacetype, SPACE_IPO, SPACE_NLA) + initTranslation(t); + else + initTimeTranslate(t); + t->mode = mode; + break; case TFM_TIME_EXTEND: /* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION @@ -1707,6 +1708,13 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int break; } + if(t->state == TRANS_CANCEL) + { + postTrans(C, t); + return 0; + } + + /* overwrite initial values if operator supplied a non-null vector */ if (RNA_property_is_set(op->ptr, "value")) { @@ -1917,7 +1925,7 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl eulO_to_axis_angle( axis, angle,eul, EULER_ORDER_DEFAULT); /* when converting to axis-angle, we need a special exception for the case when there is no axis */ - if (IS_EQ(axis[0], axis[1]) && IS_EQ(axis[1], axis[2])) { + if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) { /* for now, rotate around y-axis then (so that it simply becomes the roll) */ axis[1]= 1.0f; } @@ -1978,7 +1986,7 @@ static void constraintTransLim(TransInfo *UNUSED(t), TransData *td) { if (td->con) { bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT); - bConstraintOb cob= {0}; + bConstraintOb cob= {NULL}; bConstraint *con; /* Make a temporary bConstraintOb for using these limit constraints @@ -2134,7 +2142,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td) { if (td->con && td->ext) { bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_SIZELIMIT); - bConstraintOb cob= {0}; + bConstraintOb cob= {NULL}; bConstraint *con; /* Make a temporary bConstraintOb for using these limit constraints @@ -2233,8 +2241,8 @@ void initWarp(TransInfo *t) t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; - t->snap[1] = 5.0f / 180 * M_PI; - t->snap[2] = 1.0f / 180 * M_PI; + t->snap[1] = 5.0f / 180.0f * (float)M_PI; + t->snap[2] = 1.0f / 180.0f * (float)M_PI; t->num.increment = 1.0f; @@ -2257,7 +2265,7 @@ void initWarp(TransInfo *t) mid_v3_v3v3(t->center, min, max); - if (max[0] == min[0]) max[0] += 0.1; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */ + if (max[0] == min[0]) max[0] += 0.1f; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */ t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */ } @@ -2268,10 +2276,10 @@ int handleEventWarp(TransInfo *t, wmEvent *event) if (event->type == MIDDLEMOUSE && event->val==KM_PRESS) { // Use customData pointer to signal warp direction - if (t->customData == 0) + if (t->customData == NULL) t->customData = (void*)1; else - t->customData = 0; + t->customData = NULL; status = 1; } @@ -2321,11 +2329,11 @@ int Warp(TransInfo *t, short UNUSED(mval[2])) sprintf(str, "Warp: %s", c); - circumfac = circumfac / 180 * M_PI; + circumfac = DEG2RADF(circumfac); } else { /* default header print */ - sprintf(str, "Warp: %.3f", circumfac * 180 / M_PI); + sprintf(str, "Warp: %.3f", RAD2DEGF(circumfac)); } t->values[0] = circumfac; @@ -2409,7 +2417,7 @@ int handleEventShear(TransInfo *t, wmEvent *event) if (event->type == MIDDLEMOUSE && event->val==KM_PRESS) { // Use customData pointer to signal Shear direction - if (t->customData == 0) + if (t->customData == NULL) { initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE); t->customData = (void*)1; @@ -2417,7 +2425,7 @@ int handleEventShear(TransInfo *t, wmEvent *event) else { initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE); - t->customData = 0; + t->customData = NULL; } status = 1; @@ -2461,7 +2469,7 @@ int Shear(TransInfo *t, short UNUSED(mval[2])) unit_m3(smat); // Custom data signals shear direction - if (t->customData == 0) + if (t->customData == NULL) smat[1][0] = value; else smat[0][1] = value; @@ -3174,18 +3182,12 @@ int Rotation(TransInfo *t, short UNUSED(mval[2])) outputNumInput(&(t->num), c); sprintf(str, "Rot: %s %s %s", &c[0], t->con.text, t->proptext); - + /* Clamp between -180 and 180 */ - while (final >= 180.0) - final -= 360.0; - - while (final <= -180.0) - final += 360.0; - - final *= (float)(M_PI / 180.0); + final= angle_wrap_rad(DEG2RADF(final)); } else { - sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext); + sprintf(str, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext); } if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) @@ -3285,11 +3287,11 @@ int Trackball(TransInfo *t, short UNUSED(mval[2])) sprintf(str, "Trackball: %s %s %s", &c[0], &c[20], t->proptext); - phi[0] *= (float)(M_PI / 180.0); - phi[1] *= (float)(M_PI / 180.0); + phi[0] = DEG2RADF(phi[0]); + phi[1] = DEG2RADF(phi[1]); } else { - sprintf(str, "Trackball: %.2f %.2f %s", 180.0*phi[0]/M_PI, 180.0*phi[1]/M_PI, t->proptext); + sprintf(str, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext); } vec_rot_to_mat3( smat,axis1, phi[0]); @@ -3378,7 +3380,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { if(!(t->flag & T_2D_EDIT) && t->scene->unit.system) bUnit_AsString(distvec, sizeof(distvec), dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0); - else if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ + else if( dist > 1e10f || dist < -1e10f ) /* prevent string buffer overflow */ sprintf(distvec, "%.4e", dist); else sprintf(distvec, "%.4f", dist); @@ -3645,10 +3647,10 @@ int Tilt(TransInfo *t, short UNUSED(mval[2])) sprintf(str, "Tilt: %s %s", &c[0], t->proptext); - final *= (float)(M_PI / 180.0); + final = DEG2RADF(final); } else { - sprintf(str, "Tilt: %.2f %s", 180.0*final/M_PI, t->proptext); + sprintf(str, "Tilt: %.2f %s", RAD2DEGF(final), t->proptext); } for(i = 0 ; i < t->total; i++, td++) { @@ -4361,7 +4363,7 @@ static int createSlideVerts(TransInfo *t) BMBVHTree *btree = BMBVH_NewBVH(em); SmallHash table; SlideData *sld = MEM_callocN(sizeof(*sld), "sld"); - RegionView3D *v3d = t->ar->regiondata; + RegionView3D *v3d = t->ar ? t->ar->regiondata : NULL; /* background mode support */ ARegion *ar = t->ar; float projectMat[4][4]; float start[3] = {0.0f, 0.0f, 0.0f}, dir[3], end[3] = {0.0f, 0.0f, 0.0f}; @@ -4914,10 +4916,10 @@ int BoneRoll(TransInfo *t, short UNUSED(mval[2])) sprintf(str, "Roll: %s", &c[0]); - final *= (float)(M_PI / 180.0); + final = DEG2RADF(final); } else { - sprintf(str, "Roll: %.2f", 180.0*final/M_PI); + sprintf(str, "Roll: %.2f", RAD2DEGF(final)); } /* set roll values */ @@ -5225,8 +5227,8 @@ int SeqSlide(TransInfo *t, short UNUSED(mval[2])) applyNumInput(&t->num, t->values); } - t->values[0] = floor(t->values[0] + 0.5); - t->values[1] = floor(t->values[1] + 0.5); + t->values[0] = floor(t->values[0] + 0.5f); + t->values[1] = floor(t->values[1] + 0.5f); headerSeqSlide(t, t->values, str); applySeqSlide(t, t->values); @@ -5384,6 +5386,11 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, void initTimeTranslate(TransInfo *t) { + /* this tool is only really available in the Action Editor... */ + if (t->spacetype != SPACE_ACTION) { + t->state = TRANS_CANCEL; + } + t->mode = TFM_TIME_TRANSLATE; t->transform = TimeTranslate; @@ -5532,8 +5539,11 @@ void initTimeSlide(TransInfo *t) /* set flag for drawing stuff */ saction->flag |= SACTION_MOVING; + } else { + t->state = TRANS_CANCEL; } + t->mode = TFM_TIME_SLIDE; t->transform = TimeSlide; t->flag |= T_FREE_CUSTOMDATA; @@ -5640,7 +5650,7 @@ int TimeSlide(TransInfo *t, short mval[2]) /* handle numeric-input stuff */ t->vec[0] = 2.0f*(cval[0]-sval[0]) / (maxx-minx); applyNumInput(&t->num, &t->vec[0]); - t->values[0] = (maxx-minx) * t->vec[0] / 2.0 + sval[0]; + t->values[0] = (maxx-minx) * t->vec[0] / 2.0f + sval[0]; headerTimeSlide(t, sval[0], str); applyTimeSlide(t, sval[0]); @@ -5658,6 +5668,13 @@ void initTimeScale(TransInfo *t) { int center[2]; + /* this tool is only really available in the Action Editor + * AND NLA Editor (for strip scaling) + */ + if (ELEM(t->spacetype, SPACE_ACTION, SPACE_NLA) == 0) { + t->state = TRANS_CANCEL; + } + t->mode = TFM_TIME_SCALE; t->transform = TimeScale; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 9c9400d034e..76569a86e11 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/transform/transform.h + * \ingroup edtransform + */ + + #ifndef TRANSFORM_H #define TRANSFORM_H diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 4427e472412..0ef8633e6e3 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/transform/transform_constraints.c + * \ingroup edtransform + */ + + #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -186,11 +191,11 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 if(in[0]==0.0f && in[1]==0.0f && in[2]==0.0f) return; - angle = fabs(angle_v3v3(axis, t->viewinv[2])); - if (angle > M_PI / 2) { - angle = M_PI - angle; + angle = fabsf(angle_v3v3(axis, t->viewinv[2])); + if (angle > (float)M_PI / 2.0f) { + angle = (float)M_PI - angle; } - angle = 180.0f * angle / M_PI; + angle = RAD2DEGF(angle); /* For when view is parallel to constraint... will cause NaNs otherwise So we take vertical motion in 3D space and apply it to the @@ -223,12 +228,12 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 /* give arbitrary large value if projection is impossible */ factor = dot_v3v3(axis, norm); - if (1 - fabs(factor) < 0.0002f) { + if (1.0f - fabsf(factor) < 0.0002f) { VECCOPY(out, axis); if (factor > 0) { - mul_v3_fl(out, 1000000000); + mul_v3_fl(out, 1000000000.0f); } else { - mul_v3_fl(out, -1000000000); + mul_v3_fl(out, -1000000000.0f); } } else { add_v3_v3v3(v2, t->con.center, axis); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 3b3a5a6877e..2b308ffeb70 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/transform/transform_conversions.c + * \ingroup edtransform + */ + + #ifndef WIN32 #include <unistd.h> #else @@ -95,6 +100,7 @@ #include "BLI_editVert.h" #include "BLI_array.h" #include "BLI_utildefines.h" +#include "BLI_smallhash.h" #include "RNA_access.h" @@ -359,7 +365,7 @@ static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan) bConstraint *con= pchan->constraints.first; for(;con; con= con->next) { - if(con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0)) { + if(con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) { bKinematicConstraint *data= con->data; if(data->tar==NULL) @@ -760,7 +766,7 @@ static void pchan_autoik_adjust (bPoseChannel *pchan, short chainlen) /* check if pchan has ik-constraint */ for (con= pchan->constraints.first; con; con= con->next) { - if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0)) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) { bKinematicConstraint *data= con->data; /* only accept if a temporary one (for auto-ik) */ @@ -1745,10 +1751,10 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) td->ival = *(key->time); /* abuse size and quat for min/max values */ td->flag |= TD_NO_EXT; - if(k==0) tx->size = 0; + if(k==0) tx->size = NULL; else tx->size = (key - 1)->time; - if(k == point->totkey - 1) tx->quat = 0; + if(k == point->totkey - 1) tx->quat = NULL; else tx->quat = (key + 1)->time; } @@ -1812,94 +1818,76 @@ void flushTransParticles(TransInfo *t) /* proportional distance based on connectivity */ #define THRESHOLD 0.0001f -static int connectivity_edge(float mtx[][3], EditVert *v1, EditVert *v2) +/*I did this wrong, it should be a breadth-first search + but instead it's a depth-first search, fudged + to report shortest distances. I have no idea how fast + or slow this is.*/ +static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], float *dists) { - float edge_vec[3]; - float edge_len; - int done = 0; - - /* note: hidden verts are not being checked for, this assumes - * flushing of hidden faces & edges is working right */ + BMVert **stack = NULL; + float *dstack = NULL; + BLI_array_declare(stack); + BLI_array_declare(dstack); + SmallHash svisit, *visit=&svisit; + BMVert *v; + BMIter viter; + int i; - if (v1->f2 + v2->f2 == 4) - return 0; + BLI_smallhash_init(visit); - sub_v3_v3v3(edge_vec, v1->co, v2->co); - mul_m3_v3(mtx, edge_vec); - - edge_len = len_v3(edge_vec); - - if (v1->f2) { - if (v2->f2) { - if (v2->tmp.fp + edge_len + THRESHOLD < v1->tmp.fp) { - v1->tmp.fp = v2->tmp.fp + edge_len; - done = 1; - } else if (v1->tmp.fp + edge_len + THRESHOLD < v2->tmp.fp) { - v2->tmp.fp = v1->tmp.fp + edge_len; - done = 1; - } - } - else { - v2->f2 = 1; - v2->tmp.fp = v1->tmp.fp + edge_len; - done = 1; - } - } - else if (v2->f2) { - v1->f2 = 1; - v1->tmp.fp = v2->tmp.fp + edge_len; - done = 1; - } - - return done; -} - -static void editmesh_set_connectivity_distance(EditMesh *em, float mtx[][3]) -{ - EditVert *eve; - EditEdge *eed; - EditFace *efa; - int done= 1; - - /* f2 flag is used for 'selection' */ - /* tmp.l is offset on scratch array */ - for(eve= em->verts.first; eve; eve= eve->next) { - if(eve->h==0) { - eve->tmp.fp = 0; - - if(eve->f & SELECT) { - eve->f2= 2; - } - else { - eve->f2 = 0; - } - } + i = 0; + BM_ITER(v, &viter, em->bm, BM_VERTS_OF_MESH, NULL) { + BMINDEX_SET(v, i); + dists[i] = FLT_MAX; + i++; } - - - /* Floodfill routine */ - /* - At worst this is n*n of complexity where n is number of edges - Best case would be n if the list is ordered perfectly. - Estimate is n log n in average (so not too bad) - */ - while(done) { - done= 0; - - for(eed= em->edges.first; eed; eed= eed->next) { - if(eed->h==0) { - done |= connectivity_edge(mtx, eed->v1, eed->v2); - } - } - - /* do internal edges for quads */ - for(efa= em->faces.first; efa; efa= efa->next) { - if (efa->v4 && efa->h==0) { - done |= connectivity_edge(mtx, efa->v1, efa->v3); - done |= connectivity_edge(mtx, efa->v2, efa->v4); + + BM_ITER(v, &viter, em->bm, BM_VERTS_OF_MESH, NULL) { + BMVert *v2; + + if (BLI_smallhash_haskey(visit, (uintptr_t)v) || BM_TestHFlag(v, BM_SELECT)==0 || BM_TestHFlag(v, BM_HIDDEN)) + continue; + + BLI_array_empty(stack); + BLI_array_append(stack, v); + BLI_smallhash_insert(visit, (uintptr_t)v, NULL); + BLI_array_append(dstack, 0.0f); + + while (BLI_array_count(stack)) { + BMIter eiter; + BMEdge *e; + BMVert *v3; + float d, d2, vec[3]; + + v2 = BLI_array_pop(stack); + + d = dstack[BLI_array_count(dstack)-1]; + BLI_array_pop(dstack); + + dists[BMINDEX_GET(v2)] = d; + BM_ITER(e, &eiter, em->bm, BM_EDGES_OF_VERT, v2) { + float d2; + v3 = BM_OtherEdgeVert(e, v2); + + sub_v3_v3v3(vec, v2->co, v3->co); + mul_m3_v3(mtx, vec); + + d2 = d + len_v3(vec); + + if (d2 >= dists[BMINDEX_GET(v3)] && BLI_smallhash_haskey(visit, (uintptr_t)v3)) + continue; + + BLI_smallhash_insert(visit, (uintptr_t)v3, NULL); + + BLI_array_append(stack, v3); + BLI_array_append(dstack, d2); } } } + + BLI_smallhash_release(visit); + BLI_array_free(stack); + BLI_array_free(dstack); } /* loop-in-a-loop I know, but we need it! (ton) */ @@ -2052,106 +2040,6 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3, } #undef TAN_MAKE_VEC -static void set_crazyspace_quats(BMEditMesh *em, float *origcos, float *mappedcos, float *quats) -{ -#if 0 - BMVert *eve, *prev; - BMFace *efa; - float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4; - intptr_t index= 0; - - /* two abused locations in vertices */ - for(eve= em->verts.first; eve; eve= eve->next, index++) { - eve->tmp.p = NULL; - eve->prev= (BMVert *)index; - } - - /* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */ - for(efa= em->faces.first; efa; efa= efa->next) { - - /* retrieve mapped coordinates */ - v1= mappedcos + 3*(intptr_t)(efa->v1->prev); - v2= mappedcos + 3*(intptr_t)(efa->v2->prev); - v3= mappedcos + 3*(intptr_t)(efa->v3->prev); - - co1= (origcos)? origcos + 3*(intptr_t)(efa->v1->prev): efa->v1->co; - co2= (origcos)? origcos + 3*(intptr_t)(efa->v2->prev): efa->v2->co; - co3= (origcos)? origcos + 3*(intptr_t)(efa->v3->prev): efa->v3->co; - - if(efa->v2->tmp.p==NULL && efa->v2->f1) { - set_crazy_vertex_quat(quats, co2, co3, co1, v2, v3, v1); - efa->v2->tmp.p= (void*)quats; - quats+= 4; - } - - if(efa->v4) { - v4= mappedcos + 3*(intptr_t)(efa->v4->prev); - co4= (origcos)? origcos + 3*(intptr_t)(efa->v4->prev): efa->v4->co; - - if(efa->v1->tmp.p==NULL && efa->v1->f1) { - set_crazy_vertex_quat(quats, co1, co2, co4, v1, v2, v4); - efa->v1->tmp.p= (void*)quats; - quats+= 4; - } - if(efa->v3->tmp.p==NULL && efa->v3->f1) { - set_crazy_vertex_quat(quats, co3, co4, co2, v3, v4, v2); - efa->v3->tmp.p= (void*)quats; - quats+= 4; - } - if(efa->v4->tmp.p==NULL && efa->v4->f1) { - set_crazy_vertex_quat(quats, co4, co1, co3, v4, v1, v3); - efa->v4->tmp.p= (void*)quats; - quats+= 4; - } - } - else { - if(efa->v1->tmp.p==NULL && efa->v1->f1) { - set_crazy_vertex_quat(quats, co1, co2, co3, v1, v2, v3); - efa->v1->tmp.p= (void*)quats; - quats+= 4; - } - if(efa->v3->tmp.p==NULL && efa->v3->f1) { - set_crazy_vertex_quat(quats, co3, co1, co2, v3, v1, v2); - efa->v3->tmp.p= (void*)quats; - quats+= 4; - } - } - } - - /* restore abused prev pointer */ - for(prev= NULL, eve= em->verts.first; eve; prev= eve, eve= eve->next) - eve->prev= prev; -#endif -} - -static void createTransBMeshVerts(TransInfo *t, BME_Mesh *bm, BME_TransData_Head *td) { -#if 0 - BME_Vert *v; - BME_TransData *vtd; - TransData *tob; - int i; - - tob = t->data = MEM_callocN(td->len*sizeof(TransData), "TransObData(Bevel tool)"); - - for (i=0,v=bm->verts.first;v;v=v->next) { - if ( (vtd = BME_get_transdata(td,v)) ) { - tob->loc = vtd->loc; - tob->val = &vtd->factor; - VECCOPY(tob->iloc,vtd->co); - VECCOPY(tob->center,vtd->org); - VECCOPY(tob->axismtx[0],vtd->vec); - tob->axismtx[1][0] = vtd->max ? *vtd->max : 0; - tob++; - i++; - } - } - /* since td is a memarena, it can hold more transdata than actual elements - * (i.e. we can't depend on td->len to determine the number of actual elements) */ - t->total = i; -#endif - t->total = 0; -} - static void createTransEditVerts(bContext *C, TransInfo *t) { ToolSettings *ts = CTX_data_tool_settings(C); @@ -2159,15 +2047,14 @@ static void createTransEditVerts(bContext *C, TransInfo *t) BMEditMesh *em = ((Mesh *)t->obedit->data)->edit_btmesh; BMesh *bm = em->bm; BMVert *eve; - BMVert **nears = NULL; BMIter iter; BMVert *eve_act = NULL; float *mappedcos = NULL, *quats= NULL; float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL; - float *vectors=NULL; + float *dists=NULL; int count=0, countsel=0, a, totleft, *selstate = NULL; BLI_array_declare(selstate); - int propmode = t->flag & T_PROP_EDIT; + int propmode = t->flag & (T_PROP_EDIT|T_PROP_CONNECTED); int mirror = 0; short selectmode = ts->selectmode; @@ -2254,8 +2141,8 @@ static void createTransEditVerts(bContext *C, TransInfo *t) t->total = count; /* allocating scratch arrays */ - vectors = (float *)MEM_mallocN(t->total * 3 * sizeof(float), "scratch vectors"); - nears = (BMVert**)MEM_mallocN(t->total * sizeof(BMVert*), "scratch nears"); + if (propmode & T_PROP_CONNECTED) + dists = MEM_mallocN(em->bm->totvert * sizeof(float), "scratch nears"); } else t->total = countsel; @@ -2264,31 +2151,29 @@ static void createTransEditVerts(bContext *C, TransInfo *t) copy_m3_m4(mtx, t->obedit->obmat); invert_m3_m3(smtx, mtx); - //BMESH_TODO if(propmode) editmesh_set_connectivity_distance(em, t->total, vectors, nears); + if(propmode & T_PROP_CONNECTED) + editmesh_set_connectivity_distance(em, mtx, dists); /* detect CrazySpace [tm] */ - if(propmode==0) { - if(modifiers_getCageIndex(t->scene, t->obedit, NULL, 1)>=0) { - if(modifiers_isCorrectableDeformed(t->obedit)) { - /* check if we can use deform matrices for modifier from the - start up to stack, they are more accurate than quats */ - - totleft= editbmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos); - - /* if we still have more modifiers, also do crazyspace - correction with quats, relative to the coordinates after - the modifiers that support deform matrices (defcos) */ - if(totleft > 0) { - mappedcos= crazyspace_get_mapped_editverts(t->scene, t->obedit); - quats= MEM_mallocN( (t->total)*sizeof(float)*4, "crazy quats"); - crazyspace_set_quats_editmesh(em, (float*)defcos, mappedcos, quats); - if(mappedcos) - MEM_freeN(mappedcos); - } - - if(defcos) - MEM_freeN(defcos); + if(modifiers_getCageIndex(t->scene, t->obedit, NULL, 1)>=0) { + if(modifiers_isCorrectableDeformed(t->obedit)) { + /* check if we can use deform matrices for modifier from the + start up to stack, they are more accurate than quats */ + totleft= editbmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos); + + /* if we still have more modifiers, also do crazyspace + correction with quats, relative to the coordinates after + the modifiers that support deform matrices (defcos) */ + if(totleft > 0) { + mappedcos= crazyspace_get_mapped_editverts(t->scene, t->obedit); + quats= MEM_mallocN( (t->total)*sizeof(float)*4, "crazy quats"); + crazyspace_set_quats_editmesh(em, (float*)defcos, mappedcos, quats); + if(mappedcos) + MEM_freeN(mappedcos); } + + if(defcos) + MEM_freeN(defcos); } } @@ -2325,26 +2210,21 @@ static void createTransEditVerts(bContext *C, TransInfo *t) if(eve == eve_act) tob->flag |= TD_ACTIVE; if(propmode) { - /*BMESH_TODO - this has to do with edge connectivity - PEP mode, I think. -joeedh - if (eve->f2) { - tob->dist= eve->tmp.fp; - } - else {*/ + if (propmode & T_PROP_CONNECTED) { + tob->dist = dists[a]; + } else { tob->flag |= TD_NOTCONNECTED; tob->dist = MAXFLOAT; - //} + } } /* CrazySpace */ - if(defmats) { // || (quats && eve->tmp.p)) { - float mat[3][3], imat[3][3]; + if(defmats || (quats && BMINDEX_GET(eve) != -1)) { + float mat[3][3], qmat[3][3], imat[3][3]; /* use both or either quat and defmat correction */ - //BMESH_TODO, need to restore this quats thing - /*if(quats && eve->tmp.f) { - quat_to_mat3( qmat,eve->tmp.p); + if(quats && BMINDEX_GET(eve) != -1) { + quat_to_mat3(qmat, quats + 4*BMINDEX_GET(eve)); if(defmats) mul_serie_m3(mat, mtx, qmat, defmats[a], @@ -2352,7 +2232,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) else mul_m3_m3m3(mat, mtx, qmat); } - else*/ + else mul_m3_m3m3(mat, mtx, defmats[a]); invert_m3_m3(imat, mat); @@ -2397,7 +2277,9 @@ static void createTransEditVerts(bContext *C, TransInfo *t) MEM_freeN(quats); if(defmats) MEM_freeN(defmats); - + if (dists) + MEM_freeN(dists); + BLI_array_free(selstate); if (t->flag & T_MIRROR) @@ -2851,6 +2733,7 @@ static void createTransNlaData(bContext *C, TransInfo *t) unit_m3(td->smtx); } else { + /* time scaling only needs single value */ td->val= &tdn->h1[0]; td->ival= tdn->h1[0]; } @@ -2882,6 +2765,7 @@ static void createTransNlaData(bContext *C, TransInfo *t) unit_m3(td->smtx); } else { + /* time scaling only needs single value */ td->val= &tdn->h2[0]; td->ival= tdn->h2[0]; } @@ -2902,7 +2786,7 @@ static void createTransNlaData(bContext *C, TransInfo *t) } } } - + /* cleanup temp list */ BLI_freelistN(&anim_data); } @@ -3040,7 +2924,7 @@ static void posttrans_fcurve_clean (FCurve *fcu) if (BEZSELECTED(bezt) == 0) { /* check beztriple should be removed according to cache */ for (index= 0; index < len; index++) { - if (IS_EQ(bezt->vec[1][0], selcache[index])) { + if (IS_EQF(bezt->vec[1][0], selcache[index])) { delete_fcurve_key(fcu, i, 0); break; } @@ -3213,7 +3097,7 @@ void flushTransGPactionData (TransInfo *t) /* flush data! */ for (i = 0; i < t->total; i++, tfd++) { - *(tfd->sdata)= (int)floor(tfd->val + 0.5); + *(tfd->sdata)= (int)floor(tfd->val + 0.5f); } } @@ -3596,8 +3480,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) mul_v3_fl(mtx[1], yscale); /* smtx is global (i.e. view) to data conversion */ - if (IS_EQ(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f/xscale); - if (IS_EQ(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f/yscale); + if (IS_EQF(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f/xscale); + if (IS_EQF(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f/yscale); } /* loop 2: build transdata arrays */ @@ -3779,11 +3663,12 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert, const short UNUSED( } /* This function firstly adjusts the pointers that the transdata has to each BezTriple */ -static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert, const short use_handle) +static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totvert, const short UNUSED(use_handle)) { BezTriple *bezts = fcu->bezt; BeztMap *bezm; - TransData2D *td; + TransData2D *td2d; + TransData *td; int i, j; char *adjusted; @@ -3799,43 +3684,50 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv /* loop through transdata, testing if we have a hit * for the handles (vec[0]/vec[2]), we must also check if they need to be swapped... */ - td= t->data2d; - for (j= 0; j < t->total; j++, td++) { + td2d= t->data2d; + td= t->data; + for (j= 0; j < t->total; j++, td2d++, td++) { /* skip item if already marked */ if (adjusted[j] != 0) continue; - /* only selected verts */ - if (bezm->pipo == BEZT_IPO_BEZ) { - if (use_handle && bezm->bezt->f1 & SELECT) { - if (td->loc2d == bezm->bezt->vec[0]) { - if (bezm->swapHs == 1) - td->loc2d= (bezts + bezm->newIndex)->vec[2]; - else - td->loc2d= (bezts + bezm->newIndex)->vec[0]; - adjusted[j] = 1; - } - } + /* update all transdata pointers, no need to check for selections etc, + * since only points that are really needed were created as transdata + */ + if (td2d->loc2d == bezm->bezt->vec[0]) { + if (bezm->swapHs == 1) + td2d->loc2d= (bezts + bezm->newIndex)->vec[2]; + else + td2d->loc2d= (bezts + bezm->newIndex)->vec[0]; + adjusted[j] = 1; } - if (bezm->cipo == BEZT_IPO_BEZ) { - if (use_handle && bezm->bezt->f3 & SELECT) { - if (td->loc2d == bezm->bezt->vec[2]) { - if (bezm->swapHs == 1) - td->loc2d= (bezts + bezm->newIndex)->vec[0]; - else - td->loc2d= (bezts + bezm->newIndex)->vec[2]; - adjusted[j] = 1; - } - } + else if (td2d->loc2d == bezm->bezt->vec[2]) { + if (bezm->swapHs == 1) + td2d->loc2d= (bezts + bezm->newIndex)->vec[0]; + else + td2d->loc2d= (bezts + bezm->newIndex)->vec[2]; + adjusted[j] = 1; } - if (bezm->bezt->f2 & SELECT) { - if (td->loc2d == bezm->bezt->vec[1]) { - td->loc2d= (bezts + bezm->newIndex)->vec[1]; + else if (td2d->loc2d == bezm->bezt->vec[1]) { + td2d->loc2d= (bezts + bezm->newIndex)->vec[1]; - /* if only control point is selected, the handle pointers need to be updated as well */ - td->h1= (bezts + bezm->newIndex)->vec[0]; - td->h2= (bezts + bezm->newIndex)->vec[2]; + /* if only control point is selected, the handle pointers need to be updated as well */ + if(td2d->h1) + td2d->h1= (bezts + bezm->newIndex)->vec[0]; + if(td2d->h2) + td2d->h2= (bezts + bezm->newIndex)->vec[2]; - adjusted[j] = 1; + adjusted[j] = 1; + } + + /* the handle type pointer has to be updated too */ + if (adjusted[j] && td->flag & TD_BEZTRIPLE && td->hdata) { + if(bezm->swapHs == 1) { + td->hdata->h1 = &(bezts + bezm->newIndex)->h2; + td->hdata->h2 = &(bezts + bezm->newIndex)->h1; + } + else { + td->hdata->h1 = &(bezts + bezm->newIndex)->h1; + td->hdata->h2 = &(bezts + bezm->newIndex)->h2; } } } @@ -3867,6 +3759,7 @@ void remake_graph_transdata (TransInfo *t, ListBase *anim_data) BeztMap *bezm; /* adjust transform-data pointers */ + /* note, none of these functions use 'use_handle', it could be removed */ bezm= bezt_to_beztmaps(fcu->bezt, fcu->totvert, use_handle); sort_time_beztmaps(bezm, fcu->totvert, use_handle); beztmap_to_data(t, fcu, bezm, fcu->totvert, use_handle); @@ -4366,7 +4259,7 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list) if (list) { for (con= list->first; con; con=con->next) { /* only consider constraint if it is enabled, and has influence on result */ - if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0)) { + if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0f)) { /* (affirmative) returns for specific constraints here... */ /* constraints that require this regardless */ if (con->type == CONSTRAINT_TYPE_CHILDOF) return 1; @@ -4908,7 +4801,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) Object *ob; // short redrawipo=0, resetslowpar=1; int cancelled= (t->state == TRANS_CANCEL); - short duplicate= (t->undostr && strstr(t->undostr, "Duplicate")) ? 1 : 0; /* see bugreport #21229 for reasons for this data */ + short duplicate= (t->mode == TFM_TIME_DUPLICATE); /* early out when nothing happened */ if (t->total == 0 || t->mode == TFM_DUMMY) @@ -4936,10 +4829,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t) if(t->mode == TFM_SEQ_SLIDE) { if(t->frame_side == 'B') - scene_marker_tfm_translate(t->scene, floor(t->values[0] + 0.5f), SELECT); + ED_markers_post_apply_transform(&t->scene->markers, t->scene, TFM_TIME_TRANSLATE, t->vec[0], t->frame_side); } else if (ELEM(t->frame_side, 'L', 'R')) { - scene_marker_tfm_extend(t->scene, floor(t->vec[0] + 0.5f), SELECT, t->scene->r.cfra, t->frame_side); + ED_markers_post_apply_transform(&t->scene->markers, t->scene, TFM_TIME_EXTEND, t->vec[0], t->frame_side); } } @@ -4970,6 +4863,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) AnimData *adt= ANIM_nla_mapping_get(&ac, ale); FCurve *fcu= (FCurve *)ale->key_data; + /* 3 cases here for curve cleanups: + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed + * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these + */ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 && ((cancelled == 0) || (duplicate)) ) { @@ -4996,34 +4894,26 @@ void special_aftertrans_update(bContext *C, TransInfo *t) DAG_id_tag_update(&ob->id, OB_RECALC_OB); } - /* Do curve cleanups? */ + /* 3 cases here for curve cleanups: + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed + * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these + */ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 && ((cancelled == 0) || (duplicate)) ) { posttrans_action_clean(&ac, (bAction *)ac.data); } } - - /* marker transform, not especially nice but we may want to move markers - * at the same time as keyframes in the dope sheet. */ - if ((saction->flag & SACTION_MARKERS_MOVE) && (cancelled == 0)) { - /* cant use , TFM_TIME_EXTEND - * for some reason EXTEND is changed into TRANSLATE, so use frame_side instead */ - - if(t->mode == TFM_TIME_TRANSLATE) { - if(t->frame_side == 'B') - scene_marker_tfm_translate(t->scene, floor(t->vec[0] + 0.5f), SELECT); - else if (ELEM(t->frame_side, 'L', 'R')) - scene_marker_tfm_extend(t->scene, floor(t->vec[0] + 0.5f), SELECT, t->scene->r.cfra, t->frame_side); - } - else if(t->mode == TFM_TIME_SCALE) { - scene_marker_tfm_scale(t->scene, t->vec[0], SELECT); - } - } - else if (ac.datatype == ANIMCONT_GPENCIL) { /* remove duplicate frames and also make sure points are in order! */ - if ((cancelled == 0) || (duplicate)) + /* 3 cases here for curve cleanups: + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed + * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these + */ + if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 && + ((cancelled == 0) || (duplicate)) ) { bGPdata *gpd; @@ -5036,6 +4926,21 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } } + /* marker transform, not especially nice but we may want to move markers + * at the same time as keyframes in the dope sheet. + */ + if ((saction->flag & SACTION_MARKERS_MOVE) && (cancelled == 0)) { + if (t->mode == TFM_TIME_TRANSLATE) { + if (ELEM(t->frame_side, 'L', 'R')) /* TFM_TIME_EXTEND */ + ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side); + else /* TFM_TIME_TRANSLATE */ + ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side); + } + else if (t->mode == TFM_TIME_SCALE) { + ED_markers_post_apply_transform(ED_context_get_markers(C), t->scene, t->mode, t->vec[0], t->frame_side); + } + } + /* make sure all F-Curves are set correctly */ ANIM_editkeyframes_refresh(&ac); @@ -5063,13 +4968,18 @@ void special_aftertrans_update(bContext *C, TransInfo *t) AnimData *adt= ANIM_nla_mapping_get(&ac, ale); FCurve *fcu= (FCurve *)ale->key_data; + /* 3 cases here for curve cleanups: + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed + * 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these + */ if ( (sipo->flag & SIPO_NOTRANSKEYCULL)==0 && ((cancelled == 0) || (duplicate)) ) { if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0); posttrans_fcurve_clean(fcu); - ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0); } else posttrans_fcurve_clean(fcu); @@ -5295,7 +5205,7 @@ static void createTransObject(struct bContext *C, TransInfo *t) } /* select linked objects, but skip them later */ - if (ob->id.lib != 0) { + if (ob->id.lib != NULL) { td->flag |= TD_SKIP; } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index cf66a9f9d93..efff37c74ea 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/transform/transform_generics.c + * \ingroup edtransform + */ + + #include <string.h> #include <math.h> @@ -334,7 +339,7 @@ void recalcData(TransInfo *t) Scene *scene= t->scene; SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first; - bAnimContext ac= {0}; + bAnimContext ac= {NULL}; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -962,7 +967,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) t->options |= CTX_EDGE; } - t->spacetype = sa->spacetype; + t->spacetype = sa ? sa->spacetype : SPACE_EMPTY; /* background mode */ if(t->spacetype == SPACE_VIEW3D) { View3D *v3d = sa->spacedata.first; @@ -1006,7 +1011,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) SpaceImage *sima = sa->spacedata.first; // XXX for now, get View2D from the active region t->view = &ar->v2d; - t->around = sima->around; + t->around = (sima ? sima->around : 0); } else if(t->spacetype==SPACE_IPO) { diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 486fed91e3e..45ed983fce5 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -22,6 +22,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/transform/transform_input.c + * \ingroup edtransform + */ + + #include <stdlib.h> #include <math.h> @@ -87,8 +92,9 @@ static void InputSpringFlip(TransInfo *t, MouseInput *mi, short mval[2], float o InputSpring(t, mi, mval, output); /* flip scale */ - if ((mi->center[0] - mval[0]) * (mi->center[0] - mi->imval[0]) + - (mi->center[1] - mval[1]) * (mi->center[1] - mi->imval[1]) < 0) + /* values can become really big when zoomed in so use longs [#26598] */ + if ((long long int)(mi->center[0] - mval[0]) * (long long int)(mi->center[0] - mi->imval[0]) + + (long long int)(mi->center[1] - mval[1]) * (long long int)(mi->center[1] - mi->imval[1]) < 0) { output[0] *= -1.0f; } @@ -268,7 +274,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], floa mi->imval[1] = mval[1]; } - *angle += dphi; + *angle += (double)dphi; output[0] = *angle; } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index a281b388084..607fd59e0ec 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/transform/transform_manipulator.c + * \ingroup edtransform + */ + + #include <stdlib.h> #include <string.h> #include <math.h> @@ -558,29 +563,29 @@ static void test_manipulator_axis(const bContext *C) viewvector(rv3d, rv3d->twmat[3], vec); angle = fabs(angle_v3v3(rv3d->twmat[0], vec)); - if (angle > M_PI / 2) { - angle = M_PI - angle; + if (angle > (float)M_PI / 2.0f) { + angle = (float)M_PI - angle; } - angle = rv3d->twangle[0] = 180.0f * angle / M_PI; - if (angle < 5) { + angle = rv3d->twangle[0] = RAD2DEGF(angle); + if (angle < 5.0f) { rv3d->twdrawflag &= ~(MAN_TRANS_X|MAN_SCALE_X); } angle = fabs(angle_v3v3(rv3d->twmat[1], vec)); - if (angle > M_PI / 2) { - angle = M_PI - angle; + if (angle > (float)M_PI / 2.0f) { + angle = (float)M_PI - angle; } - angle = rv3d->twangle[1] = 180.0f * angle / M_PI; - if (angle < 5) { + angle = rv3d->twangle[1] = RAD2DEGF(angle); + if (angle < 5.0f) { rv3d->twdrawflag &= ~(MAN_TRANS_Y|MAN_SCALE_Y); } angle = fabs(angle_v3v3(rv3d->twmat[2], vec)); - if (angle > M_PI / 2) { - angle = M_PI - angle; + if (angle > (float)M_PI / 2.0f) { + angle = (float)M_PI - angle; } - angle = rv3d->twangle[2] = 180.0f * angle / M_PI; - if (angle < 5) { + angle = rv3d->twangle[2] = RAD2DEGF(angle); + if (angle < 5.0f) { rv3d->twdrawflag &= ~(MAN_TRANS_Z|MAN_SCALE_Z); } } @@ -830,7 +835,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, if(arcs) { /* clipplane makes nice handles, calc here because of multmatrix but with translate! */ VECCOPY(plane, rv3d->viewinv[2]); - plane[3]= -0.02*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 */ @@ -1564,7 +1569,6 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, short *mval, float ho return 0; } -int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties, ReportList *reports); /* return 0; nothing happened */ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) @@ -1621,7 +1625,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) } RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, op->ptr); - //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL); + //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL, FALSE); } else if (drawflags & MAN_SCALE_C) { switch(drawflags) { @@ -1652,11 +1656,11 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) } RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); WM_operator_name_call(C, "TRANSFORM_OT_resize", WM_OP_INVOKE_DEFAULT, op->ptr); - //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_resize", 0), event, op->ptr, NULL); + //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_resize", 0), event, op->ptr, NULL, FALSE); } else if (drawflags == MAN_ROT_T) { /* trackball need special case, init is different */ - //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_trackball", 0), event, op->ptr, NULL); WM_operator_name_call(C, "TRANSFORM_OT_trackball", WM_OP_INVOKE_DEFAULT, op->ptr); + //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_trackball", 0), event, op->ptr, NULL, FALSE); } else if (drawflags & MAN_ROT_C) { switch(drawflags) { @@ -1672,7 +1676,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) } RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); WM_operator_name_call(C, "TRANSFORM_OT_rotate", WM_OP_INVOKE_DEFAULT, op->ptr); - //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_rotate", 0), event, op->ptr, NULL); + //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_rotate", 0), event, op->ptr, NULL, FALSE); } } /* after transform, restore drawflags */ diff --git a/source/blender/editors/transform/transform_ndofinput.c b/source/blender/editors/transform/transform_ndofinput.c index f9ac1bd38d1..c5946163770 100644 --- a/source/blender/editors/transform/transform_ndofinput.c +++ b/source/blender/editors/transform/transform_ndofinput.c @@ -23,6 +23,11 @@ * * ***** END GPL LICENSE BLOCK ***** */ + +/** \file blender/editors/transform/transform_ndofinput.c + * \ingroup edtransform + */ + #include <math.h> /* fabs */ #include <stdio.h> /* for sprintf */ diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index e1dd0191c0d..4edaabb9508 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -22,6 +22,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/transform/transform_ops.c + * \ingroup edtransform + */ + + #include "MEM_guardedalloc.h" #include "DNA_scene_types.h" @@ -41,6 +46,7 @@ #include "WM_types.h" #include "UI_interface.h" +#include "UI_resources.h" #include "ED_screen.h" @@ -104,6 +110,39 @@ static TransformModeItem transform_modes[] = {NULL, 0} }; +EnumPropertyItem transform_mode_types[] = +{ + {TFM_INIT, "INIT", 0, "Init", ""}, + {TFM_DUMMY, "DUMMY", 0, "Dummy", ""}, + {TFM_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, + {TFM_ROTATION, "ROTATION", 0, "Rotation", ""}, + {TFM_RESIZE, "RESIZE", 0, "Resize", ""}, + {TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""}, + {TFM_SHEAR, "SHEAR", 0, "Shear", ""}, + {TFM_WARP, "WARP", 0, "Warp", ""}, + {TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""}, + {TFM_TILT, "TILT", 0, "Tilt", ""}, + {TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""}, + {TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""}, + {TFM_CREASE, "CREASE", 0, "Crease", ""}, + {TFM_MIRROR, "MIRROR", 0, "Mirror", ""}, + {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""}, + {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""}, + {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""}, + {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""}, + {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""}, + {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""}, + {TFM_TIME_SCALE, "TIME_SCALE", 0, "Time_Scale", ""}, + {TFM_TIME_EXTEND, "TIME_EXTEND", 0, "Time_Extend", ""}, + {TFM_BAKE_TIME, "BAKE_TIME", 0, "Bake_Time", ""}, + {TFM_BEVEL, "BEVEL", 0, "Bevel", ""}, + {TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""}, + {TFM_ALIGN, "ALIGN", 0, "Align", ""}, + {TFM_EDGE_SLIDE, "EDGESLIDE", 0, "Edge Slide", ""}, + {TFM_SEQ_SLIDE, "SEQSLIDE", 0, "Sequence Slide", ""}, + {0, NULL, 0, NULL, NULL} +}; + static int snap_type_exec(bContext *C, wmOperator *op) { ToolSettings *ts= CTX_data_tool_settings(C); @@ -152,7 +191,7 @@ static int select_orientation_invoke(bContext *C, wmOperator *UNUSED(op), wmEven uiPopupMenu *pup; uiLayout *layout; - pup= uiPupMenuBegin(C, "Orientation", ICON_NULL); + pup= uiPupMenuBegin(C, "Orientation", ICON_NONE); layout= uiPupMenuLayout(pup); uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation"); uiPupMenuEnd(C, pup); @@ -297,7 +336,7 @@ static int transformops_data(bContext *C, wmOperator *op, wmEvent *event) if (mode == -1) { - mode = RNA_int_get(op->ptr, "mode"); + mode = RNA_enum_get(op->ptr, "mode"); } retval = initTransform(C, t, op, event, mode); @@ -369,6 +408,8 @@ static int transform_exec(bContext *C, wmOperator *op) transformEnd(C, t); transformops_exit(C, op); + + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -747,37 +788,7 @@ void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot) void TRANSFORM_OT_transform(struct wmOperatorType *ot) { - static EnumPropertyItem transform_mode_types[] = { - {TFM_INIT, "INIT", 0, "Init", ""}, - {TFM_DUMMY, "DUMMY", 0, "Dummy", ""}, - {TFM_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, - {TFM_ROTATION, "ROTATION", 0, "Rotation", ""}, - {TFM_RESIZE, "RESIZE", 0, "Resize", ""}, - {TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""}, - {TFM_SHEAR, "SHEAR", 0, "Shear", ""}, - {TFM_WARP, "WARP", 0, "Warp", ""}, - {TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""}, - {TFM_TILT, "TILT", 0, "Tilt", ""}, - {TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""}, - {TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""}, - {TFM_CREASE, "CREASE", 0, "Crease", ""}, - {TFM_MIRROR, "MIRROR", 0, "Mirror", ""}, - {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""}, - {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""}, - {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""}, - {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""}, - {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""}, - {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""}, - {TFM_TIME_SCALE, "TIME_SCALE", 0, "Time_Scale", ""}, - {TFM_TIME_EXTEND, "TIME_EXTEND", 0, "Time_Extend", ""}, - {TFM_BAKE_TIME, "BAKE_TIME", 0, "Bake_Time", ""}, - {TFM_BEVEL, "BEVEL", 0, "Bevel", ""}, - {TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""}, - {TFM_ALIGN, "ALIGN", 0, "Align", ""}, - {TFM_EDGE_SLIDE, "EDGESLIDE", 0, "Edge Slide", ""}, - {TFM_SEQ_SLIDE, "SEQSLIDE", 0, "Sequence Slide", ""}, - {0, NULL, 0, NULL, NULL} - }; + PropertyRNA *prop; /* identifiers */ ot->name = "Transform"; @@ -792,7 +803,8 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot) ot->cancel = transform_cancel; ot->poll = ED_operator_areaactive; - RNA_def_enum(ot->srna, "mode", transform_mode_types, 0, "Mode", ""); + prop= RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX); @@ -874,19 +886,19 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac break; case SPACE_ACTION: km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_TRANSLATE); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_TRANSLATE); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND); + RNA_enum_set(km->ptr, "mode", TFM_TIME_EXTEND); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_SCALE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_SCALE); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", TKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_SLIDE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_SLIDE); break; case SPACE_IPO: WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0); @@ -894,7 +906,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND); + RNA_enum_set(km->ptr, "mode", TFM_TIME_EXTEND); WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0); @@ -902,24 +914,24 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac break; case SPACE_NLA: km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TRANSLATION); + RNA_enum_set(km->ptr, "mode", TFM_TRANSLATION); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TRANSLATION); + RNA_enum_set(km->ptr, "mode", TFM_TRANSLATION); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND); + RNA_enum_set(km->ptr, "mode", TFM_TIME_EXTEND); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_SCALE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_SCALE); break; case SPACE_NODE: WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0); km= WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_A, KM_ANY, 0, 0); - RNA_enum_set(km->ptr, "release_confirm", 1); + RNA_boolean_set(km->ptr, "release_confirm", 1); km= WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0); - RNA_enum_set(km->ptr, "release_confirm", 1); + RNA_boolean_set(km->ptr, "release_confirm", 1); WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0); @@ -931,7 +943,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac WM_keymap_add_item(keymap, OP_SEQ_SLIDE, EVT_TWEAK_S, KM_ANY, 0, 0); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND); + RNA_enum_set(km->ptr, "mode", TFM_TIME_EXTEND); break; case SPACE_IMAGE: WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index b63d279a42b..46f601e25e1 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -22,6 +22,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/transform/transform_orientations.c + * \ingroup edtransform + */ + + #include <string.h> #include <ctype.h> diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 7379eb46a3a..16c2856ff8b 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -26,6 +26,11 @@ * * ***** END GPL LICENSE BLOCK ***** */ + +/** \file blender/editors/transform/transform_snap.c + * \ingroup edtransform + */ + #include <stdlib.h> #include <math.h> @@ -642,7 +647,7 @@ float RotationBetween(TransInfo *t, float p1[3], float p2[3]) cross_v3_v3v3(tmp, start, end); - if (dot_v3v3(tmp, axis) < 0.0) + if (dot_v3v3(tmp, axis) < 0.0f) angle = -acos(dot_v3v3(start, end)); else angle = acos(dot_v3v3(start, end)); @@ -658,11 +663,11 @@ float RotationBetween(TransInfo *t, float p1[3], float p2[3]) angle = atan2(start[1],start[0]) - atan2(end[1],end[0]); } - if (angle > M_PI) { - angle = angle - 2 * M_PI; + if (angle > (float)M_PI) { + angle = angle - 2 * (float)M_PI; } - else if (angle < -(M_PI)) { - angle = 2 * M_PI + angle; + else if (angle < -((float)M_PI)) { + angle = 2.0f * (float)M_PI + angle; } return angle; @@ -1131,7 +1136,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh * this takes care of series of connected edges a bit slanted w.r.t the viewport * otherwise, it would stick to the verts of the closest edge and not slide along merrily * */ - if (new_dist <= *dist && new_depth < *depth * 1.001) + if (new_dist <= *dist && new_depth < *depth * 1.001f) { float n1[3], n2[3]; @@ -1683,7 +1688,7 @@ static void removeDoublesPeel(ListBase *depth_peels) { DepthPeel *next_peel = peel->next; - if (peel && next_peel && ABS(peel->depth - next_peel->depth) < 0.0015) + if (peel && next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f) { peel->next = next_peel->next; @@ -1954,7 +1959,7 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3) // Early bailing out if no need to snap - if (fac[action] == 0.0) + if (fac[action] == 0.0f) return; /* evil hack - snapping needs to be adapted for image aspect ratio */ @@ -1963,6 +1968,6 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea } for (i=0; i<=max_index; i++) { - val[i]= fac[action]*asp[i]*(float)floor(val[i]/(fac[action]*asp[i]) +.5); + val[i]= fac[action]*asp[i]*(float)floor(val[i]/(fac[action]*asp[i]) +0.5f); } } |