diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 3748a3b02c2..10583c03fac 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -129,8 +129,8 @@ def setup_staticlibs(lenv): libincs.extend([ lenv['BF_OPENGL_LIBPATH'], lenv['BF_JPEG_LIBPATH'], - lenv['BF_PNG_LIBPATH'], lenv['BF_ZLIB_LIBPATH'], + lenv['BF_PNG_LIBPATH'], lenv['BF_LIBSAMPLERATE_LIBPATH'], lenv['BF_ICONV_LIBPATH'] ]) @@ -152,6 +152,10 @@ def setup_staticlibs(lenv): libincs += Split(lenv['BF_LCMS_LIBPATH']) if lenv['WITH_BF_TIFF']: libincs += Split(lenv['BF_TIFF_LIBPATH']) + if lenv['WITH_BF_STATICTIFF']: + statlibs += Split(lenv['BF_TIFF_LIB_STATIC']) + if lenv['WITH_BF_ZLIB'] and lenv['WITH_BF_STATICZLIB']: + statlibs += Split(lenv['BF_ZLIB_LIB_STATIC']) if lenv['WITH_BF_FFTW3']: libincs += Split(lenv['BF_FFTW3_LIBPATH']) if lenv['WITH_BF_FFMPEG'] and lenv['WITH_BF_STATICFFMPEG']: @@ -198,7 +202,6 @@ def setup_syslibs(lenv): lenv['BF_JPEG_LIB'], lenv['BF_PNG_LIB'], - lenv['BF_ZLIB_LIB'], lenv['BF_LIBSAMPLERATE_LIB'] ] @@ -221,11 +224,12 @@ def setup_syslibs(lenv): syslibs += ['gomp'] if lenv['WITH_BF_ICONV']: syslibs += Split(lenv['BF_ICONV_LIB']) - if lenv['WITH_BF_OPENEXR']: - if not lenv['WITH_BF_STATICOPENEXR']: - syslibs += Split(lenv['BF_OPENEXR_LIB']) - if lenv['WITH_BF_TIFF']: - syslibs += Split(lenv['BF_TIFF_LIB']) + if lenv['WITH_BF_OPENEXR'] and not lenv['WITH_BF_STATICOPENEXR']: + syslibs += Split(lenv['BF_OPENEXR_LIB']) + if lenv['WITH_BF_TIFF'] and not lenv['WITH_BF_STATICTIFF']: + syslibs += Split(lenv['BF_TIFF_LIB']) + if lenv['WITH_BF_ZLIB'] and not lenv['WITH_BF_STATICZLIB']: + syslibs += Split(lenv['BF_ZLIB_LIB']) if lenv['WITH_BF_FFMPEG'] and not lenv['WITH_BF_STATICFFMPEG']: syslibs += Split(lenv['BF_FFMPEG_LIB']) if lenv['WITH_BF_OGG']: diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 5c4a4c527d5..da916a8e89c 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -15,7 +15,15 @@ import sys Variables = SCons.Variables BoolVariable = SCons.Variables.BoolVariable -VERSION = '2.54' # This is used in creating the local config directories +def get_version(): + fname = os.path.join(os.path.dirname(__file__), "..", "..", "..", "source", "blender", "blenkernel", "BKE_blender.h") + for l in open(fname, "r"): + if "BLENDER_VERSION" in l: + ver = int(l.split()[-1]) + return "%d.%d" % (ver / 100, ver % 100) + raise Exception("%s: missing version string" % fname) + +VERSION = get_version() # This is used in creating the local config directories def print_arguments(args, bc): if len(args): @@ -44,8 +52,8 @@ def validate_arguments(args, bc): 'WITH_BF_OPENJPEG', 'BF_OPENJPEG', 'BF_OPENJPEG_INC', 'BF_OPENJPEG_LIB', 'BF_OPENJPEG_LIBPATH', 'WITH_BF_REDCODE', 'BF_REDCODE', 'BF_REDCODE_INC', 'BF_REDCODE_LIB', 'BF_REDCODE_LIBPATH', 'WITH_BF_PNG', 'BF_PNG', 'BF_PNG_INC', 'BF_PNG_LIB', 'BF_PNG_LIBPATH', - 'WITH_BF_TIFF', 'BF_TIFF', 'BF_TIFF_INC', 'BF_TIFF_LIB', 'BF_TIFF_LIBPATH', - 'WITH_BF_ZLIB', 'BF_ZLIB', 'BF_ZLIB_INC', 'BF_ZLIB_LIB', 'BF_ZLIB_LIBPATH', + 'WITH_BF_TIFF', 'BF_TIFF', 'BF_TIFF_INC', 'BF_TIFF_LIB', 'BF_TIFF_LIBPATH', 'WITH_BF_STATICTIFF', 'BF_TIFF_LIB_STATIC', + 'WITH_BF_ZLIB', 'BF_ZLIB', 'BF_ZLIB_INC', 'BF_ZLIB_LIB', 'BF_ZLIB_LIBPATH', 'WITH_BF_STATICZLIB', 'BF_ZLIB_LIB_STATIC', 'WITH_BF_INTERNATIONAL', 'BF_GETTEXT', 'BF_GETTEXT_INC', 'BF_GETTEXT_LIB', 'WITH_BF_GETTEXT_STATIC', 'BF_GETTEXT_LIB_STATIC', 'BF_GETTEXT_LIBPATH', 'WITH_BF_ICONV', 'BF_ICONV', 'BF_ICONV_INC', 'BF_ICONV_LIB', 'BF_ICONV_LIBPATH', @@ -270,10 +278,12 @@ def read_opts(env, cfg, args): ('BF_PNG_LIBPATH', 'PNG library path', ''), (BoolVariable('WITH_BF_TIFF', 'Use TIFF if true', True)), + (BoolVariable('WITH_BF_STATICTIFF', 'Staticly link to TIFF', False)), ('BF_TIFF', 'TIFF base path', ''), ('BF_TIFF_INC', 'TIFF include path', ''), ('BF_TIFF_LIB', 'TIFF library', ''), ('BF_TIFF_LIBPATH', 'TIFF library path', ''), + ('BF_TIFF_LIB_STATIC', 'TIFF static library', ''), (BoolVariable('WITH_BF_LCMS', 'Enable color correction with lcms', False)), ('BF_LCMS', 'LCMS base path', ''), @@ -282,10 +292,12 @@ def read_opts(env, cfg, args): ('BF_LCMS_LIBPATH', 'LCMS library path', ''), (BoolVariable('WITH_BF_ZLIB', 'Use ZLib if true', True)), + (BoolVariable('WITH_BF_STATICZLIB', 'Staticly link to ZLib', False)), ('BF_ZLIB', 'ZLib base path', ''), ('BF_ZLIB_INC', 'ZLib include path', ''), ('BF_ZLIB_LIB', 'ZLib library', ''), ('BF_ZLIB_LIBPATH', 'ZLib library path', ''), + ('BF_ZLIB_LIB_STATIC', 'ZLib static library', ''), (BoolVariable('WITH_BF_INTERNATIONAL', 'Use Gettext if true', True)), diff --git a/extern/binreloc/CMakeLists.txt b/extern/binreloc/CMakeLists.txt index c684a7602e1..cc27b82ede1 100644 --- a/extern/binreloc/CMakeLists.txt +++ b/extern/binreloc/CMakeLists.txt @@ -18,8 +18,15 @@ # All rights reserved. # -SET(INC ./include ) +SET(SRC + binreloc.c +) + +SET(INC + ./include +) + ADD_DEFINITIONS(-DENABLE_BINRELOC) -FILE(GLOB SRC *.c) + BLENDERLIB(extern_binreloc "${SRC}" "${INC}") diff --git a/extern/glew/CMakeLists.txt b/extern/glew/CMakeLists.txt index b22c7caaaae..ea3c13da611 100644 --- a/extern/glew/CMakeLists.txt +++ b/extern/glew/CMakeLists.txt @@ -24,7 +24,9 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC include src) +SET(INC + ./include +) IF(UNIX) LIST(APPEND INC ${X11_X11_INCLUDE_PATH}) diff --git a/extern/lzo/CMakeLists.txt b/extern/lzo/CMakeLists.txt index 8bc887c923e..1563300d509 100644 --- a/extern/lzo/CMakeLists.txt +++ b/extern/lzo/CMakeLists.txt @@ -25,10 +25,6 @@ # ***** END GPL LICENSE BLOCK ***** SET(INC include) - -FILE(GLOB SRC minilzo/*.c) - - +SET(SRC minilzo/minilzo.c) BLENDERLIB(extern_minilzo "${SRC}" "${INC}") -#, libtype='blender', priority = 0 ) diff --git a/intern/boolop/CMakeLists.txt b/intern/boolop/CMakeLists.txt index 99923bc99dc..91500712a4c 100644 --- a/intern/boolop/CMakeLists.txt +++ b/intern/boolop/CMakeLists.txt @@ -24,9 +24,18 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC . intern extern ../moto/include ../container ../memutil ../../source/blender/makesdna ../guardedalloc ../../source/blender/blenlib) +SET(INC + . + ./intern + ./extern + ../memutil + ../container + ../guardedalloc + ../moto/include + ../../source/blender/blenlib + ../../source/blender/makesdna +) FILE(GLOB SRC intern/*.cpp) BLENDERLIB(bf_intern_bop "${SRC}" "${INC}") -#, libtype='common', priority=5 ) diff --git a/intern/bsp/CMakeLists.txt b/intern/bsp/CMakeLists.txt index 4f87e161030..debbc86c240 100644 --- a/intern/bsp/CMakeLists.txt +++ b/intern/bsp/CMakeLists.txt @@ -24,9 +24,13 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC intern ../container ../moto/include ../memutil) +SET(INC + ./intern + ../container + ../moto/include + ../memutil +) FILE(GLOB SRC intern/*.cpp) BLENDERLIB(bf_intern_bsp "${SRC}" "${INC}") -#, libtype='core', priority=15 ) diff --git a/intern/container/CMakeLists.txt b/intern/container/CMakeLists.txt index 462b62ae8bb..9ae684ec542 100644 --- a/intern/container/CMakeLists.txt +++ b/intern/container/CMakeLists.txt @@ -29,4 +29,3 @@ SET(INC .) FILE(GLOB SRC intern/*.cpp) BLENDERLIB(bf_intern_ctr "${SRC}" "${INC}") -#, libtype=['intern'], priority = 10 ) diff --git a/intern/decimation/CMakeLists.txt b/intern/decimation/CMakeLists.txt index 7fdf08978a4..77ab6249e7f 100644 --- a/intern/decimation/CMakeLists.txt +++ b/intern/decimation/CMakeLists.txt @@ -24,9 +24,13 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC . ../moto/include ../container ../memutil) +SET(INC + . + ../container + ../memutil + ../moto/include +) FILE(GLOB SRC intern/*.cpp) BLENDERLIB(bf_intern_decimate "${SRC}" "${INC}") -#, libtype=['core','common','player'], priority = [10, 20, 25] ) diff --git a/intern/elbeem/CMakeLists.txt b/intern/elbeem/CMakeLists.txt index d0e100907b1..57fb6180adb 100644 --- a/intern/elbeem/CMakeLists.txt +++ b/intern/elbeem/CMakeLists.txt @@ -38,4 +38,3 @@ IF(WITH_OPENMP) ENDIF(WITH_OPENMP) BLENDERLIB_NOLIST(bf_intern_elbeem "${SRC}" "${INC}") -#, libtype='blender', priority=0 ) diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt index 642b04fdb60..29e4f553974 100644 --- a/intern/guardedalloc/CMakeLists.txt +++ b/intern/guardedalloc/CMakeLists.txt @@ -26,12 +26,18 @@ SET(INC .) -FILE(GLOB SRC intern/*.c) +SET(SRC + ./intern/mallocn.c +) + +IF(WIN32) + LIST(APPEND SRC ./intern/mmap_win.c) +ENDIF(WIN32) BLENDERLIB(bf_intern_guardedalloc "${SRC}" "${INC}") -# Override C++ alloc optional +# Override C++ alloc, optional. IF(WITH_CXX_GUARDEDALLOC) - FILE(GLOB SRC cpp/*.cpp) + SET(SRC cpp/mallocn.cpp) BLENDERLIB(bf_intern_guardedalloc_cpp "${SRC}" "${INC}") ENDIF(WITH_CXX_GUARDEDALLOC) diff --git a/intern/iksolver/CMakeLists.txt b/intern/iksolver/CMakeLists.txt index 8ea05ac994d..50ae78d6d16 100644 --- a/intern/iksolver/CMakeLists.txt +++ b/intern/iksolver/CMakeLists.txt @@ -24,9 +24,12 @@ # # ***** END GPL LICENSE BLOCK ***** -SET(INC intern ../moto/include ../memutil) +SET(INC + intern + ../memutil + ../moto/include +) FILE(GLOB SRC intern/*.cpp) BLENDERLIB(bf_intern_ik "${SRC}" "${INC}") -#, libtype=['blender'], priority = [10] ) diff --git a/intern/itasc/CMakeLists.txt b/intern/itasc/CMakeLists.txt index 39443bd2b22..88f902b38c8 100644 --- a/intern/itasc/CMakeLists.txt +++ b/intern/itasc/CMakeLists.txt @@ -29,4 +29,3 @@ SET(INC ../../extern/Eigen2) FILE(GLOB SRC *.cpp kdl/*.cpp kdl/utilities/*.cpp) BLENDERLIB(bf_intern_itasc "${SRC}" "${INC}") -#, libtype=['blender'], priority = [10] ) diff --git a/intern/memutil/CMakeLists.txt b/intern/memutil/CMakeLists.txt index 3dc725acb50..ebbc53403f4 100644 --- a/intern/memutil/CMakeLists.txt +++ b/intern/memutil/CMakeLists.txt @@ -26,7 +26,9 @@ SET(INC . ..) -FILE(GLOB SRC intern/*.cpp) +SET(SRC + ./intern/MEM_CacheLimiterC-Api.cpp + ./intern/MEM_RefCountedC-Api.cpp +) BLENDERLIB(bf_intern_memutil "${SRC}" "${INC}") -#, libtype=['intern', 'player'], priority = [0, 180] ) diff --git a/intern/moto/CMakeLists.txt b/intern/moto/CMakeLists.txt index 3d6d3d1a783..91c523eced9 100644 --- a/intern/moto/CMakeLists.txt +++ b/intern/moto/CMakeLists.txt @@ -29,4 +29,3 @@ SET(INC include) FILE(GLOB SRC intern/*.cpp) BLENDERLIB(bf_intern_moto "${SRC}" "${INC}") -#, libtype=['intern','game','game2','player'], priority = [15, 55, 100, 135] ) diff --git a/intern/opennl/CMakeLists.txt b/intern/opennl/CMakeLists.txt index 0551c94e586..b29eaa680b6 100644 --- a/intern/opennl/CMakeLists.txt +++ b/intern/opennl/CMakeLists.txt @@ -29,5 +29,3 @@ SET(INC extern superlu) FILE(GLOB SRC intern/*.c superlu/*.c) BLENDERLIB(bf_intern_opennl "${SRC}" "${INC}") -#, libtype='core', priority=55 ) - diff --git a/intern/string/CMakeLists.txt b/intern/string/CMakeLists.txt index 7aeace4ca83..a1b130d93be 100644 --- a/intern/string/CMakeLists.txt +++ b/intern/string/CMakeLists.txt @@ -25,8 +25,6 @@ # ***** END GPL LICENSE BLOCK ***** SET(INC .) - -FILE(GLOB SRC intern/*.cpp) +SET(SRC ./intern/STR_String.cpp) BLENDERLIB(bf_intern_string "${SRC}" "${INC}") -#, libtype=['core', 'player'], priority = [30,10] ) diff --git a/release/bin/blender-thumbnailer.py b/release/bin/blender-thumbnailer.py index 27d6259d172..be870560110 100755 --- a/release/bin/blender-thumbnailer.py +++ b/release/bin/blender-thumbnailer.py @@ -100,7 +100,7 @@ def write_png(buf, width, height): # reverse the vertical line order and add null bytes at the start width_byte_4 = width * 4 - raw_data = b"".join([b'\x00' + buf[span:span + width_byte_4] for span in range((height - 1) * width * 4, -1, - width_byte_4)]) + raw_data = b"".join(b'\x00' + buf[span:span + width_byte_4] for span in range((height - 1) * width * 4, -1, - width_byte_4)) def png_pack(png_tag, data): chunk_head = png_tag + data diff --git a/release/getversion.py b/release/getversion.py index 29622b2154d..4c477229ef9 100755 --- a/release/getversion.py +++ b/release/getversion.py @@ -33,7 +33,7 @@ import re nanblenderhome = os.getenv("NANBLENDERHOME") -if nanblenderhome == None: +if nanblenderhome is None: nanblenderhome = os.path.dirname(os.path.abspath(sys.argv[0])) + "/.." config = nanblenderhome + "/source/blender/blenkernel/BKE_blender.h" diff --git a/release/scripts/io/netrender/master.py b/release/scripts/io/netrender/master.py index 749046fc9e1..11409bf372e 100644 --- a/release/scripts/io/netrender/master.py +++ b/release/scripts/io/netrender/master.py @@ -124,7 +124,7 @@ class MRenderJob(netrender.model.RenderJob): if self.status not in {JOB_PAUSED, JOB_QUEUED}: return - if status == None: + if status is None: self.status = JOB_PAUSED if self.status == JOB_QUEUED else JOB_QUEUED elif status: self.status = JOB_QUEUED diff --git a/release/scripts/io/netrender/slave.py b/release/scripts/io/netrender/slave.py index 1b6caa17b13..f017fefa4e3 100644 --- a/release/scripts/io/netrender/slave.py +++ b/release/scripts/io/netrender/slave.py @@ -188,7 +188,7 @@ def render_slave(engine, netsettings, threads): cancelled = False stdout = bytes() run_t = time.time() - while not cancelled and process.poll() == None: + while not cancelled and process.poll() is None: stdout += process.stdout.read(1024) current_t = time.time() cancelled = engine.test_break() @@ -219,7 +219,7 @@ def render_slave(engine, netsettings, threads): if cancelled: # kill process if needed - if process.poll() == None: + if process.poll() is None: try: process.terminate() except OSError: diff --git a/release/scripts/io/netrender/utils.py b/release/scripts/io/netrender/utils.py index 81617ac0d30..e2a5051cf64 100644 --- a/release/scripts/io/netrender/utils.py +++ b/release/scripts/io/netrender/utils.py @@ -192,7 +192,7 @@ def prefixPath(prefix_directory, file_path, prefix_path, force = False): def getFileInfo(filepath, infos): process = subprocess.Popen([sys.argv[0], "-b", "-noaudio", filepath, "-P", __file__, "--"] + infos, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout = bytes() - while process.poll() == None: + while process.poll() is None: stdout += process.stdout.read(1024) # read leftovers if needed diff --git a/release/scripts/keyingsets/keyingsets_builtins.py b/release/scripts/keyingsets/keyingsets_builtins.py index bf5c66ad01d..73b75057299 100644 --- a/release/scripts/keyingsets/keyingsets_builtins.py +++ b/release/scripts/keyingsets/keyingsets_builtins.py @@ -11,200 +11,200 @@ from keyingsets_utils import * # Location class BUILTIN_KSI_Location(bpy.types.KeyingSetInfo): - bl_label = "Location" - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - generate = RKS_GEN_location - + bl_label = "Location" + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + generate = RKS_GEN_location + # Rotation class BUILTIN_KSI_Rotation(bpy.types.KeyingSetInfo): - bl_label = "Rotation" - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - generate = RKS_GEN_rotation - + bl_label = "Rotation" + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + generate = RKS_GEN_rotation + # Scale class BUILTIN_KSI_Scaling(bpy.types.KeyingSetInfo): - bl_label = "Scaling" - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - generate = RKS_GEN_scaling + bl_label = "Scaling" + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + generate = RKS_GEN_scaling # ------------ - + # LocRot class BUILTIN_KSI_LocRot(bpy.types.KeyingSetInfo): - bl_label = "LocRot" - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - def generate(self, context, ks, data): - # location - RKS_GEN_location(self, context, ks, data) - # rotation - RKS_GEN_rotation(self, context, ks, data) + bl_label = "LocRot" + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + def generate(self, context, ks, data): + # location + RKS_GEN_location(self, context, ks, data) + # rotation + RKS_GEN_rotation(self, context, ks, data) # LocScale class BUILTIN_KSI_LocScale(bpy.types.KeyingSetInfo): - bl_label = "LocScale" - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - def generate(self, context, ks, data): - # location - RKS_GEN_location(self, context, ks, data) - # scale - RKS_GEN_scaling(self, context, ks, data) + bl_label = "LocScale" + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + def generate(self, context, ks, data): + # location + RKS_GEN_location(self, context, ks, data) + # scale + RKS_GEN_scaling(self, context, ks, data) # LocRotScale class BUILTIN_KSI_LocRotScale(bpy.types.KeyingSetInfo): - bl_label = "LocRotScale" - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - def generate(self, context, ks, data): - # location - RKS_GEN_location(self, context, ks, data) - # rotation - RKS_GEN_rotation(self, context, ks, data) - # scale - RKS_GEN_scaling(self, context, ks, data) + bl_label = "LocRotScale" + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + def generate(self, context, ks, data): + # location + RKS_GEN_location(self, context, ks, data) + # rotation + RKS_GEN_rotation(self, context, ks, data) + # scale + RKS_GEN_scaling(self, context, ks, data) # RotScale class BUILTIN_KSI_RotScale(bpy.types.KeyingSetInfo): - bl_label = "RotScale" - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - def generate(self, context, ks, data): - # rotation - RKS_GEN_rotation(self, context, ks, data) - # scaling - RKS_GEN_scaling(self, context, ks, data) - + bl_label = "RotScale" + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + def generate(self, context, ks, data): + # rotation + RKS_GEN_rotation(self, context, ks, data) + # scaling + RKS_GEN_scaling(self, context, ks, data) + # ------------ # Location class BUILTIN_KSI_VisualLoc(bpy.types.KeyingSetInfo): - bl_label = "Visual Location" - - insertkey_visual = True - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - generate = RKS_GEN_location - + bl_label = "Visual Location" + + insertkey_visual = True + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + generate = RKS_GEN_location + # Rotation class BUILTIN_KSI_VisualRot(bpy.types.KeyingSetInfo): - bl_label = "Visual Rotation" - - insertkey_visual = True - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - generate = RKS_GEN_rotation + bl_label = "Visual Rotation" + + bl_options = {'INSERTKEY_VISUAL'} + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + generate = RKS_GEN_rotation # VisualLocRot class BUILTIN_KSI_VisualLocRot(bpy.types.KeyingSetInfo): - bl_label = "Visual LocRot" - - insertkey_visual = True - - # poll - use predefined callback for selected bones/objects - poll = RKS_POLL_selected_items - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - def generate(self, context, ks, data): - # location - RKS_GEN_location(self, context, ks, data) - # rotation - RKS_GEN_rotation(self, context, ks, data) + bl_label = "Visual LocRot" + + bl_options = {'INSERTKEY_VISUAL'} + + # poll - use predefined callback for selected bones/objects + poll = RKS_POLL_selected_items + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + def generate(self, context, ks, data): + # location + RKS_GEN_location(self, context, ks, data) + # rotation + RKS_GEN_rotation(self, context, ks, data) # ------------ # Available class BUILTIN_KSI_Available(bpy.types.KeyingSetInfo): - bl_label = "Available" - - # poll - use predefined callback for selected objects - # TODO: this should really check whether the selected object (or datablock) - # has any animation data defined yet - poll = RKS_POLL_selected_objects - - # iterator - use callback for selected bones/objects - iterator = RKS_ITER_selected_item - - # generator - use callback for location - generate = RKS_GEN_available + bl_label = "Available" + + # poll - use predefined callback for selected objects + # TODO: this should really check whether the selected object (or datablock) + # has any animation data defined yet + poll = RKS_POLL_selected_objects + + # iterator - use callback for selected bones/objects + iterator = RKS_ITER_selected_item + + # generator - use callback for location + generate = RKS_GEN_available ############################### classes = [ - BUILTIN_KSI_Location, - BUILTIN_KSI_Rotation, - BUILTIN_KSI_Scaling, - - BUILTIN_KSI_LocRot, - BUILTIN_KSI_LocScale, - BUILTIN_KSI_LocRotScale, - BUILTIN_KSI_RotScale, - - BUILTIN_KSI_VisualLoc, - BUILTIN_KSI_VisualRot, - BUILTIN_KSI_VisualLocRot, - - BUILTIN_KSI_Available, + BUILTIN_KSI_Location, + BUILTIN_KSI_Rotation, + BUILTIN_KSI_Scaling, + + BUILTIN_KSI_LocRot, + BUILTIN_KSI_LocScale, + BUILTIN_KSI_LocRotScale, + BUILTIN_KSI_RotScale, + + BUILTIN_KSI_VisualLoc, + BUILTIN_KSI_VisualRot, + BUILTIN_KSI_VisualLocRot, + + BUILTIN_KSI_Available, ] diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 5d5f736a33b..1792425268b 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -441,17 +441,18 @@ def addon_disable(module_name, default_set=True): mod = _sys.modules.get(module_name) - if mod is None: - print("addon_disable", module_name, "not loaded, nothing to do") - return + # possible this addon is from a previous session and didnt load a module this time. + # so even if the module is not found, still disable the addon in the user prefs. + if mod: + mod.__addon_enabled__ = False - mod.__addon_enabled__ = False - - try: - _bpy_types._unregister_module(module_name, free=False) # dont free because we may want to enable again. - mod.unregister() - except: - traceback.print_exc() + try: + _bpy_types._unregister_module(module_name, free=False) # dont free because we may want to enable again. + mod.unregister() + except: + traceback.print_exc() + else: + print("addon_disable", module_name, "not loaded") # could be in more then once, unlikely but better do this just incase. addons = _bpy.context.user_preferences.addons diff --git a/release/scripts/modules/io_utils.py b/release/scripts/modules/io_utils.py index adc3afce71d..eb9b2eaa90b 100644 --- a/release/scripts/modules/io_utils.py +++ b/release/scripts/modules/io_utils.py @@ -29,7 +29,13 @@ class ExportHelper: def invoke(self, context, event): import os if not self.filepath: - self.filepath = os.path.splitext(context.blend_data.filepath)[0] + self.filename_ext + blend_filepath = context.blend_data.filepath + if not blend_filepath: + blend_filepath = "untitled" + else: + blend_filepath = os.path.splitext(blend_filepath)[0] + + self.filepath = blend_filepath + self.filename_ext context.window_manager.add_fileselect(self) return {'RUNNING_MODAL'} diff --git a/release/scripts/modules/rigify/eye_balls.py b/release/scripts/modules/rigify/eye_balls.py index f65d56b9f2b..127ee87123f 100644 --- a/release/scripts/modules/rigify/eye_balls.py +++ b/release/scripts/modules/rigify/eye_balls.py @@ -56,7 +56,7 @@ def addget_shape_key_driver(obj, name="Key"): for driver_s in obj.data.shape_keys.animation_data.drivers: if driver_s.data_path == driver_path: fcurve = driver_s - if fcurve == None: + if fcurve is None: fcurve = obj.data.shape_keys.keys[name].driver_add("value") fcurve.driver.type = 'AVERAGE' new = True diff --git a/release/scripts/modules/rigify/mouth.py b/release/scripts/modules/rigify/mouth.py index ce232b91e7b..ef3875222d3 100644 --- a/release/scripts/modules/rigify/mouth.py +++ b/release/scripts/modules/rigify/mouth.py @@ -76,7 +76,7 @@ def addget_shape_key_driver(obj, name="Key"): for driver_s in obj.data.shape_keys.animation_data.drivers: if driver_s.data_path == driver_path: fcurve = driver_s - if fcurve == None: + if fcurve is None: fcurve = obj.data.shape_keys.keys[name].driver_add("value") fcurve.driver.type = 'AVERAGE' new = True diff --git a/release/scripts/modules/rigify/shape_key_control.py b/release/scripts/modules/rigify/shape_key_control.py index 1bfca60255d..a5f57313ab5 100644 --- a/release/scripts/modules/rigify/shape_key_control.py +++ b/release/scripts/modules/rigify/shape_key_control.py @@ -56,7 +56,7 @@ def addget_shape_key_driver(obj, name="Key"): for driver_s in obj.data.shape_keys.animation_data.drivers: if driver_s.data_path == driver_path: fcurve = driver_s - if fcurve == None: + if fcurve is None: fcurve = obj.data.shape_keys.keys[name].driver_add("value") fcurve.driver.type = 'AVERAGE' new = True diff --git a/release/scripts/modules/rigify/shape_key_distance.py b/release/scripts/modules/rigify/shape_key_distance.py index 7d69517216f..3045fcdab0d 100644 --- a/release/scripts/modules/rigify/shape_key_distance.py +++ b/release/scripts/modules/rigify/shape_key_distance.py @@ -53,7 +53,7 @@ def addget_shape_key_driver(obj, name="Key"): for driver_s in obj.data.shape_keys.animation_data.drivers: if driver_s.data_path == driver_path: fcurve = driver_s - if fcurve == None: + if fcurve is None: fcurve = obj.data.shape_keys.keys[name].driver_add("value") fcurve.driver.type = 'AVERAGE' diff --git a/release/scripts/modules/rigify/shape_key_rotdiff.py b/release/scripts/modules/rigify/shape_key_rotdiff.py index dfc3b914a6a..a6ba5adfe6b 100644 --- a/release/scripts/modules/rigify/shape_key_rotdiff.py +++ b/release/scripts/modules/rigify/shape_key_rotdiff.py @@ -53,7 +53,7 @@ def addget_shape_key_driver(obj, name="Key"): for driver_s in obj.data.shape_keys.animation_data.drivers: if driver_s.data_path == driver_path: fcurve = driver_s - if fcurve == None: + if fcurve is None: fcurve = obj.data.shape_keys.keys[name].driver_add("value") fcurve.driver.type = 'AVERAGE' diff --git a/release/scripts/modules/rigify/tail_control.py b/release/scripts/modules/rigify/tail_control.py index 50a9bb236da..32d414344cf 100644 --- a/release/scripts/modules/rigify/tail_control.py +++ b/release/scripts/modules/rigify/tail_control.py @@ -58,7 +58,7 @@ def metarig_definition(obj, orig_bone_name): arm = obj.data tail_base = arm.bones[orig_bone_name] - if tail_base.parent == None: + if tail_base.parent is None: raise RigifyError("'tail_control' rig type on bone '%s' requires a parent." % orig_bone_name) bone_definitions = [tail_base.name] diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index b2b8558b988..4282889c51a 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -220,7 +220,7 @@ class InfoPropertyRNA: # special case for floats if len(self.default) > 0: if self.type == "float": - self.default_str = "(%s)" % ", ".join([float_as_string(f) for f in self.default]) + self.default_str = "(%s)" % ", ".join(float_as_string(f) for f in self.default) if not self.default_str: self.default_str = str(self.default) else: @@ -247,7 +247,7 @@ class InfoPropertyRNA: if self.type in ("float", "int"): type_str += " in [%s, %s]" % (range_str(self.min), range_str(self.max)) elif self.type == "enum": - type_str += " in [%s]" % ', '.join([("'%s'" % s) for s in self.enum_items]) + type_str += " in [%s]" % ", ".join(("'%s'" % s) for s in self.enum_items) if not (as_arg or as_ret): # write default property, ignore function args for this @@ -381,7 +381,7 @@ class InfoOperatorRNA: def _GetInfoRNA(bl_rna, cls, parent_id=''): - if bl_rna == None: + if bl_rna is None: return None key = parent_id, bl_rna.identifier diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 0afe79e4829..cbe0b668e77 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -36,7 +36,7 @@ def rna_idprop_ui_prop_get(item, prop, create=True): rna_ui = rna_idprop_ui_get(item, create) - if rna_ui == None: + if rna_ui is None: return None try: @@ -49,7 +49,7 @@ def rna_idprop_ui_prop_get(item, prop, create=True): def rna_idprop_ui_prop_clear(item, prop): rna_ui = rna_idprop_ui_get(item, False) - if rna_ui == None: + if rna_ui is None: return try: diff --git a/release/scripts/op/fcurve_euler_filter.py b/release/scripts/op/fcurve_euler_filter.py index a2730e16843..b396fa0562f 100644 --- a/release/scripts/op/fcurve_euler_filter.py +++ b/release/scripts/op/fcurve_euler_filter.py @@ -15,7 +15,7 @@ def main(context): prev = keys[i-1] if i > 0 else None next = keys[i+1] if i < len(keys)-1 else None - if prev == None: + if prev is None: continue th = pi diff --git a/release/scripts/op/io_anim_bvh/__init__.py b/release/scripts/op/io_anim_bvh/__init__.py index b8bdec592bc..e7b922e1ceb 100644 --- a/release/scripts/op/io_anim_bvh/__init__.py +++ b/release/scripts/op/io_anim_bvh/__init__.py @@ -36,6 +36,7 @@ class BvhImporter(bpy.types.Operator, ImportHelper): bl_label = "Import BVH" filename_ext = ".bvh" + filter_glob = StringProperty(default="*.bvh", options={'HIDDEN'}) scale = FloatProperty(name="Scale", description="Scale the BVH by this value", min=0.0001, max=1000000.0, soft_min=0.001, soft_max=100.0, default=0.1) frame_start = IntProperty(name="Start Frame", description="Starting frame for the animation", default=1) diff --git a/release/scripts/op/io_anim_bvh/import_bvh.py b/release/scripts/op/io_anim_bvh/import_bvh.py index 5f9de6cbd90..ef0fb92aee5 100644 --- a/release/scripts/op/io_anim_bvh/import_bvh.py +++ b/release/scripts/op/io_anim_bvh/import_bvh.py @@ -177,7 +177,7 @@ def read_bvh(context, file_path, ROT_MODE='XYZ', GLOBAL_SCALE=1.0): # Apply the parents offset accumletivly - if my_parent == None: + if my_parent is None: rest_head_world = Vector(rest_head_local) else: rest_head_world = my_parent.rest_head_world + rest_head_local @@ -360,12 +360,10 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM arm_ob.select = True scn.objects.active = arm_ob - print(scn.objects.active) bpy.ops.object.mode_set(mode='OBJECT', toggle=False) bpy.ops.object.mode_set(mode='EDIT', toggle=False) - # Get the average bone length for zero length bones, we may not use this. average_bone_length = 0.0 nonzero_count = 0 @@ -382,22 +380,14 @@ def bvh_node_dict2armature(context, bvh_nodes, ROT_MODE='XYZ', IMPORT_START_FRAM # Normal operation average_bone_length = average_bone_length / nonzero_count - -#XXX - sloppy operator code - - bpy.ops.armature.delete() - bpy.ops.armature.select_all() - bpy.ops.armature.delete() + # XXX, annoying, remove bone. + while arm_data.edit_bones: + arm_ob.edit_bones.remove(arm_data.edit_bones[-1]) ZERO_AREA_BONES = [] for name, bvh_node in bvh_nodes.items(): # New editbone - bpy.ops.armature.bone_primitive_add(name="Bone") - - bone = bvh_node.temp = arm_data.edit_bones[-1] - - bone.name = name -# arm_data.bones[name]= bone + bone = bvh_node.temp = arm_data.edit_bones.new(name) bone.head = bvh_node.rest_head_world bone.tail = bvh_node.rest_tail_world diff --git a/release/scripts/op/io_mesh_ply/__init__.py b/release/scripts/op/io_mesh_ply/__init__.py index 18820dea549..a67afe0cc87 100644 --- a/release/scripts/op/io_mesh_ply/__init__.py +++ b/release/scripts/op/io_mesh_ply/__init__.py @@ -53,11 +53,11 @@ class ExportPLY(bpy.types.Operator, ExportHelper): layout = self.layout row = layout.row() - row.prop(self.properties, "use_modifiers") - row.prop(self.properties, "use_normals") + row.prop(self, "use_modifiers") + row.prop(self, "use_normals") row = layout.row() - row.prop(self.properties, "use_uv_coords") - row.prop(self.properties, "use_colors") + row.prop(self, "use_uv_coords") + row.prop(self, "use_colors") def menu_func(self, context): diff --git a/release/scripts/op/io_mesh_ply/export_ply.py b/release/scripts/op/io_mesh_ply/export_ply.py index aef4df43841..08369a46c84 100644 --- a/release/scripts/op/io_mesh_ply/export_ply.py +++ b/release/scripts/op/io_mesh_ply/export_ply.py @@ -142,7 +142,7 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u vdict_local = vdict[vidx] pf_vidx = vdict_local.get(key) # Will be None initially - if pf_vidx == None: # same as vdict_local.has_key(key) + if pf_vidx is None: # same as vdict_local.has_key(key) pf_vidx = vdict_local[key] = vert_count ply_verts.append((vidx, normal, uvcoord, color)) vert_count += 1 diff --git a/release/scripts/op/io_scene_3ds/__init__.py b/release/scripts/op/io_scene_3ds/__init__.py index 242ed751ceb..139a88209d2 100644 --- a/release/scripts/op/io_scene_3ds/__init__.py +++ b/release/scripts/op/io_scene_3ds/__init__.py @@ -36,6 +36,7 @@ class Import3DS(bpy.types.Operator, ImportHelper): bl_label = 'Import 3DS' filename_ext = ".3ds" + filter_glob = StringProperty(default="*.3ds", options={'HIDDEN'}) constrain_size = FloatProperty(name="Size Constraint", description="Scale the model by 10 until it reacehs the size constraint. Zero Disables.", min=0.0, max=1000.0, soft_min=0.0, soft_max=1000.0, default=10.0) use_image_search = BoolProperty(name="Image Search", description="Search subdirectories for any assosiated images (Warning, may be slow)", default=True) diff --git a/release/scripts/op/io_scene_3ds/export_3ds.py b/release/scripts/op/io_scene_3ds/export_3ds.py index 3d1cc02a8d8..0cbb4347dda 100644 --- a/release/scripts/op/io_scene_3ds/export_3ds.py +++ b/release/scripts/op/io_scene_3ds/export_3ds.py @@ -303,17 +303,17 @@ class _3ds_named_variable(object): self.value=val def get_size(self): - if (self.value==None): + if self.value is None: return 0 else: return self.value.get_size() def write(self, file): - if (self.value!=None): + if self.value is not None: self.value.write(file) def dump(self,indent): - if (self.value!=None): + if self.value is not None: spaces="" for i in range(indent): spaces += " " @@ -827,7 +827,7 @@ def make_kf_obj_node(obj, name_to_id): # Check parent-child relationships: parent = obj.parent - if (parent == None) or (parent.name not in name_to_id): + if (parent is None) or (parent.name not in name_to_id): # If no parent, or the parents name is not in the name_to_id dictionary, # parent id becomes -1: obj_node_header_chunk.add_variable("parent", _3ds_short(-1)) @@ -906,7 +906,8 @@ def save(operator, context, filepath=""): # get derived objects free, derived = create_derived_objects(scene, ob) - if derived == None: continue + if derived is None: + continue for ob_derived, mat in derived: # for ob_derived, mat in getDerivedObjects(ob, False): diff --git a/release/scripts/op/io_scene_fbx/__init__.py b/release/scripts/op/io_scene_fbx/__init__.py index d1bf5e168e4..75d302153f7 100644 --- a/release/scripts/op/io_scene_fbx/__init__.py +++ b/release/scripts/op/io_scene_fbx/__init__.py @@ -86,7 +86,25 @@ class ExportFBX(bpy.types.Operator, ExportHelper): GLOBAL_MATRIX = mtx4_z90n * GLOBAL_MATRIX import io_scene_fbx.export_fbx - return io_scene_fbx.export_fbx.save(self, context, GLOBAL_MATRIX=GLOBAL_MATRIX, **self.properties) + return io_scene_fbx.export_fbx.save(self, context, self.filepath, + GLOBAL_MATRIX=GLOBAL_MATRIX, + EXP_OBS_SELECTED=self.EXP_OBS_SELECTED, + EXP_MESH=self.EXP_MESH, + EXP_MESH_APPLY_MOD=self.EXP_MESH_APPLY_MOD, + EXP_ARMATURE=self.EXP_ARMATURE, + EXP_LAMP=self.EXP_LAMP, + EXP_CAMERA=self.EXP_CAMERA, + EXP_EMPTY=self.EXP_EMPTY, + EXP_IMAGE_COPY=self.EXP_IMAGE_COPY, + ANIM_ENABLE=self.ANIM_ENABLE, + ANIM_OPTIMIZE=self.ANIM_OPTIMIZE, + ANIM_OPTIMIZE_PRECISSION=self.ANIM_OPTIMIZE_PRECISSION, + ANIM_ACTION_ALL=self.ANIM_ACTION_ALL, + BATCH_ENABLE=self.BATCH_ENABLE, + BATCH_GROUP=self.BATCH_GROUP, + BATCH_FILE_PREFIX=self.BATCH_FILE_PREFIX, + BATCH_OWN_DIR=self.BATCH_OWN_DIR, + ) def menu_func(self, context): diff --git a/release/scripts/op/io_scene_fbx/export_fbx.py b/release/scripts/op/io_scene_fbx/export_fbx.py index 51a5f86a5e4..4859e87620f 100644 --- a/release/scripts/op/io_scene_fbx/export_fbx.py +++ b/release/scripts/op/io_scene_fbx/export_fbx.py @@ -181,14 +181,12 @@ def getVertsFromGroup(me, group_index): return ret # ob must be OB_MESH -def BPyMesh_meshWeight2List(ob): +def BPyMesh_meshWeight2List(ob, me): ''' Takes a mesh and return its group names and a list of lists, one list per vertex. aligning the each vert list with the group names, each list contains float value for the weight. These 2 lists can be modified and then used with list2MeshWeight to apply the changes. ''' - me = ob.data - # Clear the vert group. groupNames= [g.name for g in ob.vertex_groups] len_groupNames= len(groupNames) @@ -205,9 +203,9 @@ def BPyMesh_meshWeight2List(ob): return groupNames, vWeightList -def meshNormalizedWeights(me): +def meshNormalizedWeights(ob, me): try: # account for old bad BPyMesh - groupNames, vWeightList = BPyMesh_meshWeight2List(me) + groupNames, vWeightList = BPyMesh_meshWeight2List(ob, me) # groupNames, vWeightList = BPyMesh.meshWeight2List(me) except: return [],[] @@ -235,7 +233,8 @@ header_comment = \ ''' # This func can be called with just the filepath -def save(operator, context, filepath="", \ +def save(operator, context, filepath="", + GLOBAL_MATRIX = None, EXP_OBS_SELECTED = True, EXP_MESH = True, EXP_MESH_APPLY_MOD = True, @@ -244,7 +243,6 @@ def save(operator, context, filepath="", \ EXP_CAMERA = True, EXP_EMPTY = True, EXP_IMAGE_COPY = False, - GLOBAL_MATRIX = None, ANIM_ENABLE = True, ANIM_OPTIMIZE = True, ANIM_OPTIMIZE_PRECISSION = 6, @@ -270,8 +268,6 @@ def save(operator, context, filepath="", \ # ----------------- Batch support! if BATCH_ENABLE: - if os == None: BATCH_OWN_DIR = False - fbxpath = filepath # get the path component of filepath @@ -315,7 +311,6 @@ def save(operator, context, filepath="", \ new_fbxpath = fbxpath # own dir option modifies, we need to keep an original for data in data_seq: # scene or group newname = BATCH_FILE_PREFIX + bpy.path.clean_name(data.name) -# newname = BATCH_FILE_PREFIX + BPySys.bpy.path.clean_name(data.name) if BATCH_OWN_DIR: @@ -372,8 +367,7 @@ def save(operator, context, filepath="", \ if BATCH_GROUP: # remove temp group scene - bpy.data.remove_scene(scene) -# bpy.data.scenes.unlink(scene) + bpy.data.scenes.unlink(scene) bpy.data.scenes.active = orig_sce @@ -509,17 +503,16 @@ def save(operator, context, filepath="", \ return GLOBAL_MATRIX * self.__anim_poselist[frame] def getAnimParRelMatrixRot(self, frame): - type = self.blenObject.type + obj_type = self.blenObject.type if self.fbxParent: matrix_rot = ((GLOBAL_MATRIX * self.fbxParent.__anim_poselist[frame]).invert() * (GLOBAL_MATRIX * self.__anim_poselist[frame])).rotation_part() else: matrix_rot = (GLOBAL_MATRIX * self.__anim_poselist[frame]).rotation_part() # Lamps need to be rotated - if type =='LAMP': + if obj_type =='LAMP': matrix_rot = matrix_rot * mtx_x90 - elif type =='CAMERA': -# elif ob and type =='Camera': + elif obj_type =='CAMERA': y = matrix_rot * Vector((0.0, 1.0, 0.0)) matrix_rot = Matrix.Rotation(math.pi/2, 3, y) * matrix_rot @@ -533,14 +526,12 @@ def save(operator, context, filepath="", \ print('\nFBX export starting... %r' % filepath) start_time = time.clock() -# start_time = Blender.sys.time() try: file = open(filepath, 'w') except: return False scene = context.scene -# scene = bpy.data.scenes.active world = scene.world @@ -618,10 +609,10 @@ def save(operator, context, filepath="", \ matrix_rot = matrix.rotation_part() # Lamps need to be rotated - if ob and ob.type =='Lamp': + if ob and ob.type =='LAMP': matrix_rot = matrix_rot * mtx_x90 rot = tuple(matrix_rot.to_euler()) - elif ob and ob.type =='Camera': + elif ob and ob.type =='CAMERA': y = matrix_rot * Vector((0.0, 1.0, 0.0)) matrix_rot = Matrix.Rotation(math.pi/2, 3, y) * matrix_rot rot = tuple(matrix_rot.to_euler()) @@ -733,7 +724,6 @@ def save(operator, context, filepath="", \ Property: "NegativePercentShapeSupport", "bool", "",1 Property: "DefaultAttributeIndex", "int", "",0''') if ob and not isinstance(ob, bpy.types.Bone): -# if ob and type(ob) != Blender.Types.BoneType: # Only mesh objects have color file.write('\n\t\t\tProperty: "Color", "Color", "A",0.8,0.8,0.8') file.write('\n\t\t\tProperty: "Size", "double", "",100') @@ -954,9 +944,7 @@ def save(operator, context, filepath="", \ file.write('\n\t\t\tProperty: "ShowAzimut", "bool", "",1') file.write('\n\t\t\tProperty: "ShowTimeCode", "bool", "",0') file.write('\n\t\t\tProperty: "NearPlane", "double", "",%.6f' % data.clip_start) -# file.write('\n\t\t\tProperty: "NearPlane", "double", "",%.6f' % data.clipStart) file.write('\n\t\t\tProperty: "FarPlane", "double", "",%.6f' % data.clip_end) -# file.write('\n\t\t\tProperty: "FarPlane", "double", "",%.6f' % data.clipStart) file.write('\n\t\t\tProperty: "FilmWidth", "double", "",1.0') file.write('\n\t\t\tProperty: "FilmHeight", "double", "",1.0') file.write('\n\t\t\tProperty: "FilmAspectRatio", "double", "",%.6f' % aspect) @@ -1031,7 +1019,7 @@ def save(operator, context, filepath="", \ #eSPOT light_type_items = {'POINT': 0, 'SUN': 1, 'SPOT': 2, 'HEMI': 3, 'AREA': 4} light_type = light_type_items[light.type] -# light_type = light.type + if light_type > 2: light_type = 1 # hemi and area lights become directional # mode = light.mode @@ -1041,7 +1029,7 @@ def save(operator, context, filepath="", \ else: do_shadow = 0 - if light.use_only_shadow or (not light.diffuse and not light.specular): + if light.use_only_shadow or (not light.use_diffuse and not light.use_specular): # if mode & Blender.Lamp.Modes.OnlyShadow or (mode & Blender.Lamp.Modes.NoDiffuse and mode & Blender.Lamp.Modes.NoSpecular): do_light = 0 else: @@ -1059,14 +1047,11 @@ def save(operator, context, filepath="", \ file.write('\n\t\t\tProperty: "Intensity", "Intensity", "A+",%.2f' % (min(light.energy*100, 200))) # clamp below 200 if light.type == 'SPOT': file.write('\n\t\t\tProperty: "Cone angle", "Cone angle", "A+",%.2f' % math.degrees(light.spot_size)) -# file.write('\n\t\t\tProperty: "Cone angle", "Cone angle", "A+",%.2f' % (light.spotSize * scale)) file.write('\n\t\t\tProperty: "Fog", "Fog", "A+",50') file.write('\n\t\t\tProperty: "Color", "Color", "A",%.2f,%.2f,%.2f' % tuple(light.color)) -# file.write('\n\t\t\tProperty: "Color", "Color", "A",%.2f,%.2f,%.2f' % tuple(light.col)) + file.write('\n\t\t\tProperty: "Intensity", "Intensity", "A+",%.2f' % (min(light.energy*100, 200))) # clamp below 200 -# - # duplication? see ^ (Arystan) -# file.write('\n\t\t\tProperty: "Cone angle", "Cone angle", "A+",%.2f' % (light.spotSize * scale)) + file.write('\n\t\t\tProperty: "Fog", "Fog", "A+",50') file.write('\n\t\t\tProperty: "LightType", "enum", "",%i' % light_type) file.write('\n\t\t\tProperty: "CastLightOnObject", "bool", "",%i' % do_light) @@ -1076,7 +1061,6 @@ def save(operator, context, filepath="", \ file.write('\n\t\t\tProperty: "GoboProperty", "object", ""') file.write('\n\t\t\tProperty: "DecayType", "enum", "",0') file.write('\n\t\t\tProperty: "DecayStart", "double", "",%.2f' % light.distance) -# file.write('\n\t\t\tProperty: "DecayStart", "double", "",%.2f' % light.dist) file.write('\n\t\t\tProperty: "EnableNearAttenuation", "bool", "",0') file.write('\n\t\t\tProperty: "NearAttenuationStart", "double", "",0') file.write('\n\t\t\tProperty: "NearAttenuationEnd", "double", "",0') @@ -1132,30 +1116,21 @@ def save(operator, context, filepath="", \ # Todo, add more material Properties. if mat: mat_cold = tuple(mat.diffuse_color) -# mat_cold = tuple(mat.rgbCol) mat_cols = tuple(mat.specular_color) -# mat_cols = tuple(mat.specCol) #mat_colm = tuple(mat.mirCol) # we wont use the mirror color mat_colamb = world_amb -# mat_colamb = tuple([c for c in world_amb]) mat_dif = mat.diffuse_intensity -# mat_dif = mat.ref mat_amb = mat.ambient -# mat_amb = mat.amb mat_hard = (float(mat.specular_hardness)-1)/5.10 -# mat_hard = (float(mat.hard)-1)/5.10 mat_spec = mat.specular_intensity/2.0 -# mat_spec = mat.spec/2.0 mat_alpha = mat.alpha mat_emit = mat.emit mat_shadeless = mat.use_shadeless -# mat_shadeless = mat.mode & Blender.Material.Modes.SHADELESS if mat_shadeless: mat_shader = 'Lambert' else: if mat.diffuse_shader == 'LAMBERT': -# if mat.diffuseShader == Blender.Material.Shaders.DIFFUSE_LAMBERT: mat_shader = 'Lambert' else: mat_shader = 'Phong' @@ -1262,7 +1237,7 @@ def save(operator, context, filepath="", \ def write_texture(texname, tex, num): - # if tex == None then this is a dummy tex + # if tex is None then this is a dummy tex file.write('\n\tTexture: "Texture::%s", "TextureVideoClip" {' % texname) file.write('\n\t\tType: "TextureVideoClip"') file.write('\n\t\tVersion: 202') @@ -1287,9 +1262,7 @@ def save(operator, context, filepath="", \ Property: "UVSwap", "bool", "",0''') file.write('\n\t\t\tProperty: "WrapModeU", "enum", "",%i' % tex.use_clamp_x) -# file.write('\n\t\t\tProperty: "WrapModeU", "enum", "",%i' % tex.clampX) file.write('\n\t\t\tProperty: "WrapModeV", "enum", "",%i' % tex.use_clamp_y) -# file.write('\n\t\t\tProperty: "WrapModeV", "enum", "",%i' % tex.clampY) file.write(''' Property: "TextureRotationPivot", "Vector3D", "",0,0,0 @@ -1425,8 +1398,7 @@ def save(operator, context, filepath="", \ if my_mesh.blenTextures: do_textures = True else: do_textures = False - do_uvs = len(me.uv_textures) > 0 -# do_uvs = me.faceUV + do_uvs = bool(me.uv_textures) file.write('\n\tModel: "Model::%s", "Mesh" {' % my_mesh.fbxName) @@ -1498,14 +1470,12 @@ def save(operator, context, filepath="", \ for ed in me.edges: if i==-1: file.write('%i,%i' % (ed.vertices[0], ed.vertices[1])) -# file.write('%i,%i' % (ed.v1.index, ed.v2.index)) i=0 else: if i==13: file.write('\n\t\t') i=0 file.write(',%i,%i' % (ed.vertices[0], ed.vertices[1])) -# file.write(',%i,%i' % (ed.v1.index, ed.v2.index)) i+=1 file.write('\n\t\tGeometryVersion: 124') @@ -1522,12 +1492,10 @@ def save(operator, context, filepath="", \ for v in me.vertices: if i==-1: file.write('%.15f,%.15f,%.15f' % tuple(v.normal)); i=0 -# file.write('%.15f,%.15f,%.15f' % tuple(v.no)); i=0 else: if i==2: file.write('\n '); i=0 file.write(',%.15f,%.15f,%.15f' % tuple(v.normal)) -# file.write(',%.15f,%.15f,%.15f' % tuple(v.no)) i+=1 file.write('\n\t\t}') @@ -1586,17 +1554,11 @@ def save(operator, context, filepath="", \ # note, no programs seem to use this info :/ collayers = [] if len(me.vertex_colors): -# if me.vertexColors: collayers = me.vertex_colors -# collayers = me.getColorLayerNames() - collayer_orig = me.vertex_colors.active -# collayer_orig = me.activeColorLayer for colindex, collayer in enumerate(collayers): -# me.activeColorLayer = collayer file.write('\n\t\tLayerElementColor: %i {' % colindex) file.write('\n\t\t\tVersion: 101') file.write('\n\t\t\tName: "%s"' % collayer.name) -# file.write('\n\t\t\tName: "%s"' % collayer) file.write(''' MappingInformationType: "ByPolygonVertex" @@ -1624,19 +1586,6 @@ def save(operator, context, filepath="", \ i+=1 ii+=1 # One more Color -# for f in me.faces: -# for col in f.col: -# if i==-1: -# file.write('%.4f,%.4f,%.4f,1' % (col[0]/255.0, col[1]/255.0, col[2]/255.0)) -# i=0 -# else: -# if i==7: -# file.write('\n\t\t\t\t') -# i=0 -# file.write(',%.4f,%.4f,%.4f,1' % (col[0]/255.0, col[1]/255.0, col[2]/255.0)) -# i+=1 -# ii+=1 # One more Color - file.write('\n\t\t\tColorIndex: ') i = -1 for j in range(ii): @@ -1658,16 +1607,11 @@ def save(operator, context, filepath="", \ uvlayers = [] if do_uvs: uvlayers = me.uv_textures -# uvlayers = me.getUVLayerNames() uvlayer_orig = me.uv_textures.active -# uvlayer_orig = me.activeUVLayer for uvindex, uvlayer in enumerate(me.uv_textures): -# for uvindex, uvlayer in enumerate(uvlayers): -# me.activeUVLayer = uvlayer file.write('\n\t\tLayerElementUV: %i {' % uvindex) file.write('\n\t\t\tVersion: 101') file.write('\n\t\t\tName: "%s"' % uvlayer.name) -# file.write('\n\t\t\tName: "%s"' % uvlayer) file.write(''' MappingInformationType: "ByPolygonVertex" @@ -1678,10 +1622,8 @@ def save(operator, context, filepath="", \ ii = 0 # Count how many UVs we write for uf in uvlayer.data: -# for f in me.faces: # workaround, since uf.uv iteration is wrong atm for uv in uf.uv: -# for uv in f.uv: if i==-1: file.write('%.6f,%.6f' % tuple(uv)) i=0 @@ -1712,7 +1654,6 @@ def save(operator, context, filepath="", \ file.write('\n\t\tLayerElementTexture: %i {' % uvindex) file.write('\n\t\t\tVersion: 101') file.write('\n\t\t\tName: "%s"' % uvlayer.name) -# file.write('\n\t\t\tName: "%s"' % uvlayer) if len(my_mesh.blenTextures) == 1: file.write('\n\t\t\tMappingInformationType: "AllSame"') @@ -1737,7 +1678,6 @@ def save(operator, context, filepath="", \ i=-1 for f in uvlayer.data: -# for f in me.faces: img_key = f.image if i==-1: @@ -1763,7 +1703,6 @@ def save(operator, context, filepath="", \ TextureId: ''') file.write('\n\t\t}') -# me.activeUVLayer = uvlayer_orig # Done with UV/textures. @@ -1802,11 +1741,9 @@ def save(operator, context, filepath="", \ for f, uf in zip(me.faces, uv_faces): # for f in me.faces: try: mat = mats[f.material_index] -# try: mat = mats[f.mat] except:mat = None if do_uvs: tex = uf.image # WARNING - MULTI UV LAYER IMAGES NOT SUPPORTED :/ -# if do_uvs: tex = f.image # WARNING - MULTI UV LAYER IMAGES NOT SUPPORTED :/ else: tex = None if i==-1: @@ -1846,7 +1783,6 @@ def save(operator, context, filepath="", \ }''') if me.vertex_colors: -# if me.vertexColors: file.write(''' LayerElement: { Type: "LayerElementColor" @@ -1943,7 +1879,6 @@ def save(operator, context, filepath="", \ # if EXP_OBS_SELECTED is false, use sceens objects if not batch_objects: if EXP_OBS_SELECTED: tmp_objects = context.selected_objects -# if EXP_OBS_SELECTED: tmp_objects = scene.objects.context else: tmp_objects = scene.objects else: tmp_objects = batch_objects @@ -1953,11 +1888,9 @@ def save(operator, context, filepath="", \ # ...so mesh objects return their rest worldspace matrix when bone-parents are exported as weighted meshes. # set every armature to its rest, backup the original values so we done mess up the scene ob_arms_orig_rest = [arm.pose_position for arm in bpy.data.armatures] -# ob_arms_orig_rest = [arm.restPosition for arm in bpy.data.armatures] for arm in bpy.data.armatures: arm.pose_position = 'REST' -# arm.restPosition = True if ob_arms_orig_rest: for ob_base in bpy.data.objects: @@ -1966,7 +1899,6 @@ def save(operator, context, filepath="", \ # This causes the makeDisplayList command to effect the mesh scene.frame_set(scene.frame_current) -# Blender.Set('curframe', Blender.Get('curframe')) for ob_base in tmp_objects: @@ -1984,27 +1916,22 @@ def save(operator, context, filepath="", \ # for ob, mtx in BPyObject.getDerivedObjects(ob_base): tmp_ob_type = ob.type if tmp_ob_type == 'CAMERA': -# if tmp_ob_type == 'Camera': if EXP_CAMERA: ob_cameras.append(my_object_generic(ob, mtx)) elif tmp_ob_type == 'LAMP': -# elif tmp_ob_type == 'Lamp': if EXP_LAMP: ob_lights.append(my_object_generic(ob, mtx)) elif tmp_ob_type == 'ARMATURE': -# elif tmp_ob_type == 'Armature': if EXP_ARMATURE: # TODO - armatures dont work in dupligroups! if ob not in ob_arms: ob_arms.append(ob) # ob_arms.append(ob) # replace later. was "ob_arms.append(sane_obname(ob), ob)" elif tmp_ob_type == 'EMPTY': -# elif tmp_ob_type == 'Empty': if EXP_EMPTY: ob_null.append(my_object_generic(ob, mtx)) elif EXP_MESH: origData = True if tmp_ob_type != 'MESH': -# if tmp_ob_type != 'Mesh': # me = bpy.data.meshes.new() try: me = ob.create_mesh(scene, True, 'PREVIEW') # try: me.getFromObject(ob) @@ -2020,17 +1947,6 @@ def save(operator, context, filepath="", \ me = ob.create_mesh(scene, True, 'PREVIEW') # me.getFromObject(ob) - # so we keep the vert groups -# if EXP_ARMATURE: -# orig_mesh = ob.getData(mesh=1) -# if orig_mesh.getVertGroupNames(): -# ob.copy().link(me) -# # If new mesh has no vgroups we can try add if verts are teh same -# if not me.getVertGroupNames(): # vgroups were not kept by the modifier -# if len(me.vertices) == len(orig_mesh.vertices): -# groupNames, vWeightDict = BPyMesh.meshWeight2Dict(orig_mesh) -# BPyMesh.dict2MeshWeight(me, groupNames, vWeightDict) - # print ob, me, me.getVertGroupNames() meshes_to_clear.append( me ) origData = False @@ -2060,27 +1976,17 @@ def save(operator, context, filepath="", \ texture_mapping_local = {} material_mapping_local = {} - if len(me.uv_textures) > 0: -# if me.faceUV: - uvlayer_orig = me.uv_textures.active -# uvlayer_orig = me.activeUVLayer + if me.uv_textures: for uvlayer in me.uv_textures: -# for uvlayer in me.getUVLayerNames(): -# me.activeUVLayer = uvlayer for f, uf in zip(me.faces, uvlayer.data): -# for f in me.faces: tex = uf.image -# tex = f.image textures[tex] = texture_mapping_local[tex] = None try: mat = mats[f.material_index] -# try: mat = mats[f.mat] except: mat = None materials[mat, tex] = material_mapping_local[mat, tex] = None # should use sets, wait for blender 2.5 - -# me.activeUVLayer = uvlayer_orig else: for mat in mats: # 2.44 use mat.lib too for uniqueness @@ -2095,10 +2001,8 @@ def save(operator, context, filepath="", \ # parent bone - special case if (not armob) and ob.parent and ob.parent.type == 'ARMATURE' and \ ob.parent_type == 'BONE': -# if (not armob) and ob.parent and ob.parent.type == 'Armature' and ob.parentType == Blender.Object.ParentTypes.BONE: armob = ob.parent blenParentBoneName = ob.parent_bone -# blenParentBoneName = ob.parentbonename if armob and armob not in ob_arms: @@ -2115,7 +2019,7 @@ def save(operator, context, filepath="", \ my_mesh.blenTextures = list(texture_mapping_local.keys()) # if only 1 null texture then empty the list - if len(my_mesh.blenTextures) == 1 and my_mesh.blenTextures[0] == None: + if len(my_mesh.blenTextures) == 1 and my_mesh.blenTextures[0] is None: my_mesh.blenTextures = [] my_mesh.fbxArm = armob # replace with my_object_generic armature instance later @@ -2131,7 +2035,6 @@ def save(operator, context, filepath="", \ # now we have the meshes, restore the rest arm position for i, arm in enumerate(bpy.data.armatures): arm.pose_position = ob_arms_orig_rest[i] -# arm.restPosition = ob_arms_orig_rest[i] if ob_arms_orig_rest: for ob_base in bpy.data.objects: @@ -2139,7 +2042,6 @@ def save(operator, context, filepath="", \ ob_base.update(scene) # This causes the makeDisplayList command to effect the mesh scene.frame_set(scene.frame_current) -# Blender.Set('curframe', Blender.Get('curframe')) del tmp_ob_type, tmp_objects @@ -2161,7 +2063,6 @@ def save(operator, context, filepath="", \ #ob_arms[i] = fbxArmObName, ob, arm_my_bones, (ob.action, []) for bone in my_arm.blenData.bones: -# for bone in my_arm.blenData.bones.values(): my_bone = my_bone_class(bone, my_arm) my_arm.fbxBones.append( my_bone ) ob_bones.append( my_bone ) @@ -2210,26 +2111,22 @@ def save(operator, context, filepath="", \ # Build blenObject -> fbxObject mapping # this is needed for groups as well as fbxParenting -# for ob in bpy.data.objects: ob.tag = False -# bpy.data.objects.tag = False + for ob in bpy.data.objects: ob.tag = False # using a list of object names for tagging (Arystan) - tagged_objects = [] tmp_obmapping = {} for ob_generic in ob_all_typegroups: for ob_base in ob_generic: - tagged_objects.append(ob_base.blenObject.name) -# ob_base.blenObject.tag = True + ob_base.blenObject.tag = True tmp_obmapping[ob_base.blenObject] = ob_base # Build Groups from objects we export for blenGroup in bpy.data.groups: fbxGroupName = None for ob in blenGroup.objects: - if ob.name in tagged_objects: -# if ob.tag: - if fbxGroupName == None: + if ob.tag: + if fbxGroupName is None: fbxGroupName = sane_groupname(blenGroup) groups.append((fbxGroupName, blenGroup)) @@ -2241,8 +2138,7 @@ def save(operator, context, filepath="", \ for ob_generic in ob_all_typegroups: for my_ob in ob_generic: parent = my_ob.blenObject.parent - if parent and parent.name in tagged_objects: # does it exist and is it in the mapping -# if parent and parent.tag: # does it exist and is it in the mapping + if parent and parent.tag: # does it exist and is it in the mapping my_ob.fbxParent = tmp_obmapping[parent] @@ -2406,8 +2302,7 @@ Objects: {''') if my_mesh.fbxBoneParent: weights = None else: - weights = meshNormalizedWeights(my_mesh.blenObject) -# weights = meshNormalizedWeights(my_mesh.blenData) + weights = meshNormalizedWeights(my_mesh.blenObject, my_mesh.blenData) #for bonename, bone, obname, bone_mesh, armob in ob_bones: for my_bone in ob_bones: @@ -2430,8 +2325,7 @@ Objects: {''') for fbxName, matrix in pose_items: file.write('\n\t\tPoseNode: {') file.write('\n\t\t\tNode: "Model::%s"' % fbxName ) - if matrix: file.write('\n\t\t\tMatrix: %s' % mat4x4str(matrix)) - else: file.write('\n\t\t\tMatrix: %s' % mat4x4str(Matrix())) + file.write('\n\t\t\tMatrix: %s' % mat4x4str(matrix if matrix else Matrix())) file.write('\n\t\t}') file.write('\n\t}') @@ -2614,7 +2508,6 @@ Connections: {''') # Needed for scene footer as well as animation render = scene.render -# render = scene.render # from the FBX sdk #define KTIME_ONE_SECOND KTime (K_LONGLONG(46186158000)) @@ -2624,11 +2517,11 @@ Connections: {''') fps = float(render.fps) start = scene.frame_start -# start = render.sFrame end = scene.frame_end -# end = render.eFrame - if end < start: start, end = end, start - if start==end: ANIM_ENABLE = False + if end < start: start, end = end, st + + # comment the following line, otherwise we dont get the pose + # if start==end: ANIM_ENABLE = False # animations for these object types ob_anim_lists = ob_bones, ob_meshes, ob_null, ob_cameras, ob_lights, ob_arms @@ -2636,13 +2529,12 @@ Connections: {''') if ANIM_ENABLE and [tmp for tmp in ob_anim_lists if tmp]: frame_orig = scene.frame_current -# frame_orig = Blender.Get('curframe') if ANIM_OPTIMIZE: ANIM_OPTIMIZE_PRECISSION_FLOAT = 0.1 ** ANIM_OPTIMIZE_PRECISSION # default action, when no actions are avaioable - tmp_actions = [None] # None is the default action + tmp_actions = [] blenActionDefault = None action_lastcompat = None @@ -2651,7 +2543,7 @@ Connections: {''') if ANIM_ACTION_ALL: # bpy.data.actions.tag = False - tmp_actions = list(bpy.data.actions) + tmp_actions = bpy.data.actions[:] # find which actions are compatible with the armatures @@ -2686,6 +2578,8 @@ Connections: {''') del action_lastcompat + tmp_actions.insert(0, None) # None is the default action + file.write(''' ;Takes and animation section ;---------------------------------------------------- @@ -2707,7 +2601,7 @@ Takes: {''') print('\taction: "%s" has no armature using it, skipping' % blenAction.name) continue - if blenAction == None: + if blenAction is None: # Warning, this only accounts for tmp_actions being [None] file.write('\n\tTake: "Default Take" {') act_start = start @@ -2722,16 +2616,6 @@ Takes: {''') act_start, act_end = blenAction.frame_range act_start = int(act_start) act_end = int(act_end) -# tmp = blenAction.getFrameNumbers() -# if tmp: -# act_start = min(tmp) -# act_end = max(tmp) -# del tmp -# else: -# # Fallback on this, theres not much else we can do? :/ -# # when an action has no length -# act_start = start -# act_end = end # Set the action active for my_bone in ob_arms: @@ -2759,7 +2643,6 @@ Takes: {''') i = act_start while i <= act_end: scene.frame_set(i) -# Blender.Set('curframe', i) for ob_generic in ob_anim_lists: for my_ob in ob_generic: #Blender.Window.RedrawAll() @@ -2805,7 +2688,6 @@ Takes: {''') if prev_eul: prev_eul = mtx[1].to_euler('XYZ', prev_eul) else: prev_eul = mtx[1].to_euler() context_bone_anim_vecs.append(eulerRadToDeg(prev_eul)) -# context_bone_anim_vecs.append(prev_eul) file.write('\n\t\t\t\tChannel: "%s" {' % TX_CHAN) # translation @@ -2862,8 +2744,14 @@ Takes: {''') j = len(context_bone_anim_keys)-2 if len(context_bone_anim_keys) == 2 and context_bone_anim_keys[0][0] == context_bone_anim_keys[1][0]: + # This axis has no moton, its okay to skip KeyCount and Keys in this case - pass + # pass + + # better write one, otherwise we loose poses with no animation + file.write('\n\t\t\t\t\t\tKeyCount: 1') + file.write('\n\t\t\t\t\t\tKey: ') + file.write('\n\t\t\t\t\t\t\t%i,%.15f,L' % (fbx_time(start), context_bone_anim_keys[0][0])) else: # We only need to write these if there is at least one file.write('\n\t\t\t\t\t\tKeyCount: %i' % len(context_bone_anim_keys)) @@ -2917,7 +2805,6 @@ Takes: {''') # Clear mesh data Only when writing with modifiers applied for me in meshes_to_clear: bpy.data.meshes.remove(me) -# me.vertices = None # --------------------------- Footer if world: diff --git a/release/scripts/op/io_scene_obj/__init__.py b/release/scripts/op/io_scene_obj/__init__.py index 63b9e92e166..4d7da65a7b0 100644 --- a/release/scripts/op/io_scene_obj/__init__.py +++ b/release/scripts/op/io_scene_obj/__init__.py @@ -37,6 +37,7 @@ class ImportOBJ(bpy.types.Operator, ImportHelper): bl_label = "Import OBJ" filename_ext = ".obj" + filter_glob = StringProperty(default="*.obj;*.mtl", options={'HIDDEN'}) CREATE_SMOOTH_GROUPS = BoolProperty(name="Smooth Groups", description="Surround smooth groups by sharp edges", default= True) CREATE_FGONS = BoolProperty(name="NGons as FGons", description="Import faces with more then 4 verts as fgons", default= True) @@ -113,7 +114,6 @@ class ExportOBJ(bpy.types.Operator, ExportHelper): def execute(self, context): import io_scene_obj.export_obj - print(self.properties.keys()) return io_scene_obj.export_obj.save(self, context, **self.properties) diff --git a/release/scripts/op/io_scene_obj/export_obj.py b/release/scripts/op/io_scene_obj/export_obj.py index 01f5b221546..23d9ab2aa06 100644 --- a/release/scripts/op/io_scene_obj/export_obj.py +++ b/release/scripts/op/io_scene_obj/export_obj.py @@ -26,7 +26,7 @@ import bpy import mathutils def fixName(name): - if name == None: + if name is None: return 'None' else: return name.replace(' ', '_') @@ -303,18 +303,6 @@ def write_file(filepath, objects, scene, else: return '(null)' - # TODO: implement this in C? dunno how it should be called... - def getVertsFromGroup(me, group_index): - ret = [] - - for i, v in enumerate(me.vertices): - for g in v.groups: - if g.group == group_index: - ret.append((i, g.weight)) - - return ret - - print('OBJ Export path: %r' % filepath) temp_mesh_name = '~tmp-mesh' @@ -403,27 +391,6 @@ def write_file(filepath, objects, scene, me_verts = me.vertices[:] - # XXX - todo, find a better way to do triangulation - # ...removed convert_to_triface because it relies on editmesh - ''' - # We have a valid mesh - if EXPORT_TRI and me.faces: - # Add a dummy object to it. - has_quads = False - for f in me.faces: - if f.vertices[3] != 0: - has_quads = True - break - - if has_quads: - newob = bpy.data.objects.new('temp_object', me) - # if we forget to set Object.data - crash - scene.objects.link(newob) - newob.convert_to_triface(scene) - # mesh will still be there - scene.objects.unlink(newob) - ''' - # Make our own list so it can be sorted to reduce context switching face_index_pairs = [ (face, index) for index, face in enumerate(me.faces)] # faces = [ f for f in me.faces ] @@ -458,7 +425,7 @@ def write_file(filepath, objects, scene, materialItems = [m for m in materials] if materials: for mat in materials: - if mat: # !=None + if mat: materialNames.append(mat.name) else: materialNames.append(None) @@ -560,25 +527,16 @@ def write_file(filepath, objects, scene, # XXX if EXPORT_POLYGROUPS: # Retrieve the list of vertex groups -# vertGroupNames = me.getVertGroupNames() + vertGroupNames = [g.name for g in ob.vertex_groups] currentVGroup = '' # Create a dictionary keyed by face id and listing, for each vertex, the vertex groups it belongs to vgroupsMap = [[] for _i in range(len(me_verts))] -# vgroupsMap = [[] for _i in xrange(len(me_verts))] - for g in ob.vertex_groups: -# for vertexGroupName in vertGroupNames: - for v_idx, vWeight in getVertsFromGroup(me, g.index): -# for v_idx, vWeight in me.getVertsFromGroup(vertexGroupName, 1): - vgroupsMap[v_idx].append((g.name, vWeight)) + for v_idx, v in enumerate(me.vertices): + for g in v.groups: + vgroupsMap[v_idx].append((vertGroupNames[g.group], g.weight)) for f, f_index in face_index_pairs: - f_v = [me_verts[v_idx] for v_idx in f.vertices] - - # if f.vertices[3] == 0: - # f_v.pop() - -# f_v= f.v f_smooth= f.use_smooth f_mat = min(f.material_index, len(materialNames)-1) # f_mat = min(f.mat, len(materialNames)-1) @@ -602,26 +560,18 @@ def write_file(filepath, objects, scene, # Write the vertex group if EXPORT_POLYGROUPS: - if len(ob.vertex_groups): + if ob.vertex_groups: # find what vertext group the face belongs to theVGroup = findVertexGroupName(f,vgroupsMap) if theVGroup != currentVGroup: currentVGroup = theVGroup file.write('g %s\n' % theVGroup) -# # Write the vertex group -# if EXPORT_POLYGROUPS: -# if vertGroupNames: -# # find what vertext group the face belongs to -# theVGroup = findVertexGroupName(f,vgroupsMap) -# if theVGroup != currentVGroup: -# currentVGroup = theVGroup -# file.write('g %s\n' % theVGroup) # CHECK FOR CONTEXT SWITCH if key == contextMat: pass # Context already switched, dont do anything else: - if key[0] == None and key[1] == None: + if key[0] is None and key[1] is None: # Write a null material, since we know the context has changed. if EXPORT_GROUP_BY_MAT: # can be mat_image or (null) @@ -638,7 +588,7 @@ def write_file(filepath, objects, scene, # converting any spaces to underscores with fixName. # If none image dont bother adding it to the name - if key[1] == None: + if key[1] is None: mat_data = mtl_dict[key] = ('%s'%fixName(key[0])), materialItems[f_mat], f_image else: mat_data = mtl_dict[key] = ('%s_%s' % (fixName(key[0]), fixName(key[1]))), materialItems[f_mat], f_image @@ -657,46 +607,56 @@ def write_file(filepath, objects, scene, file.write('s off\n') contextSmooth = f_smooth - file.write('f') - if faceuv: - if EXPORT_NORMALS: - if f_smooth: # Smoothed, use vertex normals + f_v_orig = [me_verts[v_idx] for v_idx in f.vertices] + + if not EXPORT_TRI or len(f_v_orig) == 3: + f_v_iter = (f_v_orig, ) + else: + f_v_iter = (f_v_orig[0], f_v_orig[1], f_v_orig[2]), (f_v_orig[0], f_v_orig[2], f_v_orig[3]) + + # support for triangulation + for f_v in f_v_iter: + file.write('f') + + if faceuv: + if EXPORT_NORMALS: + if f_smooth: # Smoothed, use vertex normals + for vi, v in enumerate(f_v): + file.write( ' %d/%d/%d' % \ + (v.index + totverts, + totuvco + uv_face_mapping[f_index][vi], + globalNormals[ veckey3d(v.normal) ]) ) # vert, uv, normal + + else: # No smoothing, face normals + no = globalNormals[ veckey3d(f.normal) ] + for vi, v in enumerate(f_v): + file.write( ' %d/%d/%d' % \ + (v.index + totverts, + totuvco + uv_face_mapping[f_index][vi], + no) ) # vert, uv, normal + else: # No Normals for vi, v in enumerate(f_v): - file.write( ' %d/%d/%d' % \ - (v.index + totverts, - totuvco + uv_face_mapping[f_index][vi], - globalNormals[ veckey3d(v.normal) ]) ) # vert, uv, normal + file.write( ' %d/%d' % (\ + v.index + totverts,\ + totuvco + uv_face_mapping[f_index][vi])) # vert, uv - else: # No smoothing, face normals - no = globalNormals[ veckey3d(f.normal) ] - for vi, v in enumerate(f_v): - file.write( ' %d/%d/%d' % \ - (v.index + totverts, - totuvco + uv_face_mapping[f_index][vi], - no) ) # vert, uv, normal - else: # No Normals - for vi, v in enumerate(f_v): - file.write( ' %d/%d' % (\ - v.index + totverts,\ - totuvco + uv_face_mapping[f_index][vi])) # vert, uv + face_vert_index += len(f_v) - face_vert_index += len(f_v) - - else: # No UV's - if EXPORT_NORMALS: - if f_smooth: # Smoothed, use vertex normals + else: # No UV's + if EXPORT_NORMALS: + if f_smooth: # Smoothed, use vertex normals + for v in f_v: + file.write( ' %d//%d' % + (v.index + totverts, globalNormals[ veckey3d(v.normal) ]) ) + else: # No smoothing, face normals + no = globalNormals[ veckey3d(f.normal) ] + for v in f_v: + file.write( ' %d//%d' % (v.index + totverts, no) ) + else: # No Normals for v in f_v: - file.write( ' %d//%d' % - (v.index + totverts, globalNormals[ veckey3d(v.normal) ]) ) - else: # No smoothing, face normals - no = globalNormals[ veckey3d(f.normal) ] - for v in f_v: - file.write( ' %d//%d' % (v.index + totverts, no) ) - else: # No Normals - for v in f_v: - file.write( ' %d' % (v.index + totverts) ) + file.write( ' %d' % (v.index + totverts) ) - file.write('\n') + file.write('\n') # Write edges. if EXPORT_EDGES: diff --git a/release/scripts/op/io_scene_obj/import_obj.py b/release/scripts/op/io_scene_obj/import_obj.py index 61b6b4cb3c6..f6c5e625fb0 100644 --- a/release/scripts/op/io_scene_obj/import_obj.py +++ b/release/scripts/op/io_scene_obj/import_obj.py @@ -724,7 +724,7 @@ def create_mesh(new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc, v # if CREATE_FGONS and fgon_edges: # FGON= Mesh.EdgeFlags.FGON # for ed in me.findEdges( fgon_edges.keys() ): -# if ed!=None: +# if ed is not None: # me_edges[ed].flag |= FGON # del FGON @@ -738,7 +738,7 @@ def create_mesh(new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc, v # if unique_smooth_groups and sharp_edges: # SHARP= Mesh.EdgeFlags.SHARP # for ed in me.findEdges( sharp_edges.keys() ): -# if ed!=None: +# if ed is not None: # me_edges[ed].flag |= SHARP # del SHARP @@ -768,7 +768,7 @@ def create_nurbs(context_nurbs, vert_loc, new_objects): name = context_nurbs.get('name', 'ObjNurb') cstype = context_nurbs.get('cstype') - if cstype == None: + if cstype is None: print('\tWarning, cstype not found') return if cstype != 'bspline': diff --git a/release/scripts/op/io_scene_x3d/export_x3d.py b/release/scripts/op/io_scene_x3d/export_x3d.py index d4188b79351..3159d0c9acd 100644 --- a/release/scripts/op/io_scene_x3d/export_x3d.py +++ b/release/scripts/op/io_scene_x3d/export_x3d.py @@ -92,7 +92,7 @@ class x3d_class: print("failed to import compression modules, exporting uncompressed") self.filepath = filepath[:-1] # remove trailing z - if self.file == None: + if self.file is None: self.file = open(self.filepath, "w") self.bNav=0 @@ -739,7 +739,7 @@ class x3d_class: for i in range(alltexture): tex = alltextures[i] - if tex.type != 'IMAGE' or tex.image == None: + if tex.type != 'IMAGE' or tex.image is None: continue namemat = tex.name @@ -811,7 +811,7 @@ class x3d_class: free, derived = create_derived_objects(scene, ob_main) - if derived == None: continue + if derived is None: continue for ob, ob_mat in derived: # for ob, ob_mat in BPyObject.getDerivedObjects(ob_main): diff --git a/release/scripts/op/io_shape_mdd/__init__.py b/release/scripts/op/io_shape_mdd/__init__.py index 9e54477afbb..6453d70f569 100644 --- a/release/scripts/op/io_shape_mdd/__init__.py +++ b/release/scripts/op/io_shape_mdd/__init__.py @@ -37,6 +37,8 @@ class ImportMDD(bpy.types.Operator, ImportHelper): bl_label = "Import MDD" filename_ext = ".mdd" + filter_glob = StringProperty(default="*.mdd", options={'HIDDEN'}) + frame_start = IntProperty(name="Start Frame", description="Start frame for inserting animation", min=-300000, max=300000, default=0) frame_step = IntProperty(name="Step", min=1, max=1000, default=1) diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index fd6235ba783..61a4478c5e4 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -67,10 +67,10 @@ class SelectPattern(bpy.types.Operator): def draw(self, context): layout = self.layout - layout.prop(self.properties, "pattern") + layout.prop(self, "pattern") row = layout.row() - row.prop(self.properties, "case_sensitive") - row.prop(self.properties, "extend") + row.prop(self, "case_sensitive") + row.prop(self, "extend") class SelectCamera(bpy.types.Operator): diff --git a/release/scripts/op/object_randomize_transform.py b/release/scripts/op/object_randomize_transform.py index 8c606527a6d..f60f25242c7 100644 --- a/release/scripts/op/object_randomize_transform.py +++ b/release/scripts/op/object_randomize_transform.py @@ -30,7 +30,7 @@ def randomize_selected(seed, loc, rot, scale, scale_even, scale_min): random.seed(seed) def rand_vec(vec_range): - return Vector([uniform(-val, val) for val in vec_range]) + return Vector(uniform(-val, val) for val in vec_range) for obj in bpy.context.selected_objects: diff --git a/release/scripts/op/screen_play_rendered_anim.py b/release/scripts/op/screen_play_rendered_anim.py index 0103d7ea316..53421642129 100644 --- a/release/scripts/op/screen_play_rendered_anim.py +++ b/release/scripts/op/screen_play_rendered_anim.py @@ -99,7 +99,7 @@ class PlayRenderedAnim(bpy.types.Operator): file_b = rd.frame_path(frame=frame_tmp) file_b = rd.frame_path(frame=int(frame_tmp / 10)) - file = ''.join([(c if file_b[i] == c else "#") for i, c in enumerate(file_a)]) + file = "".join((c if file_b[i] == c else "#") for i, c in enumerate(file_a)) else: # works for movies and images file = rd.frame_path(frame=scene.frame_start) diff --git a/release/scripts/op/sequencer.py b/release/scripts/op/sequencer.py index 7d453745276..e34489b335d 100644 --- a/release/scripts/op/sequencer.py +++ b/release/scripts/op/sequencer.py @@ -42,14 +42,14 @@ class SequencerCrossfadeSounds(bpy.types.Operator): seq2 = None for s in context.scene.sequence_editor.sequences: if s.select and s.type == 'SOUND': - if seq1 == None: + if seq1 is None: seq1 = s - elif seq2 == None: + elif seq2 is None: seq2 = s else: seq2 = None break - if seq2 == None: + if seq2 is None: self.report({'ERROR'}, "Select 2 sound strips.") return {'CANCELLED'} if seq1.frame_final_start > seq2.frame_final_start: diff --git a/release/scripts/op/wm.py b/release/scripts/op/wm.py index af752d69ae9..958fdeb3df6 100644 --- a/release/scripts/op/wm.py +++ b/release/scripts/op/wm.py @@ -542,7 +542,7 @@ class WM_OT_doc_view(bpy.types.Operator): while class_obj: ls.insert(0, class_obj) class_obj = class_obj.nested - return '.'.join([class_obj.identifier for class_obj in ls]) + return '.'.join(class_obj.identifier for class_obj in ls) def execute(self, context): id_split = self.doc_id.split('.') diff --git a/release/scripts/ui/properties_physics_common.py b/release/scripts/ui/properties_physics_common.py index b8798db221e..b5aee894562 100644 --- a/release/scripts/ui/properties_physics_common.py +++ b/release/scripts/ui/properties_physics_common.py @@ -60,7 +60,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): col.enabled = enabled col.prop(cache, "frame_start") col.prop(cache, "frame_end") - if cachetype != 'SMOKE': + if cachetype not in ('SMOKE', 'CLOTH'): col.prop(cache, "frame_step") col = split.column() diff --git a/release/scripts/ui/properties_physics_fluid.py b/release/scripts/ui/properties_physics_fluid.py index 48539a06ee3..1c371f80f16 100644 --- a/release/scripts/ui/properties_physics_fluid.py +++ b/release/scripts/ui/properties_physics_fluid.py @@ -60,6 +60,10 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel): if md: row = layout.row() + if fluid is None: + row.label("built without fluids") + return + row.prop(fluid, "type") if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'): row.prop(fluid, "use", text="") diff --git a/release/scripts/ui/properties_render.py b/release/scripts/ui/properties_render.py index 1da77a431b6..af59e29c0ca 100644 --- a/release/scripts/ui/properties_render.py +++ b/release/scripts/ui/properties_render.py @@ -797,8 +797,13 @@ class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel): sub.prop(scene, "frame_step", text="Step") sub.label(text="Frame Rate:") + + sub = col.column(align=True) sub.prop(rd, "fps") sub.prop(rd, "fps_base", text="/") + subrow = sub.row(align=True) + subrow.prop(rd, "frame_map_old", text="Old") + subrow.prop(rd, "frame_map_new", text="New") class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel): diff --git a/release/scripts/ui/properties_scene.py b/release/scripts/ui/properties_scene.py index bb89b52cce6..e40056cfd30 100644 --- a/release/scripts/ui/properties_scene.py +++ b/release/scripts/ui/properties_scene.py @@ -96,9 +96,7 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, bpy.types.Panel): col = row.column() col.label(text="Keyframing Settings:") - col.prop(ks, "use_insertkey_needed", text="Needed") - col.prop(ks, "use_insertkey_visual", text="Visual") - col.prop(ks, "use_insertkey_xyz_to_rgb", text="XYZ to RGB") + col.prop(ks, "bl_options") class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel): @@ -148,10 +146,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, bpy.types.Panel): if ksp.group_method == 'NAMED': col.prop(ksp, "group") - col.label(text="Keyframing Settings:") - col.prop(ksp, "use_insertkey_needed", text="Needed") - col.prop(ksp, "use_insertkey_visual", text="Visual") - col.prop(ksp, "use_insertkey_xyz_to_rgb", text="XYZ to RGB") + col.prop(ksp, "bl_options") class SCENE_PT_physics(SceneButtonsPanel, bpy.types.Panel): @@ -234,7 +229,7 @@ class ANIM_OT_keying_set_export(bpy.types.Operator): f.write("# Keying Set: %s\n" % ks.name) f.write("import bpy\n\n") - f.write("scene= bpy.data.scenes[0]\n\n") + f.write("scene= bpy.data.scenes[0]\n\n") # XXX, why not use the current scene? # Add KeyingSet and set general settings f.write("# Keying Set Level declarations\n") @@ -243,10 +238,8 @@ class ANIM_OT_keying_set_export(bpy.types.Operator): if not ks.is_path_absolute: f.write("ks.is_path_absolute = False\n") f.write("\n") - - f.write("ks.use_insertkey_needed = %s\n" % ks.use_insertkey_needed) - f.write("ks.use_insertkey_visual = %s\n" % ks.use_insertkey_visual) - f.write("ks.use_insertkey_xyz_to_rgb = %s\n" % ks.use_insertkey_xyz_to_rgb) + + f.write("ks.bl_options = %r\n" % ks.bl_options) f.write("\n") # generate and write set of lookups for id's used in paths diff --git a/release/scripts/ui/properties_texture.py b/release/scripts/ui/properties_texture.py index dfb9e7b87f4..bf0c5d56e4c 100644 --- a/release/scripts/ui/properties_texture.py +++ b/release/scripts/ui/properties_texture.py @@ -94,7 +94,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, bpy.types.Panel): space = context.space_data tex = context.texture idblock = context_tex_datablock(context) - tex_collection = space.pin_id == None and type(idblock) != bpy.types.Brush and not node + tex_collection = space.pin_id is None and type(idblock) != bpy.types.Brush and not node if tex_collection: row = layout.row() diff --git a/release/scripts/ui/space_filebrowser.py b/release/scripts/ui/space_filebrowser.py index 6b51ff42c10..499fd63f1e6 100644 --- a/release/scripts/ui/space_filebrowser.py +++ b/release/scripts/ui/space_filebrowser.py @@ -57,15 +57,21 @@ class FILEBROWSER_HT_header(bpy.types.Header): row = layout.row(align=True) row.active = params.use_filter - + row.prop(params, "use_filter_folder", text="") - row.prop(params, "use_filter_blender", text="") - row.prop(params, "use_filter_image", text="") - row.prop(params, "use_filter_movie", text="") - row.prop(params, "use_filter_script", text="") - row.prop(params, "use_filter_font", text="") - row.prop(params, "use_filter_sound", text="") - row.prop(params, "use_filter_text", text="") + + if params.filter_glob: + #if st.operator and hasattr(st.operator, "filter_glob"): + # row.prop(params, "filter_glob", text="") + row.label(params.filter_glob) + else: + row.prop(params, "use_filter_blender", text="") + row.prop(params, "use_filter_image", text="") + row.prop(params, "use_filter_movie", text="") + row.prop(params, "use_filter_script", text="") + row.prop(params, "use_filter_font", text="") + row.prop(params, "use_filter_sound", text="") + row.prop(params, "use_filter_text", text="") def register(): diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index 74e1d758eea..9c1d114da12 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -927,8 +927,8 @@ class USERPREF_PT_addons(bpy.types.Panel): split = layout.split(percentage=0.2) col = split.column() - col.prop(context.window_manager, "addon_filter", text="Filter", expand=True) col.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM') + col.prop(context.window_manager, "addon_filter", text="Filter", expand=True) col = split.column() @@ -988,7 +988,7 @@ class USERPREF_PT_addons(bpy.types.Panel): if info["version"]: split = colsub.row().split(percentage=0.15) split.label(text='Version:') - split.label(text='.'.join([str(x) for x in info["version"]])) + split.label(text='.'.join(str(x) for x in info["version"])) if info["warning"]: split = colsub.row().split(percentage=0.15) split.label(text="Warning:") @@ -1017,14 +1017,18 @@ class USERPREF_PT_addons(bpy.types.Panel): col.column().label(text="Missing script files") module_names = {mod.__name__ for mod, info in addons} - for ext in sorted(missing_modules): + for module_name in sorted(missing_modules): + is_enabled = module_name in used_ext # Addon UI Code box = col.column().box() colsub = box.column() row = colsub.row() - row.label(text=ext, icon='ERROR') - row.operator("wm.addon_disable").module = ext + row.label(text=module_name, icon='ERROR') + + if is_enabled: + row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name + from bpy.props import * @@ -1092,6 +1096,7 @@ class WM_OT_addon_install(bpy.types.Operator): filepath = StringProperty(name="File Path", description="File path to write file to") filter_folder = BoolProperty(name="Filter folders", description="", default=True, options={'HIDDEN'}) filter_python = BoolProperty(name="Filter python", description="", default=True, options={'HIDDEN'}) + filter_glob = StringProperty(default="*.py;*.zip", options={'HIDDEN'}) def execute(self, context): import traceback @@ -1099,6 +1104,7 @@ class WM_OT_addon_install(bpy.types.Operator): pyfile = self.filepath path_addons = bpy.utils.script_paths("addons")[-1] + contents = set(os.listdir(path_addons)) #check to see if the file is in compressed format (.zip) if zipfile.is_zipfile(pyfile): @@ -1127,6 +1133,23 @@ class WM_OT_addon_install(bpy.types.Operator): traceback.print_exc() return {'CANCELLED'} + # disable any addons we may have enabled previously and removed. + # this is unlikely but do just incase. bug [#23978] + addons_new = set(os.listdir(path_addons)) - contents + for new_addon in addons_new: + bpy.utils.addon_disable(os.path.splitext(new_addon)[0]) + + # possible the zip contains multiple addons, we could disallow this + # but for now just use the first + for mod in USERPREF_PT_addons._addon_list(): + if mod.__name__ in addons_new: + info = addon_info_get(mod) + + # show the newly installed addon. + context.window_manager.addon_filter = 'All' + context.window_manager.addon_search = info["name"] + break + # TODO, should not be a warning. # self.report({'WARNING'}, "File installed to '%s'\n" % path_dest) return {'FINISHED'} diff --git a/release/scripts/ui/space_userpref_keymap.py b/release/scripts/ui/space_userpref_keymap.py index 3c104b67ad3..0cdebd4734c 100644 --- a/release/scripts/ui/space_userpref_keymap.py +++ b/release/scripts/ui/space_userpref_keymap.py @@ -119,7 +119,7 @@ def _merge_keymaps(kc1, kc2): """ merged_keymaps = [(km, kc1) for km in kc1.keymaps] if kc1 != kc2: - merged_keymaps.extend([(km, kc2) for km in kc2.keymaps if not _km_exists_in(km, merged_keymaps)]) + merged_keymaps.extend((km, kc2) for km in kc2.keymaps if not _km_exists_in(km, merged_keymaps)) return merged_keymaps diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index 67363d3a7c0..02f29c7632c 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -647,7 +647,6 @@ class VIEW3D_MT_select_face(bpy.types.Menu): # XXX no matching enum # ********** Object menu ********** - class VIEW3D_MT_object(bpy.types.Menu): bl_context = "objectmode" bl_label = "Object" @@ -655,6 +654,11 @@ class VIEW3D_MT_object(bpy.types.Menu): def draw(self, context): layout = self.layout + layout.operator("ed.undo") + layout.operator("ed.redo") + + layout.separator() + layout.menu("VIEW3D_MT_transform") layout.menu("VIEW3D_MT_mirror") layout.menu("VIEW3D_MT_object_clear") @@ -663,9 +667,7 @@ class VIEW3D_MT_object(bpy.types.Menu): layout.separator() - layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...") - layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...") - layout.operator("anim.keying_set_active_set", text="Change Keying Set...") + layout.menu("VIEW3D_MT_object_animation") layout.separator() @@ -687,8 +689,7 @@ class VIEW3D_MT_object(bpy.types.Menu): layout.separator() - layout.menu("VIEW3D_MT_object_game_properties") - layout.menu("VIEW3D_MT_object_game_logicbricks") + layout.menu("VIEW3D_MT_object_game") layout.separator() @@ -703,6 +704,18 @@ class VIEW3D_MT_object(bpy.types.Menu): layout.operator_menu_enum("object.convert", "target") +class VIEW3D_MT_object_animation(bpy.types.Menu): + bl_context = "objectmode" + bl_label = "Animation" + + def draw(self, context): + layout = self.layout + + layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...") + layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...") + layout.operator("anim.keying_set_active_set", text="Change Keying Set...") + + class VIEW3D_MT_object_clear(bpy.types.Menu): bl_label = "Clear" @@ -908,27 +921,25 @@ class VIEW3D_MT_make_links(bpy.types.Menu): layout.operator_enums("object.make_links_data", "type") # inline -class VIEW3D_MT_object_game_properties(bpy.types.Menu): - bl_label = "Game Properties" +class VIEW3D_MT_object_game(bpy.types.Menu): + bl_label = "Game" def draw(self, context): layout = self.layout - layout.operator("object.game_property_copy", text="Replace").operation = 'REPLACE' - layout.operator("object.game_property_copy", text="Merge").operation = 'MERGE' - layout.operator_menu_enum("object.game_property_copy", "property", text="Copy...") + layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks") + layout.separator() + + layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE' + layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE' + layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...") + + layout.separator() + layout.operator("object.game_property_clear") -class VIEW3D_MT_object_game_logicbricks(bpy.types.Menu): - bl_label = "Logic Bricks" - - def draw(self, context): - layout = self.layout - - layout.operator("object.logic_bricks_copy", text="Copy") - # ********** Vertex paint menu ********** @@ -938,6 +949,11 @@ class VIEW3D_MT_paint_vertex(bpy.types.Menu): def draw(self, context): layout = self.layout + layout.operator("ed.undo") + layout.operator("ed.redo") + + layout.separator() + layout.operator("paint.vertex_color_set") layout.operator("paint.vertex_color_dirt") @@ -992,6 +1008,11 @@ class VIEW3D_MT_paint_weight(bpy.types.Menu): def draw(self, context): layout = self.layout + layout.operator("ed.undo") + layout.operator("ed.redo") + + layout.separator() + layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC' layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES' @@ -1016,6 +1037,11 @@ class VIEW3D_MT_sculpt(bpy.types.Menu): sculpt = tool_settings.sculpt brush = tool_settings.sculpt.brush + layout.operator("ed.undo") + layout.operator("ed.redo") + + layout.separator() + layout.prop(sculpt, "use_symmetry_x") layout.prop(sculpt, "use_symmetry_y") layout.prop(sculpt, "use_symmetry_z") @@ -1061,6 +1087,11 @@ class VIEW3D_MT_particle(bpy.types.Menu): particle_edit = context.tool_settings.particle_edit + layout.operator("ed.undo") + layout.operator("ed.redo") + + layout.separator() + layout.operator("particle.mirror") layout.separator() @@ -1111,6 +1142,11 @@ class VIEW3D_MT_pose(bpy.types.Menu): arm = context.active_object.data + layout.operator("ed.undo") + layout.operator("ed.redo") + + layout.separator() + layout.menu("VIEW3D_MT_transform") layout.menu("VIEW3D_MT_snap") diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index b4bad02bda6..a6f3f7e34c2 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -768,7 +768,7 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel): col = split.column() - col.prop(tex_slot, "size") + col.prop(tex_slot, "scale") col = layout.column() diff --git a/release/test/rna_info_dump.py b/release/test/rna_info_dump.py index 1e40c43eac9..62c1248d733 100644 --- a/release/test/rna_info_dump.py +++ b/release/test/rna_info_dump.py @@ -45,7 +45,7 @@ def api_dump(use_properties=True, use_functions=True): data_str = "%s.%s(%s)" % (struct_id_str, func_id, ", ".join(args)) if func.return_values: - return_args = ", ".join([prop_type(arg) for arg in func.return_values]) + return_args = ", ".join(prop_type(arg) for arg in func.return_values) if len(func.return_values) > 1: data_str += " --> (%s)" % return_args else: diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 0e406a16d0c..25d0eb5bc36 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -62,7 +62,7 @@ float brush_curve_strength_clamp(struct Brush *br, float p, const float len); float brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */ /* sampling */ -void brush_sample_tex(struct Brush *brush, float *xy, float *rgba); +void brush_sample_tex(struct Brush *brush, float *xy, float *rgba, const int thread); void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size, struct ImBuf **imbuf); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 9f12b419084..b4eb1d073a6 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -31,7 +31,6 @@ SET(INC ../avi ../blenlib ../blenloader - ../editors/include ../freestyle ../gpu ../ikplugin @@ -40,6 +39,7 @@ SET(INC ../makesrna ../modifiers ../nodes + ../editors/include ../render/extern/include ../../../extern/glew/include ../../../intern/audaspace/intern diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 98bdf3b2e9f..6da9f2bbabc 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -640,29 +640,19 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, /* Need to verify the quat interpolation is correct - XXX */ if (quat) { - //float totfac, q1[4], q2[4]; + float totfac, q1[4], q2[4]; - /* checks for totfac are needed when 'fac' is 1.0 key_curve_position_weights can assign zero - * to more then one index in data which can give divide by zero error */ -/* - totfac= data[0]+data[1]; - if(totfac>0.000001) interp_qt_qtqt(q1, p0->quat, p1->quat, data[0] / totfac); - else QUATCOPY(q1, p1->quat); + totfac= data[0]+data[3]; + if(totfac>FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac); + else QUATCOPY(q1, p1->quat); - normalize_qt(q1); - - totfac= data[2]+data[3]; - if(totfac>0.000001) interp_qt_qtqt(q2, p2->quat, p3->quat, data[2] / totfac); - else QUATCOPY(q1, p3->quat); - normalize_qt(q2); + totfac= data[1]+data[2]; + if(totfac>FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac); + else QUATCOPY(q1, p3->quat); totfac = data[0]+data[1]+data[2]+data[3]; - if(totfac>0.000001) interp_qt_qtqt(quat, q1, q2, (data[0]+data[1]) / totfac); - else QUATCOPY(quat, q2); - normalize_qt(quat); - */ - // XXX - find some way to make quat interpolation work correctly, above code fails in rare but nasty cases. - QUATCOPY(quat, p1->quat); + if(totfac>FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac); + else QUATCOPY(quat, q2); } if(radius) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 41821f34ba8..2e760f53155 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1289,7 +1289,9 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) /* Find Axis & Amount for bone matrix*/ cross_v3_v3v3(axis,target,nor); - if (dot_v3v3(axis,axis) > 0.0000000000001) { + /* was 0.0000000000001, caused bug [#23954], smaller values give unstable + * roll when toggling editmode */ + if (dot_v3v3(axis,axis) > 0.00001) { /* if nor is *not* a multiple of target ... */ normalize_v3(axis); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 90ea562be9d..c67db9382f3 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -480,7 +480,7 @@ int brush_clone_image_delete(Brush *brush) } /* Brush Sampling */ -void brush_sample_tex(Brush *brush, float *xy, float *rgba) +void brush_sample_tex(Brush *brush, float *xy, float *rgba, const int thread) { MTex *mtex= &brush->mtex; @@ -493,7 +493,7 @@ void brush_sample_tex(Brush *brush, float *xy, float *rgba) co[1]= xy[1]/radius; co[2]= 0.0f; - hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta); + hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, thread); if (hasrgb) { rgba[0]= tr; @@ -547,12 +547,12 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf dstf[3]= alpha*brush_curve_strength_clamp(brush, dist, radius); } else if (texfall == 1) { - brush_sample_tex(brush, xy, dstf); + brush_sample_tex(brush, xy, dstf, 0); } else { dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]); - brush_sample_tex(brush, xy, rgba); + brush_sample_tex(brush, xy, rgba, 0); dstf[0] = rgba[0]*brush->rgb[0]; dstf[1] = rgba[1]*brush->rgb[1]; @@ -583,7 +583,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf dst[3]= FTOCHAR(alpha*brush_curve_strength(brush, dist, radius)); } else if (texfall == 1) { - brush_sample_tex(brush, xy, rgba); + brush_sample_tex(brush, xy, rgba, 0); dst[0]= FTOCHAR(rgba[0]); dst[1]= FTOCHAR(rgba[1]); dst[2]= FTOCHAR(rgba[2]); @@ -592,7 +592,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf else { dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]); - brush_sample_tex(brush, xy, rgba); + brush_sample_tex(brush, xy, rgba, 0); dst[0] = FTOCHAR(rgba[0]*brush->rgb[0]); dst[1] = FTOCHAR(rgba[1]*brush->rgb[1]); dst[2] = FTOCHAR(rgba[2]*brush->rgb[2]); @@ -739,7 +739,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i xy[0] = x + xoff; xy[1] = y + yoff; - brush_sample_tex(brush, xy, tf); + brush_sample_tex(brush, xy, tf, 0); } bf[0] = tf[0]*mf[0]; @@ -770,7 +770,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i xy[0] = x + xoff; xy[1] = y + yoff; - brush_sample_tex(brush, xy, rgba); + brush_sample_tex(brush, xy, rgba, 0); t[0]= FTOCHAR(rgba[0]); t[1]= FTOCHAR(rgba[1]); t[2]= FTOCHAR(rgba[2]); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 57e5630da19..59e81293c9f 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -850,7 +850,14 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta * the effect of this constraint (i.e. owner is 'parented' to parent) */ copy_m4_m4(tempmat, cob->matrix); - mul_m4_m4m4(cob->matrix, tempmat, parmat); + mul_m4_m4m4(cob->matrix, tempmat, parmat); + + /* without this, changes to scale and rotation can change location + * of a parentless bone or a disconnected bone. Even though its set + * to zero above. */ + if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0]= tempmat[3][0]; + if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1]= tempmat[3][1]; + if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2]= tempmat[3][2]; } } @@ -1629,8 +1636,9 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta mat4_to_size(size, cob->matrix); /* to allow compatible rotations, must get both rotations in the order of the owner... */ - mat4_to_eulO(eul, cob->rotOrder, ct->matrix); mat4_to_eulO(obeul, cob->rotOrder, cob->matrix); + /* we must get compatible eulers from the beginning because some of them can be modified below (see bug #21875) */ + mat4_to_compatible_eulO(eul, obeul, cob->rotOrder, ct->matrix); if ((data->flag & ROTLIKE_X)==0) eul[0] = obeul[0]; @@ -1662,6 +1670,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[2] *= -1; } + /* good to make eulers compatible again, since we don't know how much they were changed above */ compatible_eul(eul, obeul); loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder); } @@ -4402,7 +4411,7 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) } } - /* Solve the constraint */ + /* Solve the constraint and put result in cob->matrix */ cti->evaluate_constraint(con, cob, &targets); /* clear targets after use @@ -4414,23 +4423,13 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) } /* Interpolate the enforcement, to blend result of constraint into final owner transform */ - /* 1. Remove effects of original matrix from constraint solution ==> delta */ - invert_m4_m4(imat, oldmat); - copy_m4_m4(solution, cob->matrix); - mul_m4_m4m4(delta, solution, imat); - - /* 2. If constraint influence is not full strength, then interpolate - * identity_matrix --> delta_matrix to get the effect the constraint actually exerts - */ + /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */ if (enf < 1.0) { - float identity[4][4]; - unit_m4(identity); - blend_m4_m4m4(delta, identity, delta, enf); + float solution[4][4]; + copy_m4_m4(solution, cob->matrix); + blend_m4_m4m4(cob->matrix, oldmat, solution, enf); } - /* 3. Now multiply the delta by the matrix in use before the evaluation */ - mul_m4_m4m4(cob->matrix, delta, oldmat); - /* move owner back into worldspace for next constraint/other business */ if ((con->flag & CONSTRAINT_SPACEONCE) == 0) constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index a44c5ace298..d0336d9f786 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -930,7 +930,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) EditFace *efa; DispList *dlnew=0, *dl; float *f1; - int colnr=0, charidx=0, cont=1, tot, a, *index; + int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0; intptr_t totvert; if(dispbase==0) return; @@ -938,38 +938,41 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) while(cont) { cont= 0; - totvert=0; + totvert= 0; + nextcol= 0; dl= dispbase->first; while(dl) { if(dl->type==DL_POLY) { if(charidxcharidx) cont= 1; - else if(charidx==dl->charidx) { - - colnr= dl->col; - charidx= dl->charidx; - - /* make editverts and edges */ - f1= dl->verts; - a= dl->nr; - eve= v1= 0; - - while(a--) { - vlast= eve; + else if(charidx==dl->charidx) { /* character with needed index */ + if(colnr==dl->col) { + /* make editverts and edges */ + f1= dl->verts; + a= dl->nr; + eve= v1= 0; - eve= BLI_addfillvert(f1); - totvert++; - - if(vlast==0) v1= eve; - else { - BLI_addfilledge(vlast, eve); + while(a--) { + vlast= eve; + + eve= BLI_addfillvert(f1); + totvert++; + + if(vlast==0) v1= eve; + else { + BLI_addfilledge(vlast, eve); + } + f1+=3; } - f1+=3; - } - - if(eve!=0 && v1!=0) { - BLI_addfilledge(eve, v1); + + if(eve!=0 && v1!=0) { + BLI_addfilledge(eve, v1); + } + } else if (colnrcol) { + /* got poly with next material at current char */ + cont= 1; + nextcol= 1; } } } @@ -1032,7 +1035,14 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) } BLI_end_edgefill(); - charidx++; + if(nextcol) { + /* stay at current char but fill polys with next material */ + colnr++; + } else { + /* switch to next char and start filling from first material */ + charidx++; + colnr= 0; + } } /* do not free polys, needed for wireframe display */ diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 0da5e0da2c4..4860e7d8eed 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -86,7 +86,6 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_scene.h" -#include "BKE_screen.h" #include "BKE_utildefines.h" #include "RE_render_ext.h" diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index c0a60ea6294..47627d09b97 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1146,7 +1146,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) return NULL; } - if(mode==0) { + if(mode == FO_EDIT) { /* make nurbdata */ unsigned long cha; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f3dfd4292c6..344f8500075 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1777,8 +1777,6 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) else BLI_path_abs(str, G.sce); - BLI_path_frame(str, cfra, 0); - /* read ibuf */ ibuf = IMB_loadiffname(str, flag); } @@ -2022,14 +2020,9 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); } else if(ima->source == IMA_SRC_VIEWER) { - if(ima->type==IMA_TYPE_R_RESULT) { - /* always verify entirely, not that this shouldn't happen - * during render anyway */ - } - else if(ima->type==IMA_TYPE_COMPOSITE) { - frame= iuser?iuser->framenr:0; - ibuf= image_get_ibuf(ima, 0, frame); - } + /* always verify entirely, not that this shouldn't happen + * as part of texture sampling in rendering anyway, so not + * a big bottleneck */ } *frame_r = frame; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 2f8553b06b3..6f1cdefbcad 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -440,7 +440,7 @@ void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int inve int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) { /* first test if the face is legal */ - if(mface->v3 && mface->v3==mface->v4) { + if((mface->v3 || nr==4) && mface->v3==mface->v4) { mface->v4= 0; nr--; } @@ -854,6 +854,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int mface->v2= startvert+index[2]; mface->v3= startvert+index[1]; mface->v4= 0; + mface->mat_nr= (unsigned char)dl->col; test_index_face(mface, NULL, 0, 3); if(smooth) mface->flag |= ME_SMOOTH; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e2dbae92d5c..f45c0717b26 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1338,6 +1338,8 @@ Object *copy_object(Object *ob) obn->gpulamp.first = obn->gpulamp.last = NULL; obn->pc_ids.first = obn->pc_ids.last = NULL; + + obn->mpath= NULL; return obn; } @@ -1688,11 +1690,29 @@ void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat) /* see pchan_apply_mat4() for the equivalent 'pchan' function */ void object_apply_mat4(Object *ob, float mat[][4]) { - float mat3[3][3]; + float mat3[3][3], tmat[3][3], imat[3][3]; + + /* location */ copy_v3_v3(ob->loc, mat[3]); - mat4_to_size(ob->size, mat); + + /* rotation */ copy_m3_m4(mat3, mat); object_mat3_to_rot(ob, mat3, 0); + + /* scale */ +#if 0 + /* works fine except for neg scales */ + mat4_to_size(ob->size, mat); +#else + /* this is more complicated but works for negative scales */ + object_rot_to_mat3(ob, tmat); + invert_m3_m3(imat, tmat); + mul_m3_m3m3(tmat, imat, mat3); + + ob->size[0]= tmat[0][0]; + ob->size[1]= tmat[1][1]; + ob->size[2]= tmat[2][2]; +#endif } void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 07b712c4330..6b75f5d417c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3686,7 +3686,7 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float else VECCOPY(texco,orco); - externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3); + externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0); if((event & mtex->pmapto) & MAP_PA_TIME){ if((setvars&MAP_PA_TIME)==0){ ptex->time=0.0; @@ -3740,7 +3740,7 @@ void psys_get_texture(ParticleSimulationData *sim, Material *ma, ParticleData *p psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texco, 0); } - externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3); + externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0); if((event & mtex->pmapto) & MAP_PA_TIME){ /* the first time has to set the base value for time regardless of blend mode */ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 5318754951f..47a220dcefb 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -195,9 +195,11 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) psys->free_edit = NULL; } - newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles"); - if(psys->part->phystype == PART_PHYS_BOIDS) - newboids= MEM_callocN(totpart*sizeof(BoidParticle), "boid particles"); + if(totpart) { + newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles"); + if(psys->part->phystype == PART_PHYS_BOIDS) + newboids= MEM_callocN(totpart*sizeof(BoidParticle), "boid particles"); + } if(psys->particles) { totsaved=MIN2(psys->totpart,totpart); @@ -2837,11 +2839,18 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B } while(t2); } -/* particle - mesh collision code */ -/* in addition to basic point to surface collisions handles friction & damping,*/ -/* angular momentum <-> linear momentum and swept sphere - mesh collisions */ -/* 1. check for all possible deflectors for closest intersection on particle path */ -/* 2. if deflection was found kill the particle or calculate new coordinates */ +/* Particle - Mesh collision code + * Features: + * - point and swept sphere to mesh surface collisions + * - moving colliders (but not yet rotating or deforming colliders) + * - friction & damping + * - angular momentum <-> linear momentum + * - high accuracy by re-applying particle acceleration after collision + * - behaves relatively well even if limit of 10 collisions per simulation step is exceeded + * Main parts: + * 1. check for all possible deflectors for closest intersection on particle path + * 2. if deflection was found calculate new coordinates or kill the particle + */ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, float cfra){ Object *ground_ob = NULL; ParticleSettings *part = sim->psys->part; @@ -2849,19 +2858,21 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo ParticleCollision col; ColliderCache *coll; BVHTreeRayHit hit; - float ray_dir[3], zerovec[3]={0.0,0.0,0.0}; + float ray_dir[3], acc[3]; float radius = ((part->flag & PART_SIZE_DEFL)?pa->size:0.0f), boid_z = 0.0f; - float timestep = psys_get_timestep(sim); + float timestep = psys_get_timestep(sim) * dfra; + float inv_timestep = 1.0f/timestep; int deflections=0, max_deflections=10; - VECCOPY(col.co1, pa->prev_state.co); - VECCOPY(col.co2, pa->state.co); - - VECCOPY(col.ve1, pa->prev_state.vel); - VECCOPY(col.ve2, pa->state.vel); - mul_v3_fl(col.ve1, timestep * dfra); - mul_v3_fl(col.ve2, timestep * dfra); - + /* get acceleration (from gravity, forcefields etc. to be re-applied after collision) */ + sub_v3_v3v3(acc, pa->state.vel, pa->prev_state.vel); + mul_v3_fl(acc, inv_timestep); + + /* set values for first iteration */ + copy_v3_v3(col.co1, pa->prev_state.co); + copy_v3_v3(col.co2, pa->state.co); + copy_v3_v3(col.ve1, pa->prev_state.vel); + copy_v3_v3(col.ve2, pa->state.vel); col.t = 0.0f; /* override for boids */ @@ -2876,7 +2887,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo if(sim->colliders) while(deflections < max_deflections){ /* 1. */ - VECSUB(ray_dir, col.co2, col.co1); + sub_v3_v3v3(ray_dir, col.co2, col.co1); hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); @@ -2904,45 +2915,49 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* 2. */ if(hit.index>=0) { PartDeflect *pd = col.hit_ob->pd; - int through = (BLI_frand() < pd->pdef_perm) ? 1 : 0; float co[3]; /* point of collision */ - float vec[3]; /* movement through collision */ - float acc[3]; /* acceleration */ - float x = hit.dist/col.ray_len; /* location of collision between this iteration */ - float le = len_v3(col.ve1)/col.ray_len; - float ac = len_v3(col.ve2)/col.ray_len - le; /* (taking acceleration into account) */ - float t = (-le + sqrt(le*le + 2*ac*x))/ac; /* time of collision between this iteration */ - float dt = col.t + x * (1.0f - col.t); /* time of collision between frame change*/ - float it = 1.0 - t; + float df = col.t + x * (1.0f - col.t); /* time of collision between frame change*/ + float dt1 = (df - col.t) * timestep; /* iteration time of collision (in seconds) */ + float dt2 = (1.0f - df) * timestep; /* time left after collision (in seconds) */ + int through = (BLI_frand() < pd->pdef_perm) ? 1 : 0; /* did particle pass through the collision surface? */ + + deflections++; interp_v3_v3v3(co, col.co1, col.co2, x); - VECSUB(vec, col.co2, col.co1); - - VECSUB(acc, col.ve2, col.ve1); - mul_v3_fl(col.vel, 1.0f-col.t); + /* make sure we don't hit the current face again */ + /* TODO: could/should this be proportional to pa->size? */ + madd_v3_v3fl(co, col.nor, (through ? -0.0001f : 0.0001f)); /* particle dies in collision */ if(through == 0 && (part->flag & PART_DIE_ON_COL || pd->flag & PDEFLE_KILL_PART)) { pa->alive = PARS_DYING; - pa->dietime = pa->state.time + (cfra - pa->state.time) * dt; - - /* we have to add this for dying particles too so that reactors work correctly */ - VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f)); + pa->dietime = pa->state.time + (cfra - pa->state.time) * df; - VECCOPY(pa->state.co, co); - interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, dt); - interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, dt); - interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, dt); + copy_v3_v3(pa->state.co, co); + interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, df); + interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, df); + interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, df); /* particle is dead so we don't need to calculate further */ - deflections=max_deflections; + return; } + /* figure out velocity and other data after collision */ else { - float nor_vec[3], tan_vec[3], tan_vel[3]; + float v0[3]; /* velocity directly before collision to be modified into velocity directly after collision */ + float v0_nor[3];/* normal component of v0 */ + float v0_tan[3];/* tangential component of v0 */ + float vc_tan[3];/* tangential component of collision surface velocity */ + float check[3]; + float v0_dot, vc_dot, check_dot; float damp, frict; - float inp, inp_v; + + /* get exact velocity right before collision */ + madd_v3_v3v3fl(v0, col.ve1, acc, dt1); + + /* convert collider velocity from 1/framestep to 1/s */ + mul_v3_fl(col.vel, inv_timestep); /* get damping & friction factors */ damp = pd->pdef_damp + pd->pdef_rdamp * 2 * (BLI_frand() - 0.5f); @@ -2952,119 +2967,118 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo CLAMP(frict,0.0,1.0); /* treat normal & tangent components separately */ - inp = dot_v3v3(col.nor, vec); - inp_v = dot_v3v3(col.nor, col.vel); + v0_dot = dot_v3v3(col.nor, v0); + madd_v3_v3v3fl(v0_tan, v0, col.nor, -v0_dot); - VECADDFAC(tan_vec, vec, col.nor, -inp); - VECADDFAC(tan_vel, col.vel, col.nor, -inp_v); - if((part->flag & PART_ROT_DYN)==0) - interp_v3_v3v3(tan_vec, tan_vec, tan_vel, frict); + vc_dot = dot_v3v3(col.nor, col.vel); + madd_v3_v3v3fl(vc_tan, col.vel, col.nor, -vc_dot); - VECCOPY(nor_vec, col.nor); - inp *= 1.0f - damp; + /* handle friction effects (tangential and angular velocity) */ + if(frict > 0.0f) { + /* angular <-> linear velocity */ + if(part->flag & PART_ROT_DYN) { + float vr_tan[3], v1_tan[3], ave[3]; + + /* linear velocity of particle surface */ + cross_v3_v3v3(vr_tan, col.nor, pa->state.ave); + mul_v3_fl(vr_tan, pa->size); - if(through) - inp_v *= damp; + /* change to coordinates that move with the collision plane */ + sub_v3_v3v3(v1_tan, v0_tan, vc_tan); + + /* The resulting velocity is a weighted average of particle cm & surface + * velocity. This weight (related to particle's moment of inertia) could + * be made a parameter for angular <-> linear conversion. + */ + madd_v3_v3fl(v1_tan, vr_tan, -0.4); + mul_v3_fl(v1_tan, 1.0f/1.4f); /* 1/(1+0.4) */ - /* special case for object hitting the particle from behind */ - if(through==0 && ((inp_v>0 && inp>0 && inp_v>inp) || (inp_v<0 && inp<0 && inp_v linear velocity - slightly more physical and looks even nicer than before */ - if(part->flag & PART_ROT_DYN) { - float surface_vel[3], rot_vel[3], friction[3], dave[3], dvel[3]; + /* surface_velocity is opposite to cm velocity */ + mul_v3_v3fl(vr_tan, v1_tan, -1.0f); - /* apparent velocity along collision surface */ - VECSUB(surface_vel, tan_vec, tan_vel); + /* get back to global coordinates */ + add_v3_v3(v1_tan, vc_tan); - /* direction of rolling friction */ - cross_v3_v3v3(rot_vel, pa->state.ave, col.nor); - /* convert to current dt */ - mul_v3_fl(rot_vel, (timestep*dfra) * (1.0f - col.t)); - mul_v3_fl(rot_vel, pa->size); + /* convert to angular velocity*/ + cross_v3_v3v3(ave, vr_tan, col.nor); + mul_v3_fl(ave, 1.0f/MAX2(pa->size, 0.001)); - /* apply sliding friction */ - VECSUB(surface_vel, surface_vel, rot_vel); - VECCOPY(friction, surface_vel); - - mul_v3_fl(surface_vel, 1.0 - frict); - mul_v3_fl(friction, frict); - - /* sliding changes angular velocity */ - cross_v3_v3v3(dave, col.nor, friction); - mul_v3_fl(dave, 1.0f/MAX2(pa->size, 0.001)); - - /* we assume rolling friction is around 0.01 of sliding friction */ - mul_v3_fl(rot_vel, 1.0 - frict*0.01); - - /* change in angular velocity has to be added to the linear velocity too */ - cross_v3_v3v3(dvel, dave, col.nor); - mul_v3_fl(dvel, pa->size); - VECADD(rot_vel, rot_vel, dvel); - - VECADD(surface_vel, surface_vel, rot_vel); - VECADD(tan_vec, surface_vel, tan_vel); - - /* convert back to normal time */ - mul_v3_fl(dave, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); - - mul_v3_fl(pa->state.ave, 1.0 - frict*0.01); - VECADD(pa->state.ave, pa->state.ave, dave); + /* only friction will cause change in linear & angular velocity */ + interp_v3_v3v3(pa->state.ave, pa->state.ave, ave, frict); + interp_v3_v3v3(v0_tan, v0_tan, v1_tan, frict); + } + else { + /* just basic friction (unphysical due to the friction model used in Blender) */ + interp_v3_v3v3(v0_tan, v0_tan, vc_tan, frict); + } } + /* stickness was possibly added before, so cancel that before calculating new normal velocity */ + /* otherwise particles go flying out of the surface because of high reversed sticky velocity */ + if(v0_dot < 0.0f) { + v0_dot += pd->pdef_stickness; + if(v0_dot > 0.0f) + v0_dot = 0.0f; + } + + /* damping and flipping of velocity around normal */ + v0_dot *= 1.0f - damp; + vc_dot *= through ? damp : 1.0f; + + /* special case for object hitting the particle from behind */ + if(through==0 && ((vc_dot>0.0f && v0_dot>0.0f && vc_dot>v0_dot) || (vc_dot<0.0f && v0_dot<0.0f && vc_dotphystype == PART_PHYS_BOIDS && part->boids->options & BOID_ALLOW_LAND) { BoidParticle *bpa = pa->boid; if(bpa->data.mode == eBoidMode_OnLand || co[2] <= boid_z) { co[2] = boid_z; - vec[2] = 0.0f; + v0[2] = 0.0f; } } - - /* set coordinates for next iteration */ - /* apply acceleration to final position, but make sure particle stays above surface */ - madd_v3_v3v3fl(acc, vec, acc, it); - ac = dot_v3v3(acc, col.nor); - if((!through && ac < 0.0f) || (through && ac > 0.0f)) - madd_v3_v3fl(acc, col.nor, -ac); + if(deflections < max_deflections) { + /* re-apply acceleration to final velocity and location */ + madd_v3_v3v3fl(pa->state.vel, v0, acc, dt2); + madd_v3_v3v3fl(pa->state.co, co, v0, dt2); + madd_v3_v3fl(pa->state.co, acc, 0.5f*dt2*dt2); - VECCOPY(col.co1, co); - VECADDFAC(col.co2, co, acc, it); + /* make sure particle stays on the right side of the surface */ + sub_v3_v3v3(check, pa->state.co, co); + /* (collision surface has moved during the time too) */ + madd_v3_v3fl(check, col.vel, -dt2); - VECCOPY(col.ve1, vec); - VECCOPY(col.ve2, acc); + check_dot = dot_v3v3(check, col.nor); + if((!through && check_dot < 0.0f) || (through && check_dot > 0.0f)) + madd_v3_v3fl(pa->state.co, col.nor, (through ? -0.0001f : 0.0001f) - check_dot); - if(len_v3(vec) < 0.001 && len_v3v3(pa->state.co, pa->prev_state.co) < 0.001) { - /* kill speed to stop slipping */ - VECCOPY(pa->state.vel,zerovec); - VECCOPY(pa->state.co, co); - if(part->flag & PART_ROT_DYN) { - VECCOPY(pa->state.ave,zerovec); - } + /* Stickness to surface */ + madd_v3_v3fl(pa->state.vel, col.nor, -pd->pdef_stickness); + + /* set coordinates for next iteration */ + copy_v3_v3(col.co1, co); + copy_v3_v3(col.co2, pa->state.co); + + copy_v3_v3(col.ve1, v0); + copy_v3_v3(col.ve2, pa->state.vel); + + col.t = df; } else { - VECCOPY(pa->state.co, col.co2); - mul_v3_v3fl(pa->state.vel, acc, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); - - /* Stickness to surface */ - normalize_v3(nor_vec); - madd_v3_v3fl(pa->state.vel, col.nor, -pd->pdef_stickness); + /* final chance to prevent failure, so don't do anything fancy */ + copy_v3_v3(pa->state.co, co); + copy_v3_v3(pa->state.vel, v0); } - - col.t = dt; } - deflections++; - - //reaction_state.time = cfra - (1.0f - dt) * dfra; - //push_reaction(col.ob, psys, p, PART_EVENT_COLLIDE, &reaction_state); } else return; @@ -3346,6 +3360,8 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* frame & time changes */ float dfra, dtime, pa_dtime, pa_dfra=0.0; float birthtime, dietime; + + int invalidParticles=0; /* where have we gone in time since last time */ dfra= cfra - psys->cfra; @@ -3496,6 +3512,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) //push_reaction(ob,psys,p,PART_EVENT_NEAR,&pa->state); } + if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) {invalidParticles++;} } free_collider_cache(&sim->colliders); diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 01652aaa713..f64854f90de 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -337,7 +337,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S } //After sucessufuly build the trees, start projection vertexs - if( bvhtree_from_mesh_faces(&treeData, calc->target, calc->keepDist, 4, 6) + if( bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6) && (auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 0.0, 4, 6))) { @@ -383,6 +383,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); + + if(hit.index != -1) + madd_v3_v3v3fl(hit.co, hit.co, tmp_no, -calc->keepDist); } //Project over negative direction of axis @@ -395,6 +398,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); + + if(hit.index != -1) + madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist); } diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 36a4cfea7a0..3d984c7e877 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -39,8 +39,37 @@ #define SEP_CHR '#' #define SEP_STR "#" -#define EPS 0.000001 +#define EPS 0.00001 +#define UN_SC_KM 1000.0f +#define UN_SC_HM 100.0f +#define UN_SC_DAM 10.0f +#define UN_SC_M 1.0f +#define UN_SC_DM 0.1f +#define UN_SC_CM 0.01f +#define UN_SC_MM 0.001f +#define UN_SC_UM 0.000001f + +#define UN_SC_MI 1609.344f +#define UN_SC_FUR 201.168f +#define UN_SC_CH 20.1168f +#define UN_SC_YD 0.9144f +#define UN_SC_FT 0.3048f +#define UN_SC_IN 0.0254f +#define UN_SC_MIL 0.0000254f + +#define UN_SC_MTON 1000.0f /* metric ton */ +#define UN_SC_QL 100.0f +#define UN_SC_KG 1.0f +#define UN_SC_HG 0.1f +#define UN_SC_DAG 0.01f +#define UN_SC_G 0.001f + +#define UN_SC_ITON 907.18474f /* imperial ton */ +#define UN_SC_CWT 45.359237f +#define UN_SC_ST 6.35029318f +#define UN_SC_LB 0.45359237f +#define UN_SC_OZ 0.028349523125f /* define a single unit */ typedef struct bUnitDef { @@ -63,7 +92,7 @@ typedef struct bUnitDef { /* define a single unit */ typedef struct bUnitCollection { struct bUnitDef *units; - int base_unit; /* use for 0.0, or none given */ + int base_unit; /* basic unit index (when user desn't specify unit explicitly) */ int flag; /* options for this system */ int length; /* to quickly find the last item */ } bUnitCollection; @@ -78,14 +107,14 @@ static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDum /* Lengths */ static struct bUnitDef buMetricLenDef[] = { - {"kilometer", "kilometers", "km", NULL, "Kilometers", 1000.0, 0.0, B_UNIT_DEF_NONE}, - {"hectometer", "hectometers", "hm", NULL, "100 Meters", 100.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"dekameter", "dekameters", "dam",NULL, "10 Meters", 10.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"meter", "meters", "m", NULL, "Meters", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", 0.1, 0.0, B_UNIT_DEF_SUPPRESS}, - {"centimeter", "centimeters", "cm", NULL, "Centimeters", 0.01, 0.0, B_UNIT_DEF_NONE}, - {"millimeter", "millimeters", "mm", NULL, "Millimeters", 0.001, 0.0, B_UNIT_DEF_NONE}, - {"micrometer", "micrometers", "µm", "um", "Micrometers", 0.000001, 0.0, B_UNIT_DEF_NONE}, // micron too? + {"kilometer", "kilometers", "km", NULL, "Kilometers", UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"hectometer", "hectometers", "hm", NULL, "100 Meters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"dekameter", "dekameters", "dam",NULL, "10 Meters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"meter", "meters", "m", NULL, "Meters", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too? /* These get displayed because of float precision problems in the transform header, * could work around, but for now probably people wont use these */ @@ -98,17 +127,121 @@ static struct bUnitDef buMetricLenDef[] = { static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef)/sizeof(bUnitDef)}; static struct bUnitDef buImperialLenDef[] = { - {"mile", "miles", "mi", "m", "Miles", 1609.344, 0.0, B_UNIT_DEF_NONE}, - {"furlong", "furlongs", "fur", NULL, "Furlongs",201.168, 0.0, B_UNIT_DEF_SUPPRESS}, - {"chain", "chains", "ch", NULL, "Chains", 0.9144*22.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"yard", "yards", "yd", NULL, "Yards", 0.9144, 0.0, B_UNIT_DEF_NONE}, - {"foot", "feet", "'", "ft", "Feet", 0.3048, 0.0, B_UNIT_DEF_NONE}, - {"inch", "inches", "\"", "in", "Inches", 0.0254, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"thou", "thous", "mil", NULL, "Thous", 0.0000254, 0.0, B_UNIT_DEF_NONE}, + {"mile", "miles", "mi", "m", "Miles", UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"furlong", "furlongs", "fur", NULL, "Furlongs",UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, + {"chain", "chains", "ch", NULL, "Chains", UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"yard", "yards", "yd", NULL, "Yards", UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"foot", "feet", "'", "ft", "Feet", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"inch", "inches", "\"", "in", "Inches", UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"thou", "thous", "mil", NULL, "Thous", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; +/* Areas */ +static struct bUnitDef buMetricAreaDef[] = { + {"square kilometer", "square kilometers", "km²", "km2", "Square Kilometers", UN_SC_KM*UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"square hectometer","square hectometers", "hm²", "hm2", "Square Hectometers", UN_SC_HM*UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, /* hectare */ + {"square dekameter", "square dekameters", "dam²","dam2", "Square Dekameters", UN_SC_DAM*UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, /* are */ + {"square meter", "square meters", "m²", "m2", "Square Meters", UN_SC_M*UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"square decimetre", "square decimetres", "dm²", "dm2", "Square Decimetres", UN_SC_DM*UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM*UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM*UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"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 bUnitDef buImperialAreaDef[] = { + {"square mile", "square miles", "sq mi", "sq m","Square Miles", UN_SC_MI*UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"square furlong", "square furlongs", "sq fur",NULL, "Square Furlongs", UN_SC_FUR*UN_SC_FUR, 0.0,B_UNIT_DEF_SUPPRESS}, + {"square chain", "square chains", "sq ch", NULL, "Square Chains", UN_SC_CH*UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square yard", "square yards", "sq yd", NULL, "Square Yards", UN_SC_YD*UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"square foot", "square feet", "sq ft", NULL, "Square Feet", UN_SC_FT*UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"square inch", "square inches", "sq in", NULL, "Square Inches", UN_SC_IN*UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"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)}; + +/* Volumes */ +static struct bUnitDef buMetricVolDef[] = { + {"cubic kilometer", "cubic kilometers", "km³", "km3", "Cubic Kilometers", UN_SC_KM*UN_SC_KM*UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"cubic hectometer","cubic hectometers", "hm³", "hm3", "Cubic Hectometers", UN_SC_HM*UN_SC_HM*UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, + {"cubic dekameter", "cubic dekameters", "dam³","dam3", "Cubic Dekameters", UN_SC_DAM*UN_SC_DAM*UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic meter", "cubic meters", "m³", "m3", "Cubic Meters", UN_SC_M*UN_SC_M*UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"cubic decimetre", "cubic decimetres", "dm³", "dm3", "Cubic Decimetres", UN_SC_DM*UN_SC_DM*UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM*UN_SC_CM*UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM*UN_SC_MM*UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"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 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}, + {"cubic furlong", "cubic furlongs", "cu fur",NULL, "Cubic Furlongs", UN_SC_FUR*UN_SC_FUR*UN_SC_FUR, 0.0,B_UNIT_DEF_SUPPRESS}, + {"cubic chain", "cubic chains", "cu ch", NULL, "Cubic Chains", UN_SC_CH*UN_SC_CH*UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic yard", "cubic yards", "cu yd", NULL, "Cubic Yards", UN_SC_YD*UN_SC_YD*UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"cubic foot", "cubic feet", "cu ft", NULL, "Cubic Feet", UN_SC_FT*UN_SC_FT*UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"cubic inch", "cubic inches", "cu in", NULL, "Cubic Inches", UN_SC_IN*UN_SC_IN*UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"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)}; + +/* Mass */ +static struct bUnitDef buMetricMassDef[] = { + {"ton", "tonnes", "ton", "t", "1000 Kilograms", UN_SC_MTON, 0.0, B_UNIT_DEF_NONE}, + {"quintal", "quintals", "ql", "q", "100 Kilograms", UN_SC_QL, 0.0, B_UNIT_DEF_NONE}, + {"kilogram", "kilograms", "kg", NULL, "Kilograms", UN_SC_KG, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"hectogram", "hectograms", "hg", NULL, "Hectograms", UN_SC_HG, 0.0, B_UNIT_DEF_NONE}, + {"dekagram", "dekagrams", "dag",NULL, "10 Grams", UN_SC_DAG, 0.0, B_UNIT_DEF_SUPPRESS}, + {"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 bUnitDef buImperialMassDef[] = { + {"ton", "tonnes", "ton", "t", "Tonnes", UN_SC_ITON, 0.0, B_UNIT_DEF_NONE}, + {"centum weight", "centum weights", "cwt", NULL, "Centum weights", UN_SC_CWT, 0.0, B_UNIT_DEF_NONE}, + {"stone", "stones", "st", NULL, "Stones", UN_SC_ST, 0.0, B_UNIT_DEF_NONE}, + {"pound", "pounds", "lb", NULL, "Pounds", UN_SC_LB, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"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)}; + +/* 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 */ + +/* Velocity */ +static struct bUnitDef buMetricVelDef[] = { + {"meter per second", "meters per second", "m/s", NULL, "Meters per second", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"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 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)}; + +/* 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 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)}; /* Time */ static struct bUnitDef buNaturalTimeDef[] = { @@ -118,7 +251,7 @@ static struct bUnitDef buNaturalTimeDef[] = { {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0 , B_UNIT_DEF_NONE}, - {"microsecond", "microseconds", "us", NULL, "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, + {"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)}; @@ -130,13 +263,12 @@ static struct bUnitDef buNaturalRotDef[] = { }; static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; -#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 8) / sizeof(void *)) - 1) - -static struct bUnitCollection *bUnitSystems[][8] = { - {0,0,0,0,0,&buNaturalRotCollection,&buNaturalTimeCollecton,0}, - {0,&buMetricLenCollecton, 0,0,0, &buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* metric */ - {0,&buImperialLenCollecton, 0,0,0,&buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* imperial */ - {0,0,0,0,0,0,0,0} +#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 9) / sizeof(void *)) - 1) +static struct bUnitCollection *bUnitSystems[][9] = { + {0, 0, 0, 0, 0, &buNaturalRotCollection, &buNaturalTimeCollecton, 0, 0}, + {0, &buMetricLenCollecton, &buMetricAreaCollecton, &buMetricVolCollecton, &buMetricMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buMetricVelCollecton, &buMetricAclCollecton}, /* metric */ + {0, &buImperialLenCollecton, &buImperialAreaCollecton, &buImperialVolCollecton, &buImperialMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buImperialVelCollecton, &buImperialAclCollecton}, /* imperial */ + {0, 0, 0, 0, 0, 0, 0, 0, 0} }; @@ -263,8 +395,9 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, if(usys==NULL || usys->units[0].name==NULL) usys= &buDummyCollecton; - - if(split) { + + /* split output makes sense only for length, mass and time */ + if(split && (type==B_UNIT_LENGTH || type==B_UNIT_MASS || type==B_UNIT_TIME)) { int i; bUnitDef *unit_a, *unit_b; double value_a, value_b; @@ -450,10 +583,6 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre for(unit= usys->units; unit->name; unit++) { - - if(unit->flag & B_UNIT_DEF_SUPPRESS) - continue; - /* incase there are multiple instances */ while(unit_replace(str, len_max, str_tmp, scale_pref, unit)) change= 1; @@ -470,13 +599,10 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre usys_iter= unit_get_system(system_iter, type); if (usys_iter) { for(unit= usys_iter->units; unit->name; unit++) { - - if((unit->flag & B_UNIT_DEF_SUPPRESS) == 0) { - int ofs = 0; - /* incase there are multiple instances */ - while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) - change= 1; - } + int ofs = 0; + /* incase there are multiple instances */ + while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) + change= 1; } } } @@ -489,10 +615,6 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre if(str_prev) { /* see which units the original value had */ for(unit= usys->units; unit->name; unit++) { - - if(unit->flag & B_UNIT_DEF_SUPPRESS) - continue; - if (unit_find(str_prev, unit)) break; } diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index bb20cb7c8e1..48ad46282c2 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -155,6 +155,8 @@ MINLINE float interpf(float a, float b, float t); MINLINE float minf(float a, float b); MINLINE float maxf(float a, float b); +MINLINE float signf(float f); + MINLINE float power_of_2(float f); MINLINE float shell_angle_to_dist(float angle); diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index ac8ed041ebc..1b3f4dced02 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -147,6 +147,7 @@ void mat4_to_eulO(float eul[3], short order, float mat[4][4]); void axis_angle_to_eulO(float eul[3], short order, float axis[3], float angle); void mat3_to_compatible_eulO(float eul[3], float old[3], short order, float mat[3][3]); +void mat4_to_compatible_eulO(float eul[3], float old[3], short order, float mat[4][4]); void rotate_eulO(float eul[3], short order, char axis, float angle); diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index b8c886d95a9..f01e1a25d8a 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -100,6 +100,7 @@ int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char void BLI_getlastdir(const char* dir, char *last, int maxlen); int BLI_testextensie(const char *str, const char *ext); int BLI_testextensie_array(const char *str, const char **ext_array); +int BLI_testextensie_glob(const char *str, const char *ext_fnmatch); int BLI_replace_extension(char *path, int maxlen, const char *ext); void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len); void BLI_newname(char * name, int add); diff --git a/source/blender/blenlib/BLI_storage.h b/source/blender/blenlib/BLI_storage.h index 83537e4f3c4..e443a853324 100644 --- a/source/blender/blenlib/BLI_storage.h +++ b/source/blender/blenlib/BLI_storage.h @@ -40,6 +40,11 @@ #endif #endif +#ifdef WIN32 +/* for size_t, only needed on win32 for some reason */ +#include +#endif + struct direntry; diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index b364ff73e4f..fc413457122 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -122,5 +122,10 @@ MINLINE float maxf(float a, float b) return (a > b)? a: b; } +MINLINE float signf(float f) +{ + return (f < 0.f)? -1.f: 1.f; +} + #endif /* BLI_MATH_BASE_INLINE */ diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 787e126a42b..2b6a091cc8d 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -393,6 +393,7 @@ void srgb_to_linearrgb_rgba_rgba_buf(float *col_to, float *col_from, int tot) { while(tot--) { srgb_to_linearrgb_v3_v3(col_to, col_from); + col_to[3]= col_from[3]; col_to += 4; col_from += 4; } @@ -402,6 +403,7 @@ void linearrgb_to_srgb_rgba_rgba_buf(float *col_to, float *col_from, int tot) { while(tot--) { linearrgb_to_srgb_v3_v3(col_to, col_from); + col_to[3]= col_from[3]; col_to += 4; col_from += 4; } diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index f72269f6d7b..b8cef511293 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1249,6 +1249,15 @@ void mat3_to_compatible_eulO(float eul[3], float oldrot[3], short order,float ma copy_v3_v3(eul, eul1); } +void mat4_to_compatible_eulO(float eul[3], float oldrot[3], short order,float M[4][4]) +{ + float m[3][3]; + + /* for now, we'll just do this the slow way (i.e. copying matrices) */ + copy_m3_m4(m, M); + normalize_m3(m); + mat3_to_compatible_eulO(eul, oldrot, order, m); +} /* rotate the given euler by the given angle on the specified axis */ // NOTE: is this safe to do with different axis orders? void rotate_eulO(float beul[3], short order, char axis, float ang) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 50c5095afe7..384f3aa541f 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -48,6 +48,12 @@ #include "GHOST_Path-api.h" +#if defined WIN32 && !defined _LIBC +# include "BLI_fnmatch.h" /* use fnmatch included in blenlib */ +#else +# define _GNU_SOURCE +# include +#endif #ifdef WIN32 #include @@ -1285,6 +1291,36 @@ int BLI_testextensie_array(const char *str, const char **ext_array) return 0; } +/* semicolon separated wildcards, eg: + * '*.zip;*.py;*.exe' */ +int BLI_testextensie_glob(const char *str, const char *ext_fnmatch) +{ + const char *ext_step= ext_fnmatch; + char pattern[16]; + + while(ext_step[0]) { + char *ext_next; + int len_ext; + + if((ext_next=strchr(ext_step, ';'))) { + len_ext= (int)(ext_next - ext_step) + 1; + } + else { + len_ext= sizeof(pattern); + } + + BLI_strncpy(pattern, ext_step, len_ext); + + if(fnmatch(pattern, str, FNM_CASEFOLD)==0) { + return 1; + } + ext_step += len_ext; + } + + return 0; +} + + int BLI_replace_extension(char *path, int maxlen, const char *ext) { int a; diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index cae0fccd12a..cc70d3355f2 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -27,10 +27,15 @@ FILE(GLOB SRC intern/*.c) SET(INC - . ../../../intern/guardedalloc ../blenlib ../blenkernel - ../makesdna ../readblenfile ../include ../makesrna - ../python ../../kernel/gen_messaging + . + ../blenlib + ../blenkernel + ../makesdna + ../readblenfile + ../include + ../makesrna ../render/extern/include + ../../../intern/guardedalloc ${ZLIB_INC} ) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 46caab94ce7..352cc5f85ce 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1398,6 +1398,14 @@ static void IDP_DirectLinkIDPArray(IDProperty *prop, int switch_endian, FileData prop->data.pointer = newdataadr(fd, prop->data.pointer); array= (IDProperty*) prop->data.pointer; + + /* note!, idp-arrays didn't exist in 2.4x, so the pointer will be cleared + * theres not really anything we can do to correct this, at least dont crash */ + if(array==NULL) { + prop->len= 0; + prop->totallen= 0; + } + for(i=0; ilen; i++) IDP_DirectLinkProperty(&array[i], switch_endian, fd); diff --git a/source/blender/blenpluginapi/CMakeLists.txt b/source/blender/blenpluginapi/CMakeLists.txt index 42aa5eddc42..3abf1e44449 100644 --- a/source/blender/blenpluginapi/CMakeLists.txt +++ b/source/blender/blenpluginapi/CMakeLists.txt @@ -27,7 +27,12 @@ FILE(GLOB SRC intern/*.c) SET(INC - . .. ../../../intern/guardedalloc ../blenlib ../imbuf ../makesdna + . + .. + ../blenlib + ../imbuf + ../makesdna + ../../../intern/guardedalloc ) IF(WIN32) diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 2a16e27df29..c768020a0ff 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1403,8 +1403,23 @@ static int animdata_filter_dopesheet_mats (bAnimContext *ac, ListBase *anim_data short ok = 0; /* for now, if no material returned, skip (this shouldn't confuse the user I hope) */ - if (ELEM(NULL, ma, ma->adt)) - continue; + if (ma == NULL) continue; + if (ma->adt == NULL) { + /* need to check textures */ + if(ma->mtex) { + MTex **mtex = ma->mtex; + int a; + for (a=0; a < MAX_MTEX; a++) { + if (ELEM3(NULL, mtex[a], mtex[a]->tex, mtex[a]->tex->adt)) + continue; + else + ok=1; + } + } + else + continue; + } + /* check if ok */ ANIMDATA_FILTER_CASES(ma, @@ -1421,7 +1436,6 @@ static int animdata_filter_dopesheet_mats (bAnimContext *ac, ListBase *anim_data } /* if there were no channels found, no need to carry on */ - // XXX: textures with no animated owner material won't work because of this... if (mats.first == NULL) return 0; @@ -2529,11 +2543,26 @@ static int animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, bDo /* firstly check that we actuallly have some materials */ for (a=0; a < ob->totcol; a++) { Material *ma= give_current_material(ob, a); + int mtInd; if ((ma) && ANIMDATA_HAS_KEYS(ma)) { matOk= 1; break; } + + if(ma) { + for (mtInd= 0; mtInd < MAX_MTEX; mtInd++) { + MTex *mtex= ma->mtex[mtInd]; + + if (mtex && mtex->tex && ANIMDATA_HAS_KEYS(mtex->tex)) { + matOk= 1; + break; + } + } + } + + if(matOk) + break; } } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 719b46738d3..5c4d231fd3a 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -362,6 +362,7 @@ static int ed_marker_add(bContext *C, wmOperator *op) BLI_addtail(markers, marker); WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -511,6 +512,7 @@ static void ed_marker_move_cancel(bContext *C, wmOperator *op) ed_marker_move_exit(C, op); WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); } @@ -537,6 +539,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) if(WM_modal_tweak_exit(evt, mm->event_type)) { ed_marker_move_exit(C, op); WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -614,6 +617,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) } WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); ED_area_headerprint(CTX_wm_area(C), str); } } @@ -635,6 +639,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) ED_area_headerprint(CTX_wm_area(C), str); WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); } } @@ -840,6 +845,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) #endif WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); /* allowing tweaks */ return OPERATOR_PASS_THROUGH; @@ -935,6 +941,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); return 1; } @@ -1000,6 +1007,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -1042,8 +1050,10 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *op) } } - if (changed) + if (changed) { WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + } return OPERATOR_FINISHED; } @@ -1136,8 +1146,10 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op) } } - if (changed) + if (changed) { WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 9edcf637cdc..898d7db89fc 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -372,12 +372,12 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) /* try to create driver using property retrieved from UI */ memset(&ptr, 0, sizeof(PointerRNA)); - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); if (all) index= -1; - if (ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { path= RNA_path_from_ID_to_property(&ptr, prop); if (path) { @@ -389,6 +389,8 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ + uiContextAnimUpdate(C); + DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX @@ -427,12 +429,12 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) /* try to find driver using property retrieved from UI */ memset(&ptr, 0, sizeof(PointerRNA)); - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); if (all) index= -1; - if (ptr.data && prop) { + if (ptr.id.data && ptr.data && prop) { path= RNA_path_from_ID_to_property(&ptr, prop); success= ANIM_remove_driver(ptr.id.data, path, index, 0); MEM_freeN(path); @@ -440,6 +442,8 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ + uiContextAnimUpdate(C); + DAG_ids_flush_update(CTX_data_main(C), 0); WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX @@ -478,14 +482,16 @@ static int copy_driver_button_exec (bContext *C, wmOperator *op) /* try to create driver using property retrieved from UI */ memset(&ptr, 0, sizeof(PointerRNA)); - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); - if (ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { path= RNA_path_from_ID_to_property(&ptr, prop); if (path) { /* only copy the driver for the button that this was involved for */ success= ANIM_copy_driver(ptr.id.data, path, index, 0); + + uiContextAnimUpdate(C); MEM_freeN(path); } @@ -522,14 +528,16 @@ static int paste_driver_button_exec (bContext *C, wmOperator *op) /* try to create driver using property retrieved from UI */ memset(&ptr, 0, sizeof(PointerRNA)); - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); - if (ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { path= RNA_path_from_ID_to_property(&ptr, prop); if (path) { /* only copy the driver for the button that this was involved for */ success= ANIM_paste_driver(ptr.id.data, path, index, 0); + + uiContextAnimUpdate(C); MEM_freeN(path); } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 5073cfe08b8..befcc0a71cb 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -82,6 +82,12 @@ void delete_fcurve_key(FCurve *fcu, int index, short do_recalc) /* Delete this keyframe */ memmove(&fcu->bezt[index], &fcu->bezt[index+1], sizeof(BezTriple)*(fcu->totvert-index-1)); fcu->totvert--; + + if (fcu->totvert == 0) { + if (fcu->bezt) + MEM_freeN(fcu->bezt); + fcu->bezt= NULL; + } /* recalc handles - only if it won't cause problems */ if (do_recalc) diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index fc5649be869..e92065eea91 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1362,9 +1362,9 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) /* try to insert keyframe using property retrieved from UI */ memset(&ptr, 0, sizeof(PointerRNA)); - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); - if ((ptr.data && prop) && RNA_property_animateable(&ptr, prop)) { + if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) { path= RNA_path_from_ID_to_property(&ptr, prop); if (path) { @@ -1405,6 +1405,8 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ + uiContextAnimUpdate(C); + DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ @@ -1446,9 +1448,9 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) /* try to insert keyframe using property retrieved from UI */ memset(&ptr, 0, sizeof(PointerRNA)); - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); - if (ptr.data && prop) { + if (ptr.id.data && ptr.data && prop) { path= RNA_path_from_ID_to_property(&ptr, prop); if (path) { @@ -1476,6 +1478,8 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) if (success) { /* send updates */ + uiContextAnimUpdate(C); + DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index ab236de9ac5..d80ccf2cd29 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -323,10 +323,10 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) /* try to add to keyingset using property retrieved from UI */ memset(&ptr, 0, sizeof(PointerRNA)); - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); /* check if property is able to be added */ - if (ptr.data && prop && RNA_property_animateable(&ptr, prop)) { + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { path= RNA_path_from_ID_to_property(&ptr, prop); if (path) { @@ -409,9 +409,9 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op) /* try to add to keyingset using property retrieved from UI */ memset(&ptr, 0, sizeof(PointerRNA)); - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); - if (ptr.data && prop) { + if (ptr.id.data && ptr.data && prop) { path= RNA_path_from_ID_to_property(&ptr, prop); if (path) { diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index fadb4f234d9..2d28d3cb9e5 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -66,6 +66,8 @@ void ARMATURE_OT_select_linked(struct wmOperatorType *ot); void ARMATURE_OT_delete(struct wmOperatorType *ot); void ARMATURE_OT_duplicate(struct wmOperatorType *ot); void ARMATURE_OT_extrude(struct wmOperatorType *ot); +void ARMATURE_OT_hide(struct wmOperatorType *ot); +void ARMATURE_OT_reveal(struct wmOperatorType *ot); void ARMATURE_OT_click_extrude(struct wmOperatorType *ot); void ARMATURE_OT_fill(struct wmOperatorType *ot); void ARMATURE_OT_merge(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 908aa5bb432..535cc62caf6 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -72,6 +72,8 @@ void ED_operatortypes_armature(void) WM_operatortype_append(ARMATURE_OT_delete); WM_operatortype_append(ARMATURE_OT_duplicate); WM_operatortype_append(ARMATURE_OT_extrude); + WM_operatortype_append(ARMATURE_OT_hide); + WM_operatortype_append(ARMATURE_OT_reveal); WM_operatortype_append(ARMATURE_OT_click_extrude); WM_operatortype_append(ARMATURE_OT_fill); WM_operatortype_append(ARMATURE_OT_merge); @@ -203,7 +205,8 @@ void ED_keymap_armature(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "snap", 1); /* only set in editmode armature, by space_view3d listener */ -// WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index f2bc4b3d46a..930f6e684fc 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -88,10 +88,6 @@ #include "reeb.h" #endif -/* ************* XXX *************** */ -static void BIF_undo_push(const char *msg) {} -/* ************* XXX *************** */ - /* **************** tools on Editmode Armature **************** */ /* Sync selection to parent for connected children */ @@ -1896,7 +1892,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot) * toggle==2: only active tag * toggle==3: swap (no test) */ -void ED_armature_deselectall(Object *obedit, int toggle, int doundo) +void ED_armature_deselectall(Object *obedit, int toggle) { bArmature *arm= obedit->data; EditBone *eBone; @@ -1967,7 +1963,7 @@ int mouse_armature(bContext *C, short mval[2], int extend) if (nearBone) { if (!extend) - ED_armature_deselectall(obedit, 0, 0); + ED_armature_deselectall(obedit, 0); /* by definition the non-root connected bones have no root point drawn, so a root selection needs to be delivered to the parent tip */ @@ -2249,6 +2245,8 @@ static void undoBones_to_editBones(void *uarmv, void *armv) ebo= uarm->act_edbone; arm->act_edbone= ebo->temp; } + else + arm->act_edbone= NULL; /* set pointers */ for(newebo= arm->edbo->first; newebo; newebo= newebo->next) { @@ -2362,7 +2360,7 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) mul_m3_m3m3(totmat, obmat, viewmat); invert_m3_m3(imat, totmat); - ED_armature_deselectall(obedit, 0, 0); + ED_armature_deselectall(obedit, 0); /* Create a bone */ bone= ED_armature_edit_bone_add(obedit->data, "Bone"); @@ -2415,7 +2413,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *op) to_root= 1; } - ED_armature_deselectall(obedit, 0, 0); + ED_armature_deselectall(obedit, 0); /* we re-use code for mirror editing... */ flipbone= NULL; @@ -3264,6 +3262,81 @@ void ARMATURE_OT_merge (wmOperatorType *ot) /* ************** END Add/Remove stuff in editmode ************ */ /* *************** Tools in editmode *********** */ +static int armature_hide_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + bArmature *arm= obedit->data; + EditBone *ebone; + + /* cancel if nothing selected */ + if (CTX_DATA_COUNT(C, selected_bones) == 0) + return OPERATOR_CANCELLED; + + for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + if (EBONE_VISIBLE(arm, ebone)) { + if (ebone->flag & BONE_SELECTED) { + ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag |= BONE_HIDDEN_A; + } + } + } + ED_armature_validate_active(arm); + ED_armature_sync_selection(arm->edbo); + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); + + return OPERATOR_FINISHED; +} + +void ARMATURE_OT_hide(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Hide Selected Bones"; + ot->idname= "ARMATURE_OT_hide"; + + /* api callbacks */ + ot->exec= armature_hide_exec; + ot->poll= ED_operator_editarmature; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int armature_reveal_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + bArmature *arm= obedit->data; + EditBone *ebone; + + for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + if(arm->layer & ebone->layer) { + if (ebone->flag & BONE_HIDDEN_A) { + ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag &= ~BONE_HIDDEN_A; + } + } + } + ED_armature_validate_active(arm); + ED_armature_sync_selection(arm->edbo); + + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); + + return OPERATOR_FINISHED; +} + +void ARMATURE_OT_reveal(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Reveal Bones"; + ot->idname= "ARMATURE_OT_reveal"; + + /* api callbacks */ + ot->exec= armature_reveal_exec; + ot->poll= ED_operator_editarmature; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} void hide_selected_armature_bones(Scene *scene) { @@ -3281,7 +3354,6 @@ void hide_selected_armature_bones(Scene *scene) } ED_armature_validate_active(arm); ED_armature_sync_selection(arm->edbo); - BIF_undo_push("Hide Bones"); } @@ -3304,7 +3376,6 @@ static void hide_unselected_armature_bones(Scene *scene) ED_armature_validate_active(arm); ED_armature_sync_selection(arm->edbo); - BIF_undo_push("Hide Unselected Bones"); } #endif @@ -3325,7 +3396,6 @@ void show_all_armature_bones(Scene *scene) } ED_armature_validate_active(arm); ED_armature_sync_selection(arm->edbo); - BIF_undo_push("Reveal Bones"); } #endif @@ -3510,7 +3580,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) mul_m3_m3m3(totmat, obmat, viewmat); invert_m3_m3(imat, totmat); - ED_armature_deselectall(obedit, 0, 0); + ED_armature_deselectall(obedit, 0); /* Create a bone */ bone= ED_armature_edit_bone_add(obedit->data, name); @@ -4393,7 +4463,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor /* since we do unified select, we don't shift+select a bone if the armature object was not active yet */ if (!(extend) || (base != scene->basact)) { - ED_pose_deselectall(ob, 0, 0); + ED_pose_deselectall(ob, 0); nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); arm->act_bone= nearBone; @@ -4440,7 +4510,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor test==2: only clear active tag test==3: swap select (no test / inverse selection status of all independently) */ -void ED_pose_deselectall (Object *ob, int test, int doundo) +void ED_pose_deselectall (Object *ob, int test) { bArmature *arm= ob->data; bPoseChannel *pchan; @@ -4480,13 +4550,6 @@ void ED_pose_deselectall (Object *ob, int test, int doundo) if(arm->act_bone && (arm->act_bone->flag & BONE_SELECTED)==0) arm->act_bone= NULL; - - //countall(); // XXX need an equivalent to this... - - if (doundo) { - if (selectmode==1) BIF_undo_push("Select All"); - else BIF_undo_push("Deselect All"); - } } static int bone_skinnable(Object *ob, Bone *bone, void *datap) @@ -5709,6 +5772,7 @@ void transform_armature_mirror_update(Object *obedit) eboflip->tail[1]= ebo->tail[1]; eboflip->tail[2]= ebo->tail[2]; eboflip->rad_tail= ebo->rad_tail; + eboflip->roll= -ebo->roll; /* Also move connected children, in case children's name aren't mirrored properly */ for (children=arm->edbo->first; children; children=children->next) { @@ -5723,6 +5787,7 @@ void transform_armature_mirror_update(Object *obedit) eboflip->head[1]= ebo->head[1]; eboflip->head[2]= ebo->head[2]; eboflip->rad_head= ebo->rad_head; + eboflip->roll= -ebo->roll; /* Also move connected parent, in case parent's name isn't mirrored properly */ if (eboflip->parent && eboflip->flag & BONE_CONNECTED) @@ -6070,8 +6135,6 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) } BLI_ghash_free(arcBoneMap, NULL, NULL); - - BIF_undo_push("Generate Skeleton"); } void generateSkeleton(Scene *scene) diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 146213af667..ae79c0b0053 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -236,10 +236,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) ef->textbuf[cu->pos]= c; ef->textbufinfo[cu->pos] = cu->curinfo; ef->textbufinfo[cu->pos].kern = 0; - if(obedit->actcol>0) - ef->textbufinfo[cu->pos].mat_nr = obedit->actcol; - else - ef->textbufinfo[cu->pos].mat_nr = 0; + ef->textbufinfo[cu->pos].mat_nr = obedit->actcol; cu->pos++; cu->len++; @@ -257,16 +254,14 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re { Curve *cu= obedit->data; EditFont *ef= cu->editfont; - - if(cu->pos) - cu->curinfo = ef->textbufinfo[cu->pos-1]; - else - cu->curinfo = ef->textbufinfo[0]; + cu->curinfo = ef->textbufinfo[cu->pos?cu->pos-1:0]; if(obedit->totcol>0) - obedit->actcol= ef->textbufinfo[cu->pos-1].mat_nr; + obedit->actcol= ef->textbufinfo[cu->pos?cu->pos-1:0].mat_nr; + + if(mode == FO_EDIT) + update_string(cu); - update_string(cu); BKE_text_to_curve(scene, obedit, mode); if(recalc) @@ -371,7 +366,7 @@ static int paste_file(bContext *C, ReportList *reports, char *filename) } MEM_freeN(strp); - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); return OPERATOR_FINISHED; } @@ -754,7 +749,7 @@ static int cut_text_exec(bContext *C, wmOperator *op) copy_selection(obedit); kill_selection(obedit, 0); - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); return OPERATOR_FINISHED; } @@ -812,7 +807,7 @@ static int paste_text_exec(bContext *C, wmOperator *op) if(!paste_selection(obedit, op->reports)) return OPERATOR_CANCELLED; - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); return OPERATOR_FINISHED; } @@ -853,7 +848,7 @@ static int move_cursor(bContext *C, int type, int select) Object *obedit= CTX_data_edit_object(C); Curve *cu= obedit->data; EditFont *ef= cu->editfont; - int cursmove= 0; + int cursmove= -1; switch(type) { case LINE_BEGIN: @@ -923,7 +918,7 @@ static int move_cursor(bContext *C, int type, int select) break; } - if(!cursmove) + if(cursmove == -1) return OPERATOR_CANCELLED; if(select == 0) { @@ -1017,7 +1012,7 @@ static int change_spacing_exec(bContext *C, wmOperator *op) ef->textbufinfo[cu->pos-1].kern = kern; - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); return OPERATOR_FINISHED; } @@ -1062,7 +1057,7 @@ static int change_character_exec(bContext *C, wmOperator *op) ef->textbuf[cu->pos - 1]= character; - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); return OPERATOR_FINISHED; } @@ -1105,7 +1100,7 @@ static int line_break_exec(bContext *C, wmOperator *op) cu->selstart = cu->selend = 0; - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); return OPERATOR_FINISHED; } @@ -1195,7 +1190,7 @@ static int delete_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); return OPERATOR_FINISHED; } @@ -1245,7 +1240,7 @@ static int insert_text_exec(bContext *C, wmOperator *op) MEM_freeN(inserted_utf8); kill_selection(obedit, 1); - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); return OPERATOR_FINISHED; } @@ -1313,12 +1308,12 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) } kill_selection(obedit, 1); - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); } else { inserted_text[0]= ascii; insert_into_textbuf(obedit, ascii); - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); } } else if(val && event == BACKSPACEKEY) { @@ -1560,7 +1555,7 @@ static int set_case(bContext *C, int ccase) } } - text_update_edited(C, scene, obedit, 1, 0); + text_update_edited(C, scene, obedit, 1, FO_EDIT); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 5df04435abe..6055b9eecb3 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -102,7 +102,7 @@ void ED_keymap_armature(struct wmKeyConfig *keyconf); void ED_armature_from_edit(struct Object *obedit); void ED_armature_to_edit(struct Object *ob); void ED_armature_edit_free(struct Object *ob); -void ED_armature_deselectall(struct Object *obedit, int toggle, int doundo); +void ED_armature_deselectall(struct Object *obedit, int toggle); int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int *buffer, short hits, short extend); @@ -140,7 +140,7 @@ void undo_push_armature(struct bContext *C, char *name); void ED_armature_exit_posemode(struct bContext *C, struct Base *base); void ED_armature_enter_posemode(struct bContext *C, struct Base *base); int ED_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan); -void ED_pose_deselectall(struct Object *ob, int test, int doundo); +void ED_pose_deselectall(struct Object *ob, int test); void ED_pose_recalculate_paths(struct bContext *C, struct Scene *scene, struct Object *ob); /* sketch */ diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index c55dafa6f51..c5abd5465d7 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -68,13 +68,21 @@ typedef struct ScreenFrameRateInfo { /* ----------------------------------------------------- */ +/* Enum for Action Zone Edges. Which edge of area is action zone. */ +typedef enum { + AE_RIGHT_TO_TOPLEFT, /* Region located on the left, _right_ edge is action zone. Region minimised to the top left */ + AE_LEFT_TO_TOPRIGHT, /* Region located on the right, _left_ edge is action zone. Region minimised to the top right */ + AE_TOP_TO_BOTTOMRIGHT, /* Region located at the bottom, _top_ edge is action zone. Region minimised to the bottom right */ + AE_BOTTOM_TO_TOPLEFT /* Region located at the top, _bottom_edge is action zone. Region minimised to the top left */ +} AZEdge; + /* for editing areas/regions */ typedef struct AZone { struct AZone *next, *prev; ARegion *ar; int type; /* region-azone, which of the edges */ - short edge; + AZEdge edge; /* internal */ short do_draw; /* for draw */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 7d56698f7b9..54a627da2da 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -737,7 +737,8 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname, c void UI_buttons_operatortypes(void); /* Helpers for Operators */ -void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index); +void uiContextActiveProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index); +void uiContextAnimUpdate(const struct bContext *C); void uiFileBrowseContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop); void uiIDContextProperty(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index f6ba948db7d..4f9393fb862 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -753,7 +753,10 @@ void uiDrawBlock(const bContext *C, uiBlock *block) /* widgets */ for(but= block->buttons.first; but; but= but->next) { ui_but_to_pixelrect(&rect, ar, block, but); - if(!(but->flag & UI_HIDDEN)) + if(!(but->flag & UI_HIDDEN) && + /* XXX: figure out why invalid coordinates happen when closing render window */ + /* and material preview is redrawn in main window (temp fix for bug #23848) */ + rect.xmin < rect.xmax && rect.ymin < rect.ymax) ui_draw_but(C, ar, &style, but, &rect); } @@ -808,7 +811,13 @@ static void ui_is_but_sel(uiBut *but) break; case ROW: case LISTROW: - if(value == but->hardmax) push= 1; + /* support for rna enum buts */ + if(but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) { + if((int)value & (int)but->hardmax) push= 1; + } + else { + if(value == but->hardmax) push= 1; + } break; case COL: push= 2; @@ -1352,7 +1361,14 @@ void ui_set_but_val(uiBut *but, double value) RNA_property_float_set(&but->rnapoin, prop, value); break; case PROP_ENUM: - RNA_property_enum_set(&but->rnapoin, prop, value); + if(RNA_property_flag(prop) & PROP_ENUM_FLAG) { + int ivalue= (int)value; + ivalue ^= RNA_property_enum_get(&but->rnapoin, prop); /* toggle for enum/flag buttons */ + RNA_property_enum_set(&but->rnapoin, prop, ivalue); + } + else { + RNA_property_enum_set(&but->rnapoin, prop, value); + } break; default: break; diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index c99622c7518..2a30a36ffe0 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -114,74 +114,50 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) } } -void uiAnimContextProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index) -{ - ARegion *ar= CTX_wm_region(C); - uiBlock *block; - uiBut *but; - - memset(ptr, 0, sizeof(*ptr)); - *prop= NULL; - *index= 0; - - if(ar) { - for(block=ar->uiblocks.first; block; block=block->next) { - for(but=block->buttons.first; but; but= but->next) { - if((but->active || but->flag & UI_BUT_LAST_ACTIVE) && but->rnapoin.id.data) { - *ptr= but->rnapoin; - *prop= but->rnaprop; - *index= but->rnaindex; - return; - } - } - } - } -} - void ui_but_anim_insert_keyframe(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_keyframe_insert_button", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_delete_keyframe(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_keyframe_delete_button", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_add_driver(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_driver_button_add", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_remove_driver(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_driver_button_remove", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_copy_driver(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_copy_driver_button", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_paste_driver(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_paste_driver_button", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_add_keyingset(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_keyingset_button_add", WM_OP_INVOKE_DEFAULT, NULL); } void ui_but_anim_remove_keyingset(bContext *C) { - /* this operator calls uiAnimContextProperty above */ + /* this operator calls uiContextActiveProperty */ WM_operator_name_call(C, "ANIM_OT_keyingset_button_remove", WM_OP_INVOKE_DEFAULT, NULL); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index fea152bb4a7..5bcde844d45 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4255,6 +4255,7 @@ static int ui_but_menu(bContext *C, uiBut *but) static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) { + Scene *scene= CTX_data_scene(C); uiHandleButtonData *data; int retval; @@ -4906,6 +4907,98 @@ void ui_button_active_free(const bContext *C, uiBut *but) } } +/* helper function for insert keyframe, reset to default, etc operators */ +void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index) +{ + ARegion *ar= CTX_wm_region(C); + uiBlock *block; + uiBut *but, *activebut; + + memset(ptr, 0, sizeof(*ptr)); + *prop= NULL; + *index= 0; + + while(ar) { + /* find active button */ + activebut= NULL; + + for(block=ar->uiblocks.first; block; block=block->next) { + for(but=block->buttons.first; but; but= but->next) { + if(but->active) + activebut= but; + else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) + activebut= but; + } + } + + if(activebut) { + if(activebut->rnapoin.data) { + /* found RNA button */ + *ptr= activebut->rnapoin; + *prop= activebut->rnaprop; + *index= activebut->rnaindex; + return; + } + else { + /* recurse into opened menu */ + uiHandleButtonData *data= activebut->active; + if(data && data->menu) + ar = data->menu->region; + else + return; + } + } + else { + /* no active button */ + return; + } + } +} + +/* helper function for insert keyframe, reset to default, etc operators */ +void uiContextAnimUpdate(const bContext *C) +{ + Scene *scene= CTX_data_scene(C); + ARegion *ar= CTX_wm_region(C); + uiBlock *block; + uiBut *but, *activebut; + + while(ar) { + /* find active button */ + activebut= NULL; + + for(block=ar->uiblocks.first; block; block=block->next) { + for(but=block->buttons.first; but; but= but->next) { + ui_but_anim_flag(but, (scene)? scene->r.cfra: 0.0f); + + if(but->active) + activebut= but; + else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) + activebut= but; + } + } + + if(activebut) { + if(activebut->rnapoin.data) { + /* found RNA button */ + return; + } + else { + /* recurse into opened menu */ + uiHandleButtonData *data= activebut->active; + if(data && data->menu) + ar = data->menu->region; + else + return; + } + } + else { + /* no active button */ + return; + } + } +} + /************** handle activating a button *************/ static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event) @@ -5404,20 +5497,44 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, if(event->val==KM_PRESS) { but= ui_but_find_activated(ar); if(but) { - if(ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) - but= ui_but_next(but); - else - but= ui_but_prev(but); + /* is there a situation where UI_LEFT or UI_RIGHT would also change navigation direction? */ + /* UI_TOP and UI_DOWN are inconsistant - should be UI_UP and UI_DOWN or UI_TOP and UI_BOTTOM */ + if( ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DOWN)) || + ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_TOP)) + ) { + /* the following is just a hack - uiBut->type set to BUT and BUTM have there menus built + * opposite ways - this should be changed so that all popup-menus use the same uiBlock->direction */ + if(but->type & BUT) + but= ui_but_next(but); + else + but= ui_but_prev(but); + } + else { + if(but->type & BUT) + but= ui_but_prev(but); + else + but= ui_but_next(but); + } if(but) ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE); } if(!but) { - if(ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) - bt= ui_but_last(block); - else - bt= ui_but_first(block); + if( ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DOWN)) || + ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_TOP)) + ) { + if(ui_but_first(block)->type & BUT) + bt= ui_but_last(block); + else + bt= ui_but_first(block); + } + else { + if(ui_but_first(block)->type & BUT) + bt= ui_but_first(block); + else + bt= ui_but_last(block); + } if(bt) ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index d5f6b089544..3873c5c9092 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -103,7 +103,7 @@ typedef enum { #define UI_PANEL_MINY 70 /* uiBut->flag */ -#define UI_SELECT 1 +#define UI_SELECT 1 /* use when the button is pressed */ #define UI_MOUSE_OVER 2 #define UI_ACTIVE 4 #define UI_HAS_ICON 8 diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 1d98b1f22c1..e268120fa07 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -917,8 +917,15 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index if(layout->root->type == UI_LAYOUT_MENU) { if(type == PROP_BOOLEAN) icon= (RNA_property_boolean_get(ptr, prop))? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; - else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) - icon= (RNA_property_enum_get(ptr, prop) == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; + else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) { + int enum_value= RNA_property_enum_get(ptr, prop); + if(RNA_property_flag(prop) & PROP_ENUM_FLAG) { + icon= (enum_value & value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; + } + else { + icon= (enum_value == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; + } + } } slider= (flag & UI_ITEM_R_SLIDER); @@ -948,7 +955,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index uiDefButR(block, ROW, 0, name, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL); } /* expanded enum */ - else if(type == PROP_ENUM && expand) + else if(type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG)) ui_item_enum_expand(layout, block, ptr, prop, name, 0, 0, w, h, icon_only); /* property with separate label */ else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) { diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index caee3c1c2fe..bcde54f473a 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -68,7 +68,7 @@ static int eyedropper_init(bContext *C, wmOperator *op) op->customdata= eye= MEM_callocN(sizeof(Eyedropper), "Eyedropper"); - uiAnimContextProperty(C, &eye->ptr, &eye->prop, &eye->index); + uiContextActiveProperty(C, &eye->ptr, &eye->prop, &eye->index); return (eye->ptr.data && eye->prop && RNA_property_editable(&eye->ptr, eye->prop)); } @@ -228,9 +228,9 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *op) int index; /* try to create driver using property retrieved from UI */ - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); - if (ptr.data && prop) { + if (ptr.id.data && ptr.data && prop) { path= RNA_path_from_ID_to_property(&ptr, prop); if (path) { @@ -266,7 +266,7 @@ static int reset_default_button_poll(bContext *C) PropertyRNA *prop; int index; - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); return (ptr.data && prop && RNA_property_editable(&ptr, prop)); } @@ -279,7 +279,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op) int index, all = RNA_boolean_get(op->ptr, "all"); /* try to reset the nominated setting to its default value */ - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); /* if there is a valid property that is editable... */ if (ptr.data && prop && RNA_property_editable(&ptr, prop)) { @@ -335,7 +335,7 @@ static int copy_to_selected_button_poll(bContext *C) PropertyRNA *prop; int index, success= 0; - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.data && prop) { CollectionPointerLink *link; @@ -361,7 +361,7 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op) int index, all = RNA_boolean_get(op->ptr, "all"); /* try to reset the nominated setting to its default value */ - uiAnimContextProperty(C, &ptr, &prop, &index); + uiContextActiveProperty(C, &ptr, &prop, &index); /* if there is a valid property that is editable... */ if (ptr.data && prop) { diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 474927d3638..7dac8a465fa 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -1300,7 +1300,7 @@ static void make_prim_ext(bContext *C, float *loc, float *rot, int enter_editmod scale= ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); dia *= scale; - depth *= scale; + depth *= scale * 0.5f; make_prim(obedit, type, mat, tot, seg, subdiv, dia, depth, ext, fill); @@ -1359,7 +1359,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) /* sqrt(2.0f) - plane (diameter of 1.41 makes it unit size) */ make_prim_ext(C, loc, rot, enter_editmode, layer, - PRIM_CUBE, 4, 0, 0, sqrt(2.0f), 1.0f, 1, 1); + PRIM_CUBE, 4, 0, 0, sqrt(2.0f), 2.0f, 1, 1); return OPERATOR_FINISHED; } @@ -1457,7 +1457,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) /* props */ RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 2, 500); RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00); - RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00); + RNA_def_float(ot->srna, "depth", 2.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00); RNA_def_boolean(ot->srna, "cap_ends", 1, "Cap Ends", ""); ED_object_add_generic_props(ot, TRUE); @@ -1498,7 +1498,7 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot) /* props */ RNA_def_int(ot->srna, "vertices", 32, INT_MIN, INT_MAX, "Vertices", "", 2, 500); RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00); - RNA_def_float(ot->srna, "depth", 1.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00); + RNA_def_float(ot->srna, "depth", 2.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00); RNA_def_boolean(ot->srna, "cap_end", 0, "Cap End", ""); ED_object_add_generic_props(ot, TRUE); diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 0274bf1004d..7316e24ce65 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -2542,7 +2542,7 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", ""); - RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", ""); + RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "Limit selection by seam boundries (faces only)"); } @@ -2631,7 +2631,7 @@ void MESH_OT_select_linked(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", ""); + RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "Limit selection by seam boundries (faces only)"); } @@ -4450,7 +4450,7 @@ void vertexnoise(Object *obedit, EditMesh *em) } else { float tin, dum; - externtex(ma->mtex[0], eve->co, &tin, &dum, &dum, &dum, &dum); + externtex(ma->mtex[0], eve->co, &tin, &dum, &dum, &dum, &dum, 0); eve->co[2]+= 0.05*tin; } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 5d6d9e314f2..eadf0ca120f 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2941,6 +2941,13 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float } } + //third pass: unhide edges that have both verts visible + //(these were missed if all faces were hidden, bug #21976) + for(eed=em->edges.first; eed; eed=eed->next){ + if(eed->v1->h == 0 && eed->v2->h == 0) + eed->h &= ~1; + } + // Free the ghash and call MEM_freeN on all the value entries to return // that memory BLI_ghash_free(gh, NULL, (GHashValFreeFP)MEM_freeN); diff --git a/source/blender/editors/mesh/loopcut.c b/source/blender/editors/mesh/loopcut.c index 174207a71c5..13538a6f218 100644 --- a/source/blender/editors/mesh/loopcut.c +++ b/source/blender/editors/mesh/loopcut.c @@ -252,7 +252,7 @@ static void ringsel_find_edge(tringselOpData *lcd, const bContext *C, ARegion *a { if (lcd->eed) { edgering_sel(lcd, cuts, 0); - } else { + } else if(lcd->edges) { MEM_freeN(lcd->edges); lcd->edges = NULL; lcd->totedge = 0; diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index a03d1a29333..f81e73faf73 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -48,6 +48,7 @@ #include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" +#include "BKE_multires.h" #include "BKE_report.h" #include "RE_pipeline.h" @@ -63,6 +64,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "ED_object.h" /* ****************** render BAKING ********************** */ @@ -137,6 +139,12 @@ static void init_bake_internal(BakeRender *bkr, bContext *C) { Scene *scene= CTX_data_scene(C); + /* flush multires changes (for sculpt) */ + multires_force_render_update(CTX_data_active_object(C)); + + /* get editmode results */ + ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ + bkr->sa= biggest_image_area(CTX_wm_screen(C)); /* can be NULL */ bkr->main= CTX_data_main(C); bkr->scene= scene; @@ -227,7 +235,7 @@ static void bake_freejob(void *bkv) BakeRender *bkr= bkv; finish_bake_internal(bkr); - if(bkr->tot==0) BKE_report(bkr->reports, RPT_ERROR, "No Images found to bake to"); + if(bkr->tot==0) BKE_report(bkr->reports, RPT_ERROR, "No valid images found to bake to"); MEM_freeN(bkr); G.rendering = 0; } @@ -252,6 +260,10 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *_eve { Scene *scene= CTX_data_scene(C); + /* only one render job at a time */ + if(WM_jobs_test(CTX_wm_manager(C), scene)) + return OPERATOR_CANCELLED; + if(test_bake_internal(C, op->reports)==0) { return OPERATOR_CANCELLED; } @@ -323,7 +335,7 @@ static int bake_image_exec(bContext *C, wmOperator *op) } BLI_end_threads(&threads); - if(bkr.tot==0) BKE_report(op->reports, RPT_ERROR, "No Images found to bake to"); + if(bkr.tot==0) BKE_report(op->reports, RPT_ERROR, "No valid images found to bake to"); finish_bake_internal(&bkr); } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index baf71cb21d6..f5d87df10a1 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -808,7 +808,7 @@ static int constraint_delete_exec (bContext *C, wmOperator *op) ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */ /* notifiers */ - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, ob); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 2aaabebdb29..2a0289ca8b3 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -421,6 +421,9 @@ static int parent_clear_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + if(ob->parent == NULL) + continue; + if(type == 0) { ob->parent= NULL; } @@ -569,8 +572,8 @@ static int parent_set_exec(bContext *C, wmOperator *op) Object workob; /* apply transformation of previous parenting */ - object_apply_mat4(ob, ob->obmat); - + /* object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */ + /* set the parent (except for follow-path constraint option) */ if(partype != PAR_PATH_CONST) ob->parent= par; @@ -1889,7 +1892,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - ot->prop= RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", type_items, SELECT, "Type", ""); RNA_def_boolean(ot->srna, "object", 0, "Object", "Make single user objects"); RNA_def_boolean(ot->srna, "obdata", 0, "Object Data", "Make single user object data"); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index f4806adf8b4..e943a80040b 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2067,6 +2067,8 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) vgroup_remap_update_users(ob, sort_map_update); ob->actdef= sort_map_update[ob->actdef]; + + MEM_freeN(sort_map_update); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 5ca8162a93d..9a03d12509d 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -22,25 +22,24 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenfont ../../blenkernel ../../blenlib ../../blenloader ../../gpu ../../imbuf - ../include - ../../../../intern/guardedalloc - ../../../../extern/glew/include ../../makesdna ../../makesrna - ../../python ../../render/extern/include ../../windowmanager + ../../../../intern/guardedalloc + ../../../../extern/glew/include ../../freestyle ) IF(WITH_QUICKTIME) - SET(INC ${INC} ../../quicktime ${QUICKTIME_INC}) + LIST(APPEND INC ../../quicktime ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 93e891dcc57..39eb6921379 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -1309,6 +1309,7 @@ static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int ImBuf *ibuf=NULL; int dx; int retval; + int relative= (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path")); if(env->cube[1]==NULL) { BKE_report(op->reports, RPT_ERROR, "There is no generated environment map available to save"); @@ -1335,6 +1336,9 @@ static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ibuf->profile = IB_PROFILE_LINEAR_RGB; + /* to save, we first get absolute path */ + BLI_path_abs(str, G.sce); + if (BKE_write_ibuf(scene, ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) { retval = OPERATOR_FINISHED; } @@ -1342,6 +1346,9 @@ static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int BKE_reportf(op->reports, RPT_ERROR, "Error saving environment map to %s.", str); retval = OPERATOR_CANCELLED; } + /* in case we were saving with relative paths, change back again */ + if(relative) + BLI_path_rel(str, G.sce); IMB_freeImBuf(ibuf); ibuf = NULL; diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index b6a8e27449b..f7dfd81dba9 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -22,15 +22,15 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenfont ../../blenkernel ../../blenlib ../../imbuf - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) IF(WIN32) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 07d1e47f74e..d0361c5fa01 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -469,29 +469,31 @@ static void area_azone_initialize(ScrArea *sa) #define AZONEPAD_ICON 8 static void region_azone_edge(AZone *az, ARegion *ar) { - if(az->edge=='t') { - az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymax - AZONEPAD_EDGE; - az->x2= ar->winrct.xmax; - az->y2= ar->winrct.ymax; - } - else if(az->edge=='b') { - az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymin + AZONEPAD_EDGE; - az->x2= ar->winrct.xmax; - az->y2= ar->winrct.ymin; - } - else if(az->edge=='l') { - az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymin; - az->x2= ar->winrct.xmin + AZONEPAD_EDGE; - az->y2= ar->winrct.ymax; - } - else { // if(az->edge=='r') { - az->x1= ar->winrct.xmax; - az->y1= ar->winrct.ymin; - az->x2= ar->winrct.xmax - AZONEPAD_EDGE; - az->y2= ar->winrct.ymax; + switch(az->edge) { + case AE_TOP_TO_BOTTOMRIGHT: + az->x1= ar->winrct.xmin; + az->y1= ar->winrct.ymax - AZONEPAD_EDGE; + az->x2= ar->winrct.xmax; + az->y2= ar->winrct.ymax; + break; + case AE_BOTTOM_TO_TOPLEFT: + az->x1= ar->winrct.xmin; + az->y1= ar->winrct.ymin + AZONEPAD_EDGE; + az->x2= ar->winrct.xmax; + az->y2= ar->winrct.ymin; + break; + case AE_LEFT_TO_TOPRIGHT: + az->x1= ar->winrct.xmin; + az->y1= ar->winrct.ymin; + az->x2= ar->winrct.xmin + AZONEPAD_EDGE; + az->y2= ar->winrct.ymax; + break; + case AE_RIGHT_TO_TOPLEFT: + az->x1= ar->winrct.xmax; + az->y1= ar->winrct.ymin; + az->x2= ar->winrct.xmax - AZONEPAD_EDGE; + az->y2= ar->winrct.ymax; + break; } BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); @@ -502,33 +504,38 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) AZone *azt; int tot=0; + /* count how many actionzones with along same edge are available. + This allows for adding more action zones in the future without + having to worry about correct offset */ for(azt= sa->actionzones.first; azt; azt= azt->next) { if(azt->edge == az->edge) tot++; } - if(az->edge=='t') { - az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON; - az->y1= ar->winrct.ymax + AZONEPAD_ICON; - az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON; - az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON; - } - else if(az->edge=='b') { - az->x1= ar->winrct.xmin + AZONEPAD_ICON; - az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON; - az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON; - az->y2= ar->winrct.ymin - AZONEPAD_ICON; - } - else if(az->edge=='l') { - az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON; - az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON; - az->x2= ar->winrct.xmin - AZONEPAD_ICON; - az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON; - } - else { // if(az->edge=='r') { - az->x1= ar->winrct.xmax + AZONEPAD_ICON; - az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON; - az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON; - az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON; + switch(az->edge) { + case AE_TOP_TO_BOTTOMRIGHT: + az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON; + az->y1= ar->winrct.ymax + AZONEPAD_ICON; + az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON; + az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON; + break; + case AE_BOTTOM_TO_TOPLEFT: + az->x1= ar->winrct.xmin + AZONEPAD_ICON; + az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON; + az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON; + az->y2= ar->winrct.ymin - AZONEPAD_ICON; + break; + case AE_LEFT_TO_TOPRIGHT: + az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON; + az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON; + az->x2= ar->winrct.xmin - AZONEPAD_ICON; + az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON; + break; + case AE_RIGHT_TO_TOPLEFT: + az->x1= ar->winrct.xmax + AZONEPAD_ICON; + az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON; + az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON; + az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON; + break; } BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); @@ -537,22 +544,21 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) for(azt= sa->actionzones.first; azt; azt= azt->next) { if(az!=azt) { if( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) { - if(az->edge=='t' || az->edge=='b') { + if(az->edge==AE_TOP_TO_BOTTOMRIGHT || az->edge==AE_BOTTOM_TO_TOPLEFT) { az->x1+= AZONESPOT; az->x2+= AZONESPOT; - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } - else { + else{ az->y1-= AZONESPOT; az->y2-= AZONESPOT; - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } + BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } } } } -static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge) +static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) { AZone *az; @@ -575,17 +581,16 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge) static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment) { - /* edge code (t b l r) is where azone will be drawn */ + /* edge code (t b l r) is along which area edge azone will be drawn */ if(alignment==RGN_ALIGN_TOP) - region_azone_initialize(sa, ar, 'b'); + region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT); else if(alignment==RGN_ALIGN_BOTTOM) - region_azone_initialize(sa, ar, 't'); + region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT); else if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) - region_azone_initialize(sa, ar, 'l'); + region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT); else if(ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT)) - region_azone_initialize(sa, ar, 'r'); - + region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT); } /* dir is direction to check, not the splitting edge direction! */ diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 1ca8bff3193..05b6e072eac 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -53,6 +53,7 @@ #include "ED_object.h" #include "ED_screen.h" #include "ED_screen_types.h" +#include "ED_fileselect.h" #include "UI_interface.h" @@ -1161,7 +1162,7 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) if(az->type==AZONE_AREA) WM_cursor_set(win, CURSOR_EDIT); else if(az->type==AZONE_REGION) { - if(az->edge == 'l' || az->edge == 'r') + if(az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) WM_cursor_set(win, CURSOR_X_MOVE); else WM_cursor_set(win, CURSOR_Y_MOVE); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 0c92d6bbc6a..363e8a2b47c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1291,19 +1291,19 @@ typedef struct RegionMoveData { int bigger, smaller, origval; int origx, origy; int maxsize; - char edge; + AZEdge edge; } RegionMoveData; -static int area_max_regionsize(ScrArea *sa, ARegion *scalear, char edge) +static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) { ARegion *ar; int dist; - if(edge=='l' || edge=='r') { + if(edge==AE_RIGHT_TO_TOPLEFT || edge==AE_LEFT_TO_TOPRIGHT) { dist = sa->totrct.xmax - sa->totrct.xmin; - } else { /* t, b */ + } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ dist = sa->totrct.ymax - sa->totrct.ymin; } @@ -1325,9 +1325,9 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, char edge) /* case of regions in regions, like operator properties panel */ /* these can sit on top of other regions such as headers, so account for this */ - else if (edge == 'b' && scalear->alignment & RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_TOP && ar->regiontype == RGN_TYPE_HEADER) + else if (edge == AE_BOTTOM_TO_TOPLEFT && scalear->alignment & RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_TOP && ar->regiontype == RGN_TYPE_HEADER) dist -= ar->winy; - else if (edge == 't' && scalear->alignment & RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_BOTTOM && ar->regiontype == RGN_TYPE_HEADER) + else if (edge == AE_TOP_TO_BOTTOMRIGHT && scalear->alignment & RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_BOTTOM && ar->regiontype == RGN_TYPE_HEADER) dist -= ar->winy; } @@ -1367,7 +1367,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) rmd->ar->sizey= rmd->ar->type->prefsizey; /* now copy to regionmovedata */ - if(rmd->edge=='l' || rmd->edge=='r') { + if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { rmd->origval= rmd->ar->sizex; } else { rmd->origval= rmd->ar->sizey; @@ -1399,9 +1399,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) switch(event->type) { case MOUSEMOVE: - if(rmd->edge=='l' || rmd->edge=='r') { + if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { delta= event->x - rmd->origx; - if(rmd->edge=='l') delta= -delta; + if(rmd->edge==AE_LEFT_TO_TOPRIGHT) delta= -delta; rmd->ar->sizex= rmd->origval + delta; CLAMP(rmd->ar->sizex, 0, rmd->maxsize); @@ -1417,7 +1417,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) else { int maxsize=0; delta= event->y - rmd->origy; - if(rmd->edge=='b') delta= -delta; + if(rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta; rmd->ar->sizey= rmd->origval + delta; CLAMP(rmd->ar->sizey, 0, rmd->maxsize); diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index fb8382e10ca..3211763b619 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -22,16 +22,16 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../imbuf ../../gpu ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager ../../render/extern/include + ../../../../intern/guardedalloc ) IF(WIN32) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index e7a06f27f67..6e921b57d9d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -3757,7 +3757,7 @@ static void *do_projectpaint_thread(void *ph_v) if (falloff > 0.0f) { if (ps->is_texbrush) { - brush_sample_tex(ps->brush, projPixel->projCoSS, rgba); + brush_sample_tex(ps->brush, projPixel->projCoSS, rgba, thread_index); alpha = rgba[3]; } else { alpha = 1.0f; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 10af35a1b4b..2e192a08ca5 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -724,7 +724,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float *point, const floa /* Get strength by feeding the vertex location directly into a texture */ externtex(mtex, point, &avg, - &jnk, &jnk, &jnk, &jnk); + &jnk, &jnk, &jnk, &jnk, 0); } else if(ss->texcache) { float rotation = -mtex->rot; diff --git a/source/blender/editors/sound/CMakeLists.txt b/source/blender/editors/sound/CMakeLists.txt index 02765726c6e..456c02d947e 100644 --- a/source/blender/editors/sound/CMakeLists.txt +++ b/source/blender/editors/sound/CMakeLists.txt @@ -22,14 +22,14 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc - ../../../../intern/audaspace/intern ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc + ../../../../intern/audaspace/intern ) BLENDERLIB(bf_editor_sound "${SRC}" "${INC}") diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt index 85275b2db23..3c0585c31ca 100644 --- a/source/blender/editors/space_action/CMakeLists.txt +++ b/source/blender/editors/space_action/CMakeLists.txt @@ -22,14 +22,13 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) - BLENDERLIB(bf_editor_space_action "${SRC}" "${INC}") diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt index 591e97f800f..da140fe0982 100644 --- a/source/blender/editors/space_api/CMakeLists.txt +++ b/source/blender/editors/space_api/CMakeLists.txt @@ -22,13 +22,13 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) BLENDERLIB(bf_editor_space_api "${SRC}" "${INC}") diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index bb50ac0cc86..f8e9536ecf8 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -22,13 +22,13 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) BLENDERLIB(bf_editor_space_buttons "${SRC}" "${INC}") diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index c4357008a9c..c1803dde805 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -33,8 +33,12 @@ #include "DNA_userdef_types.h" #include "BLI_fileops.h" +#include "BLI_path_util.h" +#include "BLI_storage.h" +#include "BLI_string.h" #include "BKE_context.h" +#include "BKE_global.h" #include "WM_api.h" #include "WM_types.h" @@ -89,12 +93,28 @@ typedef struct FileBrowseOp { static int file_browse_exec(bContext *C, wmOperator *op) { FileBrowseOp *fbo= op->customdata; - char *str; + ID *id; + char *base, *str, path[FILE_MAX]; if (RNA_property_is_set(op->ptr, "filepath")==0 || fbo==NULL) return OPERATOR_CANCELLED; str= RNA_string_get_alloc(op->ptr, "filepath", 0, 0); + + /* add slash for directories, important for some properties */ + if(RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { + id = fbo->ptr.id.data; + base = (id && id->lib)? id->lib->filepath: G.sce; + + BLI_strncpy(path, str, FILE_MAX); + BLI_path_abs(path, base); + + if(BLI_is_dir(path)) { + str = MEM_reallocN(str, strlen(str)+2); + BLI_add_slash(str); + } + } + RNA_property_string_set(&fbo->ptr, fbo->prop, str); RNA_property_update(C, &fbo->ptr, fbo->prop); MEM_freeN(str); diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt index 0cee45576b8..59074bcbb79 100644 --- a/source/blender/editors/space_console/CMakeLists.txt +++ b/source/blender/editors/space_console/CMakeLists.txt @@ -22,15 +22,15 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenfont ../../blenkernel ../../blenlib ../../blenloader - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) IF(NOT WITH_PYTHON) diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index 207d83b56c6..2a204d67537 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -22,18 +22,17 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenfont ../../blenkernel ../../blenlib ../../blenloader ../../imbuf - ../include - ../../../../intern/audaspace/intern - ../../../../intern/guardedalloc ../../makesdna ../../makesrna - ../../render/extern/include ../../windowmanager + ../../render/extern/include + ../../../../intern/guardedalloc ) IF(WITH_IMAGE_OPENEXR) diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 7888fdeef8a..e9764a2d36a 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1135,6 +1135,7 @@ int file_filenum_exec(bContext *C, wmOperator *op) if(sfile->params && (inc != 0)) { BLI_newname(sfile->params->file, inc); ED_area_tag_redraw(sa); + file_draw_check_cb(C, NULL, NULL); // WM_event_add_notifier(C, NC_WINDOW, NULL); } @@ -1168,6 +1169,8 @@ int file_rename_exec(bContext *C, wmOperator *op) if ( (0<=idx) && (idxfiles, idx); file->flags |= EDITING; + BLI_strncpy(sfile->params->renameedit, file->relname, FILE_MAXFILE); + sfile->params->renamefile[0]= '\0'; } ED_area_tag_redraw(sa); } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index c3bea2a5bea..eba0df9f963 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -108,6 +108,7 @@ typedef struct FileList short prv_h; short hide_dot; unsigned int filter; + char filter_glob[64]; short changed; struct BlendHandle *libfiledata; @@ -547,6 +548,7 @@ void filelist_free(struct FileList* filelist) free(filelist->filelist); filelist->filelist = 0; filelist->filter = 0; + filelist->filter_glob[0] = '\0'; filelist->numfiltered =0; filelist->hide_dot =0; } @@ -713,6 +715,11 @@ void filelist_setfilter(struct FileList* filelist, unsigned int filter) filelist->filter = filter; } +void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob) +{ + BLI_strncpy(filelist->filter_glob, filter_glob, sizeof(filelist->filter_glob)); +} + static void filelist_read_dir(struct FileList* filelist) { char wdir[FILE_MAX]; @@ -824,6 +831,9 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime) file->flags |= MOVIEFILE; } else if(BLI_testextensie_array(file->relname, imb_ext_audio)) { file->flags |= SOUNDFILE; + } else if(filelist->filter_glob + && BLI_testextensie_glob(file->relname, filelist->filter_glob)) { + file->flags |= OPERATORFILE; } } } diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index b2a86b9c764..9dd7ab26625 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -58,6 +58,7 @@ void filelist_setdir(struct FileList* filelist, const char *dir); struct direntry * filelist_file(struct FileList* filelist, int index); void filelist_hidedot(struct FileList* filelist, short hide); void filelist_setfilter(struct FileList* filelist, unsigned int filter); +void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob); void filelist_filter(struct FileList* filelist); void filelist_swapselect(struct FileList* filelist); void filelist_imgsize(struct FileList* filelist, short w, short h); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index e2099be6f03..7192870bcc8 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -105,6 +105,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams"); /* set path to most recently opened .blend */ BLI_split_dirfile(G.sce, sfile->params->dir, sfile->params->file); + sfile->params->filter_glob[0] = '\0'; } params = sfile->params; @@ -168,6 +169,14 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->filter |= RNA_boolean_get(op->ptr, "filter_btx") ? BTXFILE : 0; if(RNA_struct_find_property(op->ptr, "filter_collada")) params->filter |= RNA_boolean_get(op->ptr, "filter_collada") ? COLLADAFILE : 0; + if (RNA_struct_find_property(op->ptr, "filter_glob")) { + RNA_string_get(op->ptr, "filter_glob", params->filter_glob); + params->filter |= (OPERATORFILE|FOLDERFILE); + } + else { + params->filter_glob[0] = '\0'; + } + if (params->filter != 0) { if (U.uiflag & USER_FILTERFILEEXTS) { params->flag |= FILE_FILTER; @@ -200,6 +209,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->flag |= FILE_HIDE_DOT; params->display = FILE_SHORTDISPLAY; params->filter = 0; + params->filter_glob[0] = '\0'; params->sort = FILE_SORT_ALPHA; } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 7b9423332f2..0cd721964bd 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -192,6 +192,7 @@ static void file_refresh(const bContext *C, ScrArea *sa) } filelist_hidedot(sfile->files, params->flag & FILE_HIDE_DOT); filelist_setfilter(sfile->files, params->flag & FILE_FILTER ? params->filter : 0); + filelist_setfilter_types(sfile->files, params->filter_glob); if (filelist_empty(sfile->files)) { thumbnails_stop(sfile->files, C); diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt index 6ad95d920c6..33ddbcea019 100644 --- a/source/blender/editors/space_graph/CMakeLists.txt +++ b/source/blender/editors/space_graph/CMakeLists.txt @@ -22,13 +22,13 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ../../../../intern/audaspace/intern ) diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 1c0a97767b7..d47f5a9820e 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -22,15 +22,15 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib ../../imbuf - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna - ../../render/extern/include ../../windowmanager + ../../render/extern/include + ../../../../intern/guardedalloc ) IF(WITH_IMAGE_OPENEXR) diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt index aa9a40ac98f..9d439c4ec00 100644 --- a/source/blender/editors/space_info/CMakeLists.txt +++ b/source/blender/editors/space_info/CMakeLists.txt @@ -22,14 +22,14 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib ../../imbuf - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) BLENDERLIB(bf_editor_space_info "${SRC}" "${INC}") diff --git a/source/blender/editors/space_logic/CMakeLists.txt b/source/blender/editors/space_logic/CMakeLists.txt index 91087d57f11..6f0a260124d 100644 --- a/source/blender/editors/space_logic/CMakeLists.txt +++ b/source/blender/editors/space_logic/CMakeLists.txt @@ -22,14 +22,14 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager ../../editors/interface + ../../../../intern/guardedalloc ) IF(WITH_GAMEENGINE) diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt index be8020b0793..6bb656cba8c 100644 --- a/source/blender/editors/space_nla/CMakeLists.txt +++ b/source/blender/editors/space_nla/CMakeLists.txt @@ -22,13 +22,13 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) BLENDERLIB(bf_editor_space_nla "${SRC}" "${INC}") diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index 06dd2257147..ae298a611e9 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -22,17 +22,17 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib ../../imbuf - ../include - ../../../../intern/guardedalloc - ../../../../intern/opennl/extern ../../makesdna ../../makesrna ../../nodes - ../../render/extern/include ../../windowmanager + ../../render/extern/include + ../../../../intern/guardedalloc + ../../../../intern/opennl/extern ) IF(WIN32) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 93dddac3107..5e0926da216 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -74,7 +74,7 @@ void node_buts_group(uiLayout *layout, bContext *C, PointerRNA *ptr) { - uiTemplateIDBrowse(layout, C, ptr, "nodetree", NULL, NULL, ""); + uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, ""); } static void node_buts_value(uiLayout *layout, bContext *C, PointerRNA *ptr) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 5aa512ea904..b6dc0b4db7c 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1735,7 +1735,7 @@ static int node_make_link_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); - snode_autoconnect(snode, 0, replace); + snode_autoconnect(snode, 1, replace); node_tree_verify_groups(snode->nodetree); snode_notify(C, snode); diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 17c50b32e98..0711ef66497 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -49,6 +49,7 @@ #include "UI_interface.h" +#include "UI_view2d.h" #include "node_intern.h" @@ -153,6 +154,18 @@ static void node_menu_add(const bContext *C, Menu *menu) { uiLayout *layout= menu->layout; SpaceNode *snode= CTX_wm_space_node(C); + ScrArea *sa= CTX_wm_area(C); + ARegion *ar; + + /* get location to add node at mouse */ + for(ar=sa->regionbase.first; ar; ar=ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) { + wmWindow *win= CTX_wm_window(C); + UI_view2d_region_to_view(&ar->v2d, + win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, + &snode->mx, &snode->my); + } + } if(!snode->nodetree) uiLayoutSetActive(layout, 0); diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 78c4fcbdd8d..5ebe47f8c5e 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -22,15 +22,15 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib ../../imbuf - ../include - ../../../../intern/guardedalloc - ../../../../intern/opennl/extern ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc + ../../../../intern/opennl/extern ) BLENDERLIB(bf_editor_space_outliner "${SRC}" "${INC}") diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index aa51055ed7b..7b98b421758 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -1571,6 +1571,7 @@ static int outliner_toggle_visibility_exec(bContext *C, wmOperator *op) outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); + WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -1579,7 +1580,7 @@ static int outliner_toggle_visibility_exec(bContext *C, wmOperator *op) void OUTLINER_OT_visibility_toggle(wmOperatorType *ot) { /* identifiers */ - ot->name= "Toggle Visability"; + ot->name= "Toggle Visibility"; ot->idname= "OUTLINER_OT_visibility_toggle"; ot->description= "Toggle the visibility of selected items"; @@ -1610,6 +1611,7 @@ static int outliner_toggle_selectability_exec(bContext *C, wmOperator *op) outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -1703,6 +1705,7 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *op) { SpaceOops *soops= CTX_wm_space_outliner(C); ARegion *ar= CTX_wm_region(C); + Scene *scene= CTX_data_scene(C); if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1)) outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); @@ -1711,6 +1714,7 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *op) soops->storeflag |= SO_TREESTORE_REDRAW; + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -2114,8 +2118,8 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen if(set) { if(!(pchan->bone->flag & BONE_HIDDEN_P)) { - if(set==2) ED_pose_deselectall(ob, 2, 0); // 2 = clear active tag - else ED_pose_deselectall(ob, 0, 0); // 0 = deselect + if(set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag + else ED_pose_deselectall(ob, 0); // 0 = deselect if(set==2 && (pchan->bone->flag & BONE_SELECTED)) { pchan->bone->flag &= ~BONE_SELECTED; @@ -2145,8 +2149,8 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, if(set) { if(!(bone->flag & BONE_HIDDEN_P)) { - if(set==2) ED_pose_deselectall(OBACT, 2, 0); // 2 is clear active tag - else ED_pose_deselectall(OBACT, 0, 0); + if(set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag + else ED_pose_deselectall(OBACT, 0); if(set==2 && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; @@ -2179,8 +2183,8 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, if(set) { if(!(ebone->flag & BONE_HIDDEN_A)) { bArmature *arm= scene->obedit->data; - if(set==2) ED_armature_deselectall(scene->obedit, 2, 0); // only clear active tag - else ED_armature_deselectall(scene->obedit, 0, 0); // deselect + if(set==2) ED_armature_deselectall(scene->obedit, 2); // only clear active tag + else ED_armature_deselectall(scene->obedit, 0); // deselect ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; arm->act_edbone= ebone; @@ -3182,8 +3186,6 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto te->directdata= NULL; tselem->id= NULL; } - - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); } @@ -3333,6 +3335,7 @@ void outliner_del(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops) outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); DAG_scene_sort(CTX_data_main(C), scene); ED_undo_push(C, "Delete Objects"); + WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); } } @@ -3370,34 +3373,37 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) } str= "Select Objects"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } else if(event==2) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb); str= "Deselect Objects"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } else if(event==4) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); DAG_scene_sort(bmain, scene); str= "Delete Objects"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); } - else if(event==5) { /* disabled, see above (ton) */ + else if(event==5) { /* disabled, see above enum (ton) */ outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb); str= "Localized Objects"; } else if(event==6) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); str= "Toggle Visibility"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); } else if(event==7) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); str= "Toggle Selectability"; + WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } else if(event==8) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); str= "Toggle Renderability"; } - - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); ED_undo_push(C, str); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 1a46c32713e..5e11d3502c1 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -113,11 +113,21 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case ND_BONE_ACTIVE: case ND_BONE_SELECT: + case ND_PARENT: ED_region_tag_redraw(ar); break; + case ND_CONSTRAINT: + switch(wmn->action) { + case NA_ADDED: + case NA_REMOVED: + case NA_RENAME: + ED_region_tag_redraw(ar); + break; + } + break; case ND_MODIFIER: - if(wmn->action == NA_RENAME) - ED_region_tag_redraw(ar); + /* all modifier actions now */ + ED_region_tag_redraw(ar); break; } break; diff --git a/source/blender/editors/space_script/CMakeLists.txt b/source/blender/editors/space_script/CMakeLists.txt index 58b3affe2d4..7abaa4db441 100644 --- a/source/blender/editors/space_script/CMakeLists.txt +++ b/source/blender/editors/space_script/CMakeLists.txt @@ -22,17 +22,17 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) IF(WITH_PYTHON) - SET(INC ${INC} ${PYTHON_INC} ../../python) + LIST(APPEND INC ${PYTHON_INC} ../../python) ELSE(WITH_PYTHON) ADD_DEFINITIONS(-DDISABLE_PYTHON) ENDIF(WITH_PYTHON) diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index 383cc05b7f7..fa99d35a7cd 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -22,14 +22,14 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib ../../imbuf - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ../../../../intern/audaspace/intern ) diff --git a/source/blender/editors/space_sound/CMakeLists.txt b/source/blender/editors/space_sound/CMakeLists.txt index 60c8f5e44bd..c78fc11a908 100644 --- a/source/blender/editors/space_sound/CMakeLists.txt +++ b/source/blender/editors/space_sound/CMakeLists.txt @@ -22,13 +22,13 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) BLENDERLIB(bf_editor_space_sound "${SRC}" "${INC}") diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt index 0616cf5147a..eabf508b5f6 100644 --- a/source/blender/editors/space_text/CMakeLists.txt +++ b/source/blender/editors/space_text/CMakeLists.txt @@ -22,18 +22,18 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenfont ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) IF(WITH_PYTHON) - SET(INC ${INC} ${PYTHON_INC} ../../python) + LIST(APPEND INC ${PYTHON_INC} ../../python) ELSE(WITH_PYTHON) ADD_DEFINITIONS(-DDISABLE_PYTHON) ENDIF(WITH_PYTHON) diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index c8c19a0bc93..ada2a6ee200 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -117,12 +117,25 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_TEXT: - if(!wmn->reference || wmn->reference == st->text || wmn->data == ND_DISPLAY || wmn->action == NA_EDITED) { + /* check if active text was changed, no need to redraw if text isn't active + reference==NULL means text was unlinked, should update anyway for this + case -- no way to know was text active before unlinking or not */ + if(wmn->reference && wmn->reference != st->text) + break; + + if(wmn->data == ND_DISPLAY) ED_area_tag_redraw(sa); - if(wmn->action == NA_EDITED) + switch(wmn->action) { + case NA_EDITED: if(st->text) text_update_edited(st->text); + ED_area_tag_redraw(sa); + /* no break -- fall down to tag redraw */ + case NA_ADDED: + case NA_REMOVED: + ED_area_tag_redraw(sa); + break; } break; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index d39056c6bbc..ed70f31f970 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -357,7 +357,7 @@ static int unlink_exec(bContext *C, wmOperator *op) unlink_text(bmain, text); free_libblock(&bmain->text, text); - WM_event_add_notifier(C, NC_TEXT|NA_REMOVED, text); + WM_event_add_notifier(C, NC_TEXT|NA_REMOVED, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_time/CMakeLists.txt b/source/blender/editors/space_time/CMakeLists.txt index 39b7ba355b9..4da42ec1f42 100644 --- a/source/blender/editors/space_time/CMakeLists.txt +++ b/source/blender/editors/space_time/CMakeLists.txt @@ -22,13 +22,13 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) BLENDERLIB(bf_editor_space_time "${SRC}" "${INC}") diff --git a/source/blender/editors/space_userpref/CMakeLists.txt b/source/blender/editors/space_userpref/CMakeLists.txt index 1752f39cfa5..d57661bb166 100644 --- a/source/blender/editors/space_userpref/CMakeLists.txt +++ b/source/blender/editors/space_userpref/CMakeLists.txt @@ -25,10 +25,10 @@ SET(INC ../include ../../blenkernel ../../blenlib - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) BLENDERLIB(bf_editor_space_userpref "${SRC}" "${INC}") diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index ca9ad001a40..48747898981 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -28,16 +28,16 @@ SET(INC ../../blenlib ../../gpu ../../imbuf - ../../../../intern/guardedalloc - ../../../../intern/smoke/extern ../../makesdna ../../makesrna - ../../render/extern/include ../../windowmanager + ../../render/extern/include + ../../../../intern/guardedalloc + ../../../../intern/smoke/extern ) IF(WITH_GAMEENGINE) - SET(INC ${INC} ../../../kernel/gen_system) + LIST(APPEND INC ../../../kernel/gen_system) ADD_DEFINITIONS(-DGAMEBLENDER) ENDIF(WITH_GAMEENGINE) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 321281299ee..44fa0c7b181 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3075,12 +3075,15 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B int glsl = draw_glsl_material(scene, ob, v3d, dt); GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); - if (!glsl) + if(!glsl) { glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); + glEnable(GL_LIGHTING); + dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); + glDisable(GL_LIGHTING); + } + else + dm->drawFacesGLSL(dm, GPU_enable_material); - glEnable(GL_LIGHTING); - dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); - glDisable(GL_LIGHTING); GPU_end_object_materials(); } else { if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_SOLID)==0) diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index a85881dd76b..c6b92fae1c0 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -591,6 +591,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) case ND_TRANSFORM: case ND_OB_ACTIVE: case ND_OB_SELECT: + case ND_OB_VISIBLE: case ND_LAYER: case ND_RENDER_OPTIONS: case ND_MODE: diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index fa394ff708a..a44f2b15d11 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1979,20 +1979,18 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, /* calculate pixelsize factor once, is used for lamps and obcenters */ { - float len1, len2, vec[3]; - - copy_v3_v3(vec, rv3d->persinv[0]); - len1= normalize_v3(vec); - copy_v3_v3(vec, rv3d->persinv[1]); - len2= normalize_v3(vec); - - rv3d->pixsize= 2.0f*(len1>len2?len1:len2); + rv3d->pixsize= 2.0f; + if(rv3d->persp == RV3D_ORTHO || v3d->camera) { /* camera view needs with for ortho & persp */ + float len1= len_v3(rv3d->persinv[0]); + float len2= len_v3(rv3d->persinv[1]); + rv3d->pixsize *= MAX2(len1, len2); + } + /* correct for window size */ - if(ar->winx > ar->winy) rv3d->pixsize/= (float)ar->winx; - else rv3d->pixsize/= (float)ar->winy; + rv3d->pixsize/= (float)MAX2(ar->winx, ar->winy); } - + /* set for opengl */ glMatrixMode(GL_PROJECTION); glLoadMatrixf(rv3d->winmat); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 7a45a43ddd4..4065b159ccf 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -141,6 +141,7 @@ void VIEW3D_OT_select_lasso(struct wmOperatorType *ot); /* view3d_view.c */ void view3d_settings_from_ob(struct Object *ob, float *ofs, float *quat, float *dist, float *lens); +int view3d_is_ortho(View3D *v3d, RegionView3D *rv3d); void VIEW3D_OT_smoothview(struct wmOperatorType *ot); void VIEW3D_OT_setcameratoview(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index cc1d26b136e..cc4defacb35 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1833,61 +1833,61 @@ static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, floa { ToolSettings *ts= vc->scene->toolsettings; int bbsel; - Object *ob= vc->obact; + struct {ViewContext *vc; short select, mval[2]; float radius; } data; - if(vc->obedit==NULL && paint_facesel_test(ob)) { - Mesh *me = ob?ob->data:NULL; + bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0)); + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ - if (me) { - em_vertoffs= me->totface+1; /* max index array */ + vc->em= ((Mesh *)vc->obedit->data)->edit_mesh; - bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0)); - EM_backbuf_checkAndSelectTFaces(me, selecting==LEFTMOUSE); - EM_free_backbuf(); + data.vc = vc; + data.select = selecting; + data.mval[0] = mval[0]; + data.mval[1] = mval[1]; + data.radius = rad; -// XXX object_tface_flags_changed(OBACT, 0); + if(ts->selectmode & SCE_SELECT_VERTEX) { + if(bbsel) { + EM_backbuf_checkAndSelectVerts(vc->em, selecting==LEFTMOUSE); + } else { + mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, 1); } } - else { - struct {ViewContext *vc; short select, mval[2]; float radius; } data; - + + if(ts->selectmode & SCE_SELECT_EDGE) { + if (bbsel) { + EM_backbuf_checkAndSelectEdges(vc->em, selecting==LEFTMOUSE); + } else { + mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, 0); + } + } + + if(ts->selectmode & SCE_SELECT_FACE) { + if(bbsel) { + EM_backbuf_checkAndSelectFaces(vc->em, selecting==LEFTMOUSE); + } else { + mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data); + } + } + + EM_free_backbuf(); + EM_selectmode_flush(vc->em); +} + +static void paint_facesel_circle_select(ViewContext *vc, int selecting, short *mval, float rad) +{ + Object *ob= vc->obact; + Mesh *me = ob?ob->data:NULL; + int bbsel; + + if (me) { + em_vertoffs= me->totface+1; /* max index array */ + bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0)); - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ - - vc->em= ((Mesh *)vc->obedit->data)->edit_mesh; - - data.vc = vc; - data.select = selecting; - data.mval[0] = mval[0]; - data.mval[1] = mval[1]; - data.radius = rad; - - if(ts->selectmode & SCE_SELECT_VERTEX) { - if(bbsel) { - EM_backbuf_checkAndSelectVerts(vc->em, selecting==LEFTMOUSE); - } else { - mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, 1); - } - } - - if(ts->selectmode & SCE_SELECT_EDGE) { - if (bbsel) { - EM_backbuf_checkAndSelectEdges(vc->em, selecting==LEFTMOUSE); - } else { - mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, 0); - } - } - - if(ts->selectmode & SCE_SELECT_FACE) { - if(bbsel) { - EM_backbuf_checkAndSelectFaces(vc->em, selecting==LEFTMOUSE); - } else { - mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data); - } - } - + EM_backbuf_checkAndSelectTFaces(me, selecting==LEFTMOUSE); EM_free_backbuf(); - EM_selectmode_flush(vc->em); + +// XXX object_tface_flags_changed(OBACT, 0); } } @@ -2082,7 +2082,8 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) selecting= (gesture_mode==GESTURE_MODAL_SELECT); - if(CTX_data_edit_object(C) || (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) { + if(CTX_data_edit_object(C) || paint_facesel_test(obact) || + (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) { ViewContext vc; short mval[2]; @@ -2096,6 +2097,10 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) obedit_circle_select(&vc, selecting, mval, (float)radius); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data); } + else if(paint_facesel_test(obact)) { + paint_facesel_circle_select(&vc, selecting, mval, (float)radius); + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data); + } else return PE_circle_select(C, selecting, mval, (float)radius); } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index a4e893a6181..5ee87db6b68 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -99,6 +99,37 @@ static void special_transvert_update(Scene *scene, Object *obedit) Nurb *nu= nurbs->first; while(nu) { + /* keep handles' vectors unchanged */ + if(nu->bezt) { + int a= nu->pntsu; + TransVert *tv= transvmain; + BezTriple *bezt= nu->bezt; + + while(a--) { + if(bezt->f1 & SELECT) tv++; + + if(bezt->f2 & SELECT) { + float v[3]; + + if(bezt->f1 & SELECT) { + sub_v3_v3v3(v, (tv-1)->oldloc, tv->oldloc); + add_v3_v3v3(bezt->vec[0], bezt->vec[1], v); + } + + if(bezt->f3 & SELECT) { + sub_v3_v3v3(v, (tv+1)->oldloc, tv->oldloc); + add_v3_v3v3(bezt->vec[2], bezt->vec[1], v); + } + + tv++; + } + + if(bezt->f3 & SELECT) tv++; + + bezt++; + } + } + test2DNurb(nu); testhandlesNurb(nu); /* test for bezier too */ nu= nu->next; @@ -152,7 +183,9 @@ static void special_transvert_update(Scene *scene, Object *obedit) } /* copied from editobject.c, needs to be replaced with new transform code still */ -/* mode: 1 = proportional, 2 = all joints (for bones only) */ +/* mode flags: */ +#define TM_ALL_JOINTS 1 /* all joints (for bones only) */ +#define TM_SKIP_HANDLES 2 /* skip handles when control point is selected (for curves only) */ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) { Nurb *nu; @@ -173,7 +206,6 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) if(obedit->type==OB_MESH) { Mesh *me= obedit->data; EditMesh *em= me->edit_mesh; - int proptrans= 0; // transform now requires awareness for select mode, so we tag the f1 flags in verts tottrans= 0; @@ -206,17 +238,6 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) for(eve= em->verts.first; eve; eve= eve->next) if(eve->f1) tottrans++; } - /* proportional edit exception... */ - if((mode & 1) && tottrans) { - for(eve= em->verts.first; eve; eve= eve->next) { - if(eve->h==0) { - eve->f1 |= 2; - proptrans++; - } - } - if(proptrans>tottrans) tottrans= proptrans; - } - /* and now make transverts */ if(tottrans) { tv=transvmain= MEM_callocN(tottrans*sizeof(TransVert), "maketransverts"); @@ -248,7 +269,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) short rootok= (!(ebo->parent && (ebo->flag & BONE_CONNECTED) && ebo->parent->flag & BONE_TIPSEL)); if ((tipsel && rootsel) || (rootsel)) { - /* Don't add the tip (unless mode & 2, for getting all joints), + /* Don't add the tip (unless mode & TM_ALL_JOINTS, for getting all joints), * otherwise we get zero-length bones as tips will snap to the same * location as heads. */ @@ -261,7 +282,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) tottrans++; } - if ((mode & 2) && (tipsel)) { + if ((mode & TM_ALL_JOINTS) && (tipsel)) { VECCOPY (tv->oldloc, ebo->tail); tv->loc= ebo->tail; tv->nor= NULL; @@ -301,14 +322,18 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) bezt= nu->bezt; while(a--) { if(bezt->hide==0) { - if((mode & 1) || (bezt->f1 & SELECT)) { + int skip_handle= 0; + if(bezt->f2 & SELECT) + skip_handle= mode & TM_SKIP_HANDLES; + + if((bezt->f1 & SELECT) && !skip_handle) { VECCOPY(tv->oldloc, bezt->vec[0]); tv->loc= bezt->vec[0]; tv->flag= bezt->f1 & SELECT; tv++; tottrans++; } - if((mode & 1) || (bezt->f2 & SELECT)) { + if(bezt->f2 & SELECT) { VECCOPY(tv->oldloc, bezt->vec[1]); tv->loc= bezt->vec[1]; tv->val= &(bezt->alfa); @@ -317,7 +342,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) tv++; tottrans++; } - if((mode & 1) || (bezt->f3 & SELECT)) { + if((bezt->f3 & SELECT) && !skip_handle) { VECCOPY(tv->oldloc, bezt->vec[2]); tv->loc= bezt->vec[2]; tv->flag= bezt->f3 & SELECT; @@ -333,7 +358,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) bp= nu->bp; while(a--) { if(bp->hide==0) { - if((mode & 1) || (bp->f1 & SELECT)) { + if(bp->f1 & SELECT) { VECCOPY(tv->oldloc, bp->vec); tv->loc= bp->vec; tv->val= &(bp->alfa); @@ -376,10 +401,10 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; - tv=transvmain= MEM_callocN(a*sizeof(TransVert), "maketransverts curve"); + tv=transvmain= MEM_callocN(a*sizeof(TransVert), "maketransverts latt"); while(a--) { - if((mode & 1) || (bp->f1 & SELECT)) { + if(bp->f1 & SELECT) { if(bp->hide==0) { copy_v3_v3(tv->oldloc, bp->vec); tv->loc= bp->vec; @@ -392,6 +417,13 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) } } + if(!tottrans && transvmain) { + /* prevent memory leak. happens for curves/latticies due to */ + /* difficult condition of adding points to trans data */ + MEM_freeN(transvmain); + transvmain= NULL; + } + /* cent etc */ tv= transvmain; total= 0.0; @@ -727,7 +759,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *op) tottrans=0; if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL) - make_trans_verts(obedit, bmat[0], bmat[1], 2); + make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS|TM_SKIP_HANDLES); if(tottrans==0) return OPERATOR_CANCELLED; copy_m3_m4(bmat, obedit->obmat); @@ -909,7 +941,7 @@ int minmax_verts(Object *obedit, float *min, float *max) tottrans=0; if ELEM5(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE) - make_trans_verts(obedit, bmat[0], bmat[1], 2); + make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS); if(tottrans==0) return 0; diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index e47a3af19f1..6e2624cb60b 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -129,7 +129,7 @@ static void view3d_panel_operator_redo_operator(const bContext *C, Panel *pa, wm { if(op->type->flag & OPTYPE_MACRO) { for(op= op->macro.first; op; op= op->next) { - uiItemL(pa->layout, op->idname, 0); + uiItemL(pa->layout, op->type->name, 0); view3d_panel_operator_redo_operator(C, pa, op); } } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 6c35b8a7bea..6a3c121ce4b 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -2722,3 +2722,7 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f } } +int view3d_is_ortho(View3D *v3d, RegionView3D *rv3d) +{ + return (rv3d->persp == RV3D_ORTHO || (v3d->camera && ((Camera *)v3d->camera->data)->type == CAM_ORTHO)); +} diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index e67771270cf..e28ed89c80c 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -22,13 +22,13 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) BLENDERLIB(bf_editor_transform "${SRC}" "${INC}") diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 481dfb473c7..88d74a443ca 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -298,7 +298,10 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) if (t->spacetype == SPACE_VIEW3D) { /* Do we need more refined tags? */ - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + if(t->flag & T_POSE) + WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + else + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); /* for realtime animation record - send notifiers recognised by animation editors */ // XXX: is this notifier a lame duck? @@ -4658,8 +4661,23 @@ void freeSlideVerts(TransInfo *t) { TransDataSlideUv *suv; SlideData *sld = t->customData; + Mesh *me = t->obedit->data; int uvlay_idx; + if(me->drawflag & ME_DRAW_EDGELEN) { + TransDataSlideVert *tempsv; + LinkNode *look = sld->vertlist; + GHash *vertgh = sld->vhash; + while(look) { + tempsv = BLI_ghash_lookup(vertgh,(EditVert*)look->link); + if(tempsv != NULL) { + tempsv->up->f &= !SELECT; + tempsv->down->f &= !SELECT; + } + look = look->next; + } + } + //BLI_ghash_free(edgesgh, freeGHash, NULL); BLI_ghash_free(sld->vhash, NULL, (GHashValFreeFP)MEM_freeN); BLI_linklist_free(sld->vertlist, NULL); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 5609b7068b3..01404603b86 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -102,20 +102,19 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list); /* ************************** Functions *************************** */ -static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail) { - TransData pivot = *head; +static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, TransData *temp) { TransData *ihead = head; TransData *itail = tail; - short connected = t->flag & T_PROP_CONNECTED; + *temp = *head; while (head < tail) { - if (connected) { - while ((tail->dist >= pivot.dist) && (head < tail)) + if (t->flag & T_PROP_CONNECTED) { + while ((tail->dist >= temp->dist) && (head < tail)) tail--; } else { - while ((tail->rdist >= pivot.rdist) && (head < tail)) + while ((tail->rdist >= temp->rdist) && (head < tail)) tail--; } @@ -125,12 +124,12 @@ static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail) { head++; } - if (connected) { - while ((head->dist <= pivot.dist) && (head < tail)) + if (t->flag & T_PROP_CONNECTED) { + while ((head->dist <= temp->dist) && (head < tail)) head++; } else { - while ((head->rdist <= pivot.rdist) && (head < tail)) + while ((head->rdist <= temp->rdist) && (head < tail)) head++; } @@ -141,16 +140,17 @@ static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail) { } } - *head = pivot; + *head = *temp; if (ihead < head) { - qsort_trans_data(t, ihead, head-1); + qsort_trans_data(t, ihead, head-1, temp); } if (itail > head) { - qsort_trans_data(t, head+1, itail); + qsort_trans_data(t, head+1, itail, temp); } } void sort_trans_data_dist(TransInfo *t) { + TransData temp; TransData *start = t->data; int i = 1; @@ -158,7 +158,7 @@ void sort_trans_data_dist(TransInfo *t) { start++; i++; } - qsort_trans_data(t, start, t->data + t->total - 1); + qsort_trans_data(t, start, t->data + t->total - 1, &temp); } static void sort_trans_data(TransInfo *t) @@ -3389,17 +3389,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */ for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { - if (sipo->around == V3D_LOCAL && !ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE)) { - /* for local-pivot we only need to count the number of selected handles only, so that centerpoints don't - * don't get moved wrong - */ - if (bezt->ipo == BEZT_IPO_BEZ) { - if (bezt->f1 & SELECT) count++; - if (bezt->f3 & SELECT) count++; - } - else if (bezt->f2 & SELECT) count++; // TODO: could this cause problems? - } - else if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) { + if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) { /* for 'normal' pivots - just include anything that is selected. this works a bit differently in translation modes */ if (bezt->f2 & SELECT) count++; @@ -3408,6 +3398,17 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) if (bezt->f3 & SELECT) count++; } } + else if (sipo->around == V3D_LOCAL) { + /* for local-pivot we only need to count the number of selected handles only, so that centerpoints don't + * don't get moved wrong + */ + if (bezt->ipo == BEZT_IPO_BEZ) { + if (bezt->f1 & SELECT) count++; + if (bezt->f3 & SELECT) count++; + } + /* else if (bezt->f2 & SELECT) count++; // TODO: could this cause problems? */ + /* - yes this causes problems, because no td is created for the center point */ + } else { /* for 'normal' pivots - just include anything that is selected */ if (bezt->f1 & SELECT) count++; @@ -3501,34 +3502,32 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } /* only include main vert if selected */ - if (bezt->f2 & SELECT) { + if (bezt->f2 & SELECT && (sipo->around != V3D_LOCAL || ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE))) { + /* move handles relative to center */ if (ELEM3(t->mode, TFM_TRANSLATION, TFM_TIME_TRANSLATE, TFM_TIME_SLIDE)) { if (bezt->f1 & SELECT) td->flag |= TD_MOVEHANDLE1; if (bezt->f3 & SELECT) td->flag |= TD_MOVEHANDLE2; } - /* if scaling around individuals centers, do not include keyframes */ - if (sipo->around != V3D_LOCAL) { - /* if handles were not selected, store their selection status */ - if (!(bezt->f1 & SELECT) && !(bezt->f3 & SELECT)) { - if (hdata == NULL) - hdata = initTransDataCurveHandles(td, bezt); - } - - bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals, mtx, smtx); + /* if handles were not selected, store their selection status */ + if (!(bezt->f1 & SELECT) && !(bezt->f3 & SELECT)) { + if (hdata == NULL) + hdata = initTransDataCurveHandles(td, bezt); } + + bezt_to_transdata(td++, td2d++, adt, bezt, 1, 1, 0, intvals, mtx, smtx); - /* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...): - * - Check if we've got entire BezTriple selected and we're scaling/rotating that point, - * then check if we're using auto-handles. - * - If so, change them auto-handles to aligned handles so that handles get affected too - */ - if ((bezt->h1 == HD_AUTO) && (bezt->h2 == HD_AUTO) && ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { - if (h1 && h2) { - bezt->h1= HD_ALIGN; - bezt->h2= HD_ALIGN; - } + } + /* special hack (must be done after initTransDataCurveHandles(), as that stores handle settings to restore...): + * - Check if we've got entire BezTriple selected and we're scaling/rotating that point, + * then check if we're using auto-handles. + * - If so, change them auto-handles to aligned handles so that handles get affected too + */ + if ((bezt->h1 == HD_AUTO) && (bezt->h2 == HD_AUTO) && ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { + if (hdata && (bezt->f1 & SELECT) && (bezt->f3 & SELECT)) { + bezt->h1= HD_ALIGN; + bezt->h2= HD_ALIGN; } } } @@ -3682,6 +3681,11 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv if (bezm->bezt->f2 & SELECT) { if (td->loc2d == bezm->bezt->vec[1]) { td->loc2d= (bezts + bezm->newIndex)->vec[1]; + + /* if only control point is selected, the handle pointers need to be updated as well */ + td->h1= (bezts + bezm->newIndex)->vec[0]; + td->h2= (bezts + bezm->newIndex)->vec[2]; + adjusted[j] = 1; } } @@ -4916,8 +4920,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t) BLI_freelistN(&anim_data); } - /* make sure all F-Curves are set correctly */ - ANIM_editkeyframes_refresh(&ac); + /* Make sure all F-Curves are set correctly, but not if transform was + * canceled, since then curves were already restored to initial state. + * Note: if the refresh is really needed after cancel then some way + * has to be added to not update handle types (see bug 22289). + */ + if(!cancelled) + ANIM_editkeyframes_refresh(&ac); } else if (t->spacetype == SPACE_NLA) { bAnimContext ac; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 15e2d32cc94..036ef410963 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -306,7 +306,7 @@ static void animrecord_check_state (Scene *scene, ID *id, wmTimer *animtimer) static int fcu_test_selected(FCurve *fcu) { BezTriple *bezt= fcu->bezt; - int i; + unsigned int i; if (bezt==NULL) /* ignore baked */ return 0; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 396cb15e61a..51698c27b37 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -562,17 +562,12 @@ void test_manipulator_axis(const bContext *C) static float screen_aligned(RegionView3D *rv3d, float mat[][4]) { - float vec[3], size; - - VECCOPY(vec, mat[0]); - size= normalize_v3(vec); - glTranslatef(mat[3][0], mat[3][1], mat[3][2]); /* sets view screen aligned */ glRotatef( -360.0f*saacos(rv3d->viewquat[0])/(float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]); - return size; + return len_v3(mat[0]); /* draw scale */ } diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index b4b2fd12cef..be700b17b7a 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -22,13 +22,13 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc ) BLENDERLIB(bf_editor_util "${SRC}" "${INC}") diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index 297863b2a9f..36cd1274ec7 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -22,14 +22,14 @@ FILE(GLOB SRC *.c) SET(INC + ../include ../../blenkernel ../../blenlib - ../include - ../../../../intern/guardedalloc - ../../../../intern/opennl/extern ../../makesdna ../../makesrna ../../windowmanager + ../../../../intern/guardedalloc + ../../../../intern/opennl/extern ) BLENDERLIB(bf_editor_uvedit "${SRC}" "${INC}") diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 126cddf852f..5de7b0c5281 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -26,9 +26,18 @@ FILE(GLOB SRC intern/*.c) -SET(INC - . ../blenlib ../blenkernel ../makesdna ../makesrna ../include - ../../../extern/glew/include ../../../intern/guardedalloc ../../../intern/smoke/extern ../imbuf) +SET(INC + . + ../blenlib + ../blenkernel + ../include + ../imbuf + ../makesdna + ../makesrna + ../../../extern/glew/include + ../../../intern/guardedalloc + ../../../intern/smoke/extern +) IF(WIN32) INCLUDE_DIRECTORIES(${PTHREADS_INC}) diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index c0023d49c95..699ed6e1b00 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -29,12 +29,12 @@ FILE(GLOB SRC intern/*.c) SET(INC . - ../makesdna - ../../../intern/guardedalloc - ../../../intern/memutil - ../blenlib ../avi + ../blenlib ../blenkernel + ../makesdna + ../../../intern/memutil + ../../../intern/guardedalloc ${JPEG_INC} ${PNG_INC} ${ZLIB_INC} diff --git a/source/blender/imbuf/intern/cineon/CMakeLists.txt b/source/blender/imbuf/intern/cineon/CMakeLists.txt index cd887b6fc4e..5633d2a66f6 100644 --- a/source/blender/imbuf/intern/cineon/CMakeLists.txt +++ b/source/blender/imbuf/intern/cineon/CMakeLists.txt @@ -28,13 +28,13 @@ FILE(GLOB SRC *.c) SET(INC . - ../../../blenkernel - ../../ .. - ../../../blenlib + ../../ intern/include - ../../../../../intern/guardedalloc + ../../../blenkernel + ../../../blenlib ../../../makesdna + ../../../../../intern/guardedalloc ) BLENDERLIB(bf_cineon "${SRC}" "${INC}") diff --git a/source/blender/imbuf/intern/dds/CMakeLists.txt b/source/blender/imbuf/intern/dds/CMakeLists.txt index 376dd3d61f4..620d4041703 100644 --- a/source/blender/imbuf/intern/dds/CMakeLists.txt +++ b/source/blender/imbuf/intern/dds/CMakeLists.txt @@ -28,12 +28,12 @@ FILE (GLOB SRC *.cpp) SET(INC . + .. + ./intern/include + ../../ + ../../../blenlib ../../../blenkernel ../../../makesdna - ../../ - .. - ../../../blenlib - intern/include ../../../../../intern/guardedalloc ) diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 8537b703c69..50579660806 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -141,7 +141,7 @@ typedef struct Nurb { typedef struct CharInfo { short kern; - short mat_nr; + short mat_nr; /* index start at 1, unlike mesh & nurbs */ char flag; char pad; short pad2; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index bf64bc27b48..ce038ee4a95 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -163,6 +163,8 @@ typedef struct FileSelectParams { char renamefile[80]; char renameedit[80]; /* annoying but the first is only used for initialization */ + char filter_glob[64]; /* list of filetypes to filter */ + short type; /* XXXXX for now store type here, should be moved to the operator */ short flag; /* settings for filter, hiding dots files,... */ short sort; /* sort order */ @@ -725,6 +727,7 @@ enum FileSortTypeE { #define FOLDERFILE (1<<11) /* represents folders for filtering */ #define BTXFILE (1<<12) #define COLLADAFILE (1<<13) +#define OPERATORFILE (1<<14) /* from filter_glob operator property */ /* SpaceImage->dt_uv */ #define SI_UVDT_OUTLINE 0 diff --git a/source/blender/makesdna/DNA_vfont_types.h b/source/blender/makesdna/DNA_vfont_types.h index 8a96d8574c2..0ea60c732cf 100644 --- a/source/blender/makesdna/DNA_vfont_types.h +++ b/source/blender/makesdna/DNA_vfont_types.h @@ -46,7 +46,7 @@ typedef struct VFont { } VFont; /* *************** FONT ****************** */ - +#define FO_EDIT 0 #define FO_CURS 1 #define FO_CURSUP 2 #define FO_CURSDOWN 3 diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index 0eb42373d6d..d42289e17c4 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -28,7 +28,15 @@ INCLUDE_DIRECTORIES(../../../../intern/guardedalloc ..) FILE(GLOB INC_FILES ../*.h) # Build makesdna executable -SET(SRC makesdna.c ../../../../intern/guardedalloc/intern/mallocn.c ../../../../intern/guardedalloc/intern/mmap_win.c) +SET(SRC + makesdna.c + ../../../../intern/guardedalloc/intern/mallocn.c +) + +IF(WIN32) + LIST(APPEND SRC ../../../../intern/guardedalloc/intern/mmap_win.c) +ENDIF(WIN32) + ADD_EXECUTABLE(makesdna ${SRC} ${INC_FILES}) # Output dna.c diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 31cd0b3c326..ecc307ed68b 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -423,7 +423,11 @@ int preprocess_include(char *maindata, int len) int a, newlen, comment = 0; char *cp, *temp, *md; - temp= MEM_mallocN(len, "preprocess_include"); + /* note: len + 1, last character is a dummy to prevent + * comparisons using uninitialized memory */ + temp= MEM_mallocN(len + 1, "preprocess_include"); + temp[len]= ' '; + memcpy(temp, maindata, len); // remove all c++ comments @@ -1056,6 +1060,7 @@ int make_structDNA(char *baseDirectory, FILE *file) MEM_freeN(names); MEM_freeN(types); MEM_freeN(typelens); + MEM_freeN(alphalens); MEM_freeN(structs); if (debugSDNA > -1) printf("done.\n"); diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index def1be1b17a..46ca4d9fca8 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -395,7 +395,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr { char *func; - if(prop->flag & PROP_IDPROPERTY) + if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL) return NULL; if(!manualfunc) { @@ -576,7 +576,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr if(!(prop->flag & PROP_EDITABLE)) return NULL; - if(prop->flag & PROP_IDPROPERTY) + if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL) return NULL; if(!manualfunc) { @@ -744,7 +744,7 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA { char *func= NULL; - if(prop->flag & PROP_IDPROPERTY) + if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL) return NULL; if(prop->type == PROP_STRING) { @@ -802,7 +802,7 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA * { char *func, *getfunc; - if(prop->flag & PROP_IDPROPERTY) + if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL) return NULL; if(!manualfunc) { @@ -860,7 +860,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property { char *func; - if(prop->flag & PROP_IDPROPERTY) + if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL) return NULL; if(!manualfunc) { @@ -952,7 +952,7 @@ static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *p { char *func, *getfunc; - if(prop->flag & PROP_IDPROPERTY) + if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL) return NULL; if(!manualfunc) @@ -978,7 +978,7 @@ static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *pr { char *func; - if(prop->flag & PROP_IDPROPERTY) + if(prop->flag & PROP_IDPROPERTY && manualfunc==NULL) return NULL; func= rna_alloc_function_name(srna->identifier, prop->identifier, "end"); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 981602fb2c9..8681067061a 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -255,6 +255,18 @@ void rna_ID_user_clear(ID *id) id->flag &= ~LIB_FAKEUSER; } +static void rna_IDPArray_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + IDProperty *prop= (IDProperty *)ptr->data; + rna_iterator_array_begin(iter, IDP_IDPArray(prop), sizeof(IDProperty), prop->len, 0, NULL); +} + +static int rna_IDPArray_length(PointerRNA *ptr) +{ + IDProperty *prop= (IDProperty *)ptr->data; + return prop->len; +} + #else static void rna_def_ID_properties(BlenderRNA *brna) @@ -305,6 +317,11 @@ static void rna_def_ID_properties(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); RNA_def_property_struct_type(prop, "IDPropertyGroup"); + prop= RNA_def_property(srna, "idp_array", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "IDPropertyGroup"); + RNA_def_property_collection_funcs(prop, "rna_IDPArray_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_IDPArray_length", 0, 0); + RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY); + // never tested, maybe its useful to have this? #if 0 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 9c4ab59d827..6cb5858648a 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -364,7 +364,8 @@ static PropertyRNA *typemap[IDP_NUMTYPES] = (PropertyRNA*)&rna_IDProperty_float, NULL, NULL, NULL, (PropertyRNA*)&rna_IDProperty_group, NULL, - (PropertyRNA*)&rna_IDProperty_double}; + (PropertyRNA*)&rna_IDProperty_double, + (PropertyRNA*)&rna_IDProperty_idp_array}; static PropertyRNA *arraytypemap[IDP_NUMTYPES] = {NULL, (PropertyRNA*)&rna_IDProperty_int_array, @@ -2066,7 +2067,7 @@ void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, Collectio void RNA_property_collection_next(CollectionPropertyIterator *iter) { - CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop; + CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)rna_ensure_property(iter->prop); if(iter->idprop) { rna_iterator_array_next(iter); @@ -2080,7 +2081,7 @@ void RNA_property_collection_next(CollectionPropertyIterator *iter) void RNA_property_collection_end(CollectionPropertyIterator *iter) { - CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)iter->prop; + CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)rna_ensure_property(iter->prop); if(iter->idprop) rna_iterator_array_end(iter); @@ -2272,7 +2273,7 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, Poi int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr) { - CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)rna_ensure_property(prop); if(cprop->lookupint) { /* we have a callback defined, use it */ @@ -2302,7 +2303,7 @@ int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int k int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr) { - CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)rna_ensure_property(prop); if(cprop->lookupstring) { /* we have a callback defined, use it */ @@ -2863,6 +2864,7 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int { const char *p; char *buf; + char quote= '\0'; int i, j, len, escape; len= 0; @@ -2874,9 +2876,30 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int p= *path; - escape= 0; - while(*p && (*p != ']' || escape)) { - escape= (*p == '\\'); + /* 2 kinds of lookups now, quoted or unquoted */ + quote= *p; + + if(quote != '\'' && quote != '"') + quote= 0; + + if(quote==0) { + while(*p && (*p != ']')) { + len++; + p++; + } + } + else { + escape= 0; + /* skip the first quote */ + len++; + p++; + while(*p && (*p != quote || escape)) { + escape= (*p == '\\'); + len++; + p++; + } + + /* skip the last quoted char to get the ']' */ len++; p++; } @@ -2906,7 +2929,7 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int /* copy string, taking into account escaped ] */ if(bracket) { for(p=*path, i=0, j=0; ir.cfra, 0); } + +char *rna_ImageUser_path(PointerRNA *ptr) +{ + if (ptr->id.data) { + // ImageUser *iuser= ptr->data; + + switch(GS(((ID *)ptr->id.data)->name)) { + case ID_TE: + return BLI_strdup("image_user"); + } + } + + return BLI_strdup(""); +} + static EnumPropertyItem *rna_Image_source_itemf(bContext *C, PointerRNA *ptr, int *free) { Image *ima= (Image*)ptr->data; @@ -222,6 +237,7 @@ static void rna_def_imageuser(BlenderRNA *brna) srna= RNA_def_struct(brna, "ImageUser", NULL); RNA_def_struct_ui_text(srna, "Image User", "Parameters defining how an Image datablock is used by another datablock"); + RNA_def_struct_path_func(srna, "rna_ImageUser_path"); prop= RNA_def_property(srna, "use_auto_refresh", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 76ee24a5608..9845526f023 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -287,6 +287,7 @@ extern FloatPropertyRNA rna_IDProperty_float; extern FloatPropertyRNA rna_IDProperty_float_array; extern PointerPropertyRNA rna_IDProperty_group; extern CollectionPropertyRNA rna_IDProperty_collection; +extern CollectionPropertyRNA rna_IDProperty_idp_array; extern FloatPropertyRNA rna_IDProperty_double; extern FloatPropertyRNA rna_IDProperty_double_array; diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 40ff5efafc1..bb35673e388 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -176,22 +176,13 @@ Object *rna_Main_objects_new(Main *bmain, ReportList *reports, char* name, ID *d void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) { - /* - NOTE: the following example shows when this function should _not_ be called - - ob = bpy.data.add_object() - scene.add_object(ob) - - # ob is freed here - scene.remove_object(ob) - - # don't do this since ob is already freed! - bpy.data.remove_object(ob) - */ - if(ID_REAL_USERS(object) <= 0) + if(ID_REAL_USERS(object) <= 0) { + unlink_object(NULL, object); /* needed or ID pointers to this are not cleared */ free_libblock(&bmain->object, object); - else + } + else { BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, ID_REAL_USERS(object)); + } } struct Material *rna_Main_materials_new(Main *bmain, char* name) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 5024c8d2c2e..e83a17cc277 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1306,7 +1306,7 @@ static void rna_def_modifier_displace(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "texmapping"); RNA_def_property_enum_items(prop, prop_texture_coordinates_items); RNA_def_property_ui_text(prop, "Texture Coordinates", ""); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); + RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvlayer_name"); @@ -2280,6 +2280,7 @@ void RNA_def_modifier(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Render); RNA_def_property_ui_text(prop, "Render", "Use modifier during rendering"); RNA_def_property_ui_icon(prop, ICON_SCENE, 0); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); prop= RNA_def_property(srna, "show_in_editmode", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Editmode); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 20e74ca5a72..36385759c5a 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -871,13 +871,13 @@ static void def_cmp_blur(StructRNA *srna) prop = RNA_def_property(srna, "size_x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "sizex"); - RNA_def_property_range(prop, 0, 256); + RNA_def_property_range(prop, 0, 2048); RNA_def_property_ui_text(prop, "Size X", ""); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "size_y", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "sizey"); - RNA_def_property_range(prop, 0, 256); + RNA_def_property_range(prop, 0, 2048); RNA_def_property_ui_text(prop, "Size Y", ""); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index d354e152fce..3f07d953e0b 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -216,6 +216,7 @@ static void rna_Object_dependency_update(Main *bmain, Scene *scene, PointerRNA * { DAG_id_flush_update(ptr->id.data, OB_RECALC_OB); DAG_scene_sort(bmain, scene); + WM_main_add_notifier(NC_OBJECT|ND_PARENT, ptr->id.data); } /* when changing the selection flag the scene needs updating */ @@ -1483,6 +1484,7 @@ static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_int_funcs(prop, "rna_Object_active_particle_system_index_get", "rna_Object_active_particle_system_index_set", "rna_Object_active_particle_system_index_range"); RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_particle_update"); @@ -1518,6 +1520,7 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_update(prop, NC_GEOM|ND_DATA, "rna_Object_internal_update_data"); prop= RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_int_sdna(prop, NULL, "actdef"); RNA_def_property_int_funcs(prop, "rna_Object_active_vertex_group_index_get", "rna_Object_active_vertex_group_index_set", "rna_Object_active_vertex_group_index_range"); RNA_def_property_ui_text(prop, "Active Vertex Group Index", "Active index in vertex group array"); @@ -1740,6 +1743,7 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "actcol"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_int_funcs(prop, "rna_Object_active_material_index_get", "rna_Object_active_material_index_set", "rna_Object_active_material_index_range"); RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); diff --git a/source/blender/makesrna/intern/rna_pose_api.c b/source/blender/makesrna/intern/rna_pose_api.c index 48e8a1e6940..4560fa426f1 100644 --- a/source/blender/makesrna/intern/rna_pose_api.c +++ b/source/blender/makesrna/intern/rna_pose_api.c @@ -64,7 +64,7 @@ void RNA_api_pose_channel(StructRNA *srna) PropertyRNA *parm; FunctionRNA *func; - func= RNA_def_function(srna, "envelope", "rna_PoseBone_do_envelope"); + func= RNA_def_function(srna, "evaluate_envelope", "rna_PoseBone_do_envelope"); RNA_def_function_ui_description(func, "Calculate bone envelope at given point."); parm= RNA_def_float_vector_xyz(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "Position in 3d space to evaluate", -FLT_MAX, FLT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 97cb2b9f3da..db8ae1b4f6a 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -942,22 +942,12 @@ static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *m MEM_freeN(marker); } -static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, - char name[], int absolute, int insertkey_needed, int insertkey_visual) +static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, char name[]) { KeyingSet *ks= NULL; - short flag=0, keyingflag=0; - - /* validate flags */ - if (absolute) - flag |= KEYINGSET_ABSOLUTE; - if (insertkey_needed) - keyingflag |= INSERTKEY_NEEDED; - if (insertkey_visual) - keyingflag |= INSERTKEY_MATRIX; - + /* call the API func, and set the active keyingset index */ - ks= BKE_keyingset_add(&sce->keyingsets, name, flag, keyingflag); + ks= BKE_keyingset_add(&sce->keyingsets, name, KEYINGSET_ABSOLUTE, 0); if (ks) { sce->active_keyingset= BLI_countlist(&sce->keyingsets); @@ -2689,6 +2679,22 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "FPS Base", "Framerate base"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + /* frame mapping */ + prop= RNA_def_property(srna, "frame_map_old", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "framapto"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_range(prop, 1, 900); + RNA_def_property_ui_text(prop, "Frame Map Old", "Specify old mapping value in frames"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "frame_map_new", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "images"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_range(prop, 1, 900); + RNA_def_property_ui_text(prop, "Frame Map New", "Specify how many frames the Map Old will last"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "dither_intensity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dither_intensity"); RNA_def_property_range(prop, 0.0f, 2.0f); @@ -3299,17 +3305,13 @@ static void rna_def_scene_keying_sets(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "new", "rna_Scene_keying_set_new"); RNA_def_function_ui_description(func, "Add a new Keying Set to Scene."); RNA_def_function_flag(func, FUNC_USE_REPORTS); + /* name */ + RNA_def_string(func, "name", "KeyingSet", 64, "Name", "Name of Keying Set"); + /* returns the new KeyingSet */ parm= RNA_def_pointer(func, "keyingset", "KeyingSet", "", "Newly created Keying Set."); RNA_def_function_return(func, parm); - /* name */ - RNA_def_string(func, "name", "KeyingSet", 64, "Name", "Name of Keying Set"); - /* flags */ - RNA_def_boolean(func, "absolute", 1, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)"); - /* keying flags */ - RNA_def_boolean(func, "insertkey_needed", 0, "Insert Keyframes - Only Needed", "Only insert keyframes where they're needed in the relevant F-Curves."); - RNA_def_boolean(func, "insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'."); - + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "KeyingSet"); RNA_def_property_flag(prop, PROP_EDITABLE); @@ -3513,7 +3515,8 @@ void RNA_def_scene(BlenderRNA *brna) /* Nodes (Compositing) */ - prop= RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); RNA_def_property_ui_text(prop, "Node Tree", "Compositing node tree"); prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 780cc31edea..eeb45aec538 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1218,7 +1218,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4); RNA_def_property_update(prop, NC_WINDOW, NULL); - prop= RNA_def_property(srna, "view_rotate_method", PROP_FLOAT, PROP_QUATERNION); + prop= RNA_def_property(srna, "view_rotation", PROP_FLOAT, PROP_QUATERNION); RNA_def_property_float_sdna(prop, NULL, "viewquat"); RNA_def_property_ui_text(prop, "View Rotation", "Rotation in quaternions (keep normalized)"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); @@ -2126,6 +2126,11 @@ static void rna_def_fileselect_params(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Filter Folder", "Show folders"); RNA_def_property_ui_icon(prop, ICON_FILE_FOLDER, 0); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + + prop= RNA_def_property(srna, "filter_glob", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "filter_glob"); + RNA_def_property_ui_text(prop, "Extension Filter", ""); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_FILE_LIST, NULL); } @@ -2141,6 +2146,10 @@ static void rna_def_space_filebrowser(BlenderRNA *brna) prop= RNA_def_property(srna, "params", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "params"); RNA_def_property_ui_text(prop, "Filebrowser Parameter", "Parameters and Settings for the Filebrowser"); + + prop= RNA_def_property(srna, "operator", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "op"); + RNA_def_property_ui_text(prop, "Operator", ""); } static void rna_def_space_info(BlenderRNA *brna) @@ -2209,7 +2218,8 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "ID From", "Datablock from which the edited datablock is linked"); - prop= RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Node Tree", "Node tree being displayed and edited"); diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 29ace805543..efe57410441 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -134,7 +134,7 @@ static void updateDepgraph( { DisplaceModifierData *dmd = (DisplaceModifierData*) md; - if(dmd->map_object) { + if(dmd->map_object && dmd->texmapping == MOD_DISP_MAP_OBJECT) { DagNode *curNode = dag_get_node(forest, dmd->map_object); dag_add_relation(forest, curNode, obNode, diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index a6d99ad72ae..ee608c7cf31 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -442,11 +442,11 @@ static DerivedMesh *applyModifier(ModifierData *md, j= 2; } - for(; j>=0; j--) { + do { vidx = *(&mf->v1 + j); vert_accum[vidx] += face_angles[j]; vert_angles[vidx]+= shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * face_angles[j]; - } + } while(j--); } /* vertex group support */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c index 7d64d4e719c..aa7fac81c2c 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c @@ -83,7 +83,7 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float p_dy = vec[1] * ys; /* if no displacement, then just copy this pixel */ - if (p_dx < DISPLACE_EPSILON && p_dy < DISPLACE_EPSILON) { + if (fabsf(p_dx) < DISPLACE_EPSILON && fabsf(p_dy) < DISPLACE_EPSILON) { qd_getPixel(cbuf, x-cbuf->xof, y-cbuf->yof, col); qd_setPixel(stackbuf, x, y, col); continue; @@ -99,10 +99,13 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float qd_getPixel(vecbuf, x-vecbuf->xof, y-vecbuf->yof+1, vecdy); d_dx = vecdx[0] * xs; d_dy = vecdy[0] * ys; - + /* clamp derivatives to minimum displacement distance in UV space */ - dxt = MAX2(p_dx - d_dx, DISPLACE_EPSILON)/(float)stackbuf->x; - dyt = MAX2(p_dy - d_dy, DISPLACE_EPSILON)/(float)stackbuf->y; + dxt = p_dx - d_dx; + dyt = p_dy - d_dy; + + dxt = signf(dxt)*maxf(fabsf(dxt), DISPLACE_EPSILON)/(float)stackbuf->x; + dyt = signf(dyt)*maxf(fabsf(dyt), DISPLACE_EPSILON)/(float)stackbuf->y; ibuf_sample(ibuf, u, v, dxt, dyt, col); qd_setPixel(stackbuf, x, y, col); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_image.c b/source/blender/nodes/intern/CMP_nodes/CMP_image.c index 0bbf9c9bf85..9309d2939db 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_image.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_image.c @@ -62,38 +62,56 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i ImBuf *ibuf; CompBuf *stackbuf; int type; - - ibuf= BKE_image_get_ibuf(ima, iuser); - if(ibuf==NULL) - return NULL; - if (!(rd->color_mgt_flag & R_COLOR_MANAGEMENT)) { - int profile = IB_PROFILE_NONE; - - /* temporarily set profile to none to not disturb actual */ - SWAP(int, ibuf->profile, profile); - - if (ibuf->rect_float != NULL) { - imb_freerectfloatImBuf(ibuf); - } - IMB_float_from_rect(ibuf); - - SWAP(int, ibuf->profile, profile); + float *rect; + int alloc= FALSE; + + ibuf= BKE_image_get_ibuf(ima, iuser); + if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) { + return NULL; } - + if (ibuf->rect_float == NULL) { IMB_float_from_rect(ibuf); } + /* now we need a float buffer from the image + * with matching color management */ + if(rd->color_mgt_flag & R_COLOR_MANAGEMENT) { + if(ibuf->profile != IB_PROFILE_NONE) { + rect= ibuf->rect_float; + } + else { + rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); + srgb_to_linearrgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y); + alloc= TRUE; + } + } + else { + if(ibuf->profile == IB_PROFILE_NONE) { + rect= ibuf->rect_float; + } + else { + rect= MEM_mapallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, "node_composit_get_image"); + linearrgb_to_srgb_rgba_rgba_buf(rect, ibuf->rect_float, ibuf->x * ibuf->y); + alloc= TRUE; + } + } + /* done coercing into the correct color management */ + + type= ibuf->channels; if(rd->scemode & R_COMP_CROP) { - stackbuf= get_cropped_compbuf(&rd->disprect, ibuf->rect_float, ibuf->x, ibuf->y, type); + stackbuf= get_cropped_compbuf(&rd->disprect, rect, ibuf->x, ibuf->y, type); + if(alloc) + MEM_freeN(rect); } else { /* we put imbuf copy on stack, cbuf knows rect is from other ibuf when freed! */ - stackbuf= alloc_compbuf(ibuf->x, ibuf->y, type, 0); - stackbuf->rect= ibuf->rect_float; + stackbuf= alloc_compbuf(ibuf->x, ibuf->y, type, FALSE); + stackbuf->rect= rect; + stackbuf->malloc= alloc; } /*code to respect the premul flag of images; I'm diff --git a/source/blender/python/doc/sphinx_doc_gen.py b/source/blender/python/doc/sphinx_doc_gen.py index 1cd73445233..0ced9da2d70 100644 --- a/source/blender/python/doc/sphinx_doc_gen.py +++ b/source/blender/python/doc/sphinx_doc_gen.py @@ -522,7 +522,7 @@ def rna2sphinx(BASEPATH): type_descr = prop.get_type_description(**kwargs) if prop.name or prop.description: - fw(ident + ":%s%s: %s\n" % (id_name, identifier, ", ".join([val for val in (prop.name, prop.description) if val]))) + fw(ident + ":%s%s: %s\n" % (id_name, identifier, ", ".join(val for val in (prop.name, prop.description) if val))) fw(ident + ":%s%s: %s\n" % (id_type, identifier, type_descr)) def write_struct(struct): @@ -564,12 +564,12 @@ def rna2sphinx(BASEPATH): else: fw("base class --- ") - fw(", ".join([(":class:`%s`" % base_id) for base_id in base_ids])) + fw(", ".join((":class:`%s`" % base_id) for base_id in base_ids)) fw("\n\n") subclass_ids = [s.identifier for s in structs.values() if s.base is struct if not rna_info.rna_id_ignore(s.identifier)] if subclass_ids: - fw("subclasses --- \n" + ", ".join([(":class:`%s`" % s) for s in subclass_ids]) + "\n\n") + fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in subclass_ids) + "\n\n") base_id = getattr(struct.base, "identifier", "") @@ -607,7 +607,7 @@ def rna2sphinx(BASEPATH): del py_properties, py_prop for func in struct.functions: - args_str = ", ".join([prop.get_arg_default(force=False) for prop in func.args]) + args_str = ", ".join(prop.get_arg_default(force=False) for prop in func.args) fw(" .. %s:: %s(%s)\n\n" % ("classmethod" if func.is_classmethod else "method", func.identifier, args_str)) fw(" %s\n\n" % func.description) @@ -618,7 +618,7 @@ def rna2sphinx(BASEPATH): if len(func.return_values) == 1: write_param(" ", fw, func.return_values[0], is_return=True) elif func.return_values: # multiple return values - fw(" :return (%s):\n" % ", ".join([prop.identifier for prop in func.return_values])) + fw(" :return (%s):\n" % ", ".join(prop.identifier for prop in func.return_values)) for prop in func.return_values: type_descr = prop.get_type_description(as_ret=True, class_fmt=":class:`%s`") descr = prop.description @@ -736,7 +736,7 @@ def rna2sphinx(BASEPATH): subclass_ids = [s.identifier for s in structs.values() if s.base is None if not rna_info.rna_id_ignore(s.identifier)] if subclass_ids: - fw("subclasses --- \n" + ", ".join([(":class:`%s`" % s) for s in sorted(subclass_ids)]) + "\n\n") + fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in sorted(subclass_ids)) + "\n\n") fw(".. class:: %s\n\n" % _BPY_STRUCT_FAKE) fw(" built-in base class for all classes in bpy.types.\n\n") @@ -774,7 +774,7 @@ def rna2sphinx(BASEPATH): fw(".. module:: bpy.ops.%s\n\n" % op.module_name) last_mod = op.module_name - args_str = ", ".join([prop.get_arg_default(force=True) for prop in op.args]) + args_str = ", ".join(prop.get_arg_default(force=True) for prop in op.args) fw(".. function:: %s(%s)\n\n" % (op.func_name, args_str)) # if the description isn't valid, we output the standard warning diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 5dfae400d9b..11f8ff49ffe 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -357,26 +357,3 @@ void bpy_text_clear_modules(int clear_all) Py_DECREF(list); /* removes all references from append */ } #endif - - -/***************************************************************************** -* Description: This function creates a new Python dictionary object. -* note: dict is owned by sys.modules["__main__"] module, reference is borrowed -* note: important we use the dict from __main__, this is what python expects - for 'pickle' to work as well as strings like this... - >> foo = 10 - >> print(__import__("__main__").foo) -*****************************************************************************/ -PyObject *bpy_namespace_dict_new(const char *filename) -{ - PyInterpreterState *interp= PyThreadState_GET()->interp; - PyObject *mod_main= PyModule_New("__main__"); - PyDict_SetItemString(interp->modules, "__main__", mod_main); - Py_DECREF(mod_main); /* sys.modules owns now */ - PyModule_AddStringConstant(mod_main, "__name__", "__main__"); - if(filename) - PyModule_AddStringConstant(mod_main, "__file__", filename); /* __file__ only for nice UI'ness */ - PyModule_AddObject(mod_main, "__builtins__", interp->builtins); - Py_INCREF(interp->builtins); /* AddObject steals a reference */ - return PyModule_GetDict(mod_main); -} diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h index 83e05fd6ded..09e1fa629d3 100644 --- a/source/blender/python/generic/bpy_internal_import.h +++ b/source/blender/python/generic/bpy_internal_import.h @@ -60,7 +60,4 @@ extern PyMethodDef bpy_reload_meth[]; struct Main *bpy_import_main_get(void); void bpy_import_main_set(struct Main *maggie); -/* name namespace function for bpy & bge */ -PyObject *bpy_namespace_dict_new(const char *filename); - #endif /* EXPP_bpy_import_h */ diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index ad109528a8c..d59624b54ab 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -269,3 +269,170 @@ PyObject *PyC_UnicodeFromByte(const char *str) return result; } } + +/***************************************************************************** +* Description: This function creates a new Python dictionary object. +* note: dict is owned by sys.modules["__main__"] module, reference is borrowed +* note: important we use the dict from __main__, this is what python expects + for 'pickle' to work as well as strings like this... + >> foo = 10 + >> print(__import__("__main__").foo) +*****************************************************************************/ +PyObject *PyC_DefaultNameSpace(const char *filename) +{ + PyInterpreterState *interp= PyThreadState_GET()->interp; + PyObject *mod_main= PyModule_New("__main__"); + PyDict_SetItemString(interp->modules, "__main__", mod_main); + Py_DECREF(mod_main); /* sys.modules owns now */ + PyModule_AddStringConstant(mod_main, "__name__", "__main__"); + if(filename) + PyModule_AddStringConstant(mod_main, "__file__", filename); /* __file__ only for nice UI'ness */ + PyModule_AddObject(mod_main, "__builtins__", interp->builtins); + Py_INCREF(interp->builtins); /* AddObject steals a reference */ + return PyModule_GetDict(mod_main); +} + + +/* Would be nice if python had this built in */ +void PyC_RunQuicky(const char *filepath, int n, ...) +{ + FILE *fp= fopen(filepath, "r"); + + if(fp) { + PyGILState_STATE gilstate= PyGILState_Ensure(); + + va_list vargs; + + int *sizes= PyMem_MALLOC(sizeof(int) * (n / 2)); + int i; + + PyObject *py_dict = PyC_DefaultNameSpace(filepath); + PyObject *values= PyList_New(n / 2); /* namespace owns this, dont free */ + + PyObject *py_result, *ret; + + PyObject *struct_mod= PyImport_ImportModule("struct"); + PyObject *calcsize= PyObject_GetAttrString(struct_mod, "calcsize"); /* struct.calcsize */ + PyObject *pack= PyObject_GetAttrString(struct_mod, "pack"); /* struct.pack */ + PyObject *unpack= PyObject_GetAttrString(struct_mod, "unpack"); /* struct.unpack */ + + Py_DECREF(struct_mod); + + va_start(vargs, n); + for (i=0; i * 2compiled ) { /* if it wasn't already compiled, do it now */ char *buf = txt_to_buf( text ); @@ -320,31 +320,36 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc BPY_free_compiled_text( text ); } } - if(text->compiled) - py_result = PyEval_EvalCode( text->compiled, py_dict, py_dict ); + + if(text->compiled) { + py_dict = PyC_DefaultNameSpace(fn_dummy); + py_result = PyEval_EvalCode(text->compiled, py_dict, py_dict); + } } else { FILE *fp= fopen(fn, "r"); - py_dict = bpy_namespace_dict_new(fn); - if(fp) { + py_dict = PyC_DefaultNameSpace(fn); + #ifdef _WIN32 /* Previously we used PyRun_File to run directly the code on a FILE * object, but as written in the Python/C API Ref Manual, chapter 2, * 'FILE structs for different C libraries can be different and * incompatible'. * So now we load the script file data to a buffer */ - char *pystring; + { + char *pystring; - fclose(fp); + fclose(fp); - pystring= MEM_mallocN(strlen(fn) + 32, "pystring"); - pystring[0]= '\0'; - sprintf(pystring, "exec(open(r'%s').read())", fn); - py_result = PyRun_String( pystring, Py_file_input, py_dict, py_dict ); - MEM_freeN(pystring); + pystring= MEM_mallocN(strlen(fn) + 32, "pystring"); + pystring[0]= '\0'; + sprintf(pystring, "exec(open(r'%s').read())", fn); + py_result = PyRun_String( pystring, Py_file_input, py_dict, py_dict ); + MEM_freeN(pystring); + } #else py_result = PyRun_File(fp, fn, Py_file_input, py_dict, py_dict); fclose(fp); @@ -471,7 +476,7 @@ int BPY_run_python_script_space(const char *modulename, const char *func) gilstate = PyGILState_Ensure(); - py_dict = bpy_namespace_dict_new(""); + py_dict = PyC_DefaultNameSpace(""); PyObject *module = PyImport_ImportModule(scpt->script.filename); if (module==NULL) { @@ -523,7 +528,7 @@ int BPY_eval_button(bContext *C, const char *expr, double *value) bpy_context_set(C, &gilstate); - py_dict= bpy_namespace_dict_new(""); + py_dict= PyC_DefaultNameSpace(""); mod = PyImport_ImportModule("math"); if (mod) { @@ -594,7 +599,7 @@ int BPY_eval_string(bContext *C, const char *expr) bpy_context_set(C, &gilstate); - py_dict= bpy_namespace_dict_new(""); + py_dict= PyC_DefaultNameSpace(""); retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index d2234963927..b0ae13640ba 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1065,6 +1065,26 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *p StructRNA *ptype= RNA_property_pointer_type(ptr, prop); int flag = RNA_property_flag(prop); + /* this is really nasty!, so we can fake the operator having direct properties eg: + * layout.prop(self, "filepath") + * ... which infact should be + * layout.prop(self.properties, "filepath") + * + * we need to do this trick. + * if the prop is not an operator type and the pyobject is an operator, use its properties in place of its self. + * + * this is so bad that its almost a good reason to do away with fake 'self.properties -> self' class mixing + * if this causes problems in the future it should be removed. + */ + if( (ptype == &RNA_AnyType) && + (BPy_StructRNA_Check(value)) && + (RNA_struct_is_a(((BPy_StructRNA *)value)->ptr.type, &RNA_Operator)) + ) { + value= PyObject_GetAttrString(value, "properties"); + value_new= value; + } + + /* if property is an OperatorProperties pointer and value is a map, forward back to pyrna_pydict_to_props */ if (RNA_struct_is_a(ptype, &RNA_OperatorProperties) && PyDict_Check(value)) { PointerRNA opptr = RNA_property_pointer_get(ptr, prop); @@ -1140,6 +1160,8 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *p Py_XDECREF(value_new); return -1; } } + + Py_XDECREF(value_new); break; } @@ -1957,26 +1979,46 @@ static PyObject *pyrna_struct_values(BPy_PropertyRNA *self) static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefix, const char *path, char **path_full, int *index) { + const int is_idbase= RNA_struct_is_ID(ptr->type); PropertyRNA *prop; + PointerRNA r_ptr; if (ptr->data==NULL) { PyErr_Format(PyExc_TypeError, "%.200s this struct has no data, can't be animated", error_prefix); return -1; } - prop = RNA_struct_find_property(ptr, path); - + /* full paths can only be given from ID base */ + if(is_idbase) { + int r_index= -1; + if(RNA_path_resolve_full(ptr, path, &r_ptr, &prop, &r_index)==0) { + prop= NULL; + } + else if(r_index != -1) { + PyErr_Format(PyExc_ValueError, "%.200s path includes index, must be a separate argument", error_prefix, path); + return -1; + } + else if(ptr->id.data != r_ptr.id.data) { + PyErr_Format(PyExc_ValueError, "%.200s path spans ID blocks", error_prefix, path); + return -1; + } + } + else { + prop = RNA_struct_find_property(ptr, path); + r_ptr= *ptr; + } + if (prop==NULL) { PyErr_Format( PyExc_TypeError, "%.200s property \"%s\" not found", error_prefix, path); return -1; } - if (!RNA_property_animateable(ptr, prop)) { + if (!RNA_property_animateable(&r_ptr, prop)) { PyErr_Format(PyExc_TypeError, "%.200s property \"%s\" not animatable", error_prefix, path); return -1; } - if(RNA_property_array_check(ptr, prop) == 0) { + if(RNA_property_array_check(&r_ptr, prop) == 0) { if((*index) == -1) { *index= 0; } @@ -1986,18 +2028,23 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi } } else { - int array_len= RNA_property_array_length(ptr, prop); + int array_len= RNA_property_array_length(&r_ptr, prop); if((*index) < -1 || (*index) >= array_len) { PyErr_Format( PyExc_TypeError, "%.200s index out of range \"%s\", given %d, array length is %d", error_prefix, path, *index, array_len); return -1; } } - *path_full= RNA_path_from_ID_to_property(ptr, prop); - - if (*path_full==NULL) { - PyErr_Format( PyExc_TypeError, "%.200s could not make path to \"%s\"", error_prefix, path); - return -1; + if(is_idbase) { + *path_full= BLI_strdup(path); + } + else { + *path_full= RNA_path_from_ID_to_property(&r_ptr, prop); + + if (*path_full==NULL) { + PyErr_Format( PyExc_TypeError, "%.200s could not make path to \"%s\"", error_prefix, path); + return -1; + } } return 0; @@ -2262,17 +2309,29 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args) PyObject *coerce= Py_True; PointerRNA r_ptr; PropertyRNA *r_prop; + int index= -1; if (!PyArg_ParseTuple(args, "s|O!:path_resolve", &path, &PyBool_Type, &coerce)) return NULL; - if (RNA_path_resolve(&self->ptr, path, &r_ptr, &r_prop)) { + if (RNA_path_resolve_full(&self->ptr, path, &r_ptr, &r_prop, &index)) { if(r_prop) { - if(coerce == Py_False) { - return pyrna_prop_CreatePyObject(&r_ptr, r_prop); + if(index != -1) { + if(index >= RNA_property_array_length(&r_ptr, r_prop) || index < 0) { + PyErr_Format(PyExc_TypeError, "%.200s.path_resolve(\"%.200s\") index out of range", RNA_struct_identifier(self->ptr.type), path); + return NULL; + } + else { + return pyrna_array_index(&r_ptr, r_prop, index); + } } else { - return pyrna_prop_to_py(&r_ptr, r_prop); + if(coerce == Py_False) { + return pyrna_prop_CreatePyObject(&r_ptr, r_prop); + } + else { + return pyrna_prop_to_py(&r_ptr, r_prop); + } } } else { diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 4b8beb42930..7f750f94242 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -101,6 +101,7 @@ void pyrna_free_types(void); /* primitive type conversion */ int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, char *param_data, PyObject *py, const char *error_prefix); int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix); +PyObject *pyrna_array_index(PointerRNA *ptr, PropertyRNA *prop, int index); PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop); PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int index); diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m index 80b97066b61..41c4e0cc5a3 100644 --- a/source/blender/quicktime/apple/qtkit_import.m +++ b/source/blender/quicktime/apple/qtkit_import.m @@ -30,6 +30,8 @@ */ #ifdef WITH_QUICKTIME +#include "MEM_guardedalloc.h" + #include "IMB_anim.h" #include "BLO_sys_types.h" #include "BKE_global.h" @@ -113,6 +115,8 @@ int anim_is_quicktime (char *name) void free_anim_quicktime (struct anim *anim) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + if (anim == NULL) return; if (anim->qtime == NULL) return; @@ -122,11 +126,15 @@ void free_anim_quicktime (struct anim *anim) { [anim->qtime->media release]; [anim->qtime->movie release]; + [QTMovie exitQTKitOnThread]; + if(anim->qtime) MEM_freeN (anim->qtime); anim->qtime = NULL; anim->duration = 0; + + [pool drain]; } static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height) @@ -302,6 +310,8 @@ int startquicktime (struct anim *anim) pool = [[NSAutoreleasePool alloc] init]; + [QTMovie enterQTKitOnThread]; + attributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithCString:anim->name encoding:[NSString defaultCStringEncoding]], QTMovieFileNameAttribute, @@ -314,6 +324,7 @@ int startquicktime (struct anim *anim) if(QTIME_DEBUG) printf("qt: bad movie %s\n", anim->name); MEM_freeN(anim->qtime); if(QTIME_DEBUG) printf("qt: can't load %s\n", anim->name); + [QTMovie exitQTKitOnThread]; [pool drain]; return -1; } @@ -328,6 +339,7 @@ int startquicktime (struct anim *anim) [anim->qtime->movie release]; MEM_freeN(anim->qtime); if(QTIME_DEBUG) printf("qt: can't load %s\n", anim->name); + [QTMovie exitQTKitOnThread]; [pool drain]; return -1; } diff --git a/source/blender/quicktime/apple/quicktime_import.c b/source/blender/quicktime/apple/quicktime_import.c index 75f77dccbfa..f9793f04b88 100644 --- a/source/blender/quicktime/apple/quicktime_import.c +++ b/source/blender/quicktime/apple/quicktime_import.c @@ -32,6 +32,7 @@ #if defined(_WIN32) || defined(__APPLE__) #ifndef USE_QTKIT +#include "MEM_guardedalloc.h" #include "IMB_anim.h" #include "BLO_sys_types.h" #include "BKE_global.h" @@ -88,16 +89,22 @@ typedef struct _QuicktimeMovie { void quicktime_init(void) { + OSErr nerr; #ifdef _WIN32 - if (InitializeQTML(0) != noErr) + QTLoadLibrary("QTCF.dll"); + nerr = InitializeQTML(0); + if (nerr != noErr) { G.have_quicktime = FALSE; + printf("Error initializing quicktime\n"); + } else G.have_quicktime = TRUE; #endif /* _WIN32 */ /* Initialize QuickTime */ #if defined(_WIN32) || defined (__APPLE__) - if (EnterMovies() != noErr) + nerr = EnterMovies(); + if (nerr != noErr) G.have_quicktime = FALSE; else #endif /* _WIN32 || __APPLE__ */ @@ -317,7 +324,9 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position) ImBuf *ibuf = NULL; unsigned int *rect; +#ifdef __APPLE__ unsigned char *from, *to; +#endif #ifdef _WIN32 unsigned char *crect; #endif @@ -373,7 +382,7 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position) } #endif - ibuf->profile == IB_PROFILE_SRGB; + ibuf->profile = IB_PROFILE_SRGB; IMB_flipy(ibuf); return ibuf; diff --git a/source/blender/render/extern/include/RE_render_ext.h b/source/blender/render/extern/include/RE_render_ext.h index 98720897e8e..b04f7247e2a 100644 --- a/source/blender/render/extern/include/RE_render_ext.h +++ b/source/blender/render/extern/include/RE_render_ext.h @@ -51,7 +51,7 @@ struct ImBuf; //void RE_zbufferall_radio(struct RadView *vw, struct RNode **rg_elem, int rg_totelem, struct Render *re); /* particle.c, effect.c, editmesh_modes.c and brush.c, returns 1 if rgb, 0 otherwise */ -int externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta); +int externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta, const int thread); /* particle.c */ void texture_rgb_blend(float *in, float *tex, float *out, float fact, float facg, int blendtype); diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index a09c16b7ed9..1ca1ea10273 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -248,7 +248,8 @@ static void cache_pointdensity(Render *re, Tex *tex) } else if (pd->source == TEX_PD_OBJECT) { Object *ob = pd->object; - if (ob) pointdensity_cache_object(re, pd, ob); + if (ob && ob->type == OB_MESH) + pointdensity_cache_object(re, pd, ob); } } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 8e1a959abef..bd4af52cd91 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2562,10 +2562,9 @@ static void shade_tface(BakeShade *bs) if (bs->usemask) { if (bs->ibuf->userdata==NULL) { BLI_lock_thread(LOCK_CUSTOM1); - if (bs->ibuf->userdata==NULL) { /* since the thread was locked, its possible another thread alloced the value */ + if (bs->ibuf->userdata==NULL) /* since the thread was locked, its possible another thread alloced the value */ bs->ibuf->userdata = (void *)MEM_callocN(sizeof(char)*bs->rectx*bs->recty, "BakeMask"); - bs->rect_mask= (char *)bs->ibuf->userdata; - } + bs->rect_mask= (char *)bs->ibuf->userdata; BLI_unlock_thread(LOCK_CUSTOM1); } else { bs->rect_mask= (char *)bs->ibuf->userdata; diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index ce55935d392..91d58b7943e 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -1019,7 +1019,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f } } - externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta); + externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta, 0); yn= tin*mtex->colfac; zn= tin*mtex->alphafac; @@ -1151,7 +1151,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater VECCOPY(texvec, orco); } - externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta); + externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta, 0); //yn= tin*mtex->colfac; //zn= tin*mtex->alphafac; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 394f90fea5e..e96baf0eab2 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -792,10 +792,26 @@ void shade_input_set_normals(ShadeInput *shi) { float u= shi->u, v= shi->v; float l= 1.0f+u+v; + + shi->flippednor = 0; + + /* test flip normals to viewing direction */ + if(!(shi->vlr->flag & R_TANGENT)) { + if(dot_v3v3(shi->facenor, shi->view) < 0.0f) { + negate_v3(shi->facenor); + shi->flippednor= 1; + } + } /* calculate vertexnormals */ if(shi->vlr->flag & R_SMOOTH) { float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; + + if(shi->flippednor) { + negate_v3(n1); + negate_v3(n2); + negate_v3(n3); + } shi->vn[0]= l*n3[0]-u*n1[0]-v*n2[0]; shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 0e98069f884..be2c83a7edf 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -3016,7 +3016,7 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef /* ------------------------------------------------------------------------- */ -int externtex(MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta) +int externtex(MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta, const int thread) { Tex *tex; TexResult texr; @@ -3042,7 +3042,7 @@ int externtex(MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *t do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); } - rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, 0, mtex->which_output); + rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output); if(rgb) { texr.tin= (0.35*texr.tr+0.45*texr.tg+0.2*texr.tb); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index a732524ca03..3f67888a4e9 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -177,27 +177,29 @@ typedef struct wmNotifier { #define ND_SEQUENCER (6<<16) #define ND_OB_ACTIVE (7<<16) #define ND_OB_SELECT (8<<16) -#define ND_MODE (9<<16) -#define ND_RENDER_RESULT (10<<16) -#define ND_COMPO_RESULT (11<<16) -#define ND_KEYINGSET (12<<16) -#define ND_TOOLSETTINGS (13<<16) -#define ND_LAYER (14<<16) -#define ND_FRAME_RANGE (15<<16) +#define ND_OB_VISIBLE (9<<16) +#define ND_MODE (10<<16) +#define ND_RENDER_RESULT (11<<16) +#define ND_COMPO_RESULT (12<<16) +#define ND_KEYINGSET (13<<16) +#define ND_TOOLSETTINGS (14<<16) +#define ND_LAYER (15<<16) +#define ND_FRAME_RANGE (16<<16) #define ND_LAYER_CONTENT (101<<16) /* NC_OBJECT Object */ -#define ND_TRANSFORM (16<<16) -#define ND_OB_SHADING (17<<16) -#define ND_POSE (18<<16) -#define ND_BONE_ACTIVE (19<<16) -#define ND_BONE_SELECT (20<<16) -#define ND_DRAW (21<<16) -#define ND_MODIFIER (22<<16) -#define ND_KEYS (23<<16) -#define ND_CONSTRAINT (24<<16) -#define ND_PARTICLE (25<<16) -#define ND_POINTCACHE (26<<16) +#define ND_TRANSFORM (17<<16) +#define ND_OB_SHADING (18<<16) +#define ND_POSE (19<<16) +#define ND_BONE_ACTIVE (20<<16) +#define ND_BONE_SELECT (21<<16) +#define ND_DRAW (22<<16) +#define ND_MODIFIER (23<<16) +#define ND_KEYS (24<<16) +#define ND_CONSTRAINT (25<<16) +#define ND_PARTICLE (26<<16) +#define ND_POINTCACHE (27<<16) +#define ND_PARENT (28<<16) /* NC_MATERIAL Material */ #define ND_SHADING (30<<16) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 9e7606a9f14..45c56164a30 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -838,8 +838,9 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA retval= wm_operator_call_internal(C, ot, context, properties, reports); /* keep the reports around if needed later */ - if (retval & OPERATOR_RUNNING_MODAL || wm_operator_register_check(wm, ot)) - { + if ( (retval & OPERATOR_RUNNING_MODAL) || + ((retval & OPERATOR_FINISHED) && wm_operator_register_check(wm, ot)) + ) { reports->flag |= RPT_FREE; /* let blender manage freeing */ } @@ -1232,11 +1233,14 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa /* remlink now, for load file case before removing*/ BLI_remlink(handlers, handler); - if(event->val!=EVT_FILESELECT_EXTERNAL_CANCEL) - if(screen != handler->filescreen) + if(event->val!=EVT_FILESELECT_EXTERNAL_CANCEL) { + if(screen != handler->filescreen) { ED_screen_full_prevspace(C, CTX_wm_area(C)); - else + } + else { ED_area_prevspace(C, CTX_wm_area(C)); + } + } wm_handler_op_context(C, handler); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 291ac83fd42..3a754f1f466 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -38,6 +38,7 @@ extern "C" { #include "bpy_internal_import.h" /* from the blender python api, but we want to import text too! */ + #include "py_capi_utils.h" #include "mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use. #include "geometry.h" // Blender.Geometry module copied here so the blenderlayer can use. #include "bgl.h" @@ -1920,7 +1921,7 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur PyObjectPlus::ClearDeprecationWarning(); - return bpy_namespace_dict_new(NULL); + return PyC_DefaultNameSpace(NULL); } void exitGamePlayerPythonScripting() @@ -1956,7 +1957,7 @@ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLev PyObjectPlus::NullDeprecationWarning(); - return bpy_namespace_dict_new(NULL); + return PyC_DefaultNameSpace(NULL); } void exitGamePythonScripting()