diff --git a/source/blender/include/BIF_transform.h b/source/blender/include/BIF_transform.h index 6d1b4e32658..3b5eeb6f35a 100755 --- a/source/blender/include/BIF_transform.h +++ b/source/blender/include/BIF_transform.h @@ -67,8 +67,11 @@ void initTransform(int mode, int context); void Transform(void); void Mirror(short mode); -/* Standalone call to get the transformation center corresponding to the current situation */ -void calculateTransformCenter(int centerMode, float *vec); +/* Standalone call to get the transformation center corresponding to the current situation + * returns 1 if successful, 0 otherwise (usually means there's no selection) + * (if 0 is returns, *vec is unmodified) + * */ +int calculateTransformCenter(int centerMode, float *vec); struct TransInfo; struct ScrArea; diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 7067d1e9003..3bd63fed07a 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -756,8 +756,9 @@ static void transformEvent(unsigned short event, short val) { } } -void calculateTransformCenter(int centerMode, float *vec) +int calculateTransformCenter(int centerMode, float *vec) { + int success = 1; checkFirstTime(); Trans.state = TRANS_RUNNING; @@ -772,15 +773,24 @@ void calculateTransformCenter(int centerMode, float *vec) Trans.around = centerMode; // override userdefined mode - calculateCenter(&Trans); - - // Copy center from constraint center. Transform center can be local - VECCOPY(vec, Trans.con.center); + if (Trans.total == 0) { + success = 0; + } + else { + success = 1; + + calculateCenter(&Trans); + // Copy center from constraint center. Transform center can be local + VECCOPY(vec, Trans.con.center); + } + postTrans(&Trans); /* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */ special_aftertrans_update(&Trans); + + return success; } void initTransform(int mode, int context) { diff --git a/source/blender/src/view.c b/source/blender/src/view.c index ad8aa2bd38a..ef6a589e541 100644 --- a/source/blender/src/view.c +++ b/source/blender/src/view.c @@ -578,6 +578,7 @@ void viewmove(int mode) VECCOPY(ofs, G.vd->ofs); + /* If there's no selection, obofs is unmodified, so <0,0,0> */ calculateTransformCenter(V3D_CENTROID, obofs); VecMulf(obofs, -1.0f); }