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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r--source/blender/editors/transform/transform.c112
-rw-r--r--source/blender/editors/transform/transform_conversions.c25
-rw-r--r--source/blender/editors/transform/transform_snap.c14
3 files changed, 74 insertions, 77 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index dccd0c27234..ee5d50c7aba 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -126,11 +126,11 @@ static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
{
float divx, divy;
- divx = BLI_RCT_SIZE_X(&v2d->mask);
- divy = BLI_RCT_SIZE_Y(&v2d->mask);
+ divx = BLI_rcti_size_x(&v2d->mask);
+ divy = BLI_rcti_size_y(&v2d->mask);
- r_vec[0] = BLI_RCT_SIZE_X(&v2d->cur) * dx / divx;
- r_vec[1] = BLI_RCT_SIZE_Y(&v2d->cur) * dy / divy;
+ r_vec[0] = BLI_rctf_size_x(&v2d->cur) * dx / divx;
+ r_vec[1] = BLI_rctf_size_y(&v2d->cur) * dy / divy;
r_vec[2] = 0.0f;
}
@@ -139,11 +139,11 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
float divx, divy;
float mulx, muly;
- divx = BLI_RCT_SIZE_X(&v2d->mask);
- divy = BLI_RCT_SIZE_Y(&v2d->mask);
+ divx = BLI_rcti_size_x(&v2d->mask);
+ divy = BLI_rcti_size_y(&v2d->mask);
- mulx = BLI_RCT_SIZE_X(&v2d->cur);
- muly = BLI_RCT_SIZE_Y(&v2d->cur);
+ mulx = BLI_rctf_size_x(&v2d->cur);
+ muly = BLI_rctf_size_y(&v2d->cur);
/* difference with convertViewVec2D */
/* clamp w/h, mask only */
@@ -226,7 +226,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
{
if (t->spacetype == SPACE_VIEW3D) {
if (t->ar->regiontype == RGN_TYPE_WINDOW)
- project_int_noclip(t->ar, vec, adr);
+ ED_view3d_project_int_noclip(t->ar, vec, adr);
}
else if (t->spacetype == SPACE_IMAGE) {
SpaceImage *sima = t->sa->spacedata.first;
@@ -344,7 +344,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
case SPACE_VIEW3D:
{
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
- project_float_noclip(t->ar, vec, adr);
+ ED_view3d_project_float_noclip(t->ar, vec, adr);
return;
}
break;
@@ -2195,7 +2195,6 @@ static void constraintTransLim(TransInfo *t, TransData *td)
for (con = td->con; con; con = con->next) {
bConstraintTypeInfo *cti = NULL;
ListBase targets = {NULL, NULL};
- float tmat[4][4];
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
@@ -2221,8 +2220,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->mtx, tmat);
+ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
}
else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
/* skip... incompatable spacetype */
@@ -2237,9 +2235,8 @@ static void constraintTransLim(TransInfo *t, TransData *td)
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
- /* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->smtx, tmat);
+ /* just multiply by td->smtx (this should be ok) */
+ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
}
/* free targets list */
@@ -2287,18 +2284,17 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
bConstraintOb cob;
bConstraint *con;
int do_limit = FALSE;
-
+
/* Evaluate valid constraints */
for (con = td->con; con; con = con->next) {
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* we're only interested in Limit-Rotation constraints */
if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
bRotLimitConstraint *data = con->data;
- float tmat[4][4];
-
+
/* only use it if it's tagged for this purpose */
if ((data->flag2 & LIMIT_TRANSFORM) == 0)
continue;
@@ -2312,12 +2308,11 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
constraintob_from_transdata(&cob, td);
do_limit = TRUE;
}
-
+
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->mtx, tmat);
+ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
}
/* do constraint */
@@ -2325,9 +2320,8 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
- /* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->smtx, tmat);
+ /* just multiply by td->smtx (this should be ok) */
+ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
}
}
}
@@ -2382,7 +2376,6 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* we're only interested in Limit-Scale constraints */
if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
bSizeLimitConstraint *data = con->data;
- float tmat[4][4];
/* only use it if it's tagged for this purpose */
if ((data->flag2 & LIMIT_TRANSFORM) == 0)
@@ -2391,11 +2384,10 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->mtx, tmat);
+ mul_m4_m3m4(cob.matrix, td->mtx, cob.matrix);
}
else if (con->ownspace != CONSTRAINT_SPACE_LOCAL) {
- /* skip... incompatable spacetype */
+ /* skip... incompatible spacetype */
continue;
}
@@ -2404,13 +2396,12 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
- /* just multiply by td->mtx (this should be ok) */
- copy_m4_m4(tmat, cob.matrix);
- mul_m4_m3m4(cob.matrix, td->smtx, tmat);
+ /* just multiply by td->smtx (this should be ok) */
+ mul_m4_m3m4(cob.matrix, td->smtx, cob.matrix);
}
}
}
-
+
/* copy results from cob->matrix */
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
@@ -2420,7 +2411,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
return;
-
+
mat4_to_size(td->ext->size, cob.matrix);
}
}
@@ -2852,11 +2843,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
if (t->flag & (T_OBJECT | T_TEXTURE | T_POSE)) {
float obsizemat[3][3];
- // Reorient the size mat to fit the oriented object.
+ /* Reorient the size mat to fit the oriented object. */
mul_m3_m3m3(obsizemat, tmat, td->axismtx);
- //print_m3("obsizemat", obsizemat);
+ /* print_m3("obsizemat", obsizemat); */
TransMat3ToSize(obsizemat, td->axismtx, fsize);
- //print_v3("fsize", fsize);
+ /* print_v3("fsize", fsize); */
}
else {
mat3_to_size(fsize, tmat);
@@ -2864,7 +2855,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
protectedSizeBits(td->protectflag, fsize);
- if ((t->flag & T_V3D_ALIGN) == 0) { // align mode doesn't resize objects itself
+ if ((t->flag & T_V3D_ALIGN) == 0) { /* align mode doesn't resize objects itself */
if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
*td->val = td->ival * (1 + (fsize[0] - 1) * td->factor);
@@ -4100,9 +4091,9 @@ void initMaskShrinkFatten(TransInfo *t)
int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
{
- TransData *td = t->data;
+ TransData *td;
float ratio;
- int i;
+ int i, initial_feather = FALSE;
char str[50];
ratio = t->values[0];
@@ -4116,13 +4107,30 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
char c[NUM_STR_REP_LEN];
outputNumInput(&(t->num), c);
- sprintf(str, "Shrink/Fatten: %s", c);
+ sprintf(str, "Feather Shrink/Fatten: %s", c);
}
else {
- sprintf(str, "Shrink/Fatten: %3f", ratio);
+ sprintf(str, "Feather Shrink/Fatten: %3f", ratio);
}
- for (i = 0; i < t->total; i++, td++) {
+ /* detect if no points have feather yet */
+ if (ratio > 1.0f) {
+ initial_feather = TRUE;
+
+ for (td = t->data, i = 0; i < t->total; i++, td++) {
+ if (td->flag & TD_NOACTION)
+ break;
+
+ if (td->flag & TD_SKIP)
+ continue;
+
+ if (td->ival >= 0.001f)
+ initial_feather = FALSE;
+ }
+ }
+
+ /* apply shrink/fatten */
+ for (td = t->data, i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4130,7 +4138,11 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
continue;
if (td->val) {
- *td->val = td->ival * ratio;
+ if (initial_feather)
+ *td->val = td->ival + (ratio - 1.0f) * 0.01f;
+ else
+ *td->val = td->ival * ratio;
+
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
if (*td->val <= 0.0f) *td->val = 0.001f;
@@ -4774,7 +4786,7 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo
sv->edge_len = len_v3v3(dw_p, up_p);
mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co);
- project_float_noclip(t->ar, v_proj, v_proj);
+ ED_view3d_project_float_noclip(t->ar, v_proj, v_proj);
dist = len_squared_v2v2(mval, v_proj);
if (dist < min_dist) {
@@ -5040,19 +5052,19 @@ static int createSlideVerts(TransInfo *t)
j = GET_INT_FROM_POINTER(BLI_smallhash_lookup(&table, (uintptr_t)v));
if (sv_array[j].down) {
- ED_view3d_project_float_v3(ar, sv_array[j].down->co, vec1, projectMat);
+ ED_view3d_project_float_v3_m4(ar, sv_array[j].down->co, vec1, projectMat);
}
else {
add_v3_v3v3(vec1, v->co, sv_array[j].downvec);
- ED_view3d_project_float_v3(ar, vec1, vec1, projectMat);
+ ED_view3d_project_float_v3_m4(ar, vec1, vec1, projectMat);
}
if (sv_array[j].up) {
- ED_view3d_project_float_v3(ar, sv_array[j].up->co, vec2, projectMat);
+ ED_view3d_project_float_v3_m4(ar, sv_array[j].up->co, vec2, projectMat);
}
else {
add_v3_v3v3(vec2, v->co, sv_array[j].upvec);
- ED_view3d_project_float_v3(ar, vec2, vec2, projectMat);
+ ED_view3d_project_float_v3_m4(ar, vec2, vec2, projectMat);
}
/* global direction */
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 181f9fe6036..022e9177a4a 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -1773,9 +1773,6 @@ void flushTransParticles(TransInfo *t)
/* ********************* mesh ****************** */
-/* proportional distance based on connectivity */
-#define THRESHOLDFACTOR (1.0f - 0.0001f)
-
/* 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
@@ -5170,7 +5167,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* Depending on the lock status, draw necessary views */
// fixme... some of this stuff is not good
if (ob) {
- if (ob->pose || ob_get_key(ob))
+ if (ob->pose || BKE_key_from_object(ob))
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
else
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
@@ -5554,8 +5551,8 @@ static void createTransObject(bContext *C, TransInfo *t)
static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
{
/* hold original location */
- float locxy[2] = {BLI_RCT_CENTER_X(&node->totr),
- BLI_RCT_CENTER_Y(&node->totr)};
+ float locxy[2] = {BLI_rctf_cent_x(&node->totr),
+ BLI_rctf_cent_y(&node->totr)};
copy_v2_v2(td2d->loc, locxy);
td2d->loc[2] = 0.0f;
@@ -5722,10 +5719,9 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, TransDataTra
unit_m3(td->smtx);
}
-static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
+static void trackToTransData(const int framenr, TransData *td, TransData2D *td2d,
TransDataTracking *tdt, MovieTrackingTrack *track, float aspx, float aspy)
{
- int framenr = ED_space_clip_get_clip_frame_number(sc);
MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr);
tdt->flag = marker->flag;
@@ -5777,7 +5773,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
MovieClip *clip = ED_space_clip_get_clip(sc);
ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
MovieTrackingTrack *track;
- MovieTrackingMarker *marker;
TransDataTracking *tdt;
int framenr = ED_space_clip_get_clip_frame_number(sc);
float aspx, aspy;
@@ -5788,8 +5783,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- marker = BKE_tracking_marker_get(track, framenr);
-
t->total++; /* offset */
if (track->flag & SELECT)
@@ -5820,9 +5813,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
- marker = BKE_tracking_marker_get(track, framenr);
-
- trackToTransData(sc, td, td2d, tdt, track, aspx, aspy);
+ trackToTransData(framenr, td, td2d, tdt, track, aspx, aspy);
/* offset */
td++;
@@ -5845,12 +5836,6 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
td += 2;
td2d += 2;
tdt += 2;
-
- if (marker->flag & MARKER_DISABLED) {
- td += 3;
- td2d += 3;
- tdt += 3;
- };
}
}
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index b88ae68e00b..1d75be05534 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -315,7 +315,7 @@ void applyProject(TransInfo *t)
copy_v3_v3(iloc, td->ob->obmat[3]);
}
- project_float(t->ar, iloc, mval);
+ ED_view3d_project_float(t->ar, iloc, mval);
if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect)) {
// if (t->flag & (T_EDIT|T_POSE)) {
@@ -601,7 +601,7 @@ int updateSelectedSnapPoint(TransInfo *t)
int dx, dy;
int dist;
- project_int(t->ar, p->co, screen_loc);
+ ED_view3d_project_int(t->ar, p->co, screen_loc);
dx = t->mval[0] - screen_loc[0];
dy = t->mval[1] - screen_loc[1];
@@ -960,8 +960,8 @@ static void TargetSnapOffset(TransInfo *t, TransData *td)
if (t->spacetype == SPACE_NODE && td != NULL) {
bNode *node = td->extra;
char border = t->tsnap.snapNodeBorder;
- float width = BLI_RCT_SIZE_X(&node->totr);
- float height = BLI_RCT_SIZE_Y(&node->totr);
+ float width = BLI_rctf_size_x(&node->totr);
+ float height = BLI_rctf_size_y(&node->totr);
if (border & NODE_LEFT)
t->tsnap.snapTarget[0] -= 0.5f * width;
@@ -1164,7 +1164,7 @@ static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], fl
new_depth = len_v3v3(location, ray_start);
- project_int(ar, location, screen_loc);
+ ED_view3d_project_int(ar, location, screen_loc);
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
if (new_dist <= *dist && new_depth < *depth) {
@@ -1232,7 +1232,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
new_depth = len_v3v3(location, ray_start);
- project_int(ar, location, screen_loc);
+ ED_view3d_project_int(ar, location, screen_loc);
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
/* 10% threshold if edge is closer but a bit further
@@ -1289,7 +1289,7 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4],
new_depth = len_v3v3(location, ray_start);
- project_int(ar, location, screen_loc);
+ ED_view3d_project_int(ar, location, screen_loc);
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
if (new_dist <= *r_dist && new_depth < *r_depth) {