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:
authorMartin Poirier <theeth@yahoo.com>2007-03-24 16:38:50 +0300
committerMartin Poirier <theeth@yahoo.com>2007-03-24 16:38:50 +0300
commitd193ce012a8dc674211d9241213fbc16b7798303 (patch)
treeb921a1a9bede5c6567e73c1453bf92ab266b428f
parentf712172ac33778f1f7c57a5976975e20c9cc1015 (diff)
Followup to Bugfix #6435 by Ton.
Added sensible way in calculateTransformCenter to report an error (including empty selection).
-rwxr-xr-xsource/blender/include/BIF_transform.h7
-rwxr-xr-xsource/blender/src/transform.c20
-rw-r--r--source/blender/src/view.c1
3 files changed, 21 insertions, 7 deletions
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);
}