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.c39
-rw-r--r--source/blender/editors/transform/transform_conversions.c2
-rw-r--r--source/blender/editors/transform/transform_snap_object.c23
3 files changed, 39 insertions, 25 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 973c1c0b7f7..98203a7e316 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -4607,6 +4607,10 @@ static void applyRotationValue(TransInfo *t,
}
axis_angle_normalized_to_mat3(mat, axis, angle);
+ /* Counter for needed updates (when we need to update to non-default matrix,
+ * we also need another update on next iteration to go back to default matrix,
+ * hence the '2' value used here, instead of a mere boolean). */
+ short do_update_matrix = 0;
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
@@ -4623,6 +4627,9 @@ static void applyRotationValue(TransInfo *t,
if (t->con.applyRot) {
t->con.applyRot(t, tc, td, axis, NULL);
angle_final = angle * td->factor;
+ /* Even though final angle might be identical to orig value,
+ * we have to update the rotation matrix in that case... */
+ do_update_matrix = 2;
}
else if (t->flag & T_PROP_EDIT) {
angle_final = angle * td->factor;
@@ -4645,11 +4652,17 @@ static void applyRotationValue(TransInfo *t,
axis_angle_normalized_to_mat3(mat, axis, angle_progress);
ElementRotation(t, tc, td, mat, t->around);
}
- axis_angle_normalized_to_mat3(mat, axis, angle_final);
+ do_update_matrix = 2;
}
else if (angle_final != angle) {
+ do_update_matrix = 2;
+ }
+
+ if (do_update_matrix > 0) {
axis_angle_normalized_to_mat3(mat, axis, angle_final);
+ do_update_matrix--;
}
+
ElementRotation(t, tc, td, mat, t->around);
}
}
@@ -9449,7 +9462,7 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR])
}
}
-static void applyTimeTranslateValue(TransInfo *t)
+static void applyTimeTranslateValue(TransInfo *t, float value)
{
Scene *scene = t->scene;
int i;
@@ -9458,7 +9471,6 @@ static void applyTimeTranslateValue(TransInfo *t)
const double secf = FPS;
float deltax, val /* , valprev */;
- t->values_final[0] = t->values[0];
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
@@ -9476,7 +9488,7 @@ static void applyTimeTranslateValue(TransInfo *t)
/* check if any need to apply nla-mapping */
if (adt && (t->spacetype != SPACE_SEQ)) {
- deltax = t->values_final[0];
+ deltax = value;
if (autosnap == SACTSNAP_TSTEP) {
deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf);
@@ -9529,7 +9541,7 @@ static void applyTimeTranslate(TransInfo *t, const int mval[2])
t->values_final[0] = t->vec[0];
headerTimeTranslate(t, str);
- applyTimeTranslateValue(t);
+ applyTimeTranslateValue(t, t->values_final[0]);
recalcData(t);
@@ -9637,20 +9649,17 @@ static void headerTimeSlide(TransInfo *t, const float sval, char str[UI_MAX_DRAW
BLI_snprintf(str, UI_MAX_DRAW_STR, TIP_("TimeSlide: %s"), &tvec[0]);
}
-static void applyTimeSlideValue(TransInfo *t, float sval)
+static void applyTimeSlideValue(TransInfo *t, float sval, float cval)
{
int i;
const float *range = t->custom.mode.data;
float minx = range[0];
float maxx = range[1];
- t->values_final[0] = t->values[0];
/* set value for drawing black line */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
- float cvalf = t->values_final[0];
-
- saction->timeslide = cvalf;
+ saction->timeslide = cval;
}
/* It doesn't matter whether we apply to t->data or
@@ -9663,7 +9672,6 @@ static void applyTimeSlideValue(TransInfo *t, float sval)
* (this is only valid when not in NLA)
*/
AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
- float cval = t->values_final[0];
/* only apply to data if in range */
if ((sval > minx) && (sval < maxx)) {
@@ -9724,7 +9732,7 @@ static void applyTimeSlide(TransInfo *t, const int mval[2])
t->values_final[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0];
headerTimeSlide(t, sval[0], str);
- applyTimeSlideValue(t, sval[0]);
+ applyTimeSlideValue(t, sval[0], t->values_final[0]);
recalcData(t);
@@ -9796,14 +9804,13 @@ static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR])
BLI_snprintf(str, UI_MAX_DRAW_STR, TIP_("ScaleX: %s"), &tvec[0]);
}
-static void applyTimeScaleValue(TransInfo *t)
+static void applyTimeScaleValue(TransInfo *t, float value)
{
Scene *scene = t->scene;
int i;
const short autosnap = getAnimEdit_SnapMode(t);
const double secf = FPS;
- t->values_final[0] = t->values[0];
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
@@ -9815,7 +9822,7 @@ static void applyTimeScaleValue(TransInfo *t)
*/
AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL;
float startx = CFRA;
- float fac = t->values_final[0];
+ float fac = value;
if (autosnap == SACTSNAP_TSTEP) {
fac = (float)(floor((double)fac / secf + 0.5) * secf);
@@ -9851,7 +9858,7 @@ static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2]))
t->values_final[0] = t->vec[0];
headerTimeScale(t, str);
- applyTimeScaleValue(t);
+ applyTimeScaleValue(t, t->values_final[0]);
recalcData(t);
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 4eccf4c5071..ef9d23d1db8 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -9049,7 +9049,7 @@ static void createTransGPencil(bContext *C, TransInfo *t)
/* initialize falloff curve */
if (is_multiedit) {
- curvemapping_initialize(ts->gp_sculpt.cur_falloff);
+ BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff);
}
/* First Pass: Count the number of data-points required for the strokes,
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 6f06f8639bd..67bd107ab49 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -573,11 +573,11 @@ static bool raycastEditMesh(SnapObjectContext *sctx,
BVHTreeFromEditMesh *treedata = sod->bvh_trees[2];
- BVHCache *em_bvh_cache = ((Mesh *)em->ob->data)->runtime.bvh_cache;
+ BVHCache **em_bvh_cache = &((Mesh *)em->ob->data)->runtime.bvh_cache;
if (sctx->callbacks.edit_mesh.test_face_fn == NULL) {
/* The tree is owned by the Mesh and may have been freed since we last used! */
- if (!bvhcache_has_tree(em_bvh_cache, treedata->tree)) {
+ if (treedata->tree && !bvhcache_has_tree(*em_bvh_cache, treedata->tree)) {
free_bvhtree_from_editmesh(treedata);
}
}
@@ -605,7 +605,7 @@ static bool raycastEditMesh(SnapObjectContext *sctx,
else {
/* Only cache if bvhtree is created without a mask.
* This helps keep a standardized bvhtree in cache. */
- bvh_cache = &em_bvh_cache;
+ bvh_cache = em_bvh_cache;
}
bvhtree_from_editmesh_looptri_ex(
@@ -1382,6 +1382,13 @@ static short snap_mesh_edge_verts_mixed(SnapObjectContext *sctx,
};
SnapObjectData *sod = BLI_ghash_lookup(sctx->cache.object_map, ob);
+ if (sod == NULL) {
+ /* The object is in edit mode, and the key used
+ * was the object referenced in BMEditMesh */
+ BMEditMesh *em = BKE_editmesh_from_object(ob);
+ sod = BLI_ghash_lookup(sctx->cache.object_map, em->ob);
+ }
+
BLI_assert(sod != NULL);
if (sod->type == SNAP_MESH) {
@@ -2188,7 +2195,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
return 0;
}
- BVHCache *em_bvh_cache = ((Mesh *)em->ob->data)->runtime.bvh_cache;
+ BVHCache **em_bvh_cache = &((Mesh *)em->ob->data)->runtime.bvh_cache;
if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) {
if (sod->bvh_trees[0] == NULL) {
@@ -2198,7 +2205,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
if (sctx->callbacks.edit_mesh.test_vert_fn == NULL) {
/* The tree is owned by the Mesh and may have been freed since we last used! */
- if (!bvhcache_has_tree(em_bvh_cache, treedata_vert->tree)) {
+ if (treedata_vert->tree && !bvhcache_has_tree(*em_bvh_cache, treedata_vert->tree)) {
free_bvhtree_from_editmesh(treedata_vert);
}
}
@@ -2220,7 +2227,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
MEM_freeN(verts_mask);
}
else {
- bvhtree_from_editmesh_verts(treedata_vert, em, 0.0f, 2, 6, &em_bvh_cache);
+ bvhtree_from_editmesh_verts(treedata_vert, em, 0.0f, 2, 6, em_bvh_cache);
}
}
}
@@ -2233,7 +2240,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
if (sctx->callbacks.edit_mesh.test_edge_fn == NULL) {
/* The tree is owned by the Mesh and may have been freed since we last used! */
- if (!bvhcache_has_tree(em_bvh_cache, treedata_edge->tree)) {
+ if (treedata_edge->tree && !bvhcache_has_tree(*em_bvh_cache, treedata_edge->tree)) {
free_bvhtree_from_editmesh(treedata_edge);
}
}
@@ -2255,7 +2262,7 @@ static short snapEditMesh(SnapObjectContext *sctx,
MEM_freeN(edges_mask);
}
else {
- bvhtree_from_editmesh_edges(treedata_edge, em, 0.0f, 2, 6, &em_bvh_cache);
+ bvhtree_from_editmesh_edges(treedata_edge, em, 0.0f, 2, 6, em_bvh_cache);
}
}
}