From 8582495c161076f6ee4cfa72afacee8af024b831 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 5 Dec 2011 07:56:31 +0000 Subject: [PATCH 01/73] Minor whitespace fixes --- extern/libmv/libmv-capi.cpp | 6 +++--- source/blender/blenkernel/intern/tracking.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp index ed89f8cbfb3..dd98d0828dc 100644 --- a/extern/libmv/libmv-capi.cpp +++ b/extern/libmv/libmv-capi.cpp @@ -132,7 +132,7 @@ libmv_RegionTracker *libmv_hybridRegionTrackerNew(int max_iterations, int half_w esm_region_tracker->min_determinant = 1e-4; libmv::BruteRegionTracker *brute_region_tracker = new libmv::BruteRegionTracker; - brute_region_tracker->half_window_size = half_window_size; + brute_region_tracker->half_window_size = half_window_size; libmv::HybridRegionTracker *hybrid_region_tracker = new libmv::HybridRegionTracker(brute_region_tracker, esm_region_tracker); @@ -494,7 +494,7 @@ double libmv_reporojectionErrorForTrack(libmv_Reconstruction *libmv_reconstructi { libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction; libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics; - libmv::vector markers = libmv_reconstruction->tracks.MarkersForTrack(track); + libmv::vector markers = libmv_reconstruction->tracks.MarkersForTrack(track); int num_reprojected = 0; double total_error = 0.0; @@ -678,7 +678,7 @@ void libmv_destroyFeatures(struct libmv_Features *libmv_features) /* ************ camera intrinsics ************ */ struct libmv_CameraIntrinsics *libmv_ReconstructionExtractIntrinsics(struct libmv_Reconstruction *libmv_Reconstruction) { - return (struct libmv_CameraIntrinsics *)&libmv_Reconstruction->intrinsics; + return (struct libmv_CameraIntrinsics *)&libmv_Reconstruction->intrinsics; } struct libmv_CameraIntrinsics *libmv_CameraIntrinsicsNew(double focal_length, double principal_x, double principal_y, diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 4b5dc917cb6..66c0c0265a1 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1145,7 +1145,7 @@ int BKE_tracking_next(MovieTrackingContext *context) if(!ibuf_new) return 0; - #pragma omp parallel for private(a) shared(ibuf_new, ok) if(map_size>1) + #pragma omp parallel for private(a) shared(ibuf_new, ok) if(map_size>1) for(a= 0; a Date: Mon, 5 Dec 2011 11:02:54 +0000 Subject: [PATCH 02/73] fix for dscale which was set to 0,0,0 from files saved between Nov 29 and Dec 4. --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenloader/intern/readfile.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 8738dc0830a..36e61c62069 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 6 +#define BLENDER_SUBVERSION 7 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e352e783c24..13e2ed49e6a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12642,6 +12642,18 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + /* sigh, this dscale vs dsize version patching was not done right, fix for fix, + * this intentionally checks an exact subversion, also note this was never in a release, + * at some point this could be removed. */ + else if (main->versionfile == 260 && main->subversionfile == 6) + { + Object *ob; + for (ob= main->object.first; ob; ob= ob->id.next) { + if (is_zero_v3(ob->dscale)) { + fill_vn_fl(ob->dscale, 3, 1.0f); + } + } + } /* put compatibility code here until next subversion bump */ { From c9eb206c060b3f2221b223b5cb0730e055c04bab Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Mon, 5 Dec 2011 13:36:41 +0000 Subject: [PATCH 03/73] Fix: Dynamic Paint sub-steps didn't work for constraint controlled brush objects. --- .../blender/blenkernel/intern/dynamicpaint.c | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 59139886fe6..b592e078db3 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -24,6 +24,7 @@ #include "BLI_utildefines.h" #include "DNA_anim_types.h" +#include "DNA_constraint_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_group_types.h" /*GroupObject*/ #include "DNA_material_types.h" @@ -39,6 +40,7 @@ #include "BKE_bvhutils.h" /* bvh tree */ #include "BKE_blender.h" #include "BKE_cdderivedmesh.h" +#include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_colortools.h" @@ -453,15 +455,35 @@ static void object_cacheIgnoreClear(Object *ob, int state) static void subframe_updateObject(Scene *scene, Object *ob, int flags, float frame) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint); + bConstraint *con; /* if other is dynamic paint canvas, dont update */ if (pmd && pmd->canvas) return; - /* if object has parent, update it too */ - if ((flags & UPDATE_PARENTS) && ob->parent) subframe_updateObject(scene, ob->parent, 0, frame); - if ((flags & UPDATE_PARENTS) && ob->track) subframe_updateObject(scene, ob->track, 0, frame); + /* if object has parents, update them too */ + if (flags & UPDATE_PARENTS) { + if (ob->parent) subframe_updateObject(scene, ob->parent, 0, frame); + if (ob->track) subframe_updateObject(scene, ob->track, 0, frame); + /* also update constraint targets */ + for (con = ob->constraints.first; con; con=con->next) { + bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + ListBase targets = {NULL, NULL}; + + if (cti && cti->get_constraint_targets) { + bConstraintTarget *ct; + cti->get_constraint_targets(con, &targets); + for (ct= targets.first; ct; ct= ct->next) { + if (ct->tar) + subframe_updateObject(scene, ct->tar, 0, frame); + } + /* free temp targets */ + if (cti->flush_constraint_targets) + cti->flush_constraint_targets(con, &targets, 0); + } + } + } /* for curve following objects, parented curve has to be updated too */ if(ob->type==OB_CURVE) { Curve *cu= ob->data; From 9cac9579aebf3d0c2a56052dd94b799d7925e48f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Dec 2011 14:01:57 +0000 Subject: [PATCH 04/73] Fix #29506: libmv build issues on freebsd, patch by Shane Ambler. --- extern/libmv/libmv/numeric/numeric.h | 2 +- .../libmv/tracking/brute_region_tracker.cc | 11 +- extern/libmv/third_party/glog/src/config.h | 2 + .../third_party/glog/src/config_freebsd.h | 161 ++++++++++++++++++ 4 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 extern/libmv/third_party/glog/src/config_freebsd.h diff --git a/extern/libmv/libmv/numeric/numeric.h b/extern/libmv/libmv/numeric/numeric.h index 21e0f067446..bb7f9b364ef 100644 --- a/extern/libmv/libmv/numeric/numeric.h +++ b/extern/libmv/libmv/numeric/numeric.h @@ -33,7 +33,7 @@ #include #include -#if _WIN32 || __APPLE__ +#if _WIN32 || __APPLE__ || __FreeBSD__ void static sincos (double x, double *sinx, double *cosx) { *sinx = sin(x); *cosx = cos(x); diff --git a/extern/libmv/libmv/tracking/brute_region_tracker.cc b/extern/libmv/libmv/tracking/brute_region_tracker.cc index c33432b7fd7..a416710ad2b 100644 --- a/extern/libmv/libmv/tracking/brute_region_tracker.cc +++ b/extern/libmv/libmv/tracking/brute_region_tracker.cc @@ -24,7 +24,7 @@ #include #endif -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__FreeBSD__) // Needed for memalign on Linux and _aligned_alloc on Windows. #ifdef FREE_WINDOWS /* make sure _aligned_malloc is included */ @@ -59,6 +59,15 @@ void *aligned_malloc(int size, int alignment) { // they work natively with SSE types with no further work. CHECK_EQ(alignment, 16); return malloc(size); +#elif __FreeBSD__ + void *result; + + if(posix_memalign(&result, alignment, size)) { + // non-zero means allocation error + // either no allocation or bad alignment value + return NULL; + } + return result; #else // This is for Linux. return memalign(alignment, size); #endif diff --git a/extern/libmv/third_party/glog/src/config.h b/extern/libmv/third_party/glog/src/config.h index 06ed686f87c..49c0d8905b0 100644 --- a/extern/libmv/third_party/glog/src/config.h +++ b/extern/libmv/third_party/glog/src/config.h @@ -4,6 +4,8 @@ /* Namespace for Google classes */ #ifdef __APPLE__ #include "config_mac.h" +#elif __FreeBSD__ + #include "config_freebsd.h" #elif __MINGW32__ #include "windows/config.h" #elif __GNUC__ diff --git a/extern/libmv/third_party/glog/src/config_freebsd.h b/extern/libmv/third_party/glog/src/config_freebsd.h new file mode 100644 index 00000000000..caaef9d998b --- /dev/null +++ b/extern/libmv/third_party/glog/src/config_freebsd.h @@ -0,0 +1,161 @@ +/* src/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Namespace for Google classes */ +#define GOOGLE_NAMESPACE google + +/* Define if you have the `dladdr' function */ +/* #undef HAVE_DLADDR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_EXECINFO_H 1 + +/* Define if you have the `fcntl' function */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GLOB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#define HAVE_LIBPTHREAD 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* define if you have google gflags library */ +#define HAVE_LIB_GFLAGS 1 + +/* define if you have google gmock library */ +/* #undef HAVE_LIB_GMOCK */ + +/* define if you have google gtest library */ +/* #undef HAVE_LIB_GTEST */ + +/* define if you have libunwind */ +/* #undef HAVE_LIB_UNWIND */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* define if the compiler implements namespaces */ +#define HAVE_NAMESPACES 1 + +/* Define if you have POSIX threads libraries and header files. */ +#define HAVE_PTHREAD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* define if the compiler implements pthread_rwlock_* */ +#define HAVE_RWLOCK 1 + +/* Define if you have the `sigaltstack' function */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYSCALL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UCONTEXT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UCONTEXT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* define if the compiler supports using expression for operator */ +#define HAVE_USING_OPERATOR 1 + +/* define if your compiler has __attribute__ */ +#define HAVE___ATTRIBUTE__ 1 + +/* define if your compiler has __builtin_expect */ +#define HAVE___BUILTIN_EXPECT 1 + +/* define if your compiler has __sync_val_compare_and_swap */ +/* #undef HAVE___SYNC_VAL_COMPARE_AND_SWAP */ + +/* Name of package */ +#define PACKAGE "glog" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "opensource@google.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "glog" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "glog 0.3.1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "glog" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.3.1" + +/* How to access the PC from a struct ucontext */ +/* #define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_RIP] */ + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +/* #undef PTHREAD_CREATE_JOINABLE */ + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 8 + +/* Define to 1 if you have the ANSI C header files. */ +/* #undef STDC_HEADERS */ + +#define STDC_HEADERS 1 +/* the namespace where STL code like vector<> is defined */ +#define STL_NAMESPACE std + +/* location of source code */ +#define TEST_SRC_DIR "." + +/* Version number of package */ +#define VERSION "0.3.1" + +/* Stops putting the code inside the Google namespace */ +#define _END_GOOGLE_NAMESPACE_ } + +/* Puts following code inside the Google namespace */ +#define _START_GOOGLE_NAMESPACE_ namespace google { + From a5434508ac871f76b6c12d528d5df8f903eda4b3 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 5 Dec 2011 15:32:17 +0000 Subject: [PATCH 05/73] Release Cycle: * BCon4: Release candidate, important bug fixes only! --- source/blender/blenkernel/BKE_blender.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 36e61c62069..257a550edb4 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -51,7 +51,7 @@ extern "C" { /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR a /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE beta +#define BLENDER_VERSION_CYCLE rc extern char versionstr[]; /* from blender.c */ From 72827ee53190d74ebaa083f2bb616d9bc4b2e078 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Dec 2011 15:57:57 +0000 Subject: [PATCH 06/73] Fix #29507: cycles rendering of metaball animations not working. --- source/blender/makesrna/intern/rna_object_api.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 5b8b9d9a6b2..a87d954046a 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -130,7 +130,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ case OB_MBALL: { /* metaballs don't have modifiers, so just convert to mesh */ - Object *basis_ob = find_basis_mball( sce, ob ); + Object *basis_ob = find_basis_mball(sce, ob); /* todo, re-generatre for render-res */ /* metaball_polygonize(scene, ob) */ @@ -138,7 +138,15 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ return NULL; /* only do basis metaball */ tmpmesh = add_mesh("Mesh"); - mball_to_mesh( &ob->disp, tmpmesh ); + + if(render) { + ListBase disp = {NULL, NULL}; + makeDispListMBall_forRender(sce, ob, &disp); + mball_to_mesh(&disp, tmpmesh); + freedisplist(&disp); + } + else + mball_to_mesh(&ob->disp, tmpmesh); break; } From c40d8921b8b61c0465a2fe9bca72dc418bf39c7d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Dec 2011 16:37:31 +0000 Subject: [PATCH 07/73] Fix #28107: save screenshot operator option to save full screen or only a single editor was not working. Solution is to take full screenshot and crop it on save. Also fixed screenshot showing popup menu used to execute operator. --- source/blender/editors/screen/screendump.c | 50 +++++++++++++------ source/blender/windowmanager/WM_api.h | 3 ++ source/blender/windowmanager/intern/wm_draw.c | 13 +++++ 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 7d0ec866456..7c76766affa 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -68,28 +68,20 @@ typedef struct ScreenshotData { unsigned int *dumprect; int dumpsx, dumpsy; + rcti crop; } ScreenshotData; /* get shot from frontbuffer */ -static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy, int fscreen) +static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy) { wmWindow *win= CTX_wm_window(C); - ScrArea *curarea= CTX_wm_area(C); int x=0, y=0; unsigned int *dumprect= NULL; - if(fscreen) { /* full screen */ - x= 0; - y= 0; - *dumpsx= win->sizex; - *dumpsy= win->sizey; - } - else { - x= curarea->totrct.xmin; - y= curarea->totrct.ymin; - *dumpsx= curarea->totrct.xmax-x; - *dumpsy= curarea->totrct.ymax-y; - } + x= 0; + y= 0; + *dumpsx= win->sizex; + *dumpsy= win->sizey; if (*dumpsx && *dumpsy) { @@ -108,15 +100,23 @@ static int screenshot_data_create(bContext *C, wmOperator *op) { unsigned int *dumprect; int dumpsx, dumpsy; + + /* do redraw so we don't show popups/menus */ + WM_redraw_windows(C); - dumprect= screenshot(C, &dumpsx, &dumpsy, RNA_boolean_get(op->ptr, "full")); + dumprect= screenshot(C, &dumpsx, &dumpsy); + if(dumprect) { ScreenshotData *scd= MEM_callocN(sizeof(ScreenshotData), "screenshot"); + ScrArea *sa= CTX_wm_area(C); scd->dumpsx= dumpsx; scd->dumpsy= dumpsy; scd->dumprect= dumprect; + if(sa) + scd->crop= sa->totrct; op->customdata= scd; + return TRUE; } else { @@ -137,6 +137,21 @@ static void screenshot_data_free(wmOperator *op) } } +static void screenshot_crop(ImBuf *ibuf, rcti crop) +{ + unsigned int *to= ibuf->rect; + unsigned int *from= ibuf->rect + crop.ymin*ibuf->x + crop.xmin; + int y, cropw= crop.xmax - crop.xmin, croph = crop.ymax - crop.ymin; + + if(cropw > 0 && croph > 0) { + for(y=0; yx) + memmove(to, from, sizeof(unsigned int)*cropw); + + ibuf->x= cropw; + ibuf->y= croph; + } +} + static int screenshot_exec(bContext *C, wmOperator *op) { ScreenshotData *scd= op->customdata; @@ -166,6 +181,10 @@ static int screenshot_exec(bContext *C, wmOperator *op) ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); ibuf->rect= scd->dumprect; + /* crop to show only single editor */ + if(!RNA_boolean_get(op->ptr, "full")) + screenshot_crop(ibuf, scd->crop); + BKE_write_ibuf(ibuf, path, &scene->r.im_format); IMB_freeImBuf(ibuf); @@ -213,7 +232,6 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); prop= RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); - RNA_def_property_flag(prop, PROP_HIDDEN); /* hide because once the file sel is displayed, the option no longer does anything */ } /* *************** screenshot movie job ************************* */ diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1d8161086b0..2c0e22337c0 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -331,6 +331,9 @@ void WM_progress_clear(struct wmWindow *win); void WM_console_toggle(struct bContext *C, short show); #endif + /* Draw (for screenshot) */ +void WM_redraw_windows(struct bContext *C); + /* debugging only, convenience function to write on crash */ int write_crash_blend(void); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 389049d9e59..f03680852ea 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -835,3 +835,16 @@ void wm_draw_region_clear(wmWindow *win, ARegion *ar) win->screen->do_draw= 1; } +void WM_redraw_windows(bContext *C) +{ + wmWindow *win_prev= CTX_wm_window(C); + ScrArea *area_prev= CTX_wm_area(C); + ARegion *ar_prev= CTX_wm_region(C); + + wm_draw_update(C); + + CTX_wm_window_set(C, win_prev); + CTX_wm_area_set(C, area_prev); + CTX_wm_region_set(C, ar_prev); +} + From 63ad25c30ddca609d39e3ae6288cdddeed7fb918 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Dec 2011 19:54:59 +0000 Subject: [PATCH 08/73] Cycles: Fix #29475: remove node from properties editor crash on windows. This was a bug in the UI code, which code access removed data. Fix OpenCL still being used in a case where Experimental was disabled. Fix msvc debug warning in md5 code. --- intern/cycles/blender/blender_sync.cpp | 7 ++++++- intern/cycles/util/util_md5.cpp | 5 +++-- source/blender/editors/interface/interface_handlers.c | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index f7b1ca53fd3..b89b7ebb9be 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -264,7 +264,12 @@ SessionParams BlenderSync::get_session_params(BL::Scene b_scene, bool background if(RNA_enum_get(&cscene, "device") != 0) { vector types = Device::available_types(); - DeviceType dtype = (RNA_enum_get(&cscene, "gpu_type") == 0)? DEVICE_CUDA: DEVICE_OPENCL; + DeviceType dtype; + + if(!experimental || RNA_enum_get(&cscene, "gpu_type") == 0) + dtype = DEVICE_CUDA; + else + dtype = DEVICE_CUDA; if(device_type_available(types, dtype)) params.device_type = dtype; diff --git a/intern/cycles/util/util_md5.cpp b/intern/cycles/util/util_md5.cpp index b871fad3636..25a77f18d02 100644 --- a/intern/cycles/util/util_md5.cpp +++ b/intern/cycles/util/util_md5.cpp @@ -361,14 +361,15 @@ void MD5Hash::finish(uint8_t digest[16]) string MD5Hash::get_hex() { uint8_t digest[16]; - char buf[16*2]; + char buf[16*2+1]; finish(digest); for(int i=0; i<16; i++) sprintf(buf + i*2, "%02X", digest[i]); + buf[sizeof(buf)-1] = '\0'; - return string(buf, sizeof(buf)); + return string(buf); } CCL_NAMESPACE_END diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index c24d07f73b9..c6159487145 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5241,9 +5241,10 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s data->state= state; - if(state != BUTTON_STATE_EXIT) { + if(!ELEM(state, BUTTON_STATE_EXIT, BUTTON_STATE_HIGHLIGHT)) { /* When objects for eg. are removed, running ui_check_but() - * can access the removed data - so disable update on exit */ + * can access the removed data - so disable update on exit + * or highlight */ ui_check_but(but); } From b44c82b4fdf4db3ce9935d46bc6feeab6319a104 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Dec 2011 22:19:30 +0000 Subject: [PATCH 09/73] remove invalid NULL checks from own recent commit and minor pep8 edits. --- intern/cycles/blender/addon/ui.py | 1 + .../startup/bl_operators/object_randomize_transform.py | 9 +++++++-- release/scripts/startup/bl_ui/properties_texture.py | 2 +- source/blender/editors/screen/screendump.c | 4 +--- source/blender/editors/space_view3d/drawobject.c | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index d23347b937d..d631158f5eb 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -725,6 +725,7 @@ def draw_device(self, context): if experimental and cscene.device == 'CPU' and engine.with_osl(): layout.prop(cscene, "shading_system") + def draw_pause(self, context): layout = self.layout scene = context.scene diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index 965231218a4..63c5fa11917 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -62,7 +62,9 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): else: org_sca_x, org_sca_y, org_sca_z = obj.scale - sca_x, sca_y, sca_z = uniform(-scale[0]+2, scale[0]), uniform(-scale[1]+2, scale[1]), uniform(-scale[2]+2, scale[2]) + sca_x, sca_y, sca_z = (uniform(-scale[0] + 2.0, scale[0]), + uniform(-scale[1] + 2.0, scale[1]), + uniform(-scale[2] + 2.0, scale[2])) if scale_even: aX = sca_x * org_sca_x @@ -81,7 +83,10 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): uniform(0.0, 0.0), uniform(0.0, 0.0), uniform(0.0, 0.0) -from bpy.props import IntProperty, BoolProperty, FloatProperty, FloatVectorProperty +from bpy.props import (IntProperty, + BoolProperty, + FloatProperty, + FloatVectorProperty) class RandomizeLocRotSize(Operator): diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index d16b2f15f52..358f1e12239 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -166,7 +166,7 @@ class TEXTURE_PT_preview(TextureButtonsPanel, Panel): layout.template_preview(tex, parent=idblock, slot=slot) else: layout.template_preview(tex, slot=slot) - + #Show Alpha Button for Brush Textures, see #29502 if context.space_data.texture_context == 'BRUSH': layout.prop(tex, "use_preview_alpha") diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 7c76766affa..31aab956754 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -218,8 +218,6 @@ static int screenshot_cancel(bContext *UNUSED(C), wmOperator *op) void SCREEN_OT_screenshot(wmOperatorType *ot) { - PropertyRNA *prop; - ot->name= "Save Screenshot"; /* weak: opname starting with 'save' makes filewindow give save-over */ ot->idname= "SCREEN_OT_screenshot"; @@ -231,7 +229,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) ot->flag= 0; WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); - prop= RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); + RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); } /* *************** screenshot movie job ************************* */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 547d89cd1a2..9505ea5098d 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2986,7 +2986,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D int /* totvert,*/ totedge, totface; DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask); ModifierData *md = NULL; - const short is_obact= (ob != NULL && ob == OBACT); + const short is_obact= (ob == OBACT); int draw_flags = (is_obact && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0; if(!dm) @@ -6108,7 +6108,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) int /*sel, drawtype,*/ colindex= 0; int i, selstart, selend, empty_object=0; short dt, dtx, zbufoff= 0; - const short is_obact= (ob != NULL && ob == OBACT); + const short is_obact= (ob == OBACT); /* only once set now, will be removed too, should become a global standard */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); From 04464c6cf99b1a9a0cce6d16d5f9e0cc2c0a33e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 5 Dec 2011 23:05:16 +0000 Subject: [PATCH 10/73] more minor py edits --- .../startup/bl_operators/object_randomize_transform.py | 1 - release/scripts/startup/bl_ui/properties_render.py | 4 ++-- release/scripts/startup/bl_ui/space_clip.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index 63c5fa11917..f0d2448b508 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -85,7 +85,6 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): from bpy.props import (IntProperty, BoolProperty, - FloatProperty, FloatVectorProperty) diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index d5350e81a88..4b4c2d2b214 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -453,7 +453,7 @@ class RENDER_PT_output(RenderButtonsPanel, Panel): rd = context.scene.render image_settings = rd.image_settings - file_format = rd.image_settings.file_format + file_format = image_settings.file_format layout.prop(rd, "filepath", text="") @@ -462,7 +462,7 @@ class RENDER_PT_output(RenderButtonsPanel, Panel): flow.prop(rd, "use_placeholder") flow.prop(rd, "use_file_extension") - layout.template_image_settings(rd.image_settings) + layout.template_image_settings(image_settings) if file_format == 'QUICKTIME_CARBON': layout.operator("scene.render_data_set_quicktime_codec") diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 5cdd1de547f..af2c6c792b5 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -156,7 +156,7 @@ class CLIP_PT_tools_tracking(Panel): def draw(self, context): layout = self.layout - clip = context.space_data.clip + # clip = context.space_data.clip # UNUSED row = layout.row(align=True) From 4b73f587eeae8713035efb780cb9a2d5362e4d98 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 Dec 2011 04:53:16 +0000 Subject: [PATCH 11/73] attempt to fix defione for qtcreator project file and cycles define. --- build_files/cmake/cmake_qtcreator_project.py | 9 ++++++++- release/scripts/modules/bpy_extras/io_utils.py | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index 07ffa659437..8cabc75e426 100755 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -47,6 +47,13 @@ import os import sys +def quote_define(define): + if " " in define.strip(): + return '"%s"' % define + else: + return define + + def create_qtc_project_main(): files = list(source_list(SOURCE_DIR, filename_check=is_project_file)) files_rel = [os.path.relpath(f, start=PROJECT_DIR) for f in files] @@ -99,7 +106,7 @@ def create_qtc_project_main(): qtc_cfg = os.path.join(PROJECT_DIR, "%s.config" % FILE_NAME) f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") - defines_final = [("#define %s %s" % item) for item in defines] + defines_final = [("#define %s %s" % (item[0], quote_define(item[1]))) for item in defines] if sys.platform != "win32": defines_final += cmake_compiler_defines() f.write("\n".join(defines_final)) diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index 3d71feaf79e..90f0d3f1c1d 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -269,8 +269,6 @@ def axis_conversion_ensure(operator, forward_attr, up_attr): return axis_forward, axis_up - change = False - axis = getattr(operator, forward_attr), getattr(operator, up_attr) axis_new = validate(*axis) From 3b1e077b397130c4f663161a9b6ce235fa418b8a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 6 Dec 2011 09:23:35 +0000 Subject: [PATCH 12/73] Camera tracking: fixed typo in remove tracking preset button --- release/scripts/startup/bl_ui/space_clip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index af2c6c792b5..39b78ce8cdc 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -114,7 +114,7 @@ class CLIP_PT_tools_marker(Panel): row.menu('CLIP_MT_tracking_settings_presets', text=label) row.operator("clip.tracking_settings_preset_add", text="", icon='ZOOMIN') - props = row.operator("clip.track_color_preset_add", + props = row.operator("clip.tracking_settings_preset_add", text="", icon='ZOOMOUT') props.remove_active = True From fca9c231a0a798bbb0ba2f65c61adcc668f93eb1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 6 Dec 2011 12:04:39 +0000 Subject: [PATCH 13/73] Fixed crash when movie clip curves region is opened and clip is getting unlinked --- source/blender/editors/space_clip/clip_graph_draw.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 7b14783d4ca..5a904e0e9b6 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -235,6 +235,7 @@ static void draw_frame_curves(SpaceClip *sc) void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) { + MovieClip *clip= ED_space_clip(sc); View2D *v2d= &ar->v2d; View2DGrid *grid; short unitx= V2D_UNIT_FRAMESCALE, unity= V2D_UNIT_VALUES; @@ -244,11 +245,13 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); - if(sc->flag&SC_SHOW_GRAPH_TRACKS) - draw_tracks_curves(v2d, sc); + if(clip) { + if(sc->flag&SC_SHOW_GRAPH_TRACKS) + draw_tracks_curves(v2d, sc); - if(sc->flag&SC_SHOW_GRAPH_FRAMES) - draw_frame_curves(sc); + if(sc->flag&SC_SHOW_GRAPH_FRAMES) + draw_frame_curves(sc); + } /* current frame */ draw_graph_cfra(sc, ar, scene); From cd1e78f1b705c4fff3152d349534d25617877b9f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 Dec 2011 12:29:54 +0000 Subject: [PATCH 14/73] Cycles: scons cuda kernel compile now does one kernel at a time, to reduce memory usage. --- intern/cycles/kernel/SConscript | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/intern/cycles/kernel/SConscript b/intern/cycles/kernel/SConscript index c9beb3ad0ae..7749f94818e 100644 --- a/intern/cycles/kernel/SConscript +++ b/intern/cycles/kernel/SConscript @@ -34,6 +34,7 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']: # dependencies dependencies = ['kernel.cu'] + kernel.Glob('*.h') + kernel.Glob('../util/*.h') + kernel.Glob('svm/*.h') + last_cubin_file = None # add command for each cuda architecture for arch in cuda_archs: @@ -46,5 +47,10 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']: kernel_binaries.append(cubin_file) + # trick to compile one kernel at a time to reduce memory usage + if last_cubin_file: + kernel.Depends(cubin_file, last_cubin_file) + last_cubin_file = cubin_file + Return('kernel_binaries') From b264fea601ecffaa3fc8b55162186e0c1789a8e7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 6 Dec 2011 14:34:56 +0000 Subject: [PATCH 15/73] Fix #29511: Separate tool duplicates objects Do not register separate mesh operator so it can't be redone from operator redo panel. --- source/blender/editors/mesh/editmesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 159ef3a46c7..1477469ca85 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1575,7 +1575,7 @@ void MESH_OT_separate(wmOperatorType *ot) ot->poll= ED_operator_editmesh; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_UNDO; ot->prop= RNA_def_enum(ot->srna, "type", prop_separate_types, 0, "Type", ""); } From fc72660bedf306aacbf32917a176a7714076aaf6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 6 Dec 2011 15:32:10 +0000 Subject: [PATCH 16/73] Fix #27622: Sequencer Wipe Angle Incorrect Made wipe angle be real angle instead of making some ease effects which can be reached by animation curves. --- source/blender/blenkernel/intern/seqeffects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index e8e9c754806..718b3144677 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1581,7 +1581,7 @@ typedef struct WipeZone { static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo) { wipezone->flip = (wipe->angle < 0); - wipezone->angle = pow(fabsf(wipe->angle)/45.0f, log(xo)/M_LN2); + wipezone->angle = tan(DEG2RAD(fabsf(wipe->angle))); wipezone->xo = xo; wipezone->yo = yo; wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f)); From b7649ea7578e90a15a0584142c9a2720731eedfe Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 6 Dec 2011 16:00:57 +0000 Subject: [PATCH 17/73] Cycles / CUDA Kernel compile: * Added option "WITH_BF_CYCLES_CUDA_THREADED_COMPILE" for the people who have much RAM (8 or more) and can compile several kernels at the same time. If enabled, it uses the general BF_NUMJOBS flag. * The option is off per default. --- build_files/scons/tools/btools.py | 3 ++- intern/cycles/kernel/SConscript | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 98c1b74d5cc..05e28ab1813 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -157,7 +157,7 @@ def validate_arguments(args, bc): 'WITH_BF_JEMALLOC', 'WITH_BF_STATICJEMALLOC', 'BF_JEMALLOC', 'BF_JEMALLOC_INC', 'BF_JEMALLOC_LIBPATH', 'BF_JEMALLOC_LIB', 'BF_JEMALLOC_LIB_STATIC', 'BUILDBOT_BRANCH', 'WITH_BF_3DMOUSE', 'WITH_BF_STATIC3DMOUSE', 'BF_3DMOUSE', 'BF_3DMOUSE_INC', 'BF_3DMOUSE_LIB', 'BF_3DMOUSE_LIBPATH', 'BF_3DMOUSE_LIB_STATIC', - 'WITH_BF_CYCLES', 'WITH_BF_CYCLES_CUDA_BINARIES' 'BF_CYCLES_CUDA_NVCC', 'BF_CYCLES_CUDA_NVCC', + 'WITH_BF_CYCLES', 'WITH_BF_CYCLES_CUDA_BINARIES' 'BF_CYCLES_CUDA_NVCC', 'BF_CYCLES_CUDA_NVCC', 'WITH_BF_CYCLES_CUDA_THREADED_COMPILE', 'WITH_BF_OIIO', 'WITH_BF_STATICOIIO', 'BF_OIIO', 'BF_OIIO_INC', 'BF_OIIO_LIB', 'BF_OIIO_LIB_STATIC', 'BF_OIIO_LIBPATH', 'WITH_BF_BOOST', 'WITH_BF_STATICBOOST', 'BF_BOOST', 'BF_BOOST_INC', 'BF_BOOST_LIB', 'BF_BOOST_LIB_STATIC', 'BF_BOOST_LIBPATH' ] @@ -545,6 +545,7 @@ def read_opts(env, cfg, args): localopts.AddVariables( (BoolVariable('WITH_BF_CYCLES', 'Build with the Cycles engine', True)), (BoolVariable('WITH_BF_CYCLES_CUDA_BINARIES', 'Build with precompiled CUDA binaries', False)), + (BoolVariable('WITH_BF_CYCLES_CUDA_THREADED_COMPILE', 'Build several render kernels at once (using BF_NUMJOBS)', False)), ('BF_CYCLES_CUDA_NVCC', 'CUDA nvcc compiler path', ''), ('BF_CYCLES_CUDA_BINARIES_ARCH', 'CUDA architectures to compile binaries for', []), diff --git a/intern/cycles/kernel/SConscript b/intern/cycles/kernel/SConscript index 7749f94818e..eb99680efe4 100644 --- a/intern/cycles/kernel/SConscript +++ b/intern/cycles/kernel/SConscript @@ -46,11 +46,12 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']: kernel.Depends(cubin_file, dependencies) kernel_binaries.append(cubin_file) - - # trick to compile one kernel at a time to reduce memory usage - if last_cubin_file: - kernel.Depends(cubin_file, last_cubin_file) - last_cubin_file = cubin_file + + if not env['WITH_BF_CYCLES_CUDA_THREADED_COMPILE']: + # trick to compile one kernel at a time to reduce memory usage + if last_cubin_file: + kernel.Depends(cubin_file, last_cubin_file) + last_cubin_file = cubin_file Return('kernel_binaries') From b8cc575ee312ced934498663f85b7b6b7428cc14 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 Dec 2011 16:04:45 +0000 Subject: [PATCH 18/73] Fix related to #29513: materials using nodes will output passes from the active material node. This is a confusing system, but two features were missing from 2.4x that made this at least a bit more clear: * The top right icon in the node now shows brighter again for the active node. * Setting a material datablock in a node makes that node active. --- source/blender/editors/space_node/node_draw.c | 10 +++------- source/blender/makesrna/intern/rna_nodetree.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 02a8b5cc9fb..67b4c43343e 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -605,15 +605,11 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN iconofs= rct->xmax - 7.0f; if(node->typeinfo->flag & NODE_PREVIEW) { - int icon_id; + float alpha = (node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT))? 1.0f: 0.5f; - if(node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT)) - icon_id= ICON_MATERIAL; - else - icon_id= ICON_MATERIAL_DATA; iconofs-=iconbutw; - uiDefIconBut(node->block, LABEL, B_REDR, icon_id, iconofs, rct->ymax-NODE_DY, - iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); + uiDefIconBut(node->block, LABEL, B_REDR, ICON_MATERIAL, iconofs, rct->ymax-NODE_DY, + iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, alpha, ""); } if(node->type == NODE_GROUP) { diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 8e567d0ac70..c588dc9c8ac 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -365,6 +365,17 @@ static void rna_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr) node_update(bmain, scene, ntree, node); } +static void rna_Node_material_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNodeTree *ntree= (bNodeTree*)ptr->id.data; + bNode *node= (bNode*)ptr->data; + + if(node->id) + nodeSetActive(ntree, node); + + node_update(bmain, scene, ntree, node); +} + static void rna_NodeGroup_update(Main *bmain, Scene *scene, PointerRNA *ptr) { bNodeTree *ntree= (bNodeTree*)ptr->id.data; @@ -1119,7 +1130,7 @@ static void def_sh_material(StructRNA *srna) RNA_def_property_struct_type(prop, "Material"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Material", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_material_update"); prop = RNA_def_property(srna, "use_diffuse", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_DIFF); From 6f7ae034fd40a29e23fd02b1e8d034222f45643c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Dec 2011 00:36:57 +0000 Subject: [PATCH 19/73] fix for noise module in driver namespace (was infact mathutils). --- source/blender/makesdna/DNA_object_types.h | 2 +- source/blender/python/intern/bpy_driver.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index e4237197fca..8707ae038c3 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -219,7 +219,7 @@ typedef struct Object { ListBase controllers; /* game logic controllers */ ListBase actuators; /* game logic actuators */ - float bbsize[3]; + float bbsize[3] DNA_DEPRECATED; short index; /* custom index, for renderpasses */ unsigned short actdef; /* current deformation group, note: index starts at 1 */ float col[4]; /* object color */ diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 34270c832ea..db408374b7f 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -82,9 +82,10 @@ int bpy_pydriver_create_dict(void) } /* add noise to global namespace */ - mod= PyImport_ImportModuleLevel((char *)"mathutils.noise", NULL, NULL, NULL, 0); + mod= PyImport_ImportModuleLevel((char *)"mathutils", NULL, NULL, NULL, 0); if (mod) { - PyDict_SetItemString(bpy_pydriver_Dict, "noise", mod); + PyObject *modsub= PyDict_GetItemString(PyModule_GetDict(mod), "noise"); + PyDict_SetItemString(bpy_pydriver_Dict, "noise", modsub); Py_DECREF(mod); } From 9d69115e9217c6b4de76efd3091934eaa255f012 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Dec 2011 07:13:33 +0000 Subject: [PATCH 20/73] fix for uninitialized memory use drawing 'nan' vertex groups, noticed while looking into [#29521] --- .../blender/blenkernel/intern/DerivedMesh.c | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 795b36813e1..5c80038a50d 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -60,6 +60,7 @@ #include "BKE_texture.h" #include "BKE_multires.h" #include "BKE_armature.h" +#include "BKE_deform.h" #ifdef WITH_GAMEENGINE #include "BKE_navmesh_conversion.h" @@ -625,40 +626,49 @@ void weight_to_rgb(float r_rgb[3], const float weight) r_rgb[1]= blend * (1.0f-((weight-0.75f)*4.0f)); r_rgb[2]= 0.0f; } + else { + /* exceptional value, unclamped or nan, + * avoid uninitialized memory use */ + r_rgb[0]= 1.0f; + r_rgb[1]= 0.0f; + r_rgb[2]= 1.0f; + } } /* draw_flag's for calc_weightpaint_vert_color */ enum { CALC_WP_MULTIPAINT= (1<<0), - CALC_WP_AUTO_NORMALIZE= (1<<1), + CALC_WP_AUTO_NORMALIZE= (1<<1) }; static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col, char *dg_flags, int selected, int UNUSED(unselected), const int draw_flag) { Mesh *me = ob->data; - float colf[4], input = 0.0f; - int i; - + float input = 0.0f; int make_black= FALSE; if (me->dvert) { + MDeformVert *dvert= &me->dvert[vert]; + if ((selected > 1) && (draw_flag & CALC_WP_MULTIPAINT)) { - int was_a_nonzero= FALSE; - for (i=0; idvert[vert].totweight; i++) { + int i; + + MDeformWeight *dw= dvert->dw; + for (i = dvert->totweight; i > 0; i--, dw++) { /* in multipaint, get the average if auto normalize is inactive * get the sum if it is active */ - if(dg_flags[me->dvert[vert].dw[i].def_nr]) { - if(me->dvert[vert].dw[i].weight) { - input+= me->dvert[vert].dw[i].weight; + if (dg_flags[dw->def_nr]) { + if (dw->weight) { + input += dw->weight; was_a_nonzero= TRUE; } } } /* make it black if the selected groups have no weight on a vertex */ - if(was_a_nonzero == FALSE) { + if (was_a_nonzero == FALSE) { make_black = TRUE; } else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) { @@ -667,11 +677,7 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u } else { /* default, non tricky behavior */ - for (i=0; idvert[vert].totweight; i++) { - if (me->dvert[vert].dw[i].def_nr==ob->actdef-1) { - input+=me->dvert[vert].dw[i].weight; - } - } + input= defvert_find_weight(dvert, ob->actdef-1); } } @@ -680,20 +686,23 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u col[2] = 0; col[1] = 0; col[0] = 255; - return; } + else { + float colf[4]; + CLAMP(input, 0.0f, 1.0f); - CLAMP(input, 0.0f, 1.0f); + colf[0]= colf[1]= colf[2]= -1; - if(coba) - do_colorband(coba, input, colf); - else - weight_to_rgb(colf, input); - - col[3] = (unsigned char)(colf[0] * 255.0f); - col[2] = (unsigned char)(colf[1] * 255.0f); - col[1] = (unsigned char)(colf[2] * 255.0f); - col[0] = 255; + if(coba) + do_colorband(coba, input, colf); + else + weight_to_rgb(colf, input); + + col[3] = (unsigned char)(colf[0] * 255.0f); + col[2] = (unsigned char)(colf[1] * 255.0f); + col[1] = (unsigned char)(colf[2] * 255.0f); + col[0] = 255; + } } static ColorBand *stored_cb= NULL; From c292bf18be49f7052b716e0eec1b25a87d117394 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Dec 2011 08:03:52 +0000 Subject: [PATCH 21/73] correct missing argument error if CYCLES_OPTIMIZED_KERNEL_FLAGS isnt set --- intern/cycles/kernel/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 601b95d262a..a0803f37cb9 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -129,7 +129,7 @@ include_directories(${INC}) add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_SVM_HEADERS}) if(WITH_CYCLES_OPTIMIZED_KERNEL) - SET_SOURCE_FILES_PROPERTIES(kernel_optimized.cpp PROPERTIES COMPILE_FLAGS ${CYCLES_OPTIMIZED_KERNEL_FLAGS}) + set_source_files_properties(kernel_optimized.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_OPTIMIZED_KERNEL_FLAGS}") endif() if(WITH_CYCLES_CUDA) From 2b49d0533817df05e829b3adc802a30b2234e49d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Dec 2011 09:13:15 +0000 Subject: [PATCH 22/73] fix for NULL pointer free and add in some checks, while looking into bug [#29521], add asserts so we know if an invalid active index is ever set. --- source/blender/editors/object/object_vgroup.c | 48 +++++++++++++------ .../editors/sculpt_paint/paint_vertex.c | 10 ++-- .../editors/space_outliner/outliner_select.c | 2 + 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 55d72bcf165..b809fd5dbb1 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1608,21 +1608,37 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v sel, sel_mirr, \ flip_map, flip_map_len, \ mirror_weights, flip_vgroups, \ - all_vgroups, act_vgroup \ + all_vgroups, def_nr \ ) EditVert *eve, *eve_mirr; MDeformVert *dvert, *dvert_mirr; short sel, sel_mirr; int *flip_map, flip_map_len; - const int act_vgroup= ob->actdef > 0 ? ob->actdef-1 : 0; + const int def_nr= ob->actdef-1; - if(mirror_weights==0 && flip_vgroups==0) + if ( (mirror_weights==0 && flip_vgroups==0) || + (BLI_findlink(&ob->defbase, def_nr) == NULL) ) + { return; + } - flip_map= all_vgroups ? - defgroup_flip_map(ob, &flip_map_len, FALSE) : - defgroup_flip_map_single(ob, &flip_map_len, FALSE, act_vgroup); + if (flip_vgroups) { + flip_map= all_vgroups ? + defgroup_flip_map(ob, &flip_map_len, FALSE) : + defgroup_flip_map_single(ob, &flip_map_len, FALSE, def_nr); + + BLI_assert(flip_map != NULL); + + if (flip_map == NULL) { + /* something went wrong!, possibly no groups */ + return; + } + } + else { + flip_map= NULL; + flip_map_len= 0; + } /* only the active group */ if(ob->type == OB_MESH) { @@ -1631,8 +1647,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v if (em) { if(!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT)) { - MEM_freeN(flip_map); - return; + goto cleanup; } EM_cache_x_mirror_vert(ob, em); @@ -1654,7 +1669,6 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v eve->tmp.v= eve_mirr->tmp.v= NULL; } } - BKE_mesh_end_editmesh(me, em); } else { @@ -1664,8 +1678,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0; if (me->dvert == NULL) { - MEM_freeN(flip_map); - return; + goto cleanup; } if (!use_vert_sel) { @@ -1712,8 +1725,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v if(lt->editlatt) lt= lt->editlatt->latt; if(lt->pntsu == 1 || lt->dvert == NULL) { - MEM_freeN(flip_map); - return; + goto cleanup; } /* unlike editmesh we know that by only looping over the first hald of @@ -1749,9 +1761,11 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v } } - MEM_freeN(flip_map); +cleanup: + if (flip_map) MEM_freeN(flip_map); #undef VGROUP_MIRR_OP + } static void vgroup_remap_update_users(Object *ob, int *map) @@ -2733,6 +2747,7 @@ static int set_active_group_exec(bContext *C, wmOperator *op) int nr= RNA_enum_get(op->ptr, "group"); ob->actdef= nr+1; + BLI_assert(ob->actdef >= 0); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob); @@ -2811,7 +2826,7 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) MDeformVert *dvert= NULL; bDeformGroup *def; int def_tot = BLI_countlist(&ob->defbase); - int *sort_map_update= MEM_mallocN(MAX_VGROUP_NAME * sizeof(int) * def_tot + 1, "sort vgroups"); /* needs a dummy index at the start*/ + int *sort_map_update= MEM_mallocN(sizeof(int) * (def_tot + 1), "sort vgroups"); /* needs a dummy index at the start*/ int *sort_map= sort_map_update + 1; char *name; int i; @@ -2820,6 +2835,8 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) for(def= ob->defbase.first, i=0; def; def=def->next, i++){ sort_map[i]= BLI_findstringindex(&ob->defbase, name, offsetof(bDeformGroup, name)); name += MAX_VGROUP_NAME; + + BLI_assert(sort_map[i] != -1); } if(ob->mode == OB_MODE_EDIT) { @@ -2861,6 +2878,7 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) vgroup_remap_update_users(ob, sort_map_update); ob->actdef= sort_map_update[ob->actdef]; + BLI_assert(ob->actdef >= 0); MEM_freeN(sort_map_update); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index a5bd38d6696..9cc81df6ce5 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1022,6 +1022,7 @@ static int weight_sample_group_exec(bContext *C, wmOperator *op) view3d_set_viewcontext(C, &vc); vc.obact->actdef= type + 1; + BLI_assert(vc.obact->actdef >= 0); DAG_id_tag_update(&vc.obact->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, vc.obact); @@ -1879,10 +1880,13 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED if(pchan) { bDeformGroup *dg= defgroup_find_name(ob, pchan->name); - if(dg==NULL) + if(dg==NULL) { dg= ED_vgroup_add_name(ob, pchan->name); /* sets actdef */ - else + } + else { ob->actdef= 1 + defgroup_find_index(ob, dg); + BLI_assert(ob->actdef >= 0); + } } } } @@ -1954,7 +1958,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P wpi.defbase_tot= wpd->defbase_tot; wpi.defbase_sel= MEM_mallocN(wpi.defbase_tot*sizeof(char), "wpi.defbase_sel"); wpi.defbase_tot_sel= get_selected_defgroups(ob, wpi.defbase_sel, wpi.defbase_tot); - if(wpi.defbase_tot_sel == 0 && ob->actdef) wpi.defbase_tot_sel = 1; + if(wpi.defbase_tot_sel == 0 && ob->actdef > 0) wpi.defbase_tot_sel = 1; wpi.defbase_tot_unsel= wpi.defbase_tot - wpi.defbase_tot_sel; wpi.vgroup_mirror= wpd->vgroup_mirror; wpi.lock_flags= wpd->lock_flags; diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index aa50b3d5154..89547edaafa 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -397,6 +397,8 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement * ob= (Object *)tselem->id; if(set) { ob->actdef= te->index+1; + BLI_assert(ob->actdef >= 0); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); } From 433033c2bf4b72e389d103e00a375d344588ac8e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 7 Dec 2011 09:21:50 +0000 Subject: [PATCH 23/73] Camera tracking: some bug fixes - Fixed bug with not putting disabled markers properly when doing backwards tracking - Fixed margin size calculating from pattern size which used to be double-sized and prevented to track things on the image edges. --- source/blender/blenkernel/intern/tracking.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 66c0c0265a1..043fabcd510 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1158,7 +1158,7 @@ int BKE_tracking_next(MovieTrackingContext *context) if(marker && (marker->flag&MARKER_DISABLED)==0) { #ifdef WITH_LIBMV int width, height, origin[2], tracked= 0, need_readjust= 0; - float pos[2], margin[2]; + float pos[2], margin[2], dim[2]; double x1, y1, x2, y2; ImBuf *ibuf= NULL; MovieTrackingMarker marker_new, *marker_keyed; @@ -1174,7 +1174,8 @@ int BKE_tracking_next(MovieTrackingContext *context) else nextfra= curfra+1; /* margin from frame boundaries */ - sub_v2_v2v2(margin, track->pat_max, track->pat_min); + sub_v2_v2v2(dim, track->pat_max, track->pat_min); + margin[0]= margin[1]= MAX2(dim[0], dim[1]) / 2.0f; margin[0]= MAX2(margin[0], (float)track->margin / ibuf_new->x); margin[1]= MAX2(margin[1], (float)track->margin / ibuf_new->y); @@ -1287,7 +1288,7 @@ int BKE_tracking_next(MovieTrackingContext *context) { /* check if there's no keyframe/tracked markers before tracking marker. if so -- create disabled marker before currently tracking "segment" */ - put_disabled_marker(track, marker, 1, 0); + put_disabled_marker(track, marker, !context->backwards, 0); } } @@ -1311,7 +1312,7 @@ int BKE_tracking_next(MovieTrackingContext *context) /* make currently tracked segment be finished with disabled marker */ #pragma omp critical { - put_disabled_marker(track, &marker_new, 0, 0); + put_disabled_marker(track, &marker_new, context->backwards, 0); } } else { marker_new= *marker; From d0c327c81c519aed6dcf19329c6e9daf0d87cc01 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 7 Dec 2011 09:55:37 +0000 Subject: [PATCH 24/73] Fix #29432: Marquee Select Bug Moved tweak threshold value to user preferences This threshold might be needed to be tweaked when working with tables, i.e. to prevent tap+slight movement be treated as tweak event. --- release/scripts/startup/bl_ui/space_userpref.py | 2 ++ source/blender/editors/interface/resources.c | 2 ++ source/blender/makesdna/DNA_userdef_types.h | 4 +++- source/blender/makesrna/intern/rna_userdef.c | 5 +++++ source/blender/windowmanager/intern/wm_gesture.c | 3 +-- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index d71d57509c1..df8c085d77e 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -889,6 +889,8 @@ class USERPREF_PT_input(Panel, InputKeyMapPanel): sub.label(text="NDOF Device:") sub.prop(inputs, "ndof_sensitivity", text="NDOF Sensitivity") + col.prop(inputs, "tweak_threshold") + row.separator() def draw(self, context): diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index dee945ecd7d..c3fe50edcd3 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1715,6 +1715,8 @@ void init_userdef_do_versions(void) U.ndof_flag = NDOF_LOCK_HORIZON | NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE; } + if (U.tweak_threshold == 0 ) + U.tweak_threshold= 10; /* funny name, but it is GE stuff, moves userdef stuff to engine */ // XXX space_set_commmandline_options(); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 4f6c7e22f5e..851d4b562e6 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -408,7 +408,9 @@ typedef struct UserDef { struct ColorBand coba_weight; /* from texture.h */ float sculpt_paint_overlay_col[3]; - int pad3; + + short tweak_threshold; + short pad3; char author[80]; /* author name for file formats supporting it */ } UserDef; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 0ea6b902150..f9b20d3ac78 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2929,6 +2929,11 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_range(prop, 3, 40); RNA_def_property_ui_text(prop, "Drag Threshold", "Amount of pixels you have to drag before dragging UI items happens"); + prop= RNA_def_property(srna, "tweak_threshold", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "tweak_threshold"); + RNA_def_property_range(prop, 3, 1024); + RNA_def_property_ui_text(prop, "Tweak Threshold", "Number of pixels you have to drag before tweak event is triggered"); + /* 3D mouse settings */ /* global options */ prop= RNA_def_property(srna, "ndof_sensitivity", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index ef463989c64..4fb8751de69 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -124,14 +124,13 @@ void WM_gestures_remove(bContext *C) /* tweak and line gestures */ -#define TWEAK_THRESHOLD 10 int wm_gesture_evaluate(wmGesture *gesture) { if(gesture->type==WM_GESTURE_TWEAK) { rcti *rect= gesture->customdata; int dx= rect->xmax - rect->xmin; int dy= rect->ymax - rect->ymin; - if(ABS(dx)+ABS(dy) > TWEAK_THRESHOLD) { + if(ABS(dx)+ABS(dy) > U.tweak_threshold) { int theta= (int)floor(4.0f*atan2f((float)dy, (float)dx)/(float)M_PI + 0.5f); int val= EVT_GESTURE_W; From 62fc8f5197eb4b4eaf69a7f193d8587e296fcadb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 7 Dec 2011 10:01:39 +0000 Subject: [PATCH 25/73] Make Hybrid tracker default for movie clips --- source/blender/blenkernel/intern/tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 043fabcd510..e3284b46e8e 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -76,7 +76,7 @@ void BKE_tracking_init_settings(MovieTracking *tracking) tracking->camera.pixel_aspect= 1.0f; tracking->camera.units= CAMERA_UNITS_MM; - tracking->settings.default_tracker= TRACKER_KLT; + tracking->settings.default_tracker= TRACKER_HYBRID; tracking->settings.default_pyramid_levels= 2; tracking->settings.default_minimum_correlation= 0.75; tracking->settings.default_pattern_size= 11; From 91796ab6301c6d7c017a2086522015a0db6a2cec Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 7 Dec 2011 10:53:51 +0000 Subject: [PATCH 26/73] Tracks which were moved to close to boundary weren'haven't been disabled when doing frame-by-frame tracking. --- source/blender/blenkernel/intern/tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index e3284b46e8e..9044661f369 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1282,7 +1282,7 @@ int BKE_tracking_next(MovieTrackingContext *context) } coords_correct= !isnan(x2) && !isnan(y2) && finite(x2) && finite(y2); - if(coords_correct && (tracked || !context->disable_failed)) { + if(coords_correct && !onbound && (tracked || !context->disable_failed)) { if(context->first_time) { #pragma omp critical { From f96ac8c335e1bd535111a0ab7d81c8d774fc677b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Dec 2011 11:22:29 +0000 Subject: [PATCH 27/73] Fix #29518: uv cylinder/sphere unwrap from menu didn't work same as using U key menu. --- release/scripts/startup/bl_ui/space_view3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index ce0d56b9fca..5444ad327a9 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -255,7 +255,7 @@ class VIEW3D_MT_uv_map(Menu): layout.separator() - layout.operator_context = 'EXEC_DEFAULT' + layout.operator_context = 'EXEC_REGION_WIN' layout.operator("uv.cube_project") layout.operator("uv.cylinder_project") layout.operator("uv.sphere_project") From 11bacd403f16818023229bcebd22d609054eda16 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Dec 2011 11:29:24 +0000 Subject: [PATCH 28/73] Fix #29523: RenderEngine.update_progress() doesn't redraw UI. --- source/blender/editors/render/render_internal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index dbd1e27024e..8a580627da3 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -378,8 +378,12 @@ static void render_progress_update(void *rjv, float progress) { RenderJob *rj= rjv; - if(rj->progress) + if(rj->progress && *rj->progress != progress) { *rj->progress = progress; + + /* make jobs timer to send notifier */ + *(rj->do_update)= 1; + } } static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect) From d568f56f181d21869e86511d9cc5502d1f312a79 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 7 Dec 2011 14:54:03 +0000 Subject: [PATCH 29/73] Merging remained part of hybrid tracker which adds correlation threshold Keir's comment: Add support for detecting tracking failure in the ESM tracker component of libmv. Since both KLT and Hybrid rely on ESM underneath, KLT and Hybrid now have a minimum correlation setting to match. With this fix, track failures should get detected quicker, with the issue that sometimes the tracker will give up too easily. That is fixable by reducing the required correlation (in the track properties). Command used for merge: svn merge -r 42396:42397 -r 42399:42400 ^/branches/soc-2011-tomato --- extern/libmv/libmv-capi.cpp | 6 ++-- extern/libmv/libmv-capi.h | 4 +-- .../libmv/tracking/esm_region_tracker.cc | 28 ++++++++++++++++--- .../libmv/libmv/tracking/esm_region_tracker.h | 4 ++- release/scripts/startup/bl_ui/space_clip.py | 6 ++-- source/blender/blenkernel/intern/tracking.c | 5 ++-- 6 files changed, 37 insertions(+), 16 deletions(-) diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp index dd98d0828dc..1835c53b53f 100644 --- a/extern/libmv/libmv-capi.cpp +++ b/extern/libmv/libmv-capi.cpp @@ -111,12 +111,13 @@ void libmv_setLoggingVerbosity(int verbosity) /* ************ RegionTracker ************ */ -libmv_RegionTracker *libmv_pyramidRegionTrackerNew(int max_iterations, int pyramid_level, int half_window_size) +libmv_RegionTracker *libmv_pyramidRegionTrackerNew(int max_iterations, int pyramid_level, int half_window_size, double minimum_correlation) { libmv::EsmRegionTracker *esm_region_tracker = new libmv::EsmRegionTracker; esm_region_tracker->half_window_size = half_window_size; esm_region_tracker->max_iterations = max_iterations; esm_region_tracker->min_determinant = 1e-4; + esm_region_tracker->minimum_correlation = minimum_correlation; libmv::PyramidRegionTracker *pyramid_region_tracker = new libmv::PyramidRegionTracker(esm_region_tracker, pyramid_level); @@ -124,12 +125,13 @@ libmv_RegionTracker *libmv_pyramidRegionTrackerNew(int max_iterations, int pyram return (libmv_RegionTracker *)pyramid_region_tracker; } -libmv_RegionTracker *libmv_hybridRegionTrackerNew(int max_iterations, int half_window_size) +libmv_RegionTracker *libmv_hybridRegionTrackerNew(int max_iterations, int half_window_size, double minimum_correlation) { libmv::EsmRegionTracker *esm_region_tracker = new libmv::EsmRegionTracker; esm_region_tracker->half_window_size = half_window_size; esm_region_tracker->max_iterations = max_iterations; esm_region_tracker->min_determinant = 1e-4; + esm_region_tracker->minimum_correlation = minimum_correlation; libmv::BruteRegionTracker *brute_region_tracker = new libmv::BruteRegionTracker; brute_region_tracker->half_window_size = half_window_size; diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h index c5e61d69c56..e10d4ef842a 100644 --- a/extern/libmv/libmv-capi.h +++ b/extern/libmv/libmv-capi.h @@ -43,8 +43,8 @@ void libmv_startDebugLogging(void); void libmv_setLoggingVerbosity(int verbosity); /* RegionTracker */ -struct libmv_RegionTracker *libmv_pyramidRegionTrackerNew(int max_iterations, int pyramid_level, int half_window_size); -struct libmv_RegionTracker *libmv_hybridRegionTrackerNew(int max_iterations, int half_window_size); +struct libmv_RegionTracker *libmv_pyramidRegionTrackerNew(int max_iterations, int pyramid_level, int half_window_size, double minimum_correlation); +struct libmv_RegionTracker *libmv_hybridRegionTrackerNew(int max_iterations, int half_window_size, double minimum_correlation); int libmv_regionTrackerTrack(struct libmv_RegionTracker *libmv_tracker, const float *ima1, const float *ima2, int width, int height, double x1, double y1, double *x2, double *y2); void libmv_regionTrackerDestroy(struct libmv_RegionTracker *libmv_tracker); diff --git a/extern/libmv/libmv/tracking/esm_region_tracker.cc b/extern/libmv/libmv/tracking/esm_region_tracker.cc index 844b5ff3cb9..9784b61c068 100644 --- a/extern/libmv/libmv/tracking/esm_region_tracker.cc +++ b/extern/libmv/libmv/tracking/esm_region_tracker.cc @@ -273,10 +273,30 @@ bool EsmRegionTracker::Track(const FloatImage &image1, // If the step was accepted, then check for termination. if (d.squaredNorm() < min_update_squared_distance) { - if (new_error > reasonable_error) { - LG << "Update size shrank but reasonable error (" - << reasonable_error << ") not achieved; failing."; - return true; // XXX + // Compute the Pearson product-moment correlation coefficient to check + // for sanity. + // TODO(keir): Put this somewhere smarter. + double sX=0,sY=0,sXX=0,sYY=0,sXY=0; + for (int r = 0; r < width; ++r) { + for (int c = 0; c < width; ++c) { + double x = image_and_gradient1_sampled(r, c, 0); + double y = image_and_gradient2_sampled[new_image](r, c, 0); + sX += x; + sY += y; + sXX += x*x; + sYY += y*y; + sXY += x*y; + } + } + double N = width*width; + sX /= N, sY /= N, sXX /= N, sYY /= N, sXY /= N; + double correlation = (sXY-sX*sY)/sqrt(double((sXX-sX*sX)*(sYY-sY*sY))); + LG << "Final correlation: " << correlation; + + if (correlation < minimum_correlation) { + LG << "Correlation " << correlation << " greater than " + << minimum_correlation << "; bailing."; + return false; } LG << "Successful track in " << (i + 1) << " iterations."; return true; diff --git a/extern/libmv/libmv/tracking/esm_region_tracker.h b/extern/libmv/libmv/tracking/esm_region_tracker.h index c63417201ad..602b32f1675 100644 --- a/extern/libmv/libmv/tracking/esm_region_tracker.h +++ b/extern/libmv/libmv/tracking/esm_region_tracker.h @@ -38,7 +38,8 @@ struct EsmRegionTracker : public RegionTracker { max_iterations(16), min_determinant(1e-6), min_update_squared_distance(1e-4), - sigma(0.9) {} + sigma(0.9), + minimum_correlation(0.78) {} virtual ~EsmRegionTracker() {} @@ -54,6 +55,7 @@ struct EsmRegionTracker : public RegionTracker { double min_determinant; double min_update_squared_distance; double sigma; + double minimum_correlation; }; } // namespace libmv diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 39b78ce8cdc..d05c93ccfe1 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -129,8 +129,7 @@ class CLIP_PT_tools_marker(Panel): if settings.default_tracker == 'KLT': col.prop(settings, "default_pyramid_levels") - elif settings.default_tracker == 'SAD': - col.prop(settings, "default_correlation_min") + col.prop(settings, "default_correlation_min") col.separator() @@ -497,8 +496,7 @@ class CLIP_PT_track_settings(Panel): if active.tracker == 'KLT': col.prop(active, "pyramid_levels") - elif active.tracker == 'SAD': - col.prop(active, "correlation_min") + col.prop(active, "correlation_min") col.separator() col.prop(active, "frames_limit") diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 9044661f369..cacea980fe2 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -77,7 +77,6 @@ void BKE_tracking_init_settings(MovieTracking *tracking) tracking->camera.units= CAMERA_UNITS_MM; tracking->settings.default_tracker= TRACKER_HYBRID; - tracking->settings.default_pyramid_levels= 2; tracking->settings.default_minimum_correlation= 0.75; tracking->settings.default_pattern_size= 11; tracking->settings.default_search_size= 51; @@ -810,9 +809,9 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u int level= MIN2(track->pyramid_levels, max_pyramid_levels); if(track->tracker==TRACKER_KLT) - track_context.region_tracker= libmv_pyramidRegionTrackerNew(100, level, MAX2(wndx, wndy)); + track_context.region_tracker= libmv_pyramidRegionTrackerNew(100, level, MAX2(wndx, wndy), track->minimum_correlation); else - track_context.region_tracker= libmv_hybridRegionTrackerNew(100, MAX2(wndx, wndy)); + track_context.region_tracker= libmv_hybridRegionTrackerNew(100, MAX2(wndx, wndy), track->minimum_correlation); } else if(track->tracker==TRACKER_SAD) { track_context.pattern_size= MAX2(patx, paty); From 4e48c7d91df6aea65f59d770a0af2b07453afc88 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 7 Dec 2011 15:21:38 +0000 Subject: [PATCH 30/73] Fix [#29461] Selection-to-Cursor works strange with bones with TrackTo constraint. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In fact, the problem was present with any kind of constraint… We need the cursor coordinates in the rest bone space (aka armature space), i.e with all "manual" and "procedural" (constraints, ...) pose transforms cleared (as said in armature_mat_pose_to_bone: /* Remove the pchan's transforms from it's pose_mat. * This should leave behind the effects of restpose + * parenting + constraints */ , only "manual" transforms are "cleared" by armature_loc_pose_to_bone...). --- source/blender/editors/space_view3d/view3d_snap.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index b2707db806f..0b33ac0d3cd 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -641,16 +641,19 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) if(pchan->bone->layer & arm->layer) { if((pchan->bone->flag & BONE_CONNECTED)==0) { float curspn[3]; + float inv_restmat[4][4]; - /* get location of cursor in bone-space */ - armature_loc_pose_to_bone(pchan, cursp, curspn); + /* get location of cursor in *rest* bone-space */ + copy_v3_v3(curspn, cursp); + invert_m4_m4(inv_restmat, pchan->bone->arm_mat); + mul_m4_v3(inv_restmat, curspn); /* copy new position */ - if ((pchan->protectflag & OB_LOCK_LOCX)==0) + if ((pchan->protectflag & OB_LOCK_LOCX)==0) pchan->loc[0]= curspn[0]; - if ((pchan->protectflag & OB_LOCK_LOCY)==0) + if ((pchan->protectflag & OB_LOCK_LOCY)==0) pchan->loc[1]= curspn[1]; - if ((pchan->protectflag & OB_LOCK_LOCZ)==0) + if ((pchan->protectflag & OB_LOCK_LOCZ)==0) pchan->loc[2]= curspn[2]; /* auto-keyframing */ From 58528bca3662802d8b7aa5e9f5c7b2d3dce885ab Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 7 Dec 2011 15:55:37 +0000 Subject: [PATCH 31/73] =?UTF-8?q?More=20fix=20for=20snapto=20in=20Pose=20m?= =?UTF-8?q?ode:=20*=20The=20code=20for=20snap=20to=20grid=20was=20complete?= =?UTF-8?q?ly=20wrong=20(only=20x=20pos=20of=20chan=20was=20affected?= =?UTF-8?q?=E2=80=A6=20by=20z=20computed=20value!),=20and=20the=20same=20p?= =?UTF-8?q?roblem=20as=20with=20snap=20to=20cursor=20was=20present=20(usin?= =?UTF-8?q?g=20armature=5Floc=5Fpose=5Fto=5Fbone=20is=20wrong=20here).=20A?= =?UTF-8?q?lso,=20computing=20nearest=20grid=20point=20in=20world=20space!?= =?UTF-8?q?=20Else,=20it=20generally=20ends=20up=20completely=20out=20of?= =?UTF-8?q?=20grid,=20due=20to=20object=20transforms...=20*=20Small=20clea?= =?UTF-8?q?nup=20of=20code=20(uneeded=20vars=20and=20copying).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editors/space_view3d/view3d_snap.c | 90 +++++++++---------- 1 file changed, 42 insertions(+), 48 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 0b33ac0d3cd..ecb54c77e0c 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -91,9 +91,7 @@ static int tottrans= 0; /* copied from editobject.c, now uses (almost) proper depgraph */ static void special_transvert_update(Object *obedit) { - if(obedit) { - DAG_id_tag_update(obedit->data, 0); if(obedit->type==OB_MESH) { @@ -177,7 +175,7 @@ static void special_transvert_update(Object *obedit) } } } - if(arm->flag & ARM_MIRROR_EDIT) + if(arm->flag & ARM_MIRROR_EDIT) transform_armature_mirror_update(obedit); } else if(obedit->type==OB_LATTICE) { @@ -193,7 +191,7 @@ static void special_transvert_update(Object *obedit) /* mode flags: */ #define TM_ALL_JOINTS 1 /* all joints (for bones only) */ #define TM_SKIP_HANDLES 2 /* skip handles when control point is selected (for curves only) */ -static void make_trans_verts(Object *obedit, float *min, float *max, int mode) +static void make_trans_verts(Object *obedit, float *min, float *max, int mode) { Nurb *nu; BezTriple *bezt; @@ -278,7 +276,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) if ((tipsel && rootsel) || (rootsel)) { /* Don't add the tip (unless mode & TM_ALL_JOINTS, for getting all joints), * otherwise we get zero-length bones as tips will snap to the same - * location as heads. + * location as heads. */ if (rootok) { copy_v3_v3(tv->oldloc, ebo->head); @@ -296,7 +294,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) tv->flag= 1; tv++; tottrans++; - } + } } else if (tipsel) { copy_v3_v3(tv->oldloc, ebo->tail); @@ -306,7 +304,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) tv++; tottrans++; } - } + } } } else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { @@ -465,7 +463,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) if(obedit) { tottrans= 0; - if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) + if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) make_trans_verts(obedit, bmat[0], bmat[1], 0); if(tottrans==0) return OPERATOR_CANCELLED; @@ -474,7 +472,6 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) tv= transvmain; for(a=0; aloc); mul_m3_v3(bmat, vec); add_v3_v3(vec, obedit->obmat[3]); @@ -491,7 +488,6 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) MEM_freeN(transvmain); transvmain= NULL; - } else { struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID); @@ -501,34 +497,42 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) bPoseChannel *pchan; bArmature *arm= ob->data; + invert_m4_m4(ob->imat, ob->obmat); + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if(pchan->bone->flag & BONE_SELECTED) { if(pchan->bone->layer & arm->layer) { - if((pchan->bone->flag & BONE_CONNECTED)==0) { - float vecN[3], nLoc[3]; + if((pchan->bone->flag & BONE_CONNECTED)==0) { + float nLoc[3]; + float inv_restmat[4][4]; /* get nearest grid point to snap to */ copy_v3_v3(nLoc, pchan->pose_mat[3]); + /* We must operate in world space! */ + mul_m4_v3(ob->obmat, nLoc); vec[0]= gridf * (float)(floor(0.5f+ nLoc[0]/gridf)); vec[1]= gridf * (float)(floor(0.5f+ nLoc[1]/gridf)); vec[2]= gridf * (float)(floor(0.5f+ nLoc[2]/gridf)); + /* Back in object space... */ + mul_m4_v3(ob->imat, vec); - /* get bone-space location of grid point */ - armature_loc_pose_to_bone(pchan, vec, vecN); + /* get location of grid point in *rest* bone-space */ + invert_m4_m4(inv_restmat, pchan->bone->arm_mat); + mul_m4_v3(inv_restmat, vec); /* adjust location */ - if ((pchan->protectflag & OB_LOCK_LOCX)==0) - pchan->loc[0]= vecN[0]; - if ((pchan->protectflag & OB_LOCK_LOCY)==0) - pchan->loc[0]= vecN[1]; - if ((pchan->protectflag & OB_LOCK_LOCZ)==0) - pchan->loc[0]= vecN[2]; + if ((pchan->protectflag & OB_LOCK_LOCX)==0) + pchan->loc[0]= vec[0]; + if ((pchan->protectflag & OB_LOCK_LOCY)==0) + pchan->loc[1]= vec[1]; + if ((pchan->protectflag & OB_LOCK_LOCZ)==0) + pchan->loc[2]= vec[2]; /* auto-keyframing */ ED_autokeyframe_pchan(C, scene, ob, pchan, ks); } - /* if the bone has a parent and is connected to the parent, - * don't do anything - will break chain unless we do auto-ik. + /* if the bone has a parent and is connected to the parent, + * don't do anything - will break chain unless we do auto-ik. */ } } @@ -572,7 +576,6 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) { - /* identifiers */ ot->name= "Snap Selection to Grid"; ot->description= "Snap selected item(s) to nearest grid node"; @@ -603,7 +606,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) if(obedit) { tottrans= 0; - if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) + if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) make_trans_verts(obedit, bmat[0], bmat[1], 0); if(tottrans==0) return OPERATOR_CANCELLED; @@ -621,7 +624,6 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) MEM_freeN(transvmain); transvmain= NULL; - } else { struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID); @@ -630,37 +632,34 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) if(ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm= ob->data; - float cursp[3]; invert_m4_m4(ob->imat, ob->obmat); - copy_v3_v3(cursp, curs); - mul_m4_v3(ob->imat, cursp); + copy_v3_v3(vec, curs); + mul_m4_v3(ob->imat, vec); for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { if(pchan->bone->flag & BONE_SELECTED) { if(pchan->bone->layer & arm->layer) { - if((pchan->bone->flag & BONE_CONNECTED)==0) { - float curspn[3]; + if((pchan->bone->flag & BONE_CONNECTED)==0) { float inv_restmat[4][4]; /* get location of cursor in *rest* bone-space */ - copy_v3_v3(curspn, cursp); invert_m4_m4(inv_restmat, pchan->bone->arm_mat); - mul_m4_v3(inv_restmat, curspn); + mul_m4_v3(inv_restmat, vec); /* copy new position */ if ((pchan->protectflag & OB_LOCK_LOCX)==0) - pchan->loc[0]= curspn[0]; + pchan->loc[0]= vec[0]; if ((pchan->protectflag & OB_LOCK_LOCY)==0) - pchan->loc[1]= curspn[1]; + pchan->loc[1]= vec[1]; if ((pchan->protectflag & OB_LOCK_LOCZ)==0) - pchan->loc[2]= curspn[2]; + pchan->loc[2]= vec[2]; /* auto-keyframing */ ED_autokeyframe_pchan(C, scene, ob, pchan, ks); } - /* if the bone has a parent and is connected to the parent, - * don't do anything - will break chain unless we do auto-ik. + /* if the bone has a parent and is connected to the parent, + * don't do anything - will break chain unless we do auto-ik. */ } } @@ -704,7 +703,6 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot) { - /* identifiers */ ot->name= "Snap Selection to Cursor"; ot->description= "Snap selected item(s) to cursor"; @@ -741,7 +739,6 @@ static int snap_curs_to_grid(bContext *C, wmOperator *UNUSED(op)) void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot) { - /* identifiers */ ot->name= "Snap Cursor to Grid"; ot->description= "Snap cursor to nearest grid node"; @@ -806,7 +803,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) if(obedit) { tottrans=0; - if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) + if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS|TM_SKIP_HANDLES); if(tottrans==0) return OPERATOR_CANCELLED; @@ -884,10 +881,9 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot) { - /* identifiers */ ot->name= "Snap Cursor to Selected"; - ot->description= "Snap cursor to center of selected item(s)"; + ot->description= "Snap cursor to center of selected item(s)"; ot->idname= "VIEW3D_OT_snap_cursor_to_selected"; /* api callbacks */ @@ -935,7 +931,6 @@ static int snap_curs_to_active(bContext *C, wmOperator *UNUSED(op)) void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot) { - /* identifiers */ ot->name= "Snap Cursor to Active"; ot->description= "Snap cursor to active item"; @@ -969,13 +964,12 @@ static int snap_curs_to_center(bContext *C, wmOperator *UNUSED(op)) void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot) { - /* identifiers */ ot->name= "Snap Cursor to Center"; ot->description= "Snap cursor to the Center"; ot->idname= "VIEW3D_OT_snap_cursor_to_center"; - /* api callbacks */ + /* api callbacks */ ot->exec= snap_curs_to_center; ot->poll= ED_operator_view3d_active; @@ -993,7 +987,7 @@ int minmax_verts(Object *obedit, float *min, float *max) int a; tottrans=0; - if ELEM5(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE) + if ELEM5(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE) make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS); if(tottrans==0) return 0; @@ -1001,12 +995,12 @@ int minmax_verts(Object *obedit, float *min, float *max) copy_m3_m4(bmat, obedit->obmat); tv= transvmain; - for(a=0; aloc); mul_m3_v3(bmat, vec); add_v3_v3(vec, obedit->obmat[3]); add_v3_v3(centroid, vec); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, min, max); } MEM_freeN(transvmain); From d227471b72f6f20b35c8cfa5fc5cf7d264060838 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 7 Dec 2011 17:23:45 +0000 Subject: [PATCH 32/73] Fix #28663: All "unit" properties show a value of 0 (on WinXP&MinGW&scons) Use %g instead of %lg due to %g is supposed to be used for doubles and %lg confuses mingw at all --- source/blender/blenkernel/intern/unit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 616c27f6b0b..aa914998a72 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -494,7 +494,7 @@ static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pr len_name = strlen(replace_str); len_move= (len - (found_ofs+len_name)) + 1; /* 1+ to copy the string terminator */ - len_num= BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%lg"SEP_STR, unit->scalar/scale_pref); /* # removed later */ + len_num= BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%g"SEP_STR, unit->scalar/scale_pref); /* # removed later */ if(len_num > len_max) len_num= len_max; From 1b71790316ff3e2c3c4a5f472fd45304fee83886 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 7 Dec 2011 17:28:42 +0000 Subject: [PATCH 33/73] Update presets for tracking --- .../presets/tracking_settings/blurry_footage.py | 11 +++++++++++ .../presets/tracking_settings/blurry_movie.py | 11 ----------- release/scripts/presets/tracking_settings/default.py | 4 ++-- .../scripts/presets/tracking_settings/fast_motion.py | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 release/scripts/presets/tracking_settings/blurry_footage.py delete mode 100644 release/scripts/presets/tracking_settings/blurry_movie.py diff --git a/release/scripts/presets/tracking_settings/blurry_footage.py b/release/scripts/presets/tracking_settings/blurry_footage.py new file mode 100644 index 00000000000..c805301df78 --- /dev/null +++ b/release/scripts/presets/tracking_settings/blurry_footage.py @@ -0,0 +1,11 @@ +import bpy +settings = bpy.context.edit_movieclip.tracking.settings + +settings.default_tracker = 'Hybrid' +settings.default_pyramid_levels = 2 +settings.default_correlation_min = 0.75 +settings.default_pattern_size = 21 +settings.default_search_size = 100 +settings.default_frames_limit = 0 +settings.default_pattern_match = 'PREV_FRAME' +settings.default_margin = 0 diff --git a/release/scripts/presets/tracking_settings/blurry_movie.py b/release/scripts/presets/tracking_settings/blurry_movie.py deleted file mode 100644 index 8a503bec9bd..00000000000 --- a/release/scripts/presets/tracking_settings/blurry_movie.py +++ /dev/null @@ -1,11 +0,0 @@ -import bpy -settings = bpy.context.edit_movieclip.tracking.settings - -settings.default_tracker = 'KLT' -settings.default_pyramid_levels = 4 -settings.default_correlation_min = 0.75 -settings.default_pattern_size = 11 -settings.default_search_size = 202 -settings.default_frames_limit = 25 -settings.default_pattern_match = 'KEYFRAME' -settings.default_margin = 0 diff --git a/release/scripts/presets/tracking_settings/default.py b/release/scripts/presets/tracking_settings/default.py index 4b2d41bf292..3846f92d828 100644 --- a/release/scripts/presets/tracking_settings/default.py +++ b/release/scripts/presets/tracking_settings/default.py @@ -1,11 +1,11 @@ import bpy settings = bpy.context.edit_movieclip.tracking.settings -settings.default_tracker = 'KLT' +settings.default_tracker = 'Hybrid' settings.default_pyramid_levels = 2 settings.default_correlation_min = 0.75 settings.default_pattern_size = 11 -settings.default_search_size = 51 +settings.default_search_size = 61 settings.default_frames_limit = 0 settings.default_pattern_match = 'KEYFRAME' settings.default_margin = 0 diff --git a/release/scripts/presets/tracking_settings/fast_motion.py b/release/scripts/presets/tracking_settings/fast_motion.py index a3d382e6700..f99fd7f0c42 100644 --- a/release/scripts/presets/tracking_settings/fast_motion.py +++ b/release/scripts/presets/tracking_settings/fast_motion.py @@ -1,11 +1,11 @@ import bpy settings = bpy.context.edit_movieclip.tracking.settings -settings.default_tracker = 'KLT' +settings.default_tracker = 'Hybrid' settings.default_pyramid_levels = 2 -settings.default_correlation_min = 0.75 -settings.default_pattern_size = 11 -settings.default_search_size = 121 +settings.default_correlation_min = 0.7 +settings.default_pattern_size = 31 +settings.default_search_size = 300 settings.default_frames_limit = 0 -settings.default_pattern_match = 'KEYFRAME' -settings.default_margin = 0 +settings.default_pattern_match = 'PREV_FRAME' +settings.default_margin = 5 From 3637794436b6a37ae9447adbd9baaccc0add0823 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 Dec 2011 18:22:16 +0000 Subject: [PATCH 34/73] remove initilaizing weight collor with dummy value (from recent commit), harmless but not needed. --- source/blender/blenkernel/intern/DerivedMesh.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 5c80038a50d..1498a3b4cc0 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -641,7 +641,9 @@ enum { CALC_WP_AUTO_NORMALIZE= (1<<1) }; -static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col, char *dg_flags, int selected, int UNUSED(unselected), const int draw_flag) +static void calc_weightpaint_vert_color( + Object *ob, ColorBand *coba, int vert, unsigned char *col, + const char *dg_flags, int selected, int UNUSED(unselected), const int draw_flag) { Mesh *me = ob->data; float input = 0.0f; @@ -691,12 +693,8 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u float colf[4]; CLAMP(input, 0.0f, 1.0f); - colf[0]= colf[1]= colf[2]= -1; - - if(coba) - do_colorband(coba, input, colf); - else - weight_to_rgb(colf, input); + if(coba) do_colorband(coba, input, colf); + else weight_to_rgb(colf, input); col[3] = (unsigned char)(colf[0] * 255.0f); col[2] = (unsigned char)(colf[1] * 255.0f); From 5310ee5e2cd4c16ff9dbdc205db1404982ad1551 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 7 Dec 2011 18:51:43 +0000 Subject: [PATCH 35/73] Reorder options in refine menu + fixed typo Patch by Sebastian Koenig, thanks! --- source/blender/makesrna/intern/rna_tracking.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 5a2ef54cfc1..2fdf733752b 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -302,17 +302,17 @@ static void rna_def_trackingSettings(BlenderRNA *brna) static EnumPropertyItem refine_items[] = { {0, "NONE", 0, "Nothing", "Do not refine camera intrinsics"}, {REFINE_FOCAL_LENGTH, "FOCAL_LENGTH", 0, "Focal Length", "Refine focal length"}, + {REFINE_FOCAL_LENGTH|REFINE_RADIAL_DISTORTION_K1, "FOCAL_LENGTH_RADIAL_K1", 0, "Focal length, K1", "Refine focal length and radial distortion K1"}, {REFINE_FOCAL_LENGTH| - REFINE_PRINCIPAL_POINT, "FOCAL_LENGTH_PRINCIPAL_POINT", 0, "Focal Length, Optical Center", "Refine focal length and optical center"}, + REFINE_RADIAL_DISTORTION_K1| + REFINE_RADIAL_DISTORTION_K2, "FOCAL_LENGTH_RADIAL_K1_K2", 0, "Focal length, K1, K2", "Refine focal length and radial distortion K1 and K2"}, {REFINE_FOCAL_LENGTH| REFINE_PRINCIPAL_POINT| REFINE_RADIAL_DISTORTION_K1| REFINE_RADIAL_DISTORTION_K2, "FOCAL_LENGTH_PRINCIPAL_POINT_RADIAL_K1_K2", 0, "Focal Length, Optical Center, K1, K2", "Refine focal length, optical center and radial distortion K1 and K2"}, {REFINE_FOCAL_LENGTH| - REFINE_RADIAL_DISTORTION_K1| - REFINE_RADIAL_DISTORTION_K2, "FOCAL_LENGTH_RADIAL_K1_K2", 0, "Focal length, K1. K2", "Refine focal length and radial distortion K1 and K2"}, - {REFINE_FOCAL_LENGTH|REFINE_RADIAL_DISTORTION_K1, "FOCAL_LENGTH_RADIAL_K1", 0, "Focal length, K1", "Refine focal length and radial distortion K1"}, + REFINE_PRINCIPAL_POINT, "FOCAL_LENGTH_PRINCIPAL_POINT", 0, "Focal Length, Optical Center", "Refine focal length and optical center"}, {0, NULL, 0, NULL, NULL} }; From a5fb261016f0dd9a1393da4aadc76272a0c248b0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Dec 2011 22:03:49 +0000 Subject: [PATCH 36/73] Fix #29520: issue drawing with VBO + GLSL + alpha pass. Includes some refactoring to hopefully make alpha material drawing code more clear. --- .../blender/blenkernel/intern/cdderivedmesh.c | 7 +-- .../blender/editors/space_view3d/drawobject.c | 12 ++-- source/blender/gpu/GPU_draw.h | 2 +- source/blender/gpu/intern/gpu_draw.c | 57 ++++++++++++------- 4 files changed, 45 insertions(+), 33 deletions(-) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index aade98ec9da..d4d83fec0eb 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1243,11 +1243,8 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } } } - if(!dodraw) { - continue; - } - if( numdata != 0 ) { + if(dodraw && numdata != 0 ) { offset = 0; if(attribs.totorco) { copy_v3_v3((float *)&varray[elementsize*curface*3],(float *)attribs.orco.array[mface->v1]); @@ -1289,7 +1286,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } curface++; if(mface->v4) { - if( numdata != 0 ) { + if(dodraw && numdata != 0 ) { offset = 0; if(attribs.totorco) { copy_v3_v3((float *)&varray[elementsize*curface*3],(float *)attribs.orco.array[mface->v3]); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 9505ea5098d..f6f2c35163f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -265,7 +265,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID); } -static int check_material_alpha(Base *base, int glsl) +static int check_alpha_pass(Base *base) { if(base->flag & OB_FROMDUPLI) return 0; @@ -273,7 +273,7 @@ static int check_material_alpha(Base *base, int glsl) if(G.f & G_PICKSEL) return 0; - return (glsl || (base->object->dtx & OB_DRAWTRANSP)); + return (base->object->dtx & OB_DRAWTRANSP); } /***/ @@ -3294,7 +3294,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D Object *obedit= scene->obedit; Mesh *me= ob->data; EditMesh *em= me->edit_mesh; - int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha, i; + int do_alpha_after= 0, drawlinked= 0, retval= 0, glsl, check_alpha, i; /* If we are drawing shadows and any of the materials don't cast a shadow, * then don't draw the object */ @@ -3339,11 +3339,11 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */ if(me->totface<=4 || ED_view3d_boundbox_clip(rv3d, ob->obmat, (ob->bb)? ob->bb: me->bb)) { glsl = draw_glsl_material(scene, ob, v3d, dt); - check_alpha = check_material_alpha(base, glsl); + check_alpha = check_alpha_pass(base); if(dt==OB_SOLID || glsl) { GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, - (check_alpha)? &do_alpha_pass: NULL); + (check_alpha)? &do_alpha_after: NULL); } draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, flag); @@ -3355,7 +3355,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } /* GPU_begin_object_materials checked if this is needed */ - if(do_alpha_pass) { + if(do_alpha_after) { if(ob->dtx & OB_DRAWXRAY) { add_view3d_after(&v3d->afterdraw_xraytransp, base, flag); } diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index dc1f80ca903..f73bd402167 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -69,7 +69,7 @@ void GPU_state_print(void); * - after drawing, the material must be disabled again */ void GPU_begin_object_materials(struct View3D *v3d, struct RegionView3D *rv3d, - struct Scene *scene, struct Object *ob, int glsl, int *do_alpha_pass); + struct Scene *scene, struct Object *ob, int glsl, int *do_alpha_after); void GPU_end_object_materials(void); int GPU_enable_material(int nr, void *attribs); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index afd22fb70a0..3cd3cde8aad 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -942,7 +942,7 @@ static struct GPUMaterialState { GPUBlendMode *alphablend; GPUBlendMode alphablend_fixed[FIXEDMAT]; - int alphapass; + int use_alpha_pass, is_alpha_pass; int lastmatnr, lastretval; GPUBlendMode lastalphablend; @@ -993,7 +993,7 @@ static Material *gpu_active_node_material(Material *ma) return ma; } -void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, Object *ob, int glsl, int *do_alpha_pass) +void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, Object *ob, int glsl, int *do_alpha_after) { Material *ma; GPUMaterial *gpumat; @@ -1015,9 +1015,15 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O GMS.gviewmat= rv3d->viewmat; GMS.gviewinv= rv3d->viewinv; - GMS.alphapass = (v3d && v3d->transp); - if(do_alpha_pass) - *do_alpha_pass = 0; + /* alpha pass setup. there's various cases to handle here: + * object transparency on: only solid materials draw in the first pass, + and only transparent in the second 'alpha' pass. + * object transparency off: for glsl we draw both in a single pass, and + for solid we don't use transparency at all. */ + GMS.use_alpha_pass = (do_alpha_after != NULL); + GMS.is_alpha_pass = (v3d && v3d->transp); + if(GMS.use_alpha_pass) + *do_alpha_after = 0; if(GMS.totmat > FIXEDMAT) { GMS.matbuf= MEM_callocN(sizeof(GPUMaterialFixed)*GMS.totmat, "GMS.matbuf"); @@ -1064,20 +1070,23 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O /* fixed function opengl materials */ gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob, new_shading_nodes); - alphablend = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_BLEND_ALPHA; - if(do_alpha_pass && GMS.alphapass) + if(GMS.use_alpha_pass) { GMS.matbuf[a].diff[3]= ma->alpha; - else + alphablend = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_BLEND_ALPHA; + } + else { GMS.matbuf[a].diff[3]= 1.0f; + alphablend = GPU_BLEND_SOLID; + } } - /* setting do_alpha_pass = 1 indicates this object needs to be + /* setting do_alpha_after = 1 indicates this object needs to be * drawn in a second alpha pass for improved blending */ - if(do_alpha_pass) { - GMS.alphablend[a]= alphablend; - if(ELEM3(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ADD, GPU_BLEND_ALPHA_SORT) && !GMS.alphapass) - *do_alpha_pass= 1; - } + if(GMS.use_alpha_pass && !GMS.is_alpha_pass) + if(ELEM3(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ADD, GPU_BLEND_ALPHA_SORT)) + *do_alpha_after= 1; + + GMS.alphablend[a]= alphablend; } /* let's start with a clean state */ @@ -1122,20 +1131,26 @@ int GPU_enable_material(int nr, void *attribs) /* unbind glsl material */ if(GMS.gboundmat) { - if(GMS.alphapass) glDepthMask(0); + if(GMS.is_alpha_pass) glDepthMask(0); GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat)); GMS.gboundmat= NULL; } /* draw materials with alpha in alpha pass */ GMS.lastmatnr = nr; - GMS.lastretval = ELEM(GMS.alphablend[nr], GPU_BLEND_SOLID, GPU_BLEND_CLIP); - if(GMS.alphapass) - GMS.lastretval = !GMS.lastretval; + GMS.lastretval = 1; + + if(GMS.use_alpha_pass) { + GMS.lastretval = ELEM(GMS.alphablend[nr], GPU_BLEND_SOLID, GPU_BLEND_CLIP); + if(GMS.is_alpha_pass) + GMS.lastretval = !GMS.lastretval; + } + else + GMS.lastretval = !GMS.is_alpha_pass; if(GMS.lastretval) { /* for alpha pass, use alpha blend */ - alphablend = (GMS.alphapass)? GPU_BLEND_ALPHA: GPU_BLEND_SOLID; + alphablend = GMS.alphablend[nr]; if(gattribs && GMS.gmatbuf[nr]) { /* bind glsl material and get attributes */ @@ -1152,7 +1167,7 @@ int GPU_enable_material(int nr, void *attribs) if(mat->game.alpha_blend != GPU_BLEND_SOLID) alphablend= mat->game.alpha_blend; - if(GMS.alphapass) glDepthMask(1); + if(GMS.is_alpha_pass) glDepthMask(1); } else { /* or do fixed function opengl material */ @@ -1188,7 +1203,7 @@ void GPU_disable_material(void) GMS.lastretval= 1; if(GMS.gboundmat) { - if(GMS.alphapass) glDepthMask(0); + if(GMS.is_alpha_pass) glDepthMask(0); GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat)); GMS.gboundmat= NULL; } From 2b8249854499199299a4a067f9edfa691a14bbe9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Dec 2011 03:47:45 +0000 Subject: [PATCH 37/73] minor refactor of vertex group functions, - defvert_remove_index's index wasnt used anywhere, rename to defvert_remove_group - defvert_add_to_group was local in MOD_weightvg_util.c, moved to deform.c and renamed to defvert_add_index_notest real fix coming next... --- source/blender/blenkernel/BKE_deform.h | 3 +- source/blender/blenkernel/intern/deform.c | 87 +++++++++++-------- .../modifiers/intern/MOD_weightvg_util.c | 20 +---- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index ed8ea691134..b08afd9c475 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -52,7 +52,8 @@ void defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob); struct MDeformWeight *defvert_find_index(const struct MDeformVert *dv, const int defgroup); struct MDeformWeight *defvert_verify_index(struct MDeformVert *dv, const int defgroup); -void defvert_remove_index(struct MDeformVert *dvert, int defgroup, struct MDeformWeight *dw); +void defvert_add_index_notest(struct MDeformVert *dv, int defgroup, const float weight); +void defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw); float defvert_find_weight(const struct MDeformVert *dvert, const int defgroup); float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup); diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 1f09d98d697..8dfd7e25bfb 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -574,46 +574,61 @@ MDeformWeight *defvert_verify_index(MDeformVert *dvert, const int defgroup) return dw_new; } -/* Removes the given vertex from the vertex group, specified either by its defgrp_idx, - * or directly by its MDeformWeight pointer, if dw is not NULL. - * WARNING: This function frees the given MDeformWeight, do not use it afterward! */ -void defvert_remove_index(MDeformVert *dvert, int defgroup, MDeformWeight *dw) +/* TODO. merge with code above! */ + +/* Adds the given vertex to the specified vertex group, with given weight. + * warning, this does NOT check for existign, assume caller already knows its not there */ +void defvert_add_index_notest(MDeformVert *dvert, int defgroup, const float weight) { MDeformWeight *dw_new; - int i; - /* Get index of removed MDeformWeight. */ - if (dw == NULL) { - dw = dvert->dw; - for (i = dvert->totweight; i > 0; i--, dw++) { - if (dw->def_nr == defgroup) - break; - } - i--; - } - else { - i = dw - dvert->dw; - /* Security check! */ - if(i < 0 || i >= dvert->totweight) - return; - } + /* do this check always, this function is used to check for it */ + if (!dvert || defgroup < 0) + return; - dvert->totweight--; - /* If there are still other deform weights attached to this vert then remove - * this deform weight, and reshuffle the others. - */ - if (dvert->totweight) { - dw_new = MEM_mallocN(sizeof(MDeformWeight)*(dvert->totweight), __func__); - if (dvert->dw){ - memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*i); - memcpy(dw_new+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i)); - MEM_freeN(dvert->dw); - } - dvert->dw = dw_new; - } - else { - /* If there are no other deform weights left then just remove this one. */ + dw_new = MEM_callocN(sizeof(MDeformWeight)*(dvert->totweight+1), "defvert_add_to group, new deformWeight"); + if(dvert->dw) { + memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*dvert->totweight); MEM_freeN(dvert->dw); - dvert->dw = NULL; + } + dvert->dw = dw_new; + dw_new += dvert->totweight; + dw_new->weight = weight; + dw_new->def_nr = defgroup; + dvert->totweight++; +} + + +/* Removes the given vertex from the vertex group. + * WARNING: This function frees the given MDeformWeight, do not use it afterward! */ +void defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw) +{ + if (dvert && dw) { + MDeformWeight *dw_new; + int i = dw - dvert->dw; + + /* Security check! */ + if(i < 0 || i >= dvert->totweight) { + return; + } + + dvert->totweight--; + /* If there are still other deform weights attached to this vert then remove + * this deform weight, and reshuffle the others. + */ + if (dvert->totweight) { + dw_new = MEM_mallocN(sizeof(MDeformWeight)*(dvert->totweight), __func__); + if (dvert->dw){ + memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*i); + memcpy(dw_new+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i)); + MEM_freeN(dvert->dw); + } + dvert->dw = dw_new; + } + else { + /* If there are no other deform weights left then just remove this one. */ + MEM_freeN(dvert->dw); + dvert->dw = NULL; + } } } diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index e206000f41d..5631b7e716a 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -222,23 +222,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne } } -/* Adds the given vertex to the specified vertex group, with given weight. */ -static void defvert_add_to_group(MDeformVert *dv, int defgrp_idx, const float weight) -{ - /* TODO, move into deform.c as a generic function. This assumes the vertex - * groups have already been checked, so this has to remain low level. */ - MDeformWeight *newdw; - newdw = MEM_callocN(sizeof(MDeformWeight)*(dv->totweight+1), "defvert_add_to group, new deformWeight"); - if(dv->dw) { - memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight); - MEM_freeN(dv->dw); - } - dv->dw = newdw; - dv->dw[dv->totweight].weight = weight; - dv->dw[dv->totweight].def_nr = defgrp_idx; - dv->totweight++; -} /* Applies weights to given vgroup (defgroup), and optionnaly add/remove vertices from the group. @@ -264,7 +248,7 @@ void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, MDeformWeight **dws, /* If the vertex is in this vgroup, remove it if needed, or just update it. */ if(dw != NULL) { if(do_rem && w < rem_thresh) { - defvert_remove_index(dv, defgrp_idx, dw); + defvert_remove_group(dv, dw); } else { dw->weight = w; @@ -272,7 +256,7 @@ void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, MDeformWeight **dws, } /* Else, add it if needed! */ else if(do_add && w > add_thresh) { - defvert_add_to_group(dv, defgrp_idx, w); + defvert_add_index_notest(dv, defgrp_idx, w); } } } From 0feb2acd8a1deeb56c91723f557055ccd579ac0a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Dec 2011 04:51:03 +0000 Subject: [PATCH 38/73] regarding [#29521] Invalid Vertex Weights added checks to mesh.validate() so it checks for nan weights and negative groups which can crash blender. the file in the report looks to be corrupt, but this at least can make it load. also noticed validate was using isnan() and finite() were both used to check valid vertex locations, only finite is needed. --- source/blender/blenkernel/BKE_mesh.h | 8 ++- .../blender/blenkernel/intern/mesh_validate.c | 64 +++++++++++++++++-- 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 232aa46575e..3e2b2e47be5 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -145,7 +145,13 @@ int mesh_center_bounds(struct Mesh *me, float cent[3]); void mesh_translate(struct Mesh *me, float offset[3], int do_keys); /* mesh_validate.c */ -int BKE_mesh_validate_arrays(struct Mesh *me, struct MVert *mverts, unsigned int totvert, struct MEdge *medges, unsigned int totedge, struct MFace *mfaces, unsigned int totface, const short do_verbose, const short do_fixes); +int BKE_mesh_validate_arrays( + struct Mesh *me, + struct MVert *mverts, unsigned int totvert, + struct MEdge *medges, unsigned int totedge, + struct MFace *mfaces, unsigned int totface, + struct MDeformVert *dverts, /* assume totvert length */ + const short do_verbose, const short do_fixes); int BKE_mesh_validate(struct Mesh *me, int do_verbose); int BKE_mesh_validate_dm(struct DerivedMesh *dm); diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 4295133b469..c09e18e3ba0 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -45,6 +45,7 @@ #include "MEM_guardedalloc.h" #include "BKE_mesh.h" +#include "BKE_deform.h" #define SELECT 1 @@ -118,7 +119,12 @@ static int search_face_cmp(const void *v1, const void *v2) #define PRINT if(do_verbose) printf -int BKE_mesh_validate_arrays(Mesh *me, MVert *mverts, unsigned int totvert, MEdge *medges, unsigned int totedge, MFace *mfaces, unsigned int totface, const short do_verbose, const short do_fixes) +int BKE_mesh_validate_arrays( Mesh *me, + MVert *mverts, unsigned int totvert, + MEdge *medges, unsigned int totedge, + MFace *mfaces, unsigned int totface, + MDeformVert *dverts, /* assume totvert length */ + const short do_verbose, const short do_fixes) { # define REMOVE_EDGE_TAG(_med) { _med->v2= _med->v1; do_edge_free= 1; } # define REMOVE_FACE_TAG(_mf) { _mf->v3=0; do_face_free= 1; } @@ -157,7 +163,7 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *mverts, unsigned int totvert, MEdg int fix_normal= TRUE; for(j=0; j<3; j++) { - if(isnan(mvert->co[j]) || !finite(mvert->co[j])) { + if(!finite(mvert->co[j])) { PRINT(" vertex %u: has invalid coordinate\n", i); zero_v3(mvert->co); @@ -307,6 +313,43 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *mverts, unsigned int totvert, MEdg BLI_edgehash_free(edge_hash, NULL); MEM_freeN(sort_faces); + + /* fix deform verts */ + if (dverts) { + MDeformVert *dv; + for(i=0, dv= dverts; idw; + unsigned int j= 0; + + for(j=0, dw= dv->dw; j < dv->totweight; j++, dw++) { + /* note, greater then max defgroups is accounted for in our code, but not < 0 */ + if (!finite(dw->weight)) { + PRINT(" vertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight); + if (do_fixes) { + dw->weight= 0.0f; + } + } + + if (dw->def_nr < 0) { + PRINT(" vertex deform %u, has invalid group %d\n", i, dw->def_nr); + if (do_fixes) { + defvert_remove_group(dv, dw); + if (dv->dw) { + /* re-allocated, the new values compensate for stepping + * within the for loop and may not be valid */ + j--; + dw= dv->dw + j; + } + else { /* all freed */ + break; + } + } + } + } + } + } + + PRINT("BKE_mesh_validate: finished\n\n"); # undef REMOVE_EDGE_TAG @@ -357,7 +400,8 @@ static int mesh_validate_customdata(CustomData *data, short do_verbose, const sh #undef PRINT -static int BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata, CustomData *fdata, short do_verbose, const short do_fixes) +static int BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata, CustomData *fdata, + short do_verbose, const short do_fixes) { int vfixed= 0, efixed= 0, ffixed= 0; @@ -377,14 +421,24 @@ int BKE_mesh_validate(Mesh *me, int do_verbose) } layers_fixed= BKE_mesh_validate_all_customdata(&me->vdata, &me->edata, &me->fdata, do_verbose, TRUE); - arrays_fixed= BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface, do_verbose, TRUE); + arrays_fixed= BKE_mesh_validate_arrays(me, + me->mvert, me->totvert, + me->medge, me->totedge, + me->mface, me->totface, + me->dvert, + do_verbose, TRUE); return layers_fixed || arrays_fixed; } int BKE_mesh_validate_dm(DerivedMesh *dm) { - return BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getFaceArray(dm), dm->getNumFaces(dm), TRUE, FALSE); + return BKE_mesh_validate_arrays(NULL, + dm->getVertArray(dm), dm->getNumVerts(dm), + dm->getEdgeArray(dm), dm->getNumEdges(dm), + dm->getFaceArray(dm), dm->getNumFaces(dm), + dm->getVertDataArray(dm, CD_MDEFORMVERT), + TRUE, FALSE); } void BKE_mesh_calc_edges(Mesh *mesh, int update) From 36e7a22fcc3c7ad3b66f5798c6c9a3ad9e0972ea Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 8 Dec 2011 11:02:29 +0000 Subject: [PATCH 39/73] Disable redo for some vertex group operators to prevent confusing situation when changing properties in redo panel messes up things. This should help in cases described in #29527: Vgroup assign, remove and undo --- source/blender/editors/object/object_vgroup.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index b809fd5dbb1..3401157359e 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2194,7 +2194,10 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) ot->exec= vertex_group_remove_exec; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + /* redo operator will fail in this case because vertex groups aren't stored + in local edit mode stack and toggling "all" property will lead to + all groups deleted without way to restore them (see [#29527], sergey) */ + ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups"); @@ -2226,7 +2229,10 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) ot->exec= vertex_group_assign_exec; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + /* redo operator will fail in this case because vertex group assignment + isn't stored in local edit mode stack and toggling "new" property will + lead to creating plenty of new veretx groups (see [#29527], sergey) */ + ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "new", 0, "New", "Assign vertex to new vertex group"); @@ -2265,7 +2271,10 @@ void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot) ot->exec= vertex_group_remove_from_exec; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + /* redo operator will fail in this case because vertex groups ssignment + isn't stored in local edit mode stack and toggling "all" property will lead to + removing vertices from all groups (see [#29527], sergey) */ + ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups"); From 5fbc3b57d44b17a49f62253817812d560625b00c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 8 Dec 2011 11:37:04 +0000 Subject: [PATCH 40/73] Fix #29546: missing 3d view redraw after game exit with overlap draw mode, when launching game from properties editor. Also fix popup/menu still showing during game when starting from the top menu. --- source/blender/editors/space_view3d/view3d_view.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 90f617513a5..89f859d0976 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1715,6 +1715,10 @@ static int game_engine_exec(bContext *C, wmOperator *op) if(!ED_view3d_context_activate(C)) return OPERATOR_CANCELLED; + /* redraw to hide any menus/popups, we don't go back to + the window manager until after this operator exits */ + WM_redraw_windows(C); + rv3d= CTX_wm_region_view3d(C); /* sa= CTX_wm_area(C); */ /* UNUSED */ ar= CTX_wm_region(C); @@ -1750,6 +1754,8 @@ static int game_engine_exec(bContext *C, wmOperator *op) CTX_wm_window_set(C, NULL); } + ED_area_tag_redraw(CTX_wm_area(C)); + if(prevwin) { /* restore context, in case it changed in the meantime, for example by working in another window or closing it */ @@ -1763,8 +1769,6 @@ static int game_engine_exec(bContext *C, wmOperator *op) //XXX restore_all_scene_cfra(scene_cfra_store); set_scene_bg(CTX_data_main(C), startscene); //XXX scene_update_for_newframe(bmain, scene, scene->lay); - - ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; #else From f8ccc111cf6e7b0f047752f356dc1b178887d9af Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 8 Dec 2011 14:21:55 +0000 Subject: [PATCH 41/73] Tweak related to #29545: show info message if no frames are written in animation render due to disabled Overwrite option. --- source/blender/render/intern/source/pipeline.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 0bad1a13a5a..d82cff16496 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -3084,7 +3084,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri { bMovieHandle *mh= BKE_get_movie_handle(scene->r.im_format.imtype); int cfrao= scene->r.cfra; - int nfra; + int nfra, totrendered= 0, totskipped= 0; /* do not fully call for each frame, it initializes & pops output window */ if(!render_initialize_from_main(re, bmain, scene, NULL, camera_override, lay, 0, 1)) @@ -3109,6 +3109,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); do_render_all_options(re); + totrendered++; if(re->test_break(re->tbh) == 0) { if(!do_write_image_or_movie(re, bmain, scene, mh, NULL)) @@ -3157,6 +3158,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri if(scene->r.mode & R_NO_OVERWRITE && BLI_exists(name)) { printf("skipping existing frame \"%s\"\n", name); + totskipped++; continue; } if(scene->r.mode & R_TOUCH && !BLI_exists(name)) { @@ -3172,6 +3174,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri do_render_all_options(re); + totrendered++; if(re->test_break(re->tbh) == 0) { if(!G.afbreek) @@ -3201,6 +3204,9 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri /* end movie */ if(BKE_imtype_is_movie(scene->r.im_format.imtype)) mh->end_movie(); + + if(totskipped && totrendered == 0) + BKE_report(re->reports, RPT_INFO, "No frames rendered, skipped to not overwrite"); scene->r.cfra= cfrao; From edcc68b3d0acb45d4c6125d5e53bdd3f0e3dc403 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 8 Dec 2011 14:26:46 +0000 Subject: [PATCH 42/73] Fix #29547: missing units for some curve properties, patch by M.G. Kishalmi. --- source/blender/makesrna/intern/rna_curve.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 4afe0da85fa..5fd67efba1d 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -1286,21 +1286,21 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Bevel Resolution", "Bevel resolution when depth is non-zero and no specific bevel object has been defined"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "width"); RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3); RNA_def_property_float_funcs(prop, "rna_Curve_offset_get", "rna_Curve_offset_set", NULL); RNA_def_property_ui_text(prop, "Offset", "Offset the curve to adjust the width of a text"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "ext1"); RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3); RNA_def_property_range(prop, 0.0, FLT_MAX); RNA_def_property_ui_text(prop, "Extrude", "Amount of curve extrusion when not using a bevel object"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE|PROP_UNIT_LENGTH); RNA_def_property_float_sdna(prop, NULL, "ext2"); RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3); RNA_def_property_ui_text(prop, "Bevel Depth", "Bevel depth when not using a bevel object"); From 46626e4f5f3d7e56b83d51829491cb5fe9ed98a6 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 8 Dec 2011 15:50:28 +0000 Subject: [PATCH 43/73] Fix [#29543] Hook modifier: falloff + vgroup influence broken MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A valid derivedmesh is needed for modifier_get_vgroup to work, and it wasn’t take care of when not in edit mode... Checked quickly the other deform modifiers, they all seem to handle this correctly. --- source/blender/modifiers/intern/MOD_hook.c | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 30e801c9b42..9e48c5d29e2 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -143,14 +143,9 @@ static float hook_falloff(float *co_1, float *co_2, const float falloff_squared, return fac; } -static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *dm, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) +static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { - HookModifierData *hmd = (HookModifierData*) md; bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); float vec[3], mat[4][4], dmat[4][4]; int i, *index_pt; @@ -251,17 +246,29 @@ static void deformVerts(ModifierData *md, Object *ob, } } -static void deformVertsEM( - ModifierData *md, Object *ob, struct EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) +static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts, + int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { - DerivedMesh *dm = derivedData; + HookModifierData *hmd = (HookModifierData*) md; + DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); - if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data); + deformVerts_do(hmd, ob, dm, vertexCos, numVerts); - deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0); + if(derivedData != dm) + dm->release(dm); +} - if(!derivedData) dm->release(dm); +static void deformVertsEM(ModifierData *md, Object *ob, struct EditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) +{ + HookModifierData *hmd = (HookModifierData*) md; + DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, 0); + + deformVerts_do(hmd, ob, dm, vertexCos, numVerts); + + if(derivedData != dm) + dm->release(dm); } From 7797c1dc424b1f772f23a3b8730a8374012d8c8b Mon Sep 17 00:00:00 2001 From: "M.G. Kishalmi" Date: Thu, 8 Dec 2011 15:55:49 +0000 Subject: [PATCH 44/73] randomize transform operators 'rotation' property subtype changed from TRANSLATION to EULER and tweaks needed along with that. --- .../bl_operators/object_randomize_transform.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index f0d2448b508..ed881fab5fd 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -20,13 +20,12 @@ import bpy from bpy.types import Operator - +from mathutils import Vector def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): import random from random import uniform - from mathutils import Vector random.seed(seed) @@ -86,6 +85,7 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): from bpy.props import (IntProperty, BoolProperty, FloatVectorProperty) +from math import pi class RandomizeLocRotSize(Operator): @@ -129,10 +129,10 @@ class RandomizeLocRotSize(Operator): rot = FloatVectorProperty( name="Rotation", description="Maximun rotation over each axis", - min=-180.0, - max=180.0, + min=-pi, + max=pi, default=(0.0, 0.0, 0.0), - subtype='TRANSLATION', + subtype='EULER', ) use_scale = BoolProperty( name="Randomize Scale", @@ -162,14 +162,12 @@ class RandomizeLocRotSize(Operator): ) def execute(self, context): - from math import radians - seed = self.random_seed delta = self.use_delta loc = None if not self.use_loc else self.loc - rot = None if not self.use_rot else self.rot * radians(1.0) + rot = None if not self.use_rot else Vector(self.rot) scale = None if not self.use_scale else self.scale scale_even = self.scale_even From 7c630aac80d6326bd5dd569bce343e386123fdac Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Thu, 8 Dec 2011 19:16:43 +0000 Subject: [PATCH 45/73] Scons/CUDA * Added missing bitness info to the nvcc_flags. This makes sure that the nvcc compiler builds the correct cubins. --- SConstruct | 6 ++++++ build_files/scons/tools/Blender.py | 1 + intern/cycles/kernel/SConscript | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index fd99933e976..0bd7dc70446 100644 --- a/SConstruct +++ b/SConstruct @@ -119,6 +119,12 @@ tempbitness = int(B.arguments.get('BF_BITNESS', bitness)) # default to bitness f if tempbitness in (32, 64): # only set if 32 or 64 has been given bitness = int(tempbitness) +if bitness: + B.bitness = bitness +else: + B.bitness = tempbitness + + # first check cmdline for toolset and we create env to work on quickie = B.arguments.get('BF_QUICK', None) quickdebug = B.arguments.get('BF_QUICKDEBUG', None) diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 8e431d8f43c..e9195fe207d 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -50,6 +50,7 @@ program_list = [] # A list holding Nodes to final binaries, used to create insta arguments = None targets = None resources = [] +bitness = 0 #some internals blenderdeps = [] # don't manipulate this one outside this module! diff --git a/intern/cycles/kernel/SConscript b/intern/cycles/kernel/SConscript index eb99680efe4..be3c37b476c 100644 --- a/intern/cycles/kernel/SConscript +++ b/intern/cycles/kernel/SConscript @@ -1,6 +1,7 @@ #!/usr/bin/python import sys import os +import Blender as B def normpath(path): return os.path.abspath(os.path.normpath(path)) @@ -9,6 +10,12 @@ Import ('env') kernel_binaries = [] +#Bitness +if B.bitness == 32: + bits = 32 +else: + bits = 64 + if env['WITH_BF_CYCLES_CUDA_BINARIES']: kernel = env.Clone() @@ -27,7 +34,8 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']: svm_dir = os.path.join(source_dir, "../svm") # nvcc flags - nvcc_flags = "--cubin -use_fast_math --ptxas-options=\"-v\" --maxrregcount=24" + nvcc_flags = "-m%s" % (bits) + nvcc_flags += " --cubin -use_fast_math --ptxas-options=\"-v\" --maxrregcount=24" nvcc_flags += " --opencc-options -OPT:Olimit=0" nvcc_flags += " -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC" nvcc_flags += " -I \"%s\" -I \"%s\"" % (util_dir, svm_dir) From 601b0b284e1ec87917c47341165c111ef5b8d96c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 8 Dec 2011 20:24:01 +0000 Subject: [PATCH 46/73] Fix for #29475 broke properly updating toggle buttons in popup menus. Tweak the fix a bit, not a true solution to the problem, but too close to release for bigger changes. --- .../blender/editors/interface/interface_handlers.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index c6159487145..aee23626787 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5241,11 +5241,14 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s data->state= state; - if(!ELEM(state, BUTTON_STATE_EXIT, BUTTON_STATE_HIGHLIGHT)) { - /* When objects for eg. are removed, running ui_check_but() - * can access the removed data - so disable update on exit - * or highlight */ - ui_check_but(but); + if(state != BUTTON_STATE_EXIT) { + /* When objects for eg. are removed, running ui_check_but() can access + the removed data - so disable update on exit. Also in case of + highlight when not in a popup menu, we remove because data used in + button below popup might have been removed by action of popup. Needs + a more reliable solution... */ + if(state != BUTTON_STATE_HIGHLIGHT || but->block->handle) + ui_check_but(but); } /* redraw */ From 3314184f4d77bed0d9b4cdc186154b2289b5ab75 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 8 Dec 2011 21:55:35 +0000 Subject: [PATCH 47/73] Fix #29528: crash adding subsurf modifier in a particular scene with viewport render. --- intern/cycles/blender/blender_sync.cpp | 2 +- intern/cycles/render/mesh.cpp | 18 ++++++++++------- intern/cycles/render/sobol.cpp | 27 +++++++++++++------------- intern/cycles/render/sobol.h | 4 +++- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index b89b7ebb9be..b66004bee58 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -269,7 +269,7 @@ SessionParams BlenderSync::get_session_params(BL::Scene b_scene, bool background if(!experimental || RNA_enum_get(&cscene, "gpu_type") == 0) dtype = DEVICE_CUDA; else - dtype = DEVICE_CUDA; + dtype = DEVICE_OPENCL; if(device_type_available(types, dtype)) params.device_type = dtype; diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index fc2dd49205a..5d65ce69a00 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -270,15 +270,19 @@ void Mesh::compute_bvh(SceneParams *params, Progress& progress) void Mesh::tag_update(Scene *scene, bool rebuild) { need_update = true; - if(rebuild) + + if(rebuild) { need_update_rebuild = true; + scene->light_manager->need_update = true; + } + else { + foreach(uint sindex, used_shaders) + if(scene->shaders[sindex]->has_surface_emission) + scene->light_manager->need_update = true; + } scene->mesh_manager->need_update = true; scene->object_manager->need_update = true; - - foreach(uint sindex, used_shaders) - if(scene->shaders[sindex]->has_surface_emission) - scene->light_manager->need_update = true; } /* Mesh Manager */ @@ -685,9 +689,9 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen if(!mesh->transform_applied) { string msg = "Updating Mesh BVH "; if(mesh->name == "") - msg += string_printf("%lu/%lu", (unsigned long)(i+1), (unsigned long)num_instance_bvh); + msg += string_printf("%u/%u", (uint)(i+1), (uint)num_instance_bvh); else - msg += string_printf("%s %lu/%lu", mesh->name.c_str(), (unsigned long)(i+1), (unsigned long)num_instance_bvh); + msg += string_printf("%s %u/%u", mesh->name.c_str(), (uint)(i+1), (uint)num_instance_bvh); progress.set_status(msg, "Building BVH"); mesh->compute_bvh(&scene->params, progress); diff --git a/intern/cycles/render/sobol.cpp b/intern/cycles/render/sobol.cpp index be8939174b4..e3c2e802067 100644 --- a/intern/cycles/render/sobol.cpp +++ b/intern/cycles/render/sobol.cpp @@ -47,6 +47,7 @@ */ #include "util_debug.h" +#include "util_types.h" #include "sobol.h" @@ -55,8 +56,8 @@ CCL_NAMESPACE_BEGIN #define SOBOL_MAX_NUMBER 32 typedef struct SobolDirectionNumbers { - unsigned int d, s, a; - unsigned int m[SOBOL_MAX_NUMBER]; + uint d, s, a; + uint m[SOBOL_MAX_NUMBER]; } SobolDirectionNumbers; static SobolDirectionNumbers SOBOL_NUMBERS[SOBOL_MAX_DIMENSIONS-1] = { @@ -21262,38 +21263,38 @@ static SobolDirectionNumbers SOBOL_NUMBERS[SOBOL_MAX_DIMENSIONS-1] = { {21201, 18, 131059, {1, 1, 7, 11, 15, 7, 37, 239, 337, 245, 1557, 3681, 7357, 9639, 27367, 26869, 114603, 86317}} }; -void sobol_generate_direction_vectors(unsigned int vectors[][SOBOL_BITS], int dimensions) +void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions) { assert(dimensions <= SOBOL_MAX_DIMENSIONS); - const unsigned int L = SOBOL_BITS; + const uint L = SOBOL_BITS; /* first dimension is exception */ - unsigned int *v = vectors[0]; + uint *v = vectors[0]; - for(unsigned int i = 0; i < L; i++) + for(uint i = 0; i < L; i++) v[i] = 1 << (31-i); // all m's = 1 for(int dim = 1; dim < dimensions; dim++) { SobolDirectionNumbers *numbers = &SOBOL_NUMBERS[dim-1]; - unsigned int s = numbers->s; - unsigned int a = numbers->a; - unsigned int *m = numbers->m; + uint s = numbers->s; + uint a = numbers->a; + uint *m = numbers->m; v = vectors[dim]; if(L <= s) { - for(unsigned int i = 0; i < L; i++) + for(uint i = 0; i < L; i++) v[i] = m[i] << (31-i); } else { - for(unsigned int i = 0; i < s; i++) + for(uint i = 0; i < s; i++) v[i] = m[i] << (31-i); - for(unsigned int i = s; i < L; i++) { + for(uint i = s; i < L; i++) { v[i] = v[i-s] ^ (v[i-s] >> s); - for(unsigned int k = 1; k < s; k++) + for(uint k = 1; k < s; k++) v[i] ^= (((a >> (s-1-k)) & 1) * v[i-k]); } } diff --git a/intern/cycles/render/sobol.h b/intern/cycles/render/sobol.h index bfc2f5512aa..0f52a5fee68 100644 --- a/intern/cycles/render/sobol.h +++ b/intern/cycles/render/sobol.h @@ -19,12 +19,14 @@ #ifndef __SOBOL_H__ #define __SOBOL_H__ +#include "util_types.h" + CCL_NAMESPACE_BEGIN #define SOBOL_BITS 32 #define SOBOL_MAX_DIMENSIONS 21201 -void sobol_generate_direction_vectors(unsigned int vectors[][SOBOL_BITS], int dimensions); +void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions); CCL_NAMESPACE_END From ea399744e7807b63f995c60724e773a0335d1d89 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 9 Dec 2011 00:24:48 +0000 Subject: [PATCH 48/73] Fix #29555: cycles crash rendering with no material in material slot. --- intern/cycles/blender/blender_mesh.cpp | 4 ++-- intern/cycles/blender/blender_object.cpp | 2 +- intern/cycles/blender/blender_shader.cpp | 4 ++-- intern/cycles/blender/blender_sync.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index e247b3744fa..4b7651dba4c 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -233,9 +233,9 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated) BL::Object::material_slots_iterator slot; for(b_ob.material_slots.begin(slot); slot != b_ob.material_slots.end(); ++slot) { if(render_layer.material_override) - find_shader(render_layer.material_override, used_shaders); + find_shader(render_layer.material_override, used_shaders, scene->default_surface); else - find_shader(slot->material(), used_shaders); + find_shader(slot->material(), used_shaders, scene->default_surface); } if(used_shaders.size() == 0) diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index abadee9328e..ec22d3db6f7 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -137,7 +137,7 @@ void BlenderSync::sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, /* shader */ vector used_shaders; - find_shader(b_lamp, used_shaders); + find_shader(b_lamp, used_shaders, scene->default_light); if(used_shaders.size() == 0) used_shaders.push_back(scene->default_light); diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 930ac1d495a..b0dd6988457 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -36,9 +36,9 @@ typedef map PtrSockMap; /* Find */ -void BlenderSync::find_shader(BL::ID id, vector& used_shaders) +void BlenderSync::find_shader(BL::ID id, vector& used_shaders, int default_shader) { - Shader *shader = shader_map.find(id); + Shader *shader = (id)? shader_map.find(id): scene->shaders[default_shader]; for(size_t i = 0; i < scene->shaders.size(); i++) { if(scene->shaders[i] == shader) { diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index bde3207e1be..83c7f70fd59 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -81,7 +81,7 @@ private: void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm); /* util */ - void find_shader(BL::ID id, vector& used_shaders); + void find_shader(BL::ID id, vector& used_shaders, int default_shader); bool object_is_modified(BL::Object b_ob); bool object_is_mesh(BL::Object b_ob); bool object_is_light(BL::Object b_ob); From 2ba8b819497ca1b2fdedf1bbf30359d48adca5c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 01:27:59 +0000 Subject: [PATCH 49/73] remove redundant cases. no functional change. --- source/blender/editors/animation/anim_ipo_utils.c | 9 +++++---- source/blender/editors/animation/keyframing.c | 5 +++-- source/blender/editors/space_outliner/outliner_tree.c | 4 ++-- source/blender/makesrna/intern/rna_access.c | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index d18a3c320f7..8e36e02bbb4 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -78,7 +78,8 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* try to resolve the path */ if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) { - char *structname=NULL, *propname=NULL, arrayindbuf[16]; + const char *structname=NULL, *propname=NULL; + char arrayindbuf[16]; const char *arrayname=NULL; short free_structname = 0; @@ -122,11 +123,11 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) free_structname= 1; } else - structname= (char *)RNA_struct_ui_name(ptr.type); + structname= RNA_struct_ui_name(ptr.type); } /* Property Name is straightforward */ - propname= (char *)RNA_property_ui_name(prop); + propname= RNA_property_ui_name(prop); /* Array Index - only if applicable */ if (RNA_property_array_length(&ptr, prop)) { @@ -153,7 +154,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* free temp name if nameprop is set */ if (free_structname) - MEM_freeN(structname); + MEM_freeN((void *)structname); /* Icon for this property's owner: diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 4595bf3f64f..54314980e03 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -524,7 +524,8 @@ static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int inde enum { VISUALKEY_NONE = 0, VISUALKEY_LOC, - VISUALKEY_ROT, + VISUALKEY_ROT + /* VISUALKEY_SCA */ /* TODO - looks like support can be added now */ }; /* This helper function determines if visual-keyframing should be used when @@ -655,7 +656,7 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) */ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_index) { - char *identifier= (char *)RNA_property_identifier(prop); + const char *identifier= RNA_property_identifier(prop); /* handle for Objects or PoseChannels only * - constraints can be on either Objects or PoseChannels, so we only check if the diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 794f898a1fc..084e48c0d6e 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -977,7 +977,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i if(te->name) te->flag |= TE_FREE_NAME; else - te->name= (char*)RNA_struct_ui_name(ptr->type); + te->name= RNA_struct_ui_name(ptr->type); /* If searching don't expand RNA entries */ if(SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA",te->name)==0) tselem->flag &= ~TSE_CHILDSEARCH; @@ -1007,7 +1007,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i prop= propptr.data; proptype= RNA_property_type(prop); - te->name= (char*)RNA_property_ui_name(prop); + te->name= RNA_property_ui_name(prop); te->directdata= prop; te->rnaptr= *ptr; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index fa2fb061e3e..a31984dfc29 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -3751,7 +3751,7 @@ char *RNA_path_append(const char *path, PointerRNA *UNUSED(ptr), PropertyRNA *pr BLI_dynstr_append(dynstr, "."); } - BLI_dynstr_append(dynstr, (char*)RNA_property_identifier(prop)); + BLI_dynstr_append(dynstr, RNA_property_identifier(prop)); if(RNA_property_type(prop) == PROP_COLLECTION) { /* add ["strkey"] or [intkey] */ From fd543185cc2fa802df15e33c823d61d0f3ede89d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 06:05:58 +0000 Subject: [PATCH 50/73] minor changes, fix coming next (no functional edits). --- source/blender/blenkernel/intern/armature.c | 6 +-- .../editors/sculpt_paint/paint_vertex.c | 41 +++++++++++-------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 68d2cf940af..e7743bea2cd 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2473,7 +2473,7 @@ void where_is_pose (Scene *scene, Object *ob) /* Returns total selected vgroups, * wpi.defbase_sel is assumed malloc'd, all values are set */ -int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_len) +int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_tot) { bDeformGroup *defgroup; unsigned int i; @@ -2482,7 +2482,7 @@ int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_len) if(armob) { bPose *pose= armob->pose; - for (i= 0, defgroup= ob->defbase.first; i < defbase_len && defgroup; defgroup = defgroup->next, i++) { + for (i= 0, defgroup= ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { bPoseChannel *pchan= get_pose_channel(pose, defgroup->name); if(pchan && (pchan->bone->flag & BONE_SELECTED)) { dg_selection[i]= TRUE; @@ -2494,7 +2494,7 @@ int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_len) } } else { - memset(dg_selection, FALSE, sizeof(char) * defbase_len); + memset(dg_selection, FALSE, sizeof(char) * defbase_tot); } return dg_flags_sel_tot; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 9cc81df6ce5..296582cd8d6 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1159,7 +1159,7 @@ static char *gen_lock_flags(Object* ob, int defbase_tot) return NULL; } -static int has_locked_group_selected(int defbase_tot, char *defbase_sel, char *lock_flags) +static int has_locked_group_selected(int defbase_tot, const char *defbase_sel, const char *lock_flags) { int i; for(i = 0; i < defbase_tot; i++) { @@ -1188,7 +1188,7 @@ static int has_unselected_unlocked_bone_group(int defbase_tot, char *defbase_sel #endif -static void multipaint_selection(MDeformVert *dvert, float change, char *defbase_sel, int defbase_tot) +static void multipaint_selection(MDeformVert *dvert, float change, const char *defbase_sel, int defbase_tot) { int i; MDeformWeight *dw; @@ -1274,11 +1274,11 @@ static float redistribute_change(MDeformVert *ndv, char *change_status, int chan /* left overs */ return totchange; } -static float get_mp_change(MDeformVert *odv, char *defbase_sel, float brush_change); +static float get_mp_change(MDeformVert *odv, const char *defbase_sel, float brush_change); /* observe the changes made to the weights of groups. * make sure all locked groups on the vertex have the same deformation * by moving the changes made to groups onto other unlocked groups */ -static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_tot, char *defbase_sel, +static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_tot, const char *defbase_sel, const char *lock_flags, const char *vgroup_validmap, char do_auto_normalize, char do_multipaint) { float totchange = 0.0f; @@ -1389,7 +1389,7 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_tot, c } /* multi-paint's initial, potential change is computed here based on the user's stroke */ -static float get_mp_change(MDeformVert *odv, char *defbase_sel, float brush_change) +static float get_mp_change(MDeformVert *odv, const char *defbase_sel, float brush_change) { float selwsum = 0.0f; unsigned int i; @@ -1443,12 +1443,12 @@ typedef struct WeightPaintInfo { int vgroup_mirror; /* mirror group or -1 */ - char *lock_flags; /* boolean array for locked bones, - * length of defbase_tot */ - char *defbase_sel; /* boolean array for selected bones, - * length of defbase_tot */ + const char *lock_flags; /* boolean array for locked bones, + * length of defbase_tot */ + const char *defbase_sel; /* boolean array for selected bones, + * length of defbase_tot, cant be const because of how its passed */ - char *vgroup_validmap; /* same as WeightPaintData.vgroup_validmap, + const char *vgroup_validmap; /* same as WeightPaintData.vgroup_validmap, * only added here for convenience */ char do_flip; @@ -1514,7 +1514,7 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi, /* within the current dvert index, get the dw that is selected and has a weight * above 0, this helps multi-paint */ -static int get_first_selected_nonzero_weight(MDeformVert *dvert, char *defbase_sel) +static int get_first_selected_nonzero_weight(MDeformVert *dvert, const char *defbase_sel) { int i; MDeformWeight *dw= dvert->dw; @@ -1767,8 +1767,8 @@ struct WPaintData { float wpimat[3][3]; /*variables for auto normalize*/ - char *vgroup_validmap; /*stores if vgroups tie to deforming bones or not*/ - char *lock_flags; + const char *vgroup_validmap; /*stores if vgroups tie to deforming bones or not*/ + const char *lock_flags; int defbase_tot; }; @@ -1823,6 +1823,8 @@ static char *wpaint_make_validmap(Object *ob) vgroup_validmap[i]= (BLI_ghash_lookup(gh, dg->name) != NULL); } + BLI_assert(i == BLI_ghash_size(gh)); + BLI_ghash_free(gh, NULL, NULL); return vgroup_validmap; @@ -1925,6 +1927,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P float alpha; float mval[2], pressure; int use_vert_sel; + char *defbase_sel; /* intentionally dont initialize as NULL, make sure we initialize all members below */ WeightPaintInfo wpi; @@ -1956,9 +1959,11 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* *** setup WeightPaintInfo - pass onto do_weight_paint_vertex *** */ wpi.defbase_tot= wpd->defbase_tot; - wpi.defbase_sel= MEM_mallocN(wpi.defbase_tot*sizeof(char), "wpi.defbase_sel"); - wpi.defbase_tot_sel= get_selected_defgroups(ob, wpi.defbase_sel, wpi.defbase_tot); + defbase_sel= MEM_mallocN(wpi.defbase_tot*sizeof(char), "wpi.defbase_sel"); + wpi.defbase_tot_sel= get_selected_defgroups(ob, defbase_sel, wpi.defbase_tot); + wpi.defbase_sel= defbase_sel; /* so we can stay const */ if(wpi.defbase_tot_sel == 0 && ob->actdef > 0) wpi.defbase_tot_sel = 1; + wpi.defbase_tot_unsel= wpi.defbase_tot - wpi.defbase_tot_sel; wpi.vgroup_mirror= wpd->vgroup_mirror; wpi.lock_flags= wpd->lock_flags; @@ -2084,7 +2089,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* *** free wpi members */ - MEM_freeN(wpi.defbase_sel); + MEM_freeN((void *)wpi.defbase_sel); /* *** dont freeing wpi members */ @@ -2106,9 +2111,9 @@ static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) MEM_freeN(wpd->indexar); if (wpd->vgroup_validmap) - MEM_freeN(wpd->vgroup_validmap); + MEM_freeN((void *)wpd->vgroup_validmap); if(wpd->lock_flags) - MEM_freeN(wpd->lock_flags); + MEM_freeN((void *)wpd->lock_flags); MEM_freeN(wpd); } From fbdb8b414d9734606f1e51304b7c355e2f59e02f Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Fri, 9 Dec 2011 06:21:26 +0000 Subject: [PATCH 51/73] [#29509] Randomize rotations fails with Axis/Angle Fix based on Brecht's idea: use Blender's conversion from quat or axis angle to euler and back. Euler rotations are left alone so their rotation order is respected --- .../startup/bl_operators/object_randomize_transform.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index ed881fab5fd..319fd1526fb 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -42,8 +42,13 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): else: # otherwise the values change under us uniform(0.0, 0.0), uniform(0.0, 0.0), uniform(0.0, 0.0) - if rot: # TODO, non euler's + if rot: vec = rand_vec(rot) + + rotation_mode = obj.rotation_mode + if rotation_mode in ('QUATERNION', 'AXIS_ANGLE'): + obj.rotation_mode = 'XYZ' + if delta: obj.delta_rotation_euler[0] += vec[0] obj.delta_rotation_euler[1] += vec[1] @@ -52,6 +57,7 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): obj.rotation_euler[0] += vec[0] obj.rotation_euler[1] += vec[1] obj.rotation_euler[2] += vec[2] + obj.rotation_mode = rotation_mode else: uniform(0.0, 0.0), uniform(0.0, 0.0), uniform(0.0, 0.0) From fb2961a1788763614b78583d84ebe86ef34ed147 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 07:18:04 +0000 Subject: [PATCH 52/73] possible/partial fix for [#29521], in many places the deform group index was not checked which could crash blender. --- .../editors/sculpt_paint/paint_vertex.c | 171 ++++++++++-------- 1 file changed, 100 insertions(+), 71 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 296582cd8d6..fa791665eb8 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -967,11 +967,11 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA index= view3d_sample_backbuf(&vc, win->eventstate->x - vc.ar->winrct.xmin, win->eventstate->y - vc.ar->winrct.ymin); if(index && index<=me->totface) { - const int totgroup= BLI_countlist(&vc.obact->defbase); - if(totgroup) { + const int defbase_tot= BLI_countlist(&vc.obact->defbase); + if(defbase_tot) { MFace *mf= ((MFace *)me->mface) + index-1; unsigned int fidx= mf->v4 ? 3:2; - int *groups= MEM_callocN(totgroup*sizeof(int), "groups"); + int *groups= MEM_callocN(defbase_tot*sizeof(int), "groups"); int found= FALSE; do { @@ -979,8 +979,10 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA int i= dvert->totweight; MDeformWeight *dw; for(dw= dvert->dw; i > 0; dw++, i--) { - groups[dw->def_nr]= TRUE; - found= TRUE; + if (dw->def_nr < defbase_tot) { + groups[dw->def_nr]= TRUE; + found= TRUE; + } } } while (fidx--); @@ -992,7 +994,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA int totitem= 0; int i= 0; bDeformGroup *dg; - for(dg= vc.obact->defbase.first; dg && inext) { + for(dg= vc.obact->defbase.first; dg && inext) { if(groups[i]) { item_tmp.identifier= item_tmp.name= dg->name; item_tmp.value= i; @@ -1091,7 +1093,8 @@ static void do_weight_paint_auto_normalize(MDeformVert *dvert, #endif /* the active group should be involved in auto normalize */ -static void do_weight_paint_auto_normalize_all_groups(MDeformVert *dvert, const char *vgroup_validmap, char do_auto_normalize) +static void do_weight_paint_auto_normalize_all_groups(MDeformVert *dvert, const int defbase_tot, + const char *vgroup_validmap, char do_auto_normalize) { if (do_auto_normalize == FALSE) { return; @@ -1102,9 +1105,11 @@ static void do_weight_paint_auto_normalize_all_groups(MDeformVert *dvert, const MDeformWeight *dw; for (i= dvert->totweight, dw= dvert->dw; i != 0; i--, dw++) { - if (vgroup_validmap[dw->def_nr]) { - tot++; - sum += dw->weight; + if (dw->def_nr < defbase_tot) { + if (vgroup_validmap[dw->def_nr]) { + tot++; + sum += dw->weight; + } } } @@ -1115,8 +1120,10 @@ static void do_weight_paint_auto_normalize_all_groups(MDeformVert *dvert, const fac= 1.0f / sum; for (i= dvert->totweight, dw= dvert->dw; i != 0; i--, dw++) { - if (vgroup_validmap[dw->def_nr]) { - dw->weight *= fac; + if (dw->def_nr < defbase_tot) { + if (vgroup_validmap[dw->def_nr]) { + dw->weight *= fac; + } } } } @@ -1125,12 +1132,17 @@ static void do_weight_paint_auto_normalize_all_groups(MDeformVert *dvert, const /* See if the current deform vertex has a locked group */ -static char has_locked_group(MDeformVert *dvert, const char *lock_flags) +static char has_locked_group(MDeformVert *dvert, const int defbase_tot, + const char *lock_flags) { int i; - for(i = 0; i < dvert->totweight; i++) { - if(lock_flags[dvert->dw[i].def_nr] && dvert->dw[i].weight > 0.0f) { - return TRUE; + MDeformWeight *dw; + + for (i= dvert->totweight, dw= dvert->dw; i != 0; i--, dw++) { + if (dw->def_nr < defbase_tot) { + if (lock_flags[dw->def_nr] && dw->weight > 0.0f) { + return TRUE; + } } } return FALSE; @@ -1188,7 +1200,7 @@ static int has_unselected_unlocked_bone_group(int defbase_tot, char *defbase_sel #endif -static void multipaint_selection(MDeformVert *dvert, float change, const char *defbase_sel, int defbase_tot) +static void multipaint_selection(MDeformVert *dvert, const int defbase_tot, float change, const char *defbase_sel) { int i; MDeformWeight *dw; @@ -1227,7 +1239,10 @@ static void multipaint_selection(MDeformVert *dvert, float change, const char *d /* move all change onto valid, unchanged groups. If there is change left over, * then return it. * assumes there are valid groups to shift weight onto */ -static float redistribute_change(MDeformVert *ndv, char *change_status, int changeme, int changeto, float totchange, float total_valid, char do_auto_normalize) +static float redistribute_change(MDeformVert *ndv, const int defbase_tot, + char *change_status, const char change_me, int changeto, + float totchange, float total_valid, + char do_auto_normalize) { float was_change; float change; @@ -1241,30 +1256,35 @@ static float redistribute_change(MDeformVert *ndv, char *change_status, int chan change = totchange/total_valid; for(i = 0; i < ndv->totweight && total_valid && totchange; i++) { ndw = (ndv->dw+i); - /* change only the groups with a valid status */ - if(change_status[ndw->def_nr] == changeme) { - oldval = ndw->weight; - /* if auto normalize is active, don't worry about upper bounds */ - if(do_auto_normalize == FALSE && ndw->weight + change > 1) { - totchange -= 1-ndw->weight; - ndw->weight = 1; - /* stop the changes to this group */ - change_status[ndw->def_nr] = changeto; - total_valid--; - } - else if(ndw->weight + change < 0) { /* check the lower bound */ - totchange -= ndw->weight; - ndw->weight = 0; - change_status[ndw->def_nr] = changeto; - total_valid--; - } - else {/* a perfectly valid change occurred to ndw->weight */ - totchange -= change; - ndw->weight += change; - } - /* see if there was a change */ - if(oldval != ndw->weight) { - was_change = TRUE; + + /* ignore anything outside the value range */ + if (ndw->def_nr < defbase_tot) { + + /* change only the groups with a valid status */ + if(change_status[ndw->def_nr] == change_me) { + oldval = ndw->weight; + /* if auto normalize is active, don't worry about upper bounds */ + if(do_auto_normalize == FALSE && ndw->weight + change > 1) { + totchange -= 1-ndw->weight; + ndw->weight = 1; + /* stop the changes to this group */ + change_status[ndw->def_nr] = changeto; + total_valid--; + } + else if(ndw->weight + change < 0) { /* check the lower bound */ + totchange -= ndw->weight; + ndw->weight = 0; + change_status[ndw->def_nr] = changeto; + total_valid--; + } + else {/* a perfectly valid change occurred to ndw->weight */ + totchange -= change; + ndw->weight += change; + } + /* see if there was a change */ + if(oldval != ndw->weight) { + was_change = TRUE; + } } } } @@ -1274,12 +1294,14 @@ static float redistribute_change(MDeformVert *ndv, char *change_status, int chan /* left overs */ return totchange; } -static float get_mp_change(MDeformVert *odv, const char *defbase_sel, float brush_change); +static float get_mp_change(MDeformVert *odv, const int defbase_tot, const char *defbase_sel, float brush_change); /* observe the changes made to the weights of groups. * make sure all locked groups on the vertex have the same deformation * by moving the changes made to groups onto other unlocked groups */ -static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_tot, const char *defbase_sel, - const char *lock_flags, const char *vgroup_validmap, char do_auto_normalize, char do_multipaint) +static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, + const int defbase_tot, const char *defbase_sel, + const char *lock_flags, const char *vgroup_validmap, + char do_auto_normalize, char do_multipaint) { float totchange = 0.0f; float totchange_allowed = 0.0f; @@ -1295,7 +1317,7 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_tot, c char *change_status; - if(!lock_flags || !has_locked_group(ndv, lock_flags)) { + if(!lock_flags || !has_locked_group(ndv, defbase_tot, lock_flags)) { return; } /* record if a group was changed, unlocked and not changed, or locked */ @@ -1359,17 +1381,17 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_tot, c totchange_allowed = -totchange; } /* move the weight evenly between the allowed groups, move excess back onto the used groups based on the change */ - totchange_allowed = redistribute_change(ndv, change_status, 1, -1, totchange_allowed, total_valid, do_auto_normalize); + totchange_allowed = redistribute_change(ndv, defbase_tot, change_status, 1, -1, totchange_allowed, total_valid, do_auto_normalize); left_over += totchange_allowed; if(left_over) { /* more than one nonzero weights were changed with the same ratio with multipaint, so keep them changed that way! */ if(total_changed > 1 && do_multipaint) { - float undo_change = get_mp_change(ndv, defbase_sel, left_over); - multipaint_selection(ndv, undo_change, defbase_sel, defbase_tot); + float undo_change = get_mp_change(ndv, defbase_tot, defbase_sel, left_over); + multipaint_selection(ndv, defbase_tot, undo_change, defbase_sel); } /* or designatedw is still -1 put weight back as evenly as possible */ else { - redistribute_change(ndv, change_status, 2, -2, left_over, total_changed, do_auto_normalize); + redistribute_change(ndv, defbase_tot, change_status, 2, -2, left_over, total_changed, do_auto_normalize); } } } @@ -1389,15 +1411,17 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, int defbase_tot, c } /* multi-paint's initial, potential change is computed here based on the user's stroke */ -static float get_mp_change(MDeformVert *odv, const char *defbase_sel, float brush_change) +static float get_mp_change(MDeformVert *odv, const int defbase_tot, const char *defbase_sel, float brush_change) { float selwsum = 0.0f; unsigned int i; MDeformWeight *dw= odv->dw; for (i= odv->totweight; i != 0; i--, dw++) { - if(defbase_sel[dw->def_nr]) { - selwsum += dw->weight; + if (dw->def_nr < defbase_tot) { + if(defbase_sel[dw->def_nr]) { + selwsum += dw->weight; + } } } if(selwsum && selwsum+brush_change > 0) { @@ -1449,7 +1473,7 @@ typedef struct WeightPaintInfo { * length of defbase_tot, cant be const because of how its passed */ const char *vgroup_validmap; /* same as WeightPaintData.vgroup_validmap, - * only added here for convenience */ + * only added here for convenience */ char do_flip; char do_multipaint; @@ -1458,7 +1482,10 @@ typedef struct WeightPaintInfo { /* fresh start to make multi-paint and locking modular */ /* returns TRUE if it thinks you need to reset the weights due to - * normalizing while multi-painting */ + * normalizing while multi-painting + * + * note: this assumes dw->def_nr range has been checked by the caller + */ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi, const unsigned int index, MDeformWeight *dw, MDeformWeight *tdw, @@ -1473,13 +1500,13 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi, dv_test.totweight = dv->totweight; /* do not multi-paint if a locked group is selected or the active group is locked * !lock_flags[dw->def_nr] helps if nothing is selected, but active group is locked */ - if( (wpi->lock_flags == NULL) || - ((wpi->lock_flags[dw->def_nr] == FALSE) && - has_locked_group_selected(wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags) == FALSE)) + if ( (wpi->lock_flags == NULL) || + ((wpi->lock_flags[dw->def_nr] == FALSE) && /* def_nr range has to be checked for by caller */ + has_locked_group_selected(wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags) == FALSE)) { if(wpi->do_multipaint && wpi->defbase_tot_sel > 1) { if(change && change!=1) { - multipaint_selection(dv, change, wpi->defbase_sel, wpi->defbase_tot); + multipaint_selection(dv, wpi->defbase_tot, change, wpi->defbase_sel); } } else { /* this lets users paint normally, but don't let them paint locked groups */ @@ -1490,7 +1517,7 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi, enforce_locks(&dv_test, dv, wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags, wpi->vgroup_validmap, wpi->do_auto_normalize, wpi->do_multipaint); - do_weight_paint_auto_normalize_all_groups(dv, wpi->vgroup_validmap, wpi->do_auto_normalize); + do_weight_paint_auto_normalize_all_groups(dv, wpi->defbase_tot, wpi->vgroup_validmap, wpi->do_auto_normalize); if(oldChange && wpi->do_multipaint && wpi->defbase_tot_sel > 1) { if(tdw->weight != oldw) { @@ -1514,13 +1541,15 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi, /* within the current dvert index, get the dw that is selected and has a weight * above 0, this helps multi-paint */ -static int get_first_selected_nonzero_weight(MDeformVert *dvert, const char *defbase_sel) +static int get_first_selected_nonzero_weight(MDeformVert *dvert, const int defbase_tot, const char *defbase_sel) { int i; MDeformWeight *dw= dvert->dw; for(i=0; i< dvert->totweight; i++, dw++) { - if(defbase_sel[dw->def_nr] && dw->weight > 0.0f) { - return i; + if (dw->def_nr < defbase_tot) { + if (defbase_sel[dw->def_nr] && dw->weight > 0.0f) { + return i; + } } } return -1; @@ -1560,8 +1589,8 @@ static void do_weight_paint_vertex( /* vars which remain the same for every vert /* If there are no locks or multipaint, * then there is no need to run the more complicated checks */ - if( (wpi->do_multipaint == FALSE || wpi->defbase_tot_sel <= 1) && - (wpi->lock_flags == NULL || has_locked_group(dv, wpi->lock_flags) == FALSE)) + if ( (wpi->do_multipaint == FALSE || wpi->defbase_tot_sel <= 1) && + (wpi->lock_flags == NULL || has_locked_group(dv, wpi->defbase_tot, wpi->lock_flags) == FALSE)) { wpaint_blend(wp, dw, uw, alpha, paintweight, wpi->do_flip, FALSE); @@ -1579,7 +1608,7 @@ static void do_weight_paint_vertex( /* vars which remain the same for every vert * which has already been scaled down in relation to other weights, * then scales a second time [#26193]. Tricky multi-paint code doesn't * suffer from this problem - campbell */ - do_weight_paint_auto_normalize_all_groups(dv, wpi->vgroup_validmap, wpi->do_auto_normalize); + do_weight_paint_auto_normalize_all_groups(dv, wpi->defbase_tot, wpi->vgroup_validmap, wpi->do_auto_normalize); } else { /* use locks and/or multipaint */ @@ -1604,13 +1633,13 @@ static void do_weight_paint_vertex( /* vars which remain the same for every vert dv_copy.totweight = dv->totweight; tdw = dw; tuw = uw; - change = get_mp_change(wp->wpaint_prev+index, wpi->defbase_sel, neww - oldw); + change = get_mp_change(&wp->wpaint_prev[index], wpi->defbase_tot, wpi->defbase_sel, neww - oldw); if(change) { if(!tdw->weight) { - i = get_first_selected_nonzero_weight(dv, wpi->defbase_sel); + i = get_first_selected_nonzero_weight(dv, wpi->defbase_tot, wpi->defbase_sel); if(i>=0) { tdw = &(dv->dw[i]); - tuw = defvert_verify_index(wp->wpaint_prev+index, tdw->def_nr); + tuw = defvert_verify_index(&wp->wpaint_prev[index], tdw->def_nr); } else { change = 0; @@ -2144,8 +2173,8 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) { op->customdata = paint_stroke_new(C, NULL, wpaint_stroke_test_start, - wpaint_stroke_update_step, - wpaint_stroke_done, event->type); + wpaint_stroke_update_step, + wpaint_stroke_done, event->type); /* add modal handler */ WM_event_add_modal_handler(C, op); From a80a5c403474d281beb8cec1d58013d506c55b50 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 07:23:17 +0000 Subject: [PATCH 53/73] BKE_mesh_validate_arrays was correcting non-finite verts and zero normals even when do_fixes was false, also return true if any bad vertex weights were found.` --- .../blender/blenkernel/intern/mesh_validate.c | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index c09e18e3ba0..774565bb4bd 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -136,9 +136,11 @@ int BKE_mesh_validate_arrays( Mesh *me, MVert *mvert= mverts; unsigned int i; - int do_face_free= FALSE; - int do_edge_free= FALSE; - int verts_fixed= FALSE; + short do_face_free= FALSE; + short do_edge_free= FALSE; + + short verts_fixed= FALSE; + short vert_weights_fixed= FALSE; int do_edge_recalc= FALSE; @@ -165,9 +167,12 @@ int BKE_mesh_validate_arrays( Mesh *me, for(j=0; j<3; j++) { if(!finite(mvert->co[j])) { PRINT(" vertex %u: has invalid coordinate\n", i); - zero_v3(mvert->co); - verts_fixed= TRUE; + if (do_fixes) { + zero_v3(mvert->co); + + verts_fixed= TRUE; + } } if(mvert->no[j]!=0) @@ -176,8 +181,10 @@ int BKE_mesh_validate_arrays( Mesh *me, if(fix_normal) { PRINT(" vertex %u: has zero normal, assuming Z-up normal\n", i); - mvert->no[2]= SHRT_MAX; - verts_fixed= TRUE; + if (do_fixes) { + mvert->no[2]= SHRT_MAX; + verts_fixed= TRUE; + } } } @@ -327,6 +334,7 @@ int BKE_mesh_validate_arrays( Mesh *me, PRINT(" vertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight); if (do_fixes) { dw->weight= 0.0f; + vert_weights_fixed= TRUE; } } @@ -339,6 +347,8 @@ int BKE_mesh_validate_arrays( Mesh *me, * within the for loop and may not be valid */ j--; dw= dv->dw + j; + + vert_weights_fixed= TRUE; } else { /* all freed */ break; @@ -369,7 +379,7 @@ int BKE_mesh_validate_arrays( Mesh *me, } } - return (verts_fixed || do_face_free || do_edge_free || do_edge_recalc); + return (verts_fixed || vert_weights_fixed || do_face_free || do_edge_free || do_edge_recalc); } static int mesh_validate_customdata(CustomData *data, short do_verbose, const short do_fixes) From 11aba526f28f22995c96d901f1a4a083e279a2f9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 07:35:56 +0000 Subject: [PATCH 54/73] another possible fix for bug [#29521], all callers of flip_side_name(...), assumed it initialized the string however for 1-2 length names it returned without doing anything. in most cases the caller would then check if the name was different to see if the name was flipped, incorrectly comparing the uninitialized string with the original name. --- source/blender/blenkernel/intern/deform.c | 10 +++++++--- source/blender/editors/armature/editarmature.c | 6 +++--- source/blender/editors/armature/poseobject.c | 4 ++-- source/blender/editors/object/object_select.c | 3 ++- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 8dfd7e25bfb..e5176663228 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -410,11 +410,15 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_ char number[MAX_VGROUP_NAME]= ""; /* The number extension string */ char *index=NULL; - len= BLI_strnlen(from_name, MAX_VGROUP_NAME); - if (len < 3) return; // we don't do names like .R or .L - + /* always copy the name, since this can be called with an uninitialized string */ BLI_strncpy(name, from_name, MAX_VGROUP_NAME); + len= BLI_strnlen(from_name, MAX_VGROUP_NAME); + if (len < 3) { + /* we don't do names like .R or .L */ + return; + } + /* We first check the case with a .### extension, let's find the last period */ if (isdigit(name[len-1])) { index= strrchr(name, '.'); // last occurrence diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index caffdc29118..6dbb08e115f 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -161,7 +161,7 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone) EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo) { EditBone *eboflip= NULL; - char name[32]; + char name[MAXBONENAME]; if (ebo == NULL) return NULL; @@ -4663,7 +4663,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, /* find flipped group */ if (dgroup && mirror) { - char name[32]; + char name[MAXBONENAME]; // 0 = don't strip off number extensions flip_side_name(name, dgroup->name, FALSE); @@ -5456,7 +5456,7 @@ static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_edit_object(C); bArmature *arm; - char newname[32]; + char newname[MAXBONENAME]; /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 993c8420576..8d35122650f 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -989,7 +989,7 @@ static void set_pose_keys (Object *ob) static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short selOnly, short flip) { bPoseChannel *pchan; - char name[32]; + char name[MAXBONENAME]; short paste_ok; /* get the name - if flipping, we must flip this first */ @@ -1740,7 +1740,7 @@ static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) { - char newname[32]; + char newname[MAXBONENAME]; flip_side_name(newname, pchan->name, TRUE); ED_armature_bone_rename(arm, pchan->name, newname); } diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index fce37b7a022..c4d33b74574 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -41,6 +41,7 @@ #include "DNA_modifier_types.h" #include "DNA_property_types.h" #include "DNA_scene_types.h" +#include "DNA_armature_types.h" #include "BLI_math.h" #include "BLI_listbase.h" @@ -893,7 +894,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) extend= RNA_boolean_get(op->ptr, "extend"); CTX_DATA_BEGIN(C, Base*, primbase, selected_bases) { - char tmpname[32]; + char tmpname[MAXBONENAME]; flip_side_name(tmpname, primbase->object->id.name+2, TRUE); From 6a6c9fc160ef292e5949a27842cd4cae9653d346 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 08:05:23 +0000 Subject: [PATCH 55/73] function de-duplicate, particle.c had 'vert_weight' which serves the exact same purpose as 'defvert_find_weight'. --- source/blender/blenkernel/intern/particle.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0f2d14e3858..000df5e721d 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -79,6 +79,7 @@ #include "BKE_cdderivedmesh.h" #include "BKE_pointcache.h" #include "BKE_scene.h" +#include "BKE_deform.h" #include "RE_render_ext.h" @@ -1847,20 +1848,6 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int in /************************************************/ /* Path Cache */ /************************************************/ -static float vert_weight(MDeformVert *dvert, int group) -{ - MDeformWeight *dw; - int i; - - if(dvert) { - dw= dvert->dw; - for(i= dvert->totweight; i>0; i--, dw++) { - if(dw->def_nr == group) return dw->weight; - if(i==1) break; /*otherwise dw will point to somewhere it shouldn't*/ - } - } - return 0.0; -} static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float time, float freq, float shape, float amplitude, float flat, short type, short axis, float obmat[][4], int smooth_start) { @@ -2308,11 +2295,11 @@ float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) vg=MEM_callocN(sizeof(float)*totvert, "vg_cache"); if(psys->vg_neg&(1<vgroup[vgroup]-1); + vg[i]= 1.0f - defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1); } else{ for(i=0; ivgroup[vgroup]-1); + vg[i]= defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1); } } } From f025b7b51159cf3cdf49e9ec0eeaf4427010e1f7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 08:20:27 +0000 Subject: [PATCH 56/73] went over all uses of MDeformWeight.def_nr and made sure the value is clamped when used as an array index. --- source/blender/blenkernel/BKE_deform.h | 2 +- .../blender/blenkernel/intern/DerivedMesh.c | 28 ++++++++-------- source/blender/blenkernel/intern/armature.c | 10 +++--- source/blender/blenkernel/intern/deform.c | 28 +++++++++------- source/blender/editors/object/object_vgroup.c | 32 +++++++++---------- source/blender/modifiers/intern/MOD_mask.c | 15 +++++---- .../gameengine/Converter/BL_SkinDeformer.cpp | 6 ++-- 7 files changed, 64 insertions(+), 57 deletions(-) diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index b08afd9c475..9902b26e15b 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -63,7 +63,7 @@ void defvert_copy_index(struct MDeformVert *dvert_dst, const struct MDeformVert void defvert_sync(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, int use_verify); void defvert_sync_mapped(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const int *flip_map, const int flip_map_len, const int use_verify); -void defvert_remap (struct MDeformVert *dvert, int *map); +void defvert_remap (struct MDeformVert *dvert, int *map, const int map_len); void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len); void defvert_normalize(struct MDeformVert *dvert); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 1498a3b4cc0..4b91911a6ab 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -642,7 +642,7 @@ enum { }; static void calc_weightpaint_vert_color( - Object *ob, ColorBand *coba, int vert, unsigned char *col, + Object *ob, const int defbase_tot, ColorBand *coba, int vert, unsigned char *col, const char *dg_flags, int selected, int UNUSED(unselected), const int draw_flag) { Mesh *me = ob->data; @@ -661,10 +661,12 @@ static void calc_weightpaint_vert_color( for (i = dvert->totweight; i > 0; i--, dw++) { /* in multipaint, get the average if auto normalize is inactive * get the sum if it is active */ - if (dg_flags[dw->def_nr]) { - if (dw->weight) { - input += dw->weight; - was_a_nonzero= TRUE; + if (dw->def_nr < defbase_tot) { + if (dg_flags[dw->def_nr]) { + if (dw->weight) { + input += dw->weight; + was_a_nonzero= TRUE; + } } } } @@ -718,20 +720,20 @@ static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm, int const draw_flag) unsigned char *wtcol; int i; - int defbase_len = BLI_countlist(&ob->defbase); - char *defbase_sel = MEM_mallocN(defbase_len * sizeof(char), __func__); - int selected = get_selected_defgroups(ob, defbase_sel, defbase_len); - int unselected = defbase_len - selected; + int defbase_tot = BLI_countlist(&ob->defbase); + char *defbase_sel = MEM_mallocN(defbase_tot * sizeof(char), __func__); + int selected = get_selected_defgroups(ob, defbase_sel, defbase_tot); + int unselected = defbase_tot - selected; wtcol = MEM_callocN (sizeof (unsigned char) * me->totface*4*4, "weightmap"); memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4); for (i=0; itotface; i++, mf++) { - calc_weightpaint_vert_color(ob, coba, mf->v1, &wtcol[(i*4 + 0)*4], defbase_sel, selected, unselected, draw_flag); - calc_weightpaint_vert_color(ob, coba, mf->v2, &wtcol[(i*4 + 1)*4], defbase_sel, selected, unselected, draw_flag); - calc_weightpaint_vert_color(ob, coba, mf->v3, &wtcol[(i*4 + 2)*4], defbase_sel, selected, unselected, draw_flag); + calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v1, &wtcol[(i*4 + 0)*4], defbase_sel, selected, unselected, draw_flag); + calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v2, &wtcol[(i*4 + 1)*4], defbase_sel, selected, unselected, draw_flag); + calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v3, &wtcol[(i*4 + 2)*4], defbase_sel, selected, unselected, draw_flag); if (mf->v4) - calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4], defbase_sel, selected, unselected, draw_flag); + calc_weightpaint_vert_color(ob, defbase_tot, coba, mf->v4, &wtcol[(i*4 + 3)*4], defbase_sel, selected, unselected, draw_flag); } MEM_freeN(defbase_sel); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e7743bea2cd..e10c4b24458 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -827,7 +827,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, const short use_envelope = deformflag & ARM_DEF_ENVELOPE; const short use_quaternion = deformflag & ARM_DEF_QUATERNION; const short invert_vgroup= deformflag & ARM_DEF_INVERT_VGROUP; - int numGroups = 0; /* safety for vertexgroup index overflow */ + int defbase_tot = 0; /* safety for vertexgroup index overflow */ int i, target_totvert = 0; /* safety for vertexgroup overflow */ int use_dverts = 0; int armature_def_nr; @@ -869,7 +869,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, armature_def_nr= defgroup_name_index(target, defgrp_name); if(ELEM(target->type, OB_MESH, OB_LATTICE)) { - numGroups = BLI_countlist(&target->defbase); + defbase_tot = BLI_countlist(&target->defbase); if(target->type==OB_MESH) { Mesh *me= target->data; @@ -896,8 +896,8 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, else if(dverts) use_dverts = 1; if(use_dverts) { - defnrToPC = MEM_callocN(sizeof(*defnrToPC) * numGroups, "defnrToBone"); - defnrToPCIndex = MEM_callocN(sizeof(*defnrToPCIndex) * numGroups, "defnrToIndex"); + defnrToPC = MEM_callocN(sizeof(*defnrToPC) * defbase_tot, "defnrToBone"); + defnrToPCIndex = MEM_callocN(sizeof(*defnrToPCIndex) * defbase_tot, "defnrToIndex"); for(i = 0, dg = target->defbase.first; dg; i++, dg = dg->next) { defnrToPC[i] = get_pose_channel(armOb->pose, dg->name); @@ -975,7 +975,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, for(j = 0; j < dvert->totweight; j++){ int index = dvert->dw[j].def_nr; - if(index < numGroups && (pchan= defnrToPC[index])) { + if(index < defbase_tot && (pchan= defnrToPC[index])) { float weight = dvert->dw[j].weight; Bone *bone= pchan->bone; pdef_info= pdef_info_array + defnrToPCIndex[index]; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index e5176663228..94be15e27c0 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -161,12 +161,14 @@ void defvert_sync_mapped(MDeformVert *dvert_dst, const MDeformVert *dvert_src, } /* be sure all flip_map values are valid */ -void defvert_remap(MDeformVert *dvert, int *map) +void defvert_remap(MDeformVert *dvert, int *map, const int map_len) { MDeformWeight *dw; int i; for (i=0, dw=dvert->dw; itotweight; i++, dw++) { - dw->def_nr= map[dw->def_nr]; + if (dw->def_nr < map_len) { + dw->def_nr= map[dw->def_nr]; + } } } @@ -198,8 +200,10 @@ void defvert_flip(MDeformVert *dvert, const int *flip_map, const int flip_map_le int i; for (dw= dvert->dw, i=0; itotweight; dw++, i++) { - if ((dw->def_nr < flip_map_len) && (flip_map[dw->def_nr] >= 0)) { - dw->def_nr= flip_map[dw->def_nr]; + if (dw->def_nr < flip_map_len) { + if (flip_map[dw->def_nr] >= 0) { + dw->def_nr= flip_map[dw->def_nr]; + } } } } @@ -283,17 +287,17 @@ int defgroup_find_index(Object *ob, bDeformGroup *dg) /* note, must be freed */ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) { - int totdg= *flip_map_len= BLI_countlist(&ob->defbase); + int defbase_tot= *flip_map_len= BLI_countlist(&ob->defbase); - if (totdg==0) { + if (defbase_tot==0) { return NULL; } else { bDeformGroup *dg; char name[sizeof(dg->name)]; - int i, flip_num, *map= MEM_mallocN(totdg * sizeof(int), __func__); + int i, flip_num, *map= MEM_mallocN(defbase_tot * sizeof(int), __func__); - for (i=0; i < totdg; i++) { + for (i=0; i < defbase_tot; i++) { map[i]= -1; } @@ -321,17 +325,17 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) /* note, must be freed */ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, int defgroup) { - int totdg= *flip_map_len= BLI_countlist(&ob->defbase); + int defbase_tot= *flip_map_len= BLI_countlist(&ob->defbase); - if (totdg==0) { + if (defbase_tot==0) { return NULL; } else { bDeformGroup *dg; char name[sizeof(dg->name)]; - int i, flip_num, *map= MEM_mallocN(totdg * sizeof(int), __func__); + int i, flip_num, *map= MEM_mallocN(defbase_tot * sizeof(int), __func__); - for (i=0; i < totdg; i++) { + for (i=0; i < defbase_tot; i++) { if (use_default) map[i]= i; else map[i]= -1; } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 3401157359e..408558a30eb 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -286,8 +286,8 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from) int dvert_tot_from; int dvert_tot; int i; - int totdef_from= BLI_countlist(&ob_from->defbase); - int totdef= BLI_countlist(&ob->defbase); + int defbase_tot_from= BLI_countlist(&ob_from->defbase); + int defbase_tot= BLI_countlist(&ob->defbase); short new_vgroup= FALSE; ED_vgroup_give_parray(ob_from->data, &dvert_array_from, &dvert_tot_from); @@ -314,11 +314,11 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from) BLI_duplicatelist(&ob->defbase, &ob_from->defbase); ob->actdef= ob_from->actdef; - if(totdef_from < totdef) { + if(defbase_tot_from < defbase_tot) { /* correct vgroup indices because the number of vgroups is being reduced. */ - int *remap= MEM_mallocN(sizeof(int) * (totdef + 1), "ED_vgroup_copy_array"); - for(i=0; i<=totdef_from; i++) remap[i]= i; - for(; i<=totdef; i++) remap[i]= 0; /* can't use these, so disable */ + int *remap= MEM_mallocN(sizeof(int) * (defbase_tot + 1), "ED_vgroup_copy_array"); + for(i=0; i<=defbase_tot_from; i++) remap[i]= i; + for(; i<=defbase_tot; i++) remap[i]= 0; /* can't use these, so disable */ vgroup_remap_update_users(ob, remap); MEM_freeN(remap); @@ -1809,12 +1809,12 @@ static void vgroup_remap_update_users(Object *ob, int *map) static void vgroup_delete_update_users(Object *ob, int id) { - int i, tot= BLI_countlist(&ob->defbase) + 1; - int *map= MEM_mallocN(sizeof(int) * tot, "vgroup del"); + int i, defbase_tot= BLI_countlist(&ob->defbase) + 1; + int *map= MEM_mallocN(sizeof(int) * defbase_tot, "vgroup del"); map[id]= map[0]= 0; for(i=1; idefbase); - char *name_array= MEM_mallocN(MAX_VGROUP_NAME * sizeof(char) * def_tot, "sort vgroups"); + int defbase_tot = BLI_countlist(&ob->defbase); + char *name_array= MEM_mallocN(MAX_VGROUP_NAME * sizeof(char) * defbase_tot, "sort vgroups"); char *name; name= name_array; @@ -2834,8 +2834,8 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) { MDeformVert *dvert= NULL; bDeformGroup *def; - int def_tot = BLI_countlist(&ob->defbase); - int *sort_map_update= MEM_mallocN(sizeof(int) * (def_tot + 1), "sort vgroups"); /* needs a dummy index at the start*/ + int defbase_tot = BLI_countlist(&ob->defbase); + int *sort_map_update= MEM_mallocN(sizeof(int) * (defbase_tot + 1), "sort vgroups"); /* needs a dummy index at the start*/ int *sort_map= sort_map_update + 1; char *name; int i; @@ -2856,7 +2856,7 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) for(eve=em->verts.first; eve; eve=eve->next){ dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT); if(dvert && dvert->totweight){ - defvert_remap(dvert, sort_map); + defvert_remap(dvert, sort_map, defbase_tot); } } } @@ -2874,13 +2874,13 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) /*create as necassary*/ while(dvert && dvert_tot--) { if(dvert->totweight) - defvert_remap(dvert, sort_map); + defvert_remap(dvert, sort_map, defbase_tot); dvert++; } } /* update users */ - for(i=0; idefbase); /* check that there is armature object with bones to use, otherwise return original mesh */ if (ELEM3(NULL, mmd->ob_arm, mmd->ob_arm->pose, ob->defbase.first)) return derivedData; - bone_select_array= MEM_mallocN(BLI_countlist(&ob->defbase) * sizeof(char), "mask array"); + bone_select_array= MEM_mallocN(defbase_tot * sizeof(char), "mask array"); for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { @@ -194,12 +195,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, MDeformWeight *dw= dv->dw; int j; - for (j= dv->totweight; j > 0; j--, dw++) - { - if (bone_select_array[dw->def_nr]) - { - if(dw->weight != 0.0f) { - break; + for (j= dv->totweight; j > 0; j--, dw++) { + if (dw->def_nr < defbase_tot) { + if (bone_select_array[dw->def_nr]) { + if(dw->weight != 0.0f) { + break; + } } } } diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 81533205909..0c4806f4bd8 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -217,14 +217,14 @@ void BL_SkinDeformer::BGEDeformVerts() Object *par_arma = m_armobj->GetArmatureObject(); MDeformVert *dverts = m_bmesh->dvert; bDeformGroup *dg; - int numGroups = BLI_countlist(&m_objMesh->defbase); + int defbase_tot = BLI_countlist(&m_objMesh->defbase); if (!dverts) return; if (m_dfnrToPC == NULL) { - m_dfnrToPC = new bPoseChannel*[numGroups]; + m_dfnrToPC = new bPoseChannel*[defbase_tot]; int i; for (i=0, dg=(bDeformGroup*)m_objMesh->defbase.first; dg; @@ -260,7 +260,7 @@ void BL_SkinDeformer::BGEDeformVerts() { int index = dvert->dw[j].def_nr; - if (index < numGroups && (pchan=m_dfnrToPC[index])) + if (index < defbase_tot && (pchan=m_dfnrToPC[index])) { weight = dvert->dw[j].weight; From 2827f57f624cad8b2dec90ec8b94e115bf98268b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 10:19:11 +0000 Subject: [PATCH 57/73] global is python keyword so cant use as operator argument, also ran operator cheat sheet and made sure no syntax errors. + minor pep8 edits. --- .../startup/bl_operators/object_randomize_transform.py | 5 +++-- release/scripts/startup/bl_operators/wm.py | 4 ++-- source/blender/editors/object/object_add.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index 319fd1526fb..fa36e48d47b 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -22,6 +22,7 @@ import bpy from bpy.types import Operator from mathutils import Vector + def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): import random @@ -44,9 +45,9 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): if rot: vec = rand_vec(rot) - + rotation_mode = obj.rotation_mode - if rotation_mode in ('QUATERNION', 'AXIS_ANGLE'): + if rotation_mode in {'QUATERNION', 'AXIS_ANGLE'}: obj.rotation_mode = 'XYZ' if delta: diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 14c9a090529..89029e3af01 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -457,8 +457,8 @@ class WM_OT_context_cycle_enum(Operator): class WM_OT_context_cycle_array(Operator): - '''Set a context array value. - Useful for cycling the active mesh edit mode''' + '''Set a context array value. ''' + '''Useful for cycling the active mesh edit mode''' bl_idname = "wm.context_cycle_array" bl_label = "Context Array Cycle" bl_options = {'UNDO', 'INTERNAL'} diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 855b67b71bc..8c60a4d5868 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -893,7 +893,7 @@ static int object_delete_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - const short use_global= RNA_boolean_get(op->ptr, "global"); + const short use_global= RNA_boolean_get(op->ptr, "use_global"); /* int islamp= 0; */ /* UNUSED */ if(CTX_data_edit_object(C)) @@ -951,7 +951,7 @@ void OBJECT_OT_delete(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "global", 0, "Delete Globally", "Remove object from all scenes"); + RNA_def_boolean(ot->srna, "use_global", 0, "Delete Globally", "Remove object from all scenes"); } /**************************** Copy Utilities ******************************/ From 9d807eb6ddaead5e3d29bdb53cbad5060f636c7b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 9 Dec 2011 11:46:48 +0000 Subject: [PATCH 58/73] Mesh drawing optimization and fixes: - Pass MFace, MTface and OrigIndex arrays via userData to compareDrawParams callback rather than looking up for this layers for each face - This allowed to avoid massing DM to compare callback which seems like a bad-level pass - Fixed crashes on some video cards when assigning different materials to different faces in edit mode. Both of intel and nvidia cards in my laptop were affected by this error --- .../blenkernel/intern/editderivedmesh.c | 13 ++++++-- .../blender/editors/space_view3d/drawmesh.c | 30 ++++++++++--------- .../blender/editors/space_view3d/drawobject.c | 15 +++++----- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 8eccfd4d3f0..bb1d20f0187 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -273,7 +273,7 @@ static void emDM_drawMappedFaces( { EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; EditFace *efa; - int i, draw; + int i, draw, flush; const int skip_normals= !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */ /* GL_ZERO is used to detect if drawing has started or not */ @@ -352,7 +352,11 @@ static void emDM_drawMappedFaces( } } - if (draw==2) { + flush= (draw==2); + if (!skip_normals && !flush && efa->next) + flush|= efa->mat_nr != efa->next->mat_nr; + + if (flush) { glEnd(); poly_prev= GL_ZERO; /* force glBegin */ @@ -419,8 +423,11 @@ static void emDM_drawMappedFaces( } } + flush= (draw==2); + if (!skip_normals && !flush && efa->next) + flush|= efa->mat_nr != efa->next->mat_nr; - if (draw==2) { + if (flush) { glEnd(); poly_prev= GL_ZERO; /* force glBegin */ diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index e83591b73f5..6dd362b827f 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -513,7 +513,7 @@ static int draw_tface_mapped__set_draw(void *userData, int index) static int draw_em_tf_mapped__set_draw(void *userData, int index) { - struct {DerivedMesh *dm; EditMesh *em; short has_mcol; short has_mtface;} *data = userData; + struct {EditMesh *em; short has_mcol; short has_mtface; MFace *mf; MTFace *tf;} *data = userData; EditMesh *em = data->em; EditFace *efa= EM_get_face_for_index(index); MTFace *tface; @@ -631,14 +631,12 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) static int compareDrawOptions(void *userData, int cur_index, int next_index) { - DerivedMesh *dm= (DerivedMesh*) userData; - MFace *mf = DM_get_face_data_layer(dm, CD_MFACE); - MTFace *tf = DM_get_face_data_layer(dm, CD_MTFACE); + struct { MFace *mf; MTFace *tf; } *data = userData; - if(mf && mf[cur_index].mat_nr != mf[next_index].mat_nr) + if(data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr) return 0; - if(tf && tf[cur_index].tpage != tf[next_index].tpage) + if(data->tf && data->tf[cur_index].tpage != data->tf[next_index].tpage) return 0; return 1; @@ -646,14 +644,12 @@ static int compareDrawOptions(void *userData, int cur_index, int next_index) static int compareDrawOptionsEm(void *userData, int cur_index, int next_index) { - struct {DerivedMesh *dm; EditMesh *em; short has_mcol; short has_mtface;} *data= userData; - MFace *mf = DM_get_face_data_layer(data->dm, CD_MFACE); - MTFace *tf = DM_get_face_data_layer(data->dm, CD_MTFACE); + struct {EditMesh *em; short has_mcol; short has_mtface; MFace *mf; MTFace *tf;} *data= userData; - if(mf && mf[cur_index].mat_nr != mf[next_index].mat_nr) + if(data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr) return 0; - if(tf && tf[cur_index].tpage != tf[next_index].tpage) + if(data->tf && data->tf[cur_index].tpage != data->tf[next_index].tpage) return 0; return 1; @@ -673,12 +669,13 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec glColor4f(1.0f,1.0f,1.0f,1.0f); if(ob->mode & OB_MODE_EDIT) { - struct {DerivedMesh *dm; EditMesh *em; short has_mcol; short has_mtface;} data; + struct {EditMesh *em; short has_mcol; short has_mtface; MFace *mf; MTFace *tf;} data; - data.dm = dm; data.em= me->edit_mesh; data.has_mcol= CustomData_has_layer(&me->edit_mesh->fdata, CD_MCOL); data.has_mtface= CustomData_has_layer(&me->edit_mesh->fdata, CD_MTFACE); + data.mf= DM_get_face_data_layer(dm, CD_MFACE); + data.tf= DM_get_face_data_layer(dm, CD_MTFACE); dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, compareDrawOptionsEm, &data); } @@ -696,10 +693,15 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec dm->drawFacesTex(dm, draw_tface__set_draw_legacy, NULL, NULL); } else { + struct { MFace *mf; MTFace *tf; } userData; + if(!CustomData_has_layer(&dm->faceData,CD_TEXTURE_MCOL)) add_tface_color_layer(dm); - dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, dm); + userData.mf = DM_get_face_data_layer(dm, CD_MFACE); + userData.tf = DM_get_face_data_layer(dm, CD_MTFACE); + + dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, &userData); } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f6f2c35163f..b3eba8652b0 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2349,7 +2349,7 @@ static void draw_dm_edges_sharp(DerivedMesh *dm) * return 2 for the active face so it renders with stipple enabled */ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNUSED(drawSmooth_r)) { - struct { DerivedMesh *dm; unsigned char *cols[3]; EditFace *efa_act; } * data = userData; + struct { unsigned char *cols[3]; EditFace *efa_act; int *orig_index; } * data = userData; EditFace *efa = EM_get_face_for_index(index); unsigned char *col; @@ -2369,17 +2369,16 @@ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNU static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index) { - struct { DerivedMesh *dm; unsigned char *cols[3]; EditFace *efa_act; } *data = userData; - int *orig_index= DM_get_face_data_layer(data->dm, CD_ORIGINDEX); + struct { unsigned char *cols[3]; EditFace *efa_act; int *orig_index; } *data = userData; EditFace *efa; EditFace *next_efa; unsigned char *col, *next_col; - if(!orig_index) + if(!data->orig_index) return 0; - efa= EM_get_face_for_index(orig_index[index]); - next_efa= EM_get_face_for_index(orig_index[next_index]); + efa= EM_get_face_for_index(data->orig_index[index]); + next_efa= EM_get_face_for_index(data->orig_index[next_index]); if(efa == next_efa) return 1; @@ -2399,12 +2398,12 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int /* also draws the active face */ static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act) { - struct { DerivedMesh *dm; unsigned char *cols[3]; EditFace *efa_act; } data; - data.dm= dm; + struct { unsigned char *cols[3]; EditFace *efa_act; int *orig_index; } data; data.cols[0] = baseCol; data.cols[1] = selCol; data.cols[2] = actCol; data.efa_act = efa_act; + data.orig_index = DM_get_face_data_layer(dm, CD_ORIGINDEX); dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions, &data, 0); } From 707e0da6f4952adb8e23fd48a2ee7581e98f44cc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 9 Dec 2011 14:30:44 +0000 Subject: [PATCH 59/73] Fix for select similar vertices operator: it's exec used to return selection count instead of OPERATOR_* return values which used to confuse operators system. --- source/blender/editors/mesh/editmesh_mods.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index b1754fa2f2e..0d268f8f4c1 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -1166,7 +1166,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) deselcount--; if (!deselcount) {/*have we selected all posible faces?, if so return*/ BKE_mesh_end_editmesh(me, em); - return selcount; + return OPERATOR_FINISHED; } } } @@ -1184,7 +1184,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) deselcount--; if (!deselcount) {/*have we selected all posible faces?, if so return*/ BKE_mesh_end_editmesh(me, em); - return selcount; + return OPERATOR_FINISHED; } } } @@ -1198,7 +1198,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) if (!base_dvert || base_dvert->totweight == 0) { BKE_mesh_end_editmesh(me, em); - return selcount; + return OPERATOR_FINISHED; } for(eve= em->verts.first; eve; eve= eve->next) { @@ -1216,7 +1216,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) deselcount--; if (!deselcount) { /*have we selected all posible faces?, if so return*/ BKE_mesh_end_editmesh(me, em); - return selcount; + return OPERATOR_FINISHED; } break; } From 3e90bfb07b3bfafd89e499c5dbe2fa78fc22cad8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 9 Dec 2011 15:56:04 +0000 Subject: [PATCH 60/73] Fix for recent rna rename of global to use_global --- source/blender/editors/object/object_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index b7fe2d70b37..3b4a5ed976e 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -338,9 +338,9 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_move_to_layer", MKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "global", TRUE); + RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "use_global", TRUE); WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "global", TRUE); + RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "use_global", TRUE); WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); From c804f4002783a3bd14b67faf7c2b6b0be9bad85e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 9 Dec 2011 16:10:15 +0000 Subject: [PATCH 61/73] Fix #29558: Selecting similar edges doesn't work Return OPERATOR_FINISHED from select grouped operator in any case so even if nothing were selected operator would be registered in redo panel and threshold can be adjusted there. --- source/blender/editors/mesh/editmesh_mods.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 0d268f8f4c1..a6e6a041090 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -873,12 +873,10 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) /* here was an edge-mode only select flush case, has to be generalized */ EM_selectmode_flush(em); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); - BKE_mesh_end_editmesh(me, em); - return OPERATOR_FINISHED; } BKE_mesh_end_editmesh(me, em); - return OPERATOR_CANCELLED; + return OPERATOR_FINISHED; } /* ***************************************************** */ @@ -1092,12 +1090,10 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) /* here was an edge-mode only select flush case, has to be generalized */ EM_selectmode_flush(em); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); - BKE_mesh_end_editmesh(me, em); - return OPERATOR_FINISHED; } - + BKE_mesh_end_editmesh(me, em); - return OPERATOR_CANCELLED; + return OPERATOR_FINISHED; } /* ********************************* */ @@ -1135,7 +1131,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) if (!ok || !deselcount) { /* no data selected OR no more data to select*/ BKE_mesh_end_editmesh(me, em); - return 0; + return OPERATOR_CANCELLED; } if(mode == SIMVERT_FACE) { @@ -1230,12 +1226,10 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) if(selcount) { WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); - BKE_mesh_end_editmesh(me, em); - return OPERATOR_FINISHED; } BKE_mesh_end_editmesh(me, em); - return OPERATOR_CANCELLED; + return OPERATOR_FINISHED; } static int select_similar_exec(bContext *C, wmOperator *op) From 71ea408c736583fc0e009c5a97340d4493378ec3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 20:29:21 +0000 Subject: [PATCH 62/73] check for weights outside of 0-1 range when validating weights --- source/blender/blenkernel/intern/mesh_validate.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 774565bb4bd..5a53d953f1b 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -325,8 +325,8 @@ int BKE_mesh_validate_arrays( Mesh *me, if (dverts) { MDeformVert *dv; for(i=0, dv= dverts; idw; - unsigned int j= 0; + MDeformWeight *dw; + unsigned int j; for(j=0, dw= dv->dw; j < dv->totweight; j++, dw++) { /* note, greater then max defgroups is accounted for in our code, but not < 0 */ @@ -337,6 +337,13 @@ int BKE_mesh_validate_arrays( Mesh *me, vert_weights_fixed= TRUE; } } + else if (dw->weight < 0.0f || dw->weight > 1.0f) { + PRINT(" vertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight); + if (do_fixes) { + CLAMP(dw->weight, 0.0f, 1.0f); + vert_weights_fixed= TRUE; + } + } if (dw->def_nr < 0) { PRINT(" vertex deform %u, has invalid group %d\n", i, dw->def_nr); From 82480e99954f3618e953c5f669577efd72ba3f1f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Dec 2011 21:07:37 +0000 Subject: [PATCH 63/73] fix for bpy_extras.image_utils.load_image() making a placeholder image when passed a path in bytes. made OBJ import fail when the image was missing. --- release/scripts/modules/bpy_extras/image_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/release/scripts/modules/bpy_extras/image_utils.py b/release/scripts/modules/bpy_extras/image_utils.py index 52050b08bc7..6d02b2b7af9 100644 --- a/release/scripts/modules/bpy_extras/image_utils.py +++ b/release/scripts/modules/bpy_extras/image_utils.py @@ -104,7 +104,10 @@ def load_image(imagepath, return _image_load(nfilepath) if place_holder: - image = bpy.data.images.new(bpy.path.basename(imagepath), 128, 128) + name = bpy.path.basename(imagepath) + if type(name) == bytes: + name = name.decode('utf-8', "replace") + image = bpy.data.images.new(name, 128, 128) # allow the path to be resolved later image.filepath = imagepath return image From 965c287630b7528a4a0b146212e8f1783a904948 Mon Sep 17 00:00:00 2001 From: Morten Mikkelsen Date: Fri, 9 Dec 2011 23:26:06 +0000 Subject: [PATCH 64/73] fixes scale on derivative maps --- source/blender/blenkernel/BKE_DerivedMesh.h | 2 + .../blender/blenkernel/intern/DerivedMesh.c | 158 ++++++++++++++++++ source/blender/gpu/GPU_material.h | 6 +- source/blender/gpu/intern/gpu_codegen.c | 2 + source/blender/gpu/intern/gpu_draw.c | 3 +- source/blender/gpu/intern/gpu_material.c | 49 +++--- source/blender/python/intern/gpu.c | 1 + .../render/intern/source/render_texture.c | 21 ++- source/gameengine/Ketsji/BL_BlenderShader.cpp | 3 +- 9 files changed, 214 insertions(+), 31 deletions(-) diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 429d5e84785..5f451ce7821 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -94,6 +94,7 @@ struct DerivedMesh { BVHCache bvhCache; struct GPUDrawObject *drawObject; DerivedMeshType type; + float auto_bump_scale; /* Misc. Queries */ @@ -578,6 +579,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, struct GPUVertexAttribs *gattribs, DMVertexAttribs *attribs); void DM_add_tangent_layer(DerivedMesh *dm); +void DM_calc_auto_bump_scale(DerivedMesh *dm); /* Set object's bounding box based on DerivedMesh min/max data */ void DM_set_object_boundbox(struct Object *ob, DerivedMesh *dm); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 4b91911a6ab..c829d840ace 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -184,6 +184,7 @@ void DM_init(DerivedMesh *dm, DerivedMeshType type, DM_init_funcs(dm); dm->needsFree = 1; + dm->auto_bump_scale = -1.0f; } void DM_from_template(DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type, @@ -1831,6 +1832,159 @@ void DM_add_tangent_layer(DerivedMesh *dm) MEM_freeN(vtangents); } +void DM_calc_auto_bump_scale(DerivedMesh *dm) +{ + int totvert= dm->getNumVerts(dm); + int totface= dm->getNumFaces(dm); + + MVert * mvert = dm->getVertArray(dm); + MFace * mface = dm->getFaceArray(dm); + MTFace * mtface = dm->getFaceDataArray(dm, CD_MTFACE); + + if(mtface) + { + double dsum = 0.0; + int nr_accumulated = 0; + int f; + + for ( f=0; fFLT_EPSILON ) + { + float norm[3], v0[3], v1[3], f2x_surf_area, fsurf_ratio; + sub_v3_v3v3(v0, p1, p0); + sub_v3_v3v3(v1, p2, p0); + cross_v3_v3v3(norm, v0, v1); + + f2x_surf_area = len_v3(norm); + fsurf_ratio = f2x_surf_area/f2x_area_uv; // tri area divided by texture area + + ++nr_accumulated; + dsum += (double)(fsurf_ratio); + } + } + } + } + } + } + + // finalize + { + const float avg_area_ratio = (nr_accumulated>0) ? ((float)(dsum / nr_accumulated)) : 1.0f; + const float use_as_render_bump_scale = sqrtf(avg_area_ratio); // use width of average surface ratio as your bump scale + dm->auto_bump_scale = use_as_render_bump_scale; + } + } + else + { + dm->auto_bump_scale = 1.0f; + } +} + void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, DMVertexAttribs *attribs) { CustomData *vdata, *fdata, *tfdata = NULL; @@ -1851,6 +2005,10 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, else tfdata = fdata; + /* calc auto bump scale if necessary */ + if(dm->auto_bump_scale<=0.0f) + DM_calc_auto_bump_scale(dm); + /* add a tangent layer if necessary */ for(b = 0; b < gattribs->totlayer; b++) if(gattribs->layer[b].type == CD_TANGENT) diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 418bea5fe9c..5689f02d2d7 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -83,7 +83,8 @@ typedef enum GPUBuiltin { GPU_INVERSE_OBJECT_MATRIX = 8, GPU_VIEW_POSITION = 16, GPU_VIEW_NORMAL = 32, - GPU_OBCOLOR = 64 + GPU_OBCOLOR = 64, + GPU_AUTO_BUMPSCALE = 128 } GPUBuiltin; typedef enum GPUBlendMode { @@ -129,7 +130,7 @@ void GPU_material_free(struct Material *ma); void GPU_materials_free(void); void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap); -void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4]); +void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4], float autobumpscale); void GPU_material_unbind(GPUMaterial *material); int GPU_material_bound(GPUMaterial *material); @@ -162,6 +163,7 @@ typedef enum GPUDynamicType { GPU_DYNAMIC_OBJECT_VIEWIMAT = 3, GPU_DYNAMIC_OBJECT_IMAT = 4, GPU_DYNAMIC_OBJECT_COLOR = 5, + GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE = 15, GPU_DYNAMIC_LAMP_FIRST = 6, GPU_DYNAMIC_LAMP_DYNVEC = 6, GPU_DYNAMIC_LAMP_DYNCO = 7, diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 185f9eb185e..05c459b703d 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -344,6 +344,8 @@ const char *GPU_builtin_name(GPUBuiltin builtin) return "varnormal"; else if(builtin == GPU_OBCOLOR) return "unfobcolor"; + else if(builtin == GPU_AUTO_BUMPSCALE) + return "unfobautobumpscale"; else return ""; } diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 3cd3cde8aad..6a11010002f 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -60,6 +60,7 @@ #include "BKE_node.h" #include "BKE_object.h" #include "BKE_scene.h" +#include "BKE_DerivedMesh.h" #include "BLI_threads.h" #include "BLI_blenlib.h" @@ -1159,7 +1160,7 @@ int GPU_enable_material(int nr, void *attribs) gpumat = GPU_material_from_blender(GMS.gscene, mat); GPU_material_vertex_attributes(gpumat, gattribs); GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT)); - GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col); + GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col, GMS.gob->derivedFinal->auto_bump_scale); GMS.gboundmat= mat; /* for glsl use alpha blend mode, unless it's set to solid and diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 397c0e32c69..2d8487deb71 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -94,7 +94,7 @@ struct GPUMaterial { /* for passing uniforms */ int viewmatloc, invviewmatloc; int obmatloc, invobmatloc; - int obcolloc; + int obcolloc, obautobumpscaleloc; ListBase lamps; }; @@ -212,7 +212,8 @@ static int GPU_material_construct_end(GPUMaterial *material) material->invobmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_OBJECT_MATRIX)); if(material->builtins & GPU_OBCOLOR) material->obcolloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBCOLOR)); - + if(material->builtins & GPU_AUTO_BUMPSCALE) + material->obautobumpscaleloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_AUTO_BUMPSCALE)); return 1; } @@ -273,7 +274,7 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim } } -void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4]) +void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4], float autobumpscale) { if(material->pass) { GPUShader *shader = GPU_pass_shader(material->pass); @@ -300,7 +301,9 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float v CLAMP(col[3], 0.0f, 1.0f); GPU_shader_uniform_vector(shader, material->obcolloc, 4, 1, col); } - + if(material->builtins & GPU_AUTO_BUMPSCALE) { + GPU_shader_uniform_vector(shader, material->obautobumpscaleloc, 1, 1, &autobumpscale); + } /* update lamps */ for(nlink=material->lamps.first; nlink; nlink=nlink->next) { lamp= nlink->data; @@ -1087,8 +1090,7 @@ static void do_material_tex(GPUShadeInput *shi) /* ntap bumpmap image */ int iBumpSpace; float ima_x, ima_y; - float hScale = 0.1f; // compatibility adjustment factor for all bumpspace types - float hScaleTex = 13.0f; // factor for scaling texspace bumps + float hScale; float imag_tspace_dimension_x = 1024.0f; // only used for texture space variant float aspect = 1.0f; @@ -1096,16 +1098,35 @@ static void do_material_tex(GPUShadeInput *shi) GPUNodeLink *surf_pos = GPU_builtin(GPU_VIEW_POSITION); GPUNodeLink *vR1, *vR2; GPUNodeLink *dBs, *dBt, *fDet; - + + hScale = 0.1; // compatibility adjustment factor for all bumpspace types if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) - hScale = hScaleTex; + hScale = 13.0f; // factor for scaling texspace bumps + else if(found_deriv_map!=0) + hScale = 1.0f; + + // resolve texture resolution + if( (mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map ) { + ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, &tex->iuser); + ima_x= 512.0f; ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only + if(ibuf) { + ima_x= ibuf->x; + ima_y= ibuf->y; + aspect = ((float) ima_y) / ima_x; + } + } // The negate on norfac is done because the // normal in the renderer points inward which corresponds // to inverting the bump map. Should this ever change // this negate must be removed. norfac = -hScale * mtex->norfac; + if(found_deriv_map) norfac /= sqrtf(ima_x*ima_y); + tnorfac = GPU_uniform(&norfac); + + if(found_deriv_map) + GPU_link(mat, "math_multiply", tnorfac, GPU_builtin(GPU_AUTO_BUMPSCALE), &tnorfac); if(GPU_link_changed(stencil)) GPU_link(mat, "math_multiply", tnorfac, stencil, &tnorfac); @@ -1152,17 +1173,6 @@ static void do_material_tex(GPUShadeInput *shi) iBumpSpacePrev = iBumpSpace; } - - // resolve texture resolution - if( (mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map ) { - ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, &tex->iuser); - ima_x= 512.0f; ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only - if(ibuf) { - ima_x= ibuf->x; - ima_y= ibuf->y; - aspect = ((float) ima_y) / ima_x; - } - } if(found_deriv_map) { @@ -1703,6 +1713,7 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma) { GPU_OBJECT_MATRIX, GPU_DYNAMIC_OBJECT_MAT, GPU_DATA_16F }, { GPU_INVERSE_OBJECT_MATRIX, GPU_DYNAMIC_OBJECT_IMAT, GPU_DATA_16F }, { GPU_OBCOLOR, GPU_DYNAMIC_OBJECT_COLOR, GPU_DATA_4F }, + { GPU_AUTO_BUMPSCALE, GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE, GPU_DATA_1F }, { 0 } }; diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index 57ce7b59067..0da63297077 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -87,6 +87,7 @@ PyInit_gpu(void) PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWIMAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_IMAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_COLOR); + PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNVEC); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNCO); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_LAMP_DYNIMAT); diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index ae48b0f777f..e55d2676b17 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1932,11 +1932,13 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T float *nvec = texres->nor; texres->nor = NULL; - if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { - if(tex->ima) - Hscale *= 13.0f; // appears to be a sensible default value - } else - Hscale *= 0.1f; // factor 0.1 proved to look like the previous bump code + if(found_deriv_map==0) { + if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { + if(tex->ima) + Hscale *= 13.0f; // appears to be a sensible default value + } else + Hscale *= 0.1f; // factor 0.1 proved to look like the previous bump code + } if( !ntap_bump->init_done ) { copy_v3_v3(ntap_bump->vNacc, shi->vn); @@ -1958,15 +1960,18 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } if(found_deriv_map) { - float dBdu, dBdv; + float dBdu, dBdv, auto_bump; float s = 1; // negate this if flipped texture coordinate texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); + + auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale; + auto_bump /= sqrtf((float) (dimx*dimy)); // this variant using a derivative map is described here // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html - dBdu = Hscale*dimx*(2*texres->tr-1); - dBdv = Hscale*dimy*(2*texres->tg-1); + dBdu = auto_bump*Hscale*dimx*(2*texres->tr-1); + dBdv = auto_bump*Hscale*dimy*(2*texres->tg-1); dHdx = dBdu*dxt[0] + s * dBdv*dxt[1]; dHdy = dBdu*dyt[0] + s * dBdv*dyt[1]; diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 6680e9556b9..52c9846772d 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -8,6 +8,7 @@ #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_DerivedMesh.h" #include "BL_BlenderShader.h" #include "BL_Material.h" @@ -146,7 +147,7 @@ void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty ) else obcol[0]= obcol[1]= obcol[2]= obcol[3]= 1.0f; - GPU_material_bind_uniforms(gpumat, obmat, viewmat, viewinvmat, obcol); + GPU_material_bind_uniforms(gpumat, obmat, viewmat, viewinvmat, obcol, ms.m_pDerivedMesh->auto_bump_scale); mAlphaBlend = GPU_material_alpha_blend(gpumat, obcol); } From 82b9e4d16f08e8ca1b3fee84226334b3012aaed3 Mon Sep 17 00:00:00 2001 From: Morten Mikkelsen Date: Sat, 10 Dec 2011 01:00:12 +0000 Subject: [PATCH 65/73] verify existence of dm --- source/blender/gpu/intern/gpu_draw.c | 5 ++++- source/blender/render/intern/source/render_texture.c | 9 ++++++--- source/gameengine/Ketsji/BL_BlenderShader.cpp | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 6a11010002f..2d2da3c592d 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1156,11 +1156,14 @@ int GPU_enable_material(int nr, void *attribs) if(gattribs && GMS.gmatbuf[nr]) { /* bind glsl material and get attributes */ Material *mat = GMS.gmatbuf[nr]; + float auto_bump_scale; gpumat = GPU_material_from_blender(GMS.gscene, mat); GPU_material_vertex_attributes(gpumat, gattribs); GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT)); - GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col, GMS.gob->derivedFinal->auto_bump_scale); + + auto_bump_scale = GMS.gob->derivedFinal!=0 ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f; + GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col, auto_bump_scale); GMS.gboundmat= mat; /* for glsl use alpha blend mode, unless it's set to solid and diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index e55d2676b17..fe9312e37d5 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1960,13 +1960,16 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } if(found_deriv_map) { - float dBdu, dBdv, auto_bump; + float dBdu, dBdv, auto_bump = 1.0f; float s = 1; // negate this if flipped texture coordinate texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); - auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale; - auto_bump /= sqrtf((float) (dimx*dimy)); + if(shi->obr->ob->derivedFinal) + { + auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale; + auto_bump /= sqrtf((float) (dimx*dimy)); + } // this variant using a derivative map is described here // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 52c9846772d..0f97898c73f 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -147,7 +147,8 @@ void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty ) else obcol[0]= obcol[1]= obcol[2]= obcol[3]= 1.0f; - GPU_material_bind_uniforms(gpumat, obmat, viewmat, viewinvmat, obcol, ms.m_pDerivedMesh->auto_bump_scale); + float auto_bump_scale = ms.m_pDerivedMesh!=0 ? ms.m_pDerivedMesh->auto_bump_scale : 1.0f; + GPU_material_bind_uniforms(gpumat, obmat, viewmat, viewinvmat, obcol, auto_bump_scale); mAlphaBlend = GPU_material_alpha_blend(gpumat, obcol); } From 87ff925d909f75d2eb63ced6610c81f0b59c1fef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 10 Dec 2011 01:01:22 +0000 Subject: [PATCH 66/73] fix for error in bpy_extras.image_utils.load_image() when the image file exists but cant be read (wrong permissions for eg). --- .../scripts/modules/bpy_extras/image_utils.py | 39 ++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/release/scripts/modules/bpy_extras/image_utils.py b/release/scripts/modules/bpy_extras/image_utils.py index 6d02b2b7af9..7d409510c85 100644 --- a/release/scripts/modules/bpy_extras/image_utils.py +++ b/release/scripts/modules/bpy_extras/image_utils.py @@ -65,19 +65,45 @@ def load_image(imagepath, # TODO: recursive + # ------------------------------------------------------------------------- + # Utility Functions + + def _image_load_placeholder(path): + name = bpy.path.basename(path) + if type(name) == bytes: + name = name.decode('utf-8', "replace") + image = bpy.data.images.new(name, 128, 128) + # allow the path to be resolved later + image.filepath = path + image.source = 'FILE' + return image + def _image_load(path): import bpy if convert_callback: path = convert_callback(path) - image = bpy.data.images.load(path) + try: + image = bpy.data.images.load(path) + except RuntimeError: + image = None if verbose: - print(" image loaded '%s'" % path) + if image: + print(" image loaded '%s'" % path) + else: + print(" image load failed '%s'" % path) + + # image path has been checked so the path could not be read for some + # reason, so be sure to return a placeholder + if place_holder: + image = _image_load_placeholder(path) return image + # ------------------------------------------------------------------------- + if verbose: print("load_image('%s', '%s', ...)" % (imagepath, dirname)) @@ -103,14 +129,9 @@ def load_image(imagepath, if os.path.exists(nfilepath): return _image_load(nfilepath) + # None of the paths exist so return placeholder if place_holder: - name = bpy.path.basename(imagepath) - if type(name) == bytes: - name = name.decode('utf-8', "replace") - image = bpy.data.images.new(name, 128, 128) - # allow the path to be resolved later - image.filepath = imagepath - return image + return _image_load_placeholder(imagepath) # TODO comprehensiveImageLoad also searched in bpy.config.textureDir return None From ae17390b77bfda18d387da32d1158530c19c1fa5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 10 Dec 2011 01:07:22 +0000 Subject: [PATCH 67/73] picky edits & regen man page --- doc/manpage/blender.1 | 7 +++---- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/gpu/intern/gpu_draw.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/manpage/blender.1 b/doc/manpage/blender.1 index 620a90e61d2..169006fc609 100644 --- a/doc/manpage/blender.1 +++ b/doc/manpage/blender.1 @@ -1,4 +1,4 @@ -.TH "BLENDER" "1" "October 17, 2011" "Blender Blender 2\&.60 (sub 0)" +.TH "BLENDER" "1" "December 10, 2011" "Blender Blender 2\&.60 (sub 7)" .SH NAME blender \- a 3D modelling and rendering package @@ -15,7 +15,7 @@ Use Blender to create TV commercials, to make technical visualizations, business http://www.blender.org .SH OPTIONS -Blender 2.59 (sub 4) +Blender 2.60 (sub 7) Usage: blender [args ...] [file] [args ...] .br .SS "Render Options:" @@ -378,11 +378,10 @@ Arguments are executed in the order they are given. eg \fIBLENDER_USER_CONFIG\fR Directory for user configuration files. \fIBLENDER_USER_SCRIPTS\fR Directory for user scripts. \fIBLENDER_SYSTEM_SCRIPTS\fR Directory for system wide scripts. - \fIBLENDER_USER_DATAFILES\fR Directory for user data files (icons, translations, ..). + \fIBLENDER_USER_DAT`AFILES\fR Directory for user data files (icons, translations, ..). \fIBLENDER_SYSTEM_DATAFILES\fR Directory for system wide data files. \fIBLENDER_SYSTEM_PYTHON\fR Directory for system python libraries. \fITMP\fR or \fITMPDIR\fR Store temporary files here. - \fISDL_AUDIODRIVER\fR LibSDL audio driver \- alsa, esd, dma. \fIPYTHONHOME\fR Path to the python directory, eg. /usr/lib/python. .br .br diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c829d840ace..06f29b95825 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1834,7 +1834,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) void DM_calc_auto_bump_scale(DerivedMesh *dm) { - int totvert= dm->getNumVerts(dm); + /* int totvert= dm->getNumVerts(dm); */ /* UNUSED */ int totface= dm->getNumFaces(dm); MVert * mvert = dm->getVertArray(dm); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 2d2da3c592d..d63be22bc13 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1162,7 +1162,7 @@ int GPU_enable_material(int nr, void *attribs) GPU_material_vertex_attributes(gpumat, gattribs); GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT)); - auto_bump_scale = GMS.gob->derivedFinal!=0 ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f; + auto_bump_scale = GMS.gob->derivedFinal != NULL GMS.gob->derivedFinal->auto_bump_scale : 1.0f; GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col, auto_bump_scale); GMS.gboundmat= mat; From 0cc887e2e9428c0a6715e322071c30e6d10e2506 Mon Sep 17 00:00:00 2001 From: Morten Mikkelsen Date: Sat, 10 Dec 2011 01:14:36 +0000 Subject: [PATCH 68/73] disabling DM_calc_auto_bump_scale() until after release --- source/blender/blenkernel/intern/DerivedMesh.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 06f29b95825..0087b91c615 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2006,8 +2006,13 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, tfdata = fdata; /* calc auto bump scale if necessary */ +#if 0 if(dm->auto_bump_scale<=0.0f) DM_calc_auto_bump_scale(dm); +#else + dm->auto_bump_scale = 1.0f; // will revert this after release +#endif + /* add a tangent layer if necessary */ for(b = 0; b < gattribs->totlayer; b++) From 3f39fde3739aaafecd794786aeed896d4f228403 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 10 Dec 2011 03:24:19 +0000 Subject: [PATCH 69/73] Compile fix for r.42546 typo --- source/blender/gpu/intern/gpu_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index d63be22bc13..4af0cceb4e0 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1162,7 +1162,7 @@ int GPU_enable_material(int nr, void *attribs) GPU_material_vertex_attributes(gpumat, gattribs); GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT)); - auto_bump_scale = GMS.gob->derivedFinal != NULL GMS.gob->derivedFinal->auto_bump_scale : 1.0f; + auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f; GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gviewinv, GMS.gob->col, auto_bump_scale); GMS.gboundmat= mat; From a88b29c062f32514e4414bfd4006f7b348077a42 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 10 Dec 2011 03:37:37 +0000 Subject: [PATCH 70/73] Bugfix [#29567] Second Hook Modifier fails on Curve Object This was broken in r.42515. In particular, rigs with Spline IK would break, since they often use curves with hook modifiers controlling the control-points of those curves. --- source/blender/modifiers/intern/MOD_hook.c | 24 ++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 9e48c5d29e2..b5cf289f4ce 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -185,22 +185,20 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, const float fac_orig= hmd->force; float fac; const int *origindex_ar; - - /* if DerivedMesh is present and has original index data, - * use it - */ + + /* if DerivedMesh is present and has original index data, use it */ if(dm && (origindex_ar= dm->getVertDataArray(dm, CD_ORIGINDEX))) { for(i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) { if(*index_pt < numVerts) { int j; - + for(j = 0; j < numVerts; j++) { if(origindex_ar[j] == *index_pt) { float *co = vertexCos[j]; if((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { if(dvert) fac *= defvert_find_weight(dvert+j, defgrp_index); - + if(fac) { mul_v3_m4v3(vec, mat, co); interp_v3_v3v3(co, co, vec, fac); @@ -218,7 +216,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, if((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { if(dvert) fac *= defvert_find_weight(dvert+(*index_pt), defgrp_index); - + if(fac) { mul_v3_m4v3(vec, mat, co); interp_v3_v3v3(co, co, vec, fac); @@ -230,11 +228,11 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, } else if(dvert) { /* vertex group hook */ const float fac_orig= hmd->force; - + for(i = 0; i < max_dvert; i++, dvert++) { float fac; float *co = vertexCos[i]; - + if((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { fac *= defvert_find_weight(dvert, defgrp_index); if(fac) { @@ -251,12 +249,8 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { HookModifierData *hmd = (HookModifierData*) md; - DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); - - deformVerts_do(hmd, ob, dm, vertexCos, numVerts); - - if(derivedData != dm) - dm->release(dm); + + deformVerts_do(hmd, ob, derivedData, vertexCos, numVerts); } static void deformVertsEM(ModifierData *md, Object *ob, struct EditMesh *editData, From e9a0a42dd3493c1a4456696cc6912b34a8548b25 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 10 Dec 2011 13:54:51 +0000 Subject: [PATCH 71/73] Fixed for movieclips tag function which was tagging wrong list Pointed out by Lockal, thanks! --- source/blender/makesrna/intern/rna_main_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 1809a5313c5..a62da4c3f7e 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -572,7 +572,7 @@ void rna_Main_armatures_tag(Main *bmain, int value) { tag_main_lb(&bmain->armatu void rna_Main_actions_tag(Main *bmain, int value) { tag_main_lb(&bmain->action, value); } void rna_Main_particles_tag(Main *bmain, int value) { tag_main_lb(&bmain->particle, value); } void rna_Main_gpencil_tag(Main *bmain, int value) { tag_main_lb(&bmain->gpencil, value); } -void rna_Main_movieclips_tag(Main *bmain, int value) { tag_main_lb(&bmain->text, value); } +void rna_Main_movieclips_tag(Main *bmain, int value) { tag_main_lb(&bmain->movieclip, value); } static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA); } static int rna_Main_scenes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCE); } From a912afd202ecfdd0b459d85fba18280c38b0062f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 10 Dec 2011 14:45:30 +0000 Subject: [PATCH 72/73] Fix #29516: Twist brush giving crazy results - Rotation now happens around initial stroke location rather than around scene origin - Added slider for rotation strength which helps in cases only few rotation is needed to be to increase the precision of such strokes --- .../startup/bl_ui/space_view3d_toolbar.py | 5 +++++ source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenkernel/intern/brush.c | 1 + source/blender/blenloader/intern/readfile.c | 10 ++++++++++ source/blender/editors/sculpt_paint/sculpt.c | 19 ++++++++++++++----- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index ddea7bd00fd..9644f57d6cd 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -546,6 +546,11 @@ class VIEW3D_PT_tools_brush(PaintPanel, Panel): row.prop(brush, "strength", text="Strength", slider=True) row.prop(brush, "use_pressure_strength", text="") + if tool == 'ROTATE': + row = col.row(align=True) + row.prop(brush, "strength", text="Strength", slider=True) + row.prop(brush, "use_pressure_strength", text="") + if tool != 'SMOOTH': col.separator() diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 257a550edb4..1e679d6fe4b 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 7 +#define BLENDER_SUBVERSION 8 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 7fac273ef77..2bf80fb7ecc 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -384,6 +384,7 @@ void brush_reset_sculpt(Brush *br) br->sub_col[1] = 1.000000; break; case SCULPT_TOOL_ROTATE: + br->alpha = 1.0; break; case SCULPT_TOOL_SMOOTH: br->flag &= ~BRUSH_SPACE_ATTEN; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 13e2ed49e6a..1ada2448d86 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12655,6 +12655,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 8)) + { + Brush *brush; + + for (brush= main->brush.first; brush; brush= brush->id.next) { + if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) + brush->alpha= 1.0f; + } + } + /* put compatibility code here until next subversion bump */ { /* nothing! */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a63a9256055..b84fea29e62 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -648,9 +648,11 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) return feather; case SCULPT_TOOL_GRAB: - case SCULPT_TOOL_ROTATE: return feather; + case SCULPT_TOOL_ROTATE: + return alpha*pressure*feather; + default: return 0; } @@ -1502,13 +1504,20 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod float bstrength= ss->cache->bstrength; float an[3]; int n; - float m[3][3]; + float m[4][4], rot[4][4], lmat[4][4], ilmat[4][4]; static const int flip[8] = { 1, -1, -1, 1, -1, 1, 1, -1 }; float angle = ss->cache->vertex_rotation * flip[ss->cache->mirror_symmetry_pass]; calc_sculpt_normal(sd, ob, an, nodes, totnode); - axis_angle_to_mat3(m, an, angle); + unit_m4(m); + unit_m4(lmat); + + copy_v3_v3(lmat[3], ss->cache->location); + invert_m4_m4(ilmat, lmat); + axis_angle_to_mat4(rot, an, angle); + + mul_serie_m4(m, lmat, rot, ilmat, NULL, NULL, NULL, NULL, NULL); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for(n=0; nmouse[0] - cache->initial_mouse[0]; dy = cache->mouse[1] - cache->initial_mouse[1]; - cache->vertex_rotation = -atan2(dx, dy); + cache->vertex_rotation = -atan2(dx, dy) * cache->bstrength; sd->draw_anchored = 1; copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse); From 33b1939aee427426c214cbc060f2eac0c3d42dde Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sat, 10 Dec 2011 15:52:08 +0000 Subject: [PATCH 73/73] In the node space context update function: Properly clear the snode->edittree pointer when no snode->nodetree is active. This would lead to crash in operators when switching from an existing node tree, since the usual poll function only tests for the edittree. Fixes bug #29566. --- source/blender/editors/space_node/node_edit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 4074e35f860..e5a216d42b0 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -483,6 +483,7 @@ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *tre } else { *ntree= NULL; + *edittree= NULL; if(treetype) *treetype= 0; } }