From 6403858ad961935e4b60f044b6fef05eeaaff7d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Nov 2011 21:13:37 +0000 Subject: [PATCH] fix [#29111] Wrong application of delta scale apply delta scale as a multiplier & do-versions on existing files. - bumps subversion to 2.60.6 --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenkernel/intern/object.c | 9 ++++-- source/blender/blenloader/intern/readfile.c | 32 +++++++++++++++---- .../blender/editors/object/object_transform.c | 6 ++-- .../render/intern/source/convertblender.c | 2 +- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index fdd876ff29b..8738dc0830a 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 260 -#define BLENDER_SUBVERSION 5 +#define BLENDER_SUBVERSION 6 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0b0a0039501..887b8409e59 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -774,6 +774,7 @@ Object *add_only_object(int type, const char *name) ob->col[3]= 1.0; ob->size[0]= ob->size[1]= ob->size[2]= 1.0; + ob->dsize[0]= ob->dsize[1]= ob->dsize[2]= 1.0; /* objects should default to having Euler XYZ rotations, * but rotations default to quaternions @@ -1441,7 +1442,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) void object_scale_to_mat3(Object *ob, float mat[][3]) { float vec[3]; - add_v3_v3v3(vec, ob->size, ob->dsize); + mul_v3_v3v3(vec, ob->size, ob->dsize); size_to_mat3( mat,vec); } @@ -1603,7 +1604,11 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const } sub_v3_v3(ob->loc, ob->dloc); - sub_v3_v3(ob->size, ob->dsize); + + if (ob->dsize[0] != 0.0f) ob->size[0] /= ob->dsize[0]; + if (ob->dsize[1] != 0.0f) ob->size[1] /= ob->dsize[1]; + if (ob->dsize[2] != 0.0f) ob->size[2] /= ob->dsize[2]; + /* object_mat3_to_rot handles delta rotations */ } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 61d023d7fc0..7ebdff546e2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11967,7 +11967,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } - /* put compatibility code here until next subversion bump */ if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) { Object *ob; @@ -11984,8 +11983,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } - /* put compatibility code here until next subversion bump */ - if (main->versionfile < 256) { bScreen *sc; ScrArea *sa; @@ -12604,16 +12601,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } - /* put compatibility code here until next subversion bump */ + if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 6)) { Scene *sce; MovieClip *clip; bScreen *sc; for(sce = main->scene.first; sce; sce = sce->id.next) { - if (sce->r.im_format.depth == 0) { - do_versions_image_settings_2_60(sce); - } + do_versions_image_settings_2_60(sce); } for (clip= main->movieclip.first; clip; clip= clip->id.next) { @@ -12640,6 +12635,29 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + + { + Object *ob; + for (ob= main->object.first; ob; ob= ob->id.next) { + /* convert delta addition into delta scale */ + int i; + for (i= 0; i < 3; i++) { + if ( (ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */ + (ob->size[i] == 0.0f)) /* cant scale the dsize to give a non zero result, so fallback to 1.0f */ + { + ob->dsize[i]= 1.0f; + } + else { + ob->size[i]= (ob->size[i] + ob->dsize[i]) / ob->size[i]; + } + } + } + } + } + + /* put compatibility code here until next subversion bump */ + { + /* nothing! */ } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index e2039739be2..0d2b35eec02 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -188,15 +188,15 @@ static void object_clear_scale(Object *ob) { /* clear scale factors which are not locked */ if ((ob->protectflag & OB_LOCK_SCALEX)==0) { - ob->dsize[0]= 0.0f; + ob->dsize[0]= 1.0f; ob->size[0]= 1.0f; } if ((ob->protectflag & OB_LOCK_SCALEY)==0) { - ob->dsize[1]= 0.0f; + ob->dsize[1]= 1.0f; ob->size[1]= 1.0f; } if ((ob->protectflag & OB_LOCK_SCALEZ)==0) { - ob->dsize[2]= 0.0f; + ob->dsize[2]= 1.0f; ob->size[2]= 1.0f; } } diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 347efaab3ef..a3c452c7ea7 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -2391,7 +2391,7 @@ static void do_displacement(Render *re, ObjectRen *obr, float mat[][4], float im /* Object Size with parenting */ obt=obr->ob; while(obt){ - add_v3_v3v3(temp, obt->size, obt->dsize); + mul_v3_v3v3(temp, obt->size, obt->dsize); scale[0]*=temp[0]; scale[1]*=temp[1]; scale[2]*=temp[2]; obt=obt->parent; }