diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-16 23:06:38 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-16 23:06:38 +0400 |
commit | 9d05ccf9e84510ca7e3fe140f6e20991a931b8ce (patch) | |
tree | f8f7241b779c9049d853a5e824db2dd150228ebe | |
parent | 707fcc42a390e91aedd858588c30d04fea43f0e6 (diff) | |
parent | 1af839081b7adcc3ceb13e5e7cc579b309e90915 (diff) |
svn merge -r41899:41926 ^/trunk/blender. also sync mempool with trunk and move BLI_mempool_alloc out of mempools header where it was inlined
42 files changed, 357 insertions, 358 deletions
diff --git a/build_files/cmake/Modules/FindPythonLibsUnix.cmake b/build_files/cmake/Modules/FindPythonLibsUnix.cmake index 8c3ff64d3f3..448e587e224 100644 --- a/build_files/cmake/Modules/FindPythonLibsUnix.cmake +++ b/build_files/cmake/Modules/FindPythonLibsUnix.cmake @@ -139,9 +139,9 @@ IF(PYTHONLIBSUNIX_FOUND) # not used # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "") - - MARK_AS_ADVANCED( - PYTHON_INCLUDE_DIR - PYTHON_LIBRARY - ) ENDIF() + +MARK_AS_ADVANCED( + PYTHON_INCLUDE_DIR + PYTHON_LIBRARY +) diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index a89bcd01523..07ffa659437 100755 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -89,7 +89,7 @@ def create_qtc_project_main(): f = open(os.path.join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w') f.write("\n".join(files_rel)) - f = open(os.path.join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w') + f = open(os.path.join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w', encoding='utf-8') f.write("\n".join(sorted(includes))) qtc_prj = os.path.join(PROJECT_DIR, "%s.creator" % FILE_NAME) @@ -104,7 +104,7 @@ def create_qtc_project_main(): defines_final += cmake_compiler_defines() f.write("\n".join(defines_final)) - print("Blender project file written to: %s" % qtc_prj) + print("Blender project file written to: %r" % qtc_prj) # --- end @@ -133,7 +133,7 @@ def create_qtc_project_python(): f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") - print("Python project file written to: %s" % qtc_prj) + print("Python project file written to: %r" % qtc_prj) def main(): diff --git a/build_files/cmake/project_info.py b/build_files/cmake/project_info.py index eed002ce7ba..0b922979a63 100755 --- a/build_files/cmake/project_info.py +++ b/build_files/cmake/project_info.py @@ -186,7 +186,7 @@ def cmake_advanced_info(): def cmake_cache_var(var): - cache_file = open(join(CMAKE_DIR, "CMakeCache.txt")) + cache_file = open(join(CMAKE_DIR, "CMakeCache.txt"), encoding='utf-8') lines = [l_strip for l in cache_file for l_strip in (l.strip(),) if l_strip if not l_strip.startswith("//") if not l_strip.startswith("#")] cache_file.close() diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp index 9d6cfd5d17a..8c453944e9d 100644 --- a/extern/libmv/libmv-capi.cpp +++ b/extern/libmv/libmv-capi.cpp @@ -368,14 +368,11 @@ libmv_Reconstruction *libmv_solveReconstruction(libmv_Tracks *tracks, int keyfra intrinsics->SetPrincipalPoint(principal_x, principal_y); intrinsics->SetRadialDistortion(k1, k2, k3); - if(focal_length) { - /* do a lens undistortion if focal length is non-zero only */ - for (int i = 0; i < markers.size(); ++i) { - intrinsics->InvertIntrinsics(markers[i].x, - markers[i].y, - &(markers[i].x), - &(markers[i].y)); - } + for (int i = 0; i < markers.size(); ++i) { + intrinsics->InvertIntrinsics(markers[i].x, + markers[i].y, + &(markers[i].x), + &(markers[i].y)); } libmv::Tracks normalized_tracks(markers); diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt index f3da1a30eb2..ea46911ce16 100644 --- a/intern/cycles/blender/CMakeLists.txt +++ b/intern/cycles/blender/CMakeLists.txt @@ -1,4 +1,11 @@ +set(BLENDER_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/intern/guardedalloc + ${CMAKE_SOURCE_DIR}/source/blender/makesdna + ${CMAKE_SOURCE_DIR}/source/blender/makesrna + ${CMAKE_SOURCE_DIR}/source/blender/blenloader + ${CMAKE_BINARY_DIR}/source/blender/makesrna/intern) + set(INC ../render ../device diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index d96efe93cf8..00010bb7463 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -459,7 +459,7 @@ class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): - world = context.world + # world = context.world return False # world and world.node_tree and CyclesButtonsPanel.poll(context) def draw(self, context): @@ -493,7 +493,7 @@ class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): - mat = context.material + # mat = context.material return False # mat and mat.node_tree and CyclesButtonsPanel.poll(context) def draw(self, context): @@ -562,7 +562,7 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel): pin_id = space.pin_id use_pin_id = space.use_pin_id user = context.texture_user - node = context.texture_node + # node = context.texture_node if not use_pin_id or not isinstance(pin_id, bpy.types.Texture): pin_id = None @@ -638,7 +638,7 @@ class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel): def draw(self, context): layout = self.layout - tex = context.texture + # tex = context.texture node = context.texture_node mapping = node.texture_mapping @@ -664,15 +664,15 @@ class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): - tex = context.texture - node = context.texture_node + # tex = context.texture + # node = context.texture_node return False #return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context) def draw(self, context): layout = self.layout - tex = context.texture + # tex = context.texture node = context.texture_node mapping = node.color_mapping diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index c5cceff6242..ff6d55c6f3e 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -176,7 +176,13 @@ static inline string get_enum_identifier(PointerRNA& ptr, const char *name) static inline string blender_absolute_path(BL::BlendData b_data, BL::ID b_id, const string& path) { if(path.size() >= 2 && path[0] == '/' && path[1] == '/') { - string dirname = (b_id.library())? b_id.library().filepath(): b_data.filepath(); + string dirname; + + if(b_id.library()) + dirname = blender_absolute_path(b_data, b_id.library(), b_id.library().filepath()); + else + dirname = b_data.filepath(); + return path_join(path_dirname(dirname), path.substr(2)); } diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index e6d0fbb99a2..4173d71b39c 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -154,25 +154,23 @@ def resolve_ncase(path): returning a string with the path if found else return the original path. """ - import os - def _ncase_path_found(path): - if not path or os.path.exists(path): + if not path or _os.path.exists(path): return path, True # filename may be a directory or a file - filename = os.path.basename(path) - dirpath = os.path.dirname(path) + filename = _os.path.basename(path) + dirpath = _os.path.dirname(path) suffix = path[:0] # "" but ensure byte/str match if not filename: # dir ends with a slash? if len(dirpath) < len(path): suffix = path[:len(path) - len(dirpath)] - filename = os.path.basename(dirpath) - dirpath = os.path.dirname(dirpath) + filename = _os.path.basename(dirpath) + dirpath = _os.path.dirname(dirpath) - if not os.path.exists(dirpath): + if not _os.path.exists(dirpath): if dirpath == path: return path, False @@ -184,8 +182,8 @@ def resolve_ncase(path): # at this point, the directory exists but not the file # we are expecting 'dirpath' to be a directory, but it could be a file - if os.path.isdir(dirpath): - files = os.listdir(dirpath) + if _os.path.isdir(dirpath): + files = _os.listdir(dirpath) else: return path, False @@ -198,7 +196,7 @@ def resolve_ncase(path): break if f_iter_nocase: - return os.path.join(dirpath, f_iter_nocase) + suffix, True + return _os.path.join(dirpath, f_iter_nocase) + suffix, True else: # cant find the right one, just return the path as is. return path, False @@ -216,8 +214,7 @@ def ensure_ext(filepath, ext, case_sensitive=False): :arg case_sensitive: Check for matching case when comparing extensions. :type case_sensitive: bool """ - import os - fn_base, fn_ext = os.path.splitext(filepath) + fn_base, fn_ext = _os.path.splitext(filepath) if fn_base and fn_ext: if ((case_sensitive and ext == fn_ext) or (ext.lower() == fn_ext.lower())): diff --git a/release/scripts/presets/camera/Sony_A55.py b/release/scripts/presets/camera/Sony_A55.py index 0de8198972a..b0f172206fa 100644 --- a/release/scripts/presets/camera/Sony_A55.py +++ b/release/scripts/presets/camera/Sony_A55.py @@ -2,4 +2,3 @@ import bpy bpy.context.object.data.sensor_width = 23.4 bpy.context.object.data.sensor_height = 15.6 bpy.context.object.data.sensor_fit = 'HORIZONTAL' - diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index 091e3defbf8..d5d9684bcf3 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -36,6 +36,7 @@ def CLIP_track_view_selected(sc, track): return False + class CLIP_OT_track_to_empty(Operator): """Create an Empty object which will be copying movement of active track""" @@ -85,13 +86,8 @@ class CLIP_OT_tracks_to_mesh(Operator): @classmethod def poll(cls, context): - if context.space_data.type != 'CLIP_EDITOR': - return False - sc = context.space_data - clip = sc.clip - - return clip + return (sc.type == 'CLIP_EDITOR') and sc.clip def execute(self, context): sc = context.space_data @@ -124,6 +120,9 @@ class CLIP_OT_delete_proxy(Operator): @classmethod def poll(cls, context): + if context.space_data.type != 'CLIP_EDITOR': + return False + sc = context.space_data return sc.clip @@ -187,7 +186,8 @@ class CLIP_OT_delete_proxy(Operator): class CLIP_OT_set_viewport_background(Operator): - """Set current movie clip as a camera background in 3D viewport (works only when a 3D viewport is visible)""" + """Set current movie clip as a camera background in 3D viewport \ +(works only when a 3D viewport is visible)""" bl_idname = "clip.set_viewport_background" bl_label = "Set as Background" @@ -236,7 +236,8 @@ class CLIP_OT_set_viewport_background(Operator): class CLIP_OT_constraint_to_fcurve(Operator): - """Create F-Curves for object which will copy object's movement caused by this constraint""" + """Create F-Curves for object which will copy \ +object's movement caused by this constraint""" bl_idname = "clip.constraint_to_fcurve" bl_label = "Constraint to F-Curve" diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 8c12a6442f7..c97f6eae6c7 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -147,7 +147,7 @@ class ProjectEdit(Operator): # opengl buffer may fail, we can't help this, but best report it. try: - ret = bpy.ops.paint.image_from_view() + bpy.ops.paint.image_from_view() except RuntimeError as err: self.report({'ERROR'}, str(err)) return {'CANCELLED'} diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index aa661b76512..14c9a090529 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -106,7 +106,7 @@ def operator_path_is_undo(context, data_path): # luckily we don't do this! # # When we cant find the data owner assume no undo is needed. - data_path_head, data_path_sep, data_path_tail = data_path.rpartition(".") + data_path_head = data_path.rpartition(".")[0] if not data_path_head: return False diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py index 4e6c4063d2c..68fa0cedaa3 100644 --- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py +++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py @@ -46,7 +46,6 @@ class PHYSICS_PT_dynamic_paint(PhysicButtonsPanel, Panel): layout = self.layout md = context.dynamic_paint - ob = context.object layout.prop(md, "ui_type", expand=True) @@ -129,7 +128,6 @@ class PHYSICS_PT_dp_advanced_canvas(PhysicButtonsPanel, Panel): canvas = context.dynamic_paint.canvas_settings surface = canvas.canvas_surfaces.active - ob = context.object surface_type = surface.surface_type @@ -370,8 +368,6 @@ class PHYSICS_PT_dp_cache(PhysicButtonsPanel, Panel): md.canvas_settings.canvas_surfaces.active.is_cache_user) def draw(self, context): - layout = self.layout - surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active cache = surface.point_cache @@ -442,7 +438,6 @@ class PHYSICS_PT_dp_brush_velocity(PhysicButtonsPanel, Panel): layout = self.layout brush = context.dynamic_paint.brush_settings - ob = context.object split = layout.split() @@ -478,7 +473,6 @@ class PHYSICS_PT_dp_brush_wave(PhysicButtonsPanel, Panel): layout = self.layout brush = context.dynamic_paint.brush_settings - ob = context.object layout.prop(brush, "wave_type") if brush.wave_type != 'REFLECT': diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index c6af6bab1d1..237dd7f998d 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -54,7 +54,8 @@ class CLIP_HT_header(Header): row = layout.row(align=True) if sc.show_filters: - row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN', text="Filters") + row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN', + text="Filters") sub = row.column() sub.active = clip.tracking.reconstruction.is_valid @@ -62,7 +63,8 @@ class CLIP_HT_header(Header): row.prop(sc, "show_graph_tracks", icon='ANIM', text="") else: - row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT', text="Filters") + row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT', + text="Filters") row = layout.row() row.template_ID(sc, "clip", open='clip.open') @@ -113,7 +115,6 @@ class CLIP_PT_tools_tracking(Panel): def draw(self, context): layout = self.layout clip = context.space_data.clip - settings = clip.tracking.settings row = layout.row(align=True) @@ -639,7 +640,6 @@ class CLIP_PT_tools_clip(Panel): def draw(self, context): layout = self.layout - clip = context.space_data.clip layout.operator("clip.set_viewport_background") @@ -696,9 +696,6 @@ class CLIP_MT_proxy(Menu): def draw(self, context): layout = self.layout - sc = context.space_data - clip = sc.clip - layout.operator("clip.rebuild_proxy") layout.operator("clip.delete_proxy") @@ -719,7 +716,8 @@ class CLIP_MT_track(Menu): props = layout.operator("clip.clear_track_path", text="Clear Before") props.action = 'UPTO' - props = layout.operator("clip.clear_track_path", text="Clear Track Path") + props = layout.operator("clip.clear_track_path", + text="Clear Track Path") props.action = 'ALL' layout.separator() @@ -802,8 +800,6 @@ class CLIP_MT_select(Menu): def draw(self, context): layout = self.layout - sc = context.space_data - layout.operator("clip.select_border") layout.operator("clip.select_circle") diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 0ba0fb126e9..57eb6f4669a 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2281,12 +2281,6 @@ class VIEW3D_PT_background_image(Panel): bl_label = "Background Images" bl_options = {'DEFAULT_CLOSED'} - @classmethod - def poll(cls, context): - view = context.space_data - #~ bg = context.space_data.background_image - return (view) - def draw_header(self, context): layout = self.layout view = context.space_data @@ -2320,16 +2314,15 @@ class VIEW3D_PT_background_image(Panel): row = box.row() row.prop(bg, "source", expand=True) - hasbg = False + has_bg = False if bg.source == 'IMAGE': row = box.row() row.template_ID(bg, "image", open="image.open") if (bg.image): box.template_image(bg, "image", bg.image_user, compact=True) - hasbg = True + has_bg = True elif bg.source == 'MOVIE': - has_clip = False box.prop(bg, 'use_camera_clip') column = box.column() @@ -2340,14 +2333,14 @@ class VIEW3D_PT_background_image(Panel): column.template_movieclip(bg, "clip", compact=True) if bg.use_camera_clip or bg.clip: - hasbg = True + has_bg = True column = box.column() - column.active = hasbg + column.active = has_bg column.prop(bg.clip_user, "proxy_render_size", text="") column.prop(bg.clip_user, "use_render_undistorted") - if hasbg: + if has_bg: box.prop(bg, "opacity", slider=True) if bg.view_axis != 'CAMERA': box.prop(bg, "size") diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 16102f466da..d43f114e2af 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3235,7 +3235,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, /* Also cast a ray in opposite direction to make sure * point is at least surrounded by two brush faces */ - mul_v3_fl(ray_dir, -1.0f); + negate_v3(ray_dir); hit.index = -1; hit.dist = 9999; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 82da0e549d9..8f50fb25f45 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1913,7 +1913,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float switch(type) { case PART_KINK_CURL: { - mul_v3_fl(par_vec, -1.f); + negate_v3(par_vec); if(flat > 0.f) { float proj[3]; @@ -1979,7 +1979,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float mul_qt_v3(par_rot, z_vec); } - mul_v3_fl(par_vec, -1.f); + negate_v3(par_vec); normalize_v3_v3(vec_one, par_vec); inp_y=dot_v3v3(y_vec, vec_one); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 0caad666226..3f127c7656b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2680,7 +2680,7 @@ static float nr_signed_distance_to_plane(float *p, float radius, ParticleCollisi } if(pce->inv_nor == 1) { - mul_v3_fl(nor, -1.f); + negate_v3(nor); d = -d; } @@ -2800,7 +2800,7 @@ static void collision_point_on_surface(float p[3], ParticleCollisionElement *pce normalize_v3(nor); if(pce->inv_nor == 1) - mul_v3_fl(nor, -1.f); + negate_v3(nor); madd_v3_v3v3fl(co, pce->x0, nor, col->radius); madd_v3_v3fl(co, e1, pce->uv[0]); diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h index 54b4e5584eb..2f56bc87665 100644 --- a/source/blender/blenlib/BLI_mempool.h +++ b/source/blender/blenlib/BLI_mempool.h @@ -40,36 +40,17 @@ extern "C" #endif struct BLI_mempool; +struct BLI_mempool_chunk; -#include "BLI_listbase.h" -#include "BLI_blenlib.h" -#include <string.h> - -typedef struct BLI_freenode{ - struct BLI_freenode *next; - int freeword; /*used to identify this as a freed node*/ -}BLI_freenode; - -typedef struct BLI_mempool_chunk{ - struct BLI_mempool_chunk *next, *prev; - void *data; -}BLI_mempool_chunk; - -typedef struct BLI_mempool{ - struct ListBase chunks; - int esize, csize, pchunk; /*size of elements and chunks in bytes and number of elements per chunk*/ - BLI_freenode *free; /*free element list. Interleaved into chunk datas.*/ - int totalloc, totused; /*total number of elements allocated in total, and currently in use*/ - int use_sysmalloc, allow_iter; -}BLI_mempool; +typedef struct BLI_mempool BLI_mempool; /*allow_iter allows iteration on this mempool. note: this requires that the first four bytes of the elements never contain the character string 'free'. use with care.*/ -BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, - int use_sysmalloc, int allow_iter); -//void *BLI_mempool_alloc(BLI_mempool *pool); +struct BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, + int use_sysmalloc, int allow_iter); +void *BLI_mempool_alloc(BLI_mempool *pool); void *BLI_mempool_calloc(BLI_mempool *pool); void BLI_mempool_free(BLI_mempool *pool, void *addr); void BLI_mempool_destroy(BLI_mempool *pool); @@ -90,64 +71,6 @@ void BLI_mempool_allow_iter(BLI_mempool *pool); void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter); void *BLI_mempool_iterstep(BLI_mempool_iter *iter); -/* XXX - copied from BKE_utildefines.h, dont use here because we're in BLI */ -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) - /* Big Endian */ -#define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) -#else - /* Little Endian */ -#define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) -#endif - -/************ inlined stuff ***********/ -#define FREEWORD MAKE_ID('f', 'r', 'e', 'e') -#include "MEM_guardedalloc.h" - -BM_INLINE void *BLI_mempool_alloc(BLI_mempool *pool) { - void *retval=NULL; - BLI_freenode *curnode=NULL; - char *addr=NULL; - - if (!pool) return NULL; - - pool->totused++; - - if (!(pool->free)) { - int j; - /*need to allocate a new chunk*/ - BLI_mempool_chunk *mpchunk = pool->use_sysmalloc ? (BLI_mempool_chunk*)malloc(sizeof(BLI_mempool_chunk)) : (BLI_mempool_chunk*)MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk"); - mpchunk->next = mpchunk->prev = NULL; - mpchunk->data = pool->use_sysmalloc ? malloc(pool->csize) : MEM_mallocN(pool->csize, "BLI_Mempool Chunk Data"); - BLI_addtail(&(pool->chunks), mpchunk); - - pool->free = (BLI_freenode*)mpchunk->data; /*start of the list*/ - if (pool->allow_iter) - pool->free->freeword = FREEWORD; - for(addr = (char*)mpchunk->data, j=0; j < pool->pchunk; j++){ - curnode = ((BLI_freenode*)addr); - addr += pool->esize; - curnode->next = (BLI_freenode*)addr; - - if (pool->allow_iter) { - curnode->freeword = FREEWORD; - if (j != pool->pchunk-1) - curnode->next->freeword = FREEWORD; - } - } - curnode->next = NULL; /*terminate the list*/ - - pool->totalloc += pool->pchunk; - } - - retval = pool->free; - if (pool->allow_iter) - pool->free->freeword = 0x7FFFFFFF; - - pool->free = pool->free->next; - //memset(retval, 0, pool->esize); - return retval; -} - #ifdef __cplusplus } #endif diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 7dd4b6707c3..80b70dd45b6 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -29,27 +29,50 @@ * \ingroup bli */ - /* - Simple, fast memory allocator for allocating many elements of the same size. -*/ - -#include "MEM_guardedalloc.h" + * Simple, fast memory allocator for allocating many elements of the same size. + */ #include "BLI_utildefines.h" +#include "BLI_listbase.h" -#include "BLI_blenlib.h" -#include "BLI_linklist.h" -#include "BLI_mempool.h" -#include "BLI_utildefines.h" +#include "BLI_mempool.h" /* own include */ #include "DNA_listBase.h" -#include "DNA_ID.h" -#include <string.h> +#include "MEM_guardedalloc.h" + +#include <string.h> +#include <stdlib.h> -#define BLI_MEMPOOL_INTERN -#include "BLI_mempool.h" +/* note: copied from BKE_utildefines.h, dont use here because we're in BLI */ +#ifdef __BIG_ENDIAN__ +/* Big Endian */ +# define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) +#else +/* Little Endian */ +# define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) +#endif + +#define FREEWORD MAKE_ID('f', 'r', 'e', 'e') + +typedef struct BLI_freenode { + struct BLI_freenode *next; + int freeword; /* used to identify this as a freed node */ +} BLI_freenode; + +typedef struct BLI_mempool_chunk { + struct BLI_mempool_chunk *next, *prev; + void *data; +} BLI_mempool_chunk; + +typedef struct BLI_mempool { + struct ListBase chunks; + int esize, csize, pchunk; /*size of elements and chunks in bytes and number of elements per chunk*/ + BLI_freenode *free; /*free element list. Interleaved into chunk datas.*/ + int totalloc, totused; /*total number of elements allocated in total, and currently in use*/ + int use_sysmalloc, allow_iter; +} BLI_mempool; BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, int use_sysmalloc, int allow_iter) @@ -69,7 +92,7 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, pool = use_sysmalloc ? malloc(sizeof(BLI_mempool)) : MEM_mallocN(sizeof(BLI_mempool), "memory pool"); pool->esize = allow_iter ? MAX2(esize, sizeof(BLI_freenode)) : esize; pool->use_sysmalloc = use_sysmalloc; - pool->pchunk = pchunk; + pool->pchunk = pchunk; pool->csize = esize * pchunk; pool->chunks.first = pool->chunks.last = NULL; pool->totused= 0; @@ -79,7 +102,7 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, if (maxchunks==0) maxchunks = 1; /*allocate the actual chunks*/ - for(i=0; i < maxchunks; i++){ + for (i=0; i < maxchunks; i++) { BLI_mempool_chunk *mpchunk = use_sysmalloc ? malloc(sizeof(BLI_mempool_chunk)) : MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk"); mpchunk->next = mpchunk->prev = NULL; mpchunk->data = use_sysmalloc ? malloc(pool->csize) : MEM_mallocN(pool->csize, "BLI Mempool Chunk Data"); @@ -92,7 +115,7 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, } /*loop through the allocated data, building the pointer structures*/ - for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){ + for (addr = mpchunk->data, j=0; j < pool->pchunk; j++) { curnode = ((BLI_freenode*)addr); addr += pool->esize; curnode->next = (BLI_freenode*)addr; @@ -114,24 +137,24 @@ BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk, pool->totalloc += pool->pchunk; } - /*terminate the list*/ curnode->next = NULL; return pool; } -#if 0 + void *BLI_mempool_alloc(BLI_mempool *pool) { void *retval=NULL; - BLI_freenode *curnode=NULL; - char *addr=NULL; - int j; - + if (!pool) return NULL; - + pool->totused++; - if(!(pool->free)){ + if (!(pool->free)) { + BLI_freenode *curnode=NULL; + char *addr; + int j; + /*need to allocate a new chunk*/ BLI_mempool_chunk *mpchunk = pool->use_sysmalloc ? malloc(sizeof(BLI_mempool_chunk)) : MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk"); mpchunk->next = mpchunk->prev = NULL; @@ -165,24 +188,19 @@ void *BLI_mempool_alloc(BLI_mempool *pool) //memset(retval, 0, pool->esize); return retval; } -#endif void *BLI_mempool_calloc(BLI_mempool *pool) { - void *retval=NULL; - retval = BLI_mempool_alloc(pool); - BMEMSET(retval, 0, pool->esize); + void *retval= BLI_mempool_alloc(pool); + memset(retval, 0, pool->esize); return retval; } - -void BLI_mempool_free(BLI_mempool *pool, void *addr) //doesnt protect against double frees, dont be stupid! +/* doesnt protect against double frees, dont be stupid! */ +void BLI_mempool_free(BLI_mempool *pool, void *addr) { BLI_freenode *newhead = addr; - BLI_freenode *curnode=NULL; - char *tmpaddr=NULL; - int i; - + if (pool->allow_iter) newhead->freeword = FREEWORD; newhead->next = pool->free; @@ -192,14 +210,18 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr) //doesnt protect against do /*nothing is in use; free all the chunks except the first*/ if (pool->totused == 0) { - BLI_mempool_chunk *mpchunk=NULL, *first; + BLI_freenode *curnode=NULL; + char *tmpaddr=NULL; + int i; + + BLI_mempool_chunk *mpchunk=NULL; + BLI_mempool_chunk *first= pool->chunks.first; - first = pool->chunks.first; BLI_remlink(&pool->chunks, first); - for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { - if(pool->use_sysmalloc) free(mpchunk->data); - else MEM_freeN(mpchunk->data); + for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { + if (pool->use_sysmalloc) free(mpchunk->data); + else MEM_freeN(mpchunk->data); } pool->use_sysmalloc ? BLI_freelist(&(pool->chunks)) : BLI_freelistN(&(pool->chunks)); @@ -208,7 +230,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr) //doesnt protect against do pool->totalloc = pool->pchunk; pool->free = first->data; /*start of the list*/ - for(tmpaddr = first->data, i=0; i < pool->pchunk; i++){ + for (tmpaddr = first->data, i=0; i < pool->pchunk; i++) { curnode = ((BLI_freenode*)tmpaddr); tmpaddr += pool->esize; curnode->next = (BLI_freenode*)tmpaddr; @@ -264,15 +286,16 @@ void *BLI_mempool_iterstep(BLI_mempool_iter *iter) void BLI_mempool_destroy(BLI_mempool *pool) { BLI_mempool_chunk *mpchunk=NULL; - if(pool->use_sysmalloc) { - for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { + + if (pool->use_sysmalloc) { + for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { free(mpchunk->data); } BLI_freelist(&(pool->chunks)); free(pool); } else { - for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { + for (mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) { MEM_freeN(mpchunk->data); } BLI_freelistN(&(pool->chunks)); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 287d3f071ee..3053e834dbc 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1981,7 +1981,7 @@ static void direct_link_nladata_strips(FileData *fd, ListBase *list) /* strip's F-Modifiers */ link_list(fd, &strip->modifiers); - direct_link_modifiers(fd, &strip->modifiers); + direct_link_fmodifiers(fd, &strip->modifiers); } } diff --git a/source/blender/bmesh/bmesh_operator_api.h b/source/blender/bmesh/bmesh_operator_api.h index 82443221e4c..43f05a2ff0d 100644 --- a/source/blender/bmesh/bmesh_operator_api.h +++ b/source/blender/bmesh/bmesh_operator_api.h @@ -11,6 +11,7 @@ extern "C" { #include "BKE_utildefines.h" #include <stdarg.h> +#include <string.h> /* for memcpy */ /* operators represent logical, executable mesh modules. all topological diff --git a/source/blender/bmesh/intern/bmesh_newcore.c b/source/blender/bmesh/intern/bmesh_newcore.c index 5c7144b21f5..e54bb01bf8f 100644 --- a/source/blender/bmesh/intern/bmesh_newcore.c +++ b/source/blender/bmesh/intern/bmesh_newcore.c @@ -12,6 +12,8 @@ #include "BLI_ghash.h" #include "BLI_array.h" +#include "MEM_guardedalloc.h" + #include "DNA_listBase.h" #include "bmesh_class.h" diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c index c6859669f22..4bedba5f4e4 100644 --- a/source/blender/bmesh/intern/bmesh_walkers.c +++ b/source/blender/bmesh/intern/bmesh_walkers.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> #include "BKE_customdata.h" @@ -35,6 +36,7 @@ #include "DNA_mesh_types.h" #include "BLI_utildefines.h" +#include "BLI_listbase.h" #include "BLI_mempool.h" #include "BLI_array.h" diff --git a/source/blender/bmesh/operators/subdivideop.c b/source/blender/bmesh/operators/subdivideop.c index d0b355eca97..ca1935bde93 100644 --- a/source/blender/bmesh/operators/subdivideop.c +++ b/source/blender/bmesh/operators/subdivideop.c @@ -32,6 +32,7 @@ #include "BLI_rand.h" #include "BLI_ghash.h" #include "BLI_array.h" +#include "BLI_noise.h" #include "BLI_utildefines.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/mesh/knifetool.c b/source/blender/editors/mesh/knifetool.c index 79dac3ae396..55f6c9d0a6e 100755 --- a/source/blender/editors/mesh/knifetool.c +++ b/source/blender/editors/mesh/knifetool.c @@ -175,7 +175,7 @@ typedef struct knifetool_opdata { MODE_IDLE, MODE_DRAGGING, MODE_CONNECT, - MODE_PANNING, + MODE_PANNING } mode; int snap_midpoints, prevmode, extend; diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index cc1c8843015..6931b0b86db 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -322,10 +322,13 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str) spos+= sprintf(spos, "%s ", rs->statstr); } else { - spos+= sprintf(spos, "Fra:%d Ve:%d Fa:%d ", (scene->r.cfra), rs->totvert, rs->totface); + spos+= sprintf(spos, "Fra:%d ", (scene->r.cfra)); + if(rs->totvert) spos+= sprintf(spos, "Ve:%d ", rs->totvert); + if(rs->totface) spos+= sprintf(spos, "Fa:%d ", rs->totface); if(rs->tothalo) spos+= sprintf(spos, "Ha:%d ", rs->tothalo); if(rs->totstrand) spos+= sprintf(spos, "St:%d ", rs->totstrand); - spos+= sprintf(spos, "La:%d Mem:%.2fM (%.2fM, peak %.2fM) ", rs->totlamp, megs_used_memory, mmap_used_memory, megs_peak_memory); + if(rs->totlamp) spos+= sprintf(spos, "La:%d ", rs->totlamp); + spos+= sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory); if(rs->curfield) spos+= sprintf(spos, "Field %d ", rs->curfield); diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 9de804d275f..4c028612320 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -805,7 +805,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r if(ma) { bNode *node= give_current_material_texture_node(ma); - CTX_data_pointer_set(result, &ma->id, &RNA_Node, node); + CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node); } } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index a7f7e36b182..27ad2c4fd6d 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -1218,6 +1218,8 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL); else if (datalevel == TSE_DRIVER_BASE) /* do nothing... no special ops needed yet */; + else if ELEM3(datalevel, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS) + /*WM_operator_name_call(C, "OUTLINER_OT_renderdata_operation", WM_OP_INVOKE_REGION_WIN, NULL)*/; else WM_operator_name_call(C, "OUTLINER_OT_data_operation", WM_OP_INVOKE_REGION_WIN, NULL); } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index c0046b089af..bbc72500df4 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1946,7 +1946,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, index+= 0x10000; } /* restore things */ - if ((arm->drawtype!=ARM_LINE)&& (dt>OB_WIRE) && (arm->flag & ARM_POSEMODE)) + if (!ELEM(arm->drawtype, ARM_WIRE, ARM_LINE) && (dt>OB_WIRE) && (arm->flag & ARM_POSEMODE)) bglPolygonOffset(rv3d->dist, 0.0); } diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 368359925c4..73b2914fba1 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -169,7 +169,8 @@ static void rna_trackingCamera_focal_mm_set(PointerRNA *ptr, float value) if(clip->lastsize[0]) value= clip->lastsize[0]*value/camera->sensor_width; - camera->focal= value; + if(value>=0.0001) + camera->focal= value; } static int rna_track_2d_stabilization(CollectionPropertyIterator *UNUSED(iter), void *data) @@ -372,7 +373,7 @@ static void rna_def_trackingCamera(BlenderRNA *brna) /* Focal Length */ prop= RNA_def_property(srna, "focal_length", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "focal"); - RNA_def_property_range(prop, 0.0f, 5000.0f); + RNA_def_property_range(prop, 0.0001f, 5000.0f); RNA_def_property_float_funcs(prop, "rna_trackingCamera_focal_mm_get", "rna_trackingCamera_focal_mm_set", NULL); RNA_def_property_ui_text(prop, "Focal Length", "Camera's focal length"); RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL); diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index bdef3b7f176..e8979066d0b 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -33,6 +33,7 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" +#include "BLI_string.h" #include "BLI_math.h" #include "BLI_ghash.h" #include "BLI_edgehash.h" diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 075a13985cb..236351a5e29 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -69,6 +69,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) if(fluidmd) { FluidsimSettings *fss = MEM_callocN(sizeof(FluidsimSettings), "fluidsimsettings"); + int surfdataPathMax = FILE_MAX; fluidmd->fss = fss; @@ -104,7 +105,22 @@ void fluidsim_init(FluidsimModifierData *fluidmd) /* elubie: changed this to default to the same dir as the render output to prevent saving to C:\ on Windows */ - BLI_strncpy(fss->surfdataPath, BLI_temporary_dir(), FILE_MAX); + if (G.relbase_valid) { /* is the .blend saved? */ + /* subfolder next to saved file */ + BLI_strncpy(fss->surfdataPath, "//fluid_cache", surfdataPathMax); + BLI_add_slash(fss->surfdataPath); + } + else { + /* subfolder in temp. directory */ + BLI_strncpy(fss->surfdataPath, BLI_temporary_dir(), surfdataPathMax); + surfdataPathMax -= strlen(fss->surfdataPath); + if (surfdataPathMax > 1) { + BLI_strncpy(fss->surfdataPath+strlen(fss->surfdataPath), "fluid_cache", surfdataPathMax); + surfdataPathMax -= strlen("fluid_cache"); + if (surfdataPathMax > 1) + BLI_add_slash(fss->surfdataPath); + } + } // first init of bounding box // no bounding box needed diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 7f20b4c7bc1..d609ffc23c4 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -34,10 +34,12 @@ #include "DNA_scene_types.h" #include "BKE_cdderivedmesh.h" +#include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_ocean.h" #include "BKE_utildefines.h" +#include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_math_inline.h" #include "BLI_utildefines.h" @@ -95,6 +97,7 @@ static void initData(ModifierData *md) { #ifdef WITH_OCEANSIM OceanModifierData *omd = (OceanModifierData*) md; + int cachepathmax = sizeof(omd->cachepath); omd->resolution = 7; omd->spatial_size = 50; @@ -122,7 +125,22 @@ static void initData(ModifierData *md) omd->repeat_x = 1; omd->repeat_y = 1; - BLI_strncpy(omd->cachepath, "//ocean_cache", sizeof(omd->cachepath)); + if (G.relbase_valid) { /* is the .blend saved? */ + /* subfolder next to saved file */ + BLI_strncpy(omd->cachepath, "//ocean_cache", cachepathmax); + BLI_add_slash(omd->cachepath); + } + else { + /* subfolder in temp. directory */ + BLI_strncpy(omd->cachepath, BLI_temporary_dir(), cachepathmax); + cachepathmax -= strlen(omd->cachepath); + if (cachepathmax > 1) { + BLI_strncpy(omd->cachepath+strlen(omd->cachepath), "ocean_cache", cachepathmax); + cachepathmax -= strlen("ocean_cache"); + if (cachepathmax > 1) + BLI_add_slash(omd->cachepath); + } + } omd->cached = 0; omd->bakestart = 1; diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index dbf9fdbdb7e..c26cf2451df 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -51,6 +51,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b if(data && node->id) { ShadeInput *shi= ((ShaderCallData *)data)->shi; TexResult texres; + bNodeSocket *sock_vector= node->inputs.first; float vec[3], nor[3]={0.0f, 0.0f, 0.0f}; int retval; short which_output = node->custom1; @@ -63,7 +64,8 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b texres.nor= nor; texres.tr= texres.tg= texres.tb= 0.0f; - if(in[0]->hasinput) { + /* don't use in[0]->hasinput, see material node for explanation */ + if(sock_vector->link) { nodestack_get_vec(vec, SOCK_VECTOR, in[0]); if(in[0]->datatype==NS_OSA_VECTORS) { diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 3e7aeef3044..79628cf5ae9 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -834,18 +834,18 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type) self= base_type ? (ColorObject *)base_type->tp_alloc(base_type, 0) : (ColorObject *)PyObject_GC_New(ColorObject, &color_Type); - if(self) { + if (self) { /* init callbacks as NULL */ self->cb_user= NULL; self->cb_type= self->cb_subtype= 0; - if(type == Py_WRAP) { + if (type == Py_WRAP) { self->col = col; self->wrapped = Py_WRAP; } else if (type == Py_NEW) { self->col = PyMem_Malloc(COLOR_SIZE * sizeof(float)); - if(col) + if (col) copy_v3_v3(self->col, col); else zero_v3(self->col); @@ -863,7 +863,7 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type) PyObject *newColorObject_cb(PyObject *cb_user, int cb_type, int cb_subtype) { ColorObject *self= (ColorObject *)newColorObject(NULL, Py_NEW, NULL); - if(self) { + if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; self->cb_type= (unsigned char)cb_type; diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 293a960e0a6..1472b6886f6 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -941,8 +941,10 @@ static PyObject *Matrix_invert(MatrixObject *self) int x, y, z = 0; float det = 0.0f; - float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -964,9 +966,11 @@ static PyObject *Matrix_invert(MatrixObject *self) mat[1] = -self->matrix[0][1]; mat[2] = -self->matrix[1][0]; mat[3] = self->matrix[0][0]; - } else if (self->row_size == 3) { + } + else if (self->row_size == 3) { adjoint_m3_m3((float (*)[3]) mat,(float (*)[3])self->contigPtr); - } else if (self->row_size == 4) { + } + else if (self->row_size == 4) { adjoint_m4_m4((float (*)[4]) mat, (float (*)[4])self->contigPtr); } /*divide by determinate*/ @@ -1183,7 +1187,8 @@ static PyObject *Matrix_transpose(MatrixObject *self) t = self->matrix[1][0]; self->matrix[1][0] = self->matrix[0][1]; self->matrix[0][1] = t; - } else if (self->row_size == 3) { + } + else if (self->row_size == 3) { transpose_m3((float (*)[3])self->contigPtr); } else { @@ -1253,7 +1258,8 @@ static PyObject *Matrix_identity(MatrixObject *self) self->matrix[0][1] = 0.0f; self->matrix[1][0] = 0.0f; self->matrix[1][1] = 1.0f; - } else if (self->row_size == 3) { + } + else if (self->row_size == 3) { unit_m3((float (*)[3])self->contigPtr); } else { @@ -1657,7 +1663,8 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) if (i < 0) i += self->row_size; return Matrix_item(self, i); - } else if (PySlice_Check(item)) { + } + else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx((void *)item, self->row_size, &start, &stop, &step, &slicelength) < 0) diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index a8585f386d5..8a6c4909e94 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -639,7 +639,8 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item) if (i < 0) i += QUAT_SIZE; return Quaternion_item(self, i); - } else if (PySlice_Check(item)) { + } + else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx((void *)item, QUAT_SIZE, &start, &stop, &step, &slicelength) < 0) diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 66dda6a9623..f70bd42e2b6 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -61,7 +61,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED case 0: break; case 1: - if((size=mathutils_array_parse(vec, 2, 4, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) + if ((size=mathutils_array_parse(vec, 2, 4, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) return NULL; break; default: @@ -77,7 +77,7 @@ static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *sel { PyObject *ret= Vector_copy(self); PyObject *ret_dummy= vec_func(ret); - if(ret_dummy) { + if (ret_dummy) { Py_DECREF(ret_dummy); return (PyObject *)ret; } @@ -97,7 +97,7 @@ static PyObject *Vector_zero(VectorObject *self) { fill_vn(self->vec, self->size, 0.0f); - if(BaseMath_WriteCallback(self) == -1) + if (BaseMath_WriteCallback(self) == -1) return NULL; Py_RETURN_NONE; @@ -119,7 +119,7 @@ static PyObject *Vector_normalize(VectorObject *self) int i; float norm = 0.0f; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; for (i = 0; i < self->size; i++) { @@ -156,13 +156,13 @@ PyDoc_STRVAR(Vector_resize_2d_doc, ); static PyObject *Vector_resize_2d(VectorObject *self) { - if(self->wrapped==Py_WRAP) { + if (self->wrapped==Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_2d(): " "cannot resize wrapped data - only python vectors"); return NULL; } - if(self->cb_user) { + if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize_2d(): " "cannot resize a vector that has an owner"); @@ -170,7 +170,7 @@ static PyObject *Vector_resize_2d(VectorObject *self) } self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2)); - if(self->vec == NULL) { + if (self->vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_2d(): " "problem allocating pointer space"); @@ -197,7 +197,7 @@ static PyObject *Vector_resize_3d(VectorObject *self) "cannot resize wrapped data - only python vectors"); return NULL; } - if(self->cb_user) { + if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize_3d(): " "cannot resize a vector that has an owner"); @@ -205,14 +205,14 @@ static PyObject *Vector_resize_3d(VectorObject *self) } self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3)); - if(self->vec == NULL) { + if (self->vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_3d(): " "problem allocating pointer space"); return NULL; } - if(self->size == 2) + if (self->size == 2) self->vec[2] = 0.0f; self->size = 3; @@ -229,13 +229,13 @@ PyDoc_STRVAR(Vector_resize_4d_doc, ); static PyObject *Vector_resize_4d(VectorObject *self) { - if(self->wrapped==Py_WRAP) { + if (self->wrapped==Py_WRAP) { PyErr_SetString(PyExc_TypeError, "Vector.resize_4d(): " "cannot resize wrapped data - only python vectors"); return NULL; } - if(self->cb_user) { + if (self->cb_user) { PyErr_SetString(PyExc_TypeError, "Vector.resize_4d(): " "cannot resize a vector that has an owner"); @@ -243,18 +243,18 @@ static PyObject *Vector_resize_4d(VectorObject *self) } self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4)); - if(self->vec == NULL) { + if (self->vec == NULL) { PyErr_SetString(PyExc_MemoryError, "Vector.resize_4d(): " "problem allocating pointer space"); return NULL; } - if(self->size == 2) { + if (self->size == 2) { self->vec[2] = 0.0f; self->vec[3] = 1.0f; } - else if(self->size == 3) { + else if (self->size == 3) { self->vec[3] = 1.0f; } self->size = 4; @@ -270,7 +270,7 @@ PyDoc_STRVAR(Vector_to_2d_doc, ); static PyObject *Vector_to_2d(VectorObject *self) { - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; return newVectorObject(self->vec, 2, Py_NEW, Py_TYPE(self)); @@ -287,7 +287,7 @@ static PyObject *Vector_to_3d(VectorObject *self) { float tvec[3]= {0.0f}; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 3)); @@ -305,7 +305,7 @@ static PyObject *Vector_to_4d(VectorObject *self) { float tvec[4]= {0.0f, 0.0f, 0.0f, 1.0f}; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; memcpy(tvec, self->vec, sizeof(float) * MIN2(self->size, 4)); @@ -330,7 +330,7 @@ static PyObject *Vector_to_tuple_ext(VectorObject *self, int ndigits) ret= PyTuple_New(self->size); - if(ndigits >= 0) { + if (ndigits >= 0) { for (i = 0; i < self->size; i++) { PyTuple_SET_ITEM(ret, i, PyFloat_FromDouble(double_round((double)self->vec[i], ndigits))); } @@ -348,20 +348,20 @@ static PyObject *Vector_to_tuple(VectorObject *self, PyObject *args) { int ndigits= 0; - if(!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits)) + if (!PyArg_ParseTuple(args, "|i:to_tuple", &ndigits)) return NULL; - if(ndigits > 22 || ndigits < 0) { + if (ndigits > 22 || ndigits < 0) { PyErr_SetString(PyExc_ValueError, "Vector.to_tuple(ndigits): " "ndigits must be between 0 and 21"); return NULL; } - if(PyTuple_GET_SIZE(args)==0) + if (PyTuple_GET_SIZE(args)==0) ndigits= -1; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; return Vector_to_tuple_ext(self, ndigits); @@ -385,7 +385,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) const char *strack, *sup; short track = 2, up = 1; - if(!PyArg_ParseTuple(args, "|ss:to_track_quat", &strack, &sup)) + if (!PyArg_ParseTuple(args, "|ss:to_track_quat", &strack, &sup)) return NULL; if (self->size != 3) { @@ -395,7 +395,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) return NULL; } - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; if (strack) { @@ -508,10 +508,10 @@ static PyObject *Vector_reflect(VectorObject *self, PyObject *value) float reflect[3] = {0.0f}; float tvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) + if ((value_size= mathutils_array_parse(tvec, 2, 4, value, "Vector.reflect(other), invalid 'other' arg")) == -1) return NULL; mirror[0] = tvec[0]; @@ -547,10 +547,10 @@ static PyObject *Vector_cross(VectorObject *self, PyObject *value) VectorObject *ret; float tvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.cross(other), invalid 'other' arg") == -1) return NULL; ret= (VectorObject *)newVectorObject(NULL, 3, Py_NEW, Py_TYPE(self)); @@ -574,10 +574,10 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value) double dot = 0.0; int x; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1) return NULL; for (x = 0; x < self->size; x++) { @@ -611,13 +611,13 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) int x; PyObject *fallback= NULL; - if(!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback)) + if (!PyArg_ParseTuple(args, "O|O:angle", &value, &fallback)) return NULL; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1) return NULL; for (x = 0; x < size; x++) { @@ -626,7 +626,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) } if (!test_v1 || !test_v2) { /* avoid exception */ - if(fallback) { + if (fallback) { Py_INCREF(fallback); return fallback; } @@ -648,7 +648,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) } PyDoc_STRVAR(Vector_rotation_difference_doc, -".. function:: difference(other)\n" +".. function:: rotation_difference(other)\n" "\n" " Returns a quaternion representing the rotational difference between this\n" " vector and another.\n" @@ -664,17 +664,17 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value) { float quat[4], vec_a[3], vec_b[3]; - if(self->size < 3) { + if (self->size < 3) { PyErr_SetString(PyExc_ValueError, "vec.difference(value): " "expects both vectors to be size 3 or 4"); return NULL; } - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(vec_b, 3, MAX_DIMENSIONS, value, "Vector.difference(other), invalid 'other' arg") == -1) return NULL; normalize_v3_v3(vec_a, self->vec); @@ -703,13 +703,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value) double dot = 0.0f, dot2 = 0.0f; int x; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_array_parse(tvec, size, size, value, "Vector.project(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, size, size, value, "Vector.project(other), invalid 'other' arg") == -1) return NULL; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; //get dot products @@ -745,13 +745,13 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) float tvec[MAX_DIMENSIONS], vec[MAX_DIMENSIONS]; int x; - if(!PyArg_ParseTuple(args, "Of:lerp", &value, &fac)) + if (!PyArg_ParseTuple(args, "Of:lerp", &value, &fac)) return NULL; - if(mathutils_array_parse(tvec, size, size, value, "Vector.lerp(other), invalid 'other' arg") == -1) + if (mathutils_array_parse(tvec, size, size, value, "Vector.lerp(other), invalid 'other' arg") == -1) return NULL; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; ifac= 1.0f - fac; @@ -774,13 +774,13 @@ static PyObject *Vector_rotate(VectorObject *self, PyObject *value) { float other_rmat[3][3]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; - if(mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1) + if (mathutils_any_to_rotmat(other_rmat, value, "Vector.rotate(value)") == -1) return NULL; - if(self->size < 3) { + if (self->size < 3) { PyErr_SetString(PyExc_ValueError, "Vector must be 3D or 4D"); return NULL; @@ -805,7 +805,7 @@ PyDoc_STRVAR(Vector_copy_doc, ); static PyObject *Vector_copy(VectorObject *self) { - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; return newVectorObject(self->vec, self->size, Py_NEW, Py_TYPE(self)); @@ -815,7 +815,7 @@ static PyObject *Vector_repr(VectorObject *self) { PyObject *ret, *tuple; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; tuple= Vector_to_tuple_ext(self, -1); @@ -833,10 +833,10 @@ static int Vector_len(VectorObject *self) /* sequence accessor (get): vector[index] */ static PyObject *vector_item_internal(VectorObject *self, int i, const int is_attr) { - if(i<0) i= self->size-i; + if (i<0) i= self->size-i; - if(i < 0 || i >= self->size) { - if(is_attr) { + if (i < 0 || i >= self->size) { + if (is_attr) { PyErr_Format(PyExc_AttributeError, "Vector.%c: unavailable on %dd vector", *(((char *)"xyzw") + i), self->size); @@ -848,7 +848,7 @@ static PyObject *vector_item_internal(VectorObject *self, int i, const int is_at return NULL; } - if(BaseMath_ReadIndexCallback(self, i) == -1) + if (BaseMath_ReadIndexCallback(self, i) == -1) return NULL; return PyFloat_FromDouble(self->vec[i]); @@ -862,17 +862,17 @@ static PyObject *Vector_item(VectorObject *self, int i) static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value, const int is_attr) { float scalar; - if((scalar=PyFloat_AsDouble(value))==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar=PyFloat_AsDouble(value))==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "vector[index] = x: " "index argument not a number"); return -1; } - if(i<0) i= self->size-i; + if (i<0) i= self->size-i; - if(i < 0 || i >= self->size) { - if(is_attr) { + if (i < 0 || i >= self->size) { + if (is_attr) { PyErr_Format(PyExc_AttributeError, "Vector.%c = x: unavailable on %dd vector", *(((char *)"xyzw") + i), self->size); @@ -886,7 +886,7 @@ static int vector_ass_item_internal(VectorObject *self, int i, PyObject *value, } self->vec[i] = scalar; - if(BaseMath_WriteIndexCallback(self, i) == -1) + if (BaseMath_WriteIndexCallback(self, i) == -1) return -1; return 0; } @@ -902,7 +902,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end) PyObject *tuple; int count; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; CLAMP(begin, 0, self->size); @@ -923,7 +923,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se int y, size = 0; float vec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return -1; CLAMP(begin, 0, self->size); @@ -931,7 +931,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se begin = MIN2(begin, end); size = (end - begin); - if(mathutils_array_parse(vec, size, size, seq, "vector[begin:end] = [...]") == -1) + if (mathutils_array_parse(vec, size, size, seq, "vector[begin:end] = [...]") == -1) return -1; /*parsed well - now set in vector*/ @@ -939,7 +939,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se self->vec[begin + y] = vec[y]; } - if(BaseMath_WriteCallback(self) == -1) + if (BaseMath_WriteCallback(self) == -1) return -1; return 0; @@ -962,11 +962,11 @@ static PyObject *Vector_add(PyObject *v1, PyObject *v2) vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; - if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) return NULL; /*VECTOR + VECTOR*/ - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_AttributeError, "Vector addition: " "vectors must have the same dimensions for this operation"); @@ -993,14 +993,14 @@ static PyObject *Vector_iadd(PyObject *v1, PyObject *v2) vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_AttributeError, "Vector addition: " "vectors must have the same dimensions for this operation"); return NULL; } - if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) return NULL; add_vn_vn(vec1->vec, vec2->vec, vec1->size); @@ -1026,10 +1026,10 @@ static PyObject *Vector_sub(PyObject *v1, PyObject *v2) vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; - if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) return NULL; - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_AttributeError, "Vector subtraction: " "vectors must have the same dimensions for this operation"); @@ -1056,14 +1056,14 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) vec1 = (VectorObject*)v1; vec2 = (VectorObject*)v2; - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_AttributeError, "Vector subtraction: " "vectors must have the same dimensions for this operation"); return NULL; } - if(BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec1) == -1 || BaseMath_ReadCallback(vec2) == -1) return NULL; sub_vn_vn(vec1->vec, vec2->vec, vec1->size); @@ -1091,8 +1091,8 @@ int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec, double dot = 0.0f; int x, y, z = 0; - if(mat->row_size != vec->size) { - if(mat->row_size == 4 && vec->size == 3) { + if (mat->row_size != vec->size) { + if (mat->row_size == 4 && vec->size == 3) { vec_cpy[3] = 1.0f; } else { @@ -1133,12 +1133,12 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) if VectorObject_Check(v1) { vec1= (VectorObject *)v1; - if(BaseMath_ReadCallback(vec1) == -1) + if (BaseMath_ReadCallback(vec1) == -1) return NULL; } if VectorObject_Check(v2) { vec2= (VectorObject *)v2; - if(BaseMath_ReadCallback(vec2) == -1) + if (BaseMath_ReadCallback(vec2) == -1) return NULL; } @@ -1148,7 +1148,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) int i; double dot = 0.0f; - if(vec1->size != vec2->size) { + if (vec1->size != vec2->size) { PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "vectors must have the same dimensions for this operation"); @@ -1166,9 +1166,9 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) /* VEC * MATRIX */ float tvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback((MatrixObject *)v2) == -1) + if (BaseMath_ReadCallback((MatrixObject *)v2) == -1) return NULL; - if(row_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) { + if (row_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) { return NULL; } @@ -1186,13 +1186,13 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) QuaternionObject *quat2 = (QuaternionObject*)v2; float tvec[3]; - if(vec1->size != 3) { + if (vec1->size != 3) { PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "only 3D vector rotations (with quats) currently supported"); return NULL; } - if(BaseMath_ReadCallback(quat2) == -1) { + if (BaseMath_ReadCallback(quat2) == -1) { return NULL; } @@ -1228,7 +1228,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) VectorObject *vec = (VectorObject *)v1; float scalar; - if(BaseMath_ReadCallback(vec) == -1) + if (BaseMath_ReadCallback(vec) == -1) return NULL; /* only support vec*=float and vec*=mat @@ -1243,10 +1243,10 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) return NULL; #else float rvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback((MatrixObject *)v2) == -1) + if (BaseMath_ReadCallback((MatrixObject *)v2) == -1) return NULL; - if(column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1) + if (column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1) return NULL; memcpy(vec->vec, rvec, sizeof(float) * vec->size); @@ -1266,14 +1266,14 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) #else QuaternionObject *quat2 = (QuaternionObject*)v2; - if(vec->size != 3) { + if (vec->size != 3) { PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "only 3D vector rotations (with quats) currently supported"); return NULL; } - if(BaseMath_ReadCallback(quat2) == -1) { + if (BaseMath_ReadCallback(quat2) == -1) { return NULL; } @@ -1304,7 +1304,7 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) float vec[4], scalar; VectorObject *vec1 = NULL; - if(!VectorObject_Check(v1)) { /* not a vector */ + if (!VectorObject_Check(v1)) { /* not a vector */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); @@ -1312,17 +1312,17 @@ static PyObject *Vector_div(PyObject *v1, PyObject *v2) } vec1 = (VectorObject*)v1; /* vector */ - if(BaseMath_ReadCallback(vec1) == -1) + if (BaseMath_ReadCallback(vec1) == -1) return NULL; - if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); return NULL; } - if(scalar==0.0f) { + if (scalar==0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); @@ -1342,17 +1342,17 @@ static PyObject *Vector_idiv(PyObject *v1, PyObject *v2) float scalar; VectorObject *vec1 = (VectorObject*)v1; - if(BaseMath_ReadCallback(vec1) == -1) + if (BaseMath_ReadCallback(vec1) == -1) return NULL; - if((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if ((scalar=PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "Vector division: " "Vector must be divided by a float"); return NULL; } - if(scalar==0.0f) { + if (scalar==0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: " "divide by zero error"); @@ -1374,7 +1374,7 @@ static PyObject *Vector_neg(VectorObject *self) { float tvec[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; negate_vn_vn(tvec, self->vec, self->size); @@ -1418,7 +1418,7 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa vecA = (VectorObject*)objectA; vecB = (VectorObject*)objectB; - if(BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1) + if (BaseMath_ReadCallback(vecA) == -1 || BaseMath_ReadCallback(vecB) == -1) return NULL; if (vecA->size != vecB->size) { @@ -1434,14 +1434,14 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa case Py_LT: lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); - if(lenA < lenB) { + if (lenA < lenB) { result = 1; } break; case Py_LE: lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); - if(lenA < lenB) { + if (lenA < lenB) { result = 1; } else { @@ -1457,14 +1457,14 @@ static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int compa case Py_GT: lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); - if(lenA > lenB) { + if (lenA > lenB) { result = 1; } break; case Py_GE: lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); - if(lenA > lenB) { + if (lenA > lenB) { result = 1; } else { @@ -1632,7 +1632,7 @@ static PyObject *Vector_getLength(VectorObject *self, void *UNUSED(closure)) double dot = 0.0f; int i; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; for (i = 0; i < self->size; i++) { @@ -1646,10 +1646,10 @@ static int Vector_setLength(VectorObject *self, PyObject *value) double dot = 0.0f, param; int i; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return -1; - if((param=PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) { + if ((param=PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "length must be set to a number"); return -1; @@ -1694,7 +1694,7 @@ static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closur double dot = 0.0f; int i; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; for (i = 0; i < self->size; i++) { @@ -1713,7 +1713,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) float vec[MAX_DIMENSIONS]; unsigned int swizzleClosure; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; /* Unpack the axes from the closure into an array. */ @@ -1722,7 +1722,7 @@ static PyObject *Vector_getSwizzle(VectorObject *self, void *closure) while (swizzleClosure & SWIZZLE_VALID_AXIS) { axis_from = swizzleClosure & SWIZZLE_AXIS; - if(axis_from >= self->size) { + if (axis_from >= self->size) { PyErr_SetString(PyExc_AttributeError, "Vector swizzle: " "specified axis not present"); @@ -1760,7 +1760,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) float tvec[MAX_DIMENSIONS]; float vec_assign[MAX_DIMENSIONS]; - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return -1; /* Check that the closure can be used with this vector: even 2D vectors have @@ -1787,11 +1787,11 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) size_from= axis_from; } - else if(PyErr_Clear(), (size_from=mathutils_array_parse(vec_assign, 2, 4, value, "mathutils.Vector.**** = swizzle assignment")) == -1) { + else if (PyErr_Clear(), (size_from=mathutils_array_parse(vec_assign, 2, 4, value, "mathutils.Vector.**** = swizzle assignment")) == -1) { return -1; } - if(axis_from != size_from) { + if (axis_from != size_from) { PyErr_SetString(PyExc_AttributeError, "Vector swizzle: size does not match swizzle"); return -1; @@ -1811,7 +1811,7 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure) memcpy(self->vec, tvec, axis_from * sizeof(float)); /* continue with BaseMathObject_WriteCallback at the end */ - if(BaseMath_WriteCallback(self) == -1) + if (BaseMath_WriteCallback(self) == -1) return -1; else return 0; @@ -2223,8 +2223,8 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v double dot = 0.0f; int x, y, z= 0, vec_size= vec->size; - if(mat->col_size != vec_size) { - if(mat->col_size == 4 && vec_size != 3) { + if (mat->col_size != vec_size) { + if (mat->col_size == 4 && vec_size != 3) { PyErr_SetString(PyExc_ValueError, "vector * matrix: matrix column size " "and the vector size must be the same"); @@ -2235,7 +2235,7 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v } } - if(BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1) + if (BaseMath_ReadCallback(vec) == -1 || BaseMath_ReadCallback(mat) == -1) return -1; memcpy(vec_cpy, vec->vec, vec_size * sizeof(float)); @@ -2263,7 +2263,7 @@ PyDoc_STRVAR(Vector_negate_doc, ); static PyObject *Vector_negate(VectorObject *self) { - if(BaseMath_ReadCallback(self) == -1) + if (BaseMath_ReadCallback(self) == -1) return NULL; negate_vn(self->vec, self->size); @@ -2406,7 +2406,7 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje { VectorObject *self; - if(size > 4 || size < 2) { + if (size > 4 || size < 2) { PyErr_SetString(PyExc_RuntimeError, "Vector(): invalid size"); return NULL; @@ -2415,25 +2415,25 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje self= base_type ? (VectorObject *)base_type->tp_alloc(base_type, 0) : (VectorObject *)PyObject_GC_New(VectorObject, &vector_Type); - if(self) { + if (self) { self->size = size; /* init callbacks as NULL */ self->cb_user= NULL; self->cb_type= self->cb_subtype= 0; - if(type == Py_WRAP) { + if (type == Py_WRAP) { self->vec = vec; self->wrapped = Py_WRAP; } else if (type == Py_NEW) { self->vec= PyMem_Malloc(size * sizeof(float)); - if(vec) { + if (vec) { memcpy(self->vec, vec, size * sizeof(float)); } else { /* new empty */ fill_vn(self->vec, size, 0.0f); - if(size == 4) { /* do the homogenous thing */ + if (size == 4) { /* do the homogenous thing */ self->vec[3] = 1.0f; } } @@ -2450,7 +2450,7 @@ PyObject *newVectorObject_cb(PyObject *cb_user, int size, int cb_type, int cb_su { float dummy[4] = {0.0, 0.0, 0.0, 0.0}; /* dummy init vector, callbacks will be used on access */ VectorObject *self= (VectorObject *)newVectorObject(dummy, size, Py_NEW, NULL); - if(self) { + if (self) { Py_INCREF(cb_user); self->cb_user= cb_user; self->cb_type= (unsigned char)cb_type; diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index dfa1c98b94b..3bf2997e8c9 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -48,8 +48,6 @@ #include "BLI_utildefines.h" #define SWAP_FLOAT(a, b, tmp) tmp=a; a=b; b=tmp -#define eps 0.000001 - /*-------------------------DOC STRINGS ---------------------------*/ PyDoc_STRVAR(M_Geometry_doc, diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index b7f89e260a8..38ace8d5121 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -283,6 +283,11 @@ int RE_engine_render(Render *re, int do_all) if(re->result==NULL) return 1; + /* set render info */ + re->i.cfra= re->scene->r.cfra; + BLI_strncpy(re->i.scenename, re->scene->id.name+2, sizeof(re->i.scenename)); + re->i.totface=re->i.totvert=re->i.totstrand=re->i.totlamp=re->i.tothalo= 0; + /* render */ engine = RE_engine_create(type); engine->re= re; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 2d45b9c4ea9..1d7d1c7c936 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -3007,7 +3007,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; float *co, fact, stencilTin=1.0; float tempvec[3], texvec[3], dxt[3], dyt[3]; - int tex_nr, rgb= 0, ok; + int tex_nr, rgb= 0; if (R.r.scemode & R_NO_TEX) return; /* todo: add flag to test if there's a tex */ @@ -3171,18 +3171,21 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h texture_rgb_blend(hor, tcol, hor, texres.tin, mtex->colfac, mtex->blendtype); } if(mtex->mapto & (WOMAP_ZENUP+WOMAP_ZENDOWN)) { - ok= 0; + float zenfac = 0.0f; + if(R.wrld.skytype & WO_SKYREAL) { if((skyflag & WO_ZENUP)) { - if(mtex->mapto & WOMAP_ZENUP) ok= 1; + if(mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac; } - else if(mtex->mapto & WOMAP_ZENDOWN) ok= 1; + else if(mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac; } - else ok= 1; - - if(ok) { - texture_rgb_blend(zen, tcol, zen, texres.tin, mtex->colfac, mtex->blendtype); + else { + if(mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac; + else if(mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac; } + + if(zenfac != 0.0f) + texture_rgb_blend(zen, tcol, zen, texres.tin, zenfac, mtex->blendtype); } } if(mtex->mapto & WOMAP_BLEND) { |