From 2921d48239da85b995c77980cc5bf91ea4a69c3e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Mar 2013 00:53:57 +0000 Subject: code cleanup: unused vars in collada, preprocessor formatting & warning in mingw. also compiling without bullet needed a stub added. --- source/blender/blenkernel/intern/rigidbody.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index d144ac927a6..f9bd202d64f 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1338,6 +1338,7 @@ void BKE_rigidbody_remove_constraint(Scene *scene, Object *ob) {} void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) {} void BKE_rigidbody_aftertrans_update(Object *ob, float loc[3], float rot[3], float quat[4], float rotAxis[3], float rotAngle) {} void BKE_rigidbody_cache_reset(RigidBodyWorld *rbw) {} +void BKE_rigidbody_rebuild_world(Scene *scene, float ctime) {} void BKE_rigidbody_do_simulation(Scene *scene, float ctime) {} #ifdef __GNUC__ -- cgit v1.2.3 From ef0edd1afc816a18d5a417467192505f98a73020 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Mar 2013 05:25:16 +0000 Subject: fix [#34473] Blender Crashes on toggling modes, dynatopo sculpt/object mode. --- source/blender/blenkernel/intern/object.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 95b1809bbae..c98c18b9cdc 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -287,6 +287,9 @@ void sculptsession_bm_to_me(struct Object *ob, int reorder) BM_mesh_bm_to_me(ss->bm, ob->data, FALSE); } } + + /* ensure the objects DerivedMesh mesh doesn't hold onto arrays now realloc'd in the mesh [#34473] */ + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } } -- cgit v1.2.3 From 42ca1c8dcd8d148124b9d5fcf262887cac9909c1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 4 Mar 2013 13:18:14 +0000 Subject: Fix for image transparency backwards compatibility. Now the texture datablock has a Use Alpha option again. This makes the case where you enabled Premultiply on the image and disabled Use Alpha on the texture work again. That's mostly useful when you have a straight alpha image file which has no useful RGB colors in zero alpha regions (e.g. renders). Then sometimes you don't want to use the alpha for the texture stack mixing, but you still want to multiply it into the RGB channels to avoid a blocky transition into zero alpha regions. This also removes the version patch that copied image datablocks because it's not reliable and might be causing bug #34434. This does mean we are no longer backwards compatible for cases where two different texture datablocks with Use Alpha enabled and disabled where using the same image. --- source/blender/blenkernel/intern/texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 55a0f3752a1..2ae76ea6d1c 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -440,7 +440,7 @@ void default_tex(Tex *tex) tex->type = TEX_CLOUDS; tex->stype = 0; tex->flag = TEX_CHECKER_ODD; - tex->imaflag = TEX_INTERPOL | TEX_MIPMAP; + tex->imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA; tex->extend = TEX_REPEAT; tex->cropxmin = tex->cropymin = 0.0; tex->cropxmax = tex->cropymax = 1.0; -- cgit v1.2.3 From f5a28a288b6b345e6b93d95166c2f64da1bd535a Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Mon, 4 Mar 2013 15:58:40 +0000 Subject: Change default margin for bake to 16 pixels --- source/blender/blenkernel/intern/scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 5498122f0d4..369a6e85776 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -435,7 +435,7 @@ Scene *BKE_scene_add(Main *bmain, const char *name) sce->r.postsat = 1.0; sce->r.bake_mode = 1; /* prevent to include render stuff here */ - sce->r.bake_filter = 2; + sce->r.bake_filter = 16; sce->r.bake_osa = 5; sce->r.bake_flag = R_BAKE_CLEAR; sce->r.bake_normal_space = R_BAKE_SPACE_TANGENT; -- cgit v1.2.3 From 495aa863aeb54886a7f5ddc5c2716828fac53856 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 4 Mar 2013 18:30:48 +0000 Subject: Fix for incorrect subpixel precision of marker when using track offset Issue was caused by the way how pattern sampling happens in case of anchored display: track offset is applying on search buffer which means offset is rounding to an integer. Fractional pat of offset was completely ignoring which lead to jumps in pattern buffer. This was only a visualization issue in track preview widget. --- source/blender/blenkernel/intern/tracking.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index f63a1f2cec0..7e2970108cd 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1699,7 +1699,7 @@ static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, int g ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *search_ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, - int use_mask, int num_samples_x, int num_samples_y, + int from_anchor, int use_mask, int num_samples_x, int num_samples_y, float pos[2]) { #ifdef WITH_LIBMV @@ -1719,6 +1719,28 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea get_marker_coords_for_tracking(frame_width, frame_height, marker, src_pixel_x, src_pixel_y); + /* from_anchor means search buffer was obtained for an anchored position, + * which means applying track offset rounded to pixel space (we could not + * store search buffer with sub-pixel precision) + * + * in this case we need to alter coordinates a bit, to compensate rounded + * fractional part of offset + */ + if (from_anchor) { + int a; + + for (a = 0; a < 5; a++) { + src_pixel_x[a] += ((track->offset[0] * frame_width) - ((int) (track->offset[0] * frame_width))); + src_pixel_y[a] += ((track->offset[1] * frame_height) - ((int) (track->offset[1] * frame_height))); + + /* when offset is negative, rounding happens in opposite direction */ + if (track->offset[0] < 0.0f) + src_pixel_x[a] += 1.0f; + if (track->offset[1] < 0.0f) + src_pixel_y[a] += 1.0f; + } + } + if (use_mask) { mask = BKE_tracking_track_get_mask(frame_width, frame_height, track, marker); } @@ -1779,7 +1801,7 @@ ImBuf *BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mo if (search_ibuf) { pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker, - FALSE, num_samples_x, num_samples_y, NULL); + anchored, FALSE, num_samples_x, num_samples_y, NULL); IMB_freeImBuf(search_ibuf); } -- cgit v1.2.3 From 0d5b028d43c328f528c8aeb6738f19e442c77eba Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Mar 2013 19:27:51 +0000 Subject: patch [#34103] use boolean in path functions and add comments. path_util_1.patch from Lawrence D'Oliveiro (ldo) --- source/blender/blenkernel/intern/customdata.c | 10 +++++----- source/blender/blenkernel/intern/deform.c | 8 ++++---- source/blender/blenkernel/intern/dynamicpaint.c | 14 +++++++------- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/packedFile.c | 2 +- source/blender/blenkernel/intern/pbvh_bmesh.c | 1 + 6 files changed, 19 insertions(+), 18 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 580a69466c9..787c854d280 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2861,7 +2861,7 @@ static int CustomData_is_property_layer(int type) return 0; } -static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int index) +static bool cd_layer_find_dupe(CustomData *data, const char *name, int type, int index) { int i; /* see if there is a duplicate */ @@ -2871,21 +2871,21 @@ static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int if (CustomData_is_property_layer(type)) { if (CustomData_is_property_layer(layer->type) && strcmp(layer->name, name) == 0) { - return 1; + return true; } } else { if (i != index && layer->type == type && strcmp(layer->name, name) == 0) { - return 1; + return true; } } } } - return 0; + return false; } -static int customdata_unique_check(void *arg, const char *name) +static bool customdata_unique_check(void *arg, const char *name) { struct {CustomData *data; int type; int index; } *data_arg = arg; return cd_layer_find_dupe(data_arg->data, name, data_arg->type, data_arg->index); diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 439180e8d76..2ba71ecd9b5 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -432,22 +432,22 @@ int defgroup_flip_index(Object *ob, int index, int use_default) return (flip_index == -1 && use_default) ? index : flip_index; } -static int defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object *ob) +static bool defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object *ob) { bDeformGroup *curdef; for (curdef = ob->defbase.first; curdef; curdef = curdef->next) { if (dg != curdef) { if (!strcmp(curdef->name, name)) { - return 1; + return true; } } } - return 0; + return false; } -static int defgroup_unique_check(void *arg, const char *name) +static bool defgroup_unique_check(void *arg, const char *name) { struct {Object *ob; void *dg; } *data = arg; return defgroup_find_name_dupe(name, data->dg, data->ob); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 685d66195c7..a01b08a3c63 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -340,7 +340,7 @@ int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object * return 0; } -static int surface_duplicateOutputExists(void *arg, const char *name) +static bool surface_duplicateOutputExists(void *arg, const char *name) { DynamicPaintSurface *t_surface = (DynamicPaintSurface *)arg; DynamicPaintSurface *surface = t_surface->canvas->surfaces.first; @@ -349,11 +349,11 @@ static int surface_duplicateOutputExists(void *arg, const char *name) if (surface != t_surface && surface->type == t_surface->type && surface->format == t_surface->format) { - if (surface->output_name[0] != '\0' && !BLI_path_cmp(name, surface->output_name)) return 1; - if (surface->output_name2[0] != '\0' && !BLI_path_cmp(name, surface->output_name2)) return 1; + if (surface->output_name[0] != '\0' && !BLI_path_cmp(name, surface->output_name)) return true; + if (surface->output_name2[0] != '\0' && !BLI_path_cmp(name, surface->output_name2)) return true; } } - return 0; + return false; } static void surface_setUniqueOutputName(DynamicPaintSurface *surface, char *basename, int output) @@ -367,15 +367,15 @@ static void surface_setUniqueOutputName(DynamicPaintSurface *surface, char *base } -static int surface_duplicateNameExists(void *arg, const char *name) +static bool surface_duplicateNameExists(void *arg, const char *name) { DynamicPaintSurface *t_surface = (DynamicPaintSurface *)arg; DynamicPaintSurface *surface = t_surface->canvas->surfaces.first; for (; surface; surface = surface->next) { - if (surface != t_surface && !strcmp(name, surface->name)) return 1; + if (surface != t_surface && !strcmp(name, surface->name)) return true; } - return 0; + return false; } void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, const char *basename) diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 143f2186020..c7c83b7d0a5 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1262,7 +1262,7 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) /* Sanity Validation ------------------------------------ */ -static int nla_editbone_name_check(void *arg, const char *name) +static bool nla_editbone_name_check(void *arg, const char *name) { return BLI_ghash_haskey((GHash *)arg, (void *)name); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 288e4ccde5d..d4d4e07b929 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -591,7 +591,7 @@ void packLibraries(Main *bmain, ReportList *reports) /* test for relativenss */ for (lib = bmain->library.first; lib; lib = lib->id.next) - if (0 == BLI_path_is_rel(lib->name)) + if (!BLI_path_is_rel(lib->name)) break; if (lib) { diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 386a8b27870..4ebebbed52d 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -20,6 +20,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_buffer.h" #include "BLI_ghash.h" #include "BLI_heap.h" -- cgit v1.2.3 From f44b54d2a7866033025bd4e99992a72e3a27c428 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Mar 2013 03:17:46 +0000 Subject: patch [#34103] from Lawrence D'Oliveiro (ldo) More use of bool type, necessitating adding inclusion of BLI_utildefines.h, or moving it up in the inclusion order if it was already included, in various places - storage.c: make some variables only used in bli_builddir local to that - storage.c: BLI_file_descriptor_size should allow 0 as a valid file descriptor - path_util.c: make pointers to non-reentrant storage returned from folder routines const, necessitating making variables holding these returned pointers const elsewhere as well - path_util.c: BLI_string_to_utf8 closes iconv context in case of conversion error - blf_lang.c: fill_locales routine now has its own "languages" local variable to construct paths (was stealing internal storage belonging to BLI_get_folder before) --- source/blender/blenkernel/intern/customdata_file.c | 2 +- source/blender/blenkernel/intern/tracking.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index 78449879f72..dfaa5573562 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -29,9 +29,9 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_fileops.h" #include "BLI_string.h" -#include "BLI_utildefines.h" #include "BLI_endian_switch.h" #include "BKE_customdata_file.h" diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 7e2970108cd..2f813538b41 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1773,6 +1773,7 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea (void) frame_height; (void) search_ibuf; (void) marker; + (void) from_anchor; (void) track; (void) use_mask; -- cgit v1.2.3 From e39f05e5faa63027026e0ec4cd8c085113d01596 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Mar 2013 03:53:22 +0000 Subject: patch [#34103] fileops_1.patch from Lawrence D'Oliveiro (ldo) Add comments and use of bool type in fileops.c --- source/blender/blenkernel/intern/customdata_file.c | 2 +- source/blender/blenkernel/intern/packedFile.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index dfaa5573562..c72eea50e40 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -404,7 +404,7 @@ void cdf_write_close(CDataFile *cdf) void cdf_remove(const char *filename) { - BLI_delete(filename, 0, 0); + BLI_delete(filename, false, false); } /********************************** Layers ***********************************/ diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index d4d4e07b929..cd3357a9281 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -348,7 +348,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i } } else { - if (BLI_delete(tempname, 0, 0) != 0) { + if (BLI_delete(tempname, false, false) != 0) { BKE_reportf(reports, RPT_ERROR, "Error deleting '%s' (ignored)", tempname); } } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index c8947730ea8..4abc176f034 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2432,7 +2432,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) if (mode == PTCACHE_CLEAR_ALL) { pid->cache->last_exact = MIN2(pid->cache->startframe, 0); BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); - BLI_delete(path_full, 0, 0); + BLI_delete(path_full, false, false); } else { /* read the number of the file */ @@ -2448,7 +2448,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) { BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); - BLI_delete(path_full, 0, 0); + BLI_delete(path_full, false, false); if (pid->cache->cached_frames && frame >=sta && frame <= end) pid->cache->cached_frames[frame-sta] = 0; } @@ -2502,7 +2502,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) if (pid->cache->flag & PTCACHE_DISK_CACHE) { if (BKE_ptcache_id_exist(pid, cfra)) { ptcache_filename(pid, filename, cfra, 1, 1); /* no path */ - BLI_delete(filename, 0, 0); + BLI_delete(filename, false, false); } } else { @@ -2820,7 +2820,7 @@ void BKE_ptcache_remove(void) } else if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/ BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); - BLI_delete(path_full, 0, 0); + BLI_delete(path_full, false, false); } else { rmdir = 0; /* unknown file, don't remove the dir */ @@ -2834,7 +2834,7 @@ void BKE_ptcache_remove(void) } if (rmdir) { - BLI_delete(path, 1, 0); + BLI_delete(path, true, false); } } -- cgit v1.2.3 From 384948908afd5567d6c730a8045a368e8c08e436 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Mar 2013 06:26:10 +0000 Subject: patch [#34103] path_util_split_dirstring.patch, path_util_split_dirstring_2.patch, path_util_split_dirstring_3.patch from Lawrence D'Oliveiro (ldo) Get rid of BLI_splitdirstring, replace with calls to BLI_split_dirfile, BLI_split_dir_part and BLI_split_file_part as appropriate. --- source/blender/blenkernel/intern/font.c | 6 +----- source/blender/blenkernel/intern/packedFile.c | 13 +++---------- source/blender/blenkernel/intern/texture.c | 3 +-- 3 files changed, 5 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 3e1e55132d8..e4170a37102 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -195,11 +195,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) is_builtin = TRUE; } else { - char dir[FILE_MAXDIR]; - - BLI_strncpy(dir, name, sizeof(dir)); - BLI_splitdirstring(dir, filename); - + BLI_split_file_part(name, filename, sizeof(filename)); pf = newPackedFile(NULL, name, bmain->name); temp_pf = newPackedFile(NULL, name, bmain->name); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index cd3357a9281..ec13e58d4e0 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -488,11 +488,8 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how) int ret_value = RET_ERROR; if (vfont != NULL) { - BLI_strncpy(localname, vfont->name, sizeof(localname)); - BLI_splitdirstring(localname, fi); - + BLI_split_file_part(vfont->name, fi, sizeof(fi)); BLI_snprintf(localname, sizeof(localname), "//fonts/%s", fi); - newname = unpackFile(reports, vfont->name, localname, vfont->packedfile, how); if (newname != NULL) { ret_value = RET_OK; @@ -513,10 +510,8 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how) int ret_value = RET_ERROR; if (sound != NULL) { - BLI_strncpy(localname, sound->name, sizeof(localname)); - BLI_splitdirstring(localname, fi); + BLI_split_file_part(sound->name, fi, sizeof(fi)); BLI_snprintf(localname, sizeof(localname), "//sounds/%s", fi); - newname = unpackFile(reports, sound->name, localname, sound->packedfile, how); if (newname != NULL) { BLI_strncpy(sound->name, newname, sizeof(sound->name)); @@ -541,10 +536,8 @@ int unpackImage(ReportList *reports, Image *ima, int how) int ret_value = RET_ERROR; if (ima != NULL && ima->name[0]) { - BLI_strncpy(localname, ima->name, sizeof(localname)); - BLI_splitdirstring(localname, fi); + BLI_split_file_part(ima->name, fi, sizeof(fi)); BLI_snprintf(localname, sizeof(localname), "//textures/%s", fi); - newname = unpackFile(reports, ima->name, localname, ima->packedfile, how); if (newname != NULL) { ret_value = RET_OK; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 2ae76ea6d1c..665e3cb4941 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -911,8 +911,7 @@ void autotexname(Tex *tex) else if (tex->type == TEX_IMAGE) { ima = tex->ima; if (ima) { - BLI_strncpy(di, ima->name, sizeof(di)); - BLI_splitdirstring(di, fi); + BLI_split_file_part(ima->name, fi, sizeof(fi)); strcpy(di, "I."); strcat(di, fi); new_id(&bmain->tex, (ID *)tex, di); -- cgit v1.2.3 From 6e76d538551015b0344e4ad2ce467b4f86ca77b1 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 5 Mar 2013 09:34:14 +0000 Subject: Fix #34507, adding reroute node into invalid links would crash the compositor. Compositor relies on correctly tagged invalid links, but the nodeInternalRelink function used to replace reroute nodes in localization did not correctly take this flag into account. If a node replaces a link with an invalid upstream link the resulting link must also be flagged invalid. --- source/blender/blenkernel/intern/node.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 3dbaab008f8..897e2ff2326 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -571,6 +571,12 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node) link->fromnode = fromlink->fromnode; link->fromsock = fromlink->fromsock; + /* if the up- or downstream link is invalid, + * the replacement link will be invalid too. + */ + if (!(fromlink->flag & NODE_LINK_VALID)) + link->flag &= ~NODE_LINK_VALID; + ntree->update |= NTREE_UPDATE_LINKS; } else -- cgit v1.2.3 From dab6f8f5593876ac1c1f9d445c35401ed840b574 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 5 Mar 2013 11:19:21 +0000 Subject: Bug fix #34534 Fix for 2.66a The new Copy/Paste objects feature could hang in eternal loop. Only happens for objects that refer to another scene via linkage. This fix then crashed Blender, needed to add a NULL check for screens. --- source/blender/blenkernel/intern/blender.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index be316197078..9a21a9648c9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -899,7 +899,9 @@ static void copybuffer_doit(void *UNUSED(handle), Main *UNUSED(bmain), void *vid { if (vid) { ID *id = vid; - id->flag |= LIB_NEED_EXPAND | LIB_DOIT; + /* only tag for need-expand if not done, prevents eternal loops */ + if ((id->flag & LIB_DOIT) == 0) + id->flag |= LIB_NEED_EXPAND | LIB_DOIT; } } -- cgit v1.2.3 From f2bb536994baecb442942306d959666cad66bf61 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Mar 2013 14:47:49 +0000 Subject: code cleanup: also change BKE_blender.h BLENDER_VERSION_CHAR to 'a' so as not to confuse things. --- source/blender/blenkernel/intern/cloth.c | 2 -- source/blender/blenkernel/intern/collision.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index c1293542963..77ea856d73c 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -783,10 +783,8 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) /* goalfac= 1.0f; */ /* UNUSED */ - /* // Kicking goal factor to simplify things...who uses that anyway? // ABS ( clmd->sim_parms->maxgoal - clmd->sim_parms->mingoal ); - */ verts->goal = powf(verts->goal, 4.0f); if ( verts->goal >= SOFTGOALSNAP ) diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 061657c8f2d..41efac12250 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -654,7 +654,7 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis { int i; - *collisions = (CollPair *) MEM_mallocN(sizeof(CollPair) * numresult * 64, "collision array" ); //*4 since cloth_collision_static can return more than 1 collision + *collisions = (CollPair *) MEM_mallocN(sizeof(CollPair) * numresult * 64, "collision array" ); // * 4 since cloth_collision_static can return more than 1 collision *collisions_index = *collisions; for ( i = 0; i < numresult; i++ ) { -- cgit v1.2.3 From f840ac9801175cc16dcaceaa6168f262530a548e Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Tue, 5 Mar 2013 20:30:38 +0000 Subject: Weight Painting: Added userpref for zero_weight color. --- source/blender/blenkernel/intern/DerivedMesh.c | 46 +++++++++++++++----------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index ffd86ea9ce0..a0db25f5a48 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1025,12 +1025,18 @@ enum { CALC_WP_AUTO_NORMALIZE = (1 << 4) }; -static void weightpaint_color(unsigned char r_col[4], ColorBand *coba, const float input) +typedef struct DMWeightColorInfo { + ColorBand *coba; + unsigned char *zero_color; +} DMWeightColorInfo; + + +static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcinfo, const float input) { float colf[4]; - if (coba) { - do_colorband(coba, input, colf); + if (dm_wcinfo->coba) { + do_colorband(dm_wcinfo->coba, input, colf); } else { weight_to_rgb(colf, input); @@ -1047,7 +1053,8 @@ static void weightpaint_color(unsigned char r_col[4], ColorBand *coba, const flo static void calc_weightpaint_vert_color( unsigned char r_col[4], - MDeformVert *dv, ColorBand *coba, + MDeformVert *dv, + DMWeightColorInfo *dm_wcinfo, const int defbase_tot, const int defbase_act, const char *defbase_sel, const int defbase_sel_tot, const int draw_flag) @@ -1098,23 +1105,23 @@ static void calc_weightpaint_vert_color( } } - if (make_black) { /* TODO, theme color */ - r_col[3] = 255; - r_col[2] = 0; - r_col[1] = 0; - r_col[0] = 0; + if (make_black) { + r_col[3] = dm_wcinfo->zero_color[3]; + r_col[2] = dm_wcinfo->zero_color[2]; + r_col[1] = dm_wcinfo->zero_color[1]; + r_col[0] = dm_wcinfo->zero_color[0]; } else { CLAMP(input, 0.0f, 1.0f); - weightpaint_color(r_col, coba, input); + weightpaint_color(r_col, dm_wcinfo, input); } } -static ColorBand *stored_cb = NULL; - -void vDM_ColorBand_store(ColorBand *coba) +static DMWeightColorInfo dm_wcinfo; +void vDM_ColorBand_store(ColorBand *coba, char zero_color[4]) { - stored_cb = coba; + dm_wcinfo.coba = coba; + dm_wcinfo.zero_color = zero_color; } /* return an array of vertex weight colors, caller must free. @@ -1122,11 +1129,11 @@ void vDM_ColorBand_store(ColorBand *coba) * note that we could save some memory and allocate RGB only but then we'd need to * re-arrange the colors when copying to the face since MCol has odd ordering, * so leave this as is - campbell */ -static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, ColorBand *coba) +static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, DMWeightColorInfo *dm_wcinfo) { MDeformVert *dv = DM_get_vert_data_layer(dm, CD_MDEFORMVERT); int numVerts = dm->getNumVerts(dm); - unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * numVerts * 4, "weightmap_v"); + unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * numVerts * 4, "weightmap_v"); if (dv) { unsigned char *wc = wtcol_v; @@ -1144,7 +1151,7 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i } for (i = numVerts; i != 0; i--, wc += 4, dv++) { - calc_weightpaint_vert_color(wc, dv, coba, defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag); + calc_weightpaint_vert_color(wc, dv, dm_wcinfo, defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag); } if (defbase_sel) { @@ -1157,7 +1164,7 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i col_i = 0; } else { - weightpaint_color((unsigned char *)&col_i, coba, 0.0f); + weightpaint_color((unsigned char *)&col_i, dm_wcinfo, 0.0f); } fill_vn_i((int *)wtcol_v, numVerts, col_i); } @@ -1185,7 +1192,6 @@ static unsigned char *calc_colors_from_weights_array(const int num, float *weigh void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag, float *weights, int num, const int *indices) { - ColorBand *coba = stored_cb; /* warning, not a local var */ unsigned char *wtcol_v; unsigned char(*wtcol_l)[4] = CustomData_get_layer(dm->getLoopDataLayout(dm), CD_PREVIEW_MLOOPCOL); @@ -1216,7 +1222,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag, /* No weights given, take them from active vgroup(s). */ else - wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, coba); + wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, &dm_wcinfo); /* now add to loops, so the data can be passed through the modifier stack */ /* If no CD_PREVIEW_MLOOPCOL existed yet, we have to add a new one! */ -- cgit v1.2.3 From 28278427dedfc1a799f94a0141bda8cc203b2af9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 6 Mar 2013 02:52:34 +0000 Subject: code cleanup: quiet float/double conversion warnings. --- source/blender/blenkernel/intern/tracking.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 2f813538b41..3e3716138d6 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1446,7 +1446,7 @@ static void cameraIntrinscisOptionsFromTracking(libmv_cameraIntrinsicsOptions *c camera_intrinsics_options->k3 = camera->k3; camera_intrinsics_options->image_width = calibration_width; - camera_intrinsics_options->image_height = (double) calibration_height * aspy; + camera_intrinsics_options->image_height = (double) (calibration_height * aspy); } #endif @@ -1594,8 +1594,8 @@ void BKE_tracking_undistort_v2(MovieTracking *tracking, const float co[2], float libmv_InvertIntrinsics(&camera_intrinsics_options, x, y, &x, &y); - r_co[0] = x * camera->focal + camera->principal[0]; - r_co[1] = y * camera->focal + camera->principal[1] * aspy; + r_co[0] = (float)x * camera->focal + camera->principal[0]; + r_co[1] = (float)y * camera->focal + camera->principal[1] * aspy; #else (void) camera; (void) co; @@ -1730,14 +1730,14 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea int a; for (a = 0; a < 5; a++) { - src_pixel_x[a] += ((track->offset[0] * frame_width) - ((int) (track->offset[0] * frame_width))); - src_pixel_y[a] += ((track->offset[1] * frame_height) - ((int) (track->offset[1] * frame_height))); + src_pixel_x[a] += (double) ((track->offset[0] * frame_width) - ((int) (track->offset[0] * frame_width))); + src_pixel_y[a] += (double) ((track->offset[1] * frame_height) - ((int) (track->offset[1] * frame_height))); /* when offset is negative, rounding happens in opposite direction */ if (track->offset[0] < 0.0f) - src_pixel_x[a] += 1.0f; + src_pixel_x[a] += 1.0; if (track->offset[1] < 0.0f) - src_pixel_y[a] += 1.0f; + src_pixel_y[a] += 1.0; } } @@ -2749,7 +2749,7 @@ static void reconstruct_retrieve_libmv_intrinscis(MovieReconstructContext *conte tracking->camera.focal = focal_length; tracking->camera.principal[0] = principal_x; - tracking->camera.principal[1] = principal_y / aspy; + tracking->camera.principal[1] = principal_y / (double)aspy; tracking->camera.k1 = k1; tracking->camera.k2 = k2; -- cgit v1.2.3 From 785c26a0c33945888ea4da0095f692c92477212b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 6 Mar 2013 02:57:31 +0000 Subject: code cleanup: quiet warnings for recent weight paint theme addition. --- source/blender/blenkernel/intern/DerivedMesh.c | 42 +++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index a0db25f5a48..2b289f1a0b9 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1026,8 +1026,8 @@ enum { }; typedef struct DMWeightColorInfo { - ColorBand *coba; - unsigned char *zero_color; + const ColorBand *coba; + const char *alert_color; } DMWeightColorInfo; @@ -1054,17 +1054,18 @@ static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcin static void calc_weightpaint_vert_color( unsigned char r_col[4], MDeformVert *dv, - DMWeightColorInfo *dm_wcinfo, + DMWeightColorInfo *dm_wcinfo, const int defbase_tot, const int defbase_act, const char *defbase_sel, const int defbase_sel_tot, const int draw_flag) { float input = 0.0f; - bool make_black = false; + bool show_alert_color = false; if ((defbase_sel_tot > 1) && (draw_flag & CALC_WP_MULTIPAINT)) { - int was_a_nonzero = FALSE; + /* Multi-Paint feature */ + bool was_a_nonzero = false; unsigned int i; MDeformWeight *dw = dv->dw; @@ -1075,15 +1076,15 @@ static void calc_weightpaint_vert_color( if (defbase_sel[dw->def_nr]) { if (dw->weight) { input += dw->weight; - was_a_nonzero = TRUE; + was_a_nonzero = true; } } } } /* make it black if the selected groups have no weight on a vertex */ - if (was_a_nonzero == FALSE) { - make_black = true; + if (was_a_nonzero == false) { + show_alert_color = true; } else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) { input /= defbase_sel_tot; /* get the average */ @@ -1095,33 +1096,32 @@ static void calc_weightpaint_vert_color( if (draw_flag & CALC_WP_GROUP_USER_ACTIVE) { if (input == 0.0f) { - make_black = true; + show_alert_color = true; } } else if (draw_flag & CALC_WP_GROUP_USER_ALL) { if (input == 0.0f) { - make_black = defvert_is_weight_zero(dv, defbase_tot); + show_alert_color = defvert_is_weight_zero(dv, defbase_tot); } } } - if (make_black) { - r_col[3] = dm_wcinfo->zero_color[3]; - r_col[2] = dm_wcinfo->zero_color[2]; - r_col[1] = dm_wcinfo->zero_color[1]; - r_col[0] = dm_wcinfo->zero_color[0]; - } - else { + if (show_alert_color == false) { CLAMP(input, 0.0f, 1.0f); weightpaint_color(r_col, dm_wcinfo, input); } + else { + copy_v3_v3_char((char *)r_col, dm_wcinfo->alert_color); + r_col[3] = 255; + } } static DMWeightColorInfo dm_wcinfo; -void vDM_ColorBand_store(ColorBand *coba, char zero_color[4]) + +void vDM_ColorBand_store(const ColorBand *coba, const char alert_color[4]) { - dm_wcinfo.coba = coba; - dm_wcinfo.zero_color = zero_color; + dm_wcinfo.coba = coba; + dm_wcinfo.alert_color = alert_color; } /* return an array of vertex weight colors, caller must free. @@ -1133,7 +1133,7 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i { MDeformVert *dv = DM_get_vert_data_layer(dm, CD_MDEFORMVERT); int numVerts = dm->getNumVerts(dm); - unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * numVerts * 4, "weightmap_v"); + unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * numVerts * 4, "weightmap_v"); if (dv) { unsigned char *wc = wtcol_v; -- cgit v1.2.3 From 74a9c1510a0be7f28056dd12a8280eb3d4931a5f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 6 Mar 2013 03:58:38 +0000 Subject: Alternate fix for bug [#34369], where invalid polygon normals could be saved in the mesh data and in the file. This was from initial BMesh merge, but should not have been added in since face normals are calculated and stored in the DerivedMesh. Toggling editmode would remove poly-normals so its unlikely anything relies on this custom-data. --- source/blender/blenkernel/intern/customdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 787c854d280..e43f8312f39 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1169,7 +1169,7 @@ const CustomDataMask CD_MASK_MESH = CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MPOLY | CD_MASK_MLOOP | - CD_MASK_MTEXPOLY | CD_MASK_NORMAL | CD_MASK_RECAST | CD_MASK_PAINT_MASK | + CD_MASK_MTEXPOLY | CD_MASK_RECAST | CD_MASK_PAINT_MASK | CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN; const CustomDataMask CD_MASK_EDITMESH = CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MLOOPUV | -- cgit v1.2.3 From c75065136c03a4cb65709c87b66579190c6bdeee Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 6 Mar 2013 18:01:24 +0000 Subject: Tracking dopesheet fixes: - Dopesheet need to be updated when adding or switching between objects. - After removing object it shall also be tagged for update, otherwise crash will likely happen. --- source/blender/blenkernel/intern/tracking.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 3e3716138d6..9d6607b2b97 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1189,6 +1189,7 @@ MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char object->keyframe2 = 30; BKE_tracking_object_unique_name(tracking, object); + BKE_tracking_dopesheet_tag_update(tracking); return object; } @@ -1223,6 +1224,9 @@ int BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *obj tracking->objectnr = index - 1; else tracking->objectnr = 0; + + BKE_tracking_dopesheet_tag_update(tracking); + return TRUE; } -- cgit v1.2.3 From 53b7bc8f1f7126600f431e63398a7678e643c8ae Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 6 Mar 2013 20:55:04 +0000 Subject: Change !BLI_ghashIterator_isDone to BLI_ghashIterator_notDone. It is always used in that context so we can at least avoid reverting it twice :p. --- source/blender/blenkernel/intern/pbvh.c | 4 ++-- source/blender/blenkernel/intern/softbody.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 477ae27394f..5efeeaeedaa 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -294,7 +294,7 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) /* Build the vertex list, unique verts first */ for (iter = BLI_ghashIterator_new(map), i = 0; - BLI_ghashIterator_isDone(iter) == FALSE; + BLI_ghashIterator_notDone(iter); BLI_ghashIterator_step(iter), ++i) { void *value = BLI_ghashIterator_getValue(iter); @@ -1217,7 +1217,7 @@ void BKE_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot faces = MEM_callocN(sizeof(void *) * tot, "PBVH Grid Faces"); for (hiter = BLI_ghashIterator_new(map), i = 0; - !BLI_ghashIterator_isDone(hiter); + BLI_ghashIterator_notDone(hiter); BLI_ghashIterator_step(hiter), ++i) { faces[i] = BLI_ghashIterator_getKey(hiter); diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index e2c6df5e528..01d4696de94 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1034,7 +1034,7 @@ static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), unsigned int U hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); - while (!BLI_ghashIterator_isDone(ihash) ) { + while (BLI_ghashIterator_notDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); @@ -1113,7 +1113,7 @@ static int sb_detect_face_pointCached(float face_v1[3], float face_v2[3], float hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); - while (!BLI_ghashIterator_isDone(ihash) ) { + while (BLI_ghashIterator_notDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); @@ -1205,7 +1205,7 @@ static int sb_detect_face_collisionCached(float face_v1[3], float face_v2[3], fl hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); - while (!BLI_ghashIterator_isDone(ihash) ) { + while (BLI_ghashIterator_notDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); @@ -1433,7 +1433,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3], float edge_v2[3], fl hash = vertexowner->soft->scratch->colliderhash; ihash = BLI_ghashIterator_new(hash); - while (!BLI_ghashIterator_isDone(ihash) ) { + while (BLI_ghashIterator_notDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); @@ -1763,7 +1763,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], outerforceaccu[0]=outerforceaccu[1]=outerforceaccu[2]=0.0f; innerforceaccu[0]=innerforceaccu[1]=innerforceaccu[2]=0.0f; /* go */ - while (!BLI_ghashIterator_isDone(ihash) ) { + while (BLI_ghashIterator_notDone(ihash) ) { ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash); ob = BLI_ghashIterator_getKey (ihash); -- cgit v1.2.3 From 65869589b6bc0caf9a08a10415a18dc563a447cf Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 6 Mar 2013 22:54:44 +0000 Subject: Support position jittering on new texpaint code using the stroke system. --- source/blender/blenkernel/intern/paint.c | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index d34d5eaa250..a001a13d000 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -137,6 +137,55 @@ Paint *paint_get_active_from_context(const bContext *C) return NULL; } +PaintMode paintmode_get_active_from_context(const bContext *C) +{ + Scene *sce = CTX_data_scene(C); + SpaceImage *sima; + + if (sce) { + ToolSettings *ts = sce->toolsettings; + Object *obact = NULL; + + if (sce->basact && sce->basact->object) + obact = sce->basact->object; + + if ((sima = CTX_wm_space_image(C)) != NULL) { + if (obact && obact->mode == OB_MODE_EDIT) { + if (sima->mode == SI_MODE_PAINT) + return PAINT_TEXTURE_2D; + else if (ts->use_uv_sculpt) + return PAINT_SCULPT_UV; + } + else { + return PAINT_TEXTURE_2D; + } + } + else if (obact) { + switch (obact->mode) { + case OB_MODE_SCULPT: + return PAINT_SCULPT; + case OB_MODE_VERTEX_PAINT: + return PAINT_VERTEX; + case OB_MODE_WEIGHT_PAINT: + return PAINT_WEIGHT; + case OB_MODE_TEXTURE_PAINT: + return PAINT_TEXTURE_PROJECTIVE; + case OB_MODE_EDIT: + if (ts->use_uv_sculpt) + return PAINT_SCULPT_UV; + else + return PAINT_TEXTURE_2D; + } + } + else { + /* default to image paint */ + return PAINT_TEXTURE_2D; + } + } + + return PAINT_INVALID; +} + Brush *paint_brush(Paint *p) { return p ? p->brush : NULL; -- cgit v1.2.3 From dfa8540cdfac0d8071faa8be80d82349962c566d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 7 Mar 2013 02:44:55 +0000 Subject: use bool for rna funcs. --- source/blender/blenkernel/intern/context.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index a9e3d52f223..d899990a66a 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -27,7 +27,6 @@ * \ingroup bke */ - #include #include #include @@ -41,8 +40,6 @@ #include "DNA_windowmanager_types.h" #include "DNA_object_types.h" -#include "RNA_access.h" - #include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_threads.h" @@ -54,8 +51,10 @@ #include "BKE_main.h" #include "BKE_screen.h" +#include "RNA_access.h" + #ifdef WITH_PYTHON -#include "BPY_extern.h" +# include "BPY_extern.h" #endif /* struct */ -- cgit v1.2.3 From 41bf595c5f57247beee262005aab8a0d723660c5 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Thu, 7 Mar 2013 12:11:38 +0000 Subject: Texture paint refactoring commit This is as close as I can get to keeping the old code intact. After this commit, I will have to change existing code paths, making testing of functionality harder. Changes: * Keep only projective texturing code in paint_image_proj.c * Move 2D code to paint_image_2d.c. This needed the introduction of allocation/cleanup functions for the relevant structures. * Common code interface for both modes stays in paint_image.c (which still includes all old code, system should work as it did with the exception of non-projective 3D paint mode) and is made public. This is not a lot of code, only rectangle invalidation and undo system. * Changed the naming in the new code slightly: imapaint_ prefixed functions refer to common functions used by both systems, paint_2d_ prefixed to 2d painting. There will be an interface for the projection painting as well. Probably there is some leftover naming conversions to do. TODO: * Move operator init/exec/modal to common interface file * Get rid of old BKE_brush_painter_paint, now brush_painter_2d_paint. All code uses stroke system for the stroke management * Write space pressure management for the paint stroke system (for other systems to access as well :) ) * Move texture paint tablet presssure exception code for old bugs to stroke system (makes me wonder...aren't other systems also influenced by these pressure issues?) or up in the function hierarchy inside texture paint. This code is still not there so users with tablets may notice some issues. * possibly change other systems to pre-multiply pressure with the relevant influenced attributes in the stroke function. This could get tricky though and it's possible that it could backfire. --- source/blender/blenkernel/intern/brush.c | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index ba69fa4336e..798dde9f985 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -53,6 +53,7 @@ #include "IMB_imbuf_types.h" #include "RE_render_ext.h" /* externtex */ +#include "RE_shader_ext.h" static void brush_defaults(Brush *brush) { @@ -841,6 +842,49 @@ float BKE_brush_curve_strength(Brush *br, float p, const float len) return curvemapping_evaluateF(br->curve, 0, p); } +/* TODO: should probably be unified with BrushPainter stuff? */ +unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) +{ + unsigned int *texcache = NULL; + MTex *mtex = &br->mtex; + TexResult texres = {0}; + int hasrgb, ix, iy; + int side = half_side * 2; + + if (mtex->tex) { + float x, y, step = 2.0 / side, co[3]; + + texcache = MEM_callocN(sizeof(int) * side * side, "Brush texture cache"); + + /*do normalized cannonical view coords for texture*/ + for (y = -1.0, iy = 0; iy < side; iy++, y += step) { + for (x = -1.0, ix = 0; ix < side; ix++, x += step) { + co[0] = x; + co[1] = y; + co[2] = 0.0f; + + /* This is copied from displace modifier code */ + hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres, NULL); + + /* if the texture gave an RGB value, we assume it didn't give a valid + * intensity, so calculate one (formula from do_material_tex). + * if the texture didn't give an RGB value, copy the intensity across + */ + if (hasrgb & TEX_RGB) + texres.tin = rgb_to_grayscale(&texres.tr); + + ((char *)texcache)[(iy * side + ix) * 4] = + ((char *)texcache)[(iy * side + ix) * 4 + 1] = + ((char *)texcache)[(iy * side + ix) * 4 + 2] = + ((char *)texcache)[(iy * side + ix) * 4 + 3] = (char)(texres.tin * 255.0f); + } + } + } + + return texcache; +} + + /**** Radial Control ****/ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br) { -- cgit v1.2.3 From c36f20a7d2c3486f34ba73680881189c75cc3e7d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 8 Mar 2013 04:00:06 +0000 Subject: style cleanup --- source/blender/blenkernel/intern/bmfont.c | 6 +++--- source/blender/blenkernel/intern/collision.c | 4 ++-- source/blender/blenkernel/intern/implicit.c | 2 +- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/pbvh_bmesh.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/seqcache.c | 4 ++-- source/blender/blenkernel/intern/sequencer.c | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index fc83b24da5b..e82a2a53b7d 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -56,7 +56,7 @@ #include "BKE_bmfont.h" #include "BKE_bmfont_types.h" -void printfGlyph(bmGlyph * glyph) +void printfGlyph(bmGlyph *glyph) { printf("unicode: %d '%c'\n", glyph->unicode, glyph->unicode); printf(" locx: %4d locy: %4d\n", glyph->locx, glyph->locy); @@ -68,7 +68,7 @@ void printfGlyph(bmGlyph * glyph) #define MAX2(x, y) ((x) > (y) ? (x) : (y)) #define MAX3(x, y, z) (MAX2(MAX2((x), (y)), (z))) -void calcAlpha(ImBuf * ibuf) +void calcAlpha(ImBuf *ibuf) { int i; char * rect; @@ -82,7 +82,7 @@ void calcAlpha(ImBuf * ibuf) } } -void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) +void readBitmapFontVersion0(ImBuf *ibuf, unsigned char *rect, int step) { int glyphcount, bytes, i, index, linelength, ysize; unsigned char * buffer; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 41efac12250..ed72a0fb37b 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -116,7 +116,7 @@ BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert return tree; } -void bvhtree_update_from_mvert(BVHTree * bvhtree, MFace *faces, int numfaces, MVert *x, MVert *xnew, int UNUSED(numverts), int moving ) +void bvhtree_update_from_mvert(BVHTree *bvhtree, MFace *faces, int numfaces, MVert *x, MVert *xnew, int UNUSED(numverts), int moving ) { int i; MFace *mfaces = faces; @@ -706,7 +706,7 @@ static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, Collision } // cloth - object collisions -int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, float dt ) +int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, float dt ) { Cloth *cloth= clmd->clothObject; BVHTree *cloth_bvh= cloth->bvhtree; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 90cd7bc2df5..b9064fe8ba3 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1716,7 +1716,7 @@ static void simulate_implicit_euler(lfVector *Vnew, lfVector *UNUSED(lX), lfVect * (edge distance constraints) in a lagrangian solver. then add forces to help * guide the implicit solver to that state. this function is called after * collisions*/ -static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothModifierData * clmd, float (*initial_cos)[3], float UNUSED(step), float dt) +static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothModifierData *clmd, float (*initial_cos)[3], float UNUSED(step), float dt) { Cloth *cloth= clmd->clothObject; float (*cos)[3] = MEM_callocN(sizeof(float)*3*cloth->numverts, "cos cloth_calc_helper_forces"); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index c7c83b7d0a5..ccae1f606fc 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1660,7 +1660,7 @@ void BKE_nla_tweakmode_exit(AnimData *adt) /* Baking Tools ------------------------------------------- */ -static void UNUSED_FUNCTION(BKE_nla_bake) (Scene * scene, ID *UNUSED(id), AnimData * adt, int UNUSED(flag)) +static void UNUSED_FUNCTION(BKE_nla_bake) (Scene *scene, ID *UNUSED(id), AnimData *adt, int UNUSED(flag)) { /* verify that data is valid diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 4ebebbed52d..9befd68a1d6 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -1342,7 +1342,7 @@ void pbvh_bmesh_verify(PBVH *bvh) /* Check that the vertex is in the node */ BLI_assert(BLI_ghash_haskey(n->bm_unique_verts, v) ^ - BLI_ghash_haskey(n->bm_other_verts, v)); + BLI_ghash_haskey(n->bm_other_verts, v)); /* Check that the vertex has a node owner */ nv = pbvh_bmesh_node_lookup(bvh, bvh->bm_vert_to_node, v); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 4abc176f034..6276bce8ca2 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -3039,7 +3039,7 @@ static void *ptcache_bake_thread(void *ptr) } /* if bake is not given run simulations to current frame */ -void BKE_ptcache_bake(PTCacheBaker* baker) +void BKE_ptcache_bake(PTCacheBaker *baker) { Main *bmain = baker->main; Scene *scene = baker->scene; diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index e3f0226c863..978c1a7c9b0 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -26,7 +26,6 @@ * \ingroup bke */ - #include #include "BLO_sys_types.h" /* for intptr_t */ @@ -34,7 +33,6 @@ #include "MEM_guardedalloc.h" #include "DNA_sequence_types.h" -#include "BKE_sequencer.h" #include "IMB_moviecache.h" #include "IMB_imbuf.h" @@ -42,6 +40,8 @@ #include "BLI_listbase.h" +#include "BKE_sequencer.h" + typedef struct SeqCacheKey { struct Sequence *seq; SeqRenderData context; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 613c02c173b..a4949e3b338 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -245,7 +245,7 @@ static void seq_free_sequence_recurse(Scene *scene, Sequence *seq) } -Editing *BKE_sequencer_editing_get(Scene *scene, int alloc) +Editing *BKE_sequencer_editing_get(Scene *scene, bool alloc) { if (alloc) { BKE_sequencer_editing_ensure(scene); -- cgit v1.2.3 From 9e1ead1940f084c24b3751a1a52e40f40c3c4df1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 9 Mar 2013 03:34:01 +0000 Subject: expose obrel_is_recursive_child in BKE_object.h and rename to BKE_object_is_child_recursive() --- source/blender/blenkernel/intern/object.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c98c18b9cdc..0ace60b1fd4 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3126,6 +3126,17 @@ KeyBlock *BKE_object_insert_shape_key(Scene *scene, Object *ob, const char *name } +bool BKE_object_is_child_recursive(Object *ob_parent, Object *ob_child) +{ + Object *ob_test; + for (ob_test = ob_child->parent; ob_test; ob_test = ob_test->parent) { + if (ob_test == ob_parent) { + return true; + } + } + return false; +} + /* most important if this is modified it should _always_ return True, in certain * cases false positives are hard to avoid (shape keys for example) */ int BKE_object_is_modified(Scene *scene, Object *ob) @@ -3275,18 +3286,6 @@ static Object *obrel_armature_find(Object *ob) return ob_arm; } -static int obrel_is_recursive_child(Object *ob, Object *child) -{ - Object *par; - for (par = child->parent; par; par = par->parent) { - if (par == ob) { - return TRUE; - } - } - return FALSE; -} - - static int obrel_list_test(Object *ob) { return ob && !(ob->id.flag & LIB_DOIT); @@ -3359,7 +3358,7 @@ LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet objectS Object *child = local_base->object; if (obrel_list_test(child)) { - if ((includeFilter & OB_REL_CHILDREN_RECURSIVE && obrel_is_recursive_child(ob, child)) || + if ((includeFilter & OB_REL_CHILDREN_RECURSIVE && BKE_object_is_child_recursive(ob, child)) || (includeFilter & OB_REL_CHILDREN && child->parent && child->parent == ob)) { obrel_list_add(&links, child); -- cgit v1.2.3 From ddddb7bab173b040342ef99270ee71ae076d45e8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 9 Mar 2013 03:46:30 +0000 Subject: code cleanup: favor braces when blocks have mixed brace use. --- source/blender/blenkernel/intern/colortools.c | 8 +++- source/blender/blenkernel/intern/curve.c | 4 +- source/blender/blenkernel/intern/depsgraph.c | 4 +- source/blender/blenkernel/intern/dynamicpaint.c | 16 +++++-- source/blender/blenkernel/intern/font.c | 9 ++-- source/blender/blenkernel/intern/image.c | 4 +- source/blender/blenkernel/intern/key.c | 56 ++++++++++++++++++------- source/blender/blenkernel/intern/lattice.c | 22 ++++++---- source/blender/blenkernel/intern/material.c | 4 +- source/blender/blenkernel/intern/mball.c | 4 +- source/blender/blenkernel/intern/property.c | 6 ++- source/blender/blenkernel/intern/scene.c | 8 +++- source/blender/blenkernel/intern/seqeffects.c | 22 +++++----- source/blender/blenkernel/intern/smoke.c | 4 +- source/blender/blenkernel/intern/text.c | 4 +- source/blender/blenkernel/intern/texture.c | 12 ++++-- source/blender/blenkernel/intern/tracking.c | 4 +- 17 files changed, 135 insertions(+), 56 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index d08c16eac9e..5176f93f4f3 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -199,7 +199,9 @@ int curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) cmp[b] = cuma->curve[a]; b++; } - else removed++; + else { + removed++; + } } MEM_freeN(cuma->curve); @@ -221,7 +223,9 @@ void curvemap_remove(CurveMap *cuma, const short flag) cmp[b] = cuma->curve[a]; b++; } - else removed++; + else { + removed++; + } } cmp[b] = cuma->curve[a]; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 2da75ec64be..0cb42fb46de 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -793,7 +793,9 @@ static void makeknots(Nurb *nu, short uv) calcknots(nu->knotsv, nu->pntsv, nu->orderv, nu->flagv); } } - else nu->knotsv = NULL; + else { + nu->knotsv = NULL; + } } } } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index b919b9ffd8f..3a531cf32ae 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1555,7 +1555,9 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) if (itA->node->lasttime != curtime) { itA->lay = flush_layer_node(sce, itA->node, curtime); /* lay is only set once for each relation */ } - else itA->lay = itA->node->lay; + else { + itA->lay = itA->node->lay; + } node->lay |= itA->lay; } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index a01b08a3c63..4b05f1c1050 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -473,7 +473,9 @@ static float mixColors(float a_color[3], float a_weight, float b_color[3], float } weight_ratio = b_weight / (a_weight + b_weight); } - else return a_weight * (1.0f - ratio); + else { + return a_weight * (1.0f - ratio); + } /* calculate final interpolation factor */ if (ratio <= 0.5f) { @@ -2606,7 +2608,9 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) if (!f_data->uv_p || !f_data->barycentricWeights) error = 1; } - else error = 1; + else { + error = 1; + } sData->total_points = active_points; @@ -2859,7 +2863,9 @@ static void dynamicPaint_doMaterialTex(BrushMaterials *bMats, float color[3], fl mat = bMats->ob_mats[mat_nr]; if (mat == NULL) return; /* No material assigned */ } - else return; + else { + return; + } } RE_sample_material_color(mat, color, alpha, volume_co, surface_co, faceIndex, isQuad, orcoDm, brushOb); @@ -3924,7 +3930,9 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po strength = 1.0f - distance / brush_radius; CLAMP(strength, 0.0f, 1.0f); } - else strength = 1.0f; + else { + strength = 1.0f; + } if (strength >= 0.001f) { float paintColor[3] = {0.0f}; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index e4170a37102..3578033f566 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -943,10 +943,13 @@ makebreak: ct = chartransdata; for (i = 0; i < slen; i++) { if (ct->linenr == lnr) { - if (ct->charnr == cnr) break; - if ( (ct + 1)->charnr == 0) break; + if ((ct->charnr == cnr) || ((ct + 1)->charnr == 0)) { + break; + } + } + else if (ct->linenr > lnr) { + break; } - else if (ct->linenr > lnr) break; cu->pos++; ct++; } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 3655afdf088..689d1959b16 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1567,7 +1567,9 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (camera && camera->type == OB_CAMERA) { BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)camera->data)->lens); } - else BLI_strncpy(text, "", sizeof(text)); + else { + BLI_strncpy(text, "", sizeof(text)); + } BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s" : "%s", text); } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index f3dc391738e..d123de224e9 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -405,9 +405,13 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl) k1 = firstkey; ofs += dpos; } - else if (t[2] == t[3]) break; + else if (t[2] == t[3]) { + break; + } + } + else { + k1 = k1->next; } - else k1 = k1->next; t[0] = t[1]; k[0] = k[1]; @@ -595,7 +599,9 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key k1 += a * key->elemsize; } } - else k1 += start * key->elemsize; + else { + k1 += start * key->elemsize; + } } if (mode == KEY_MODE_BEZTRIPLE) { @@ -828,7 +834,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key if (k[0]->totelem) { k1d = k[0]->totelem / (float)tot; } - else flagdo -= 1; + else { + flagdo -= 1; + } } if (tot != k[1]->totelem) { k2tot = 0.0; @@ -836,7 +844,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key if (k[0]->totelem) { k2d = k[1]->totelem / (float)tot; } - else flagdo -= 2; + else { + flagdo -= 2; + } } if (tot != k[2]->totelem) { k3tot = 0.0; @@ -844,7 +854,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key if (k[0]->totelem) { k3d = k[2]->totelem / (float)tot; } - else flagdo -= 4; + else { + flagdo -= 4; + } } if (tot != k[3]->totelem) { k4tot = 0.0; @@ -852,7 +864,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key if (k[0]->totelem) { k4d = k[3]->totelem / (float)tot; } - else flagdo -= 8; + else { + flagdo -= 8; + } } /* this exception needed for slurphing */ @@ -869,7 +883,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key k1 += a * key->elemsize; } } - else k1 += start * key->elemsize; + else { + k1 += start * key->elemsize; + } } if (flagdo & 2) { if (flagflo & 2) { @@ -880,7 +896,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key k2 += a * key->elemsize; } } - else k2 += start * key->elemsize; + else { + k2 += start * key->elemsize; + } } if (flagdo & 4) { if (flagflo & 4) { @@ -891,7 +909,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key k3 += a * key->elemsize; } } - else k3 += start * key->elemsize; + else { + k3 += start * key->elemsize; + } } if (flagdo & 8) { if (flagflo & 8) { @@ -902,7 +922,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key k4 += a * key->elemsize; } } - else k4 += start * key->elemsize; + else { + k4 += start * key->elemsize; + } } } @@ -968,7 +990,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key k2 += elemsize; } } - else k2 += elemsize; + else { + k2 += elemsize; + } } if (flagdo & 4) { if (flagflo & 4) { @@ -978,7 +1002,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key k3 += elemsize; } } - else k3 += elemsize; + else { + k3 += elemsize; + } } if (flagdo & 8) { if (flagflo & 8) { @@ -988,7 +1014,9 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key k4 += elemsize; } } - else k4 += elemsize; + else { + k4 += elemsize; + } } if (mode == KEY_MODE_BEZTRIPLE) a += 2; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index c3e7a963c04..c881209b109 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -404,9 +404,11 @@ void calc_latt_deform(Object *ob, float co[3], float weight) if (w != 0.0f) { if (ww > 0) { if (ww < lt->pntsw) idx_w = ww * lt->pntsu * lt->pntsv; - else idx_w = (lt->pntsw - 1) * lt->pntsu * lt->pntsv; + else idx_w = (lt->pntsw - 1) * lt->pntsu * lt->pntsv; + } + else { + idx_w = 0; } - else idx_w = 0; for (vv = vi - 1; vv <= vi + 2; vv++) { v = w * tv[vv - vi + 1]; @@ -414,9 +416,11 @@ void calc_latt_deform(Object *ob, float co[3], float weight) if (v != 0.0f) { if (vv > 0) { if (vv < lt->pntsv) idx_v = idx_w + vv * lt->pntsu; - else idx_v = idx_w + (lt->pntsv - 1) * lt->pntsu; + else idx_v = idx_w + (lt->pntsv - 1) * lt->pntsu; + } + else { + idx_v = idx_w; } - else idx_v = idx_w; for (uu = ui - 1; uu <= ui + 2; uu++) { u = weight * v * tu[uu - ui + 1]; @@ -424,9 +428,11 @@ void calc_latt_deform(Object *ob, float co[3], float weight) if (u != 0.0f) { if (uu > 0) { if (uu < lt->pntsu) idx_u = idx_v + uu; - else idx_u = idx_v + (lt->pntsu - 1); + else idx_u = idx_v + (lt->pntsu - 1); + } + else { + idx_u = idx_v; } - else idx_u = idx_v; madd_v3_v3fl(co, <->latticedata[idx_u * 3], u); @@ -492,7 +498,9 @@ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir if (cycl == 0) { ctime1 = CLAMPIS(ctime, 0.0f, 1.0f); } - else ctime1 = ctime; + else { + ctime1 = ctime; + } /* vec needs 4 items */ if (where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) { diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 47117658b5e..ab425d8e5b9 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1794,7 +1794,9 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) ma->game.flag = -flag; id_us_min((ID *)ma); } - else printf("Error: Unable to create Material \"%s\" for Mesh \"%s\".", idname + 2, me->id.name + 2); + else { + printf("Error: Unable to create Material \"%s\" for Mesh \"%s\".", idname + 2, me->id.name + 2); + } } /* set as converted, no need to go bad to this face */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 5cc3145213c..5c97b29885f 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -2293,7 +2293,9 @@ void BKE_mball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) } /* width is size per polygonize cube */ - if (G.is_rendering) width = mb->rendersize; + if (G.is_rendering) { + width = mb->rendersize; + } else { width = mb->wiresize; if (G.moving && mb->flag == MB_UPDATE_HALFRES) width *= 2; diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index c4658712ecb..ec23a7db8a1 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -74,8 +74,10 @@ bProperty *BKE_bproperty_copy(bProperty *prop) if (prop->poin && prop->poin != &prop->data) { propn->poin = MEM_dupallocN(prop->poin); } - else propn->poin = &propn->data; - + else { + propn->poin = &propn->data; + } + return propn; } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 369a6e85776..131fb38e816 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -760,7 +760,9 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob) else { if (*base && fase != F_DUPLI) { *base = (*base)->next; - if (*base) *ob = (*base)->object; + if (*base) { + *ob = (*base)->object; + } else { if (fase == F_SCENE) { /* (*scene) is finished, now do the set */ @@ -777,7 +779,9 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob) } } - if (*base == NULL) fase = F_START; + if (*base == NULL) { + fase = F_START; + } else { if (fase != F_DUPLI) { if ( (*base)->object->transflag & OB_DUPLI) { diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index c0e85352217..a1dc19e1ff7 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -182,8 +182,8 @@ static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y, un fac = fac2; mfac = 1.0f - fac2 * rt1[3]; - if (fac <= 0.0f) *( (unsigned int *) rt) = *( (unsigned int *) cp2); - else if (mfac <= 0.0f) *( (unsigned int *) rt) = *( (unsigned int *) cp1); + if (fac <= 0.0f) *((unsigned int *) rt) = *((unsigned int *) cp2); + else if (mfac <= 0.0f) *((unsigned int *) rt) = *((unsigned int *) cp1); else { tempc[0] = fac * rt1[0] + mfac * rt2[0]; tempc[1] = fac * rt1[1] + mfac * rt2[1]; @@ -206,8 +206,8 @@ static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y, un fac = fac4; mfac = 1.0f - (fac4 * rt1[3]); - if (fac <= 0.0f) *( (unsigned int *) rt) = *( (unsigned int *) cp2); - else if (mfac <= 0.0f) *( (unsigned int *) rt) = *( (unsigned int *) cp1); + if (fac <= 0.0f) *((unsigned int *) rt) = *((unsigned int *) cp2); + else if (mfac <= 0.0f) *((unsigned int *) rt) = *((unsigned int *) cp1); else { tempc[0] = fac * rt1[0] + mfac * rt2[0]; tempc[1] = fac * rt1[1] + mfac * rt2[1]; @@ -328,13 +328,13 @@ static void do_alphaunder_effect_byte(float facf0, float facf1, int x, int y, un /* this complex optimization is because the * 'skybuf' can be crossed in */ - if (rt2[3] == 0 && fac2 == 256) *( (unsigned int *) rt) = *( (unsigned int *) rt1); - else if (rt2[3] == 255) *( (unsigned int *) rt) = *( (unsigned int *) rt2); + if (rt2[3] == 0 && fac2 == 256) *((unsigned int *) rt) = *((unsigned int *) rt1); + else if (rt2[3] == 255) *((unsigned int *) rt) = *((unsigned int *) rt2); else { mfac = rt2[3]; fac = (fac2 * (256 - mfac)) >> 8; - if (fac == 0) *( (unsigned int *) rt) = *( (unsigned int *) rt2); + if (fac == 0) *((unsigned int *) rt) = *((unsigned int *) rt2); else { rt[0] = (fac * rt1[0] + mfac * rt2[0]) >> 8; rt[1] = (fac * rt1[1] + mfac * rt2[1]) >> 8; @@ -351,13 +351,13 @@ static void do_alphaunder_effect_byte(float facf0, float facf1, int x, int y, un x = xo; while (x--) { - if (rt2[3] == 0 && fac4 == 256) *( (unsigned int *) rt) = *( (unsigned int *) rt1); - else if (rt2[3] == 255) *( (unsigned int *) rt) = *( (unsigned int *) rt2); + if (rt2[3] == 0 && fac4 == 256) *((unsigned int *) rt) = *((unsigned int *) rt1); + else if (rt2[3] == 255) *((unsigned int *) rt) = *((unsigned int *) rt2); else { mfac = rt2[3]; fac = (fac4 * (256 - mfac)) >> 8; - if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + if (fac == 0) *((unsigned int *)rt) = *((unsigned int *)rt2); else { rt[0] = (fac * rt1[0] + mfac * rt2[0]) >> 8; rt[1] = (fac * rt1[1] + mfac * rt2[1]) >> 8; @@ -682,7 +682,7 @@ static void gamtabs(float gamma) } /* inverse gamtab1 : in byte, out short */ for (a = 1; a <= 256; a++) { - if (gamma == 2.0f) igamtab1[a - 1] = a * a - 1; + if (gamma == 2.0f) igamtab1[a - 1] = a * a - 1; else if (gamma == 1.0f) igamtab1[a - 1] = 256 * a - 1; else { val = a / 256.0f; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 248cd689258..ca3908ab033 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -2284,7 +2284,9 @@ struct DerivedMesh *smokeModifier_do(SmokeModifierData *smd, Scene *scene, Objec { return createDomainGeometry(smd->domain, ob); } - else return CDDM_copy(dm); + else { + return CDDM_copy(dm); + } } static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 184984352ba..a155ca47d3c 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -930,7 +930,9 @@ void txt_move_right(Text *text, short sel) tabsize++; (*charp) = i; } - else (*charp) += BLI_str_utf8_size((*linep)->line + *charp); + else { + (*charp) += BLI_str_utf8_size((*linep)->line + *charp); + } } if (!sel) txt_pop_sel(text); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 665e3cb4941..bdf2ce622de 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -256,7 +256,9 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) left.pos = 0.0f; cbd2 = &left; } - else cbd2 = cbd1 - 1; + else { + cbd2 = cbd1 - 1; + } if (in >= cbd1->pos && coba->ipotype < 2) { out[0] = cbd1->r; @@ -916,9 +918,13 @@ void autotexname(Tex *tex) strcat(di, fi); new_id(&bmain->tex, (ID *)tex, di); } - else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); + else { + new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); + } + } + else { + new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } - else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } } #endif diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 9d6607b2b97..5f8e25af2ee 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -261,7 +261,9 @@ void BKE_tracking_get_projection_matrix(MovieTracking *tracking, MovieTrackingOb invert_m4_m4(imat, camera->mat); mult_m4_m4m4(mat, winmat, imat); } - else copy_m4_m4(mat, winmat); + else { + copy_m4_m4(mat, winmat); + } } /* **** space transformation functions **** */ -- cgit v1.2.3 From 221a383366cb40e4ddf4e4edcc82baed25525d39 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 9 Mar 2013 05:35:49 +0000 Subject: use 'bool' for BLI_/BKE_ functions. --- source/blender/blenkernel/intern/curve.c | 58 +++++++++++----------- source/blender/blenkernel/intern/font.c | 2 +- source/blender/blenkernel/intern/idcode.c | 11 +++-- source/blender/blenkernel/intern/image.c | 6 +-- source/blender/blenkernel/intern/image_gen.c | 5 +- source/blender/blenkernel/intern/mball.c | 19 ++++---- source/blender/blenkernel/intern/object.c | 68 +++++++++++++------------- source/blender/blenkernel/intern/packedFile.c | 4 +- source/blender/blenkernel/intern/sequencer.c | 70 +++++++++++++-------------- 9 files changed, 123 insertions(+), 120 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 0cb42fb46de..5d2c85e5825 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3319,76 +3319,76 @@ void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) } } -int BKE_nurb_check_valid_u(struct Nurb *nu) +bool BKE_nurb_check_valid_u(struct Nurb *nu) { if (nu == NULL) - return 0; + return false; if (nu->pntsu <= 1) - return 0; + return false; if (nu->type != CU_NURBS) - return 1; /* not a nurb, lets assume its valid */ + return true; /* not a nurb, lets assume its valid */ - if (nu->pntsu < nu->orderu) return 0; + if (nu->pntsu < nu->orderu) return false; if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */ if (nu->orderu == 4) { if (nu->pntsu < 5) - return 0; /* bezier with 4 orderu needs 5 points */ + return false; /* bezier with 4 orderu needs 5 points */ } else { if (nu->orderu != 3) - return 0; /* order must be 3 or 4 */ + return false; /* order must be 3 or 4 */ } } - return 1; + return true; } -int BKE_nurb_check_valid_v(struct Nurb *nu) +bool BKE_nurb_check_valid_v(struct Nurb *nu) { if (nu == NULL) - return 0; + return false; if (nu->pntsv <= 1) - return 0; + return false; if (nu->type != CU_NURBS) - return 1; /* not a nurb, lets assume its valid */ + return true; /* not a nurb, lets assume its valid */ if (nu->pntsv < nu->orderv) - return 0; + return false; if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */ if (nu->orderv == 4) { if (nu->pntsv < 5) - return 0; /* bezier with 4 orderu needs 5 points */ + return false; /* bezier with 4 orderu needs 5 points */ } else { if (nu->orderv != 3) - return 0; /* order must be 3 or 4 */ + return false; /* order must be 3 or 4 */ } } - return 1; + return true; } -int BKE_nurb_order_clamp_u(struct Nurb *nu) +bool BKE_nurb_order_clamp_u(struct Nurb *nu) { - int change = 0; + bool change = false; if (nu->pntsu < nu->orderu) { nu->orderu = nu->pntsu; - change = 1; + change = true; } if (((nu->flagu & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) { CLAMP(nu->orderu, 3, 4); - change = 1; + change = true; } return change; } -int BKE_nurb_order_clamp_v(struct Nurb *nu) +bool BKE_nurb_order_clamp_v(struct Nurb *nu) { - int change = 0; + bool change = false; if (nu->pntsv < nu->orderv) { nu->orderv = nu->pntsv; - change = 1; + change = true; } if (((nu->flagv & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) { CLAMP(nu->orderv, 3, 4); - change = 1; + change = true; } return change; } @@ -3405,7 +3405,7 @@ ListBase *BKE_curve_nurbs_get(Curve *cu) /* basic vertex data functions */ -int BKE_curve_minmax(Curve *cu, float min[3], float max[3]) +bool BKE_curve_minmax(Curve *cu, float min[3], float max[3]) { ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; @@ -3416,7 +3416,7 @@ int BKE_curve_minmax(Curve *cu, float min[3], float max[3]) return (nurb_lb->first != NULL); } -int BKE_curve_center_median(Curve *cu, float cent[3]) +bool BKE_curve_center_median(Curve *cu, float cent[3]) { ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; @@ -3454,16 +3454,16 @@ int BKE_curve_center_median(Curve *cu, float cent[3]) return (total != 0); } -int BKE_curve_center_bounds(Curve *cu, float cent[3]) +bool BKE_curve_center_bounds(Curve *cu, float cent[3]) { float min[3], max[3]; INIT_MINMAX(min, max); if (BKE_curve_minmax(cu, min, max)) { mid_v3_v3v3(cent, min, max); - return 1; + return true; } - return 0; + return false; } void BKE_curve_translate(Curve *cu, float offset[3], int do_keys) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 3578033f566..3682de8567d 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -101,7 +101,7 @@ void BKE_vfont_free(struct VFont *vf) static void *builtin_font_data = NULL; static int builtin_font_size = 0; -int BKE_vfont_is_builtin(struct VFont *vfont) +bool BKE_vfont_is_builtin(struct VFont *vfont) { return (strcmp(vfont->name, FO_BUILTIN_NAME) == 0); } diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index c3008d17bd1..7aec97e1582 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -30,12 +30,13 @@ * \ingroup bke */ - #include #include #include "DNA_ID.h" +#include "BLI_utildefines.h" + #include "BKE_idcode.h" typedef struct { @@ -105,15 +106,15 @@ static IDType *idtype_from_code(int code) return NULL; } -int BKE_idcode_is_valid(int code) +bool BKE_idcode_is_valid(int code) { - return idtype_from_code(code) ? 1 : 0; + return idtype_from_code(code) ? true : false; } -int BKE_idcode_is_linkable(int code) +bool BKE_idcode_is_linkable(int code) { IDType *idt = idtype_from_code(code); - return idt ? (idt->flags & IDTYPE_FLAGS_ISLINKABLE) : 0; + return idt ? ((idt->flags & IDTYPE_FLAGS_ISLINKABLE) != 0) : false; } const char *BKE_idcode_to_name(int code) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 689d1959b16..cad9e8cfbc6 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1042,7 +1042,7 @@ char BKE_ftype_to_imtype(const int ftype) } -int BKE_imtype_is_movie(const char imtype) +bool BKE_imtype_is_movie(const char imtype) { switch (imtype) { case R_IMF_IMTYPE_AVIRAW: @@ -1053,9 +1053,9 @@ int BKE_imtype_is_movie(const char imtype) case R_IMF_IMTYPE_THEORA: case R_IMF_IMTYPE_XVID: case R_IMF_IMTYPE_FRAMESERVER: - return 1; + return true; } - return 0; + return false; } int BKE_imtype_supports_zbuf(const char imtype) diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 468a88775c6..415f0a87431 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -24,13 +24,14 @@ * \ingroup bke */ - #include #include -#include "BKE_image.h" #include "BLI_math_color.h" #include "BLI_math_base.h" + +#include "BKE_image.h" + #include "BLF_api.h" void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, const float color[4]) diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 5c97b29885f..925040940f8 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -439,18 +439,15 @@ float *BKE_mball_make_orco(Object *ob, ListBase *dispbase) * It test last character of Object ID name. If last character * is digit it return 0, else it return 1. */ -int BKE_mball_is_basis(Object *ob) +bool BKE_mball_is_basis(Object *ob) { - int len; - /* just a quick test */ - len = strlen(ob->id.name); - if (isdigit(ob->id.name[len - 1]) ) return 0; - return 1; + const int len = strlen(ob->id.name); + return (!isdigit(ob->id.name[len - 1])); } /* return nonzero if ob1 is a basis mball for ob */ -int BKE_mball_is_basis_for(Object *ob1, Object *ob2) +bool BKE_mball_is_basis_for(Object *ob1, Object *ob2) { int basis1nr, basis2nr; char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME]; @@ -458,8 +455,12 @@ int BKE_mball_is_basis_for(Object *ob1, Object *ob2) BLI_split_name_num(basis1name, &basis1nr, ob1->id.name + 2, '.'); BLI_split_name_num(basis2name, &basis2nr, ob2->id.name + 2, '.'); - if (!strcmp(basis1name, basis2name)) return BKE_mball_is_basis(ob1); - else return 0; + if (!strcmp(basis1name, basis2name)) { + return BKE_mball_is_basis(ob1); + } + else { + return false; + } } /* \brief copy some properties from object to other metaball object with same base name diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0ace60b1fd4..0205fe91a60 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -185,7 +185,7 @@ void BKE_object_free_modifiers(Object *ob) BKE_object_free_softbody(ob); } -int BKE_object_support_modifier_type_check(Object *ob, int modifier_type) +bool BKE_object_support_modifier_type_check(Object *ob, int modifier_type) { ModifierTypeInfo *mti; @@ -194,10 +194,10 @@ int BKE_object_support_modifier_type_check(Object *ob, int modifier_type) if (!((mti->flags & eModifierTypeFlag_AcceptsCVs) || (ob->type == OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) { - return FALSE; + return false; } - return TRUE; + return true; } void BKE_object_link_modifiers(struct Object *ob_dst, struct Object *ob_src) @@ -773,61 +773,61 @@ void BKE_object_unlink(Object *ob) } /* actual check for internal data, not context or flags */ -int BKE_object_is_in_editmode(Object *ob) +bool BKE_object_is_in_editmode(Object *ob) { if (ob->data == NULL) - return 0; + return false; if (ob->type == OB_MESH) { Mesh *me = ob->data; if (me->edit_btmesh) - return 1; + return true; } else if (ob->type == OB_ARMATURE) { bArmature *arm = ob->data; if (arm->edbo) - return 1; + return true; } else if (ob->type == OB_FONT) { Curve *cu = ob->data; if (cu->editfont) - return 1; + return true; } else if (ob->type == OB_MBALL) { MetaBall *mb = ob->data; if (mb->editelems) - return 1; + return true; } else if (ob->type == OB_LATTICE) { Lattice *lt = ob->data; if (lt->editlatt) - return 1; + return true; } else if (ob->type == OB_SURF || ob->type == OB_CURVE) { Curve *cu = ob->data; if (cu->editnurb) - return 1; + return true; } - return 0; + return false; } -int BKE_object_exists_check(Object *obtest) +bool BKE_object_exists_check(Object *obtest) { Object *ob; - if (obtest == NULL) return 0; + if (obtest == NULL) return false; ob = G.main->object.first; while (ob) { - if (ob == obtest) return 1; + if (ob == obtest) return true; ob = ob->id.next; } - return 0; + return false; } /* *************************************************** */ @@ -1394,24 +1394,24 @@ void BKE_object_make_local(Object *ob) /* * Returns true if the Object is a from an external blend file (libdata) */ -int BKE_object_is_libdata(Object *ob) +bool BKE_object_is_libdata(Object *ob) { - if (!ob) return 0; - if (ob->proxy) return 0; - if (ob->id.lib) return 1; - return 0; + if (!ob) return false; + if (ob->proxy) return false; + if (ob->id.lib) return true; + return false; } /* Returns true if the Object data is a from an external blend file (libdata) */ -int BKE_object_obdata_is_libdata(Object *ob) +bool BKE_object_obdata_is_libdata(Object *ob) { - if (!ob) return 0; - if (ob->proxy && (ob->data == NULL || ((ID *)ob->data)->lib == NULL)) return 0; - if (ob->id.lib) return 1; - if (ob->data == NULL) return 0; - if (((ID *)ob->data)->lib) return 1; + if (!ob) return false; + if (ob->proxy && (ob->data == NULL || ((ID *)ob->data)->lib == NULL)) return false; + if (ob->id.lib) return true; + if (ob->data == NULL) return false; + if (((ID *)ob->data)->lib) return true; - return 0; + return false; } /* *************** PROXY **************** */ @@ -2623,11 +2623,11 @@ void BKE_object_tfm_restore(Object *ob, void *obtfm_pt) copy_m4_m4(ob->imat, obtfm->imat); } -int BKE_object_parent_loop_check(const Object *par, const Object *ob) +bool BKE_object_parent_loop_check(const Object *par, const Object *ob) { /* test if 'ob' is a parent somewhere in par's parents */ - if (par == NULL) return 0; - if (ob == par) return 1; + if (par == NULL) return false; + if (ob == par) return true; return BKE_object_parent_loop_check(par->parent, ob); } @@ -3192,7 +3192,7 @@ int BKE_object_is_deform_modified(Scene *scene, Object *ob) } /* See if an object is using an animated modifier */ -int BKE_object_is_animated(Scene *scene, Object *ob) +bool BKE_object_is_animated(Scene *scene, Object *ob) { ModifierData *md; @@ -3201,9 +3201,9 @@ int BKE_object_is_animated(Scene *scene, Object *ob) (modifier_isEnabled(scene, md, eModifierMode_Realtime) || modifier_isEnabled(scene, md, eModifierMode_Render))) { - return 1; + return true; } - return 0; + return false; } static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin) diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index ec13e58d4e0..5a02d929b76 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -617,7 +617,7 @@ void unpackAll(Main *bmain, ReportList *reports, int how) } /* ID should be not NULL, return 1 if there's a packed file */ -int BKE_pack_check(ID *id) +bool BKE_pack_check(ID *id) { if (GS(id->name) == ID_IM) { Image *ima = (Image *)id; @@ -635,7 +635,7 @@ int BKE_pack_check(ID *id) Library *li = (Library *)id; return li->packedfile != NULL; } - return 0; + return false; } /* ID should be not NULL */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index a4949e3b338..74d43b61429 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3062,30 +3062,30 @@ static void free_anim_seq(Sequence *seq) } /* check whether sequence cur depends on seq */ -int BKE_sequence_check_depend(Sequence *seq, Sequence *cur) +bool BKE_sequence_check_depend(Sequence *seq, Sequence *cur) { if (cur->seq1 == seq || cur->seq2 == seq || cur->seq3 == seq) - return TRUE; + return true; /* sequences are not intersecting in time, assume no dependency exists between them */ if (cur->enddisp < seq->startdisp || cur->startdisp > seq->enddisp) - return FALSE; + return false; /* checking sequence is below reference one, not dependent on it */ if (cur->machine < seq->machine) - return FALSE; + return false; /* sequence is not blending with lower machines, no dependency here occurs * check for non-effects only since effect could use lower machines as input */ if ((cur->type & SEQ_TYPE_EFFECT) == 0 && - ((cur->blend_mode == SEQ_BLEND_REPLACE) || - (cur->blend_mode == SEQ_TYPE_CROSS && cur->blend_opacity == 100.0f))) + ((cur->blend_mode == SEQ_BLEND_REPLACE) || + (cur->blend_mode == SEQ_TYPE_CROSS && cur->blend_opacity == 100.0f))) { - return FALSE; + return false; } - return TRUE; + return true; } static void sequence_do_invalidate_dependent(Sequence *seq, ListBase *seqbase) @@ -3291,7 +3291,7 @@ void BKE_sequence_tx_set_final_right(Sequence *seq, int val) /* used so we can do a quick check for single image seq * since they work a bit differently to normal image seq's (during transform) */ -int BKE_sequence_single_check(Sequence *seq) +bool BKE_sequence_single_check(Sequence *seq) { return ((seq->len == 1) && (seq->type == SEQ_TYPE_IMAGE || @@ -3300,21 +3300,21 @@ int BKE_sequence_single_check(Sequence *seq) } /* check if the selected seq's reference unselected seq's */ -int BKE_sequence_base_isolated_sel_check(ListBase *seqbase) +bool BKE_sequence_base_isolated_sel_check(ListBase *seqbase) { Sequence *seq; /* is there more than 1 select */ - int ok = FALSE; + bool ok = false; for (seq = seqbase->first; seq; seq = seq->next) { if (seq->flag & SELECT) { - ok = TRUE; + ok = true; break; } } - if (ok == FALSE) - return FALSE; + if (ok == false) + return false; /* test relationships */ for (seq = seqbase->first; seq; seq = seq->next) { @@ -3322,24 +3322,24 @@ int BKE_sequence_base_isolated_sel_check(ListBase *seqbase) continue; if (seq->flag & SELECT) { - if ( (seq->seq1 && (seq->seq1->flag & SELECT) == 0) || - (seq->seq2 && (seq->seq2->flag & SELECT) == 0) || - (seq->seq3 && (seq->seq3->flag & SELECT) == 0) ) + if ((seq->seq1 && (seq->seq1->flag & SELECT) == 0) || + (seq->seq2 && (seq->seq2->flag & SELECT) == 0) || + (seq->seq3 && (seq->seq3->flag & SELECT) == 0) ) { - return FALSE; + return false; } } else { - if ( (seq->seq1 && (seq->seq1->flag & SELECT)) || - (seq->seq2 && (seq->seq2->flag & SELECT)) || - (seq->seq3 && (seq->seq3->flag & SELECT)) ) + if ((seq->seq1 && (seq->seq1->flag & SELECT)) || + (seq->seq2 && (seq->seq2->flag & SELECT)) || + (seq->seq3 && (seq->seq3->flag & SELECT)) ) { - return FALSE; + return false; } } } - return TRUE; + return true; } /* use to impose limits when dragging/extending - so impossible situations don't happen @@ -3405,29 +3405,29 @@ void BKE_sequence_single_fix(Sequence *seq) } } -int BKE_sequence_tx_test(Sequence *seq) +bool BKE_sequence_tx_test(Sequence *seq) { return (seq->type < SEQ_TYPE_EFFECT) || (BKE_sequence_effect_get_num_inputs(seq->type) == 0); } -static int seq_overlap(Sequence *seq1, Sequence *seq2) +static bool seq_overlap(Sequence *seq1, Sequence *seq2) { return (seq1 != seq2 && seq1->machine == seq2->machine && ((seq1->enddisp <= seq2->startdisp) || (seq1->startdisp >= seq2->enddisp)) == 0); } -int BKE_sequence_test_overlap(ListBase *seqbasep, Sequence *test) +bool BKE_sequence_test_overlap(ListBase *seqbasep, Sequence *test) { Sequence *seq; seq = seqbasep->first; while (seq) { if (seq_overlap(test, seq)) - return 1; + return true; seq = seq->next; } - return 0; + return false; } @@ -3487,7 +3487,7 @@ Sequence *BKE_sequencer_foreground_frame_get(Scene *scene, int frame) } /* return 0 if there werent enough space */ -int BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_scene) +bool BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_scene) { int orig_machine = test->machine; test->machine++; @@ -3518,10 +3518,10 @@ int BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_sc BKE_sequence_translate(evil_scene, test, new_frame - test->start); BKE_sequence_calc(evil_scene, test); - return 0; + return false; } else { - return 1; + return true; } } @@ -3572,7 +3572,7 @@ static int shuffle_seq_time_offset(Scene *scene, ListBase *seqbasep, char dir) return tot_ofs; } -int BKE_sequence_base_shuffle_time(ListBase *seqbasep, Scene *evil_scene) +bool BKE_sequence_base_shuffle_time(ListBase *seqbasep, Scene *evil_scene) { /* note: seq->tmp is used to tag strips to move */ @@ -3591,7 +3591,7 @@ int BKE_sequence_base_shuffle_time(ListBase *seqbasep, Scene *evil_scene) } } - return offset ? 0 : 1; + return offset ? false : true; } void BKE_sequencer_update_sound_bounds_all(Scene *scene) @@ -4324,7 +4324,7 @@ void BKE_sequence_base_dupli_recursive(Scene *scene, Scene *scene_to, ListBase * /* called on draw, needs to be fast, * we could cache and use a flag if we want to make checks for file paths resolving for eg. */ -int BKE_sequence_is_valid_check(Sequence *seq) +bool BKE_sequence_is_valid_check(Sequence *seq) { switch (seq->type) { case SEQ_TYPE_MASK: @@ -4337,6 +4337,6 @@ int BKE_sequence_is_valid_check(Sequence *seq) return (seq->sound != NULL); } - return TRUE; + return true; } -- cgit v1.2.3 From 74857241607cd828acbb7b8b4e2f425beea802c8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Mar 2013 05:19:29 +0000 Subject: style cleanup: whitespace --- source/blender/blenkernel/intern/pbvh_bmesh.c | 84 +++++++++++++-------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 9befd68a1d6..9290a8a7163 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -83,8 +83,8 @@ static void pbvh_bmesh_node_finalize(PBVH *bvh, int node_index) } BLI_assert(n->vb.bmin[0] <= n->vb.bmax[0] && - n->vb.bmin[1] <= n->vb.bmax[1] && - n->vb.bmin[2] <= n->vb.bmax[2]); + n->vb.bmin[1] <= n->vb.bmax[1] && + n->vb.bmin[2] <= n->vb.bmax[2]); n->orig_vb = n->vb; @@ -275,8 +275,8 @@ static PBVHNode *pbvh_bmesh_node_lookup(PBVH *bvh, GHash *map, void *key) } static BMVert *pbvh_bmesh_vert_create(PBVH *bvh, int node_index, - const float co[3], - const BMVert *example) + const float co[3], + const BMVert *example) { BMVert *v = BM_vert_create(bvh->bm, co, example, 0); void *val = SET_INT_IN_POINTER(node_index); @@ -355,7 +355,7 @@ static PBVHNode *pbvh_bmesh_vert_other_node_find(PBVH *bvh, BMVert *v) } static void pbvh_bmesh_vert_ownership_transfer(PBVH *bvh, PBVHNode *new_owner, - BMVert *v) + BMVert *v) { PBVHNode *current_owner; @@ -368,7 +368,7 @@ static void pbvh_bmesh_vert_ownership_transfer(PBVH *bvh, PBVHNode *new_owner, /* Set new ownership */ BLI_ghash_insert(bvh->bm_vert_to_node, v, - SET_INT_IN_POINTER(new_owner - bvh->nodes)); + SET_INT_IN_POINTER(new_owner - bvh->nodes)); BLI_ghash_insert(new_owner->bm_unique_verts, v, NULL); BLI_ghash_remove(new_owner->bm_other_verts, v, NULL, NULL); BLI_assert(!BLI_ghash_haskey(new_owner->bm_other_verts, v)); @@ -491,7 +491,7 @@ static int edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f) } static void edge_queue_insert(EdgeQueue *q, BLI_mempool *pool, BMEdge *e, - float priority) + float priority) { BMVert **pair; @@ -502,7 +502,7 @@ static void edge_queue_insert(EdgeQueue *q, BLI_mempool *pool, BMEdge *e, } static void long_edge_queue_edge_add(EdgeQueue *q, BLI_mempool *pool, - BMEdge *e) + BMEdge *e) { const float len_sq = BM_edge_calc_length_squared(e); if (len_sq > q->limit_len_squared) @@ -510,7 +510,7 @@ static void long_edge_queue_edge_add(EdgeQueue *q, BLI_mempool *pool, } static void short_edge_queue_edge_add(EdgeQueue *q, BLI_mempool *pool, - BMEdge *e) + BMEdge *e) { const float len_sq = BM_edge_calc_length_squared(e); if (len_sq < q->limit_len_squared) @@ -557,8 +557,8 @@ static void short_edge_queue_face_add(EdgeQueue *q, BLI_mempool *pool, * The highest priority (lowest number) is given to the longest edge. */ static void long_edge_queue_create(EdgeQueue *q, BLI_mempool *pool, - PBVH *bvh, const float center[3], - float radius) + PBVH *bvh, const float center[3], + float radius) { int n; @@ -596,8 +596,8 @@ static void long_edge_queue_create(EdgeQueue *q, BLI_mempool *pool, * The highest priority (lowest number) is given to the shortest edge. */ static void short_edge_queue_create(EdgeQueue *q, BLI_mempool *pool, - PBVH *bvh, const float center[3], - float radius) + PBVH *bvh, const float center[3], + float radius) { int n; @@ -930,8 +930,8 @@ static int pbvh_bmesh_collapse_short_edges(PBVH *bvh, EdgeQueue *q, /************************* Called from pbvh.c *************************/ int pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3], - const float ray_normal[3], float *dist, - int use_original) + const float ray_normal[3], float *dist, + int use_original) { GHashIterator gh_iter; int hit = 0; @@ -941,10 +941,10 @@ int pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3], for (i = 0; i < node->bm_tot_ortri; i++) { const int *t = node->bm_ortri[i]; hit |= ray_face_intersection(ray_start, ray_normal, - node->bm_orco[t[0]], - node->bm_orco[t[1]], - node->bm_orco[t[2]], - NULL, dist); + node->bm_orco[t[0]], + node->bm_orco[t[1]], + node->bm_orco[t[2]], + NULL, dist); } } else { @@ -989,7 +989,7 @@ void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode) /* Build a PBVH from a BMesh */ void BKE_pbvh_build_bmesh(PBVH *bvh, BMesh *bm, int smooth_shading, - BMLog *log) + BMLog *log) { BMIter iter; BMFace *f; @@ -1099,7 +1099,7 @@ void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node) return; totvert = (BLI_ghash_size(node->bm_unique_verts) + - BLI_ghash_size(node->bm_other_verts)); + BLI_ghash_size(node->bm_other_verts)); tottri = BLI_ghash_size(node->bm_faces); @@ -1215,31 +1215,31 @@ void bmesh_print(BMesh *bm) BMLoop *l; fprintf(stderr, "\nbm=%p, totvert=%d, totedge=%d, " - "totloop=%d, totface=%d\n", - bm, bm->totvert, bm->totedge, - bm->totloop, bm->totface); + "totloop=%d, totface=%d\n", + bm, bm->totvert, bm->totedge, + bm->totloop, bm->totface); fprintf(stderr, "vertices:\n"); BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) { fprintf(stderr, " %d co=(%.3f %.3f %.3f) oflag=%x\n", - BM_elem_index_get(v), v->co[0], v->co[1], v->co[2], - v->oflags[bm->stackdepth - 1].f); + BM_elem_index_get(v), v->co[0], v->co[1], v->co[2], + v->oflags[bm->stackdepth - 1].f); } fprintf(stderr, "edges:\n"); BM_ITER_MESH(e, &iter, bm, BM_EDGES_OF_MESH) { fprintf(stderr, " %d v1=%d, v2=%d, oflag=%x\n", - BM_elem_index_get(e), - BM_elem_index_get(e->v1), - BM_elem_index_get(e->v2), - e->oflags[bm->stackdepth - 1].f); + BM_elem_index_get(e), + BM_elem_index_get(e->v1), + BM_elem_index_get(e->v2), + e->oflags[bm->stackdepth - 1].f); } fprintf(stderr, "faces:\n"); BM_ITER_MESH(f, &iter, bm, BM_FACES_OF_MESH) { fprintf(stderr, " %d len=%d, oflag=%x\n", - BM_elem_index_get(f), f->len, - f->oflags[bm->stackdepth - 1].f); + BM_elem_index_get(f), f->len, + f->oflags[bm->stackdepth - 1].f); fprintf(stderr, " v: "); BM_ITER_ELEM(v, &siter, f, BM_VERTS_OF_FACE) { @@ -1256,9 +1256,9 @@ void bmesh_print(BMesh *bm) fprintf(stderr, " l: "); BM_ITER_ELEM(l, &siter, f, BM_LOOPS_OF_FACE) { fprintf(stderr, "%d(v=%d, e=%d) ", - BM_elem_index_get(l), - BM_elem_index_get(l->v), - BM_elem_index_get(l->e)); + BM_elem_index_get(l), + BM_elem_index_get(l->v), + BM_elem_index_get(l->e)); } fprintf(stderr, "\n"); } @@ -1273,15 +1273,15 @@ void pbvh_bmesh_print(PBVH *bvh) fprintf(stderr, "bm_face_to_node:\n"); GHASH_ITER (gh_iter, bvh->bm_face_to_node) { fprintf(stderr, " %d -> %d\n", - BM_elem_index_get((BMFace*)BLI_ghashIterator_getKey(&gh_iter)), - GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(&gh_iter))); + BM_elem_index_get((BMFace*)BLI_ghashIterator_getKey(&gh_iter)), + GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(&gh_iter))); } fprintf(stderr, "bm_vert_to_node:\n"); GHASH_ITER (gh_iter, bvh->bm_vert_to_node) { fprintf(stderr, " %d -> %d\n", - BM_elem_index_get((BMVert*)BLI_ghashIterator_getKey(&gh_iter)), - GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(&gh_iter))); + BM_elem_index_get((BMVert*)BLI_ghashIterator_getKey(&gh_iter)), + GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(&gh_iter))); } for (n = 0; n < bvh->totnode; n++) { @@ -1292,15 +1292,15 @@ void pbvh_bmesh_print(PBVH *bvh) fprintf(stderr, "node %d\n faces:\n", n); GHASH_ITER (gh_iter, node->bm_faces) fprintf(stderr, " %d\n", - BM_elem_index_get((BMFace*)BLI_ghashIterator_getKey(&gh_iter))); + BM_elem_index_get((BMFace*)BLI_ghashIterator_getKey(&gh_iter))); fprintf(stderr, " unique verts:\n"); GHASH_ITER (gh_iter, node->bm_unique_verts) fprintf(stderr, " %d\n", - BM_elem_index_get((BMVert*)BLI_ghashIterator_getKey(&gh_iter))); + BM_elem_index_get((BMVert*)BLI_ghashIterator_getKey(&gh_iter))); fprintf(stderr, " other verts:\n"); GHASH_ITER (gh_iter, node->bm_other_verts) fprintf(stderr, " %d\n", - BM_elem_index_get((BMVert*)BLI_ghashIterator_getKey(&gh_iter))); + BM_elem_index_get((BMVert*)BLI_ghashIterator_getKey(&gh_iter))); } } -- cgit v1.2.3 From 7d585ed47527d4f8ea3f2d0362f23564f812aa25 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Mar 2013 05:46:24 +0000 Subject: patch [#34103] check_for_dupid.patch from Lawrence D'Oliveiro (ldo) - more comments - more uses of bool type - define symbol for length of in_use array in check_for_dupid --- source/blender/blenkernel/intern/anim_sys.c | 4 +- source/blender/blenkernel/intern/blender.c | 2 +- source/blender/blenkernel/intern/library.c | 258 ++++++++++++++++------------ source/blender/blenkernel/intern/node.c | 2 +- 4 files changed, 154 insertions(+), 112 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 74e44eab281..d9089a58f03 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -242,7 +242,7 @@ void BKE_free_animdata(ID *id) /* Freeing -------------------------------------------- */ /* Make a copy of the given AnimData - to be used when copying datablocks */ -AnimData *BKE_copy_animdata(AnimData *adt, const short do_action) +AnimData *BKE_copy_animdata(AnimData *adt, const bool do_action) { AnimData *dadt; @@ -274,7 +274,7 @@ AnimData *BKE_copy_animdata(AnimData *adt, const short do_action) return dadt; } -int BKE_copy_animdata_id(ID *id_to, ID *id_from, const short do_action) +int BKE_copy_animdata_id(ID *id_to, ID *id_from, const bool do_action) { AnimData *adt; diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 9a21a9648c9..82b3b4f5618 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -995,7 +995,7 @@ int BKE_copybuffer_paste(bContext *C, char *libname, ReportList *reports) /* append, rather than linking */ lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath)); - BKE_library_make_local(bmain, lib, 1); + BKE_library_make_local(bmain, lib, true); /* important we unset, otherwise these object wont * link into other scenes from this blend file */ diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 0c5e2b89cf7..c95576ec8e7 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -171,6 +171,7 @@ void id_us_plus(ID *id) } } +/* decrements the user count for *id. */ void id_us_min(ID *id) { if (id) { @@ -186,102 +187,108 @@ void id_us_min(ID *id) } } -int id_make_local(ID *id, int test) +/* calls the appropriate make_local method for the block, unless test. Returns true + * if the block can be made local. */ +bool id_make_local(ID *id, bool test) { if (id->flag & LIB_INDIRECT) - return 0; + return false; switch (GS(id->name)) { case ID_SCE: - return 0; /* not implemented */ + return false; /* not implemented */ case ID_LI: - return 0; /* can't be linked */ + return false; /* can't be linked */ case ID_OB: if (!test) BKE_object_make_local((Object *)id); - return 1; + return true; case ID_ME: if (!test) { BKE_mesh_make_local((Mesh *)id); BKE_key_make_local(((Mesh *)id)->key); } - return 1; + return true; case ID_CU: if (!test) { BKE_curve_make_local((Curve *)id); BKE_key_make_local(((Curve *)id)->key); } - return 1; + return true; case ID_MB: if (!test) BKE_mball_make_local((MetaBall *)id); - return 1; + return true; case ID_MA: if (!test) BKE_material_make_local((Material *)id); - return 1; + return true; case ID_TE: if (!test) BKE_texture_make_local((Tex *)id); - return 1; + return true; case ID_IM: if (!test) BKE_image_make_local((Image *)id); - return 1; + return true; case ID_LT: if (!test) { BKE_lattice_make_local((Lattice *)id); BKE_key_make_local(((Lattice *)id)->key); } - return 1; + return true; case ID_LA: if (!test) BKE_lamp_make_local((Lamp *)id); - return 1; + return true; case ID_CA: if (!test) BKE_camera_make_local((Camera *)id); - return 1; + return true; case ID_SPK: if (!test) BKE_speaker_make_local((Speaker *)id); - return 1; + return true; case ID_IP: - return 0; /* deprecated */ + return false; /* deprecated */ case ID_KE: if (!test) BKE_key_make_local((Key *)id); - return 1; + return true; case ID_WO: if (!test) BKE_world_make_local((World *)id); - return 1; + return true; case ID_SCR: - return 0; /* can't be linked */ + return false; /* can't be linked */ case ID_VF: - return 0; /* not implemented */ + return false; /* not implemented */ case ID_TXT: - return 0; /* not implemented */ + return false; /* not implemented */ case ID_SCRIPT: - return 0; /* deprecated */ + return false; /* deprecated */ case ID_SO: - return 0; /* not implemented */ + return false; /* not implemented */ case ID_GR: - return 0; /* not implemented */ + return false; /* not implemented */ case ID_AR: if (!test) BKE_armature_make_local((bArmature *)id); - return 1; + return true; case ID_AC: if (!test) BKE_action_make_local((bAction *)id); - return 1; + return true; case ID_NT: - return 0; /* not implemented */ + return false; /* not implemented */ case ID_BR: if (!test) BKE_brush_make_local((Brush *)id); - return 1; + return true; case ID_PA: if (!test) BKE_particlesettings_make_local((ParticleSettings *)id); - return 1; + return true; case ID_WM: - return 0; /* can't be linked */ + return false; /* can't be linked */ case ID_GD: - return 0; /* not implemented */ + return false; /* not implemented */ } - return 0; + return false; } -int id_copy(ID *id, ID **newid, int test) +/** + * Invokes the appropriate copy method for the block and returns the result in + * newid, unless test. Returns true iff the block can be copied. + */ +bool id_copy(ID *id, ID **newid, bool test) { if (!test) *newid = NULL; @@ -290,124 +297,124 @@ int id_copy(ID *id, ID **newid, int test) * - id.us of the new ID is set to 1 */ switch (GS(id->name)) { case ID_SCE: - return 0; /* can't be copied from here */ + return false; /* can't be copied from here */ case ID_LI: - return 0; /* can't be copied from here */ + return false; /* can't be copied from here */ case ID_OB: if (!test) *newid = (ID *)BKE_object_copy((Object *)id); - return 1; + return true; case ID_ME: if (!test) *newid = (ID *)BKE_mesh_copy((Mesh *)id); - return 1; + return true; case ID_CU: if (!test) *newid = (ID *)BKE_curve_copy((Curve *)id); - return 1; + return true; case ID_MB: if (!test) *newid = (ID *)BKE_mball_copy((MetaBall *)id); - return 1; + return true; case ID_MA: if (!test) *newid = (ID *)BKE_material_copy((Material *)id); - return 1; + return true; case ID_TE: if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id); - return 1; + return true; case ID_IM: if (!test) *newid = (ID *)BKE_image_copy(G.main, (Image *)id); - return 1; + return true; case ID_LT: if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id); - return 1; + return true; case ID_LA: if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id); - return 1; + return true; case ID_SPK: if (!test) *newid = (ID *)BKE_speaker_copy((Speaker *)id); - return 1; + return true; case ID_CA: if (!test) *newid = (ID *)BKE_camera_copy((Camera *)id); - return 1; + return true; case ID_IP: - return 0; /* deprecated */ + return false; /* deprecated */ case ID_KE: if (!test) *newid = (ID *)BKE_key_copy((Key *)id); - return 1; + return true; case ID_WO: if (!test) *newid = (ID *)BKE_world_copy((World *)id); - return 1; + return true; case ID_SCR: - return 0; /* can't be copied from here */ + return false; /* can't be copied from here */ case ID_VF: - return 0; /* not implemented */ + return false; /* not implemented */ case ID_TXT: if (!test) *newid = (ID *)BKE_text_copy((Text *)id); - return 1; + return true; case ID_SCRIPT: - return 0; /* deprecated */ + return false; /* deprecated */ case ID_SO: - return 0; /* not implemented */ + return false; /* not implemented */ case ID_GR: if (!test) *newid = (ID *)BKE_group_copy((Group *)id); - return 1; + return true; case ID_AR: if (!test) *newid = (ID *)BKE_armature_copy((bArmature *)id); - return 1; + return true; case ID_AC: if (!test) *newid = (ID *)BKE_action_copy((bAction *)id); - return 1; + return true; case ID_NT: if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id); - return 1; + return true; case ID_BR: if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id); - return 1; + return true; case ID_PA: if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings *)id); - return 1; + return true; case ID_WM: - return 0; /* can't be copied from here */ + return false; /* can't be copied from here */ case ID_GD: - return 0; /* not implemented */ + return false; /* not implemented */ case ID_MSK: if (!test) *newid = (ID *)BKE_mask_copy((Mask *)id); - return 1; + return true; } - return 0; + return false; } -int id_unlink(ID *id, int test) +bool id_unlink(ID *id, int test) { Main *mainlib = G.main; ListBase *lb; switch (GS(id->name)) { case ID_TXT: - if (test) return 1; + if (test) return true; BKE_text_unlink(mainlib, (Text *)id); break; case ID_GR: - if (test) return 1; + if (test) return true; BKE_group_unlink((Group *)id); break; case ID_OB: - if (test) return 1; + if (test) return true; BKE_object_unlink((Object *)id); break; } if (id->us == 0) { - if (test) return 1; + if (test) return true; lb = which_libbase(mainlib, GS(id->name)); BKE_libblock_free(lb, id); - return 1; + return true; } - return 0; + return false; } -int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop) +bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop) { ID *newid = NULL; PointerRNA idptr; @@ -415,7 +422,7 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop) if (id) { /* if property isn't editable, we're going to have an extra block hanging around until we save */ if (RNA_property_editable(ptr, prop)) { - if (id_copy(id, &newid, 0) && newid) { + if (id_copy(id, &newid, false) && newid) { /* copy animation actions too */ BKE_copy_animdata_id_action(id); /* us is 1 by convention, but RNA_property_pointer_set @@ -427,12 +434,12 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop) RNA_property_pointer_set(ptr, prop, idptr); RNA_property_update(C, ptr, prop); - return 1; + return true; } } } - return 0; + return false; } ListBase *which_libbase(Main *mainlib, short type) @@ -536,7 +543,13 @@ void recalc_all_library_objects(Main *main) ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } -/* note: MAX_LIBARRAY define should match this code */ +/** + * puts into array *lb pointers to all the ListBase structs in main, + * and returns the number of them as the function result. This is useful for + * generic traversal of all the blocks in a Main (by traversing all the + * lists in turn), without worrying about block types. + * + * \note MAX_LIBARRAY define should match this code */ int set_listbasepointers(Main *main, ListBase **lb) { int a = 0; @@ -600,6 +613,10 @@ int set_listbasepointers(Main *main, ListBase **lb) * * **************************** */ +/** + * Allocates and returns memory of the right size for the specified block type, + * initialized to zero. + */ static ID *alloc_libblock_notest(short type) { ID *id = NULL; @@ -702,7 +719,12 @@ static ID *alloc_libblock_notest(short type) return id; } -/* used everywhere in blenkernel and text.c */ +/** + * Allocates and returns a block of the specified type, with the specified name + * (adjusted as necessary to ensure uniqueness), and appended to the specified list. + * The user count is set to 1, all other content (apart from name and links) being + * initialized to zero. + */ void *BKE_libblock_alloc(ListBase *lb, short type, const char *name) { ID *id = NULL; @@ -714,25 +736,25 @@ void *BKE_libblock_alloc(ListBase *lb, short type, const char *name) id->icon_id = 0; *( (short *)id->name) = type; new_id(lb, id, name); - /* alphabetic insterion: is in new_id */ + /* alphabetic insertion: is in new_id */ } return id; } /* by spec, animdata is first item after ID */ /* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */ -static void id_copy_animdata(ID *id, const short do_action) +static void id_copy_animdata(ID *id, const bool do_action) { AnimData *adt = BKE_animdata_from_id(id); if (adt) { IdAdtTemplate *iat = (IdAdtTemplate *)id; - iat->adt = BKE_copy_animdata(iat->adt, do_action); /* could be set to FALSE, need to investigate */ + iat->adt = BKE_copy_animdata(iat->adt, do_action); /* could be set to false, need to investigate */ } } /* material nodes use this since they are not treated as libdata */ -void BKE_libblock_copy_data(ID *id, const ID *id_from, const short do_action) +void BKE_libblock_copy_data(ID *id, const ID *id_from, const bool do_action) { if (id_from->properties) id->properties = IDP_CopyProperty(id_from->properties); @@ -764,7 +786,7 @@ void *BKE_libblock_copy_ex(Main *bmain, ID *id) id->newid = idn; idn->flag |= LIB_NEW; - BKE_libblock_copy_data(idn, id, FALSE); + BKE_libblock_copy_data(idn, id, false); return idn; } @@ -1202,7 +1224,7 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name) /* * Check to see if an ID name is already used, and find a new one if so. - * Return 1 if created a new name (returned in name). + * Return true if created a new name (returned in name). * * Normally the ID that's being check is already in the ListBase, so ID *id * points at the new entry. The Python Library module needs to know what @@ -1210,11 +1232,13 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name) * id is NULL */ -static int check_for_dupid(ListBase *lb, ID *id, char *name) +static bool check_for_dupid(ListBase *lb, ID *id, char *name) { ID *idtest; int nr = 0, nrtest, a, left_len; - char in_use[64]; /* use as a boolean array, unrelated to name length */ +#define MAX_IN_USE 64 + bool in_use[MAX_IN_USE]; + /* to speed up finding unused numbers within [1 .. MAX_IN_USE - 1] (in_use[0] not used) */ char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8]; @@ -1222,23 +1246,23 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* if ( strlen(name) > MAX_ID_NAME-3 ) name[MAX_ID_NAME-3] = 0; */ /* removed since this is only ever called from one place - campbell */ - while (1) { + while (true) { /* phase 1: id already exists? */ idtest = is_dupid(lb, id, name); /* if there is no double, done */ - if (idtest == NULL) return 0; + if (idtest == NULL) return false; /* we have a dup; need to make a new name */ - /* quick check so we can reuse one of first 64 ids if vacant */ - memset(in_use, 0, sizeof(in_use)); + /* quick check so we can reuse one of first MAX_IN_USE - 1 ids if vacant */ + memset(in_use, false, sizeof(in_use)); /* get name portion, number portion ("name.number") */ left_len = BLI_split_name_num(left, &nr, name, '.'); /* if new name will be too long, truncate it */ - if (nr > 999 && left_len > (MAX_ID_NAME - 8)) { + if (nr > 999 && left_len > (MAX_ID_NAME - 8)) { /* assumption: won't go beyond 9999 */ left[MAX_ID_NAME - 8] = 0; left_len = MAX_ID_NAME - 8; } @@ -1255,21 +1279,24 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) (BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len) ) { - if (nrtest < sizeof(in_use)) - in_use[nrtest] = 1; /* mark as used */ + if (nrtest < MAX_IN_USE) + in_use[nrtest] = true; /* mark as used */ if (nr <= nrtest) nr = nrtest + 1; /* track largest unused */ } } /* decide which value of nr to use */ - for (a = 0; a < sizeof(in_use); a++) { - if (a >= nr) break; /* stop when we've check up to biggest */ - if (in_use[a] == 0) { /* found an unused value */ + for (a = 0; a < MAX_IN_USE; a++) { + if (a >= nr) break; /* stop when we've checked up to biggest */ /* redundant check */ + if (!in_use[a]) { /* found an unused value */ nr = a; break; } } + /* At this point, nr is either the lowest unused number within [0 .. MAX_IN_USE - 1], + or 1 greater than the largest used number if all those low ones are taken. + We can't be bothered to look for the lowest unused number beyond (MAX_IN_USE - 1). */ /* If the original name has no numeric suffix, * rather than just chopping and adding numbers, @@ -1283,7 +1310,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) name[len--] = '\0'; idtest = is_dupid(lb, id, name); } - if (idtest == NULL) return 1; + if (idtest == NULL) return true; /* otherwise just continue and use a number suffix */ } @@ -1297,24 +1324,26 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* this format specifier is from hell... */ BLI_snprintf(name, sizeof(id->name) - 2, "%s.%.3d", left, nr); - return 1; + return true; } + +#undef MAX_IN_USE } /* * Only for local blocks: external en indirect blocks already have a * unique ID. * - * return 1: created a new name + * return true: created a new name */ -int new_id(ListBase *lb, ID *id, const char *tname) +bool new_id(ListBase *lb, ID *id, const char *tname) { - int result; + bool result; char name[MAX_ID_NAME - 2]; /* if library, don't rename */ - if (id->lib) return 0; + if (id->lib) return false; /* if no libdata given, look up based on ID */ if (lb == NULL) lb = which_libbase(G.main, GS(id->name)); @@ -1386,10 +1415,9 @@ void clear_id_newpoins(void) } } -#define LIBTAG(a) if (a && a->id.lib) { a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0 - static void lib_indirect_test_id(ID *id, Library *lib) { +#define LIBTAG(a) if (a && a->id.lib) { a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0 if (id->lib) { /* datablocks that were indirectly related are now direct links @@ -1429,6 +1457,8 @@ static void lib_indirect_test_id(ID *id, Library *lib) me = ob->data; LIBTAG(me); } + +#undef LIBTAG } void tag_main_lb(ListBase *lb, const short tag) @@ -1466,7 +1496,7 @@ void tag_main(struct Main *mainvar, const short tag) /* if lib!=NULL, only all from lib local * bmain is almost certainly G.main */ -void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) +void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only) { ListBase *lbarray[MAX_LIBARRAY], tempbase = {NULL, NULL}; ID *id, *idn; @@ -1486,7 +1516,7 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) * (very nasty to discover all your links are lost after appending) * */ if (id->flag & (LIB_EXTERN | LIB_INDIRECT | LIB_NEW) && - (untagged_only == 0 || !(id->flag & LIB_PRE_EXISTING))) + ((untagged_only == false) || !(id->flag & LIB_PRE_EXISTING))) { if (lib == NULL || id->lib == lib) { if (id->lib) { @@ -1505,6 +1535,7 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) } /* patch2: make it aphabetically */ + /* FIXME: but nothing is ever put into tempbase! */ while ( (id = tempbase.first) ) { BLI_remlink(&tempbase, id); BLI_addtail(lbarray[a], id); @@ -1534,12 +1565,16 @@ void test_idbutton(char *name) /* search for id */ idtest = BLI_findstring(lb, name, offsetof(ID, name) + 2); - if (idtest && (new_id(lb, idtest, name) == 0)) { + if (idtest && !new_id(lb, idtest, name)) { id_sort_by_name(lb, idtest); } } -void text_idbutton(struct ID *id, char *text) +/** + * Puts into *text a descriptive block type prefix to be displayed before the block name. + */ +/* Not actually used anywhere any more. */ +void text_idbutton(const struct ID *id, char *text) { if (id) { if (GS(id->name) == ID_SCE) @@ -1561,6 +1596,9 @@ void text_idbutton(struct ID *id, char *text) } } +/** + * Sets the name of a block to name, suitably adjusted for uniqueness. + */ void rename_id(ID *id, const char *name) { ListBase *lb; @@ -1571,7 +1609,11 @@ void rename_id(ID *id, const char *name) new_id(lb, id, name); } -void name_uiprefix_id(char *name, ID *id) +/** + * Returns in name the name of the block, with a 3-character prefix prepended + * indicating whether it comes from a library, has a fake user, or no users. + */ +void name_uiprefix_id(char *name, const ID *id) { name[0] = id->lib ? 'L' : ' '; name[1] = id->flag & LIB_FAKEUSER ? 'F' : (id->us == 0) ? '0' : ' '; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 897e2ff2326..974a564b9da 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -716,7 +716,7 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_id_use } else { newtree = MEM_dupallocN(ntree); - BKE_libblock_copy_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */ + BKE_libblock_copy_data(&newtree->id, &ntree->id, true); /* copy animdata and ID props */ } id_us_plus((ID *)newtree->gpd); -- cgit v1.2.3 From f99be71850f6f40715f6b8f6fe9058fb66470dfa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Mar 2013 05:58:09 +0000 Subject: patch [#34103] check_for_dupid2.patch from Lawrence D'Oliveiro (ldo) check_for_dupid comments: - correct comment about in_use array - note name-truncation code will never be executed --- Added asserts to ensure comments are correct - ideasman42. --- source/blender/blenkernel/intern/library.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index c95576ec8e7..a251a62df97 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1200,7 +1200,7 @@ void id_sort_by_name(ListBase *lb, ID *id) } -/* +/** * Check to see if there is an ID with the same name as 'name'. * Returns the ID if so, if not, returns NULL */ @@ -1222,7 +1222,7 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name) return idtest; } -/* +/** * Check to see if an ID name is already used, and find a new one if so. * Return true if created a new name (returned in name). * @@ -1238,7 +1238,7 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name) int nr = 0, nrtest, a, left_len; #define MAX_IN_USE 64 bool in_use[MAX_IN_USE]; - /* to speed up finding unused numbers within [1 .. MAX_IN_USE - 1] (in_use[0] not used) */ + /* to speed up finding unused numbers within [1 .. MAX_IN_USE - 1] */ char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8]; @@ -1279,31 +1279,43 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name) (BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len) ) { + /* will get here at least once, otherwise is_dupid call above would have returned NULL */ if (nrtest < MAX_IN_USE) in_use[nrtest] = true; /* mark as used */ if (nr <= nrtest) nr = nrtest + 1; /* track largest unused */ } } + /* At this point, nr will be at least 1. */ + BLI_assert(nr >= 1); /* decide which value of nr to use */ for (a = 0; a < MAX_IN_USE; a++) { if (a >= nr) break; /* stop when we've checked up to biggest */ /* redundant check */ if (!in_use[a]) { /* found an unused value */ nr = a; + /* can only be zero if all potential duplicate names had + * nonzero numeric suffixes, which means name itself has + * nonzero numeric suffix (else no name conflict and wouldn't + * have got here), which means name[left_len] is not a null */ break; } } - /* At this point, nr is either the lowest unused number within [0 .. MAX_IN_USE - 1], - or 1 greater than the largest used number if all those low ones are taken. - We can't be bothered to look for the lowest unused number beyond (MAX_IN_USE - 1). */ + /* At this point, nr is either the lowest unused number within [0 .. MAX_IN_USE - 1], + * or 1 greater than the largest used number if all those low ones are taken. + * We can't be bothered to look for the lowest unused number beyond (MAX_IN_USE - 1). */ /* If the original name has no numeric suffix, * rather than just chopping and adding numbers, * shave off the end chars until we have a unique name. * Check the null terminators match as well so we don't get Cube.000 -> Cube.00 */ if (nr == 0 && name[left_len] == '\0') { - int len = left_len - 1; + int len; + /* FIXME: this code will never be executed, because either nr will be + * at least 1, or name will not end at left_len! */ + BLI_assert(0); + + len = left_len - 1; idtest = is_dupid(lb, id, name); while (idtest && len > 1) { -- cgit v1.2.3 From f9f707033665dc737f1011e82406a12fafa78326 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Mar 2013 06:18:03 +0000 Subject: add STREQ macro (commonly used macro like CLAMP, MAX2, STRINGIFY). Use for some areas of the python api, bmesh. --- source/blender/blenkernel/intern/font.c | 4 ++-- source/blender/blenkernel/intern/idcode.c | 6 ++++-- source/blender/blenkernel/intern/idprop.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 3682de8567d..b3edeb67928 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -103,7 +103,7 @@ static int builtin_font_size = 0; bool BKE_vfont_is_builtin(struct VFont *vfont) { - return (strcmp(vfont->name, FO_BUILTIN_NAME) == 0); + return STREQ(vfont->name, FO_BUILTIN_NAME); } void BKE_vfont_builtin_register(void *mem, int size) @@ -188,7 +188,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) PackedFile *temp_pf = NULL; int is_builtin; - if (strcmp(name, FO_BUILTIN_NAME) == 0) { + if (STREQ(name, FO_BUILTIN_NAME)) { BLI_strncpy(filename, name, sizeof(filename)); pf = get_builtin_packedfile(); diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 7aec97e1582..66f10e86a70 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -89,9 +89,11 @@ static IDType *idtype_from_name(const char *str) { int i = nidtypes; - while (i--) - if (strcmp(str, idtypes[i].name) == 0) + while (i--) { + if (STREQ(str, idtypes[i].name)) { return &idtypes[i]; + } + } return NULL; } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 19ef1e3971d..8dc284e0a3e 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -451,7 +451,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) IDProperty *loop, *prop; for (prop = src->data.group.first; prop; prop = prop->next) { for (loop = dest->data.group.first; loop; loop = loop->next) { - if (strcmp(loop->name, prop->name) == 0) { + if (STREQ(loop->name, prop->name)) { IDProperty *copy = IDP_CopyProperty(prop); BLI_insertlinkafter(&dest->data.group, loop, copy); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 74d43b61429..f2e81f0d6a4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -856,7 +856,7 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui) { Sequence *seq; for (seq = seqbasep->first; seq; seq = seq->next) { - if (sui->seq != seq && strcmp(sui->name_dest, seq->name + 2) == 0) { + if ((sui->seq != seq) && STREQ(sui->name_dest, seq->name + 2)) { /* SEQ_NAME_MAXSTR - 2 for prefix, -1 for \0, -4 for the number */ BLI_snprintf(sui->name_dest, sizeof(sui->name_dest), "%.59s.%03d", sui->name_src, sui->count++); sui->match = 1; /* be sure to re-scan */ @@ -3861,7 +3861,7 @@ Sequence *BKE_sequence_get_by_name(ListBase *seqbase, const char *name, int recu Sequence *rseq = NULL; for (iseq = seqbase->first; iseq; iseq = iseq->next) { - if (strcmp(name, iseq->name + 2) == 0) + if (STREQ(name, iseq->name + 2)) return iseq; else if (recursive && (iseq->seqbase.first) && (rseq = BKE_sequence_get_by_name(&iseq->seqbase, name, 1))) { return rseq; -- cgit v1.2.3 From 02ecd9f84279acab5d5fdc26c3db467164b6542d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Mar 2013 06:40:19 +0000 Subject: code cleanup: - remove unused block from before blender was opensourced (BKE_library_make_local) noticed by Lawrence D'Oliveiro (ldo) - remove text_idbutton() unused function. - test_idbutton(name) was taking (name + 2), then checking 2 bytes before the pointer, this is error prone so better just take the name including the ID prefix. --- source/blender/blenkernel/intern/library.c | 43 +++--------------------------- 1 file changed, 4 insertions(+), 39 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index a251a62df97..4038dd2d165 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1510,7 +1510,7 @@ void tag_main(struct Main *mainvar, const short tag) * bmain is almost certainly G.main */ void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only) { - ListBase *lbarray[MAX_LIBARRAY], tempbase = {NULL, NULL}; + ListBase *lbarray[MAX_LIBARRAY]; ID *id, *idn; int a; @@ -1545,17 +1545,8 @@ void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only) } id = idn; } - - /* patch2: make it aphabetically */ - /* FIXME: but nothing is ever put into tempbase! */ - while ( (id = tempbase.first) ) { - BLI_remlink(&tempbase, id); - BLI_addtail(lbarray[a], id); - new_id(lbarray[a], id, NULL); - } } - /* patch 3: make sure library data isn't indirect falsely... */ a = set_listbasepointers(bmain, lbarray); while (a--) { for (id = lbarray[a]->first; id; id = id->next) @@ -1571,43 +1562,17 @@ void test_idbutton(char *name) ID *idtest; - lb = which_libbase(G.main, GS(name - 2) ); + lb = which_libbase(G.main, GS(name) ); if (lb == NULL) return; /* search for id */ - idtest = BLI_findstring(lb, name, offsetof(ID, name) + 2); + idtest = BLI_findstring(lb, name + 2, offsetof(ID, name) + 2); - if (idtest && !new_id(lb, idtest, name)) { + if (idtest && !new_id(lb, idtest, name + 2)) { id_sort_by_name(lb, idtest); } } -/** - * Puts into *text a descriptive block type prefix to be displayed before the block name. - */ -/* Not actually used anywhere any more. */ -void text_idbutton(const struct ID *id, char *text) -{ - if (id) { - if (GS(id->name) == ID_SCE) - strcpy(text, "SCE: "); - else if (GS(id->name) == ID_SCR) - strcpy(text, "SCR: "); - else if (GS(id->name) == ID_MA && ((Material *)id)->use_nodes) - strcpy(text, "NT: "); - else { - text[0] = id->name[0]; - text[1] = id->name[1]; - text[2] = ':'; - text[3] = ' '; - text[4] = 0; - } - } - else { - text[0] = '\0'; - } -} - /** * Sets the name of a block to name, suitably adjusted for uniqueness. */ -- cgit v1.2.3 From 0c93ef3ba95136df3f822066772f5fbed8e696e6 Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Sun, 10 Mar 2013 19:10:20 +0000 Subject: Fix: Vertex weight color calculation tried to use NULL pointer when called through DM_update_weight_mcol(). (Introduced in r55062.) --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 2b289f1a0b9..cdcd184c2ec 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1035,7 +1035,7 @@ static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcin { float colf[4]; - if (dm_wcinfo->coba) { + if (dm_wcinfo && dm_wcinfo->coba) { do_colorband(dm_wcinfo->coba, input, colf); } else { -- cgit v1.2.3 From 5a981db3ecfd63f1d09962141b07d968f28aee60 Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Sun, 10 Mar 2013 19:12:40 +0000 Subject: Fix [#34561]: Possible smoke crash if smoke flow had lower density than adaptive domain "threshold". --- source/blender/blenkernel/intern/smoke.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index ca3908ab033..435e81556ab 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1776,6 +1776,8 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd dy = gy - sds->res_min[1]; dz = gz - sds->res_min[2]; d_index = smoke_get_index(dx, sds->res[0], dy, sds->res[1], dz); + /* make sure emission cell is inside the new domain boundary */ + if (dx < 0 || dy < 0 || dz < 0 || dx >= sds->res[0] || dy >= sds->res[1] || dz >= sds->res[2]) continue; if (sfs->type == MOD_SMOKE_FLOW_TYPE_OUTFLOW) { // outflow apply_outflow_fields(d_index, density, heat, fuel, react, color_r, color_g, color_b); -- cgit v1.2.3 From 38feedcaacd2bd317ea68a57014cddb2f9ceaf15 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Sun, 10 Mar 2013 20:05:18 +0000 Subject: Feature request for all paint systems that support it: Jittering in absolute coordinates. This allows an artist to lower the brush radius while keeping the spread of the brush constant. A toggle under the jitter slider provides the option to switch between relative/absolute. --- source/blender/blenkernel/intern/brush.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 798dde9f985..ab821ec37a1 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -791,7 +791,8 @@ void BKE_brush_scale_size(int *r_brush_size, void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2]) { - int use_jitter = brush->jitter != 0; + int use_jitter = (brush->flag & BRUSH_ABSOLUTE_JITTER) ? + (brush->jitter_absolute != 0) : (brush->jitter != 0); /* jitter-ed brush gives weird and unpredictable result for this * kinds of stroke, so manually disable jitter usage (sergey) */ @@ -799,17 +800,26 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], if (use_jitter) { float rand_pos[2]; - const int radius = BKE_brush_size_get(scene, brush); - const int diameter = 2 * radius; + float spread; + int diameter; - /* find random position within a circle of diameter 1 */ do { rand_pos[0] = BLI_frand() - 0.5f; rand_pos[1] = BLI_frand() - 0.5f; } while (len_v2(rand_pos) > 0.5f); - jitterpos[0] = pos[0] + 2 * rand_pos[0] * diameter * brush->jitter; - jitterpos[1] = pos[1] + 2 * rand_pos[1] * diameter * brush->jitter; + + if (brush->flag & BRUSH_ABSOLUTE_JITTER) { + diameter = 2 * brush->jitter_absolute; + spread = 1.0; + } + else { + diameter = 2 * BKE_brush_size_get(scene, brush); + spread = brush->jitter; + } + /* find random position within a circle of diameter 1 */ + jitterpos[0] = pos[0] + 2 * rand_pos[0] * diameter * spread; + jitterpos[1] = pos[1] + 2 * rand_pos[1] * diameter * spread; } else { copy_v2_v2(jitterpos, pos); -- cgit v1.2.3 From 4daef649866cfc2699b30b2eeab0e0370265c76a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 11 Mar 2013 09:06:49 +0000 Subject: Fix more UI i18n issues (reported by Leon Cheung and Lockal). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have a glicth with colormanagement's spaces descriptions, though, looks like they are clamped at 64 chars (see raw space), will see that later, if it’s solvable. --- source/blender/blenkernel/intern/constraint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 48ad3f51389..3430c2ea7a1 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -817,7 +817,7 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar static bConstraintTypeInfo CTI_CHILDOF = { CONSTRAINT_TYPE_CHILDOF, /* type */ sizeof(bChildOfConstraint), /* size */ - "ChildOf", /* name */ + "Child Of", /* name */ "bChildOfConstraint", /* struct name */ NULL, /* free data */ childof_id_looper, /* id looper */ @@ -992,7 +992,7 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar static bConstraintTypeInfo CTI_TRACKTO = { CONSTRAINT_TYPE_TRACKTO, /* type */ sizeof(bTrackToConstraint), /* size */ - "TrackTo", /* name */ + "Track To", /* name */ "bTrackToConstraint", /* struct name */ NULL, /* free data */ trackto_id_looper, /* id looper */ -- cgit v1.2.3 From 28857e8c9efff961f1f526dd247d0c35a0a2b8be Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 11 Mar 2013 11:09:57 +0000 Subject: Fix #34511: Invalid Audio/Video codec combination produces hung filehandle --- source/blender/blenkernel/intern/writeffmpeg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 7e51025883d..c9e07952f4a 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -837,7 +837,8 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report } if (avformat_write_header(of, NULL) < 0) { BKE_report(reports, RPT_ERROR, "Could not initialize streams, probably unsupported codec combination"); - av_dict_free(&opts); + av_dict_free(&opts); + avio_close(of->pb); return 0; } -- cgit v1.2.3 From e6dcf9504e1a9c1dcd574044e7a717d0def8aadc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Mar 2013 16:23:33 +0000 Subject: code cleanup: - move recursive bone/parent check into ED_armature.h - remove unused vars - use const for paint vector args. --- source/blender/blenkernel/intern/object.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0205fe91a60..c93da151463 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3128,9 +3128,8 @@ KeyBlock *BKE_object_insert_shape_key(Scene *scene, Object *ob, const char *name bool BKE_object_is_child_recursive(Object *ob_parent, Object *ob_child) { - Object *ob_test; - for (ob_test = ob_child->parent; ob_test; ob_test = ob_test->parent) { - if (ob_test == ob_parent) { + for (ob_child = ob_child->parent; ob_child; ob_child = ob_child->parent) { + if (ob_child == ob_parent) { return true; } } -- cgit v1.2.3 From 5792e77239c43aea0afc21b2df96153ba31c5399 Mon Sep 17 00:00:00 2001 From: Irie Shinsuke Date: Tue, 12 Mar 2013 07:25:53 +0000 Subject: Patch [#34373] Use i18n monospace font in Text editor and Python console This patch allows Blender to display i18n monospace font in the text editor and the Python interactive console. Wide characters that occupy multiple columns such as CJK characters can be displayed correctly. Furthermore, wrapping, selection, suggestion, cursor drawing, and syntax highlighting should work. Also fixes a bug [#34543]: In Text Editor false color in comment on cyrillic To estimate how many columns each character occupies, this patch uses wcwidth.c written by Markus Kuhn and distributed under MIT-style license: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c wcwidth.c is stored in extern/wcwidth and used as a static library. This patch adds new API to blenfont, blenlib and blenkernel: BLF_get_unifont_mono() BLF_free_unifont_mono() BLF_draw_mono() BLI_wcwidth() BLI_wcswidth() BLI_str_utf8_char_width() BLI_str_utf8_char_width_safe() txt_utf8_offset_to_column() txt_utf8_column_to_offset() --- source/blender/blenkernel/intern/text.c | 46 ++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index a155ca47d3c..e229c288a24 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -791,6 +791,29 @@ int txt_utf8_index_to_offset(const char *str, int index) return offset; } +int txt_utf8_offset_to_column(const char *str, int offset) +{ + int column = 0, pos = 0; + while (pos < offset) { + column += BLI_str_utf8_char_width_safe(str + pos); + pos += BLI_str_utf8_size_safe(str + pos); + } + return column; +} + +int txt_utf8_column_to_offset(const char *str, int column) +{ + int offset = 0, pos = 0, col; + while (pos < column) { + col = BLI_str_utf8_char_width_safe(str + offset); + if (pos + col > column) + break; + offset += BLI_str_utf8_size_safe(str + offset); + pos += col; + } + return offset; +} + /* returns the real number of characters in string */ /* not the same as BLI_strlen_utf8, which returns length for wide characters */ static int txt_utf8_len(const char *src) @@ -804,6 +827,17 @@ static int txt_utf8_len(const char *src) return len; } +static int txt_utf8_width(const char *src) +{ + int col = 0; + + for (; *src; src += BLI_str_utf8_size(src)) { + col += BLI_str_utf8_char_width(src); + } + + return col; +} + void txt_move_up(Text *text, short sel) { TextLine **linep; @@ -815,10 +849,10 @@ void txt_move_up(Text *text, short sel) if (!*linep) return; if ((*linep)->prev) { - int index = txt_utf8_offset_to_index((*linep)->line, *charp); + int column = txt_utf8_offset_to_column((*linep)->line, *charp); *linep = (*linep)->prev; - if (index > txt_utf8_len((*linep)->line)) *charp = (*linep)->len; - else *charp = txt_utf8_index_to_offset((*linep)->line, index); + if (column > txt_utf8_width((*linep)->line)) *charp = (*linep)->len; + else *charp = txt_utf8_column_to_offset((*linep)->line, column); } else { @@ -839,10 +873,10 @@ void txt_move_down(Text *text, short sel) if (!*linep) return; if ((*linep)->next) { - int index = txt_utf8_offset_to_index((*linep)->line, *charp); + int column = txt_utf8_offset_to_column((*linep)->line, *charp); *linep = (*linep)->next; - if (index > txt_utf8_len((*linep)->line)) *charp = (*linep)->len; - else *charp = txt_utf8_index_to_offset((*linep)->line, index); + if (column > txt_utf8_width((*linep)->line)) *charp = (*linep)->len; + else *charp = txt_utf8_column_to_offset((*linep)->line, column); } else { txt_move_eol(text, sel); -- cgit v1.2.3 From e84153a91ccd05548fb718eb612dc6155b3873c9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Mar 2013 08:24:36 +0000 Subject: Fix compilation error after recent changes to strict gcc flags Dudes, please try building blender with all default features before doing such a commits. It helps just a lot when bisecting issues later. Also solved const qualifier discard happens in recent monofont commit. --- source/blender/blenkernel/intern/writeffmpeg.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index c9e07952f4a..2cf7a962d07 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -981,7 +981,6 @@ int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty, return success; } -void BKE_ffmpeg_end(void); static void end_ffmpeg_impl(int is_autosplit); #ifdef WITH_AUDASPACE -- cgit v1.2.3 From eefee7a25e5e5b5d6778c64ebbb9b874542f082d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Mar 2013 12:47:57 +0000 Subject: replace sprintf -> strcpy where its not needed. --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 6276bce8ca2..c318356fd2a 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -3511,7 +3511,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) else if (totframes && cache->totpoint) BLI_snprintf(cache->info, sizeof(cache->info), IFACE_("%i points found!"), cache->totpoint); else - BLI_snprintf(cache->info, sizeof(cache->info), IFACE_("No valid data to read!")); + BLI_strncpy(cache->info, IFACE_("No valid data to read!"), sizeof(cache->info)); return; } -- cgit v1.2.3 From b3ff0d6d2a95f461ae53c4e61b106b45c7aff48c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 12 Mar 2013 13:18:39 +0000 Subject: Temp fix for stupid -Wformat-security issue. Also makes more use of BLI_snprintf, and makes more consistent code acrross all "header strings" generation in transform.c. --- source/blender/blenkernel/intern/pointcache.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index c318356fd2a..c900d08e4e9 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -840,7 +840,10 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) /* version header */ ptcache_file_read(pf, version, 1, sizeof(char) * 4); - if (strncmp(version, DPAINT_CACHE_VERSION, 4)) {printf("Dynamic Paint: Invalid cache version: %s!\n", version); return 0;} + if (strncmp(version, DPAINT_CACHE_VERSION, 4)) { + printf("Dynamic Paint: Invalid cache version: %s!\n", version); + return 0; + } if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) { unsigned int data_len; @@ -1516,7 +1519,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns if (mode == 2) { r = LzmaCompress(out, &out_len, in, in_len, //assume sizeof(char)==1.... - props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2); + props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2); if (!(r == SZ_OK) || (out_len >= in_len)) compressed = 0; -- cgit v1.2.3 From d0af1101fb502ec9bce2622d92f79fa60b826bd8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Mar 2013 16:09:23 +0000 Subject: Patch #34569: Enable PNG Codec for video output By Gottfried Hofmann, thanks! --- source/blender/blenkernel/intern/writeffmpeg.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 2cf7a962d07..af8b32ab75c 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -551,6 +551,12 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex } } + if (codec_id == CODEC_ID_PNG) { + if (rd->im_format.planes == R_IMF_PLANES_RGBA) { + c->pix_fmt = PIX_FMT_ARGB; + } + } + if ((of->oformat->flags & AVFMT_GLOBALHEADER) // || !strcmp(of->oformat->name, "mp4") // || !strcmp(of->oformat->name, "mov") @@ -1493,6 +1499,9 @@ int BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd) if (codec == CODEC_ID_QTRLE) return TRUE; + if (codec == CODEC_ID_PNG) + return TRUE; + #ifdef FFMPEG_FFV1_ALPHA_SUPPORTED if (codec == CODEC_ID_FFV1) return TRUE; -- cgit v1.2.3 From e6cdee370e74ef3e48051ad95a4bc3eba5f804c4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Mar 2013 16:57:14 +0000 Subject: Patch #34204: [Render Animation] Fails with "Error: Specified sample_fmt is not supported" with ogg vorbis Patch by Jehan Pages (pardon for mis-typing, emacs-nox works not so good with urf-8 buffers here), with some own modifications. Thanks! From the patch tracker: The problem is because of several versions of ffmpeg, but even more because of the fork situation libav/ffmpeg. So there are some installed versions out there where you *must* use a float sample for some codec; whereas oppositely on some other installations, you *must* use the int sample. So for some people, one works not the other, and reciprocally. As a consequence, you can't just have a switch codec-based, like in current code, which decides on the float or int implementation, you must necessarily have a runtime test because you won't know until then if ogg vorbis will use one or another sample (note: that's true also for AC3 as I fixed the exact same bug in DVDStyler for AC3 encoding a few months ago; and I guess it would be same for AAC). Some notes from self: - New FFmpeg requires using FLTP for AAC, AC3 and Vorbis, it's not supported by audaspace and result in this case would be just wrong. Throw an error in cases FLTP is trying to be used. - Moved strict_std_compliance a bit upper. When we'll support FLTP both FLT and FLTP for AAC would need to be using FF_COMPLIANCE_EXPERIMENTAL. - It is nice to have such check of supported by codec formats anyway. --- source/blender/blenkernel/intern/writeffmpeg.c | 48 +++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index af8b32ab75c..082ae380070 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -111,8 +111,9 @@ static void delete_picture(AVFrame *f) } } -static int use_float_audio_buffer(int codec_id) +static int request_float_audio_buffer(int codec_id) { + /* If any of these codecs, we prefer the float sample format (if supported) */ return codec_id == CODEC_ID_AAC || codec_id == CODEC_ID_AC3 || codec_id == CODEC_ID_VORBIS; } @@ -629,16 +630,55 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex c->bit_rate = ffmpeg_audio_bitrate * 1000; c->sample_fmt = AV_SAMPLE_FMT_S16; c->channels = rd->ffcodecdata.audio_channels; - if (use_float_audio_buffer(codec_id)) { + + if (request_float_audio_buffer(codec_id)) { + /* mainly for AAC codec which is experimental */ c->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; c->sample_fmt = AV_SAMPLE_FMT_FLT; } + codec = avcodec_find_encoder(c->codec_id); if (!codec) { //XXX error("Couldn't find a valid audio codec"); return NULL; } + if (codec->sample_fmts) { + /* check if the prefered sample format for this codec is supported. + * this is because, depending on the version of libav, and with the whole ffmpeg/libav fork situation, + * you have various implementations around. float samples in particular are not always supported. + */ + const enum AVSampleFormat *p = codec->sample_fmts; + for (; *p!=-1; p++) { + if (*p == st->codec->sample_fmt) + break; + } + if (*p == -1) { + /* sample format incompatible with codec. Defaulting to a format known to work */ + st->codec->sample_fmt = codec->sample_fmts[0]; + } + } + + if (c->sample_fmt == AV_SAMPLE_FMT_FLTP) { + BLI_strncpy(error, "Requested audio codec requires planar float sample format, which is not supported yet", error_size); + return NULL; + } + + if (codec->supported_samplerates) { + const int *p = codec->supported_samplerates; + int best = 0; + int best_dist = INT_MAX; + for (; *p; p++){ + int dist = abs(st->codec->sample_rate - *p); + if (dist < best_dist){ + best_dist = dist; + best = *p; + } + } + /* best is the closest supported sample rate (same as selected if best_dist == 0) */ + st->codec->sample_rate = best; + } + set_ffmpeg_properties(rd, c, "audio"); if (avcodec_open2(c, codec, NULL) < 0) { @@ -664,7 +704,7 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex audio_output_buffer = (uint8_t *) av_malloc(audio_outbuf_size); - if (use_float_audio_buffer(codec_id)) { + if (c->sample_fmt == AV_SAMPLE_FMT_FLT) { audio_input_buffer = (uint8_t *) av_malloc(audio_input_samples * c->channels * sizeof(float)); } else { @@ -970,7 +1010,7 @@ int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty, AVCodecContext *c = audio_stream->codec; AUD_DeviceSpecs specs; specs.channels = c->channels; - if (use_float_audio_buffer(c->codec_id)) { + if (c->sample_fmt == AV_SAMPLE_FMT_FLT) { specs.format = AUD_FORMAT_FLOAT32; } else { -- cgit v1.2.3 From 153b63e0fde21730cd54f16a501c18c793256ae2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Mar 2013 21:46:33 +0000 Subject: style cleanup --- source/blender/blenkernel/intern/writeffmpeg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 082ae380070..ad4776c7a2d 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -668,9 +668,9 @@ static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex const int *p = codec->supported_samplerates; int best = 0; int best_dist = INT_MAX; - for (; *p; p++){ + for (; *p; p++) { int dist = abs(st->codec->sample_rate - *p); - if (dist < best_dist){ + if (dist < best_dist) { best_dist = dist; best = *p; } -- cgit v1.2.3 From acd3bef34e6a6b30df694f931dc0c622ca083f59 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Wed, 13 Mar 2013 03:46:22 +0000 Subject: Texture sampling function refactoring: ALERT! POSSIBLE BREAKING COMMIT, ESPECIALLY FOR SCULPT! Separate the sculpt sampling function so that it can be reused from other paint systems. This includes updating of the relevant coordinates for anchored and rake style brushes, which are now being updated as part of the stroke system. I left only code for area-style brush texture mapping in sculpt code, since it requires a few data structures not present on other paint systems. This commit makes it almost as easy to support rake on other systems as exposing the python UI for it. Also it makes it totally possible to have texture painting capabilities in vertex paint too :) These commits will follow very soon. Also, even if I did my best to keep the code from breaking, (even fixed a leftover bug from coordinate changes) this is a big change. Please test! --- source/blender/blenkernel/intern/brush.c | 96 +++++++++++++++++++++++++++++++- source/blender/blenkernel/intern/paint.c | 20 +++++++ 2 files changed, 114 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index ab821ec37a1..4ec20d5fe04 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -513,8 +513,98 @@ void BKE_brush_sample_tex(const Scene *scene, Brush *brush, const float sampleco } } + +/* Return a multiplier for brush strength on a particular vertex. */ +float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, + const float point[3], + float rgba[3], + struct ImagePool *pool) +{ + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; + MTex *mtex = &br->mtex; + float intensity = 1.0; + bool hasrgb = false; + + if (!mtex->tex) { + intensity = 1; + } + else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) { + /* Get strength by feeding the vertex + * location directly into a texture */ + hasrgb = externtex(mtex, point, &intensity, + rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool); + } + else { + float rotation = -mtex->rot; + float point_2d[2] = {point[0], point[1]}; + float x = 0.0f, y = 0.0f; /* Quite warnings */ + float radius = 1.0f; /* Quite warnings */ + float co[2]; + + if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { + /* keep coordinates relative to mouse */ + + rotation += ups->brush_rotation; + + point_2d[0] -= ups->tex_mouse[0]; + point_2d[1] -= ups->tex_mouse[1]; + + /* use pressure adjusted size for fixed mode */ + radius = ups->pixel_radius; + + x = point_2d[0]; + y = point_2d[1]; + } + else if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) { + /* leave the coordinates relative to the screen */ + + /* use unadjusted size for tiled mode */ + radius = BKE_brush_size_get(scene, br); + + x = point_2d[0]; + y = point_2d[1]; + } + + x /= radius; + y /= radius; + + /* it is probably worth optimizing for those cases where + * the texture is not rotated by skipping the calls to + * atan2, sqrtf, sin, and cos. */ + if (rotation > 0.001f || rotation < -0.001f) { + const float angle = atan2f(y, x) + rotation; + const float flen = sqrtf(x * x + y * y); + + x = flen * cosf(angle); + y = flen * sinf(angle); + } + + x *= br->mtex.size[0]; + y *= br->mtex.size[1]; + + co[0] = x + br->mtex.ofs[0]; + co[1] = y + br->mtex.ofs[1]; + co[2] = 0.0f; + + hasrgb = externtex(mtex, co, &intensity, + rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool); + } + + intensity += br->texture_sample_bias; + + if (!hasrgb) { + rgba[0] = intensity; + rgba[1] = intensity; + rgba[2] = intensity; + rgba[3] = 1.0f; + } + + return intensity; +} + + /* Brush Sampling for 2D brushes. when we unify the brush systems this will be necessarily a separate function */ -void BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread) +float BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], struct ImagePool *pool) { MTex *mtex = &brush->mtex; @@ -527,7 +617,7 @@ void BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2] co[1] = xy[1] / radius; co[2] = 0.0f; - hasrgb = externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, thread, NULL); + hasrgb = externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, 0, pool); if (hasrgb) { rgba[0] = tr; @@ -541,9 +631,11 @@ void BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2] rgba[2] = tin; rgba[3] = 1.0f; } + return tin; } else { rgba[0] = rgba[1] = rgba[2] = rgba[3] = 1.0f; + return 1.0; } } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index a001a13d000..cc647a90c8f 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -40,6 +40,7 @@ #include "BLI_bitmap.h" #include "BLI_utildefines.h" +#include "BLI_math_vector.h" #include "BKE_brush.h" #include "BKE_context.h" @@ -300,3 +301,22 @@ float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level, return gpm->data[(y * factor) * gridsize + (x * factor)]; } + +/* threshhold to move before updating the brush rotation */ +#define RAKE_THRESHHOLD 20 + +void paint_calculate_rake_rotation(UnifiedPaintSettings *ups, const float mouse_pos[2]) +{ + const float u = 0.5f; + const float r = RAKE_THRESHHOLD; + + float dpos[2]; + sub_v2_v2v2(dpos, ups->last_rake, mouse_pos); + + if (len_squared_v2(dpos) >= r * r) { + ups->brush_rotation = atan2(dpos[0], dpos[1]); + + interp_v2_v2v2(ups->last_rake, ups->last_rake, + mouse_pos, u); + } +} -- cgit v1.2.3 From 839b07fe316c07e14780dcfc8121d10ef6053f67 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Mar 2013 05:23:53 +0000 Subject: style cleanup: also remove unused defines in paint_image.c --- source/blender/blenkernel/intern/brush.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 4ec20d5fe04..3d32ac8db77 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -516,9 +516,9 @@ void BKE_brush_sample_tex(const Scene *scene, Brush *brush, const float sampleco /* Return a multiplier for brush strength on a particular vertex. */ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, - const float point[3], - float rgba[3], - struct ImagePool *pool) + const float point[3], + float rgba[3], + struct ImagePool *pool) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; MTex *mtex = &br->mtex; -- cgit v1.2.3 From 136738029ea0d6f142d8c1e1f5ba6a60cccf45e1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Mar 2013 14:19:55 +0000 Subject: Fix write past end of array in recent texture sampling refactoring commit, and a small warning for double const keyword. --- source/blender/blenkernel/intern/brush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 3d32ac8db77..289086f8b86 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -539,7 +539,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, float point_2d[2] = {point[0], point[1]}; float x = 0.0f, y = 0.0f; /* Quite warnings */ float radius = 1.0f; /* Quite warnings */ - float co[2]; + float co[3]; if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { /* keep coordinates relative to mouse */ -- cgit v1.2.3 From 5162a155afe279519ad353312307ab5496c16603 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Mar 2013 17:16:49 +0000 Subject: Fix #34481: camera focal length and sensor size did not use units yet, now they do. I've added a separate camera unit type. It's a bit strange to have an exception for this but it ensures units are shown in familiar millimeters and it also ensures backwards compatibility. --- source/blender/blenkernel/intern/unit.c | 56 ++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index dd6ed42bd92..08c62d4217b 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -104,7 +104,7 @@ typedef struct bUnitCollection { /* Dummy */ static struct bUnitDef buDummyDef[] = { {"", NULL, "", NULL, NULL, 1.0, 0.0}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}}; -static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDummyDef)}; +static struct bUnitCollection buDummyCollection = {buDummyDef, 0, 0, sizeof(buDummyDef)}; /* Lengths */ static struct bUnitDef buMetricLenDef[] = { @@ -125,7 +125,7 @@ static struct bUnitDef buMetricLenDef[] = { #endif {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buMetricLenCollection = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialLenDef[] = { {"mile", "miles", "mi", "m", "Miles", UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, @@ -137,7 +137,7 @@ static struct bUnitDef buImperialLenDef[] = { {"thou", "thou", "thou", "mil", "Thou", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buImperialLenCollection = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef) / sizeof(bUnitDef)}; /* Areas */ static struct bUnitDef buMetricAreaDef[] = { @@ -151,7 +151,7 @@ static struct bUnitDef buMetricAreaDef[] = { {"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricAreaCollecton = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buMetricAreaCollection = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialAreaDef[] = { {"square mile", "square miles", "sq mi", "sq m", "Square Miles", UN_SC_MI * UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, @@ -163,7 +163,7 @@ static struct bUnitDef buImperialAreaDef[] = { {"square thou", "square thous", "sq mil", NULL, "Square Thous", UN_SC_MIL * UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialAreaCollecton = {buImperialAreaDef, 4, 0, sizeof(buImperialAreaDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buImperialAreaCollection = {buImperialAreaDef, 4, 0, sizeof(buImperialAreaDef) / sizeof(bUnitDef)}; /* Volumes */ static struct bUnitDef buMetricVolDef[] = { @@ -177,7 +177,7 @@ static struct bUnitDef buMetricVolDef[] = { {"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricVolCollecton = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buMetricVolCollection = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialVolDef[] = { {"cubic mile", "cubic miles", "cu mi", "cu m", "Cubic Miles", UN_SC_MI * UN_SC_MI * UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, @@ -189,7 +189,7 @@ static struct bUnitDef buImperialVolDef[] = { {"cubic thou", "cubic thous", "cu mil", NULL, "Cubic Thous", UN_SC_MIL * UN_SC_MIL * UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialVolCollecton = {buImperialVolDef, 4, 0, sizeof(buImperialVolDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buImperialVolCollection = {buImperialVolDef, 4, 0, sizeof(buImperialVolDef) / sizeof(bUnitDef)}; /* Mass */ static struct bUnitDef buMetricMassDef[] = { @@ -201,7 +201,7 @@ static struct bUnitDef buMetricMassDef[] = { {"gram", "grams", "g", NULL, "Grams", UN_SC_G, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricMassCollecton = {buMetricMassDef, 2, 0, sizeof(buMetricMassDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buMetricMassCollection = {buMetricMassDef, 2, 0, sizeof(buMetricMassDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialMassDef[] = { {"ton", "tonnes", "ton", "t", "Tonnes", UN_SC_ITON, 0.0, B_UNIT_DEF_NONE}, @@ -211,7 +211,7 @@ static struct bUnitDef buImperialMassDef[] = { {"ounce", "ounces", "oz", NULL, "Ounces", UN_SC_OZ, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialMassCollecton = {buImperialMassDef, 3, 0, sizeof(buImperialMassDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buImperialMassCollection = {buImperialMassDef, 3, 0, sizeof(buImperialMassDef) / sizeof(bUnitDef)}; /* Even if user scales the system to a point where km^3 is used, velocity and * acceleration aren't scaled: that's why we have so few units for them */ @@ -222,27 +222,27 @@ static struct bUnitDef buMetricVelDef[] = { {"kilometer per hour", "kilometers per hour", "km/h", NULL, "Kilometers per hour", UN_SC_KM / 3600.0f, 0.0, B_UNIT_DEF_SUPPRESS}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricVelCollecton = {buMetricVelDef, 0, 0, sizeof(buMetricVelDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buMetricVelCollection = {buMetricVelDef, 0, 0, sizeof(buMetricVelDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialVelDef[] = { {"foot per second", "feet per second", "ft/s", "fps", "Feet per second", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"mile per hour", "miles per hour", "mph", NULL, "Miles per hour", UN_SC_MI / 3600.0f, 0.0, B_UNIT_DEF_SUPPRESS}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialVelCollecton = {buImperialVelDef, 0, 0, sizeof(buImperialVelDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buImperialVelCollection = {buImperialVelDef, 0, 0, sizeof(buImperialVelDef) / sizeof(bUnitDef)}; /* Acceleration */ static struct bUnitDef buMetricAclDef[] = { {"meter per second squared", "meters per second squared", "m/s²", "m/s2", "Meters per second squared", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricAclCollecton = {buMetricAclDef, 0, 0, sizeof(buMetricAclDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buMetricAclCollection = {buMetricAclDef, 0, 0, sizeof(buMetricAclDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialAclDef[] = { {"foot per second squared", "feet per second squared", "ft/s²", "ft/s2", "Feet per second squared", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialAclCollecton = {buImperialAclDef, 0, 0, sizeof(buImperialAclDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buImperialAclCollection = {buImperialAclDef, 0, 0, sizeof(buImperialAclDef) / sizeof(bUnitDef)}; /* Time */ static struct bUnitDef buNaturalTimeDef[] = { @@ -255,7 +255,7 @@ static struct bUnitDef buNaturalTimeDef[] = { {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)}; +static struct bUnitCollection buNaturalTimeCollection = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)}; static struct bUnitDef buNaturalRotDef[] = { @@ -266,12 +266,24 @@ static struct bUnitDef buNaturalRotDef[] = { }; static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef) / sizeof(bUnitDef)}; -#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 9) / sizeof(void *)) - 1) -static struct bUnitCollection *bUnitSystems[][9] = { - {NULL, NULL, NULL, NULL, NULL, &buNaturalRotCollection, &buNaturalTimeCollecton, NULL, NULL}, - {NULL, &buMetricLenCollecton, &buMetricAreaCollecton, &buMetricVolCollecton, &buMetricMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buMetricVelCollecton, &buMetricAclCollecton}, /* metric */ - {NULL, &buImperialLenCollecton, &buImperialAreaCollecton, &buImperialVolCollecton, &buImperialMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buImperialVelCollecton, &buImperialAclCollecton}, /* imperial */ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} +/* Camera Lengths */ +static struct bUnitDef buCameraLenDef[] = { + {"meter", "meters", "m", NULL, "Meters", UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, + {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_MM, 0.0, B_UNIT_DEF_SUPPRESS}, // micron too? + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buCameraLenCollection = {buCameraLenDef, 3, 0, sizeof(buCameraLenDef) / sizeof(bUnitDef)}; + + +#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / B_UNIT_TYPE_TOT) / sizeof(void *)) - 1) +static struct bUnitCollection *bUnitSystems[][B_UNIT_TYPE_TOT] = { + {NULL, NULL, NULL, NULL, NULL, &buNaturalRotCollection, &buNaturalTimeCollection, NULL, NULL, NULL}, + {NULL, &buMetricLenCollection, &buMetricAreaCollection, &buMetricVolCollection, &buMetricMassCollection, &buNaturalRotCollection, &buNaturalTimeCollection, &buMetricVelCollection, &buMetricAclCollection, &buCameraLenCollection}, /* metric */ + {NULL, &buImperialLenCollection, &buImperialAreaCollection, &buImperialVolCollection, &buImperialMassCollection, &buNaturalRotCollection, &buNaturalTimeCollection, &buImperialVelCollection, &buImperialAclCollection, &buCameraLenCollection}, /* imperial */ + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} }; @@ -395,10 +407,10 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, bUnitCollection *usys = unit_get_system(system, type); if (usys == NULL || usys->units[0].name == NULL) - usys = &buDummyCollecton; + usys = &buDummyCollection; /* split output makes sense only for length, mass and time */ - if (split && (type == B_UNIT_LENGTH || type == B_UNIT_MASS || type == B_UNIT_TIME)) { + if (split && (type == B_UNIT_LENGTH || type == B_UNIT_MASS || type == B_UNIT_TIME || type == B_UNIT_CAMERA)) { bUnitDef *unit_a, *unit_b; double value_a, value_b; -- cgit v1.2.3 From 962865d19f4bd8639ac6c2064a3c82e5674e7802 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Mar 2013 18:10:05 +0000 Subject: fix for 2 errors where the 2d arrays were used as 3d. (out of bounds read). also minor code cleanup. --- source/blender/blenkernel/intern/brush.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 289086f8b86..71db2fc56da 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -532,7 +532,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, /* Get strength by feeding the vertex * location directly into a texture */ hasrgb = externtex(mtex, point, &intensity, - rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool); + rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool); } else { float rotation = -mtex->rot; @@ -587,7 +587,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, co[2] = 0.0f; hasrgb = externtex(mtex, co, &intensity, - rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool); + rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool); } intensity += br->texture_sample_bias; -- cgit v1.2.3 From d9408f88003ab9c96dd1e8ec54a93c2812b08315 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Mar 2013 22:15:59 +0000 Subject: Fix #34526: crash using mask modifier + subsurf + UV map. --- source/blender/blenkernel/intern/subsurf_ccg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index e03100280d6..6dd1786a38b 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -3304,8 +3304,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, faceFlags->mat_nr = mpoly ? mpoly[origIndex].mat_nr : 0; faceFlags++; - origIndex = base_polyOrigIndex ? base_polyOrigIndex[origIndex] : origIndex; - /* set the face base vert */ *((int *)ccgSubSurf_getFaceUserData(ss, f)) = vertNum; @@ -3413,7 +3411,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, faceOrigIndex++; } if (polyOrigIndex) { - *polyOrigIndex = origIndex; + *polyOrigIndex = base_polyOrigIndex ? base_polyOrigIndex[origIndex] : origIndex; polyOrigIndex++; } -- cgit v1.2.3 From 0d70e8a4fd6a2d04f0bc37ad4d0eb6eea8d831ce Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Thu, 14 Mar 2013 02:27:36 +0000 Subject: Two new Features: * Support for Rake in projective paint (2D painting will be a separate commit) * Support for smooth stroke across all paint systems --- source/blender/blenkernel/intern/brush.c | 48 ++------------------------------ 1 file changed, 3 insertions(+), 45 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 71db2fc56da..636f6160b9f 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -472,52 +472,10 @@ int BKE_brush_clone_image_delete(Brush *brush) return 0; } -/* Brush Sampling for 3d brushes. Currently used for texture painting only, but should be generalized */ -void BKE_brush_sample_tex(const Scene *scene, Brush *brush, const float sampleco[3], float rgba[4], const int thread, struct ImagePool *pool) -{ - MTex *mtex = &brush->mtex; - - if (mtex && mtex->tex) { - float tin, tr, tg, tb, ta; - int hasrgb; - const int radius = BKE_brush_size_get(scene, brush); - - if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D) { - hasrgb = externtex(mtex, sampleco, &tin, &tr, &tg, &tb, &ta, thread, pool); - } - else { - float co[3]; - - co[0] = sampleco[0] / radius; - co[1] = sampleco[1] / radius; - co[2] = 0.0f; - - hasrgb = externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, thread, pool); - } - - if (hasrgb) { - rgba[0] = tr; - rgba[1] = tg; - rgba[2] = tb; - rgba[3] = ta; - } - else { - rgba[0] = tin; - rgba[1] = tin; - rgba[2] = tin; - rgba[3] = 1.0f; - } - } - else { - rgba[0] = rgba[1] = rgba[2] = rgba[3] = 1.0f; - } -} - - /* Return a multiplier for brush strength on a particular vertex. */ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, const float point[3], - float rgba[3], + float rgba[3], const int thread, struct ImagePool *pool) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -532,7 +490,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, /* Get strength by feeding the vertex * location directly into a texture */ hasrgb = externtex(mtex, point, &intensity, - rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool); + rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool); } else { float rotation = -mtex->rot; @@ -587,7 +545,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, co[2] = 0.0f; hasrgb = externtex(mtex, co, &intensity, - rgba, rgba + 1, rgba + 2, rgba + 3, 0, pool); + rgba, rgba + 1, rgba + 2, rgba + 3, thread, pool); } intensity += br->texture_sample_bias; -- cgit v1.2.3 From 568435285801db081824d5873e43911764fff5a0 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Thu, 14 Mar 2013 03:47:20 +0000 Subject: Fix silly mistake that could lead to crash. Also, slight cleanup/rename and comments --- source/blender/blenkernel/intern/brush.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 636f6160b9f..5d7f9afa78c 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -472,7 +472,8 @@ int BKE_brush_clone_image_delete(Brush *brush) return 0; } -/* Return a multiplier for brush strength on a particular vertex. */ +/* Generic texture sampler for 3D painting systems. point has to be either in + * region space mouse coordinates, or 3d world coordinates for 3D mapping */ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, const float point[3], float rgba[3], const int thread, -- cgit v1.2.3 From aff410b558c4c438f38a4050dbe13684e209572b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Mar 2013 05:52:30 +0000 Subject: style cleanup: odd indentation --- source/blender/blenkernel/intern/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index e229c288a24..3936c533a41 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2861,7 +2861,7 @@ void txt_move_lines(struct Text *text, const int direction) } } -int setcurr_tab_spaces(Text *text, int space) +int txt_setcurr_tab_spaces(Text *text, int space) { int i = 0; int test = 0; -- cgit v1.2.3 From 92d45811c388ef9a22662521151aa00deca5d889 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Mar 2013 05:59:34 +0000 Subject: fix reading out of buffer bounds for recent vertex paint commit. --- source/blender/blenkernel/intern/brush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 5d7f9afa78c..d341a2c06e1 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -476,7 +476,7 @@ int BKE_brush_clone_image_delete(Brush *brush) * region space mouse coordinates, or 3d world coordinates for 3D mapping */ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, const float point[3], - float rgba[3], const int thread, + float rgba[4], const int thread, struct ImagePool *pool) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; -- cgit v1.2.3 From ffc8ecc5874931e7a0040141a7bc3ad1b70b17d0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Mar 2013 10:39:18 +0000 Subject: use BLI_strncpy_rlen() rather then BLI_snprintf() when no formatting is needed. also replace sprintf with strcpy when no formatting is done. --- source/blender/blenkernel/intern/unit.c | 2 +- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 08c62d4217b..066b6eff5c5 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -718,7 +718,7 @@ void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int syste /* print the alt_name */ if (unit->name_alt) - len_name = BLI_snprintf(str, len_max, "%s", unit->name_alt); + len_name = BLI_strncpy_rlen(str, unit->name_alt, len_max); else len_name = 0; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index ad4776c7a2d..a88a9e4954b 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -786,7 +786,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report fmt->audio_codec = ffmpeg_audio_codec; - BLI_snprintf(of->filename, sizeof(of->filename), "%s", name); + BLI_strncpy(of->filename, name, sizeof(of->filename)); /* set the codec to the user's selection */ switch (ffmpeg_type) { case FFMPEG_AVI: -- cgit v1.2.3 From a0dbd88311ae85c6713a91a6dca97eee6e90db9d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Mar 2013 18:35:21 +0000 Subject: converting a mesh to a curve was unnecessarily using tessface's. use mpolys instead and simplify checks for wire edges. Also rename BKE_mesh_from_curve() --> BKE_mesh_to_curve() since this function converts a mesh into a curve. --- source/blender/blenkernel/intern/mesh.c | 48 +++++++++++++-------------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index f6f60d03cf7..604a273efc5 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1586,60 +1586,50 @@ static void appendPolyLineVert(ListBase *lb, unsigned int index) BLI_addtail(lb, vl); } -void BKE_mesh_from_curve(Scene *scene, Object *ob) +void BKE_mesh_to_curve(Scene *scene, Object *ob) { /* make new mesh data from the original copy */ DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH); MVert *mverts = dm->getVertArray(dm); MEdge *med, *medge = dm->getEdgeArray(dm); - MFace *mf, *mface = dm->getTessFaceArray(dm); + MPoly *mp, *mpoly = dm->getPolyArray(dm); + MLoop *mloop = dm->getLoopArray(dm); int totedge = dm->getNumEdges(dm); - int totface = dm->getNumTessFaces(dm); + int totpoly = dm->getNumPolys(dm); int totedges = 0; - int i, needsFree = 0; + int i; + bool needsFree = false; /* only to detect edge polylines */ - EdgeHash *eh = BLI_edgehash_new(); - EdgeHash *eh_edge = BLI_edgehash_new(); - + int *edge_users; ListBase edges = {NULL, NULL}; - /* create edges from all faces (so as to find edges not in any faces) */ - mf = mface; - for (i = 0; i < totface; i++, mf++) { - if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2)) - BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL); - if (!BLI_edgehash_haskey(eh, mf->v2, mf->v3)) - BLI_edgehash_insert(eh, mf->v2, mf->v3, NULL); - - if (mf->v4) { - if (!BLI_edgehash_haskey(eh, mf->v3, mf->v4)) - BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL); - if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1)) - BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL); - } - else { - if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1)) - BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL); + /* get boundary edges */ + edge_users = MEM_callocN(sizeof(int) * totedge, __func__); + for (i = 0, mp = mpoly; i < totpoly; i++, mp++) { + MLoop *ml = &mloop[mp->loopstart]; + int j; + for (j = 0; j < mp->totloop; j++, ml++) { + edge_users[ml->e]++; } } + /* create edges from all faces (so as to find edges not in any faces) */ med = medge; for (i = 0; i < totedge; i++, med++) { - if (!BLI_edgehash_haskey(eh, med->v1, med->v2)) { + if (edge_users[i] == 0) { EdgeLink *edl = MEM_callocN(sizeof(EdgeLink), "EdgeLink"); - BLI_edgehash_insert(eh_edge, med->v1, med->v2, NULL); + // BLI_edgehash_insert(eh_edge, med->v1, med->v2, NULL); edl->edge = med; BLI_addtail(&edges, edl); totedges++; } } - BLI_edgehash_free(eh_edge, NULL); - BLI_edgehash_free(eh, NULL); + MEM_freeN(edge_users); if (edges.first) { Curve *cu = BKE_curve_add(G.main, ob->id.name + 2, OB_CURVE); @@ -1741,7 +1731,7 @@ void BKE_mesh_from_curve(Scene *scene, Object *ob) ob->type = OB_CURVE; /* curve objects can't contain DM in usual cases, we could free memory */ - needsFree = 1; + needsFree = true; } dm->needsFree = needsFree; -- cgit v1.2.3 From 7626101dc9749a3c6066a0f51720d9953b8b3c69 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Mar 2013 18:44:32 +0000 Subject: split up BKE_mesh_to_curve() into 2 functions, adding BKE_mesh_to_curve_ex() which doesn't do object type conversion. --- source/blender/blenkernel/intern/mesh.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 604a273efc5..1b2af2fb501 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1586,11 +1586,8 @@ static void appendPolyLineVert(ListBase *lb, unsigned int index) BLI_addtail(lb, vl); } -void BKE_mesh_to_curve(Scene *scene, Object *ob) +void BKE_mesh_to_curve_ex(DerivedMesh *dm, ListBase *nurblist) { - /* make new mesh data from the original copy */ - DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH); - MVert *mverts = dm->getVertArray(dm); MEdge *med, *medge = dm->getEdgeArray(dm); MPoly *mp, *mpoly = dm->getPolyArray(dm); @@ -1600,7 +1597,6 @@ void BKE_mesh_to_curve(Scene *scene, Object *ob) int totpoly = dm->getNumPolys(dm); int totedges = 0; int i; - bool needsFree = false; /* only to detect edge polylines */ int *edge_users; @@ -1632,9 +1628,6 @@ void BKE_mesh_to_curve(Scene *scene, Object *ob) MEM_freeN(edge_users); if (edges.first) { - Curve *cu = BKE_curve_add(G.main, ob->id.name + 2, OB_CURVE); - cu->flag |= CU_3D; - while (edges.first) { /* each iteration find a polyline and add this as a nurbs poly spline */ @@ -1721,10 +1714,27 @@ void BKE_mesh_to_curve(Scene *scene, Object *ob) BLI_freelistN(&polyline); /* add nurb to curve */ - BLI_addtail(&cu->nurb, nu); + BLI_addtail(nurblist, nu); } /* --- done with nurbs --- */ } + } +} + +void BKE_mesh_to_curve(Scene *scene, Object *ob) +{ + /* make new mesh data from the original copy */ + DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH); + ListBase nurblist = {NULL, NULL}; + bool needsFree = false; + + BKE_mesh_to_curve_ex(dm, &nurblist); + + if (nurblist.first) { + Curve *cu = BKE_curve_add(G.main, ob->id.name + 2, OB_CURVE); + cu->flag |= CU_3D; + + cu->nurb = nurblist; ((Mesh *)ob->data)->id.us--; ob->data = cu; -- cgit v1.2.3 From 9d5c3264da1a2f0639777366682c4c13d9d83122 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 15 Mar 2013 09:32:59 +0000 Subject: Skip doing frame undistortion if it's not needed for proxies. --- source/blender/blenkernel/intern/movieclip.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 5519edca7ff..ab42d86152d 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1270,6 +1270,9 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct Movi ImBuf *ibuf; MovieClipUser user; + if (!build_count) + return; + user.framenr = cfra; user.render_flag = 0; user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL; -- cgit v1.2.3 From 99ee23aec5f50f36fc39c37a795a504540cfb177 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Fri, 15 Mar 2013 09:48:51 +0000 Subject: Support for rake in 2D image painting. --- source/blender/blenkernel/intern/brush.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index d341a2c06e1..6adcdbd2c3e 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -565,15 +565,37 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br, /* Brush Sampling for 2D brushes. when we unify the brush systems this will be necessarily a separate function */ float BKE_brush_sample_tex_2D(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], struct ImagePool *pool) { + UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; MTex *mtex = &brush->mtex; if (mtex && mtex->tex) { float co[3], tin, tr, tg, tb, ta; + float x = xy[0], y = xy[1]; int hasrgb; - const int radius = BKE_brush_size_get(scene, brush); + int radius = BKE_brush_size_get(scene, brush); + float rotation = -mtex->rot; + + if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { + rotation += ups->brush_rotation; + radius = ups->pixel_radius; + } + + x /= radius; + y /= radius; + + if (rotation > 0.001f || rotation < -0.001f) { + const float angle = atan2f(y, x) + rotation; + const float flen = sqrtf(x * x + y * y); + + x = flen * cosf(angle); + y = flen * sinf(angle); + } + + x *= brush->mtex.size[0]; + y *= brush->mtex.size[1]; - co[0] = xy[0] / radius; - co[1] = xy[1] / radius; + co[0] = x + brush->mtex.ofs[0]; + co[1] = y + brush->mtex.ofs[1]; co[2] = 0.0f; hasrgb = externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, 0, pool); -- cgit v1.2.3 From 0807c976f45f81bc289aa87e1c8cedd07f8245c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Mar 2013 10:48:48 +0000 Subject: code cleanup: rename BKE_mesh_to_curve_ex --> BKE_mesh_to_curve_nurblist, also correct odd indentation. --- source/blender/blenkernel/intern/cloth.c | 2 +- source/blender/blenkernel/intern/image.c | 2 +- source/blender/blenkernel/intern/mesh.c | 8 +++----- source/blender/blenkernel/intern/rigidbody.c | 6 +++--- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/softbody.c | 18 +++++++++--------- 6 files changed, 18 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 77ea856d73c..a7311d5efc7 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -788,7 +788,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) verts->goal = powf(verts->goal, 4.0f); if ( verts->goal >= SOFTGOALSNAP ) - verts->flags |= CLOTH_VERT_FLAG_PINNED; + verts->flags |= CLOTH_VERT_FLAG_PINNED; } if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index cad9e8cfbc6..c27f5e62520 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1946,7 +1946,7 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) else if (imtype == R_IMF_IMTYPE_DPX) { ibuf->ftype = DPX; if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) { - ibuf->ftype |= CINEON_LOG; + ibuf->ftype |= CINEON_LOG; } if (imf->depth == R_IMF_CHAN_DEPTH_16) { ibuf->ftype |= CINEON_16BIT; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 1b2af2fb501..f48e7856959 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1586,7 +1586,7 @@ static void appendPolyLineVert(ListBase *lb, unsigned int index) BLI_addtail(lb, vl); } -void BKE_mesh_to_curve_ex(DerivedMesh *dm, ListBase *nurblist) +void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int edge_users_test) { MVert *mverts = dm->getVertArray(dm); MEdge *med, *medge = dm->getEdgeArray(dm); @@ -1616,10 +1616,8 @@ void BKE_mesh_to_curve_ex(DerivedMesh *dm, ListBase *nurblist) /* create edges from all faces (so as to find edges not in any faces) */ med = medge; for (i = 0; i < totedge; i++, med++) { - if (edge_users[i] == 0) { + if (edge_users[i] == edge_users_test) { EdgeLink *edl = MEM_callocN(sizeof(EdgeLink), "EdgeLink"); - - // BLI_edgehash_insert(eh_edge, med->v1, med->v2, NULL); edl->edge = med; BLI_addtail(&edges, edl); totedges++; @@ -1728,7 +1726,7 @@ void BKE_mesh_to_curve(Scene *scene, Object *ob) ListBase nurblist = {NULL, NULL}; bool needsFree = false; - BKE_mesh_to_curve_ex(dm, &nurblist); + BKE_mesh_to_curve_nurblist(dm, &nurblist, 0); if (nurblist.first) { Curve *cu = BKE_curve_add(G.main, ob->id.name + 2, OB_CURVE); diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index f9bd202d64f..bccc6f9a93b 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -637,12 +637,12 @@ void BKE_rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, shor RB_constraint_set_limits_6dof(rbc->physics_constraint, RB_LIMIT_ANG_Z, 0.0f, -1.0f); break; case RBC_TYPE_MOTOR: - rbc->physics_constraint = RB_constraint_new_motor(loc, rot, rb1, rb2); + rbc->physics_constraint = RB_constraint_new_motor(loc, rot, rb1, rb2); - RB_constraint_set_enable_motor(rbc->physics_constraint, rbc->flag & RBC_FLAG_USE_MOTOR_LIN, rbc->flag & RBC_FLAG_USE_MOTOR_ANG); + RB_constraint_set_enable_motor(rbc->physics_constraint, rbc->flag & RBC_FLAG_USE_MOTOR_LIN, rbc->flag & RBC_FLAG_USE_MOTOR_ANG); RB_constraint_set_max_impulse_motor(rbc->physics_constraint, rbc->motor_lin_max_impulse, rbc->motor_ang_max_impulse); RB_constraint_set_target_velocity_motor(rbc->physics_constraint, rbc->motor_lin_target_velocity, rbc->motor_ang_target_velocity); - break; + break; } } else { /* can't create constraint without both rigid bodies */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f2e81f0d6a4..9b276912087 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -4072,7 +4072,7 @@ Sequence *BKE_sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoad if (sound == NULL || sound->playback_handle == NULL) { #if 0 - if (op) + if (op) BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); #endif diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 01d4696de94..8e5e0da20f9 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -200,18 +200,18 @@ static float sb_time_scale(Object *ob) SoftBody *sb= ob->soft; /* is supposed to be there */ if (sb) { return(sb->physics_speed); - /*hrms .. this could be IPO as well :) - estimated range [0.001 sluggish slug - 100.0 very fast (i hope ODE solver can handle that)] - 1 approx = a unit 1 pendulum at g = 9.8 [earth conditions] has period 65 frames - theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM) + /* hrms .. this could be IPO as well :) + * estimated range [0.001 sluggish slug - 100.0 very fast (i hope ODE solver can handle that)] + * 1 approx = a unit 1 pendulum at g = 9.8 [earth conditions] has period 65 frames + * theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM) */ } return (1.0f); /* - this would be frames/sec independent timing assuming 25 fps is default - but does not work very well with NLA - return (25.0f/scene->r.frs_sec) - */ + * this would be frames/sec independent timing assuming 25 fps is default + * but does not work very well with NLA + * return (25.0f/scene->r.frs_sec) + */ } /*--- frame based timing ---*/ @@ -1305,7 +1305,7 @@ static int sb_detect_face_collisionCached(float face_v1[3], float face_v2[3], fl normalize_v3(d_nvect); if ( /* isect_line_tri_v3(nv1, nv3, face_v1, face_v2, face_v3, &t, NULL) || - we did that edge already */ + * we did that edge already */ isect_line_tri_v3(nv3, nv4, face_v1, face_v2, face_v3, &t, NULL) || isect_line_tri_v3(nv4, nv1, face_v1, face_v2, face_v3, &t, NULL) ) { Vec3PlusStVec(force, -0.5f, d_nvect); -- cgit v1.2.3 From 6dc4ea34e44ae77125918ab9eda0fcfe7d9f0b3c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 15 Mar 2013 11:59:46 +0000 Subject: Multi-threaded frame calculation for movie clip proxies This commit implements multi-threaded calculation of frames when building proxies. Both scaling and undistortion steps are now threaded. Frames and proxy resolution are still handled one-by-one, saving files after every single step. So if HDD is not so fast, this commit could have not so much benefit. Internal changes: - Added IMB_scaleImBuf_threaded which scales given image buffer in multiple threads and uses bilinear filtering. - libmv's camera intrinsics now have SetThreads() method which is used to specify how many OpenMP threads to use for buffer distortion/undistortion. And yeah, this code is using OpenMP for threading. - Reshuffled a bit libmv-capi calls and added function BKE_tracking_distortion_set_threads to specify number of threads used by intrinscis. --- source/blender/blenkernel/intern/movieclip.c | 2 +- source/blender/blenkernel/intern/tracking.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index ab42d86152d..1ad0bf1988c 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1244,7 +1244,7 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i scaleibuf = IMB_dupImBuf(ibuf); - IMB_scaleImBuf(scaleibuf, (short)rectx, (short)recty); + IMB_scaleImBuf_threaded(scaleibuf, (short)rectx, (short)recty); quality = clip->proxy.quality; scaleibuf->ftype = JPG | quality; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 5f8e25af2ee..3100917cd0c 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1462,6 +1462,8 @@ MovieDistortion *BKE_tracking_distortion_new(void) distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create"); + distortion->intrinsics = libmv_CameraIntrinsicsNewEmpty(); + return distortion; } @@ -1474,12 +1476,7 @@ void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking * cameraIntrinscisOptionsFromTracking(&camera_intrinsics_options, tracking, calibration_width, calibration_height); - if (!distortion->intrinsics) { - distortion->intrinsics = libmv_CameraIntrinsicsNew(&camera_intrinsics_options); - } - else { - libmv_CameraIntrinsicsUpdate(distortion->intrinsics, &camera_intrinsics_options); - } + libmv_CameraIntrinsicsUpdate(distortion->intrinsics, &camera_intrinsics_options); #else (void) distortion; (void) tracking; @@ -1488,6 +1485,16 @@ void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking * #endif } +void BKE_tracking_distortion_set_threads(MovieDistortion *distortion, int threads) +{ +#ifdef WITH_LIBMV + libmv_CameraIntrinsicsSetThreads(distortion->intrinsics, threads); +#else + (void) distortion; + (void) threads; +#endif +} + MovieDistortion *BKE_tracking_distortion_copy(MovieDistortion *distortion) { MovieDistortion *new_distortion; -- cgit v1.2.3 From 630798ba3c47ee8d1cead13ee0494b9645f139f7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Mar 2013 15:47:32 +0000 Subject: add in ifdef for WITH_LIBMV, correct own error passing float[2] as float[3] --- source/blender/blenkernel/intern/tracking.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 3100917cd0c..df10d1374bb 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1462,7 +1462,9 @@ MovieDistortion *BKE_tracking_distortion_new(void) distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create"); +#ifdef WITH_LIBMV distortion->intrinsics = libmv_CameraIntrinsicsNewEmpty(); +#endif return distortion; } -- cgit v1.2.3 From 08a8d11216053855460fdf54a88e33d88400a985 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 15 Mar 2013 16:57:19 +0000 Subject: Further improvement for multi-threaded proxies Handle sequences in a special case for dealing with sequence sources. Namely handle separate frames in separate threads, but do disk read from a critical section since HDD is not so friendly with lots threads requesting for data from it. Makes proxy building much faster than it was before. --- source/blender/blenkernel/intern/movieclip.c | 51 ++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 1ad0bf1988c..e79754ca203 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1230,7 +1230,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip scopes->ok = TRUE; } -static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, int proxy_render_size, int undistorted) +static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, int proxy_render_size, int undistorted, bool threaded) { char name[FILE_MAX]; int quality, rectx, recty; @@ -1244,7 +1244,10 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i scaleibuf = IMB_dupImBuf(ibuf); - IMB_scaleImBuf_threaded(scaleibuf, (short)rectx, (short)recty); + if (threaded) + IMB_scaleImBuf_threaded(scaleibuf, (short)rectx, (short)recty); + else + IMB_scaleImBuf(scaleibuf, (short)rectx, (short)recty); quality = clip->proxy.quality; scaleibuf->ftype = JPG | quality; @@ -1253,6 +1256,10 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i if (scaleibuf->planes == 32) scaleibuf->planes = 24; + /* TODO: currently the most weak part of multithreaded proxies, + * could be solved in a way that thread only prepares memory + * buffer and write to disk happens separately + */ BLI_lock_thread(LOCK_MOVIECLIP); BLI_make_existing_file(name); @@ -1264,6 +1271,9 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i IMB_freeImBuf(scaleibuf); } +/* note: currently used by proxy job for movies, threading happens within single frame + * (meaning scaling shall be threaded) + */ void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct MovieDistortion *distortion, int cfra, int *build_sizes, int build_count, int undistorted) { @@ -1287,7 +1297,7 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct Movi tmpibuf = get_undistorted_ibuf(clip, distortion, ibuf); for (i = 0; i < build_count; i++) - movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted); + movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted, true); IMB_freeImBuf(ibuf); @@ -1296,6 +1306,30 @@ void BKE_movieclip_build_proxy_frame(MovieClip *clip, int clip_flag, struct Movi } } +/* note: currently used by proxy job for sequences, threading happens within sequence + * (different threads handles different frames, no threading within frame is needed) + */ +void BKE_movieclip_build_proxy_frame_for_ibuf(MovieClip *clip, ImBuf *ibuf, struct MovieDistortion *distortion, + int cfra, int *build_sizes, int build_count, int undistorted) +{ + if (!build_count) + return; + + if (ibuf) { + ImBuf *tmpibuf = ibuf; + int i; + + if (undistorted) + tmpibuf = get_undistorted_ibuf(clip, distortion, ibuf); + + for (i = 0; i < build_count; i++) + movieclip_build_proxy_ibuf(clip, tmpibuf, cfra, build_sizes[i], undistorted, false); + + if (tmpibuf != ibuf) + IMB_freeImBuf(tmpibuf); + } +} + void BKE_movieclip_free(MovieClip *clip) { BKE_sequencer_clear_movieclip_in_clipboard(clip); @@ -1384,3 +1418,14 @@ float BKE_movieclip_remap_clip_to_scene_frame(MovieClip *clip, float framenr) { return framenr + (float) clip->start_frame - 1.0f; } + +void BKE_movieclip_filename_for_frame(MovieClip *clip, int framenr, char *name) +{ + if (clip->source != MCLIP_SRC_MOVIE) { + get_sequence_fname(clip, framenr, name); + } + else { + BLI_strncpy(name, clip->name, FILE_MAX); + BLI_path_abs(name, ID_BLEND_PATH(G.main, &clip->id)); + } +} -- cgit v1.2.3 From a0351fd97e7f0f2bea153199d4cd004d6f76f034 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Mar 2013 01:19:03 +0000 Subject: object converting curve/mball to a mesh would give invalid selection state (edges selected but nothing else). add arg to BKE_mesh_calc_edges() so selecting newly created edges is optional. --- source/blender/blenkernel/intern/mesh.c | 4 ++-- source/blender/blenkernel/intern/mesh_validate.c | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index f48e7856959..1d79c7afe43 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1198,7 +1198,7 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me) BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); - BKE_mesh_calc_edges(me, TRUE); + BKE_mesh_calc_edges(me, true, false); } } @@ -1523,7 +1523,7 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, int use_orco_u BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); - BKE_mesh_calc_edges(me, TRUE); + BKE_mesh_calc_edges(me, true, false); } else { me = BKE_mesh_add(G.main, "Mesh"); diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 74d3645ea66..9d16d38220a 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -774,7 +774,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } if (do_edge_recalc) { - BKE_mesh_calc_edges(mesh, TRUE); + BKE_mesh_calc_edges(mesh, true, false); } } @@ -914,7 +914,7 @@ int BKE_mesh_validate_dm(DerivedMesh *dm) * \param mesh The mesh to add edges into * \param update When true create new edges co-exist */ -void BKE_mesh_calc_edges(Mesh *mesh, int update) +void BKE_mesh_calc_edges(Mesh *mesh, bool update, const bool select) { CustomData edata; EdgeHashIterator *ehi; @@ -923,9 +923,11 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update) EdgeHash *eh = BLI_edgehash_new(); int i, totedge, totpoly = mesh->totpoly; int med_index; + /* select for newly created meshes which are selected [#25595] */ + const short ed_flag = (ME_EDGEDRAW | ME_EDGERENDER) | (select ? SELECT : 0); if (mesh->totedge == 0) - update = FALSE; + update = false; if (update) { /* assume existing edges are valid @@ -963,7 +965,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update) } else { BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2); - med->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT; /* select for newly created meshes which are selected [#25595] */ + med->flag = ed_flag; } /* store the new edge index in the hash value */ -- cgit v1.2.3 From 7ec47aa8642e67b46cd3d0f19360433222d9ee47 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Mar 2013 14:33:32 +0000 Subject: code cleanup: shadowing --- source/blender/blenkernel/intern/DerivedMesh.c | 14 +++++++------- source/blender/blenkernel/intern/mesh.c | 14 +++++++------- source/blender/blenkernel/intern/subsurf_ccg.c | 3 +-- 3 files changed, 15 insertions(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index cdcd184c2ec..f09de138428 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1116,12 +1116,12 @@ static void calc_weightpaint_vert_color( } } -static DMWeightColorInfo dm_wcinfo; +static DMWeightColorInfo G_dm_wcinfo; void vDM_ColorBand_store(const ColorBand *coba, const char alert_color[4]) { - dm_wcinfo.coba = coba; - dm_wcinfo.alert_color = alert_color; + G_dm_wcinfo.coba = coba; + G_dm_wcinfo.alert_color = alert_color; } /* return an array of vertex weight colors, caller must free. @@ -1219,10 +1219,10 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag, if (indices) MEM_freeN(w); } - - /* No weights given, take them from active vgroup(s). */ - else - wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, &dm_wcinfo); + else { + /* No weights given, take them from active vgroup(s). */ + wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, &G_dm_wcinfo); + } /* now add to loops, so the data can be passed through the modifier stack */ /* If no CD_PREVIEW_MLOOPCOL existed yet, we have to add a new one! */ diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 1d79c7afe43..b4833cdb53b 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1588,13 +1588,13 @@ static void appendPolyLineVert(ListBase *lb, unsigned int index) void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int edge_users_test) { - MVert *mverts = dm->getVertArray(dm); + MVert *mvert = dm->getVertArray(dm); MEdge *med, *medge = dm->getEdgeArray(dm); MPoly *mp, *mpoly = dm->getPolyArray(dm); MLoop *mloop = dm->getLoopArray(dm); - int totedge = dm->getNumEdges(dm); - int totpoly = dm->getNumPolys(dm); + int dm_totedge = dm->getNumEdges(dm); + int dm_totpoly = dm->getNumPolys(dm); int totedges = 0; int i; @@ -1604,8 +1604,8 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e ListBase edges = {NULL, NULL}; /* get boundary edges */ - edge_users = MEM_callocN(sizeof(int) * totedge, __func__); - for (i = 0, mp = mpoly; i < totpoly; i++, mp++) { + edge_users = MEM_callocN(sizeof(int) * dm_totedge, __func__); + for (i = 0, mp = mpoly; i < dm_totpoly; i++, mp++) { MLoop *ml = &mloop[mp->loopstart]; int j; for (j = 0; j < mp->totloop; j++, ml++) { @@ -1615,7 +1615,7 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e /* create edges from all faces (so as to find edges not in any faces) */ med = medge; - for (i = 0; i < totedge; i++, med++) { + for (i = 0; i < dm_totedge; i++, med++) { if (edge_users[i] == edge_users_test) { EdgeLink *edl = MEM_callocN(sizeof(EdgeLink), "EdgeLink"); edl->edge = med; @@ -1705,7 +1705,7 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e /* add points */ vl = polyline.first; for (i = 0, bp = nu->bp; i < totpoly; i++, bp++, vl = (VertLink *)vl->next) { - copy_v3_v3(bp->vec, mverts[vl->index].co); + copy_v3_v3(bp->vec, mvert[vl->index].co); bp->f1 = SELECT; bp->radius = bp->weight = 1.0; } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 6dd1786a38b..d38a2e56819 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -3103,7 +3103,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, int numTex, numCol; int hasPCol, hasOrigSpace; int gridInternalEdges; - float *w = NULL; WeightTable wtable = {0}; /* MCol *mcol; */ /* UNUSED */ MEdge *medge = NULL; @@ -3291,7 +3290,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, int numFinalEdges = numVerts * (gridSideEdges + gridInternalEdges); int origIndex = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f)); int g2_wid = gridCuts + 2; - float *w2; + float *w, *w2; int s, x, y; w = get_ss_weights(&wtable, gridCuts, numVerts); -- cgit v1.2.3 From 0fedc6e45bdcb2b159b9ab54267d70c0bb59dd72 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 16 Mar 2013 18:22:45 +0000 Subject: Stop dyntopo updates from happening in masked areas Fixes [#34348] Collapse short edges affects masked geometry /projects.blender.org/tracker/?func=detail&aid=34348&group_id=9&atid=498 Fixed by disallowing topology updates on edges with a vertex masked at 50% or greater. This is a necessarily arbitrary choice; can't do halfway updates for topology like we can with displacement. --- source/blender/blenkernel/intern/pbvh_bmesh.c | 51 +++++++++++++++++---------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index 9290a8a7163..bb4a3762de1 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -490,35 +490,50 @@ static int edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f) return ((len_squared_v3v3(q->center, c) <= q->radius_squared)); } +/* Return true if the vertex mask is less than 0.5, false otherwise */ +static int check_mask_half(BMesh *bm, BMVert *v) +{ + const float *mask; + + mask = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_PAINT_MASK); + return ((*mask) < 0.5); +} + static void edge_queue_insert(EdgeQueue *q, BLI_mempool *pool, BMEdge *e, - float priority) + float priority, BMesh *bm) { BMVert **pair; - pair = BLI_mempool_alloc(pool); - pair[0] = e->v1; - pair[1] = e->v2; - BLI_heap_insert(q->heap, priority, pair); + /* Don't let topology update affect masked vertices. Unlike with + * displacements, can't do 50% topology update, so instead set + * (arbitrary) cutoff: if both vertices' masks are less than 50%, + * topology update can happen. */ + if (check_mask_half(bm, e->v1) && check_mask_half(bm, e->v2)) { + pair = BLI_mempool_alloc(pool); + pair[0] = e->v1; + pair[1] = e->v2; + BLI_heap_insert(q->heap, priority, pair); + } } static void long_edge_queue_edge_add(EdgeQueue *q, BLI_mempool *pool, - BMEdge *e) + BMEdge *e, BMesh *bm) { const float len_sq = BM_edge_calc_length_squared(e); if (len_sq > q->limit_len_squared) - edge_queue_insert(q, pool, e, 1.0f / len_sq); + edge_queue_insert(q, pool, e, 1.0f / len_sq, bm); } static void short_edge_queue_edge_add(EdgeQueue *q, BLI_mempool *pool, - BMEdge *e) + BMEdge *e, BMesh *bm) { const float len_sq = BM_edge_calc_length_squared(e); if (len_sq < q->limit_len_squared) - edge_queue_insert(q, pool, e, len_sq); + edge_queue_insert(q, pool, e, len_sq, bm); } static void long_edge_queue_face_add(EdgeQueue *q, BLI_mempool *pool, - BMFace *f) + BMFace *f, BMesh *bm) { if (edge_queue_tri_in_sphere(q, f)) { BMLoop *l_iter; @@ -527,13 +542,13 @@ static void long_edge_queue_face_add(EdgeQueue *q, BLI_mempool *pool, /* Check each edge of the face */ l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { - long_edge_queue_edge_add(q, pool, l_iter->e); + long_edge_queue_edge_add(q, pool, l_iter->e, bm); } while ((l_iter = l_iter->next) != l_first); } } static void short_edge_queue_face_add(EdgeQueue *q, BLI_mempool *pool, - BMFace *f) + BMFace *f, BMesh *bm) { if (edge_queue_tri_in_sphere(q, f)) { BMLoop *l_iter; @@ -542,7 +557,7 @@ static void short_edge_queue_face_add(EdgeQueue *q, BLI_mempool *pool, /* Check each edge of the face */ l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { - short_edge_queue_edge_add(q, pool, l_iter->e); + short_edge_queue_edge_add(q, pool, l_iter->e, bm); } while ((l_iter = l_iter->next) != l_first); } } @@ -580,7 +595,7 @@ static void long_edge_queue_create(EdgeQueue *q, BLI_mempool *pool, GHASH_ITER (gh_iter, node->bm_faces) { BMFace *f = BLI_ghashIterator_getKey(&gh_iter); - long_edge_queue_face_add(q, pool, f); + long_edge_queue_face_add(q, pool, f, bvh->bm); } } } @@ -619,7 +634,7 @@ static void short_edge_queue_create(EdgeQueue *q, BLI_mempool *pool, GHASH_ITER (gh_iter, node->bm_faces) { BMFace *f = BLI_ghashIterator_getKey(&gh_iter); - short_edge_queue_face_add(q, pool, f); + short_edge_queue_face_add(q, pool, f, bvh->bm); } } } @@ -674,9 +689,9 @@ static void pbvh_bmesh_split_edge(PBVH *bvh, EdgeQueue *q, BLI_mempool *pool, /* Create two new faces */ f_new = pbvh_bmesh_face_create(bvh, ni, v1, v_new, opp, f_adj); - long_edge_queue_face_add(q, pool, f_new); + long_edge_queue_face_add(q, pool, f_new, bvh->bm); f_new = pbvh_bmesh_face_create(bvh, ni, v_new, v2, opp, f_adj); - long_edge_queue_face_add(q, pool, f_new); + long_edge_queue_face_add(q, pool, f_new, bvh->bm); /* Delete original */ pbvh_bmesh_face_remove(bvh, f_adj); @@ -694,7 +709,7 @@ static void pbvh_bmesh_split_edge(PBVH *bvh, EdgeQueue *q, BLI_mempool *pool, BMEdge *e2; BM_ITER_ELEM (e2, &bm_iter, opp, BM_EDGES_OF_VERT) { - long_edge_queue_edge_add(q, pool, e2); + long_edge_queue_edge_add(q, pool, e2, bvh->bm); } } } -- cgit v1.2.3 From baf3bb37a9b9322752add6c5b8031aadf96119ac Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Mar 2013 20:49:46 +0000 Subject: - ghost-sdl builds again. - without python builds without warnings. - replace MAXFLOAT -> FLT_MAX in some areas, MAXFLOAT overflows (lager then float range). - add cmake option WITH_GCC_MUDFLAP to enable libmudflap use. --- source/blender/blenkernel/intern/customdata.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index e43f8312f39..1cefd65bbc5 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -195,7 +195,7 @@ static void layerCopy_bmesh_elem_py_ptr(const void *UNUSED(source), void *dest, } #ifndef WITH_PYTHON -void bpy_bm_generic_invalidate(void *UNUSED(self)) +void bpy_bm_generic_invalidate(struct BPy_BMGeneric *UNUSED(self)) { /* dummy */ } @@ -203,8 +203,6 @@ void bpy_bm_generic_invalidate(void *UNUSED(self)) static void layerFree_bmesh_elem_py_ptr(void *data, int count, int size) { - extern void bpy_bm_generic_invalidate(void *self); - int i; for (i = 0; i < count; ++i) { -- cgit v1.2.3 From 0d0291f6e18a2b8357053bf8166220464beab138 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Mar 2013 10:26:23 +0000 Subject: code cleanup: incorrect sized array args, remove some redundant code. --- source/blender/blenkernel/intern/anim.c | 10 +++------- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/bmfont.c | 2 +- source/blender/blenkernel/intern/mball.c | 2 +- source/blender/blenkernel/intern/navmesh_conversion.c | 2 +- source/blender/blenkernel/intern/pbvh_bmesh.c | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 4eb26e81ae2..ddb4cc4391a 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1154,10 +1154,6 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ for (a = 0, mp = mpoly; a < totface; a++, mp++) { - int mv1; - int mv2; - int mv3; - /* int mv4; */ /* UNUSED */ float *v1; float *v2; float *v3; @@ -1171,9 +1167,9 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa } else { BKE_mesh_calc_poly_normal(mp, mloop + mp->loopstart, mvert, f_no); - v1 = mvert[(mv1 = loopstart[0].v)].co; - v2 = mvert[(mv2 = loopstart[1].v)].co; - v3 = mvert[(mv3 = loopstart[2].v)].co; + v1 = mvert[loopstart[0].v].co; + v2 = mvert[loopstart[1].v].co; + v3 = mvert[loopstart[2].v].co; } /* translation */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 480814a28c3..ffe6a312ef8 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1596,7 +1596,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected } else if (pchan->bone->layer & layer_protected) { ListBase proxylocal_constraints = {NULL, NULL}; - bPoseChannel pchanw = {NULL}; + bPoseChannel pchanw; /* copy posechannel to temp, but restore important pointers */ pchanw = *pchanp; diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index e82a2a53b7d..78da4f5b1c2 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -198,7 +198,7 @@ void detectBitmapFont(ImBuf *ibuf) readBitmapFontVersion0(ibuf, rect, 4); } else { - printf("detectBitmapFont :Unsupported version %d\n", version); + printf("detectBitmapFont :Unsupported version %d\n", (int)version); } /* on succes ibuf->userdata points to the bitmapfont */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 925040940f8..72284130869 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1501,7 +1501,7 @@ static void add_cube(PROCESS *mbproc, int i, int j, int k, int count) static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) { MetaElem *ml; - float f = 0.0f; + float f; ml = G_mb.mainb[a]; f = 1.0f - (mb->thresh / ml->s); diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c index 3bf5f863557..1d662ae3116 100644 --- a/source/blender/blenkernel/intern/navmesh_conversion.c +++ b/source/blender/blenkernel/intern/navmesh_conversion.c @@ -436,7 +436,7 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly, unsigned short **polys, int **dtrisToPolysMap, int **dtrisToTrisMap, int **trisToFacesMap) { - int res = 1; + int res; int ntris = 0, *recastData = NULL; unsigned short *tris = NULL; diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index bb4a3762de1..0ca73b92071 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -496,7 +496,7 @@ static int check_mask_half(BMesh *bm, BMVert *v) const float *mask; mask = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_PAINT_MASK); - return ((*mask) < 0.5); + return ((*mask) < 0.5f); } static void edge_queue_insert(EdgeQueue *q, BLI_mempool *pool, BMEdge *e, -- cgit v1.2.3