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
path: root/source
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2008-01-14 01:57:36 +0300
committerMartin Poirier <theeth@yahoo.com>2008-01-14 01:57:36 +0300
commit1f3dc315d542bcb831953b160e9a58a03ab2adf9 (patch)
treed72384524f6c143089bc7b6126149db84bc17f27 /source
parent1b6c8691fd793205b5a8bdb394ec9d115dccfcfc (diff)
Fix crash in previous commit for objects that don't have a boundbox.
In that case, the object's center is used.
Diffstat (limited to 'source')
-rw-r--r--source/blender/src/transform_snap.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/source/blender/src/transform_snap.c b/source/blender/src/transform_snap.c
index 3aeb90bee32..3279e6e6f09 100644
--- a/source/blender/src/transform_snap.c
+++ b/source/blender/src/transform_snap.c
@@ -555,14 +555,36 @@ void TargetSnapClosest(TransInfo *t)
for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++)
{
struct BoundBox *bb = object_get_boundbox(td->ob);
- int j;
- for (j = 0; j < 8; j++) {
+ /* use boundbox if possible */
+ if (bb)
+ {
+ int j;
+
+ for (j = 0; j < 8; j++) {
+ float loc[3];
+ float dist;
+
+ VECCOPY(loc, bb->vec[j]);
+ Mat4MulVecfl(td->ext->obmat, loc);
+
+ dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
+
+ if (closest == NULL || fabs(dist) < fabs(t->tsnap.dist))
+ {
+ VECCOPY(t->tsnap.snapTarget, loc);
+ closest = td;
+ t->tsnap.dist = dist;
+ }
+ }
+ }
+ /* use element center otherwise */
+ else
+ {
float loc[3];
float dist;
- VECCOPY(loc, bb->vec[j]);
- Mat4MulVecfl(td->ext->obmat, loc);
+ VECCOPY(loc, td->center);
dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);