diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-23 21:14:27 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-23 21:14:27 +0400 |
commit | 74c6c91ba65d40b103234feb2f3ef254b0335193 (patch) | |
tree | 1927b26ca8881ee2344d95e475381d89da2b8ac4 | |
parent | f850e76e0438c5e0e1ed1b8606fee93ea0775747 (diff) | |
parent | a91bd43d382b857abb4440fe5a2353a4fac0519d (diff) |
svn merge ^/trunk/blender -r42080:42095
27 files changed, 499 insertions, 70 deletions
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index a85b2ba8c2a..c5c4f6b22a6 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -12,9 +12,9 @@ if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD) set(WITH_CYCLES_OPTIMIZED_KERNEL ON) if(WIN32 AND MSVC) - set(CYCLES_OPTIMIZED_KERNEL_FLAGS "/Ox /Ot /arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /EHsc /fp:fast") + set(CYCLES_OPTIMIZED_KERNEL_FLAGS "/arch:SSE2 -D_CRT_SECURE_NO_WARNINGS /fp:fast") elseif(CMAKE_COMPILER_IS_GNUCC) - set(CYCLES_OPTIMIZED_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3 -DGOGOGO") + set(CYCLES_OPTIMIZED_KERNEL_FLAGS "-ffast-math -msse -msse2 -msse3") endif() endif() diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 5d6ac10dc40..5552e6ab7e2 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -76,6 +76,7 @@ protected: Device() {} bool background; + string error_msg; public: virtual ~Device() {} @@ -84,6 +85,7 @@ public: /* info */ virtual string description() = 0; + const string& error_message() { return error_msg; } /* regular memory */ virtual void mem_alloc(device_memory& mem, MemoryType type) = 0; diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 1158cc6c77c..e32cbfcc8a7 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -122,7 +122,10 @@ public: CUresult result = stmt; \ \ if(result != CUDA_SUCCESS) { \ - fprintf(stderr, "CUDA error: %s in %s\n", cuda_error_string(result), #stmt); \ + string message = string_printf("CUDA error: %s in %s", cuda_error_string(result), #stmt); \ + if(error_msg == "") \ + error_msg = message; \ + fprintf(stderr, "%s\n", message.c_str()); \ cuda_abort(); \ } \ } @@ -132,10 +135,20 @@ public: if(result == CUDA_SUCCESS) return false; - fprintf(stderr, "CUDA error: %s\n", cuda_error_string(result)); + string message = string_printf("CUDA error: %s", cuda_error_string(result)); + if(error_msg == "") + error_msg = message; + fprintf(stderr, "%s\n", message.c_str()); return true; } + void cuda_error(const string& message) + { + if(error_msg == "") + error_msg = message; + fprintf(stderr, "%s\n", message.c_str()); + } + void cuda_push_context() { cuda_assert(cuCtxSetCurrent(cuContext)) @@ -224,14 +237,14 @@ public: return cubin; #ifdef WITH_CUDA_BINARIES - fprintf(stderr, "CUDA binary kernel for this graphics card not found.\n"); + cuda_error("CUDA binary kernel for this graphics card not found."); return ""; #else /* if not, find CUDA compiler */ string nvcc = cuCompilerPath(); if(nvcc == "") { - fprintf(stderr, "CUDA nvcc compiler not found. Install CUDA toolkit in default location.\n"); + cuda_error("CUDA nvcc compiler not found. Install CUDA toolkit in default location."); return ""; } @@ -251,13 +264,13 @@ public: nvcc.c_str(), major, minor, machine, kernel.c_str(), cubin.c_str(), maxreg, include.c_str()); if(system(command.c_str()) == -1) { - fprintf(stderr, "Failed to execute compilation command.\n"); + cuda_error("Failed to execute compilation command, see console for details."); return ""; } /* verify if compilation succeeded */ if(!path_exists(cubin)) { - fprintf(stderr, "CUDA kernel compilation failed.\n"); + cuda_error("CUDA kernel compilation failed, see console for details."); return ""; } @@ -284,7 +297,7 @@ public: CUresult result = cuModuleLoad(&cuModule, cubin.c_str()); if(cuda_error(result)) - fprintf(stderr, "Failed loading CUDA kernel %s.\n", cubin.c_str()); + cuda_error(string_printf("Failed loading CUDA kernel %s.", cubin.c_str())); cuda_pop_context(); diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index e0b4f67da05..d783ae6c174 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -109,17 +109,30 @@ public: bool opencl_error(cl_int err) { if(err != CL_SUCCESS) { - fprintf(stderr, "OpenCL error (%d): %s\n", err, opencl_error_string(err)); + string message = string_printf("OpenCL error (%d): %s", err, opencl_error_string(err)); + if(error_msg == "") + error_msg = message; + fprintf(stderr, "%s\n", message.c_str()); return true; } return false; } + void opencl_error(const string& message) + { + if(error_msg == "") + error_msg = message; + fprintf(stderr, "%s\n", message.c_str()); + } + void opencl_assert(cl_int err) { if(err != CL_SUCCESS) { - fprintf(stderr, "OpenCL error (%d): %s\n", err, opencl_error_string(err)); + string message = string_printf("OpenCL error (%d): %s", err, opencl_error_string(err)); + if(error_msg == "") + error_msg = message; + fprintf(stderr, "%s\n", message.c_str()); #ifndef NDEBUG abort(); #endif @@ -147,7 +160,7 @@ public: return; if(num_platforms == 0) { - fprintf(stderr, "OpenCL: no platforms found.\n"); + opencl_error("OpenCL: no platforms found."); return; } @@ -183,24 +196,24 @@ public: clGetPlatformInfo(cpPlatform, CL_PLATFORM_VERSION, sizeof(version), &version, NULL); if(sscanf(version, "OpenCL %d.%d", &major, &minor) < 2) { - fprintf(stderr, "OpenCL: failed to parse platform version string (%s).", version); + opencl_error(string_printf("OpenCL: failed to parse platform version string (%s).", version)); return false; } if(!((major == req_major && minor >= req_minor) || (major > req_major))) { - fprintf(stderr, "OpenCL: platform version 1.1 or later required, found %d.%d\n", major, minor); + opencl_error(string_printf("OpenCL: platform version 1.1 or later required, found %d.%d", major, minor)); return false; } clGetDeviceInfo(cdDevice, CL_DEVICE_OPENCL_C_VERSION, sizeof(version), &version, NULL); if(sscanf(version, "OpenCL C %d.%d", &major, &minor) < 2) { - fprintf(stderr, "OpenCL: failed to parse OpenCL C version string (%s).", version); + opencl_error(string_printf("OpenCL: failed to parse OpenCL C version string (%s).", version)); return false; } if(!((major == req_major && minor >= req_minor) || (major > req_major))) { - fprintf(stderr, "OpenCL: C version 1.1 or later required, found %d.%d\n", major, minor); + opencl_error(string_printf("OpenCL: C version 1.1 or later required, found %d.%d", major, minor)); return false; } @@ -216,7 +229,7 @@ public: vector<uint8_t> binary; if(!path_read_binary(clbin, binary)) { - fprintf(stderr, "OpenCL failed to read cached binary %s.\n", clbin.c_str()); + opencl_error(string_printf("OpenCL failed to read cached binary %s.", clbin.c_str())); return false; } @@ -229,7 +242,7 @@ public: &size, &bytes, &status, &ciErr); if(opencl_error(status) || opencl_error(ciErr)) { - fprintf(stderr, "OpenCL failed create program from cached binary %s.\n", clbin.c_str()); + opencl_error(string_printf("OpenCL failed create program from cached binary %s.", clbin.c_str())); return false; } @@ -253,7 +266,7 @@ public: clGetProgramInfo(cpProgram, CL_PROGRAM_BINARIES, sizeof(uint8_t*), &bytes, NULL); if(!path_write_binary(clbin, binary)) { - fprintf(stderr, "OpenCL failed to write cached binary %s.\n", clbin.c_str()); + opencl_error(string_printf("OpenCL failed to write cached binary %s.", clbin.c_str())); return false; } @@ -293,7 +306,8 @@ public: clGetProgramBuildInfo(cpProgram, cdDevice, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); build_log[ret_val_size] = '\0'; - fprintf(stderr, "OpenCL build failed:\n %s\n", build_log); + opencl_error("OpenCL build failed: errors in console"); + fprintf(stderr, "%s\n", build_log); delete[] build_log; diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 2deb83674cc..73ac033623d 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -203,6 +203,10 @@ void Session::run_gpu() if(!no_tiles) { /* update scene */ update_scene(); + + if(device->error_message() != "") + progress.set_cancel(device->error_message()); + if(progress.get_cancel()) break; } @@ -222,6 +226,9 @@ void Session::run_gpu() device->task_wait(); + if(device->error_message() != "") + progress.set_cancel(device->error_message()); + if(progress.get_cancel()) break; } @@ -243,6 +250,9 @@ void Session::run_gpu() } } + if(device->error_message() != "") + progress.set_cancel(device->error_message()); + if(progress.get_cancel()) break; } @@ -345,6 +355,10 @@ void Session::run_cpu() /* update scene */ update_scene(); + + if(device->error_message() != "") + progress.set_cancel(device->error_message()); + if(progress.get_cancel()) break; @@ -360,6 +374,9 @@ void Session::run_cpu() if(!params.background) need_tonemap = true; + + if(device->error_message() != "") + progress.set_cancel(device->error_message()); } device->task_wait(); @@ -379,6 +396,9 @@ void Session::run_cpu() want to show the result of an incomplete sample*/ tonemap(); } + + if(device->error_message() != "") + progress.set_cancel(device->error_message()); } progress.set_update(); @@ -391,7 +411,11 @@ void Session::run() progress.set_status("Loading render kernels (may take a few minutes the first time)"); if(!device->load_kernels()) { - progress.set_status("Failed loading render kernel, see console for errors"); + string message = device->error_message(); + if(message == "") + message = "Failed loading render kernel, see console for errors"; + + progress.set_status("Error", message); progress.set_update(); return; } @@ -409,7 +433,7 @@ void Session::run() /* progress update */ if(progress.get_cancel()) - progress.set_status(progress.get_cancel_message()); + progress.set_status("Cancel", progress.get_cancel_message()); else progress.set_update(); } diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 03c3427045d..12a732e59ef 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1765,7 +1765,7 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const return NULL; } - pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding]; + pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1); @@ -1774,7 +1774,7 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const return NULL; } - strncpy((char*)temp_buff, [textPasted cStringUsingEncoding:NSISOLatin1StringEncoding], pastedTextSize); + strncpy((char*)temp_buff, [textPasted cStringUsingEncoding:NSUTF8StringEncoding], pastedTextSize); temp_buff[pastedTextSize] = '\0'; @@ -1806,7 +1806,7 @@ void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const [pasteBoard declareTypes:supportedTypes owner:nil]; - textToCopy = [NSString stringWithCString:buffer encoding:NSISOLatin1StringEncoding]; + textToCopy = [NSString stringWithCString:buffer encoding:NSUTF8StringEncoding]; [pasteBoard setString:textToCopy forType:NSStringPboardType]; diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 7bb1913d872..01217dfd17a 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -238,10 +238,13 @@ extern "C" { #pragma mark NSOpenGLView subclass //We need to subclass it in order to give Cocoa the feeling key events are trapped -@interface CocoaOpenGLView : NSOpenGLView +@interface CocoaOpenGLView : NSOpenGLView <NSTextInput> { GHOST_SystemCocoa *systemCocoa; GHOST_WindowCocoa *associatedWindow; + + bool composing; + NSString *composing_text; } - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa; @end @@ -251,6 +254,9 @@ extern "C" { { systemCocoa = sysCocoa; associatedWindow = winCocoa; + + composing = false; + composing_text = nil; } - (BOOL)acceptsFirstResponder @@ -258,9 +264,26 @@ extern "C" { return YES; } -//The trick to prevent Cocoa from complaining (beeping) -- (void)keyDown:(NSEvent *)theEvent -{} +// The trick to prevent Cocoa from complaining (beeping) +- (void)keyDown:(NSEvent *)event +{ + // Start or continue composing? + if([[event characters] length] == 0 || + [[event charactersIgnoringModifiers] length] == 0 || + composing) { + composing = YES; + + // interpret event to call insertText + NSMutableArray *events; + events = [[NSMutableArray alloc] initWithCapacity:1]; + [events addObject:event]; + [self interpretKeyEvents:events]; // calls insertText + [events removeObject:event]; + [events release]; + + return; + } +} #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 //Cmd+key are handled differently before 10.5 @@ -306,8 +329,99 @@ extern "C" { } } -@end +// Text input + +- (void)composing_free +{ + composing = NO; + + if(composing_text) { + [composing_text release]; + composing_text = nil; + } +} + +- (void)insertText:(id)chars +{ + [self composing_free]; +} + +- (void)setMarkedText:(id)chars selectedRange:(NSRange)range +{ + [self composing_free]; + if([chars length] == 0) + return; + + // start composing + composing = YES; + composing_text = [chars copy]; + + // if empty, cancel + if([composing_text length] == 0) + [self composing_free]; +} + +- (void)unmarkText +{ + [self composing_free]; +} + +- (BOOL)hasMarkedText +{ + return (composing)? YES: NO; +} + +- (void)doCommandBySelector:(SEL)selector +{ +} + +- (BOOL)isComposing +{ + return composing; +} + +- (NSInteger)conversationIdentifier +{ + return (NSInteger)self; +} + +- (NSAttributedString *)attributedSubstringFromRange:(NSRange)range +{ + return [NSAttributedString new]; // XXX does this leak? +} + +- (NSRange)markedRange +{ + unsigned int length = (composing_text)? [composing_text length]: 0; + + if(composing) + return NSMakeRange(0, length); + + return NSMakeRange(NSNotFound, 0); +} +- (NSRange)selectedRange +{ + unsigned int length = (composing_text)? [composing_text length]: 0; + return NSMakeRange(0, length); +} + +- (NSRect)firstRectForCharacterRange:(NSRange)range +{ + return NSZeroRect; +} + +- (NSUInteger)characterIndexForPoint:(NSPoint)point +{ + return NSNotFound; +} + +- (NSArray*)validAttributesForMarkedText +{ + return [NSArray array]; // XXX does this leak? +} + +@end #pragma mark initialization / finalization diff --git a/release/datafiles/fonts/droidsans.ttf.gz b/release/datafiles/fonts/droidsans.ttf.gz Binary files differindex 9c70d31a2e3..fdf92f669c4 100644 --- a/release/datafiles/fonts/droidsans.ttf.gz +++ b/release/datafiles/fonts/droidsans.ttf.gz diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ed7a22b5e0b..5f689aafaca 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1801,6 +1801,7 @@ static void give_parvert(Object *par, int nr, float *vec) dm->getVertCo(dm, 0, vec); } } + else fprintf(stderr, "%s: DerivedMesh is needed to solve parenting, object position can be wrong now\n", __func__); } else if (ELEM(par->type, OB_CURVE, OB_SURF)) { Nurb *nu; diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index accfbc64628..5a511e0137c 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -251,6 +251,7 @@ void paintvert_flush_flags(struct Object *ob); struct bDeformGroup *ED_vgroup_add(struct Object *ob); struct bDeformGroup *ED_vgroup_add_name(struct Object *ob, const char *name); void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *defgroup); +void ED_vgroup_clear(struct Object *ob); void ED_vgroup_select_by_name(struct Object *ob, const char *name); int ED_vgroup_data_create(struct ID *id); int ED_vgroup_give_array(struct ID *id, struct MDeformVert **dvert_arr, int *dvert_tot); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 3ae3876c18a..e7d753ff45c 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -142,6 +142,7 @@ enum { struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name, int type); int ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md); +void ED_object_modifier_clear(struct Main *bmain, struct Scene *scene, struct Object *ob); int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md); int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md); int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 07fc4e77ac1..1df8f723140 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -296,5 +296,6 @@ int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); struct BGpic *ED_view3D_background_image_new(struct View3D *v3d); void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic); +void ED_view3D_background_image_clear(struct View3D *v3d); #endif /* ED_VIEW3D_H */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index f1a36a07734..ae6658c7e1a 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -158,10 +158,9 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc return new_md; } -int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md) +static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgraph) { ModifierData *obmd; - int sort_depsgraph = 0; /* It seems on rapid delete it is possible to * get called twice on same modifier, so make @@ -169,11 +168,9 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob for(obmd=ob->modifiers.first; obmd; obmd=obmd->next) if(obmd==md) break; - - if(!obmd) { - BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); + + if(!obmd) return 0; - } /* special cases */ if(md->type == eModifierType_ParticleSystem) { @@ -194,13 +191,13 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob if(ob->pd) ob->pd->deflect= 0; - sort_depsgraph = 1; + *sort_depsgraph = 1; } else if(md->type == eModifierType_Surface) { if(ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE) ob->pd->shape = PFIELD_SHAPE_PLANE; - sort_depsgraph = 1; + *sort_depsgraph = 1; } else if(md->type == eModifierType_Smoke) { ob->dt = OB_TEXTURE; @@ -239,6 +236,21 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob BLI_remlink(&ob->modifiers, md); modifier_free(md); + return 1; +} + +int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md) +{ + int sort_depsgraph = 0; + int ok; + + ok= object_modifier_remove(ob, md, &sort_depsgraph); + + if(!ok) { + BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); + return 0; + } + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sorting has to be done after the update so that dynamic systems can react properly */ @@ -248,6 +260,31 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob return 1; } +void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob) +{ + ModifierData *md =ob->modifiers.first; + int sort_depsgraph = 0; + + if(!md) + return; + + while(md) { + ModifierData *next_md; + + next_md= md->next; + + object_modifier_remove(ob, md, &sort_depsgraph); + + md= next_md; + } + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + + /* sorting has to be done after the update so that dynamic systems can react properly */ + if(sort_depsgraph) + DAG_scene_sort(bmain, scene); +} + int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md) { if(md->prev) { diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ae6ec15e911..ab4ff20d503 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -61,6 +61,7 @@ #include "BKE_constraint.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" +#include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_fcurve.h" @@ -132,6 +133,10 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) em= me->edit_btmesh; + /* derivedMesh might be needed for solving parenting, + so re-create it here */ + makeDerivedMesh(scene, obedit, em, CD_MASK_BAREMESH, 0); + BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (BM_TestHFlag(eve, BM_SELECT)) { if(v1==0) v1= nr; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index d00c4b7907f..b747d3bc9fc 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -141,6 +141,23 @@ void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup) vgroup_delete_object_mode(ob, dg); } +void ED_vgroup_clear(Object *ob) +{ + bDeformGroup *dg= (bDeformGroup *)ob->defbase.first; + int edit_mode= ED_vgroup_object_is_edit_mode(ob); + + while (dg) { + bDeformGroup *next_dg= dg->next; + + if(edit_mode) + vgroup_delete_edit_mode(ob, dg); + else + vgroup_delete_object_mode(ob, dg); + + dg= next_dg; + } +} + int ED_vgroup_data_create(ID *id) { /* create deform verts */ diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 72ea79fae7e..f353a090305 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -188,6 +188,10 @@ static int nodes_use_tex(bNodeTree *ntree, Tex *tex) if(node->id == (ID*)tex) { return 1; } + else if(GS(node->id->name) == ID_MA) { + if(mtex_use_tex(((Material*)node->id)->mtex, MAX_MTEX, tex)) + return 1; + } else if(node->type==NODE_GROUP) { if(nodes_use_tex((bNodeTree *)node->id, tex)) return 1; @@ -198,14 +202,46 @@ static int nodes_use_tex(bNodeTree *ntree, Tex *tex) return 0; } -static void material_changed(Main *UNUSED(bmain), Material *ma) +static int nodes_use_material(bNodeTree *ntree, Material *ma) +{ + bNode *node; + + for(node=ntree->nodes.first; node; node= node->next) { + if(node->id) { + if(node->id == (ID*)ma) { + return 1; + } + else if(node->type==NODE_GROUP) { + if(nodes_use_material((bNodeTree *)node->id, ma)) + return 1; + } + } + } + + return 0; +} + +static void material_changed(Main *bmain, Material *ma) { + Material *parent; + /* icons */ BKE_icon_changed(BKE_icon_getid(&ma->id)); /* glsl */ if(ma->gpumaterial.first) GPU_material_free(ma); + + /* find node materials using this */ + for(parent=bmain->mat.first; parent; parent=parent->id.next) { + if(parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)); + else continue; + + BKE_icon_changed(BKE_icon_getid(&parent->id)); + + if(parent->gpumaterial.first) + GPU_material_free(parent); + } } static void texture_changed(Main *bmain, Tex *tex) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 32e162fd09c..6d2a745fd67 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3547,7 +3547,7 @@ BGpic *ED_view3D_background_image_new(View3D *v3d) return bgpic; } -void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic) +void ED_view3D_background_image_remove(View3D *v3d, BGpic *bgpic) { BLI_remlink(&v3d->bgpicbase, bgpic); @@ -3559,3 +3559,16 @@ void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic) MEM_freeN(bgpic); } + +void ED_view3D_background_image_clear(View3D *v3d) +{ + BGpic *bgpic= v3d->bgpicbase.first; + + while(bgpic) { + BGpic *next_bgpic= bgpic->next; + + ED_view3D_background_image_remove(v3d, bgpic); + + bgpic= next_bgpic; + } +} diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index c0faed69885..3800b09e3f7 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -997,8 +997,8 @@ StructRNA *ID_code_to_RNA_type(short idcode); /* macro which inserts the function name */ #ifdef __GNUC__ # define RNA_warning(format, args...) _RNA_warning("%s: " format "\n", __func__, ##args) -#else /* MSVC doesnt support variable length args in macros */ -# define RNA_warning _RNA_warning +#else +# define RNA_warning(format, args, ...) _RNA_warning("%s: " format "\n", __FUNCTION__, __VA_ARGS__) #endif void _RNA_warning(const char *format, ...) diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 95f44d86058..3125c2eec08 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -588,6 +588,19 @@ static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu) freeNurb(nu); /* invalidate pointer!, no can do */ + + DAG_id_tag_update(&cu->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GEOM|ND_DATA, NULL); +} + +static void rna_Curve_spline_clear(Curve *cu) +{ + ListBase *nurbs= BKE_curve_nurbs(cu); + + freeNurblist(nurbs); + + DAG_id_tag_update(&cu->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GEOM|ND_DATA, NULL); } static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr) @@ -1200,6 +1213,9 @@ static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop) parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + func= RNA_def_function(srna, "clear", "rna_Curve_spline_clear"); + RNA_def_function_ui_description(func, "Remove all spline from a curve"); + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_pointer_funcs(prop, "rna_Curve_active_spline_get", "rna_Curve_active_spline_set", NULL, NULL); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 323fb6780fb..5f948a3a243 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -147,6 +147,17 @@ static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, Meta } } +static void rna_MetaBall_elements_clear(MetaBall *mb) +{ + BLI_freelistN(&mb->elems); + + /* cheating way for importers to avoid slow updates */ + if(mb->id.us > 0) { + DAG_id_tag_update(&mb->id, 0); + WM_main_add_notifier(NC_GEOM|ND_DATA, &mb->id); + } +} + #else static void rna_def_metaelement(BlenderRNA *brna) @@ -234,17 +245,20 @@ static void rna_def_metaball_elements(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Meta Elements", "Collection of metaball elements"); func= RNA_def_function(srna, "new", "rna_MetaBall_elements_new"); - RNA_def_function_ui_description(func, "Add a new spline to the curve"); + RNA_def_function_ui_description(func, "Add a new element to the metaball"); RNA_def_enum(func, "type", metaelem_type_items, MB_BALL, "", "type for the new meta-element"); parm= RNA_def_pointer(func, "element", "MetaElement", "", "The newly created meta-element"); RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_MetaBall_elements_remove"); - RNA_def_function_ui_description(func, "Remove a spline from a curve"); + RNA_def_function_ui_description(func, "Remove an element from the metaball"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "element", "MetaElement", "", "The element to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + func= RNA_def_function(srna, "clear", "rna_MetaBall_elements_clear"); + RNA_def_function_ui_description(func, "Remove all elements from the metaball"); + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "lastelem"); RNA_def_property_ui_text(prop, "Active Element", "Last selected element"); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 6cf3a3ee56e..013a4e57db6 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2574,10 +2574,10 @@ static void rna_def_modifier_screw(BlenderRNA *brna) static void rna_def_modifier_weightvg_mask(BlenderRNA *brna, StructRNA *srna) { static EnumPropertyItem weightvg_mask_tex_map_items[] = { - {MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Local", ""}, - {MOD_DISP_MAP_GLOBAL, "GLOBAL", 0, "Global", ""}, - {MOD_DISP_MAP_OBJECT, "OBJECT", 0, "Object", ""}, - {MOD_DISP_MAP_UV, "UV", 0, "UV", ""}, + {MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Local", "Use local generated coordinates"}, + {MOD_DISP_MAP_GLOBAL, "GLOBAL", 0, "Global", "Use global coordinates"}, + {MOD_DISP_MAP_OBJECT, "OBJECT", 0, "Object", "Use local generated coordinates of another object"}, + {MOD_DISP_MAP_UV, "UV", 0, "UV", "Use coordinates from an UV layer"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem weightvg_mask_tex_used_items[] = { @@ -2595,7 +2595,7 @@ static void rna_def_modifier_weightvg_mask(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "mask_constant", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Influence", "Global influence of current modifications on vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2638,14 +2638,15 @@ static void rna_def_modifier_weightvg_mask(BlenderRNA *brna, StructRNA *srna) static void rna_def_modifier_weightvgedit(BlenderRNA *brna) { static EnumPropertyItem weightvg_edit_falloff_type_items[] = { - {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", ""}, + {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", "Null action"}, {MOD_WVG_MAPPING_CURVE, "CURVE", ICON_RNDCURVE, "Custom Curve", ""}, {MOD_WVG_MAPPING_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", ""}, {MOD_WVG_MAPPING_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""}, {MOD_WVG_MAPPING_ROOT, "ROOT", ICON_ROOTCURVE, "Root", ""}, {MOD_WVG_MAPPING_SPHERE, "ICON_SPHERECURVE", ICON_SPHERECURVE, "Sphere", ""}, {MOD_WVG_MAPPING_RANDOM, "RANDOM", ICON_RNDCURVE, "Random", ""}, - {MOD_WVG_MAPPING_STEP, "STEP", ICON_NOCURVE, "Median Step", ""}, /* Would need a better icon... */ + {MOD_WVG_MAPPING_STEP, "STEP", ICON_NOCURVE /* Would need a better icon... */, "Median Step", + "Map all values below 0.5 to 0.0, and all others to 1.0"}, {0, NULL, 0, NULL, NULL}}; StructRNA *srna; @@ -2682,7 +2683,7 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) prop= RNA_def_property(srna, "default_weight", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Default Weight", "Default weight a vertex will have if " "it is not in the vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2695,7 +2696,7 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) prop= RNA_def_property(srna, "add_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "add_threshold"); RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Add Threshold", "Lower bound for a vertex's weight " "to be added to the vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2703,7 +2704,7 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) prop= RNA_def_property(srna, "remove_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rem_threshold"); RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Rem Threshold", "Upper bound for a vertex's weight " "to be removed from the vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2715,21 +2716,21 @@ static void rna_def_modifier_weightvgedit(BlenderRNA *brna) static void rna_def_modifier_weightvgmix(BlenderRNA *brna) { static EnumPropertyItem weightvg_mix_modes_items[] = { - {MOD_WVG_MIX_SET, "SET", 0, "Replace weights", ""}, - {MOD_WVG_MIX_ADD, "ADD", 0, "Add to weights", ""}, - {MOD_WVG_MIX_SUB, "SUB", 0, "Subtract from weights", ""}, - {MOD_WVG_MIX_MUL, "MUL", 0, "Multiply weights", ""}, - {MOD_WVG_MIX_DIV, "DIV", 0, "Divide weights", ""}, - {MOD_WVG_MIX_DIF, "DIF", 0, "Difference", ""}, - {MOD_WVG_MIX_AVG, "AVG", 0, "Average", ""}, + {MOD_WVG_MIX_SET, "SET", 0, "Replace", "Replace VGroup A's weights by VGroup b's ones"}, + {MOD_WVG_MIX_ADD, "ADD", 0, "Add", "Add VGroup B's weights to VGroup A's ones"}, + {MOD_WVG_MIX_SUB, "SUB", 0, "Subtract", "Subtract VGroup B's weights from VGroup A's ones"}, + {MOD_WVG_MIX_MUL, "MUL", 0, "Multiply", "Multiply VGroup A's weights by VGroup B's ones"}, + {MOD_WVG_MIX_DIV, "DIV", 0, "Divide", "Divide VGroup A's weights by VGroup B's ones"}, + {MOD_WVG_MIX_DIF, "DIF", 0, "Difference", "Difference between VGroup A's and VGroup B's weigths"}, + {MOD_WVG_MIX_AVG, "AVG", 0, "Average", "Average value of VGroup A's and VGroup B's weigths"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem weightvg_mix_set_items[] = { - {MOD_WVG_SET_ALL, "ALL", 0, "All vertices", ""}, - {MOD_WVG_SET_A, "A", 0, "Vertices from group A", ""}, - {MOD_WVG_SET_B, "B", 0, "Vertices from group B", ""}, - {MOD_WVG_SET_OR, "OR", 0, "Vertices from one group", ""}, - {MOD_WVG_SET_AND, "AND", 0, "Vertices from both groups", ""}, + {MOD_WVG_SET_ALL, "ALL", 0, "All", "Affect all vertices (might add some to VGroup A)"}, + {MOD_WVG_SET_A, "A", 0, "VGroup A", "Affect vertices in VGroup A"}, + {MOD_WVG_SET_B, "B", 0, "VGroup B", "Affect vertices in VGroup B (might add some to VGroup A)"}, + {MOD_WVG_SET_OR, "OR", 0, "VGroup A or B", "Affect vertices in at least one of both VGroups (might add some to VGroup A)"}, + {MOD_WVG_SET_AND, "AND", 0, "VGroup A and B", "Affect vertices in both groups"}, {0, NULL, 0, NULL, NULL}}; StructRNA *srna; @@ -2755,14 +2756,14 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna) prop= RNA_def_property(srna, "default_weight_a", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Default Weight A", "Default weight a vertex will have if " "it is not in the first vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "default_weight_b", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0, 1.0f); - RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 0); + RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 0); RNA_def_property_ui_text(prop, "Default Weight B", "Default weight a vertex will have if " "it is not in the second vgroup"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -2799,14 +2800,15 @@ static void rna_def_modifier_weightvgproximity(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem weightvg_proximity_falloff_type_items[] = { - {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", ""}, + {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", "Null action"}, /* No curve mapping here! */ {MOD_WVG_MAPPING_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", ""}, {MOD_WVG_MAPPING_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""}, {MOD_WVG_MAPPING_ROOT, "ROOT", ICON_ROOTCURVE, "Root", ""}, {MOD_WVG_MAPPING_SPHERE, "ICON_SPHERECURVE", ICON_SPHERECURVE, "Sphere", ""}, {MOD_WVG_MAPPING_RANDOM, "RANDOM", ICON_RNDCURVE, "Random", ""}, - {MOD_WVG_MAPPING_STEP, "STEP", ICON_NOCURVE, "Median Step", ""}, /* Would need a better icon... */ + {MOD_WVG_MAPPING_STEP, "STEP", ICON_NOCURVE /* Would need a better icon... */, "Median Step", + "Map all values below 0.5 to 0.0, and all others to 1.0"}, {0, NULL, 0, NULL, NULL}}; StructRNA *srna; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index cd1b74f2b38..062fbad421a 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -645,6 +645,26 @@ static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, bNod } } +static void rna_NodeTree_node_clear(bNodeTree *ntree) +{ + bNode *node= ntree->nodes.first; + + while(node) { + bNode *next_node= node->next; + + if (node->id) + id_us_min(node->id); + + nodeFreeNode(ntree, node); + + node= next_node; + } + + ntreeUpdateTree(ntree); /* update group node socket links*/ + + WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); +} + static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports, bNodeSocket *in, bNodeSocket *out) { bNodeLink *ret; @@ -687,6 +707,22 @@ static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, bNod } } +static void rna_NodeTree_link_clear(bNodeTree *ntree) +{ + bNodeLink *link= ntree->links.first; + + while(link) { + bNodeLink *next_link= link->next; + + nodeRemLink(ntree, link); + + link= next_link; + } + ntreeUpdateTree(ntree); + + WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); +} + static bNodeSocket *rna_NodeTree_input_new(bNodeTree *ntree, ReportList *UNUSED(reports), const char *name, int type) { /* XXX should check if tree is a group here! no good way to do this currently. */ @@ -2828,6 +2864,9 @@ static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "link", "NodeLink", "", "The node link to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_link_clear"); + RNA_def_function_ui_description(func, "remove all node links from the node tree"); } static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -2856,6 +2895,9 @@ static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); + RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); } static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -2884,6 +2926,9 @@ static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); + RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); } static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -2912,6 +2957,9 @@ static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); + RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); } static void rna_def_node_socket(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index df2b2881c03..2a384329360 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1157,6 +1157,16 @@ static void rna_Object_constraints_remove(Object *object, ReportList *reports, b WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object); } +static void rna_Object_constraints_clear(Object *object) +{ + free_constraints(&object->constraints); + + ED_object_constraint_update(object); + ED_object_constraint_set_active(object, NULL); + + WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object); +} + static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, const char *name, int type) { return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type); @@ -1165,6 +1175,15 @@ static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, Report static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md) { ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md); + + WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object); +} + +static void rna_Object_modifier_clear(Object *object, bContext *C) +{ + ED_object_modifier_clear(CTX_data_main(C), CTX_data_scene(C), object); + + WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object); } static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) @@ -1196,6 +1215,13 @@ static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup) WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); } +static void rna_Object_vgroup_clear(Object *ob) +{ + ED_vgroup_clear(ob); + + WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); +} + static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len, int *index, float weight, int assignmode) { @@ -1637,6 +1663,9 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop) /* constraint to remove */ parm= RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_Object_constraints_clear"); + RNA_def_function_ui_description(func, "Remove all constraint from this object"); } /* object.modifiers */ @@ -1685,6 +1714,11 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop) /* target to remove*/ parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + /* clear all modifiers */ + func= RNA_def_function(srna, "clear", "rna_Object_modifier_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove all modifiers from the object"); } /* object.particle_systems */ @@ -1759,6 +1793,9 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Delete vertex group from object"); parm= RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_Object_vgroup_clear"); + RNA_def_function_ui_description(func, "Delete all vertex groups from object"); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f9b88e19248..40fcfa3e016 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1196,6 +1196,10 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[]) marker->frame= 1; BLI_strncpy_utf8(marker->name, name, sizeof(marker->name)); BLI_addtail(&scene->markers, marker); + + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); + return marker; } @@ -1208,6 +1212,17 @@ static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *m /* XXX, invalidates PyObject */ MEM_freeN(marker); + + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); +} + +static void rna_TimeLine_clear(Scene *scene) +{ + BLI_freelistN(&scene->markers); + + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); } static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, const char name[]) @@ -3607,6 +3622,9 @@ static void rna_def_timeline_markers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_TimeLine_clear"); + RNA_def_function_ui_description(func, "Remove all timeline markers"); } /* scene.keying_sets */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 9f6f0bb7802..495a83f4bbe 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -911,6 +911,12 @@ static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, BGpic * } } +static void rna_BackgroundImage_clear(View3D *v3d) +{ + ED_view3D_background_image_clear(v3d); + WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, v3d); +} + /* Space Node Editor */ static int rna_SpaceNodeEditor_node_tree_poll(PointerRNA *ptr, PointerRNA value) @@ -1328,6 +1334,9 @@ static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_BackgroundImage_clear"); + RNA_def_function_ui_description(func, "Remove all background images"); } static void rna_def_space_view3d(BlenderRNA *brna) diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index ad16cbe97a0..8b44f262e41 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -466,6 +466,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der if (use_trgt_verts || use_trgt_edges || use_trgt_faces) { DerivedMesh *target_dm = obr->derivedFinal; + short free_target_dm = FALSE; if (!target_dm) { if (ELEM3(obr->type, OB_CURVE, OB_SURF, OB_FONT)) target_dm = CDDM_from_curve(obr); @@ -476,6 +477,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der else target_dm = CDDM_from_mesh(me, obr); } + free_target_dm = TRUE; } /* We must check that we do have a valid target_dm! */ @@ -495,6 +497,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der if(dists_f) new_w[i] = minf(dists_f[i], new_w[i]); } + if(free_target_dm) target_dm->release(target_dm); if(dists_v) MEM_freeN(dists_v); if(dists_e) MEM_freeN(dists_e); if(dists_f) MEM_freeN(dists_f); diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index f0c706afb79..ecdbc8a39b6 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -282,6 +282,7 @@ void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar){} void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist){} struct BGpic *ED_view3D_background_image_new(struct View3D *v3d){return (struct BGpic *) NULL;} void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic){} +void ED_view3D_background_image_clear(struct View3D *v3d){} void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist){} int text_file_modified(struct Text *text){return 0;} void ED_node_shader_default(struct Material *ma){} @@ -289,6 +290,7 @@ void ED_screen_animation_timer_update(struct bContext *C, int redraws){} void ED_base_object_select(struct Base *base, short mode){} int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md){return 0;} int ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, char *name, int type){return 0;} +void ED_object_modifier_clear(struct Scene *scene, struct Object *ob){} void ED_object_enter_editmode(struct bContext *C, int flag){} void ED_object_exit_editmode(struct bContext *C, int flag){} int uiLayoutGetActive(struct uiLayout *layout){return 0;} @@ -322,6 +324,7 @@ void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, void ED_vgroup_vert_remove(struct Object *ob, struct bDeformGroup *dg, int vertnum){} void ED_vgroup_vert_weight(struct Object *ob, struct bDeformGroup *dg, int vertnum){} void ED_vgroup_delete(struct Object *ob, struct bDeformGroup *defgroup){} +void ED_vgroup_clear(struct Object *ob){} void ED_vgroup_object_is_edit_mode(struct Object *ob){} void ED_sequencer_update_view(struct bContext *C, int view){} |