diff options
247 files changed, 3493 insertions, 1749 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e5cd23ab66a..d4489a8c76b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,6 +155,7 @@ option(WITH_IMAGE_DDS "Enable DDS Image Support" ON) option(WITH_IMAGE_CINEON "Enable CINEON and DPX Image Support" ON) option(WITH_IMAGE_HDR "Enable HDR Image Support" ON) option(WITH_IMAGE_REDCODE "Enable RedCode Image Support" OFF) +option(WITH_IMAGE_FRAMESERVER "Enable image FrameServer Support for rendering" ON) # Audio/Video format support option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" OFF) @@ -729,10 +730,14 @@ elseif(WIN32) endif() if(WITH_PYTHON) - set(PYTHON_VERSION 3.2) - set(PYTHON_INCLUDE_DIRS "${LIBDIR}/python/include/python${PYTHON_VERSION}") - # set(PYTHON_BINARY python) # not used yet - set(PYTHON_LIBRARIES ${LIBDIR}/python/lib/python32.lib) + # normally cached but not since we include them with blender + set(PYTHON_VERSION 3.2) # CACHE STRING) + set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # CACHE PATH) + set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32.lib") #CACHE FILEPATH) + + # uncached vars + set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") endif() set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib") @@ -832,12 +837,14 @@ elseif(WIN32) endif() if(WITH_PYTHON) - set(PYTHON ${LIBDIR}/python) - set(PYTHON_VERSION 3.2) - set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}") - # set(PYTHON_BINARY python) # not used yet - set(PYTHON_LIBRARIES ${PYTHON}/lib/python32mw.lib) - set(PYTHON_LIBPATH ${PYTHON}/lib) + # normally cached but not since we include them with blender + set(PYTHON_VERSION 3.2) # CACHE STRING) + set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # CACHE PATH) + set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32mw.lib") # CACHE FILEPATH) + + # uncached vars + set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") endif() set(PLATFORM_LINKFLAGS "--stack,2097152") @@ -888,27 +895,33 @@ elseif(APPLE) set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib) # TODO, deprecate endif() - set(PYTHON_VERSION 3.2) - - if(PYTHON_VERSION MATCHES 3.2) - # we use precompiled libraries for py 3.2 and up by default - - set(PYTHON ${LIBDIR}/python) - set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}") - # set(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet - set(PYTHON_LIBRARIES python${PYTHON_VERSION}) - set(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}") - # set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled - else() - # otherwise, use custom system framework - - set(PYTHON /System/Library/Frameworks/Python.framework/Versions/) + if(WITH_PYTHON) set(PYTHON_VERSION 3.2) - set(PYTHON_INCLUDE_DIRS "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}") - # set(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet - set(PYTHON_LIBRARIES "") - set(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config) - set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python") + if(PYTHON_VERSION MATCHES 3.2) + # we use precompiled libraries for py 3.2 and up by default + + # normally cached but not since we include them with blender + set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") + # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet + set(PYTHON_LIBRARY python${PYTHON_VERSION}) + set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}") + # set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled + else() + # otherwise, use custom system framework + # *not used but maintained incase some dev wants to* + + set(PYTHON "/System/Library/Frameworks/Python.framework/Versions/" CACHE PATH) + set(PYTHON_INCLUDE_DIR "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE PATH) + # set(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet + set(PYTHON_LIBRARY "" CACHE FILEPATH) + set(PYTHON_LIBPATH "${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config" CACHE PATH) + set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python" CACHE STRING) + unset(PYTHON) + endif() + + # uncached vars + set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") endif() if(WITH_INTERNATIONAL) @@ -1203,6 +1216,20 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() endif() + +# ensure python header is found since detection can fail, this could happen +# with _any_ library but since we used a fixed python version this tends to +# be most problematic. +if(WITH_PYTHON) + if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h") + message(FATAL_ERROR "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n" + "Set the cache entry 'PYTHON_INCLUDE_DIR' to point " + "to a valid python include path. Containing " + "Python.h for python version \"${PYTHON_VERSION}\"") + endif() +endif() + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}") diff --git a/GNUmakefile b/GNUmakefile index b55890f9271..b6741d7e5f0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -73,7 +73,7 @@ all: @echo @echo Building Blender ... - make -C $(BUILD_DIR) -s -j $(NPROCS) install + $(MAKE) -C $(BUILD_DIR) -s -j $(NPROCS) install @echo @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild. @echo blender installed, run from: "$(BUILD_DIR)/bin/blender" @@ -99,15 +99,19 @@ test: # run pep8 check check on scripts we distribute. test_pep8: - python source/tests/pep8.py > test_pep8.log 2>&1 + python3 source/tests/pep8.py > test_pep8.log 2>&1 @echo "written: test_pep8.log" # run some checks on our cmakefiles. test_cmake: - python build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1 + python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1 @echo "written: test_cmake_consistency.log" +# run deprecation tests, see if we have anything to remove. +test_deprecated: + python3 source/tests/check_deprecated.py + clean: - make -C $(BUILD_DIR) clean + $(MAKE) -C $(BUILD_DIR) clean .PHONY: all diff --git a/SConstruct b/SConstruct index f0253f739ae..7d55c7df9f7 100644 --- a/SConstruct +++ b/SConstruct @@ -361,6 +361,23 @@ if not quickie and do_clean: print B.bc.HEADER+'Already Clean, nothing to do.'+B.bc.ENDC Exit() + +# ensure python header is found since detection can fail, this could happen +# with _any_ library but since we used a fixed python version this tends to +# be most problematic. +if env['WITH_BF_PYTHON']: + py_h = os.path.join(Dir(env.subst('${BF_PYTHON_INC}')).abspath, "Python.h") + + if not os.path.exists(py_h): + print("\nMissing: \"" + env.subst('${BF_PYTHON_INC}') + os.sep + "Python.h\",\n" + " Set 'BF_PYTHON_INC' to point " + "to a valid python include path.\n Containing " + "Python.h for python version \"" + env.subst('${BF_PYTHON_VERSION}') + "\"") + + Exit() + del py_h + + if not os.path.isdir ( B.root_build_dir): os.makedirs ( B.root_build_dir ) os.makedirs ( B.root_build_dir + 'source' ) @@ -470,7 +487,7 @@ if env['OURPLATFORM']!='darwin': if f.endswith('.ttf'): continue - if 'locale' in dp: + if 'locale' in dp or 'fonts' in dp: datafileslist.append(os.path.join(dp,f)) dir= os.path.join(*([env['BF_INSTALLDIR']] + [VERSION] + ['datafiles'] + dp.split(os.sep)[2:])) # skip bin/.blender datafilestargetlist.append(dir + os.sep + f) diff --git a/build_files/cmake/cmake_consistency_check.py b/build_files/cmake/cmake_consistency_check.py index c13da8775b3..4b35e34a5cd 100755 --- a/build_files/cmake/cmake_consistency_check.py +++ b/build_files/cmake/cmake_consistency_check.py @@ -35,6 +35,21 @@ global_c = set() global_refs = {} +def replace_line(f, i, text, keep_indent=True): + file_handle = open(f, 'r') + data = file_handle.readlines() + file_handle.close() + + l = data[i] + ws = l[:len(l) - len(l.lstrip())] + + data[i] = "%s%s\n" % (ws, text) + + file_handle = open(f, 'w') + file_handle.writelines(data) + file_handle.close() + + def source_list(path, filename_check=None): for dirpath, dirnames, filenames in os.walk(path): @@ -77,7 +92,20 @@ def cmake_get_src(f): found = False i = 0 # print(f) + + def is_definition(l, f, i, name): + if ('set(%s' % name) in l or ('set(' in l and l.endswith(name)): + if len(l.split()) > 1: + raise Exception("strict formatting not kept 'set(%s*' %s:%d" % (name, f, i)) + return True + + if ("list(APPEND %s" % name) in l or ('list(APPEND ' in l and l.endswith(name)): + if l.endswith(")"): + raise Exception("strict formatting not kept 'list(APPEND %s...)' on 1 line %s:%d" % (name, f, i)) + return True + while it is not None: + context_name = "" while it is not None: i += 1 try: @@ -87,16 +115,13 @@ def cmake_get_src(f): break l = l.strip() if not l.startswith("#"): - if 'set(SRC' in l or ('set(' in l and l.endswith("SRC")): - if len(l.split()) > 1: - raise Exception("strict formatting not kept 'set(SRC*' %s:%d" % (f, i)) - found = True + found = is_definition(l, f, i, "SRC") + if found: + context_name = "SRC" break - - if "list(APPEND SRC" in l or ('list(APPEND ' in l and l.endswith("SRC")): - if l.endswith(")"): - raise Exception("strict formatting not kept 'list(APPEND SRC...)' on 1 line %s:%d" % (f, i)) - found = True + found = is_definition(l, f, i, "INC") + if found: + context_name = "INC" break if found: @@ -125,30 +150,45 @@ def cmake_get_src(f): if not l: pass elif l.startswith("$"): - # assume if it ends with SRC we know about it - if not l.split("}")[0].endswith("SRC"): - print("Can't use var '%s' %s:%d" % (l, f, i)) + if context_name == "SRC": + # assume if it ends with context_name we know about it + if not l.split("}")[0].endswith(context_name): + print("Can't use var '%s' %s:%d" % (l, f, i)) elif len(l.split()) > 1: raise Exception("Multi-line define '%s' %s:%d" % (l, f, i)) else: new_file = normpath(join(cmake_base, l)) - if is_c_header(new_file): - sources_h.append(new_file) - global_refs.setdefault(new_file, []).append((f, i)) - elif is_c(new_file): - sources_c.append(new_file) - global_refs.setdefault(new_file, []).append((f, i)) - elif l in ("PARENT_SCOPE", ): - # cmake var, ignore - pass - elif new_file.endswith(".list"): - pass - elif new_file.endswith(".def"): - pass - else: - raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file)) - + if context_name == "SRC": + if is_c_header(new_file): + sources_h.append(new_file) + global_refs.setdefault(new_file, []).append((f, i)) + elif is_c(new_file): + sources_c.append(new_file) + global_refs.setdefault(new_file, []).append((f, i)) + elif l in ("PARENT_SCOPE", ): + # cmake var, ignore + pass + elif new_file.endswith(".list"): + pass + elif new_file.endswith(".def"): + pass + else: + raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file)) + + elif context_name == "INC": + if os.path.isdir(new_file): + new_path_rel = os.path.relpath(new_file, cmake_base) + + if new_path_rel != l: + print("overly relative path:\n %s:%d\n %s\n %s" % (f, i, l, new_path_rel)) + + ## Save time. just replace the line + # replace_line(f, i - 1, new_path_rel) + + else: + raise Exception("non existant include %s:%d -> %s" % (f, i, new_file)) + # print(new_file) global_h.update(set(sources_h)) @@ -166,6 +206,10 @@ def cmake_get_src(f): if ff not in sources_c: print(" missing: " + ff) ''' + + # reset + sources_h[:] = [] + sources_c[:] = [] filen.close() diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index d8f5ba9e115..75af7e47edd 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -320,11 +320,7 @@ def creator(env): defs.append('WITH_PYTHON') if env['BF_DEBUG']: defs.append('_DEBUG') - - if env['BF_BUILDINFO']: - defs.append('BUILD_DATE') - defs.append('NAN_BUILDINFO') - + if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): incs.append(env['BF_PTHREADS_INC']) diff --git a/doc/python_api/examples/mathutils.Vector.py b/doc/python_api/examples/mathutils.Vector.py index 880b4ef2590..bf1fc70353f 100644 --- a/doc/python_api/examples/mathutils.Vector.py +++ b/doc/python_api/examples/mathutils.Vector.py @@ -1,15 +1,15 @@ import mathutils # zero length vector -vec = mathutils.Vector((0, 0, 1)) +vec = mathutils.Vector((0.0, 0.0, 1.0)) # unit length vector vec_a = vec.copy().normalize() -vec_b = mathutils.Vector((0, 1, 2)) +vec_b = mathutils.Vector((0.0, 1.0, 2.0)) -vec2d = mathutils.Vector((1, 2)) -vec3d = mathutils.Vector((1, 0, 0)) +vec2d = mathutils.Vector((1.0, 2.0)) +vec3d = mathutils.Vector((1.0, 0.0, 0.0)) vec4d = vec_a.to_4d() # other mathutuls types @@ -34,9 +34,9 @@ vec_a + vec_b vec_a - vec_b vec_a * vec_b vec_a * 10.0 -vec_a * matrix +matrix * vec_a +quat * vec_a vec_a * vec_b -vec_a * quat -vec_a @@ -44,6 +44,7 @@ vec_a * quat x = vec_a[0] len(vec) vec_a[:] = vec_b +vec_a[:] = 1.0, 2.0, 3.0 vec2d[:] = vec3d[:2] diff --git a/doc/python_api/sphinx_doc_gen.sh b/doc/python_api/sphinx_doc_gen.sh index 5f23ca395b6..a3befe1b7cb 100755 --- a/doc/python_api/sphinx_doc_gen.sh +++ b/doc/python_api/sphinx_doc_gen.sh @@ -38,8 +38,11 @@ cp $SPHINXBASE/sphinx-out/contents.html $SPHINXBASE/sphinx-out/index.html ssh $SSH_USER@emo.blender.org 'rm -rf '$SSH_UPLOAD_FULL'/*' rsync --progress -avze "ssh -p 22" $SPHINXBASE/sphinx-out/* $SSH_HOST:$SSH_UPLOAD_FULL/ -# symlink the dir to a static URL -ssh $SSH_USER@emo.blender.org 'rm '$SSH_UPLOAD'/250PythonDoc && ln -s '$SSH_UPLOAD_FULL' '$SSH_UPLOAD'/250PythonDoc' +## symlink the dir to a static URL +#ssh $SSH_USER@emo.blender.org 'rm '$SSH_UPLOAD'/250PythonDoc && ln -s '$SSH_UPLOAD_FULL' '$SSH_UPLOAD'/250PythonDoc' + +# better redirect +ssh $SSH_USER@emo.blender.org 'echo "<html><head><title>Redirecting...</title><meta http-equiv=\"REFRESH\" content=\"0;url=../blender_python_api_'$BLENDER_VERSION'/\"></head><body>Redirecting...</body></html>" > '$SSH_UPLOAD'/250PythonDoc/index.html' # pdf sphinx-build -b latex $SPHINXBASE/sphinx-in $SPHINXBASE/sphinx-out diff --git a/extern/binreloc/CMakeLists.txt b/extern/binreloc/CMakeLists.txt index a4f85a2fdfd..753e28091d3 100644 --- a/extern/binreloc/CMakeLists.txt +++ b/extern/binreloc/CMakeLists.txt @@ -19,7 +19,7 @@ # set(INC - ./include + include ) set(INC_SYS diff --git a/extern/glew/CMakeLists.txt b/extern/glew/CMakeLists.txt index 35beacab6a3..87f8bb6e940 100644 --- a/extern/glew/CMakeLists.txt +++ b/extern/glew/CMakeLists.txt @@ -25,7 +25,7 @@ # ***** END GPL LICENSE BLOCK ***** set(INC - ./include + include ) set(INC_SYS @@ -33,7 +33,9 @@ set(INC_SYS ) if(UNIX) - list(APPEND INC_SYS ${X11_X11_INCLUDE_PATH}) + list(APPEND INC_SYS + ${X11_X11_INCLUDE_PATH} + ) endif() set(SRC diff --git a/extern/lzo/CMakeLists.txt b/extern/lzo/CMakeLists.txt index 10ea2c58f7c..11eb18520b6 100644 --- a/extern/lzo/CMakeLists.txt +++ b/extern/lzo/CMakeLists.txt @@ -25,7 +25,7 @@ # ***** END GPL LICENSE BLOCK ***** set(INC - include + ) set(INC_SYS diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt index ab88c9ecabd..7eef13b103b 100644 --- a/intern/audaspace/CMakeLists.txt +++ b/intern/audaspace/CMakeLists.txt @@ -22,9 +22,9 @@ set(INC . - intern FX SRC + intern ../ffmpeg ) @@ -159,8 +159,12 @@ set(SRC if(WITH_CODEC_FFMPEG) add_definitions(-DWITH_FFMPEG) - list(APPEND INC ffmpeg) - list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS}) + list(APPEND INC + ffmpeg + ) + list(APPEND INC_SYS + ${FFMPEG_INCLUDE_DIRS} + ) list(APPEND SRC ffmpeg/AUD_FFMPEGFactory.cpp ffmpeg/AUD_FFMPEGReader.cpp @@ -172,8 +176,12 @@ endif() if(WITH_SDL) add_definitions(-DWITH_SDL) - list(APPEND INC SDL) - list(APPEND INC_SYS ${SDL_INCLUDE_DIR}) + list(APPEND INC + SDL + ) + list(APPEND INC_SYS + ${SDL_INCLUDE_DIR} + ) list(APPEND SRC SDL/AUD_SDLDevice.cpp @@ -183,8 +191,12 @@ endif() if(WITH_OPENAL) add_definitions(-DWITH_OPENAL) - list(APPEND INC OpenAL) - list(APPEND INC_SYS ${OPENAL_INCLUDE_DIR}) + list(APPEND INC + OpenAL + ) + list(APPEND INC_SYS + ${OPENAL_INCLUDE_DIR} + ) list(APPEND SRC OpenAL/AUD_OpenALDevice.cpp @@ -194,8 +206,12 @@ endif() if(WITH_JACK) add_definitions(-DWITH_JACK) - list(APPEND INC jack) - list(APPEND INC_SYS ${JACK_INCLUDE_DIRS}) + list(APPEND INC + jack + ) + list(APPEND INC_SYS + ${JACK_INCLUDE_DIRS} + ) list(APPEND SRC jack/AUD_JackDevice.cpp @@ -205,8 +221,12 @@ endif() if(WITH_CODEC_SNDFILE) add_definitions(-DWITH_SNDFILE) - list(APPEND INC sndfile) - list(APPEND INC_SYS ${SNDFILE_INCLUDE_DIRS}) + list(APPEND INC + sndfile + ) + list(APPEND INC_SYS + ${SNDFILE_INCLUDE_DIRS} + ) list(APPEND SRC sndfile/AUD_SndFileFactory.cpp sndfile/AUD_SndFileReader.cpp @@ -218,7 +238,9 @@ endif() if(WITH_SAMPLERATE) add_definitions(-DWITH_SAMPLERATE) - list(APPEND INC_SYS ${SAMPLERATE_INCLUDE_DIRS}) + list(APPEND INC_SYS + ${SAMPLERATE_INCLUDE_DIRS} + ) list(APPEND SRC SRC/AUD_SRCResampleFactory.cpp SRC/AUD_SRCResampleReader.cpp @@ -230,8 +252,12 @@ endif() if(WITH_FFTW3 AND FALSE) add_definitions(-DWITH_FFTW3) - list(APPEND INC fftw) - list(APPEND INC_SYS ${FFTW3_INCLUDE_DIRS}) + list(APPEND INC + fftw + ) + list(APPEND INC_SYS + ${FFTW3_INCLUDE_DIRS} + ) list(APPEND SRC fftw/AUD_BandPassFactory.cpp fftw/AUD_BandPassReader.cpp @@ -242,8 +268,12 @@ if(WITH_FFTW3 AND FALSE) endif() if(WITH_PYTHON) - list(APPEND INC Python) - list(APPEND INC_SYS ${PYTHON_INCLUDE_DIRS}) + list(APPEND INC + Python + ) + list(APPEND INC_SYS + ${PYTHON_INCLUDE_DIRS} + ) list(APPEND SRC Python/AUD_PyAPI.cpp diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index b9e30bbf62a..71e7b7677e8 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -105,12 +105,15 @@ void* AUD_openalRunThread(void* device) return NULL; } -void AUD_OpenALDevice::start() +void AUD_OpenALDevice::start(bool join) { lock(); if(!m_playing) { + if(join) + pthread_join(m_thread, NULL); + pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); @@ -271,8 +274,8 @@ void AUD_OpenALDevice::updateStreams() // stop thread if(m_playingSounds->empty() || (cerr != ALC_NO_ERROR)) { - unlock(); m_playing = false; + unlock(); pthread_exit(NULL); } @@ -366,6 +369,8 @@ AUD_OpenALDevice::AUD_OpenALDevice(AUD_DeviceSpecs specs, int buffersize) pthread_mutex_init(&m_mutex, &attr); pthread_mutexattr_destroy(&attr); + + start(false); } AUD_OpenALDevice::~AUD_OpenALDevice() @@ -414,13 +419,8 @@ AUD_OpenALDevice::~AUD_OpenALDevice() alcProcessContext(m_context); // wait for the thread to stop - if(m_playing) - { - unlock(); - pthread_join(m_thread, NULL); - } - else - unlock(); + unlock(); + pthread_join(m_thread, NULL); delete m_playingSounds; delete m_pausedSounds; diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/intern/audaspace/OpenAL/AUD_OpenALDevice.h index 3bbbe85d7e6..127f69beca8 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.h +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.h @@ -106,7 +106,7 @@ private: /** * Starts the streaming thread. */ - void start(); + void start(bool join = true); /** * Checks if a handle is valid. diff --git a/intern/boolop/CMakeLists.txt b/intern/boolop/CMakeLists.txt index 7a95d556172..742c0f1d42c 100644 --- a/intern/boolop/CMakeLists.txt +++ b/intern/boolop/CMakeLists.txt @@ -26,11 +26,11 @@ set(INC . - ./intern - ./extern - ../memutil + extern + intern ../container ../guardedalloc + ../memutil ../moto/include ../../source/blender/blenlib ../../source/blender/makesdna diff --git a/intern/bsp/CMakeLists.txt b/intern/bsp/CMakeLists.txt index 792f6aa1327..a844db3257e 100644 --- a/intern/bsp/CMakeLists.txt +++ b/intern/bsp/CMakeLists.txt @@ -25,11 +25,11 @@ # ***** END GPL LICENSE BLOCK ***** set(INC - ./intern + intern ../container ../guardedalloc - ../moto/include ../memutil + ../moto/include ) set(INC_SYS diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index ecdd441c263..1d1c4cc018c 100755 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -40,7 +40,7 @@ #define FFMPEG_HAVE_AVIO 1 #endif -#if (LIBAVCODEC_VERSION_MAJOR > 53) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR > 1)) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR == 1) && (LIBAVCODEC_VERSION_MICRO >= 1)) || ((LIBAVCODEC_VERSION_MAJOR == 52) && (LIBAVCODEC_VERSION_MINOR >= 122)) +#if (LIBAVCODEC_VERSION_MAJOR > 53) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR > 1)) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR == 1) && (LIBAVCODEC_VERSION_MICRO >= 1)) || ((LIBAVCODEC_VERSION_MAJOR == 52) && (LIBAVCODEC_VERSION_MINOR >= 121)) #define FFMPEG_HAVE_DEFAULT_VAL_UNION 1 #endif diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 41c70b7cd16..ccd763ef42c 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -37,9 +37,8 @@ set(INC_SYS set(SRC intern/GHOST_Buttons.cpp - intern/GHOST_CallbackEventConsumer.cpp intern/GHOST_C-api.cpp - intern/GHOST_Path-api.cpp + intern/GHOST_CallbackEventConsumer.cpp intern/GHOST_DisplayManager.cpp intern/GHOST_EventManager.cpp intern/GHOST_ISystem.cpp @@ -47,6 +46,7 @@ set(SRC intern/GHOST_ModifierKeys.cpp intern/GHOST_NDOFManager.cpp intern/GHOST_Path-api.cpp + intern/GHOST_Path-api.cpp intern/GHOST_Rect.cpp intern/GHOST_System.cpp intern/GHOST_TimerManager.cpp @@ -63,6 +63,7 @@ set(SRC GHOST_Path-api.h GHOST_Rect.h GHOST_Types.h + intern/GHOST_Buttons.h intern/GHOST_CallbackEventConsumer.h intern/GHOST_Debug.h @@ -146,7 +147,9 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL) ) endif() - list(APPEND INC_SYS ${SDL_INCLUDE_DIR}) + list(APPEND INC_SYS + ${SDL_INCLUDE_DIR} + ) elseif(APPLE) if(WITH_COCOA) @@ -185,7 +188,9 @@ elseif(UNIX) add_definitions(-DWITH_X11_XINPUT) endif() - list(APPEND INC_SYS ${X11_X11_INCLUDE_PATH}) + list(APPEND INC_SYS + ${X11_X11_INCLUDE_PATH} + ) list(APPEND SRC intern/GHOST_DisplayManagerX11.cpp @@ -205,7 +210,9 @@ elseif(UNIX) if(X11_XF86keysym_INCLUDE_PATH) add_definitions(-DWITH_XF86KEYSYM) - list(APPEND INC_SYS ${X11_XF86keysym_INCLUDE_PATH}) + list(APPEND INC_SYS + ${X11_XF86keysym_INCLUDE_PATH} + ) endif() elseif(WIN32) @@ -213,7 +220,9 @@ elseif(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") endif() - list(APPEND INC_SYS ${WINTAB_INC}) + list(APPEND INC_SYS + ${WINTAB_INC} + ) list(APPEND SRC intern/GHOST_DisplayManagerWin32.cpp diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 3ebd24c008b..dd296fa979c 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -150,8 +150,9 @@ GHOST_SystemX11( if (gettimeofday(&tv,NULL) == -1) { GHOST_ASSERT(false,"Could not instantiate timer!"); } - - m_start_time = GHOST_TUns64(tv.tv_sec*1000 + tv.tv_usec/1000); + + // Taking care not to overflow the tv.tv_sec*1000 + m_start_time = GHOST_TUns64(tv.tv_sec)*1000 + tv.tv_usec/1000; /* use detectable autorepeate, mac and windows also do this */ @@ -199,7 +200,8 @@ getMilliSeconds( GHOST_ASSERT(false,"Could not compute time!"); } - return GHOST_TUns64(tv.tv_sec*1000 + tv.tv_usec/1000) - m_start_time; + // Taking care not to overflow the tv.tv_sec*1000 + return GHOST_TUns64(tv.tv_sec)*1000 + tv.tv_usec/1000 - m_start_time; } GHOST_TUns8 diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c index c05ada84773..1bb73553012 100644 --- a/intern/mikktspace/mikktspace.c +++ b/intern/mikktspace/mikktspace.c @@ -243,7 +243,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre int iNrActiveGroups = 0, index = 0; const int iNrFaces = pContext->m_pInterface->m_getNumFaces(pContext); tbool bRes = TFALSE; - const float fThresCos = (const float) cos((fAngularThreshold*(float)M_PI)/180.0f); + const float fThresCos = (float) cos((fAngularThreshold*(float)M_PI)/180.0f); // verify all call-backs have been set if( pContext->m_pInterface->m_getNumFaces==NULL || @@ -1411,7 +1411,7 @@ STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriListIn[] // weight contribution by the angle // between the two edge vectors fCos = vdot(v1,v2); fCos=fCos>1?1:(fCos<(-1) ? (-1) : fCos); - fAngle = (const float) acos(fCos); + fAngle = (float) acos(fCos); fMagS = pTriInfos[f].fMagS; fMagT = pTriInfos[f].fMagT; diff --git a/intern/smoke/CMakeLists.txt b/intern/smoke/CMakeLists.txt index 174ee8bc3ed..094d398a83c 100644 --- a/intern/smoke/CMakeLists.txt +++ b/intern/smoke/CMakeLists.txt @@ -89,7 +89,9 @@ endif() if(WITH_FFTW3) add_definitions(-DFFTW3=1) - list(APPEND INC ${FFTW3_INCLUDE_DIRS}) + list(APPEND INC + ${FFTW3_INCLUDE_DIRS} + ) endif() blender_add_lib(bf_intern_smoke "${SRC}" "${INC}" "${INC_SYS}") diff --git a/po/POTFILES.in b/po/POTFILES.in index 0c654339bff..b45e7b21a87 100755 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,6 +1,7 @@ release/scripts/startup/bl_operators/animsys_update.py release/scripts/startup/bl_operators/object.py release/scripts/startup/bl_operators/object_align.py +release/scripts/startup/bl_operators/object_quick_effects.py release/scripts/startup/bl_operators/object_randomize_transform.py release/scripts/startup/bl_operators/presets.py release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -9,6 +10,7 @@ release/scripts/startup/bl_operators/wm.py release/scripts/startup/bl_ui/properties_render.py release/scripts/startup/bl_ui/properties_texture.py +release/scripts/startup/bl_ui/properties_world.py release/scripts/startup/bl_ui/space_console.py release/scripts/startup/bl_ui/space_dopesheet.py diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 07f1dc618dc..cf74282d064 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -31,6 +31,8 @@ __all__ = ( import bpy as _bpy +error_duplicates = False + def paths(): # RELEASE SCRIPTS: official scripts distributed in Blender releases paths = _bpy.utils.script_paths("addons") @@ -47,8 +49,11 @@ def paths(): def modules(module_cache): + global error_duplicates import os + error_duplicates = False + path_list = paths() # fake module importing @@ -117,7 +122,12 @@ def modules(module_cache): modules_stale -= {mod_name} mod = module_cache.get(mod_name) if mod: - if mod.__time__ != os.path.getmtime(mod_path): + if mod.__file__ != mod_path: + print("multiple addons with the same name:\n %r\n %r" % + (mod.__file__, mod_path)) + error_duplicates = True + + elif mod.__time__ != os.path.getmtime(mod_path): print("reloading addon:", mod_name, mod.__time__, os.path.getmtime(mod_path), mod_path) del module_cache[mod_name] mod = None diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index 5e95428f641..251fc947e94 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -117,7 +117,7 @@ def display_name_from_filepath(name): """ Returns the path stripped of directort and extension, ensured to be utf8 compatible. """ - return _os.path.splitext(_os.path.basename(name))[0].encode("utf8", "replace").decode("utf8") + return _os.path.splitext(basename(name))[0].encode("utf8", "replace").decode("utf8") def resolve_ncase(path): @@ -231,3 +231,12 @@ def module_names(path, recursive=False): modules.append(("%s.%s" % (filename, mod_name), mod_path)) return modules + + +def basename(path): + """ + Equivalent to os.path.basename, but skips a "//" suffix. + + Use for Windows compatibility. + """ + return _os.path.basename(path[2:] if path[:2] in {"//", b"//"} else path) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 7c0d3d24cba..57d3e6dd703 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -298,11 +298,18 @@ _presets = _os.path.join(_scripts[0], "presets") # FIXME - multiple paths def preset_paths(subdir): """ Returns a list of paths for a specific preset. + + :arg subdir: preset subdirectory (must not be an absolute path). + :type subdir: string + :return: script paths. + :rtype: list """ dirs = [] for path in script_paths("presets", all=True): directory = _os.path.join(path, subdir) - if _os.path.isdir(directory): + if not directory.startswith(path): + raise Exception("invalid subdir given %r" % subdir) + elif _os.path.isdir(directory): dirs.append(directory) return dirs diff --git a/release/scripts/modules/bpy_extras/image_utils.py b/release/scripts/modules/bpy_extras/image_utils.py index f91535a0ad4..e56c1c651c4 100644 --- a/release/scripts/modules/bpy_extras/image_utils.py +++ b/release/scripts/modules/bpy_extras/image_utils.py @@ -86,7 +86,9 @@ def load_image(imagepath, variants = [imagepath] if dirname: - variants += [os.path.join(dirname, imagepath), os.path.join(dirname, os.path.basename(imagepath))] + variants += [os.path.join(dirname, imagepath), + os.path.join(dirname, bpy.path.basename(imagepath)), + ] for filepath_test in variants: if ncase_cmp: @@ -99,7 +101,7 @@ def load_image(imagepath, return _image_load(nfilepath) if place_holder: - image = bpy.data.images.new(os.path.basename(imagepath), 128, 128) + image = bpy.data.images.new(bpy.path.basename(imagepath), 128, 128) # allow the path to be resolved later image.filepath = imagepath return image diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index cfa2233f7b6..bd01897c639 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -22,6 +22,7 @@ __all__ = ( "ExportHelper", "ImportHelper", "axis_conversion", + "axis_conversion_ensure", "create_derived_objects", "free_derived_objects", "unpack_list", @@ -154,17 +155,55 @@ def axis_conversion(from_forward='Y', from_up='Z', to_forward='Y', to_up='Z'): if from_forward == to_forward and from_up == to_up: return Matrix().to_3x3() + if from_forward[-1] == from_up[-1] or to_forward[-1] == to_up[-1]: + raise Exception("invalid axis arguments passed, " + "can't use up/forward on the same axis.") + value = reduce(int.__or__, (_axis_convert_num[a] << (i * 3) for i, a in enumerate((from_forward, from_up, to_forward, to_up)))) for i, axis_lut in enumerate(_axis_convert_lut): if value in axis_lut: return Matrix(_axis_convert_matrix[i]) - assert("internal error") + assert(0) + + +def axis_conversion_ensure(operator, forward_attr, up_attr): + """ + Function to ensure an operator has valid axis conversion settings, intended + to be used from :class:`Operator.check`. + + :arg operator: the operator to access axis attributes from. + :type operator: :class:`Operator` + :arg forward_attr: + :type forward_attr: string + :arg up_attr: the directory the *filepath* will be referenced from (normally the export path). + :type up_attr: string + :return: True if the value was modified. + :rtype: boolean + """ + def validate(axis_forward, axis_up): + if axis_forward[-1] == axis_up[-1]: + axis_up = axis_up[0:-1] + 'XYZ'[('XYZ'.index(axis_up[-1]) + 1) % 3] + + return axis_forward, axis_up + + change = False + + axis = getattr(operator, forward_attr), getattr(operator, up_attr) + axis_new = validate(*axis) + + if axis != axis_new: + setattr(operator, forward_attr, axis_new[0]) + setattr(operator, up_attr, axis_new[1]) + + return True + else: + return False # return a tuple (free, object list), free is True if memory should be freed later with free_derived_objects() def create_derived_objects(scene, ob): - if ob.parent and ob.parent.dupli_type != 'NONE': + if ob.parent and ob.parent.dupli_type in {'VERTS', 'FACES'}: return False, None if ob.dupli_type != 'NONE': diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py index c0c0f9186bd..5796abce72c 100644 --- a/release/scripts/modules/bpy_extras/view3d_utils.py +++ b/release/scripts/modules/bpy_extras/view3d_utils.py @@ -50,11 +50,11 @@ def region_2d_to_vector_3d(region, rv3d, coord): -0.5 )) - w = (out[0] * persinv[0][3]) + \ - (out[1] * persinv[1][3]) + \ - (out[2] * persinv[2][3]) + persinv[3][3] + w = ((out[0] * persinv[0][3]) + + (out[1] * persinv[1][3]) + + (out[2] * persinv[2][3]) + persinv[3][3]) - return ((out * persinv) / w) - rv3d.view_matrix.inverted()[3].xyz + return ((persinv * out) / w) - rv3d.view_matrix.inverted()[3].xyz else: return rv3d.view_matrix.inverted()[2].xyz.normalized() @@ -116,7 +116,7 @@ def location_3d_to_region_2d(region, rv3d, coord): """ from mathutils import Vector - prj = Vector((coord[0], coord[1], coord[2], 1.0)) * rv3d.perspective_matrix + prj = rv3d.perspective_matrix * Vector((coord[0], coord[1], coord[2], 1.0)) if prj.w > 0.0: width_half = region.width / 2.0 height_half = region.height / 2.0 diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index f2cd46b20ae..8766c873dd8 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -144,21 +144,21 @@ class _GenericBone: """ Vector pointing down the x-axis of the bone. """ from mathutils import Vector - return Vector((1.0, 0.0, 0.0)) * self.matrix.to_3x3() + return self.matrix.to_3x3() * Vector((1.0, 0.0, 0.0)) @property def y_axis(self): """ Vector pointing down the x-axis of the bone. """ from mathutils import Vector - return Vector((0.0, 1.0, 0.0)) * self.matrix.to_3x3() + return self.matrix.to_3x3() * Vector((0.0, 1.0, 0.0)) @property def z_axis(self): """ Vector pointing down the x-axis of the bone. """ from mathutils import Vector - return Vector((0.0, 0.0, 1.0)) * self.matrix.to_3x3() + return self.matrix.to_3x3() * Vector((0.0, 0.0, 1.0)) @property def basename(self): @@ -294,9 +294,9 @@ class EditBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup): :type roll: bool """ from mathutils import Vector - z_vec = Vector((0.0, 0.0, 1.0)) * self.matrix.to_3x3() - self.tail = self.tail * matrix - self.head = self.head * matrix + z_vec = self.matrix.to_3x3() * Vector((0.0, 0.0, 1.0)) + self.tail = matrix * self.tail + self.head = matrix * self.head if scale: scalar = matrix.median_scale @@ -304,7 +304,7 @@ class EditBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup): self.tail_radius *= scalar if roll: - self.align_roll(z_vec * matrix) + self.align_roll(matrix * z_vec) def ord_ind(i1, i2): diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index 6ab803cc469..27a6d21d519 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> import bpy import mathutils @@ -40,8 +40,10 @@ def add_torus(major_rad, minor_rad, major_seg, minor_seg): for minor_index in range(minor_seg): angle = 2 * pi * minor_index / minor_seg - vec = Vector((major_rad + (cos(angle) * minor_rad), 0.0, - (sin(angle) * minor_rad))) * quat + vec = quat * Vector((major_rad + (cos(angle) * minor_rad), + 0.0, + (sin(angle) * minor_rad), + )) verts.extend(vec[:]) @@ -72,7 +74,11 @@ def add_torus(major_rad, minor_rad, major_seg, minor_seg): return verts, faces -from bpy.props import FloatProperty, IntProperty, BoolProperty, FloatVectorProperty +from bpy.props import (FloatProperty, + IntProperty, + BoolProperty, + FloatVectorProperty, + ) class AddTorus(bpy.types.Operator): @@ -82,7 +88,8 @@ class AddTorus(bpy.types.Operator): bl_options = {'REGISTER', 'UNDO'} major_radius = FloatProperty(name="Major Radius", - description="Radius from the origin to the center of the cross sections", + description=("Radius from the origin to the " + "center of the cross sections"), default=1.0, min=0.01, max=100.0) minor_radius = FloatProperty(name="Minor Radius", description="Radius of the torus' cross section", diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 34c5b0d922a..a0267b8b947 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> import bpy from bpy.props import StringProperty @@ -28,7 +28,11 @@ class EditExternally(bpy.types.Operator): bl_label = "Image Edit Externally" bl_options = {'REGISTER'} - filepath = StringProperty(name="File Path", description="Path to an image file", maxlen=1024, default="") + filepath = StringProperty( + name="File Path", + description="Path to an image file", + maxlen=1024, + ) def _editor_guess(self, context): import sys @@ -57,10 +61,13 @@ class EditExternally(bpy.types.Operator): def execute(self, context): import os import subprocess - filepath = bpy.path.abspath(self.filepath) + filepath = os.path.normpath(bpy.path.abspath(self.filepath)) if not os.path.exists(filepath): - self.report({'ERROR'}, "Image path %r not found, image may be packed or unsaved." % filepath) + self.report({'ERROR'}, + "Image path %r not found, image may be packed or " + "unsaved." % filepath) + return {'CANCELLED'} cmd = self._editor_guess(context) + [filepath] @@ -70,7 +77,10 @@ class EditExternally(bpy.types.Operator): except: import traceback traceback.print_exc() - self.report({'ERROR'}, "Image editor not found, please specify in User Preferences > File") + self.report({'ERROR'}, + "Image editor not found, " + "please specify in User Preferences > File") + return {'CANCELLED'} return {'FINISHED'} @@ -104,7 +114,9 @@ class SaveDirty(bpy.types.Operator): if "\\" not in filepath and "/" not in filepath: self.report({'WARNING'}, "Invalid path: " + filepath) elif filepath in unique_paths: - self.report({'WARNING'}, "Path used by more then one image: " + filepath) + self.report({'WARNING'}, + "Path used by more then one image: %r" % + filepath) else: unique_paths.add(filepath) image.save() @@ -144,12 +156,11 @@ class ProjectEdit(bpy.types.Operator): filepath = os.path.splitext(filepath)[0] # filepath = bpy.path.clean_name(filepath) # fixes <memory> rubbish, needs checking - if filepath.startswith(".") or filepath == "": - # TODO, have a way to check if the file is saved, assume startup.blend + if bpy.data.is_saved: + filepath = "//" + filepath + else: tmpdir = context.user_preferences.filepaths.temporary_directory filepath = os.path.join(tmpdir, "project_edit") - else: - filepath = "//" + filepath obj = context.object @@ -163,7 +174,7 @@ class ProjectEdit(bpy.types.Operator): filepath_final = filepath + ("%.3d.%s" % (i, EXT)) i += 1 - image_new.name = os.path.basename(filepath_final) + image_new.name = bpy.path.basename(filepath_final) ProjectEdit._proj_hack[0] = image_new.name image_new.filepath_raw = filepath_final # TODO, filepath raw is crummy diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index 03b0e469310..344b238709f 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> import bpy @@ -111,7 +111,8 @@ class MeshMirrorUV(bpy.types.Operator): #for i, v in enumerate(mesh.vertices): vmap = {} - for mirror_a, mirror_b in (mirror_gt, mirror_lt), (mirror_lt, mirror_gt): + for mirror_a, mirror_b in ((mirror_gt, mirror_lt), + (mirror_lt, mirror_gt)): for co, i in mirror_a.items(): nco = (-co[0], co[1], co[2]) j = mirror_b.get(nco) @@ -120,7 +121,8 @@ class MeshMirrorUV(bpy.types.Operator): active_uv_layer = mesh.uv_textures.active.data fuvs = [(uv.uv1, uv.uv2, uv.uv3, uv.uv4) for uv in active_uv_layer] - fuvs_cpy = [(uv[0].copy(), uv[1].copy(), uv[2].copy(), uv[3].copy()) for uv in fuvs] + fuvs_cpy = [(uv[0].copy(), uv[1].copy(), uv[2].copy(), uv[3].copy()) + for uv in fuvs] # as a list faces = mesh.faces[:] diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index 72e521be5cf..c0bd20b8910 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> import bpy from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty @@ -29,9 +29,22 @@ class SelectPattern(bpy.types.Operator): bl_label = _("Select Pattern") bl_options = {'REGISTER', 'UNDO'} - pattern = StringProperty(name=_("Pattern"), description=_("Name filter using '*' and '?' wildcard chars"), maxlen=32, default="*") - case_sensitive = BoolProperty(name=_("Case Sensitive"), description=_("Do a case sensitive compare"), default=False) - extend = BoolProperty(name=_("Extend"), description=_("Extend the existing selection"), default=True) + pattern = StringProperty( + name=_("Pattern"), + description=_("Name filter using '*' and '?' wildcard chars"), + maxlen=32, + default="*", + ) + case_sensitive = BoolProperty( + name=_("Case Sensitive"), + description=_("Do a case sensitive compare"), + default=False, + ) + extend = BoolProperty( + name=_("Extend"), + description=_("Extend the existing selection"), + default=True, + ) def execute(self, context): @@ -40,22 +53,37 @@ class SelectPattern(bpy.types.Operator): if self.case_sensitive: pattern_match = fnmatch.fnmatchcase else: - pattern_match = lambda a, b: fnmatch.fnmatchcase(a.upper(), b.upper()) - + pattern_match = (lambda a, b: + fnmatch.fnmatchcase(a.upper(), b.upper())) + is_ebone = False obj = context.object if obj and obj.mode == 'POSE': items = obj.data.bones + if not self.extend: + bpy.ops.pose.select_all(action='DESELECT') elif obj and obj.type == 'ARMATURE' and obj.mode == 'EDIT': items = obj.data.edit_bones + if not self.extend: + bpy.ops.armature.select_all(action='DESELECT') + is_ebone = True else: items = context.visible_objects + if not self.extend: + bpy.ops.object.select_all(action='DESELECT') # Can be pose bones or objects for item in items: if pattern_match(item.name, self.pattern): item.select = True - elif not self.extend: - item.select = False + + # hrmf, perhaps there should be a utility function for this. + if is_ebone: + item.select_head = True + item.select_tail = True + if item.use_connect: + item_parent = item.parent + if item_parent is not None: + item_parent.select_tail = True return {'FINISHED'} @@ -94,19 +122,25 @@ class SelectCamera(bpy.types.Operator): class SelectHierarchy(bpy.types.Operator): - '''Select object relative to the active objects position in the hierarchy''' + '''Select object relative to the active objects position''' \ + '''in the hierarchy''' bl_idname = "object.select_hierarchy" bl_label = _("Select Hierarchy") bl_options = {'REGISTER', 'UNDO'} - direction = EnumProperty(items=( - ('PARENT', _("Parent"), ""), - ('CHILD', _("Child"), "")), - name=_("Direction"), - description=_("Direction to select in the hierarchy"), - default='PARENT') + direction = EnumProperty( + items=(('PARENT', _("Parent"), ""), + ('CHILD', _("Child"), "") + ), + name=_("Direction"), + description=_("Direction to select in the hierarchy"), + default='PARENT') - extend = BoolProperty(name=_("Extend"), description=_("Extend the existing selection"), default=False) + extend = BoolProperty( + name=_("Extend"), + description=_("Extend the existing selection"), + default=False, + ) @classmethod def poll(cls, context): @@ -164,7 +198,11 @@ class SubdivisionSet(bpy.types.Operator): level = IntProperty(name=_("Level"), default=1, min=-100, max=100, soft_min=-6, soft_max=6) - relative = BoolProperty(name=_("Relative"), description=_("Apply the subsurf level as an offset relative to the current level"), default=False) + relative = BoolProperty( + name=_("Relative"), + description=_("Apply the subsurf level as an offset relative to the current level"), + default=False, + ) @classmethod def poll(cls, context): @@ -216,7 +254,8 @@ class SubdivisionSet(bpy.types.Operator): mod = obj.modifiers.new("Subsurf", 'SUBSURF') mod.levels = level except: - self.report({'WARNING'}, "Modifiers cannot be added to object: " + obj.name) + self.report({'WARNING'}, + "Modifiers cannot be added to object: " + obj.name) for obj in context.selected_editable_objects: set_object_subd(obj) @@ -225,23 +264,36 @@ class SubdivisionSet(bpy.types.Operator): class ShapeTransfer(bpy.types.Operator): - '''Copy another selected objects active shape to this one by applying the relative offsets''' + '''Copy another selected objects active shape to this one by ''' \ + '''applying the relative offsets''' bl_idname = "object.shape_key_transfer" bl_label = _("Transfer Shape Key") bl_options = {'REGISTER', 'UNDO'} - mode = EnumProperty(items=( - ('OFFSET', _("Offset"), _("Apply the relative positional offset")), - ('RELATIVE_FACE', _("Relative Face"), _("Calculate the geometricly relative position (using faces).")), - ('RELATIVE_EDGE', _("Relative Edge"), _("Calculate the geometricly relative position (using edges)."))), - name=_("Transformation Mode"), - description=_("Method to apply relative shape positions to the new shape"), - default='OFFSET') - - use_clamp = BoolProperty(name=_("Clamp Offset"), - description=_("Clamp the transformation to the distance each vertex moves in the original shape."), - default=False) + mode = EnumProperty( + items=(('OFFSET', + _("Offset"), + _("Apply the relative positional offset") + ), + ('RELATIVE_FACE', + _("Relative Face"), + _("Calculate relative position (using faces)."), + ), + ('RELATIVE_EDGE', + _("Relative Edge"), + _("Calculate relative position (using edges)."), + ), + ), + name=_("Transformation Mode"), + description=_("Relative shape positions to the new shape method"), + default='OFFSET', + ) + use_clamp = BoolProperty( + name=_("Clamp Offset"), + description=_("Clamp the transformation to the distance each vertex moves in the original shape."), + default=False, + ) def _main(self, ob_act, objects, mode='OFFSET', use_clamp=False): @@ -273,13 +325,16 @@ class ShapeTransfer(bpy.types.Operator): orig_shape_coords = me_cos(ob_act.active_shape_key.data) orig_normals = me_nos(me.vertices) - # orig_coords = me_cos(me.vertices) # the actual mverts location isnt as relyable as the base shape :S + # the actual mverts location isnt as relyable as the base shape :S + # orig_coords = me_cos(me.vertices) orig_coords = me_cos(me.shape_keys.key_blocks[0].data) for ob_other in objects: me_other = ob_other.data if len(me_other.vertices) != len(me.vertices): - self.report({'WARNING'}, "Skipping '%s', vertex count differs" % ob_other.name) + self.report({'WARNING'}, + ("Skipping '%s', " + "vertex count differs") % ob_other.name) continue target_normals = me_nos(me_other.vertices) @@ -291,53 +346,90 @@ class ShapeTransfer(bpy.types.Operator): ob_add_shape(ob_other, orig_key_name) # editing the final coords, only list that stores wrapped coords - target_shape_coords = [v.co for v in ob_other.active_shape_key.data] + target_shape_coords = [v.co for v in + ob_other.active_shape_key.data] median_coords = [[] for i in range(len(me.vertices))] # Method 1, edge if mode == 'OFFSET': for i, vert_cos in enumerate(median_coords): - vert_cos.append(target_coords[i] + (orig_shape_coords[i] - orig_coords[i])) + vert_cos.append(target_coords[i] + + (orig_shape_coords[i] - orig_coords[i])) elif mode == 'RELATIVE_FACE': for face in me.faces: i1, i2, i3, i4 = face.vertices_raw if i4 != 0: pt = barycentric_transform(orig_shape_coords[i1], - orig_coords[i4], orig_coords[i1], orig_coords[i2], - target_coords[i4], target_coords[i1], target_coords[i2]) + orig_coords[i4], + orig_coords[i1], + orig_coords[i2], + target_coords[i4], + target_coords[i1], + target_coords[i2], + ) median_coords[i1].append(pt) pt = barycentric_transform(orig_shape_coords[i2], - orig_coords[i1], orig_coords[i2], orig_coords[i3], - target_coords[i1], target_coords[i2], target_coords[i3]) + orig_coords[i1], + orig_coords[i2], + orig_coords[i3], + target_coords[i1], + target_coords[i2], + target_coords[i3], + ) median_coords[i2].append(pt) pt = barycentric_transform(orig_shape_coords[i3], - orig_coords[i2], orig_coords[i3], orig_coords[i4], - target_coords[i2], target_coords[i3], target_coords[i4]) + orig_coords[i2], + orig_coords[i3], + orig_coords[i4], + target_coords[i2], + target_coords[i3], + target_coords[i4], + ) median_coords[i3].append(pt) pt = barycentric_transform(orig_shape_coords[i4], - orig_coords[i3], orig_coords[i4], orig_coords[i1], - target_coords[i3], target_coords[i4], target_coords[i1]) + orig_coords[i3], + orig_coords[i4], + orig_coords[i1], + target_coords[i3], + target_coords[i4], + target_coords[i1], + ) median_coords[i4].append(pt) else: pt = barycentric_transform(orig_shape_coords[i1], - orig_coords[i3], orig_coords[i1], orig_coords[i2], - target_coords[i3], target_coords[i1], target_coords[i2]) + orig_coords[i3], + orig_coords[i1], + orig_coords[i2], + target_coords[i3], + target_coords[i1], + target_coords[i2], + ) median_coords[i1].append(pt) pt = barycentric_transform(orig_shape_coords[i2], - orig_coords[i1], orig_coords[i2], orig_coords[i3], - target_coords[i1], target_coords[i2], target_coords[i3]) + orig_coords[i1], + orig_coords[i2], + orig_coords[i3], + target_coords[i1], + target_coords[i2], + target_coords[i3], + ) median_coords[i2].append(pt) pt = barycentric_transform(orig_shape_coords[i3], - orig_coords[i2], orig_coords[i3], orig_coords[i1], - target_coords[i2], target_coords[i3], target_coords[i1]) + orig_coords[i2], + orig_coords[i3], + orig_coords[i1], + target_coords[i2], + target_coords[i3], + target_coords[i1], + ) median_coords[i3].append(pt) elif mode == 'RELATIVE_EDGE': @@ -375,7 +467,8 @@ class ShapeTransfer(bpy.types.Operator): if use_clamp: # clamp to the same movement as the original # breaks copy between different scaled meshes. - len_from = (orig_shape_coords[i] - orig_coords[i]).length + len_from = (orig_shape_coords[i] - + orig_coords[i]).length ofs = co - target_coords[i] ofs.length = len_from co = target_coords[i] + ofs @@ -396,7 +489,10 @@ class ShapeTransfer(bpy.types.Operator): if 1: # swap from/to, means we cant copy to many at once. if len(objects) != 1: - self.report({'ERROR'}, "Expected one other selected mesh object to copy from") + self.report({'ERROR'}, + ("Expected one other selected " + "mesh object to copy from")) + return {'CANCELLED'} ob_act, objects = objects[0], [ob_act] @@ -430,11 +526,14 @@ class JoinUVs(bpy.types.Operator): bpy.ops.object.mode_set(mode='OBJECT', toggle=False) if not mesh.uv_textures: - self.report({'WARNING'}, "Object: %s, Mesh: '%s' has no UVs\n" % (obj.name, mesh.name)) + self.report({'WARNING'}, + "Object: %s, Mesh: '%s' has no UVs" + % (obj.name, mesh.name)) else: len_faces = len(mesh.faces) - uv_array = array.array('f', [0.0] * 8) * len_faces # seems to be the fastest way to create an array + # seems to be the fastest way to create an array + uv_array = array.array('f', [0.0] * 8) * len_faces mesh.uv_textures.active.data.foreach_get("uv_raw", uv_array) objects = context.selected_editable_objects[:] @@ -451,11 +550,18 @@ class JoinUVs(bpy.types.Operator): mesh_other.tag = True if len(mesh_other.faces) != len_faces: - self.report({'WARNING'}, "Object: %s, Mesh: '%s' has %d faces, expected %d\n" % (obj_other.name, mesh_other.name, len(mesh_other.faces), len_faces)) + self.report({'WARNING'}, "Object: %s, Mesh: " + "'%s' has %d faces, expected %d\n" + % (obj_other.name, + mesh_other.name, + len(mesh_other.faces), + len_faces), + ) else: uv_other = mesh_other.uv_textures.active if not uv_other: - uv_other = mesh_other.uv_textures.new() # should return the texture it adds + # should return the texture it adds + uv_other = mesh_other.uv_textures.new() # finally do the copy uv_other.data.foreach_set("uv_raw", uv_array) @@ -483,14 +589,18 @@ class MakeDupliFace(bpy.types.Operator): SCALE_FAC = 0.01 offset = 0.5 * SCALE_FAC - base_tri = Vector((-offset, -offset, 0.0)), Vector((offset, -offset, 0.0)), Vector((offset, offset, 0.0)), Vector((-offset, offset, 0.0)) + base_tri = (Vector((-offset, -offset, 0.0)), + Vector((+offset, -offset, 0.0)), + Vector((+offset, +offset, 0.0)), + Vector((-offset, +offset, 0.0)), + ) def matrix_to_quat(matrix): # scale = matrix.median_scale trans = matrix.to_translation() rot = matrix.to_3x3() # also contains scale - return [(b * rot) + trans for b in base_tri] + return [(rot * b) + trans for b in base_tri] scene = bpy.context.scene linked = {} for obj in bpy.context.selected_objects: @@ -499,7 +609,10 @@ class MakeDupliFace(bpy.types.Operator): linked.setdefault(data, []).append(obj) for data, objects in linked.items(): - face_verts = [axis for obj in objects for v in matrix_to_quat(obj.matrix_world) for axis in v] + face_verts = [axis for obj in objects + for v in matrix_to_quat(obj.matrix_world) + for axis in v] + faces = list(range(len(face_verts) // 3)) mesh = bpy.data.meshes.new(data.name + "_dupli") @@ -536,7 +649,8 @@ class MakeDupliFace(bpy.types.Operator): class IsolateTypeRender(bpy.types.Operator): - '''Hide unselected render objects of same type as active by setting the hide render flag''' + '''Hide unselected render objects of same type as active ''' \ + '''by setting the hide render flag''' bl_idname = "object.isolate_type_render" bl_label = _("Restrict Render Unselected") bl_options = {'REGISTER', 'UNDO'} diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index d662d292868..04a4d7d8f42 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -16,105 +16,211 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> import bpy from mathutils import Vector from blf import gettext as _ +def GlobalBB_LQ(bb_world): -def align_objects(align_x, align_y, align_z, align_mode, relative_to): + # Initialize the variables with the 8th vertex + left, right, front, back, down, up = (bb_world[7][0], + bb_world[7][0], + bb_world[7][1], + bb_world[7][1], + bb_world[7][2], + bb_world[7][2], + ) + + # Test against the other 7 verts + for i in range (7): + + # X Range + val = bb_world[i][0] + if val < left: + left = val + + if val > right: + right = val + + # Y Range + val = bb_world[i][1] + if val < front: + front = val + + if val > back: + back = val + + # Z Range + val = bb_world[i][2] + if val < down: + down = val + + if val > up: + up = val + + return (Vector((left, front, up)), Vector((right, back, down))) + +def GlobalBB_HQ(obj): + + matrix_world = obj.matrix_world.copy() + + # Initialize the variables with the last vertex + + verts = obj.data.vertices + + val = matrix_world * verts[-1].co + + left, right, front, back, down, up = (val[0], + val[0], + val[1], + val[1], + val[2], + val[2], + ) + + # Test against all other verts + for i in range (len(verts)-1): + + vco = matrix_world * verts[i].co + + # X Range + val = vco[0] + if val < left: + left = val + + if val > right: + right = val + + # Y Range + val = vco[1] + if val < front: + front = val + + if val > back: + back = val + + # Z Range + val = vco[2] + if val < down: + down = val + + if val > up: + up = val + + return Vector((left, front, up)), Vector((right, back, down)) + + +def align_objects(align_x, + align_y, + align_z, + align_mode, + relative_to, + bb_quality): cursor = bpy.context.scene.cursor_location - Left_Up_Front_SEL = [0.0, 0.0, 0.0] - Right_Down_Back_SEL = [0.0, 0.0, 0.0] + Left_Front_Up_SEL = [0.0, 0.0, 0.0] + Right_Back_Down_SEL = [0.0, 0.0, 0.0] flag_first = True objs = [] for obj in bpy.context.selected_objects: - matrix_world = obj.matrix_world - bb_world = [Vector(v[:]) * matrix_world for v in obj.bound_box] + matrix_world = obj.matrix_world.copy() + bb_world = [matrix_world * Vector(v[:]) for v in obj.bound_box] objs.append((obj, bb_world)) if not objs: return False for obj, bb_world in objs: - Left_Up_Front = bb_world[1] - Right_Down_Back = bb_world[7] + + if bb_quality: + GBB = GlobalBB_HQ(obj) + else: + GBB = GlobalBB_LQ(bb_world) + + Left_Front_Up = GBB[0] + Right_Back_Down = GBB[1] # Active Center if obj == bpy.context.active_object: - center_active_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2.0 - center_active_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2.0 - center_active_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2.0 + center_active_x = (Left_Front_Up[0] + Right_Back_Down[0]) / 2.0 + center_active_y = (Left_Front_Up[1] + Right_Back_Down[1]) / 2.0 + center_active_z = (Left_Front_Up[2] + Right_Back_Down[2]) / 2.0 - size_active_x = (Right_Down_Back[0] - Left_Up_Front[0]) / 2.0 - size_active_y = (Right_Down_Back[1] - Left_Up_Front[1]) / 2.0 - size_active_z = (Left_Up_Front[2] - Right_Down_Back[2]) / 2.0 + size_active_x = (Right_Back_Down[0] - Left_Front_Up[0]) / 2.0 + size_active_y = (Right_Back_Down[1] - Left_Front_Up[1]) / 2.0 + size_active_z = (Left_Front_Up[2] - Right_Back_Down[2]) / 2.0 # Selection Center if flag_first: flag_first = False - Left_Up_Front_SEL[0] = Left_Up_Front[0] - Left_Up_Front_SEL[1] = Left_Up_Front[1] - Left_Up_Front_SEL[2] = Left_Up_Front[2] + Left_Front_Up_SEL[0] = Left_Front_Up[0] + Left_Front_Up_SEL[1] = Left_Front_Up[1] + Left_Front_Up_SEL[2] = Left_Front_Up[2] - Right_Down_Back_SEL[0] = Right_Down_Back[0] - Right_Down_Back_SEL[1] = Right_Down_Back[1] - Right_Down_Back_SEL[2] = Right_Down_Back[2] + Right_Back_Down_SEL[0] = Right_Back_Down[0] + Right_Back_Down_SEL[1] = Right_Back_Down[1] + Right_Back_Down_SEL[2] = Right_Back_Down[2] else: # X axis - if Left_Up_Front[0] < Left_Up_Front_SEL[0]: - Left_Up_Front_SEL[0] = Left_Up_Front[0] + if Left_Front_Up[0] < Left_Front_Up_SEL[0]: + Left_Front_Up_SEL[0] = Left_Front_Up[0] # Y axis - if Left_Up_Front[1] < Left_Up_Front_SEL[1]: - Left_Up_Front_SEL[1] = Left_Up_Front[1] + if Left_Front_Up[1] < Left_Front_Up_SEL[1]: + Left_Front_Up_SEL[1] = Left_Front_Up[1] # Z axis - if Left_Up_Front[2] > Left_Up_Front_SEL[2]: - Left_Up_Front_SEL[2] = Left_Up_Front[2] + if Left_Front_Up[2] > Left_Front_Up_SEL[2]: + Left_Front_Up_SEL[2] = Left_Front_Up[2] # X axis - if Right_Down_Back[0] > Right_Down_Back_SEL[0]: - Right_Down_Back_SEL[0] = Right_Down_Back[0] + if Right_Back_Down[0] > Right_Back_Down_SEL[0]: + Right_Back_Down_SEL[0] = Right_Back_Down[0] # Y axis - if Right_Down_Back[1] > Right_Down_Back_SEL[1]: - Right_Down_Back_SEL[1] = Right_Down_Back[1] + if Right_Back_Down[1] > Right_Back_Down_SEL[1]: + Right_Back_Down_SEL[1] = Right_Back_Down[1] # Z axis - if Right_Down_Back[2] < Right_Down_Back_SEL[2]: - Right_Down_Back_SEL[2] = Right_Down_Back[2] + if Right_Back_Down[2] < Right_Back_Down_SEL[2]: + Right_Back_Down_SEL[2] = Right_Back_Down[2] - center_sel_x = (Left_Up_Front_SEL[0] + Right_Down_Back_SEL[0]) / 2.0 - center_sel_y = (Left_Up_Front_SEL[1] + Right_Down_Back_SEL[1]) / 2.0 - center_sel_z = (Left_Up_Front_SEL[2] + Right_Down_Back_SEL[2]) / 2.0 + center_sel_x = (Left_Front_Up_SEL[0] + Right_Back_Down_SEL[0]) / 2.0 + center_sel_y = (Left_Front_Up_SEL[1] + Right_Back_Down_SEL[1]) / 2.0 + center_sel_z = (Left_Front_Up_SEL[2] + Right_Back_Down_SEL[2]) / 2.0 # Main Loop for obj, bb_world in objs: - bb_world = [Vector(v[:]) * obj.matrix_world for v in obj.bound_box] + matrix_world = obj.matrix_world.copy() + bb_world = [matrix_world * Vector(v[:]) for v in obj.bound_box] - Left_Up_Front = bb_world[1] - Right_Down_Back = bb_world[7] + if bb_quality: + GBB = GlobalBB_HQ(obj) + else: + GBB = GlobalBB_LQ(bb_world) + + Left_Front_Up = GBB[0] + Right_Back_Down = GBB[1] - center_x = (Left_Up_Front[0] + Right_Down_Back[0]) / 2.0 - center_y = (Left_Up_Front[1] + Right_Down_Back[1]) / 2.0 - center_z = (Left_Up_Front[2] + Right_Down_Back[2]) / 2.0 + center_x = (Left_Front_Up[0] + Right_Back_Down[0]) / 2.0 + center_y = (Left_Front_Up[1] + Right_Back_Down[1]) / 2.0 + center_z = (Left_Front_Up[2] + Right_Back_Down[2]) / 2.0 - positive_x = Right_Down_Back[0] - positive_y = Right_Down_Back[1] - positive_z = Left_Up_Front[2] + positive_x = Right_Back_Down[0] + positive_y = Right_Back_Down[1] + positive_z = Left_Front_Up[2] - negative_x = Left_Up_Front[0] - negative_y = Left_Up_Front[1] - negative_z = Right_Down_Back[2] + negative_x = Left_Front_Up[0] + negative_y = Left_Front_Up[1] + negative_z = Right_Back_Down[2] obj_loc = obj.location @@ -229,7 +335,7 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to): return True -from bpy.props import EnumProperty +from bpy.props import EnumProperty, BoolProperty class AlignObjects(bpy.types.Operator): @@ -238,6 +344,11 @@ class AlignObjects(bpy.types.Operator): bl_label = _("Align Objects") bl_options = {'REGISTER', 'UNDO'} + bb_quality = BoolProperty( + name=_("High Quality"), + description=_("Enables high quality calculation of the bounding box for perfect results on complex shape meshes with rotation/scale (Slow)"), + default=True) + align_mode = EnumProperty(items=( ('OPT_1', "Negative Sides", ""), ('OPT_2', "Centers", ""), @@ -270,7 +381,12 @@ class AlignObjects(bpy.types.Operator): def execute(self, context): align_axis = self.align_axis - ret = align_objects('X' in align_axis, 'Y' in align_axis, 'Z' in align_axis, self.align_mode, self.relative_to) + ret = align_objects('X' in align_axis, + 'Y' in align_axis, + 'Z' in align_axis, + self.align_mode, + self.relative_to, + self.bb_quality) if not ret: self.report({'WARNING'}, "No objects with bound-box selected") diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index 074f204d50e..ba739648000 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -16,12 +16,17 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> from mathutils import Vector import bpy -from bpy.props import BoolProperty, EnumProperty, IntProperty, FloatProperty, FloatVectorProperty - +from bpy.props import (BoolProperty, + EnumProperty, + IntProperty, + FloatProperty, + FloatVectorProperty, + ) +from blf import gettext as _ def object_ensure_material(obj, mat_name): """ Use an existing material or add a new one. @@ -61,7 +66,8 @@ class QuickFur(bpy.types.Operator): def execute(self, context): fake_context = bpy.context.copy() - mesh_objects = [obj for obj in context.selected_objects if obj.type == 'MESH'] + mesh_objects = [obj for obj in context.selected_objects + if obj.type == 'MESH'] if not mesh_objects: self.report({'ERROR'}, "Select at least one mesh object.") @@ -92,7 +98,8 @@ class QuickFur(bpy.types.Operator): psys.settings.child_type = 'INTERPOLATED' obj.data.materials.append(mat) - obj.particle_systems[-1].settings.material = len(obj.data.materials) + obj.particle_systems[-1].settings.material = \ + len(obj.data.materials) return {'FINISHED'} @@ -149,7 +156,10 @@ class QuickExplode(bpy.types.Operator): for obj in mesh_objects: if obj.particle_systems: - self.report({'ERROR'}, "Object %r already has a particle system" % obj.name) + self.report({'ERROR'}, + "Object %r already has a " + "particle system" % obj.name) + return {'CANCELLED'} if self.fade: @@ -184,9 +194,7 @@ class QuickExplode(bpy.types.Operator): if self.fade: explode.show_dead = False - bpy.ops.mesh.uv_texture_add(fake_context) - uv = obj.data.uv_textures[-1] - uv.name = "Explode fade" + uv = obj.data.uv_textures.new("Explode fade") explode.particle_uv = uv.name mat = object_ensure_material(obj, "Explode Fade") @@ -247,7 +255,7 @@ class QuickExplode(bpy.types.Operator): def obj_bb_minmax(obj, min_co, max_co): for i in range(0, 8): - bb_vec = Vector(obj.bound_box[i]) * obj.matrix_world + bb_vec = obj.matrix_world * Vector(obj.bound_box[i]) min_co[0] = min(bb_vec[0], min_co[0]) min_co[1] = min(bb_vec[1], min_co[1]) @@ -262,21 +270,26 @@ class QuickSmoke(bpy.types.Operator): bl_label = "Quick Smoke" bl_options = {'REGISTER', 'UNDO'} - style = EnumProperty(items=( - ('STREAM', "Stream", ""), - ('PUFF', "Puff", ""), - ('FIRE', "Fire", "")), - name="Smoke Style", - description="", - default='STREAM') - - show_flows = BoolProperty(name="Render Smoke Objects", - description="Keep the smoke objects visible during rendering.", - default=False) + style = EnumProperty( + items=(('STREAM', "Stream", ""), + ('PUFF', "Puff", ""), + ('FIRE', "Fire", ""), + ), + name="Smoke Style", + description="", + default='STREAM', + ) + + show_flows = BoolProperty( + name=_("Render Smoke Objects"), + description=_("Keep the smoke objects visible during rendering."), + default=False, + ) def execute(self, context): fake_context = bpy.context.copy() - mesh_objects = [obj for obj in context.selected_objects if obj.type == 'MESH'] + mesh_objects = [obj for obj in context.selected_objects + if obj.type == 'MESH'] min_co = Vector((100000.0, 100000.0, 100000.0)) max_co = -min_co @@ -336,21 +349,25 @@ class QuickSmoke(bpy.types.Operator): mat.volume.density = 0 mat.volume.density_scale = 5 - mat.texture_slots.add() - mat.texture_slots[0].texture = bpy.data.textures.new("Smoke Density", 'VOXEL_DATA') - mat.texture_slots[0].texture.voxel_data.domain_object = obj - mat.texture_slots[0].use_map_color_emission = False - mat.texture_slots[0].use_map_density = True + tex = bpy.data.textures.new("Smoke Density", 'VOXEL_DATA') + tex.voxel_data.domain_object = obj + + tex_slot = mat.texture_slots.add() + tex_slot.texture = tex + tex_slot.use_map_color_emission = False + tex_slot.use_map_density = True # for fire add a second texture for emission and emission color if self.style == 'FIRE': mat.volume.emission = 5 - mat.texture_slots.add() - mat.texture_slots[1].texture = bpy.data.textures.new("Smoke Heat", 'VOXEL_DATA') - mat.texture_slots[1].texture.voxel_data.domain_object = obj - mat.texture_slots[1].texture.use_color_ramp = True + tex = bpy.data.textures.new("Smoke Heat", 'VOXEL_DATA') + tex.voxel_data.domain_object = obj + tex.use_color_ramp = True + + tex_slot = mat.texture_slots.add() + tex_slot.texture = tex - ramp = mat.texture_slots[1].texture.color_ramp + ramp = tex.color_ramp elem = ramp.elements.new(0.333) elem.color[0] = elem.color[3] = 1 @@ -371,28 +388,37 @@ class QuickFluid(bpy.types.Operator): bl_label = "Quick Fluid" bl_options = {'REGISTER', 'UNDO'} - style = EnumProperty(items=( - ('INFLOW', "Inflow", ""), - ('BASIC', "Basic", "")), + style = EnumProperty( + items=(('INFLOW', "Inflow", ""), + ('BASIC', "Basic", ""), + ), name="Fluid Style", description="", - default='BASIC') - - initial_velocity = FloatVectorProperty(name="Initial Velocity", - description="Initial velocity of the fluid", - default=(0.0, 0.0, 0.0), min=-100.0, max=100.0, subtype='VELOCITY') - - show_flows = BoolProperty(name="Render Fluid Objects", - description="Keep the fluid objects visible during rendering.", - default=False) - - start_baking = BoolProperty(name="Start Fluid Bake", - description="Start baking the fluid immediately after creating the domain object.", - default=False) + default='BASIC', + ) + initial_velocity = FloatVectorProperty( + name=_("Initial Velocity"), + description=_("Initial velocity of the fluid"), + default=(0.0, 0.0, 0.0), + min=-100.0, + max=100.0, + subtype='VELOCITY', + ) + show_flows = BoolProperty( + name=_("Render Fluid Objects"), + description=_("Keep the fluid objects visible during rendering."), + default=False, + ) + start_baking = BoolProperty( + name=_("Start Fluid Bake"), + description=_("Start baking the fluid immediately after creating the domain object"), + default=False, + ) def execute(self, context): fake_context = bpy.context.copy() - mesh_objects = [obj for obj in context.selected_objects if (obj.type == 'MESH' and not 0 in obj.dimensions)] + mesh_objects = [obj for obj in context.selected_objects + if (obj.type == 'MESH' and not 0.0 in obj.dimensions)] min_co = Vector((100000, 100000, 100000)) max_co = Vector((-100000, -100000, -100000)) @@ -405,7 +431,8 @@ class QuickFluid(bpy.types.Operator): # make each selected object a fluid bpy.ops.object.modifier_add(fake_context, type='FLUID_SIMULATION') - # fluid has to be before constructive modifiers, so it might not be the last modifier + # fluid has to be before constructive modifiers, + # so it might not be the last modifier for mod in obj.modifiers: if mod.type == 'FLUID_SIMULATION': break @@ -429,10 +456,14 @@ class QuickFluid(bpy.types.Operator): obj = context.active_object obj.name = "Fluid Domain" - # give the fluid some room below the flows and scale with initial velocity + # give the fluid some room below the flows + # and scale with initial velocity v = 0.5 * self.initial_velocity obj.location = 0.5 * (max_co + min_co) + Vector((0.0, 0.0, -1.0)) + v - obj.scale = 0.5 * (max_co - min_co) + Vector((1.0, 1.0, 2.0)) + Vector((abs(v[0]), abs(v[1]), abs(v[2]))) + obj.scale = (0.5 * (max_co - min_co) + + Vector((1.0, 1.0, 2.0)) + + Vector((abs(v[0]), abs(v[1]), abs(v[2]))) + ) # setup smoke domain bpy.ops.object.modifier_add(type='FLUID_SIMULATION') diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index d95a21cca81..acb988e147a 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> import bpy from blf import gettext as _ @@ -94,40 +94,67 @@ class RandomizeLocRotSize(bpy.types.Operator): bl_label = _("Randomize Transform") bl_options = {'REGISTER', 'UNDO'} - random_seed = IntProperty(name="Random Seed", - description="Seed value for the random generator", - default=0, min=0, max=1000) - - use_delta = BoolProperty(name="Transform Delta", - description="Randomize delta transform values instead of regular transform", default=False) - - use_loc = BoolProperty(name="Randomize Location", - description="Randomize the location values", default=True) - - loc = FloatVectorProperty(name="Location", - description="Maximun distance the objects can spread over each axis", - default=(0.0, 0.0, 0.0), min=-100.0, max=100.0, subtype='TRANSLATION') - - use_rot = BoolProperty(name="Randomize Rotation", - description="Randomize the rotation values", default=True) - - rot = FloatVectorProperty(name="Rotation", - description="Maximun rotation over each axis", - default=(0.0, 0.0, 0.0), min=-180.0, max=180.0, subtype='TRANSLATION') - - use_scale = BoolProperty(name="Randomize Scale", - description="Randomize the scale values", default=True) - - scale_even = BoolProperty(name="Scale Even", - description="Use the same scale value for all axis", default=False) + random_seed = IntProperty( + name=_("Random Seed"), + description=_("Seed value for the random generator"), + min=0, + max=1000, + default=0, + ) + use_delta = BoolProperty( + name=_("Transform Delta"), + description=_("Randomize delta transform values instead of regular transform"), + default=False, + ) + use_loc = BoolProperty( + name=_("Randomize Location"), + description=_("Randomize the location values"), + default=True, + ) + loc = FloatVectorProperty( + name=_("Location"), + description=_("Maximun distance the objects can spread over each axis"), + min=-100.0, + max=100.0, + default=(0.0, 0.0, 0.0), + subtype='TRANSLATION', + ) + use_rot = BoolProperty( + name=_("Randomize Rotation"), + description=_("Randomize the rotation values"), + default=True, + ) + rot = FloatVectorProperty( + name=_("Rotation"), + description=_("Maximun rotation over each axis"), + min=-180.0, + max=180.0, + default=(0.0, 0.0, 0.0), + subtype='TRANSLATION', + ) + use_scale = BoolProperty( + name=_("Randomize Scale"), + description=_("Randomize the scale values"), + default=True, + ) + scale_even = BoolProperty( + name=_("Scale Even"), + description=_("Use the same scale value for all axis"), + default=False, + ) '''scale_min = FloatProperty(name="Minimun Scale Factor", description="Lowest scale percentage possible", default=0.15, min=-1.0, max=1.0, precision=3)''' - scale = FloatVectorProperty(name="Scale", - description="Maximum scale randomization over each axis", - default=(0.0, 0.0, 0.0), min=-100.0, max=100.0, subtype='TRANSLATION') + scale = FloatVectorProperty( + name=_("Scale"), + description=_("Maximum scale randomization over each axis"), + min=-100.0, + max=100.0, + default=(0.0, 0.0, 0.0), + subtype='TRANSLATION', + ) def execute(self, context): from math import radians diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 6624c2ad288..31a6f421768 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> import bpy from blf import gettext as _ @@ -31,8 +31,15 @@ class AddPresetBase(): # bl_label = "Add a Python Preset" bl_options = {'REGISTER'} # only because invoke_props_popup requires. - name = bpy.props.StringProperty(name="Name", description="Name of the preset, used to make the path name", maxlen=64, default="") - remove_active = bpy.props.BoolProperty(default=False, options={'HIDDEN'}) + name = bpy.props.StringProperty( + name=_("Name"), + description=_("Name of the preset, used to make the path name"), + maxlen=64, + ) + remove_active = bpy.props.BoolProperty( + default=False, + options={'HIDDEN'}, + ) @staticmethod def as_filename(name): # could reuse for other presets @@ -55,7 +62,10 @@ class AddPresetBase(): filename = self.as_filename(name) - target_path = bpy.utils.user_resource('SCRIPTS', os.path.join("presets", self.preset_subdir), create=True) + target_path = os.path.join("presets", self.preset_subdir) + target_path = bpy.utils.user_resource('SCRIPTS', + target_path, + create=True) if not target_path: self.report({'WARNING'}, "Failed to create presets path") @@ -96,7 +106,9 @@ class AddPresetBase(): filepath = bpy.utils.preset_find(preset_active, self.preset_subdir) if not filepath: - filepath = bpy.utils.preset_find(preset_active, self.preset_subdir, display_name=True) + filepath = bpy.utils.preset_find(preset_active, + self.preset_subdir, + display_name=True) if not filepath: return {'CANCELLED'} @@ -132,10 +144,17 @@ class AddPresetBase(): class ExecutePreset(bpy.types.Operator): ''' Executes a preset ''' bl_idname = "script.execute_preset" - bl_label = "Execute a Python Preset" - - filepath = bpy.props.StringProperty(name="Path", description="Path of the Python file to execute", maxlen=512, default="") - menu_idname = bpy.props.StringProperty(name="Menu ID Name", description="ID name of the menu this was called from", default="") + bl_label = _("Execute a Python Preset") + + filepath = bpy.props.StringProperty( + name=_("Path"), + description=_("Path of the Python file to execute"), + maxlen=512, + ) + menu_idname = bpy.props.StringProperty( + name=_("Menu ID Name"), + description=_("ID name of the menu this was called from"), + ) def execute(self, context): from os.path import basename @@ -153,7 +172,7 @@ class ExecutePreset(bpy.types.Operator): class AddPresetRender(AddPresetBase, bpy.types.Operator): '''Add a Render Preset''' bl_idname = "render.preset_add" - bl_label = "Add Render Preset" + bl_label = _("Add Render Preset") preset_menu = "RENDER_MT_presets" preset_defines = [ @@ -179,11 +198,14 @@ class AddPresetRender(AddPresetBase, bpy.types.Operator): class AddPresetSSS(AddPresetBase, bpy.types.Operator): '''Add a Subsurface Scattering Preset''' bl_idname = "material.sss_preset_add" - bl_label = "Add SSS Preset" + bl_label = _("Add SSS Preset") preset_menu = "MATERIAL_MT_sss_presets" preset_defines = [ - "material = (bpy.context.material.active_node_material if bpy.context.material.active_node_material else bpy.context.material)" + ("material = " + "bpy.context.material.active_node_material " + "if bpy.context.material.active_node_material " + "else bpy.context.material") ] preset_values = [ @@ -204,7 +226,7 @@ class AddPresetSSS(AddPresetBase, bpy.types.Operator): class AddPresetCloth(AddPresetBase, bpy.types.Operator): '''Add a Cloth Preset''' bl_idname = "cloth.preset_add" - bl_label = "Add Cloth Preset" + bl_label = _("Add Cloth Preset") preset_menu = "CLOTH_MT_presets" preset_defines = [ @@ -226,7 +248,7 @@ class AddPresetCloth(AddPresetBase, bpy.types.Operator): class AddPresetSunSky(AddPresetBase, bpy.types.Operator): '''Add a Sky & Atmosphere Preset''' bl_idname = "lamp.sunsky_preset_add" - bl_label = "Add Sunsky Preset" + bl_label = _("Add Sunsky Preset") preset_menu = "LAMP_MT_sunsky_presets" preset_defines = [ @@ -282,7 +304,7 @@ class AddPresetInteraction(AddPresetBase, bpy.types.Operator): class AddPresetKeyconfig(AddPresetBase, bpy.types.Operator): '''Add a Keyconfig Preset''' bl_idname = "wm.keyconfig_preset_add" - bl_label = "Add Keyconfig Preset" + bl_label = _("Add Keyconfig Preset") preset_menu = "USERPREF_MT_keyconfigs" preset_subdir = "keyconfig" __doc__ = _('Add a Keyconfig Preset') @@ -310,7 +332,11 @@ class AddPresetOperator(AddPresetBase, bpy.types.Operator): preset_menu = "WM_MT_operator_presets" __doc__ = _("Add an Application Interaction Preset") - operator = bpy.props.StringProperty(name="Operator", maxlen=64, options={'HIDDEN'}) + operator = bpy.props.StringProperty( + name=_("Operator"), + maxlen=64, + options={'HIDDEN'}, + ) # XXX, not ideal preset_defines = [ @@ -326,12 +352,15 @@ class AddPresetOperator(AddPresetBase, bpy.types.Operator): properties_blacklist = bpy.types.Operator.bl_rna.properties.keys() prefix, suffix = self.operator.split("_OT_", 1) - operator_rna = getattr(getattr(bpy.ops, prefix.lower()), suffix).get_rna().bl_rna + op = getattr(getattr(bpy.ops, prefix.lower()), suffix) + operator_rna = op.get_rna().bl_rna + del op ret = [] for prop_id, prop in operator_rna.properties.items(): - if (not (prop.is_hidden or prop.is_skip_save)) and prop_id not in properties_blacklist: - ret.append("op.%s" % prop_id) + if not (prop.is_hidden or prop.is_skip_save): + if prop_id not in properties_blacklist: + ret.append("op.%s" % prop_id) return ret @@ -343,7 +372,7 @@ class AddPresetOperator(AddPresetBase, bpy.types.Operator): class WM_MT_operator_presets(bpy.types.Menu): - bl_label = "Operator Presets" + bl_label = _("Operator Presets") def draw(self, context): self.operator = context.space_data.operator.bl_idname diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index 2406cc59952..ba0b1da45d1 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -1,27 +1,23 @@ -# ***** BEGIN GPL LICENSE BLOCK ***** +# ##### BEGIN GPL LICENSE BLOCK ##### # -# Script copyright (C) Campbell J Barton +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# ***** END GPL LICENCE BLOCK ***** +# ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> -# History -# # Originally written by Matt Ebb import bpy @@ -47,8 +43,10 @@ def guess_player_path(preset): player_path = "djv_view" if sys.platform == "darwin": - # TODO, crummy supporting only 1 version, could find the newest installed version - test_path = '/Applications/djv-0.8.2.app/Contents/Resources/bin/djv_view' + # TODO, crummy supporting only 1 version, + # could find the newest installed version + test_path = ("/Applications/djv-0.8.2.app" + "/Contents/Resources/bin/djv_view") if os.path.exists(test_path): player_path = test_path @@ -61,6 +59,9 @@ def guess_player_path(preset): elif preset == 'MPLAYER': player_path = "mplayer" + else: + player_path = "" + return player_path @@ -84,10 +85,10 @@ class PlayRenderedAnim(bpy.types.Operator): is_movie = rd.is_movie_format # try and guess a command line if it doesn't exist - if player_path == '': + if player_path == "": player_path = guess_player_path(preset) - if is_movie == False and preset in ('FRAMECYCLER', 'RV', 'MPLAYER'): + if is_movie == False and preset in {'FRAMECYCLER', 'RV', 'MPLAYER'}: # replace the number with '#' file_a = rd.frame_path(frame=0) @@ -97,11 +98,11 @@ class PlayRenderedAnim(bpy.types.Operator): while len(file_a) == len(file_b): frame_tmp = (frame_tmp * 10) + 9 - print(frame_tmp) 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) @@ -111,10 +112,35 @@ class PlayRenderedAnim(bpy.types.Operator): cmd = [player_path] # extra options, fps controls etc. if preset == 'BLENDER24': + # ----------------------------------------------------------------- + # Check blender is not 2.5x until it supports playback again + try: + process = subprocess.Popen([player_path, '--version'], + stdout=subprocess.PIPE, + ) + except: + # ignore and allow the main execution to catch the problem. + process = None + + if process is not None: + process.wait() + out = process.stdout.read() + process.stdout.close() + out_split = out.strip().split() + if out_split[0] == b'Blender': + if not out_split[1].startswith(b'2.4'): + self.report({'ERROR'}, + "Blender %s doesn't support playback: %r" % + (out_split[1].decode(), player_path)) + return {'CANCELLED'} + del out, out_split + del process + # ----------------------------------------------------------------- + opts = ["-a", "-f", str(rd.fps), str(rd.fps_base), file] cmd.extend(opts) elif preset == 'DJV': - opts = [file, "-playback_speed", str(rd.fps)] + opts = [file, "-playback_speed", "%d" % int(rd.fps / rd.fps_base)] cmd.extend(opts) elif preset == 'FRAMECYCLER': opts = [file, "%d-%d" % (scene.frame_start, scene.frame_end)] @@ -127,18 +153,26 @@ class PlayRenderedAnim(bpy.types.Operator): if is_movie: opts.append(file) else: - opts.append("mf://%s" % file.replace("#", "?")) - opts += ["-mf", "fps=%.4f" % (rd.fps / rd.fps_base)] + opts += [("mf://%s" % file.replace("#", "?")), + "-mf", + "fps=%.4f" % (rd.fps / rd.fps_base), + ] + opts += ["-loop", "0", "-really-quiet", "-fs"] cmd.extend(opts) else: # 'CUSTOM' cmd.append(file) # launch it + print("Executing command:\n %r" % " ".join(cmd)) + try: process = subprocess.Popen(cmd) - except: - pass - #raise OSError("Couldn't find an external animation player.") + except Exception as e: + import traceback + self.report({'ERROR'}, + "Couldn't run external animation player with command " + "%r\n%s" % (" ".join(cmd), str(e))) + return {'CANCELLED'} return {'FINISHED'} diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 7ea89cfa479..851f33bde11 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -243,7 +243,7 @@ def testNewVecLs2DRotIsBetter(vecs, mat=-1, bestAreaSoFar = -1): # Do this allong the way if mat != -1: - v = vecs[i] = v*mat + v = vecs[i] = mat * v x= v.x y= v.y if x<minx: minx= x @@ -747,14 +747,8 @@ def packIslands(islandList): def VectoQuat(vec): - a3 = vec.normalized() - up = Vector((0.0, 0.0, 1.0)) - if abs(a3.dot(up)) == 1.0: - up = Vector((0.0, 1.0, 0.0)) - - a1 = a3.cross(up).normalized() - a2 = a3.cross(a1) - return Matrix((a1, a2, a3)).to_quaternion() + vec = vec.normalized() + return vec.to_track_quat('Z', 'X' if abs(vec.x) > 0.5 else 'Y').inverted() class thickface(object): @@ -1070,7 +1064,7 @@ def main(context, f_uv = f.uv for j, v in enumerate(f.v): # XXX - note, between mathutils in 2.4 and 2.5 the order changed. - f_uv[j][:] = (v.co * MatQuat).xy + f_uv[j][:] = (MatQuat * v.co).xy if USER_SHARE_SPACE: diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 00a2f546382..ae44860c3dd 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -773,7 +773,7 @@ class WM_OT_doc_edit(bpy.types.Operator): def draw(self, context): layout = self.layout - layout.label(text=_("Descriptor ID: '%s'") % self.doc_id) + layout.label(text=_("Descriptor ID")+": '%s'" % self.doc_id) layout.prop(self, "doc_new", text="") def invoke(self, context, event): diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index ce6d0990f05..0a4d0b60514 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -394,6 +394,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel): col.operator("object.multires_higher_levels_delete", text="Delete Higher") col.operator("object.multires_reshape", text="Reshape") col.operator("object.multires_base_apply", text="Apply Base") + col.prop(md, "use_subsurf_uv") col.prop(md, "show_only_control_edges") layout.separator() diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 45c15bd1ce6..2a52ae23782 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -174,6 +174,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, bpy.types.Panel): row.prop(mat, "use_transparency") sub = row.column() sub.prop(mat, "offset_z") + sub.active = mat_type and mat.use_transparency and mat.transparency_method == 'Z_TRANSPARENCY' row = layout.row() @@ -199,6 +200,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, bpy.types.Panel): col.prop(mat, "shadow_cast_alpha", text="Casting Alpha") col.prop(mat, "use_cast_buffer_shadows") col.prop(mat, "use_cast_approximate") + col.prop(mat, "pass_index") class MATERIAL_PT_diffuse(MaterialButtonsPanel, bpy.types.Panel): @@ -729,7 +731,8 @@ class MATERIAL_PT_options(MaterialButtonsPanel, bpy.types.Panel): col.prop(mat, "use_vertex_color_paint") col.prop(mat, "use_vertex_color_light") col.prop(mat, "use_object_color") - col.prop(mat, "pass_index") + if simple_material(base_mat): + col.prop(mat, "pass_index") class MATERIAL_PT_shadow(MaterialButtonsPanel, bpy.types.Panel): diff --git a/release/scripts/startup/bl_ui/properties_world.py b/release/scripts/startup/bl_ui/properties_world.py index 4f398c9fbd9..63f8e88147b 100644 --- a/release/scripts/startup/bl_ui/properties_world.py +++ b/release/scripts/startup/bl_ui/properties_world.py @@ -19,8 +19,7 @@ # <pep8 compliant> import bpy from rna_prop_ui import PropertyPanel - -# TODO, "color_range" not in the UI +from blf import gettext as _ class WorldButtonsPanel(): @@ -64,7 +63,7 @@ class WORLD_PT_context_world(WorldButtonsPanel, bpy.types.Panel): class WORLD_PT_preview(WorldButtonsPanel, bpy.types.Panel): - bl_label = "Preview" + bl_label = _("Preview") COMPAT_ENGINES = {'BLENDER_RENDER'} @classmethod @@ -77,7 +76,7 @@ class WORLD_PT_preview(WorldButtonsPanel, bpy.types.Panel): class WORLD_PT_world(WorldButtonsPanel, bpy.types.Panel): - bl_label = "World" + bl_label = _("World") COMPAT_ENGINES = {'BLENDER_RENDER'} def draw(self, context): @@ -95,10 +94,14 @@ class WORLD_PT_world(WorldButtonsPanel, bpy.types.Panel): col.prop(world, "zenith_color") col.active = world.use_sky_blend row.column().prop(world, "ambient_color") + + row = layout.row() + row.prop(world, "exposure") + row.prop(world, "color_range") class WORLD_PT_ambient_occlusion(WorldButtonsPanel, bpy.types.Panel): - bl_label = "Ambient Occlusion" + bl_label = _("Ambient Occlusion") COMPAT_ENGINES = {'BLENDER_RENDER'} def draw_header(self, context): @@ -112,12 +115,12 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel, bpy.types.Panel): layout.active = light.use_ambient_occlusion split = layout.split() - split.prop(light, "ao_factor", text="Factor") + split.prop(light, "ao_factor", text=_("Factor")) split.prop(light, "ao_blend_type", text="") class WORLD_PT_environment_lighting(WorldButtonsPanel, bpy.types.Panel): - bl_label = "Environment Lighting" + bl_label = _("Environment Lighting") COMPAT_ENGINES = {'BLENDER_RENDER'} def draw_header(self, context): @@ -131,12 +134,12 @@ class WORLD_PT_environment_lighting(WorldButtonsPanel, bpy.types.Panel): layout.active = light.use_environment_light split = layout.split() - split.prop(light, "environment_energy", text="Energy") + split.prop(light, "environment_energy", text=_("Energy")) split.prop(light, "environment_color", text="") class WORLD_PT_indirect_lighting(WorldButtonsPanel, bpy.types.Panel): - bl_label = "Indirect Lighting" + bl_label = _("Indirect Lighting") COMPAT_ENGINES = {'BLENDER_RENDER'} def draw_header(self, context): @@ -150,15 +153,15 @@ class WORLD_PT_indirect_lighting(WorldButtonsPanel, bpy.types.Panel): layout.active = light.use_indirect_light and light.gather_method == 'APPROXIMATE' split = layout.split() - split.prop(light, "indirect_factor", text="Factor") - split.prop(light, "indirect_bounces", text="Bounces") + split.prop(light, "indirect_factor", text=_("Factor")) + split.prop(light, "indirect_bounces", text=_("Bounces")) if light.gather_method == 'RAYTRACE': - layout.label(text="Only works with Approximate gather method") + layout.label(text=_("Only works with Approximate gather method")) class WORLD_PT_gather(WorldButtonsPanel, bpy.types.Panel): - bl_label = "Gather" + bl_label = _("Gather") COMPAT_ENGINES = {'BLENDER_RENDER'} def draw(self, context): @@ -172,18 +175,18 @@ class WORLD_PT_gather(WorldButtonsPanel, bpy.types.Panel): split = layout.split() col = split.column() - col.label(text="Attenuation:") + col.label(text=_("Attenuation:")) if light.gather_method == 'RAYTRACE': col.prop(light, "distance") col.prop(light, "use_falloff") sub = col.row() sub.active = light.use_falloff - sub.prop(light, "falloff_strength", text="Strength") + sub.prop(light, "falloff_strength", text=_("Strength")) if light.gather_method == 'RAYTRACE': col = split.column() - col.label(text="Sampling:") + col.label(text=_("Sampling:")) col.prop(light, "sample_method", text="") sub = col.column() @@ -198,15 +201,15 @@ class WORLD_PT_gather(WorldButtonsPanel, bpy.types.Panel): if light.gather_method == 'APPROXIMATE': col = split.column() - col.label(text="Sampling:") + col.label(text=_("Sampling:")) col.prop(light, "passes") - col.prop(light, "error_threshold", text="Error") + col.prop(light, "error_threshold", text=_("Error")) col.prop(light, "use_cache") col.prop(light, "correction") class WORLD_PT_mist(WorldButtonsPanel, bpy.types.Panel): - bl_label = "Mist" + bl_label = _("Mist") bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -235,7 +238,7 @@ class WORLD_PT_mist(WorldButtonsPanel, bpy.types.Panel): class WORLD_PT_stars(WorldButtonsPanel, bpy.types.Panel): - bl_label = "Stars" + bl_label = _("Stars") bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER'} @@ -254,11 +257,11 @@ class WORLD_PT_stars(WorldButtonsPanel, bpy.types.Panel): col = split.column() col.prop(world.star_settings, "size") - col.prop(world.star_settings, "color_random", text="Colors") + col.prop(world.star_settings, "color_random", text=_("Colors")) col = split.column() - col.prop(world.star_settings, "distance_min", text="Min. Dist") - col.prop(world.star_settings, "average_separation", text="Separation") + col.prop(world.star_settings, "distance_min", text=_("Min. Dist")) + col.prop(world.star_settings, "average_separation", text=_("Separation")) class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, bpy.types.Panel): diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 6e0eded1d4c..15ba638dffb 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -64,7 +64,7 @@ class IMAGE_MT_view(bpy.types.Menu): ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]] for a, b in ratios: - text = _("Zoom %d:%d") % (a, b) + text = _("Zoom") + " %d:%d" % (a, b) layout.operator("image.view_zoom_ratio", text=text).ratio = a / b layout.separator() @@ -199,6 +199,10 @@ class IMAGE_MT_uvs_transform(bpy.types.Menu): layout.operator("transform.rotate") layout.operator("transform.resize") + layout.separator() + + layout.operator("transform.shear") + class IMAGE_MT_uvs_snap(bpy.types.Menu): bl_label = _("Snap") diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 4254ec3c9ab..fadd3ec73be 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -61,8 +61,10 @@ class INFO_HT_header(bpy.types.Header): layout.template_running_jobs() layout.template_reports_banner() - - layout.label(text=scene.statistics()) + + row = layout.row(align=True) + row.operator("wm.splash", text="", icon='BLENDER', emboss=False) + row.label(text=scene.statistics()) # XXX: this should be right-aligned to the RHS of the region layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER', text="") diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index e7276b82aba..1f9d45e9bc4 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -358,13 +358,13 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, bpy.types.Panel): col = layout.column(align=True) row = col.row() - row.label(text=_("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration)) + row.label(text=_("Final Length")+": %s" % bpy.utils.smpte_from_frame(strip.frame_final_duration)) row = col.row() row.active = (frame_current >= strip.frame_start and frame_current <= strip.frame_start + strip.frame_duration) - row.label(text=_("Playhead: %d") % (frame_current - strip.frame_start)) + row.label(text=_("Playhead")+": %d" % (frame_current - strip.frame_start)) - col.label(text=_("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end)) - col.label(text=_("Frame Still %d:%d") % (strip.frame_still_start, strip.frame_still_end)) + col.label(text=_("Frame Offset")+" %d:%d" % (strip.frame_offset_start, strip.frame_offset_end)) + col.label(text=_("Frame Still")+" %d:%d" % (strip.frame_still_start, strip.frame_still_end)) elem = False @@ -374,7 +374,7 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, bpy.types.Panel): elem = strip.elements[0] if elem and elem.orig_width > 0 and elem.orig_height > 0: - col.label(text=_("Orig Dim: %dx%d") % (elem.orig_width, elem.orig_height)) + col.label(text=_("Orig Dim")+": %dx%d" % (elem.orig_width, elem.orig_height)) class SEQUENCER_PT_effect(SequencerButtonsPanel, bpy.types.Panel): @@ -668,7 +668,7 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel, bpy.types.Panel): if scene: sta = scene.frame_start end = scene.frame_end - layout.label(text=_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1)) + layout.label(text=_("Original frame range")+": %d-%d (%d)" % (sta, end, end - sta + 1)) class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel): diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index 0c3da2f5e1b..93e513acf0a 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8 compliant> +# <pep8-80 compliant> import bpy from blf import gettext as _ @@ -34,19 +34,21 @@ class TEXT_HT_header(bpy.types.Header): row.template_header() if context.area.show_menus: - sub = row.row(align=True) - sub.menu("TEXT_MT_view") - sub.menu("TEXT_MT_text") + row.menu("TEXT_MT_view") + row.menu("TEXT_MT_text") + if text: - sub.menu("TEXT_MT_edit") - sub.menu("TEXT_MT_format") + row.menu("TEXT_MT_edit") + row.menu("TEXT_MT_format") + + row.menu("TEXT_MT_templates") if text and text.is_modified: - row = layout.row() - row.alert = True - row.operator("text.resolve_conflict", text="", icon='HELP') + sub = row.row() + sub.alert = True + sub.operator("text.resolve_conflict", text="", icon='HELP') - layout.template_ID(st, "text", new="text.new", unlink="text.unlink") + row.template_ID(st, "text", new="text.new", unlink="text.unlink") row = layout.row(align=True) row.prop(st, "show_line_numbers", text="") @@ -64,11 +66,13 @@ class TEXT_HT_header(bpy.types.Header): row = layout.row() if text.filepath: if text.is_dirty: - row.label(text="File: *%s (unsaved)" % text.filepath) + row.label(text=_("File")+": *%r " % text.filepath+_("(unsaved)")) else: - row.label(text="File: %s" % text.filepath) + row.label(text=_("File")+": %r" % text.filepath) else: - row.label(text="Text: External" if text.library else "Text: Internal") + row.label(text=_("Text: External") + if text.library + else _("Text: Internal")) class TEXT_PT_properties(bpy.types.Panel): @@ -151,8 +155,12 @@ class TEXT_MT_view(bpy.types.Menu): layout.separator() - layout.operator("text.move", text=_("Top of File")).type = 'FILE_TOP' - layout.operator("text.move", text=_("Bottom of File")).type = 'FILE_BOTTOM' + layout.operator("text.move", + text=_("Top of File"), + ).type = 'FILE_TOP' + layout.operator("text.move", + text=_("Bottom of File"), + ).type = 'FILE_BOTTOM' class TEXT_MT_text(bpy.types.Menu): @@ -186,19 +194,15 @@ class TEXT_MT_text(bpy.types.Menu): # XXX uiMenuItemO(head, 0, "text.refresh_pyconstraints"); #endif - layout.separator() - - layout.menu("TEXT_MT_templates") - class TEXT_MT_templates(bpy.types.Menu): - ''' - Creates the menu items by scanning scripts/templates - ''' - bl_label = _("Script Templates") + bl_label = _("Templates") def draw(self, context): - self.path_menu(bpy.utils.script_paths("templates"), "text.open", {"internal": True}) + self.path_menu(bpy.utils.script_paths("templates"), + "text.open", + {"internal": True}, + ) class TEXT_MT_edit_select(bpy.types.Menu): @@ -247,8 +251,12 @@ class TEXT_MT_edit_to3d(bpy.types.Menu): def draw(self, context): layout = self.layout - layout.operator("text.to_3d_object", text=_("One Object")).split_lines = False - layout.operator("text.to_3d_object", text=_("One Object Per Line")).split_lines = True + layout.operator("text.to_3d_object", + text=_("One Object"), + ).split_lines = False + layout.operator("text.to_3d_object", + text=_("One Object Per Line"), + ).split_lines = True class TEXT_MT_edit(bpy.types.Menu): diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 900d38d1693..fb5f2de7115 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -355,7 +355,7 @@ class USERPREF_PT_edit(bpy.types.Panel): col.prop(edit, "use_duplicate_lamp", text=_("Lamp")) col.prop(edit, "use_duplicate_material", text=_("Material")) col.prop(edit, "use_duplicate_texture", text=_("Texture")) - #col.prop(edit, "use_duplicate_fcurve", text="F-Curve") + #col.prop(edit, "use_duplicate_fcurve", text=_("F-Curve")) col.prop(edit, "use_duplicate_action", text=_("Action")) col.prop(edit, "use_duplicate_particle", text=_("Particle")) @@ -656,7 +656,7 @@ class USERPREF_PT_theme(bpy.types.Panel): col = split.column() for i, ui in enumerate(theme.bone_color_sets): - col.label(text=_("Color Set %d:") % (i + 1)) # i starts from 0 + col.label(text=_("Color Set")+" %d:" % (i + 1)) # i starts from 0 row = col.row() @@ -889,6 +889,16 @@ class USERPREF_PT_addons(bpy.types.Panel): return True return False + @staticmethod + def draw_error(layout, message): + lines = message.split("\n") + box = layout.box() + rowsub = box.row() + rowsub.label(lines[0]) + rowsub.label(icon='ERROR') + for l in lines[1:]: + box.label(l) + def draw(self, context): layout = self.layout @@ -909,6 +919,14 @@ class USERPREF_PT_addons(bpy.types.Panel): col = split.column() + # set in addon_utils.modules(...) + if addon_utils.error_duplicates: + self.draw_error(col, + "Multiple addons using the same name found!\n" + "likely a problem with the script search path.\n" + "(see console for details)", + ) + filter = context.window_manager.addon_filter search = context.window_manager.addon_search.lower() support = context.window_manager.addon_support diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index feb90cadd68..fde11a0ac29 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -202,7 +202,7 @@ class InputKeyMapPanel: subcol = self.indented_layout(col, level + 1) subrow = subcol.row() subrow.prop(km, "show_expanded_items", text="", emboss=False) - subrow.label(text=_("%s (Global)") % _(km.name) ) + subrow.label(text="%s " % _(km.name) + _("(Global)") ) else: km.show_expanded_items = True diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 9ead8bb98df..b4adc3bf028 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -55,21 +55,13 @@ class VIEW3D_HT_header(bpy.types.Header): sub.menu("VIEW3D_MT_object") row = layout.row() - row.template_header_3D() - - # do in C for now since these buttons cant be both toggle AND exclusive. - ''' - if obj and obj.mode == 'EDIT' and obj.type == 'MESH': - row_sub = row.row(align=True) - row_sub.prop(toolsettings, "mesh_select_mode", text="", index=0, icon='VERTEXSEL') - row_sub.prop(toolsettings, "mesh_select_mode", text="", index=1, icon='EDGESEL') - row_sub.prop(toolsettings, "mesh_select_mode", text="", index=2, icon='FACESEL') - ''' + # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode... + row.template_header_3D() if obj: # Particle edit if obj.mode == 'PARTICLE_EDIT': - row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True, toggle=True) + row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True) # Occlude geometry if view.viewport_shade in {'SOLID', 'SHADED', 'TEXTURED'} and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')): @@ -88,19 +80,22 @@ class VIEW3D_HT_header(bpy.types.Header): row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True) # Snap + snap_element = toolsettings.snap_element row = layout.row(align=True) row.prop(toolsettings, "use_snap", text="") row.prop(toolsettings, "snap_element", text="", icon_only=True) - if toolsettings.snap_element != 'INCREMENT': + if snap_element != 'INCREMENT': row.prop(toolsettings, "snap_target", text="") - if obj and obj.mode == 'OBJECT': - row.prop(toolsettings, "use_snap_align_rotation", text="") - if toolsettings.snap_element == 'VOLUME': + if obj: + if obj.mode == 'OBJECT': + row.prop(toolsettings, "use_snap_align_rotation", text="") + elif obj.mode == 'EDIT': + row.prop(toolsettings, "use_snap_self", text="") + + if snap_element == 'VOLUME': row.prop(toolsettings, "use_snap_peel_object", text="") - elif toolsettings.snap_element == 'FACE': + elif snap_element == 'FACE': row.prop(toolsettings, "use_snap_project", text="") - if toolsettings.use_snap_project and obj.mode == 'EDIT': - row.prop(toolsettings, "use_snap_project_self", text="") # OpenGL render row = layout.row(align=True) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index f2370ec39ac..d029de3786c 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -117,7 +117,8 @@ class VIEW3D_PT_tools_meshedit(View3DPanel, bpy.types.Panel): col.operator("transform.translate") col.operator("transform.rotate") col.operator("transform.resize", text="Scale") - col.operator("transform.shrink_fatten", text="Along Normal") + col.operator("transform.shrink_fatten", text=_("Shrink/Fatten")) + col.operator("transform.push_pull", text=_("Push/Pull")) col = layout.column(align=True) col.label(text="Deform:") diff --git a/release/scripts/templates/batch_export.py b/release/scripts/templates/batch_export.py new file mode 100755 index 00000000000..aa0e601725b --- /dev/null +++ b/release/scripts/templates/batch_export.py @@ -0,0 +1,33 @@ +# exports each selected object into its own file + +import bpy +import os + +# export to blend file location +basedir = os.path.dirname(bpy.data.filepath) + +if not basedir: + raise Exception("Blend file is not saved") + +selection = bpy.context.selected_objects + +bpy.ops.object.select_all(action='DESELECT') + +for obj in selection: + + obj.select = True + + name = bpy.path.clean_name(obj.name) + fn = os.path.join(basedir, name) + + bpy.ops.export_scene.fbx(filepath=fn + ".fbx", use_selection=True) + + ## Can be used for multiple formats + # bpy.ops.export_scene.x3d(filepath=fn + ".x3d", use_selection=True) + + obj.select = False + + print("written:", fn) + +for obj in selection: + obj.select = True diff --git a/release/scripts/templates/ui_menu.py b/release/scripts/templates/ui_menu.py new file mode 100755 index 00000000000..d3923b5b083 --- /dev/null +++ b/release/scripts/templates/ui_menu.py @@ -0,0 +1,49 @@ +import bpy + + +class CustomMenu(bpy.types.Menu): + bl_label = "Custom Menu" + bl_idname = "OBJECT_MT_custom_menu" + + def draw(self, context): + layout = self.layout + + layout.operator("wm.open_mainfile") + layout.operator("wm.save_as_mainfile").copy = True + + layout.operator("object.shade_smooth") + + layout.label(text="Hello world!", icon='WORLD_DATA') + + # use an operator enum property to populate a submenu + layout.operator_menu_enum("object.select_by_type", + property="type", + text="Select All by Type...", + ) + + # call another menu + layout.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map" + + +def draw_item(self, context): + layout = self.layout + layout.menu(CustomMenu.bl_idname) + + +def register(): + bpy.utils.register_class(CustomMenu) + + # lets add ourselves to the main header + bpy.types.INFO_HT_header.append(draw_item) + + +def unregister(): + bpy.utils.unregister_class(CustomMenu) + + bpy.types.INFO_HT_header.remove(draw_item) + +if __name__ == "__main__": + register() + + # The menu can also be called from scripts + bpy.ops.wm.call_menu(name=CustomMenu.bl_idname) diff --git a/release/scripts/templates/ui_menu_simple.py b/release/scripts/templates/ui_menu_simple.py new file mode 100755 index 00000000000..2129dfd81a4 --- /dev/null +++ b/release/scripts/templates/ui_menu_simple.py @@ -0,0 +1,26 @@ +import bpy + + +class SimpleCustomMenu(bpy.types.Menu): + bl_label = "Simple Custom Menu" + bl_idname = "OBJECT_MT_simple_custom_menu" + + def draw(self, context): + layout = self.layout + + layout.operator("wm.open_mainfile") + layout.operator("wm.save_as_mainfile") + + +def register(): + bpy.utils.register_class(SimpleCustomMenu) + + +def unregister(): + bpy.utils.unregister_class(SimpleCustomMenu) + +if __name__ == "__main__": + register() + + # The menu can also be called from scripts + bpy.ops.wm.call_menu(name=SimpleCustomMenu.bl_idname) diff --git a/release/scripts/templates/panel_simple.py b/release/scripts/templates/ui_panel_simple.py index e5bf70cb654..cde6126b626 100644..100755 --- a/release/scripts/templates/panel_simple.py +++ b/release/scripts/templates/ui_panel_simple.py @@ -1,8 +1,9 @@ import bpy -class OBJECT_PT_hello(bpy.types.Panel): +class HelloWorldPanel(bpy.types.Panel): bl_label = "Hello World Panel" + bl_idname = "OBJECT_PT_hello" bl_space_type = "PROPERTIES" bl_region_type = "WINDOW" bl_context = "object" @@ -22,11 +23,11 @@ class OBJECT_PT_hello(bpy.types.Panel): def register(): - bpy.utils.register_class(OBJECT_PT_hello) + bpy.utils.register_class(HelloWorldPanel) def unregister(): - bpy.utils.unregister_class(OBJECT_PT_hello) + bpy.utils.unregister_class(HelloWorldPanel) if __name__ == "__main__": diff --git a/source/blender/avi/CMakeLists.txt b/source/blender/avi/CMakeLists.txt index bae61fd678b..0fd6435ec4e 100644 --- a/source/blender/avi/CMakeLists.txt +++ b/source/blender/avi/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC . - ../../../intern/guardedalloc ../blenlib + ../../../intern/guardedalloc ) set(INC_SYS diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index 118a081bf69..cc677d39b10 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -24,10 +24,10 @@ set(INC . + ../blenkernel ../blenlib - ../makesdna ../editors/include - ../blenkernel + ../makesdna ../../../intern/guardedalloc ) @@ -51,7 +51,9 @@ set(SRC ) if(WITH_INTERNATIONAL) - list(APPEND INC_SYS ${GETTEXT_INC}) + list(APPEND INC_SYS + ${GETTEXT_INC} + ) add_definitions(-DINTERNATIONAL) endif() diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 25fb6f9f9ff..18f6ad21333 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -53,7 +53,7 @@ extern "C" { /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR a /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE release +#define BLENDER_VERSION_CYCLE beta struct ListBase; struct MemFile; diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h index 97ac711651b..12f9383cefb 100644 --- a/source/blender/blenkernel/BKE_effect.h +++ b/source/blender/blenkernel/BKE_effect.h @@ -105,6 +105,7 @@ typedef struct EffectorCache { /* precalculated for guides */ struct GuideEffectorData *guide_data; float guide_loc[4], guide_dir[3], guide_radius; + float velocity[3]; float frame; int flag; diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 92c50242e74..defcef58463 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -32,8 +32,10 @@ endif() set(INC . ../avi + ../blenfont ../blenlib ../blenloader + ../editors/include ../gpu ../ikplugin ../imbuf @@ -41,18 +43,19 @@ set(INC ../makesrna ../modifiers ../nodes - ../editors/include ../render/extern/include - ../../../intern/bsp/extern ../blenfont + ../../../intern/bsp/extern ../../../intern/decimation/extern ../../../intern/elbeem/extern ../../../intern/guardedalloc ../../../intern/iksolver/extern ../../../intern/memutil + ../../../intern/mikktspace ../../../intern/opennl/extern ../../../intern/smoke/extern - ../../../intern/mikktspace - ../../../source/blender/windowmanager # XXX - BAD LEVEL CALL WM_api.h + + # XXX - BAD LEVEL CALL WM_api.h + ../windowmanager ) set(INC_SYS @@ -243,12 +246,16 @@ if(WITH_AUDASPACE) endif() if(WITH_BULLET) - list(APPEND INC ../../../extern/bullet2/src) + list(APPEND INC + ../../../extern/bullet2/src + ) add_definitions(-DUSE_BULLET) endif() if(WITH_MOD_CLOTH_ELTOPO) - list(APPEND INC ../../../extern/eltopo) + list(APPEND INC + ../../../extern/eltopo + ) add_definitions(-DWITH_ELTOPO) endif() @@ -272,25 +279,41 @@ if(WITH_IMAGE_CINEON) add_definitions(-DWITH_CINEON) endif() +if(WITH_IMAGE_FRAMESERVER) + add_definitions(-DWITH_FRAMESERVER) +endif() + if(WITH_IMAGE_HDR) add_definitions(-DWITH_HDR) endif() if(WITH_CODEC_QUICKTIME) - list(APPEND INC ../quicktime) - list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS}) + list(APPEND INC + ../quicktime + ) + list(APPEND INC_SYS + ${QUICKTIME_INCLUDE_DIRS} + ) add_definitions(-DWITH_QUICKTIME) endif() if(WITH_CODEC_FFMPEG) - list(APPEND INC ../../../intern/ffmpeg) - list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS}) + list(APPEND INC + ../../../intern/ffmpeg + ) + list(APPEND INC_SYS + ${FFMPEG_INCLUDE_DIRS} + ) add_definitions(-DWITH_FFMPEG) endif() if(WITH_PYTHON) - list(APPEND INC ../python) - list(APPEND INC_SYS ${PYTHON_INCLUDE_DIRS}) + list(APPEND INC + ../python + ) + list(APPEND INC_SYS + ${PYTHON_INCLUDE_DIRS} + ) add_definitions(-DWITH_PYTHON) if(WITH_PYTHON_SECURITY) @@ -315,12 +338,16 @@ if(WITH_JACK) endif() if(WITH_LZO) - list(APPEND INC_SYS ../../../extern/lzo/minilzo) + list(APPEND INC_SYS + ../../../extern/lzo/minilzo + ) add_definitions(-DWITH_LZO) endif() if(WITH_LZMA) - list(APPEND INC_SYS ../../../extern/lzma) + list(APPEND INC_SYS + ../../../extern/lzma + ) add_definitions(-DWITH_LZMA) endif() diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 36afce7946c..5ea42ee65ae 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -22,6 +22,7 @@ incs += ' ' + env['BF_ZLIB_INC'] defs = [ 'GLEW_STATIC' ] defs.append('WITH_SMOKE') # TODO, make optional +defs.append('WITH_FRAMESERVER') # TODO, make optional if env['WITH_BF_PYTHON']: incs += ' ../python' diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 3abfa05e1fd..662c872b7f1 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1287,6 +1287,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); offset += sizeof(float)*4; } + (void)offset; } curface++; if(mface->v4) { @@ -1327,6 +1328,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); offset += sizeof(float)*4; } + (void)offset; } curface++; i++; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 45faba8439c..8d19322c0db 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -466,7 +466,6 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights), MDisps tris[2]; int vindex[4] = {0}; - S = 0; for(i = 0; i < 2; i++) for(y = 0; y < 4; y++) for(x = 0; x < 4; x++) diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index ee46bef6038..4b95c44f55f 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -241,6 +241,16 @@ static void precalculate_effector(EffectorCache *eff) } else if(eff->psys) psys_update_particle_tree(eff->psys, eff->scene->r.cfra); + + /* Store object velocity */ + if(eff->ob) { + float old_vel[3]; + + where_is_object_time(eff->scene, eff->ob, cfra - 1.0f); + copy_v3_v3(old_vel, eff->ob->obmat[3]); + where_is_object_time(eff->scene, eff->ob, cfra); + sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel); + } } static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd) { @@ -680,10 +690,6 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin Object *ob = eff->ob; Object obcopy = *ob; - /* XXX this is not thread-safe, but used from multiple threads by - particle system */ - where_is_object_time(eff->scene, ob, cfra); - /* use z-axis as normal*/ normalize_v3_v3(efd->nor, ob->obmat[2]); @@ -702,13 +708,8 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin VECCOPY(efd->loc, ob->obmat[3]); } - if(real_velocity) { - VECCOPY(efd->vel, ob->obmat[3]); - - where_is_object_time(eff->scene, ob, cfra - 1.0f); - - sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]); - } + if(real_velocity) + copy_v3_v3(efd->vel, eff->velocity); *eff->ob = obcopy; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index c48497c45a1..ab67d7e3f25 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -432,6 +432,7 @@ Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *n ima->gen_x= width; ima->gen_y= height; ima->gen_type= uvtestgrid; + ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0); ibuf= add_ibuf_size(width, height, name, depth, floatbuf, uvtestgrid, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); @@ -2172,7 +2173,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) /* UV testgrid or black or solid etc */ if(ima->gen_x==0) ima->gen_x= 1024; if(ima->gen_y==0) ima->gen_y= 1024; - ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, 0, ima->gen_type, color); + ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); ima->ok= IMA_OK_LOADED; } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 962c7fd5e86..3f01c55e935 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -550,7 +550,7 @@ Material *material_pop_id(ID *id, int index) Material **mat; if(index + 1 != (*totcol)) - memmove((*matar), (*matar) + 1, sizeof(void *) * ((*totcol) - (index + 1))); + memmove((*matar)+index, (*matar)+(index+1), sizeof(void *) * ((*totcol) - (index + 1))); (*totcol)--; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index d833c184274..88a670ecb22 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -465,12 +465,13 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv return multires_dm_create_from_derived(&mmd, 1, dm, ob, 0, 0); } -static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal) +static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv) { SubsurfModifierData smd= {{NULL}}; smd.levels = smd.renderLevels = lvl; - smd.flags |= eSubsurfModifierFlag_SubsurfUv; + if(!plain_uv) + smd.flags |= eSubsurfModifierFlag_SubsurfUv; if(simple) smd.subdivType = ME_SIMPLE_SUBSURF; if(optimal) @@ -591,7 +592,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) /* subdivide the mesh to highest level without displacements */ cddm = CDDM_from_mesh(me, NULL); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0); + origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0, mmd->flags & eMultiresModifierFlag_PlainUv); cddm->release(cddm); /* calc disps */ @@ -626,7 +627,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl /* create subsurf DM from original mesh at high level */ cddm = CDDM_from_mesh(me, NULL); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0); + highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv); /* create multires DM from original mesh at low level */ lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple); @@ -830,7 +831,7 @@ static void multiresModifier_update(DerivedMesh *dm) else cddm = CDDM_from_mesh(me, NULL); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0); + highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv); /* create multires DM from original mesh and displacements */ lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple); @@ -884,7 +885,7 @@ static void multiresModifier_update(DerivedMesh *dm) else cddm = CDDM_from_mesh(me, NULL); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0); + subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv); cddm->release(cddm); multiresModifier_disp_run(dm, me, 1, 0, subdm->getGridData(subdm), mmd->totlvl); @@ -927,7 +928,8 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca return dm; result = subsurf_dm_create_local(ob, dm, lvl, - mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges); + mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, + mmd->flags & eMultiresModifierFlag_PlainUv); if(!local_mmd) { ccgdm = (CCGDerivedMesh*)result; @@ -1633,7 +1635,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) MEM_freeN(vertCos); /* scaled ccgDM for tangent space of object with applied scale */ - dm= subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0); + dm= subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv); cddm->release(cddm); /*numGrids= dm->getNumGrids(dm);*/ /*UNUSED*/ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 63a9c224971..1423f520b95 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3987,7 +3987,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) BKE_ptcache_id_time(pid, sim->scene, 0.0f, &startframe, &endframe, NULL); /* clear everythin on start frame */ - if((int)cfra == startframe) { + if(cfra == startframe) { BKE_ptcache_id_reset(sim->scene, pid, PTCACHE_RESET_OUTDATED); BKE_ptcache_validate(cache, startframe); cache->flag &= ~PTCACHE_REDO_NEEDED; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index fbb5a77fa04..8c19b0c15c3 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2373,7 +2373,7 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, /* Blancmange (bmange@airdmhor.gen.nz) */ k = -1.0f/(2.0f*(float)M_PI*blur*blur); - fval=0; + for (ix = 0;ix< halfWidth;ix++){ weight = (float)exp(k*(ix*ix)); filter[halfWidth - ix] = weight; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 265cc3eeb79..d6a152a5280 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3232,9 +3232,10 @@ int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str) { char name[sizeof(seq_a->name)]; - if(seq_a->len != seq_b->len) + if(seq_a->len != seq_b->len) { *error_str= "Strips must be the same length"; return 0; + } /* type checking, could be more advanced but disalow sound vs non-sound copy */ if(seq_a->type != seq_b->type) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index da329503c9f..2c507370288 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -400,7 +400,13 @@ Text *add_text(const char *file, const char *relpath) llen++; } - if (llen!=0 || ta->nlines==0) { + /* create new line in cases: + - rest of line (if last line in file hasn't got \n terminator). + in this case content of such line would be used to fill text line buffer + - file is empty. in this case new line is needed to start editing from. + - last characted in buffer is \n. in this case new line is needed to + deal with newline at end of file. (see [#28087]) (sergey) */ + if (llen!=0 || ta->nlines==0 || buffer[len-1]=='\n') { tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline"); tmp->line= (char*) MEM_mallocN(llen+1, "textline_string"); tmp->format= NULL; @@ -1417,6 +1423,8 @@ void txt_insert_buf(Text *text, const char *in_buffer) } undoing= u; + + (void)count; } /******************/ diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index ba7f9bdd415..769a3f9b11e 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -105,13 +105,18 @@ bMovieHandle *BKE_get_movie_handle(int imtype) mh.get_movie_path = filepath_ffmpeg; } #endif +#ifdef WITH_FRAMESERVER if (imtype == R_FRAMESERVER) { mh.start_movie = start_frameserver; mh.append_movie = append_frameserver; mh.end_movie = end_frameserver; mh.get_next_frame = frameserver_loop; } - +#endif + + /* incase all above are disabled */ + (void)imtype; + return &mh; } diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 2239f6d3147..d13d15d1269 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -22,6 +22,7 @@ * */ +#ifdef WITH_FRAMESERVER #include <string.h> #include <stdio.h> @@ -381,3 +382,4 @@ void end_frameserver(void) shutdown_socket_system(); } +#endif /* WITH_FRAMESERVER */ diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 3b27e4dafa0..81fc8a50db6 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -98,7 +98,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check); #endif void BLI_setenv(const char *env, const char *val); -char *BLI_getenv(const char *env); void BLI_setenv_if_new(const char *env, const char* val); void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file); diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 2e05ac7892b..b4fc983008c 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -26,10 +26,10 @@ set(INC . - ../makesdna ../blenkernel ../blenloader ../gpu + ../makesdna ../../../intern/ghost ../../../intern/guardedalloc ) @@ -138,7 +138,9 @@ set(SRC ) if(WITH_BINRELOC) - list(APPEND INC_SYS "${BINRELOC_INCLUDE_DIRS}") + list(APPEND INC_SYS + ${BINRELOC_INCLUDE_DIRS} + ) add_definitions(-DWITH_BINRELOC) endif() diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 8eab5539390..f89283178ec 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1172,10 +1172,6 @@ void BLI_setenv(const char *env, const char*val) #endif } -char *BLI_getenv(const char *env) -{ - return getenv(env); -} /** Only set an env var if already not there. @@ -1684,7 +1680,7 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name) if(GetModuleFileName(0, fullname, maxlen)) { if(!BLI_exists(fullname)) { printf("path can't be found: \"%.*s\"\n", maxlen, fullname); - MessageBox(NULL, "path constains invalid characters or is too long (see console)", "Error", MB_OK); + MessageBox(NULL, "path contains invalid characters or is too long (see console)", "Error", MB_OK); } return; } diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 312a6546e22..be15b191c8a 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC . - ../blenlib ../blenkernel + ../blenlib ../makesdna ../makesrna ../render/extern/include diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2402106306e..4ad99c02b2d 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -75,6 +75,7 @@ #include "DNA_node_types.h" #include "DNA_object_fluidsim.h" // NT #include "DNA_packedFile_types.h" +#include "DNA_particle_types.h" #include "DNA_property_types.h" #include "DNA_text_types.h" #include "DNA_view3d_types.h" @@ -3161,9 +3162,37 @@ static void lib_link_particlesettings(FileData *fd, Main *main) if(part->effector_weights) part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group); - dw = part->dupliweights.first; - for(; dw; dw=dw->next) - dw->ob = newlibadr(fd, part->id.lib, dw->ob); + if(part->dupliweights.first) { + int index_ok = 0; + /* check for old files without indices (all indexes 0) */ + dw = part->dupliweights.first; + if(part->dupliweights.first == part->dupliweights.last) { + /* special case for only one object in the group */ + index_ok = 1; + } + else { + for(; dw; dw=dw->next) { + if(dw->index > 0) { + index_ok = 1; + break; + } + } + } + + if(index_ok) { + /* if we have indexes, let's use them */ + dw = part->dupliweights.first; + for(; dw; dw=dw->next) { + GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index); + dw->ob = go ? go->ob : NULL; + } + } + else { + /* otherwise try to get objects from own library (won't work on library linked groups) */ + for(; dw; dw=dw->next) + dw->ob = newlibadr(fd, part->id.lib, dw->ob); + } + } if(part->boids) { BoidState *state = part->boids->states.first; @@ -10252,8 +10281,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) sce->gm.attrib = sce->r.attrib; //Stereo - sce->gm.xsch = sce->r.xsch; - sce->gm.ysch = sce->r.ysch; sce->gm.stereomode = sce->r.stereomode; /* reassigning stereomode NO_STEREO and DOME to a separeted flag*/ if (sce->gm.stereomode == 1){ //1 = STEREO_NOSTEREO diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index ba4395ace9c..bf86527b9d3 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -837,6 +837,7 @@ static void write_particlesettings(WriteData *wd, ListBase *idbase) { ParticleSettings *part; ParticleDupliWeight *dw; + GroupObject *go; int a; part= idbase->first; @@ -851,8 +852,16 @@ static void write_particlesettings(WriteData *wd, ListBase *idbase) writestruct(wd, DATA, "EffectorWeights", 1, part->effector_weights); dw = part->dupliweights.first; - for(; dw; dw=dw->next) + for(; dw; dw=dw->next) { + /* update indices */ + dw->index = 0; + go = part->dup_group->gobject.first; + while(go && go->ob != dw->ob) { + go=go->next; + dw->index++; + } writestruct(wd, DATA, "ParticleDupliWeight", 1, dw); + } if(part->boids && part->phystype == PART_PHYS_BOIDS) { BoidState *state = part->boids->states.first; diff --git a/source/blender/blenpluginapi/CMakeLists.txt b/source/blender/blenpluginapi/CMakeLists.txt index a5af15d7f55..9d398291b85 100644 --- a/source/blender/blenpluginapi/CMakeLists.txt +++ b/source/blender/blenpluginapi/CMakeLists.txt @@ -28,9 +28,9 @@ set(INC . .. ../blenlib + ../blenloader ../imbuf ../makesdna - ../blenloader ../../../intern/guardedalloc ) @@ -50,7 +50,9 @@ set(SRC ) if(WITH_CODEC_QUICKTIME) - list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS}) + list(APPEND INC_SYS + ${QUICKTIME_INCLUDE_DIRS} + ) add_definitions(-DWITH_QUICKTIME) endif() diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt index 07da532146f..e2a68d19682 100644 --- a/source/blender/collada/CMakeLists.txt +++ b/source/blender/collada/CMakeLists.txt @@ -28,13 +28,13 @@ remove_strict_flags() set(INC . - ../blenlib ../blenkernel + ../blenlib ../blenloader - ../windowmanager + ../editors/include ../makesdna ../makesrna - ../editors/include + ../windowmanager ../../../intern/guardedalloc ) diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index a44fa6802f2..9d29177578d 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -37,12 +37,36 @@ MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw): COLLADASW::Li void MaterialsExporter::exportMaterials(Scene *sce, bool export_selected) { - openLibrary(); + if(hasMaterials(sce)) { + openLibrary(); - MaterialFunctor mf; - mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, export_selected); + MaterialFunctor mf; + mf.forEachMaterialInScene<MaterialsExporter>(sce, *this, export_selected); - closeLibrary(); + closeLibrary(); + } +} + + +bool MaterialsExporter::hasMaterials(Scene *sce) +{ + Base *base = (Base *)sce->base.first; + + while(base) { + Object *ob= base->object; + int a; + for(a = 0; a < ob->totcol; a++) + { + Material *ma = give_current_material(ob, a+1); + + // no material, but check all of the slots + if (!ma) continue; + + return true; + } + base= base->next; + } + return false; } void MaterialsExporter::operator()(Material *ma, Object *ob) diff --git a/source/blender/collada/MaterialExporter.h b/source/blender/collada/MaterialExporter.h index 0a7a276d857..c080e4b0596 100644 --- a/source/blender/collada/MaterialExporter.h +++ b/source/blender/collada/MaterialExporter.h @@ -51,6 +51,9 @@ public: MaterialsExporter(COLLADASW::StreamWriter *sw); void exportMaterials(Scene *sce, bool export_selected); void operator()(Material *ma, Object *ob); + +private: + bool hasMaterials(Scene *sce); }; // used in forEachMaterialInScene diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt index 51387b8b3f3..6195289f2a6 100644 --- a/source/blender/editors/animation/CMakeLists.txt +++ b/source/blender/editors/animation/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt index 0b675ffb4d9..7ecbdc9ebe5 100644 --- a/source/blender/editors/armature/CMakeLists.txt +++ b/source/blender/editors/armature/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index a1d13f4b4e9..b0432d980dc 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1480,10 +1480,8 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e bArmature *arm; EditBone *bone, *curBone, *next; int extend= RNA_boolean_get(op->ptr, "extend"); - ARegion *ar; Object *obedit= CTX_data_edit_object(C); arm= obedit->data; - ar= CTX_wm_region(C); view3d_operator_needs_opengl(C); diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt index bc3d167c17e..6e975e20cd7 100644 --- a/source/blender/editors/curve/CMakeLists.txt +++ b/source/blender/editors/curve/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/gpencil/CMakeLists.txt b/source/blender/editors/gpencil/CMakeLists.txt index fe5e35cc763..278a185eebd 100644 --- a/source/blender/editors/gpencil/CMakeLists.txt +++ b/source/blender/editors/gpencil/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../imbuf ../../makesdna ../../makesrna diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 829ad3217a9..dfa457c22de 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -39,6 +39,7 @@ struct Tex; struct bContext; struct bNode; struct ID; +struct ScrArea; /* drawnode.c */ void ED_init_node_butfuncs(void); @@ -51,6 +52,8 @@ void ED_node_generic_update(struct Main *bmain, struct bNodeTree *ntree, struct void ED_node_shader_default(struct Material *ma); void ED_node_composit_default(struct Scene *sce); void ED_node_texture_default(struct Tex *tex); +void ED_node_link_intersect_test(struct ScrArea *sa, int test); +void ED_node_link_insert(struct ScrArea *sa); /* node ops.c */ void ED_operatormacros_node(void); diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt index 6dd7af70e33..cc4c1eaa21c 100644 --- a/source/blender/editors/interface/CMakeLists.txt +++ b/source/blender/editors/interface/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../gpu ../../imbuf ../../makesdna diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 8b84afe9dfd..1a36130b522 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1879,7 +1879,6 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle if(but->autocomplete_func || data->searchbox) { changed= ui_textedit_autocomplete(C, but, data); update= 1; /* do live update for tab key */ - retval= WM_UI_HANDLER_BREAK; } /* the hotkey here is not well defined, was G.qual so we check all */ else if(event->shift || event->ctrl || event->alt || event->oskey) { @@ -2325,8 +2324,8 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa if(fac != 1.0f) { /* snap in unit-space */ tempf /= fac; - softmin /= fac; - softmax /= fac; + /* softmin /= fac; */ /* UNUSED */ + /* softmax /= fac; */ /* UNUSED */ softrange /= fac; } @@ -3469,13 +3468,13 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, CurveMapping *cumap= (CurveMapping*)but->poin; CurveMap *cuma= cumap->cm+cumap->cur; CurveMapPoint *cmp= cuma->curve; - float fx, fy, zoomx, zoomy, offsx, offsy; + float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */; int a, changed= 0; zoomx= (but->x2-but->x1)/(cumap->curr.xmax-cumap->curr.xmin); zoomy= (but->y2-but->y1)/(cumap->curr.ymax-cumap->curr.ymin); - offsx= cumap->curr.xmin; - offsy= cumap->curr.ymin; + /* offsx= cumap->curr.xmin; */ + /* offsy= cumap->curr.ymin; */ if(snap) { float d[2]; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index dfdce6ce2f5..2d0f49f293b 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -151,10 +151,10 @@ typedef struct uiLayoutItemBx { uiBut *roundbox; } uiLayoutItemBx; -typedef struct uiLayoutItemSplt { +typedef struct uiLayoutItemSplit { uiLayout litem; float percentage; -} uiLayoutItemSplt; +} uiLayoutItemSplit; typedef struct uiLayoutItemRoot { uiLayout litem; @@ -1617,7 +1617,7 @@ static void ui_litem_layout_row(uiLayout *litem) int x, y, w, tot, totw, neww, itemw, minw, itemh, offset; int fixedw, freew, fixedx, freex, flag= 0, lastw= 0; - x= litem->x; + /* x= litem->x; */ /* UNUSED */ y= litem->y; w= litem->w; totw= 0; @@ -2022,7 +2022,7 @@ static void ui_litem_estimate_split(uiLayout *litem) static void ui_litem_layout_split(uiLayout *litem) { - uiLayoutItemSplt *split= (uiLayoutItemSplt*)litem; + uiLayoutItemSplit *split= (uiLayoutItemSplit*)litem; uiItem *item; float percentage; const int tot= BLI_countlist(&litem->items); @@ -2244,9 +2244,9 @@ uiLayout *uiLayoutOverlap(uiLayout *layout) uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) { - uiLayoutItemSplt *split; + uiLayoutItemSplit *split; - split= MEM_callocN(sizeof(uiLayoutItemSplt), "uiLayoutItemSplt"); + split= MEM_callocN(sizeof(uiLayoutItemSplit), "uiLayoutItemSplit"); split->litem.item.type= ITEM_LAYOUT_SPLIT; split->litem.root= layout->root; split->litem.align= align; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index c19d9884c8b..01dcdda97a1 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -575,8 +575,8 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) ui_draw_tria_rect(&itemrect, 'h'); else ui_draw_tria_rect(&itemrect, 'v'); - - + + (void)ofsx; } /************************** panel alignment *************************/ diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index b6f855d2263..17c064f3ba2 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -484,6 +484,17 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) } } } + else if (ELEM(but->type, MENU, PULLDOWN)) { + if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { + if(but->menu_create_func && WM_menutype_contains((MenuType *)but->poin)) { + MenuType *mt= (MenuType *)but->poin; + BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", mt->idname); + data->color[data->totline]= 0x888888; + data->totline++; + } + } + + } assert(data->totline < MAX_TOOLTIP_LINES); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index dec4afa7894..7d1596459dd 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -251,7 +251,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) } /* ************** helpers ************************ */ - +/* XXX: read a style configure */ uiStyle* UI_GetStyle(void) { uiStyle *style = NULL; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 989dee89ac5..c1784da48bd 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -851,7 +851,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) /* verify we have valid data */ if(!RNA_struct_is_a(ptr->type, &RNA_Modifier)) { - RNA_warning("uiTemplateModifier: expected modifier on object.\n"); + RNA_warning("uiTemplateModifier: Expected modifier on object.\n"); return NULL; } @@ -859,7 +859,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) md= ptr->data; if(!ob || !(GS(ob->id.name) == ID_OB)) { - RNA_warning("uiTemplateModifier: expected modifier on object.\n"); + RNA_warning("uiTemplateModifier: Expected modifier on object.\n"); return NULL; } @@ -976,9 +976,6 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) block= uiLayoutGetBlock(box); /* Draw constraint header */ - - /* rounded header */ - // rb_col= (con->flag & CONSTRAINT_ACTIVE)?50:20; // UNUSED /* open/close */ uiBlockSetEmboss(block, UI_EMBOSSN); @@ -1083,7 +1080,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) /* verify we have valid data */ if(!RNA_struct_is_a(ptr->type, &RNA_Constraint)) { - RNA_warning("uiTemplateConstraint: expected constraint on object.\n"); + RNA_warning("uiTemplateConstraint: Expected constraint on object.\n"); return NULL; } @@ -1091,7 +1088,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) con= ptr->data; if(!ob || !(GS(ob->id.name) == ID_OB)) { - RNA_warning("uiTemplateConstraint: expected constraint on object.\n"); + RNA_warning("uiTemplateConstraint: Expected constraint on object.\n"); return NULL; } @@ -1137,7 +1134,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M PointerRNA texture_ptr; if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) { - RNA_warning("uiTemplatePreview: expected ID of type material, texture, lamp or world.\n"); + RNA_warning("uiTemplatePreview: Expected ID of type material, texture, lamp or world.\n"); return; } @@ -2171,14 +2168,14 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * if(prop) { type= RNA_property_type(prop); if(type != PROP_COLLECTION) { - RNA_warning("uiTemplateList: expected collection property.\n"); + RNA_warning("uiTemplateList: Expected collection property.\n"); return; } } activetype= RNA_property_type(activeprop); if(activetype != PROP_INT) { - RNA_warning("uiTemplateList: expected integer property.\n"); + RNA_warning("uiTemplateList: Expected integer property.\n"); return; } @@ -2200,7 +2197,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* create list items */ RNA_PROP_BEGIN(ptr, itemptr, prop) { /* create button */ - if(i == 9) + if(!(i % 9)) row= uiLayoutRow(col, 0); icon= list_item_icon_get(C, &itemptr, rnaicon, 1); @@ -2215,7 +2212,6 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * } else if(listtype == 'c') { /* compact layout */ - found= 0; row= uiLayoutRow(layout, 1); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 3f825762d74..56ef5e9e8cc 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1115,10 +1115,11 @@ void init_userdef_do_versions(void) } if(U.pad_rot_angle==0) U.pad_rot_angle= 15; - - if(U.flag & USER_CUSTOM_RANGE) - vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */ - + + /* signal for derivedmesh to use colorband */ + /* run incase this was on and is now off in the user prefs [#28096] */ + vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight):NULL); + if (bmain->versionfile <= 191) { strcpy(U.plugtexdir, U.textudir); strcpy(U.sounddir, "/"); diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 1b08f9cff5c..3c78983f82d 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -23,13 +23,13 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../imbuf ../../makesdna ../../makesrna - ../../windowmanager ../../render/extern/include + ../../windowmanager ../../../../intern/guardedalloc ) diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index f941e5243d5..748ce641b24 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -869,7 +869,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) Mesh *me= obedit->data; EditMesh *em= BKE_mesh_get_editmesh(me); - int selcount = similar_face_select__internal(em, RNA_int_get(op->ptr, "type"), RNA_float_get(op->ptr, "threshold")); + int selcount = similar_face_select__internal(em, RNA_enum_get(op->ptr, "type"), RNA_float_get(op->ptr, "threshold")); if (selcount) { /* here was an edge-mode only select flush case, has to be generalized */ diff --git a/source/blender/editors/metaball/CMakeLists.txt b/source/blender/editors/metaball/CMakeLists.txt index 9093da34519..41ed5da4f09 100644 --- a/source/blender/editors/metaball/CMakeLists.txt +++ b/source/blender/editors/metaball/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../render/extern/include diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index dae83ad61b5..ff542701a68 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -23,16 +23,16 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../gpu ../../ikplugin ../../imbuf ../../makesdna ../../makesrna ../../python - ../../windowmanager ../../render/extern/include + ../../windowmanager ../../../../intern/guardedalloc ) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 39f77973876..160df57d5f4 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -808,14 +808,14 @@ static int object_delete_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - int islamp= 0; + /* int islamp= 0; */ /* UNUSED */ if(CTX_data_edit_object(C)) return OPERATOR_CANCELLED; CTX_DATA_BEGIN(C, Base*, base, selected_bases) { - if(base->object->type==OB_LAMP) islamp= 1; + /* if(base->object->type==OB_LAMP) islamp= 1; */ /* deselect object -- it could be used in other scenes */ base->object->flag &= ~SELECT; diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 57f6c9de88e..679e4e58017 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -860,6 +860,10 @@ static void finish_images(MultiresBakeRender *bkr) RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter); ibuf->userflags|= IB_BITMAPDIRTY; + + if(ibuf->rect_float) + ibuf->userflags|= IB_RECT_INVALID; + if(ibuf->mipmap[0]) { ibuf->userflags|= IB_MIPMAP_INVALID; imb_freemipmapImBuf(ibuf); @@ -966,9 +970,10 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0); Mesh *me= (Mesh*)ob->data; - *lvl= mmd->lvl; + if(ob->mode==OB_MODE_SCULPT) *lvl= mmd->sculptlvl; + else *lvl= mmd->lvl; - if(mmd->lvl==0) { + if(*lvl==0) { DerivedMesh *tmp_dm= CDDM_from_mesh(me, ob); dm= CDDM_copy(tmp_dm); tmp_dm->release(tmp_dm); @@ -976,7 +981,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l MultiresModifierData tmp_mmd= *mmd; DerivedMesh *cddm= CDDM_from_mesh(me, ob); - tmp_mmd.lvl= mmd->lvl; + tmp_mmd.lvl= *lvl; dm= multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0, 0); cddm->release(cddm); } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index bf8ebcea754..9a649477191 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2164,16 +2164,20 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } } - else if (ELEM(type, COPY_PROPERTIES_REPLACE, COPY_PROPERTIES_MERGE)) { + + else { CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { if (ob != ob_iter) { if (ob->data != ob_iter->data){ - if (type == 2) {/* merge */ + if (type == COPY_PROPERTIES_REPLACE) + copy_properties( &ob_iter->prop, &ob->prop ); + + /* merge - the default when calling with no argument */ + else { for(prop = ob->prop.first; prop; prop= prop->next ) { set_ob_property(ob_iter, prop); } - } else /* replace */ - copy_properties( &ob_iter->prop, &ob->prop ); + } } } } diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt index 2aa05427223..931c6f9334f 100644 --- a/source/blender/editors/physics/CMakeLists.txt +++ b/source/blender/editors/physics/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index b573c77c7f3..37309f1e07c 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -722,15 +722,17 @@ typedef struct FluidBakeJob { static void fluidbake_free(void *customdata) { - FluidBakeJob *fb= customdata; + FluidBakeJob *fb= (FluidBakeJob *)customdata; MEM_freeN(fb); } /* called by fluidbake, only to check job 'stop' value */ -static int fluidbake_breakjob(void *UNUSED(customdata)) +static int fluidbake_breakjob(void *customdata) { - //FluidBakeJob *fb= (FluidBakeJob *)customdata; - //return *(fb->stop); + FluidBakeJob *fb= (FluidBakeJob *)customdata; + + if(fb->stop && *(fb->stop)) + return 1; /* this is not nice yet, need to make the jobs list template better * for identifying/acting upon various different jobs */ @@ -741,7 +743,7 @@ static int fluidbake_breakjob(void *UNUSED(customdata)) /* called by fluidbake, wmJob sends notifier */ static void fluidbake_updatejob(void *customdata, float progress) { - FluidBakeJob *fb= customdata; + FluidBakeJob *fb= (FluidBakeJob *)customdata; *(fb->do_update)= 1; *(fb->progress)= progress; @@ -749,7 +751,7 @@ static void fluidbake_updatejob(void *customdata, float progress) static void fluidbake_startjob(void *customdata, short *stop, short *do_update, float *progress) { - FluidBakeJob *fb= customdata; + FluidBakeJob *fb= (FluidBakeJob *)customdata; fb->stop= stop; fb->do_update = do_update; @@ -764,7 +766,7 @@ static void fluidbake_startjob(void *customdata, short *stop, short *do_update, static void fluidbake_endjob(void *customdata) { - FluidBakeJob *fb= customdata; + FluidBakeJob *fb= (FluidBakeJob *)customdata; if (fb->settings) { MEM_freeN(fb->settings); diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 7e497200710..cf6c4290ee0 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -51,8 +51,12 @@ set(SRC ) if(WITH_CODEC_QUICKTIME) - list(APPEND INC ../../quicktime) - list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS}) + list(APPEND INC + ../../quicktime + ) + list(APPEND INC_SYS + ${QUICKTIME_INCLUDE_DIRS} + ) add_definitions(-DWITH_QUICKTIME) endif() diff --git a/source/blender/editors/render/SConscript b/source/blender/editors/render/SConscript index 2b9737557cd..4404ea2687c 100644 --- a/source/blender/editors/render/SConscript +++ b/source/blender/editors/render/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.c') -incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' +incs = '../include ../../blenlib ../../blenfont ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../gpu' incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern' diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 91babb84477..67f828008e3 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -110,7 +110,7 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot) /* identifiers */ ot->name= _("Add Material Slot"); ot->idname= "OBJECT_OT_material_slot_add"; - ot->description=_("Add a new material slot or duplicate the selected one"); + ot->description=_("Add a new material slot"); /* api callbacks */ ot->exec= material_slot_add_exec; diff --git a/source/blender/editors/screen/CMakeLists.txt b/source/blender/editors/screen/CMakeLists.txt index 54341257692..4282110901b 100644 --- a/source/blender/editors/screen/CMakeLists.txt +++ b/source/blender/editors/screen/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../imbuf ../../makesdna ../../makesrna diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index 6d82dff4283..4438bb4f035 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -23,14 +23,14 @@ set(INC ../include ../../blenfont ../../blenkernel + ../../blenlib ../../blenloader - ../../imbuf ../../gpu - ../../blenlib + ../../imbuf ../../makesdna ../../makesrna - ../../windowmanager ../../render/extern/include + ../../windowmanager ../../../../intern/guardedalloc ) diff --git a/source/blender/editors/sound/CMakeLists.txt b/source/blender/editors/sound/CMakeLists.txt index 6d84b49166b..2b3209659fa 100644 --- a/source/blender/editors/sound/CMakeLists.txt +++ b/source/blender/editors/sound/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt index 91da0a4695d..c2e9deca9ac 100644 --- a/source/blender/editors/space_action/CMakeLists.txt +++ b/source/blender/editors/space_action/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt index c2dc2582c82..4cbb290be76 100644 --- a/source/blender/editors/space_api/CMakeLists.txt +++ b/source/blender/editors/space_api/CMakeLists.txt @@ -22,8 +22,8 @@ set(INC ../include ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt index 71eee0aaeba..a9aaf6a6d58 100644 --- a/source/blender/editors/space_buttons/CMakeLists.txt +++ b/source/blender/editors/space_buttons/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_file/CMakeLists.txt b/source/blender/editors/space_file/CMakeLists.txt index afa746ea359..4aa6cdbcf2f 100644 --- a/source/blender/editors/space_file/CMakeLists.txt +++ b/source/blender/editors/space_file/CMakeLists.txt @@ -28,8 +28,8 @@ set(INC ../../imbuf ../../makesdna ../../makesrna - ../../windowmanager ../../render/extern/include + ../../windowmanager ../../../../intern/guardedalloc ) diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 913e7486c63..132be9dfbc5 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1281,7 +1281,7 @@ void FILE_OT_filenum(struct wmOperatorType *ot) ot->poll= ED_operator_file_active; /* <- important, handler is on window level */ /* props */ - RNA_def_int(ot->srna, "increment", 1, 0, 100, _("Increment"), "", 0,100); + RNA_def_int(ot->srna, "increment", 1, -100, 100, _("Increment"), "", -100,100); } static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/space_graph/CMakeLists.txt b/source/blender/editors/space_graph/CMakeLists.txt index 7724a5dcd87..28383b29b36 100644 --- a/source/blender/editors/space_graph/CMakeLists.txt +++ b/source/blender/editors/space_graph/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index 7c2d7ffb47b..0d4408faf49 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -23,13 +23,13 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../imbuf ../../makesdna ../../makesrna - ../../windowmanager ../../render/extern/include + ../../windowmanager ../../../../intern/guardedalloc ) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 25d4c023d47..ab008296092 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -806,6 +806,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char col= uiLayoutColumn(split, 1); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); + uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 304a01db59b..34d62f35aa5 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -502,7 +502,7 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene; Object *obedit; Image *ima; - float size, min[2], max[2], d[2]; + float size, min[2], max[2], d[2], aspx, aspy; int width, height; /* retrieve state */ @@ -513,6 +513,10 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op)) ima= ED_space_image(sima); ED_space_image_size(sima, &width, &height); + ED_image_aspect(ima, &aspx, &aspy); + + width= width*aspx; + height= height*aspy; /* get bounds */ if(!ED_uvedit_minmax(scene, ima, obedit, min, max)) diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt index c6ed1b7bac7..22347df93a3 100644 --- a/source/blender/editors/space_info/CMakeLists.txt +++ b/source/blender/editors/space_info/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../imbuf ../../makesdna ../../makesrna diff --git a/source/blender/editors/space_logic/CMakeLists.txt b/source/blender/editors/space_logic/CMakeLists.txt index 39b44f88203..f4bb255e11f 100644 --- a/source/blender/editors/space_logic/CMakeLists.txt +++ b/source/blender/editors/space_logic/CMakeLists.txt @@ -23,12 +23,12 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader + ../../editors/interface ../../makesdna ../../makesrna ../../windowmanager - ../../editors/interface ../../../../intern/guardedalloc ) diff --git a/source/blender/editors/space_nla/CMakeLists.txt b/source/blender/editors/space_nla/CMakeLists.txt index ebeb959bf17..819e80d7b2e 100644 --- a/source/blender/editors/space_nla/CMakeLists.txt +++ b/source/blender/editors/space_nla/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt index 9172bc4e9eb..dcd6bcd3403 100644 --- a/source/blender/editors/space_node/CMakeLists.txt +++ b/source/blender/editors/space_node/CMakeLists.txt @@ -23,14 +23,14 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../imbuf ../../makesdna ../../makesrna ../../nodes - ../../windowmanager ../../render/extern/include + ../../windowmanager ../../../../intern/guardedalloc ../../../../intern/opennl/extern ) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 1bf2c3d89bd..50e657bbb61 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1869,10 +1869,17 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) else { /* check cyclic */ if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) { - if(link->fromnode->flag & SELECT) - th_col1= TH_EDGE_SELECT; - if(link->tonode->flag & SELECT) - th_col2= TH_EDGE_SELECT; + /* special indicated link, on drop-node */ + if(link->flag & NODE_LINKFLAG_HILITE) { + th_col1= th_col2= TH_ACTIVE; + } + else { + /* regular link */ + if(link->fromnode->flag & SELECT) + th_col1= TH_EDGE_SELECT; + if(link->tonode->flag & SELECT) + th_col2= TH_EDGE_SELECT; + } do_shaded= 1; do_triple= 1; } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index fc6281db5bc..0cd7d19a658 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -781,14 +781,15 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } { /* always hide/reveal unused sockets */ - int shade; - - iconofs-=iconbutw; // XXX re-enable - /*if(node_has_hidden_sockets(node)) + /* int shade; + if(node_has_hidden_sockets(node)) shade= -40; - else*/ - shade= -90; + else + shade= -90; */ + + iconofs-=iconbutw; + uiDefIconBut(node->block, LABEL, B_REDR, ICON_PLUS, iconofs, rct->ymax-NODE_DY, iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, ""); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 132ea200c54..3100dc7da26 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1103,7 +1103,7 @@ void NODE_OT_backimage_move(wmOperatorType *ot) ot->cancel= snode_bg_viewmove_cancel; /* flags */ - ot->flag= OPTYPE_BLOCKING; + ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; } static int backimage_zoom(bContext *C, wmOperator *op) @@ -2002,12 +2002,13 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float /* ****************** Duplicate *********************** */ -static int node_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) +static int node_duplicate_exec(bContext *C, wmOperator *op) { SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree= snode->edittree; bNode *node, *newnode, *lastnode; bNodeLink *link, *newlink, *lastlink; + int keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs"); ED_preview_kill_jobs(C); @@ -2035,10 +2036,11 @@ static int node_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) */ lastlink = ntree->links.last; for (link=ntree->links.first; link; link=link->next) { - /* this creates new links between copied nodes, - * as well as input links from unselected (when fromnode==NULL) ! + /* This creates new links between copied nodes. + * If keep_inputs is set, also copies input links from unselected (when fromnode==NULL)! */ - if (link->tonode && (link->tonode->flag & NODE_SELECT)) { + if (link->tonode && (link->tonode->flag & NODE_SELECT) + && (keep_inputs || (link->fromnode && (link->fromnode->flag & NODE_SELECT)))) { newlink = MEM_callocN(sizeof(bNodeLink), "bNodeLink"); newlink->flag = link->flag; newlink->tonode = link->tonode->new_node; @@ -2098,6 +2100,8 @@ void NODE_OT_duplicate(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + RNA_def_boolean(ot->srna, "keep_inputs", 0, _("Keep Inputs"), _("Keep the input links to duplicated nodes")); } /* *************************** add link op ******************** */ @@ -2116,9 +2120,9 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL if(tlink) { /* try to move the existing link to the next available socket */ if (tlink->tonode) { - /* is there a free input socket with same type? */ + /* is there a free input socket with the target type? */ for(sock= tlink->tonode->inputs.first; sock; sock= sock->next) { - if(sock->type==tlink->fromsock->type) + if(sock->type==tlink->tosock->type) if(nodeCountSocketLinks(snode->edittree, sock) < sock->limit) break; } @@ -2490,6 +2494,151 @@ void NODE_OT_links_cut(wmOperatorType *ot) RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, _("Cursor"), "", 0, INT_MAX); } +/* ********************* automatic node insert on dragging ******************* */ + +/* assumes sockets in list */ +static bNodeSocket *socket_best_match(ListBase *sockets, int type) +{ + bNodeSocket *sock; + + /* first, match type */ + for(sock= sockets->first; sock; sock= sock->next) + if(!(sock->flag & SOCK_HIDDEN)) + if(type == sock->type) + return sock; + + /* then just use first unhidden socket */ + for(sock= sockets->first; sock; sock= sock->next) + if(!(sock->flag & SOCK_HIDDEN)) + return sock; + + /* OK, let's unhide proper one */ + for(sock= sockets->first; sock; sock= sock->next) { + if(type == sock->type) { + sock->flag &= ~SOCK_HIDDEN; + return sock; + } + } + + /* just the first */ + sock= sockets->first; + sock->flag &= ~SOCK_HIDDEN; + + return sockets->first; +} + +/* prevent duplicate testing code below */ +static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) +{ + SpaceNode *snode= sa?sa->spacedata.first:NULL; + bNode *node; + bNodeLink *link; + + /* no unlucky accidents */ + if(sa==NULL || sa->spacetype!=SPACE_NODE) return NULL; + + *select= NULL; + + for(node= snode->edittree->nodes.first; node; node= node->next) { + if(node->flag & SELECT) { + if(*select) + break; + else + *select= node; + } + } + /* only one selected */ + if(node || *select==NULL) return NULL; + + /* correct node */ + if((*select)->inputs.first==NULL || (*select)->outputs.first==NULL) return NULL; + + /* test node for links */ + for(link= snode->edittree->links.first; link; link=link->next) { + if(link->tonode == *select || link->fromnode == *select) + return NULL; + } + + return snode; +} + +/* assumes link with NODE_LINKFLAG_HILITE set */ +void ED_node_link_insert(ScrArea *sa) +{ + bNode *node, *select; + SpaceNode *snode= ed_node_link_conditions(sa, &select); + bNodeLink *link; + bNodeSocket *sockto; + + if(snode==NULL) return; + + /* get the link */ + for(link= snode->edittree->links.first; link; link=link->next) + if(link->flag & NODE_LINKFLAG_HILITE) + break; + + if(link) { + node= link->tonode; + sockto= link->tosock; + + link->tonode= select; + link->tosock= socket_best_match(&select->inputs, link->fromsock->type); + link->flag &= ~NODE_LINKFLAG_HILITE; + + nodeAddLink(snode->edittree, select, socket_best_match(&select->outputs, sockto->type), node, sockto); + ntreeSolveOrder(snode->edittree); /* needed for pointers */ + snode_tag_changed(snode, select); + ED_node_changed_update(snode->id, select); + } +} + + +/* test == 0, clear all intersect flags */ +void ED_node_link_intersect_test(ScrArea *sa, int test) +{ + bNode *select; + SpaceNode *snode= ed_node_link_conditions(sa, &select); + bNodeLink *link, *selink=NULL; + float mcoords[6][2]; + + if(snode==NULL) return; + + /* clear flags */ + for(link= snode->edittree->links.first; link; link=link->next) + link->flag &= ~NODE_LINKFLAG_HILITE; + + if(test==0) return; + + /* okay, there's 1 node, without links, now intersect */ + mcoords[0][0]= select->totr.xmin; + mcoords[0][1]= select->totr.ymin; + mcoords[1][0]= select->totr.xmax; + mcoords[1][1]= select->totr.ymin; + mcoords[2][0]= select->totr.xmax; + mcoords[2][1]= select->totr.ymax; + mcoords[3][0]= select->totr.xmin; + mcoords[3][1]= select->totr.ymax; + mcoords[4][0]= select->totr.xmin; + mcoords[4][1]= select->totr.ymin; + mcoords[5][0]= select->totr.xmax; + mcoords[5][1]= select->totr.ymax; + + /* we only tag a single link for intersect now */ + /* idea; use header dist when more? */ + for(link= snode->edittree->links.first; link; link=link->next) { + + if(cut_links_intersect(link, mcoords, 5)) { /* intersect code wants edges */ + if(selink) + break; + selink= link; + } + } + + if(link==NULL && selink) + selink->flag |= NODE_LINKFLAG_HILITE; +} + + /* ******************************** */ // XXX some code needing updating to operators... @@ -2912,7 +3061,8 @@ void NODE_OT_delete(wmOperatorType *ot) /* note: in cmp_util.c is similar code, for node_compo_pass_on() */ /* used for disabling node (similar code in node_draw.c for disable line) */ -static void node_delete_reconnect(bNodeTree* tree, bNode* node) { +static void node_delete_reconnect(bNodeTree* tree, bNode* node) +{ bNodeLink *link, *next; bNodeSocket *valsocket= NULL, *colsocket= NULL, *vecsocket= NULL; bNodeSocket *deliveringvalsocket= NULL, *deliveringcolsocket= NULL, *deliveringvecsocket= NULL; @@ -3140,3 +3290,5 @@ void NODE_OT_add_file(wmOperatorType *ot) RNA_def_string(ot->srna, "name", "Image", 24, _("Name"), _("Datablock name to assign.")); } + + diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 23682577b8a..a5646a51347 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -96,8 +96,6 @@ static void do_node_add(bContext *C, void *UNUSED(arg), int event) if(node->flag & NODE_TEST) node->flag |= NODE_SELECT; } - snode_autoconnect(snode, 1, 0); - /* deselect after autoconnection */ for(node= snode->edittree->nodes.first; node; node= node->next) { if(node->flag & NODE_TEST) node->flag &= ~NODE_SELECT; diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 08e506253f8..3a4ca866d41 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -103,11 +103,18 @@ void node_operatortypes(void) void ED_operatormacros_node(void) { wmOperatorType *ot; + wmOperatorTypeMacro *mot; ot= WM_operatortype_append_macro("NODE_OT_duplicate_move", _("Duplicate"), OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); + /* modified operator call for duplicating with input links */ + ot= WM_operatortype_append_macro("NODE_OT_duplicate_move_keep_inputs", _("Duplicate"), OPTYPE_UNDO|OPTYPE_REGISTER); + mot = WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); + RNA_boolean_set(mot->ptr, "keep_inputs", 1); + WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); + ot= WM_operatortype_append_macro("NODE_OT_select_link_viewer", _("Link Viewer"), OPTYPE_UNDO); WM_operatortype_macro_define(ot, "NODE_OT_select"); WM_operatortype_macro_define(ot, "NODE_OT_link_viewer"); @@ -157,6 +164,8 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "NODE_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); + /* modified operator call for duplicating with input links */ + WM_keymap_add_item(keymap, "NODE_OT_duplicate_move_keep_inputs", DKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_hide_toggle", HKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_mute_toggle", MKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 029c55d0851..3c5f4a163a2 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -228,6 +228,13 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) else if (wmn->action == NA_SELECTED) ED_area_tag_redraw(sa); break; + case NC_SCREEN: + switch(wmn->data) { + case ND_ANIMPLAY: + ED_area_tag_refresh(sa); + break; + } + break; case NC_IMAGE: if (wmn->action == NA_EDITED) { diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index bda431c0290..f7f6ff96b31 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../imbuf ../../makesdna ../../makesrna diff --git a/source/blender/editors/space_script/CMakeLists.txt b/source/blender/editors/space_script/CMakeLists.txt index eaa782908a7..c08beed3051 100644 --- a/source/blender/editors/space_script/CMakeLists.txt +++ b/source/blender/editors/space_script/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager @@ -45,8 +45,12 @@ set(SRC ) if(WITH_PYTHON) - list(APPEND INC ../../python) - list(APPEND INC_SYS ${PYTHON_INCLUDE_DIRS}) + list(APPEND INC + ../../python + ) + list(APPEND INC_SYS + ${PYTHON_INCLUDE_DIRS} + ) add_definitions(-DWITH_PYTHON) endif() diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index e7960759c77..9b978dffc39 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../imbuf ../../makesdna ../../makesrna diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 66309963609..4cde3632da2 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -103,6 +103,8 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) RNA_def_boolean(ot->srna, "replace_sel", 1, _("Replace Selection"), _("replace the current selection")); + RNA_def_boolean(ot->srna, "overlap", 0, _("Allow Overlap"), _("Don't correct overlap on new sequence strips")); + if(flag & SEQPROP_FILES) RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, _("Files"), ""); } @@ -252,7 +254,11 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) seq_active_set(scene, seq); seq->flag |= SELECT; } - + + if(RNA_boolean_get(op->ptr, "overlap") == FALSE) { + if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + } + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -307,6 +313,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad SeqLoadInfo seq_load; Sequence *seq; int tot_files; + const short overlap= RNA_boolean_get(op->ptr, "overlap"); seq_load_operator_info(&seq_load, op); @@ -327,12 +334,20 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad BLI_join_dirfile(seq_load.path, sizeof(seq_load.path), dir_only, file_only); seq= seq_load_func(C, ed->seqbasep, &seq_load); + + if(overlap == FALSE) { + if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + } } RNA_END; } else { /* single file */ seq= seq_load_func(C, ed->seqbasep, &seq_load); + + if(overlap == FALSE) { + if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + } } if (seq_load.tot_success==0) { @@ -508,7 +523,11 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) /* last active name */ strncpy(ed->act_imagedir, strip->dir, FILE_MAXDIR-1); - + + if(RNA_boolean_get(op->ptr, "overlap") == FALSE) { + if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + } + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -658,7 +677,9 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) } } - if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + if(RNA_boolean_get(op->ptr, "overlap") == FALSE) { + if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + } update_changed_seq_and_deps(scene, seq, 1, 1); /* runs calc_sequence */ diff --git a/source/blender/editors/space_sound/CMakeLists.txt b/source/blender/editors/space_sound/CMakeLists.txt index 367d07c0c0b..870065966cc 100644 --- a/source/blender/editors/space_sound/CMakeLists.txt +++ b/source/blender/editors/space_sound/CMakeLists.txt @@ -22,8 +22,8 @@ set(INC ../include ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt index 0c174225a58..acf00d205a6 100644 --- a/source/blender/editors/space_text/CMakeLists.txt +++ b/source/blender/editors/space_text/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager @@ -46,8 +46,12 @@ set(SRC ) if(WITH_PYTHON) - list(APPEND INC ../../python) - list(APPEND INC_SYS ${PYTHON_INCLUDE_DIRS}) + list(APPEND INC + ../../python + ) + list(APPEND INC_SYS + ${PYTHON_INCLUDE_DIRS} + ) add_definitions(-DWITH_PYTHON) endif() diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 2e8cc6bfe9c..b9f73ffdbf5 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -36,6 +36,7 @@ #include <string.h> #include <ctype.h> /* ispunct */ #include <sys/stat.h> +#include <errno.h> #include "MEM_guardedalloc.h" @@ -451,15 +452,14 @@ static void txt_write_file(Text *text, ReportList *reports) FILE *fp; TextLine *tmp; struct stat st; - int res; - char file[FILE_MAXDIR+FILE_MAXFILE]; + char filepath[FILE_MAXDIR+FILE_MAXFILE]; - BLI_strncpy(file, text->name, FILE_MAXDIR+FILE_MAXFILE); - BLI_path_abs(file, G.main->name); + BLI_strncpy(filepath, text->name, FILE_MAXDIR+FILE_MAXFILE); + BLI_path_abs(filepath, G.main->name); - fp= fopen(file, "w"); + fp= fopen(filepath, "w"); if(fp==NULL) { - BKE_report(reports, RPT_ERROR, "Unable to save file."); + BKE_reportf(reports, RPT_ERROR, "Unable to save \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error writing file"); return; } @@ -473,8 +473,13 @@ static void txt_write_file(Text *text, ReportList *reports) fclose (fp); - res= stat(file, &st); - text->mtime= st.st_mtime; + if(stat(filepath, &st) == 0) { + text->mtime= st.st_mtime; + } + else { + text->mtime= 0; + BKE_reportf(reports, RPT_WARNING, "Unable to stat \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error starrng file"); + } if(text->flags & TXT_ISDIRTY) text->flags ^= TXT_ISDIRTY; diff --git a/source/blender/editors/space_time/CMakeLists.txt b/source/blender/editors/space_time/CMakeLists.txt index 965f7e541b8..d6bf4a551ce 100644 --- a/source/blender/editors/space_time/CMakeLists.txt +++ b/source/blender/editors/space_time/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_userpref/CMakeLists.txt b/source/blender/editors/space_userpref/CMakeLists.txt index 656a5d2f0ef..43ac90dce94 100644 --- a/source/blender/editors/space_userpref/CMakeLists.txt +++ b/source/blender/editors/space_userpref/CMakeLists.txt @@ -22,8 +22,8 @@ set(INC ../include ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index 0a12a28af8d..c6e936606c8 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -23,14 +23,14 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../gpu ../../imbuf ../../makesdna ../../makesrna - ../../windowmanager ../../render/extern/include + ../../windowmanager ../../../../intern/guardedalloc ../../../../intern/smoke/extern ) @@ -61,7 +61,9 @@ set(SRC ) if(WITH_GAMEENGINE) - list(APPEND INC ../../../../source/gameengine/BlenderRoutines) + list(APPEND INC + ../../../gameengine/BlenderRoutines + ) add_definitions(-DWITH_GAMEENGINE) endif() diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index e314d249e6d..e6889f4563f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1335,6 +1335,11 @@ static void draw_focus_cross(float dist, float size) glEnd(); } +#ifdef VIEW3D_CAMERA_BORDER_HACK +float view3d_camera_border_hack_col[4]; +short view3d_camera_border_hack_test= FALSE; +#endif + /* flag similar to draw_object() */ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int flag) { @@ -1348,7 +1353,15 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob const float scax= 1.0f / len_v3(ob->obmat[0]); const float scay= 1.0f / len_v3(ob->obmat[1]); const float scaz= 1.0f / len_v3(ob->obmat[2]); - + +#ifdef VIEW3D_CAMERA_BORDER_HACK + if(is_view && !(G.f & G_PICKSEL)) { + glGetFloatv(GL_CURRENT_COLOR, view3d_camera_border_hack_col); + view3d_camera_border_hack_test= TRUE; + return; + } +#endif + cam= ob->data; aspx= (float) scene->r.xsch*scene->r.xasp; aspy= (float) scene->r.ysch*scene->r.yasp; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 11d476977b2..cf696a6d063 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -969,7 +969,7 @@ static void v3d_editarmature_buts(uiLayout *layout, Object *ob) ebone= arm->act_edbone; if (!ebone || (ebone->layer & arm->layer)==0) { - uiItemL(col, "Nothing selected", ICON_NONE); + uiItemL(layout, "Nothing selected", ICON_NONE); return; } // row= uiLayoutRow(layout, 0); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 0ed62f3953f..d2ff6eef097 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1007,6 +1007,8 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) /* note: quite un-scientific but without this bit extra * 0.0001 on the lower left the 2D border sometimes * obscures the 3D camera border */ + /* note: with VIEW3D_CAMERA_BORDER_HACK defined this error isn't noticable + * but keep it here incase we need to remove the workaround */ x1i= (int)(x1 - 1.0001f); y1i= (int)(y1 - 1.0001f); x2i= (int)(x2 + (1.0f-0.0001f)); @@ -1039,7 +1041,17 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) setlinestyle(0); UI_ThemeColor(TH_BACK); glRectf(x1i, y1i, x2i, y2i); - + +#ifdef VIEW3D_CAMERA_BORDER_HACK + { + if(view3d_camera_border_hack_test == TRUE) { + glColor4fv(view3d_camera_border_hack_col); + glRectf(x1i+1, y1i+1, x2i-1, y2i-1); + view3d_camera_border_hack_test= FALSE; + } + } +#endif + setlinestyle(3); UI_ThemeColor(TH_WIRE); glRectf(x1i, y1i, x2i, y2i); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index fca22dc8c8b..3b760605444 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -131,7 +131,6 @@ void ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) } else { ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - root_parent= v3d->camera; DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera); } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 32c2ba32b93..a4e1081d6cd 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -507,17 +507,6 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - /* NDOF */ - /* Not implemented yet - if (G.ndofdevice ==0 ) { - uiDefIconTextButC(block, ICONTEXTROW,B_NDOF, ICON_NDOF_TURN, ndof_pup(), 0,0,UI_UNIT_X+10,UI_UNIT_Y, &(v3d->ndofmode), 0, 3.0, 0, 0, "Ndof mode"); - - uiDefIconButC(block, TOG, B_NDOF, ICON_NDOF_DOM, - 0,0,UI_UNIT_X,UI_UNIT_Y, - &v3d->ndoffilter, 0, 1, 0, 0, "dominant axis"); - } - */ - /* Transform widget / manipulators */ row= uiLayoutRow(layout, 1); uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index aa92f0d0a59..d3886d48873 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -194,6 +194,16 @@ extern const char *view3d_context_dir[]; /* doc access */ /* draw_volume.c */ void draw_volume(struct ARegion *ar, struct GPUTexture *tex, float *min, float *max, int res[3], float dx, struct GPUTexture *tex_shadow); +/* workaround for trivial but noticable camera bug caused by imprecision + * between view border calculation in 2D/3D space, workaround for bug [#28037]. + * without this deifne we get the old behavior which is to try and align them + * both which _mostly_ works fine, but when the camera moves beyond ~1000 in + * any direction it starts to fail */ +#define VIEW3D_CAMERA_BORDER_HACK +#ifdef VIEW3D_CAMERA_BORDER_HACK +extern float view3d_camera_border_hack_col[4]; +extern short view3d_camera_border_hack_test; +#endif #endif /* ED_VIEW3D_INTERN_H */ diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index 3d9c238470e..0917fb362ab 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index d61397976d3..ec002597922 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -972,7 +972,7 @@ int transformEvent(TransInfo *t, wmEvent *event) break; case OKEY: if (t->flag & T_PROP_EDIT && event->shift) { - t->prop_mode = (t->prop_mode + 1) % 6; + t->prop_mode = (t->prop_mode + 1) % PROP_MODE_MAX; calculatePropRatio(t); t->redraw |= TREDRAW_HARD; } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index d8e750acb88..d8e42488787 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -96,7 +96,7 @@ typedef struct TransSnap { short modeSelect; short align; char project; - char project_self; + char snap_self; short peel; short status; float snapPoint[3]; /* snapping from this point */ diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 16bfc75c979..0a5e290643a 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -87,6 +87,7 @@ #include "ED_object.h" #include "ED_markers.h" #include "ED_mesh.h" +#include "ED_node.h" #include "ED_types.h" #include "ED_uvedit.h" #include "ED_curve.h" /* for ED_curve_editnurbs */ @@ -2182,6 +2183,12 @@ void flushTransNodes(TransInfo *t) td->loc2d[0]= td->loc[0]; td->loc2d[1]= td->loc[1]; } + + /* handle intersection with noodles */ + if(t->total==1) { + ED_node_link_intersect_test(t->sa, 1); + } + } /* *** SEQUENCE EDITOR *** */ @@ -4756,7 +4763,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_NODE) { - /* pass */ + if(cancelled == 0) + ED_node_link_insert(t->sa); + + /* clear link line */ + ED_node_link_intersect_test(t->sa, 0); + } else if (t->spacetype == SPACE_ACTION) { SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 20a26d8c58d..6d0a978700f 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1070,7 +1070,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) } } // Need stuff to take it from edit mesh or whatnot here - else + else if (t->spacetype == SPACE_VIEW3D) { if (t->obedit && t->obedit->type == OB_MESH && (((Mesh *)t->obedit->data)->editflag & ME_EDIT_MIRROR_X)) { diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index fdf9e947590..f61cc51de98 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -956,6 +956,8 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT|KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_item(keymap, "TRANSFORM_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0); km = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index d9d9b0f9102..ca89670dedb 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -392,7 +392,7 @@ static void initSnappingMode(TransInfo *t) } else { - t->tsnap.modeSelect = t->tsnap.project_self ? SNAP_ALL : SNAP_NOT_OBEDIT; + t->tsnap.modeSelect = t->tsnap.snap_self ? SNAP_ALL : SNAP_NOT_OBEDIT; } } /* Particles edit mode*/ @@ -458,23 +458,26 @@ void initSnapping(TransInfo *t, wmOperator *op) t->tsnap.project = RNA_boolean_get(op->ptr, "use_snap_project"); } - if (RNA_struct_find_property(op->ptr, "use_snap_project_self")) + if (RNA_struct_find_property(op->ptr, "use_snap_self")) { - t->tsnap.project = RNA_boolean_get(op->ptr, "use_snap_project_self"); + t->tsnap.snap_self = RNA_boolean_get(op->ptr, "use_snap_self"); } } } /* use scene defaults only when transform is modal */ else if (t->flag & T_MODAL) { - if (ts->snap_flag & SCE_SNAP) { - t->modifiers |= MOD_SNAP; - } + if(ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) + { + if (ts->snap_flag & SCE_SNAP) { + t->modifiers |= MOD_SNAP; + } - t->tsnap.align = ((t->settings->snap_flag & SCE_SNAP_ROTATE) == SCE_SNAP_ROTATE); - t->tsnap.project = ((t->settings->snap_flag & SCE_SNAP_PROJECT) == SCE_SNAP_PROJECT); - t->tsnap.project_self = !((t->settings->snap_flag & SCE_SNAP_PROJECT_NO_SELF) == SCE_SNAP_PROJECT_NO_SELF); - t->tsnap.peel = ((t->settings->snap_flag & SCE_SNAP_PROJECT) == SCE_SNAP_PROJECT); + t->tsnap.align = ((t->settings->snap_flag & SCE_SNAP_ROTATE) == SCE_SNAP_ROTATE); + t->tsnap.project = ((t->settings->snap_flag & SCE_SNAP_PROJECT) == SCE_SNAP_PROJECT); + t->tsnap.snap_self = !((t->settings->snap_flag & SCE_SNAP_NO_SELF) == SCE_SNAP_NO_SELF); + t->tsnap.peel = ((t->settings->snap_flag & SCE_SNAP_PROJECT) == SCE_SNAP_PROJECT); + } } t->tsnap.target = snap_target; @@ -1944,6 +1947,11 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea int i; float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3) + if(max_index > 2) { + printf("applyGrid: invalid index %d, clamping\n", max_index); + max_index= 2; + } + // Early bailing out if no need to snap if (fac[action] == 0.0f) return; diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index f67056f5b71..e284540c5a6 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index d139a4b5150..4fedf35acd1 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -360,19 +360,25 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op) ret= 1; } } + else { + if (G.f & G_DEBUG) { + printf("redo_cb: WM_operator_repeat_check returned false %s\n", op->type->name); + } + } /* set region back */ CTX_wm_region_set(C, ar); } else { if (G.f & G_DEBUG) { - printf("redo_cb: WM_operator_repeat_check returned false %s\n", op->type->name); + printf("redo_cb: ED_undo_operator_repeat called with NULL 'op'\n"); } } return ret; } + void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void *UNUSED(arg_unused)) { ED_undo_operator_repeat(C, (wmOperator *)arg_op); diff --git a/source/blender/editors/uvedit/CMakeLists.txt b/source/blender/editors/uvedit/CMakeLists.txt index d25ee20e5b5..4055585af74 100644 --- a/source/blender/editors/uvedit/CMakeLists.txt +++ b/source/blender/editors/uvedit/CMakeLists.txt @@ -23,8 +23,8 @@ set(INC ../include ../../blenfont ../../blenkernel - ../../blenloader ../../blenlib + ../../blenloader ../../makesdna ../../makesrna ../../windowmanager diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index eab35ba29c0..0b042f4c7eb 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1059,6 +1059,134 @@ static void weld_align_uv(bContext *C, int tool) } } + if(tool == 's' || tool == 't' || tool == 'u') { + /* pass 1&2 variables */ + int i, j; + int starttmpl= -1, connectedtostarttmpl= -1, startcorner; + int endtmpl= -1, connectedtoendtmpl= -1, endcorner; + MTFace *startface, *endface; + int itmpl, jtmpl; + EditVert *eve; + int pass; /* first 2 passes find endpoints, 3rd pass moves middle points, 4th pass is fail-on-face-selected */ + EditFace *startefa, *endefa; + + /* pass 3 variables */ + float startx, starty, firstm, firstb, midx, midy; + float endx, endy, secondm, secondb, midmovedx, midmovedy; + float IsVertical_check= -1; + float IsHorizontal_check= -1; + + for(i= 0, eve= em->verts.first; eve; eve= eve->next, i++) /* give each point a unique name */ + eve->tmp.l= i; + for(pass= 1; pass <= 3; pass++) { /* do this for each endpoint */ + if(pass == 3){ /* calculate */ + startx= startface->uv[startcorner][0]; + starty= startface->uv[startcorner][1]; + endx= endface->uv[endcorner][0]; + endy= endface->uv[endcorner][1]; + firstm= (endy-starty)/(endx-startx); + firstb= starty-(firstm*startx); + secondm= -1.0f/firstm; + if(startx == endx) IsVertical_check= startx; + if(starty == endy) IsHorizontal_check= starty; + } + for(efa= em->faces.first; efa; efa= efa->next) { /* for each face */ + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); /* get face */ + if(uvedit_face_visible(scene, ima, efa, tf)) { /* if you can see it */ + if(uvedit_face_selected(scene, efa, tf)) { /* if the face is selected, get out now! */ + pass= 4; + break; + } + for(i= 0; (i < 3 || (i == 3 && efa->v4)); i++) { /* for each point of the face */ + itmpl= (*(&efa->v1 + i))->tmp.l; /* get unique name for points */ + if(pass == 3) { /* move */ + if(uvedit_uv_selected(scene, efa, tf, i)) { + if(!(itmpl == starttmpl || itmpl == endtmpl)) { + if(IsVertical_check != -1) tf->uv[i][0]= IsVertical_check; + if(IsHorizontal_check != -1) tf->uv[i][1]= IsHorizontal_check; + if((IsVertical_check == -1) && (IsHorizontal_check == -1)) { + midx= tf->uv[i][0]; + midy= tf->uv[i][1]; + if(tool == 's') { + secondb= midy-(secondm*midx); + midmovedx= (secondb-firstb)/(firstm-secondm); + midmovedy= (secondm*midmovedx)+secondb; + tf->uv[i][0]= midmovedx; + tf->uv[i][1]= midmovedy; + } + else if(tool == 't') { + tf->uv[i][0]= (midy-firstb)/firstm; /* midmovedx */ + } + else if(tool == 'u') { + tf->uv[i][1]= (firstm*midx)+firstb; /* midmovedy */ + } + } + } + } + } + else { + for(j= 0; (j < 3 || (j == 3 && efa->v4)); j++) { /* also for each point on the face */ + jtmpl= (*(&efa->v1 + j))->tmp.l; + if(i != j && (!efa->v4 || ABS(i-j) != 2)) { /* if the points are connected */ + /* quad (0,1,2,3) 0,1 0,3 1,0 1,2 2,1 2,3 3,0 3,2 + * triangle (0,1,2) 0,1 0,2 1,0 1,2 2,0 2,1 */ + if(uvedit_uv_selected(scene, efa, tf, i) && uvedit_uv_selected(scene, efa, tf, j)) { + /* if the edge is selected */ + if(pass == 1) { /* if finding first endpoint */ + if(starttmpl == -1) { /* if the first endpoint isn't found yet */ + starttmpl= itmpl; /* set unique name for endpoint */ + connectedtostarttmpl= jtmpl; + /* get point that endpoint is connected to */ + startface= tf; /* get face it's on */ + startcorner= i; /* what corner of the face? */ + startefa= efa; + efa= em->faces.first; + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + i= -1; + break; + } + if(starttmpl == itmpl && jtmpl != connectedtostarttmpl) { + starttmpl= -1; /* not an endpoint */ + efa= startefa; + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + i= startcorner; + break; + } + } + else if(pass == 2) { /* if finding second endpoint */ + if(endtmpl == -1 && itmpl != starttmpl) { + endtmpl= itmpl; + connectedtoendtmpl= jtmpl; + endface= tf; + endcorner= i; + endefa= efa; + efa= em->faces.first; + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + i= -1; + break; + } + if(endtmpl == itmpl && jtmpl != connectedtoendtmpl) { + endtmpl= -1; + efa= endefa; + tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + i= endcorner; + break; + } + } + } + } + } + } + } + } + } + if(pass == 2 && (starttmpl == -1 || endtmpl == -1)) { + /* if endpoints aren't found */ + pass=4; + } + } + } + uvedit_live_unwrap_update(sima, scene, obedit); DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -1076,6 +1204,9 @@ static int align_exec(bContext *C, wmOperator *op) static void UV_OT_align(wmOperatorType *ot) { static EnumPropertyItem axis_items[] = { + {'s', "ALIGN_S", 0, N_("Straighten"), N_("Align UVs along the line defined by the endpoints")}, + {'t', "ALIGN_T", 0, N_("Straighten X"), N_("Align UVs along the line defined by the endpoints along the X axis")}, + {'u', "ALIGN_U", 0, N_("Straighten Y"), N_("Align UVs along the line defined by the endpoints along the Y axis")}, {'a', "ALIGN_AUTO", 0, N_("Align Auto"), N_("Automatically choose the axis on which there is most alignment already")}, {'x', "ALIGN_X", 0, N_("Align X"), N_("Align UVs on X axis")}, {'y', "ALIGN_Y", 0, N_("Align Y"), N_("Align UVs on Y axis")}, diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 76e347270ba..8f575dfb50b 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC . - ../blenlib ../blenkernel + ../blenlib ../blenloader ../imbuf ../makesdna diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 3804aad6848..806c70d841f 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -671,7 +671,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la i = is; GPU_link(mat, "shade_visifac", i, visifac, shi->refl, &i); - vn = shi->vn; + /*if(ma->mode & MA_TANGENT_VN) GPU_link(mat, "shade_tangent_v_spec", GPU_attribute(CD_TANGENT, ""), &vn);*/ diff --git a/source/blender/ikplugin/CMakeLists.txt b/source/blender/ikplugin/CMakeLists.txt index da5c2f69635..dc637aedd6d 100644 --- a/source/blender/ikplugin/CMakeLists.txt +++ b/source/blender/ikplugin/CMakeLists.txt @@ -25,10 +25,10 @@ # ***** END GPL LICENSE BLOCK ***** set(INC + . + ../blenkernel ../blenlib ../makesdna - ../blenkernel - ../ikplugin ../../../intern/guardedalloc ../../../intern/iksolver/extern ) diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index c9a8f62a197..18b5eff5c73 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -32,12 +32,12 @@ endif() set(INC . ../avi - ../blenlib ../blenkernel + ../blenlib ../blenloader ../makesdna - ../../../intern/memutil ../../../intern/guardedalloc + ../../../intern/memutil ) set(INC_SYS @@ -113,29 +113,43 @@ if(WITH_IMAGE_OPENEXR) endif() if(WITH_IMAGE_TIFF) - list(APPEND INC_SYS ${TIFF_INCLUDE_DIR}) + list(APPEND INC_SYS + ${TIFF_INCLUDE_DIR} + ) add_definitions(-DWITH_TIFF) endif() if(WITH_IMAGE_OPENJPEG) - list(APPEND INC_SYS ${OPENJPEG_INCLUDE_DIRS}) + list(APPEND INC_SYS + ${OPENJPEG_INCLUDE_DIRS} + ) add_definitions(-DWITH_OPENJPEG) endif() if(WITH_IMAGE_REDCODE) - list(APPEND INC_SYS ${REDCODE_INC}) + list(APPEND INC_SYS + ${REDCODE_INC} + ) add_definitions(-DWITH_REDCODE) endif() if(WITH_CODEC_QUICKTIME) - list(APPEND INC ../quicktime) - list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS}) + list(APPEND INC + ../quicktime + ) + list(APPEND INC_SYS + ${QUICKTIME_INCLUDE_DIRS} + ) add_definitions(-DWITH_QUICKTIME) endif() if(WITH_CODEC_FFMPEG) - list(APPEND INC ../../../intern/ffmpeg) - list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS}) + list(APPEND INC + ../../../intern/ffmpeg + ) + list(APPEND INC_SYS + ${FFMPEG_INCLUDE_DIRS} + ) add_definitions(-DWITH_FFMPEG) endif() diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index ff01e3a8a1e..36123592c54 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -252,7 +252,7 @@ void IMB_filter(struct ImBuf *ibuf); void IMB_filterN(struct ImBuf *out, struct ImBuf *in); void IMB_mask_filter_extend(char *mask, int width, int height); void IMB_mask_clear(struct ImBuf *ibuf, char *mask, int val); -void IMB_filter_extend(struct ImBuf *ibuf, char *mask); +void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter); void IMB_makemipmap(struct ImBuf *ibuf, int use_filter); void IMB_remakemipmap(struct ImBuf *ibuf, int use_filter); struct ImBuf *IMB_getmipmap(struct ImBuf *ibuf, int level); diff --git a/source/blender/imbuf/intern/cineon/CMakeLists.txt b/source/blender/imbuf/intern/cineon/CMakeLists.txt index 079f34af773..4f7f20beecf 100644 --- a/source/blender/imbuf/intern/cineon/CMakeLists.txt +++ b/source/blender/imbuf/intern/cineon/CMakeLists.txt @@ -29,8 +29,8 @@ set(INC .. ../.. ../../../blenkernel - ../../../blenloader ../../../blenlib + ../../../blenloader ../../../makesdna ../../../../../intern/guardedalloc ) diff --git a/source/blender/imbuf/intern/dds/CMakeLists.txt b/source/blender/imbuf/intern/dds/CMakeLists.txt index fd2b94547b4..53822b830f7 100644 --- a/source/blender/imbuf/intern/dds/CMakeLists.txt +++ b/source/blender/imbuf/intern/dds/CMakeLists.txt @@ -28,9 +28,8 @@ set(INC . .. ../.. - intern/include - ../../../blenlib ../../../blenkernel + ../../../blenlib ../../../makesdna ../../../../../intern/guardedalloc ) diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index d12360e5a7e..1644e653df4 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -21,7 +21,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Morten Mikkelsen. * * ***** END GPL LICENSE BLOCK ***** * filter.c @@ -326,121 +326,132 @@ void IMB_mask_clear(ImBuf *ibuf, char *mask, int val) } } -#define EXTEND_PIXEL(color, w) if((color)[3]) {r+= w*(color)[0]; g+= w*(color)[1]; b+= w*(color)[2]; a+= w*(color)[3]; tot+=w;} +static int filter_make_index(const int x, const int y, const int w, const int h) +{ + if(x<0 || x>=w || y<0 || y>=h) return -1; /* return bad index */ + else return y*w+x; +} + +static int check_pixel_assigned(const void *buffer, const char *mask, const int index, const int depth, const int is_float) +{ + int res = 0; + + if(index>=0) { + const int alpha_index = depth*index+(depth-1); + + if(mask!=NULL) { + res = mask[index]!=0 ? 1 : 0; + } + else if( (is_float && ((const float *) buffer)[alpha_index]!=0.0f) || + (!is_float && ((const unsigned char *) buffer)[alpha_index]!=0) ) { + res=1; + } + } + + return res; +} /* if alpha is zero, it checks surrounding pixels and averages color. sets new alphas to 1.0 * * When a mask is given, only effect pixels with a mask value of 1, defined as BAKE_MASK_MARGIN in rendercore.c * */ -void IMB_filter_extend(struct ImBuf *ibuf, char *mask) +void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) { - register char *row1, *row2, *row3; - register char *cp; - int rowlen, x, y; - - rowlen= ibuf->x; - - - if (ibuf->rect_float) { - float *temprect; - float *row1f, *row2f, *row3f; - float *fp; - temprect= MEM_dupallocN(ibuf->rect_float); - - for(y=1; y<=ibuf->y; y++) { - /* setup rows */ - row1f= (float *)(temprect + (y-2)*rowlen*4); - row2f= row1f + 4*rowlen; - row3f= row2f + 4*rowlen; - if(y==1) - row1f= row2f; - else if(y==ibuf->y) - row3f= row2f; - - fp= (float *)(ibuf->rect_float + (y-1)*rowlen*4); - - for(x=0; x<rowlen; x++) { - if((mask==NULL && fp[3]==0.0f) || (mask && mask[((y-1)*rowlen)+x]==1)) { - int tot= 0; - float r=0.0f, g=0.0f, b=0.0f, a=0.0f; - - EXTEND_PIXEL(row1f, 1); - EXTEND_PIXEL(row2f, 2); - EXTEND_PIXEL(row3f, 1); - EXTEND_PIXEL(row1f+4, 2); - EXTEND_PIXEL(row3f+4, 2); - if(x!=rowlen-1) { - EXTEND_PIXEL(row1f+8, 1); - EXTEND_PIXEL(row2f+8, 2); - EXTEND_PIXEL(row3f+8, 1); - } - if(tot) { - fp[0]= r/tot; - fp[1]= g/tot; - fp[2]= b/tot; - fp[3]= a/tot; + const int width= ibuf->x; + const int height= ibuf->y; + const int depth= 4; /* always 4 channels */ + const int chsize= ibuf->rect_float ? sizeof(float) : sizeof(unsigned char); + const int bsize= width*height*depth*chsize; + const int is_float= ibuf->rect_float!=NULL; + void *dstbuf= (void *) MEM_dupallocN(ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect); + char *dstmask= mask==NULL ? NULL : (char *) MEM_dupallocN(mask); + void *srcbuf= ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect; + char *srcmask= mask; + int cannot_early_out= 1, r, n, k, i, j, c; + float weight[25]; + + /* build a weights buffer */ + n= 2; + k= 0; + for(i = -n; i <= n; i++) + for(j = -n; j <= n; j++) + weight[k++] = sqrt((float) i * i + j * j); + + /* run passes */ + for(r = 0; cannot_early_out == 1 && r < filter; r++) { + int x, y; + cannot_early_out = 0; + + for(y= 0; y<height; y++) { + for(x= 0; x<width; x++) { + const int index= filter_make_index(x, y, width, height); + + /* only update unassigned pixels */ + if(!check_pixel_assigned(srcbuf, srcmask, index, depth, is_float)) { + float tmp[4]; + float wsum=0; + float acc[4]={0,0,0,0}; + k = 0; + + if (check_pixel_assigned(srcbuf, srcmask, filter_make_index(x-1, y, width, height), depth, is_float) || + check_pixel_assigned(srcbuf, srcmask, filter_make_index(x+1, y, width, height), depth, is_float) || + check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y-1, width, height), depth, is_float) || + check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y+1, width, height), depth, is_float)) { + for(i= -n; i<=n; i++) { + for(j=-n; j<=n; j++) { + if(i != 0 || j != 0) { + const int tmpindex= filter_make_index(x+i, y+j, width, height); + + if(check_pixel_assigned(srcbuf, srcmask, tmpindex, depth, is_float)) { + if(is_float) { + for(c=0; c<depth; c++) + tmp[c] = ((const float *) srcbuf)[depth*tmpindex+c]; + } + else { + for(c=0; c<depth; c++) + tmp[c] = (float) ((const unsigned char *) srcbuf)[depth*tmpindex+c]; + } + + wsum+= weight[k]; + + for(c=0; c<depth; c++) + acc[c]+= weight[k] * tmp[c]; + } + } + k++; + } + } + + if(wsum!=0) { + for(c=0; c<depth; c++) + acc[c]/= wsum; + + if(is_float) { + for(c=0; c<depth; c++) + ((float *) dstbuf)[depth*index+c] = acc[c]; + } + else { + for(c=0; c<depth; c++) { + ((unsigned char *) dstbuf)[depth*index+c]= acc[c] > 255 ? 255 : (acc[c] < 0 ? 0 : ((unsigned char) (acc[c]+0.5f))); + } + } + + if(dstmask!=NULL) dstmask[index]=FILTER_MASK_MARGIN; /* assigned */ + cannot_early_out = 1; + } } } - fp+=4; - - if(x!=0) { - row1f+=4; row2f+=4; row3f+=4; - } } } - MEM_freeN(temprect); - } - else if(ibuf->rect) { - int *temprect; - - /* make a copy, to prevent flooding */ - temprect= MEM_dupallocN(ibuf->rect); - - for(y=1; y<=ibuf->y; y++) { - /* setup rows */ - row1= (char *)(temprect + (y-2)*rowlen); - row2= row1 + 4*rowlen; - row3= row2 + 4*rowlen; - if(y==1) - row1= row2; - else if(y==ibuf->y) - row3= row2; - - cp= (char *)(ibuf->rect + (y-1)*rowlen); - - for(x=0; x<rowlen; x++) { - /*if(cp[3]==0) {*/ - if((mask==NULL && cp[3]==0) || (mask && mask[((y-1)*rowlen)+x]==1)) { - int tot= 0, r=0, g=0, b=0, a=0; - - EXTEND_PIXEL(row1, 1); - EXTEND_PIXEL(row2, 2); - EXTEND_PIXEL(row3, 1); - EXTEND_PIXEL(row1+4, 2); - EXTEND_PIXEL(row3+4, 2); - if(x!=rowlen-1) { - EXTEND_PIXEL(row1+8, 1); - EXTEND_PIXEL(row2+8, 2); - EXTEND_PIXEL(row3+8, 1); - } - if(tot) { - cp[0]= r/tot; - cp[1]= g/tot; - cp[2]= b/tot; - cp[3]= a/tot; - } - } - cp+=4; - - if(x!=0) { - row1+=4; row2+=4; row3+=4; - } - } - } - - MEM_freeN(temprect); + /* keep the original buffer up to date. */ + memcpy(srcbuf, dstbuf, bsize); + if(dstmask!=NULL) memcpy(srcmask, dstmask, width*height); } + + /* free memory */ + MEM_freeN(dstbuf); + if(dstmask!=NULL) MEM_freeN(dstmask); } /* threadsafe version, only recreates existing maps */ diff --git a/source/blender/imbuf/intern/openexr/CMakeLists.txt b/source/blender/imbuf/intern/openexr/CMakeLists.txt index 9ca4dff5bc8..3be5219ae44 100644 --- a/source/blender/imbuf/intern/openexr/CMakeLists.txt +++ b/source/blender/imbuf/intern/openexr/CMakeLists.txt @@ -30,9 +30,8 @@ set(INC ../.. ../../../blenkernel ../../../blenlib - intern/include - ../../../../../intern/guardedalloc ../../../makesdna + ../../../../../intern/guardedalloc ) set(INC_SYS @@ -44,7 +43,9 @@ set(SRC ) if(WITH_IMAGE_OPENEXR) - list(APPEND INC_SYS ${OPENEXR_INCLUDE_DIRS}) + list(APPEND INC_SYS + ${OPENEXR_INCLUDE_DIRS} + ) add_definitions(-DWITH_OPENEXR) endif() diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index 99ed2319415..dd033339ca4 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -102,7 +102,8 @@ typedef struct Image { short animspeed; /* for generated images */ - short gen_x, gen_y, gen_type; + short gen_x, gen_y; + char gen_type, gen_flag; /* display aspect - for UV editing images resized for faster openGL display */ float aspx, aspy; @@ -136,5 +137,8 @@ typedef struct Image { #define IMA_MAX_RENDER_TEXT 512 #define IMA_MAX_RENDER_SLOT 8 +/* gen_flag */ +#define IMA_GEN_FLOAT 1 + #endif diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index d2d8e014015..3787675f339 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -624,6 +624,7 @@ typedef struct MultiresModifierData { typedef enum { eMultiresModifierFlag_ControlEdges = (1<<0), + eMultiresModifierFlag_PlainUv = (1<<1), } MultiresModifierFlag; typedef struct FluidsimModifierData { diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 03387c3a63a..efaf30b02f6 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -179,6 +179,10 @@ typedef struct bNodeLink { } bNodeLink; + +/* link->flag */ +#define NODE_LINKFLAG_HILITE 1 + /* the basis for a Node tree, all links and nodes reside internal here */ /* only re-usable node trees are in the library though, materials and textures allocate own tree struct */ typedef struct bNodeTree { diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index aace8156e9d..69ee530c0b6 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -89,7 +89,8 @@ typedef struct ParticleDupliWeight { struct ParticleDupliWeight *next, *prev; struct Object *ob; short count; - short flag, rt[2]; + short flag; + short index, rt; /* only updated on file save and used on file load */ } ParticleDupliWeight; typedef struct ParticleData { diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index f351a48b998..2211f93a8ae 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -430,7 +430,8 @@ typedef struct GameData { /* * Radius of the activity bubble, in Manhattan length. Objects * outside the box are activity-culled. */ - float activityBoxRadius; //it's not being used ANYWHERE !!!!!!!!!!!!!! + float activityBoxRadius; + /* * bit 3: (gameengine): Activity culling is enabled. * bit 5: (gameengine) : enable Bullet DBVT tree for view frustrum culling @@ -447,7 +448,8 @@ typedef struct GameData { /* stereo/dome mode */ struct GameDome dome; - short stereoflag, stereomode, xsch, ysch; //xsch and ysch used for backwards compat. + short stereoflag, stereomode; + short pad2, pad3; float eyeseparation, pad1; } GameData; @@ -1072,7 +1074,7 @@ typedef struct Scene { #define SCE_SNAP_ROTATE 2 #define SCE_SNAP_PEEL_OBJECT 4 #define SCE_SNAP_PROJECT 8 -#define SCE_SNAP_PROJECT_NO_SELF 16 +#define SCE_SNAP_NO_SELF 16 /* toolsettings->snap_target */ #define SCE_SNAP_TARGET_CLOSEST 0 #define SCE_SNAP_TARGET_CENTER 1 @@ -1105,7 +1107,8 @@ typedef struct Scene { #define PROP_SHARP 3 #define PROP_LIN 4 #define PROP_CONST 5 -#define PROP_RANDOM 6 +#define PROP_RANDOM 6 +#define PROP_MODE_MAX 7 /* toolsettings->proportional */ #define PROP_EDIT_OFF 0 diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 09fb11282f9..be58daa1ac4 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -172,17 +172,25 @@ if(WITH_IMAGE_HDR) add_definitions(-DWITH_HDR) endif() +if(WITH_IMAGE_FRAMESERVER) + add_definitions(-DWITH_FRAMESERVER) +endif() + if(WITH_AUDASPACE) add_definitions(-DWITH_AUDASPACE) endif() if(WITH_CODEC_QUICKTIME) - list(APPEND INC ../../quicktime) + list(APPEND INC + ../../quicktime + ) add_definitions(-DWITH_QUICKTIME) endif() if(WITH_CODEC_FFMPEG) - list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS}) + list(APPEND INC_SYS + ${FFMPEG_INCLUDE_DIRS} + ) add_definitions(-DWITH_FFMPEG) endif() diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 421c3a60691..160aeca4a51 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -12,6 +12,7 @@ root_build_dir=normpath(env['BF_BUILDDIR']) source_files = env.Glob('*.c') source_files.remove('rna_access.c') +source_files.append('../../blenfont/intern/blf_gettext.c') generated_files = source_files[:] generated_files.remove('rna_define.c') @@ -54,6 +55,8 @@ if env['WITH_BF_CINEON']: if env['WITH_BF_HDR']: defs.append('WITH_HDR') +defs.append('WITH_FRAMESERVER') # TODO, make optional + if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') incs += ' ' + env['BF_FFMPEG_INC'] diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index efa7306124a..b6f38332a3b 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4488,15 +4488,15 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *UNUSE if(!(parm->flag & PROP_REQUIRED) && !(parm->flag & PROP_DYNAMIC)) { switch(parm->type) { case PROP_BOOLEAN: - if(parm->arraydimension) memcpy(data, &((BooleanPropertyRNA*)parm)->defaultarray, size); + if(parm->arraydimension) memcpy(data, ((BooleanPropertyRNA*)parm)->defaultarray, size); else memcpy(data, &((BooleanPropertyRNA*)parm)->defaultvalue, size); break; case PROP_INT: - if(parm->arraydimension) memcpy(data, &((IntPropertyRNA*)parm)->defaultarray, size); + if(parm->arraydimension) memcpy(data, ((IntPropertyRNA*)parm)->defaultarray, size); else memcpy(data, &((IntPropertyRNA*)parm)->defaultvalue, size); break; case PROP_FLOAT: - if(parm->arraydimension) memcpy(data, &((FloatPropertyRNA*)parm)->defaultarray, size); + if(parm->arraydimension) memcpy(data, ((FloatPropertyRNA*)parm)->defaultarray, size); else memcpy(data, &((FloatPropertyRNA*)parm)->defaultvalue, size); break; case PROP_ENUM: diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index a52849b3366..eac4932ac43 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -502,6 +502,11 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Generated Height", "Generated image height"); RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update"); + prop= RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT); + RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer"); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_Image_generated_update"); + /* realtime properties */ prop= RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index d2c1b862fee..ba655915fb6 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -805,6 +805,11 @@ static void rna_def_modifier_multires(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", eMultiresModifierFlag_ControlEdges); RNA_def_property_ui_text(prop, "Optimal Display", "Skip drawing/rendering of interior subdivided edges"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop= RNA_def_property(srna, "use_subsurf_uv", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", eMultiresModifierFlag_PlainUv); + RNA_def_property_ui_text(prop, "Subdivide UVs", "Use subsurf to subdivide UVs"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_lattice(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 61d6a93d147..e2794baad34 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -484,7 +484,7 @@ static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr) static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; - return MAX2(ob->actdef-1, 0); + return ob->actdef-1; } static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value) diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index d6af04f2475..21fa28af01a 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -45,6 +45,8 @@ // #include "ED_mesh.h" +#include "BLI_math.h" + #ifdef RNA_RUNTIME #include "BKE_main.h" @@ -64,8 +66,6 @@ #include "BKE_mball.h" #include "BKE_modifier.h" -#include "BLI_math.h" - #include "DNA_mesh_types.h" #include "DNA_scene_types.h" #include "DNA_meshdata_types.h" @@ -415,6 +415,41 @@ void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], fl *index= -1; } +void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, float point_co[3], float max_dist, float n_location[3], float n_normal[3], int *index) +{ + BVHTreeFromMesh treeData= {NULL}; + + if(ob->derivedFinal==NULL) { + BKE_reportf(reports, RPT_ERROR, "object \"%s\" has no mesh data to be used for finding nearest point.", ob->id.name+2); + return; + } + + /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ + bvhtree_from_mesh_faces(&treeData, ob->derivedFinal, 0.0f, 4, 6); + + if(treeData.tree==NULL) { + BKE_reportf(reports, RPT_ERROR, "object \"%s\" could not create internal data for finding nearest point", ob->id.name+2); + return; + } + else { + BVHTreeNearest nearest; + + nearest.index = -1; + nearest.dist = max_dist * max_dist; + + if(BLI_bvhtree_find_nearest(treeData.tree, point_co, &nearest, treeData.nearest_callback, &treeData) != -1) { + copy_v3_v3(n_location, nearest.co); + copy_v3_v3(n_normal, nearest.no); + *index= nearest.index; + return; + } + } + + zero_v3(n_location); + zero_v3(n_normal); + *index= -1; +} + /* ObjectBase */ void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) @@ -501,6 +536,27 @@ void RNA_api_object(StructRNA *srna) parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no intersection is found.", 0, 0); RNA_def_function_output(func, parm); + /* Nearest Point */ + func= RNA_def_function(srna, "closest_point_on_mesh", "rna_Object_closest_point_on_mesh"); + RNA_def_function_ui_description(func, "Find the nearest point on the object."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + + /* location of point for test and max distance */ + parm= RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_float(func, "max_dist", sqrt(FLT_MAX), 0.0, FLT_MAX, "", "", 0.0, FLT_MAX); + + /* return location and normal */ + parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The location on the object closest to the point", -1e4, 1e4); + RNA_def_property_flag(parm, PROP_THICK_WRAP); + RNA_def_function_output(func, parm); + parm= RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "The face normal at the closest point", -1e4, 1e4); + RNA_def_property_flag(parm, PROP_THICK_WRAP); + RNA_def_function_output(func, parm); + + parm= RNA_def_int(func, "index", 0, 0, 0, "", "The face index, -1 when no closest point is found.", 0, 0); + RNA_def_function_output(func, parm); + /* View */ func= RNA_def_function(srna, "is_visible", "rna_Object_is_visible"); RNA_def_function_ui_description(func, "Determine if object is visible in a given scene."); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 3ff42e752af..9714b51a986 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -30,9 +30,11 @@ #include <stdlib.h> #include "RNA_define.h" -#include "BLF_api.h" + #include "rna_internal.h" +#include "BLF_api.h" + #include "DNA_cloth_types.h" #include "DNA_object_types.h" #include "DNA_object_force.h" diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index adad1948032..7508b84a0d0 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -136,7 +136,9 @@ EnumPropertyItem image_type_items[] = { #endif {R_AVIJPEG, "AVI_JPEG", ICON_FILE_MOVIE, "AVI JPEG", "Output video in AVI JPEG format"}, {R_AVIRAW, "AVI_RAW", ICON_FILE_MOVIE, "AVI Raw", "Output video in AVI Raw format"}, +#ifdef WITH_FRAMESERVER {R_FRAMESERVER, "FRAMESERVER", ICON_FILE_SCRIPT, "Frame Server", "Output image to a frameserver"}, +#endif #ifdef WITH_FFMPEG {R_H264, "H264", ICON_FILE_MOVIE, "H.264", "Output video in H.264 format"}, {R_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "MPEG", "Output video in MPEG format"}, @@ -1177,9 +1179,9 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_RETOPO, 0); RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ - prop= RNA_def_property(srna, "use_snap_project_self", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_flag", SCE_SNAP_PROJECT_NO_SELF); - RNA_def_property_ui_text(prop, "Project to Self", "Project into its self (editmode)"); + prop= RNA_def_property(srna, "use_snap_self", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_flag", SCE_SNAP_NO_SELF); + RNA_def_property_ui_text(prop, "Project to Self", "Snap onto its self (editmode)"); RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 833f45ec4cc..68da28788de 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -702,7 +702,7 @@ static void rna_ConsoleLine_cursor_index_range(PointerRNA *ptr, int *min, int *m ConsoleLine *ci= (ConsoleLine*)ptr->data; *min= 0; - *max= ci->len; + *max= ci->len; /* intentionally _not_ -1 */ } /* Space Dopesheet */ diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index ff9adfbab0d..3e2feec71d9 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2464,6 +2464,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) {23, "GREEK", 0, N_("Greek (Ελληνικά)"), "el_GR"}, {24, "KOREAN", 0, N_("Korean (í•œêµ ì–¸ì–´)"), "ko_KR"}, {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "UserPreferencesSystem", NULL); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "UserPreferences"); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 0171576b52e..3db4d319420 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -942,7 +942,7 @@ static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void * rna_Operator_unregister(bmain, ot->ext.srna); } - /* create a new menu type */ + /* create a new operator type */ dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator"); RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */ dummyot.ext.data= data; diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 348e2a0ec1d..d1f153265ac 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -25,15 +25,16 @@ # ***** END GPL LICENSE BLOCK ***** set(INC - . ./intern + . + intern + ../blenkernel + ../blenkernel/intern ../blenlib ../blenloader ../makesdna - ../blenkernel - ../blenkernel/intern ../render/extern/include - ../../../intern/guardedalloc ../../../intern/elbeem/extern + ../../../intern/guardedalloc ) set(INC_SYS @@ -98,7 +99,9 @@ endif() if(WITH_MOD_DECIMATE) add_definitions(-DWITH_MOD_DECIMATE) - list(APPEND INC ../../../intern/decimation/extern) + list(APPEND INC + ../../../intern/decimation/extern + ) endif() if(NOT WITH_MOD_FLUID) diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h index b9b5c8a064a..5e6f377acf1 100644 --- a/source/blender/modifiers/intern/MOD_util.h +++ b/source/blender/modifiers/intern/MOD_util.h @@ -52,6 +52,6 @@ void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]); void validate_layer_name(const struct CustomData *data, int type, char *name, char *outname); struct DerivedMesh *get_cddm(struct Object *ob, struct EditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3]); struct DerivedMesh *get_dm(struct Object *ob, struct EditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3], int orco); -void modifier_get_vgroup(struct Object *ob, DerivedMesh *dm, const char *name, struct MDeformVert **dvert, int *defgrp_index); +void modifier_get_vgroup(struct Object *ob, struct DerivedMesh *dm, const char *name, struct MDeformVert **dvert, int *defgrp_index); #endif /* MOD_UTIL_H */ diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index d2b58d61112..c3bd37c18ee 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -152,8 +152,12 @@ set(SRC ) if(WITH_PYTHON) - list(APPEND INC ../python) - list(APPEND INC_SYS ${PYTHON_INCLUDE_DIRS}) + list(APPEND INC + ../python + ) + list(APPEND INC_SYS + ${PYTHON_INCLUDE_DIRS} + ) add_definitions(-DWITH_PYTHON) endif() diff --git a/source/blender/nodes/intern/SHD_util.c b/source/blender/nodes/intern/SHD_util.c index cf7c64c9d5e..190f68ce19a 100644 --- a/source/blender/nodes/intern/SHD_util.c +++ b/source/blender/nodes/intern/SHD_util.c @@ -83,7 +83,11 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) { ShaderCallData scd; - + /* + @note: preserve material from ShadeInput for material id, nodetree execs change it + fix for bug "[#28012] Mat ID messy with shader nodes" + */ + Material *mat = shi->mat; /* convert caller data to struct */ scd.shi= shi; scd.shr= shr; @@ -92,7 +96,8 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) memset(shr, 0, sizeof(ShadeResult)); ntreeExecTree(ntree, &scd, shi->thread); /* threads */ - + // @note: set material back to preserved material + shi->mat = mat; /* better not allow negative for now */ if(shr->combined[0]<0.0f) shr->combined[0]= 0.0f; if(shr->combined[1]<0.0f) shr->combined[1]= 0.0f; diff --git a/source/blender/python/CMakeLists.txt b/source/blender/python/CMakeLists.txt index fe9e0307703..8071edb378f 100644 --- a/source/blender/python/CMakeLists.txt +++ b/source/blender/python/CMakeLists.txt @@ -18,3 +18,4 @@ add_subdirectory(intern) add_subdirectory(generic) +add_subdirectory(mathutils) diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index de6b859d259..dec0de4a6ab 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -1,6 +1,6 @@ #!/usr/bin/python -# TODO, split into 2 files. +# TODO, split into 3 files. Import ('env') @@ -18,7 +18,14 @@ if is_debug: defs.append('_DEBUG') sources = env.Glob('generic/*.c') -env.BlenderLib( libname = 'bf_python_ext', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [362,165]) # ketsji is 360 +env.BlenderLib( libname = 'bf_python_ext', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [363,165]) # ketsji is 360 + + +# mathutils +defs = [] + +sources = env.Glob('mathutils/*.c') +env.BlenderLib( libname = 'bf_python_mathutils', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [362,165]) # bpy diff --git a/source/blender/python/generic/CMakeLists.txt b/source/blender/python/generic/CMakeLists.txt index 0889c77f9ad..8dfbf476995 100644 --- a/source/blender/python/generic/CMakeLists.txt +++ b/source/blender/python/generic/CMakeLists.txt @@ -20,10 +20,10 @@ set(INC . - ../../blenlib - ../../makesdna ../../blenkernel + ../../blenlib ../../blenloader + ../../makesdna ../../../../intern/guardedalloc ) @@ -37,13 +37,6 @@ set(SRC bgl.c blf_py_api.c bpy_internal_import.c - mathutils.c - mathutils_Color.c - mathutils_Euler.c - mathutils_Matrix.c - mathutils_Quaternion.c - mathutils_Vector.c - mathutils_geometry.c noise_py_api.c py_capi_utils.c @@ -51,13 +44,6 @@ set(SRC bgl.h blf_py_api.h bpy_internal_import.h - mathutils.h - mathutils_Color.h - mathutils_Euler.h - mathutils_Matrix.h - mathutils_Quaternion.h - mathutils_Vector.h - mathutils_geometry.h noise_py_api.h py_capi_utils.h ) diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 1891e13fdc1..09432e0b316 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -48,12 +48,15 @@ static PyObject *Buffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds); /* Buffer sequence methods */ -static int Buffer_len(PyObject *self); -static PyObject *Buffer_item(PyObject *self, int i); -static PyObject *Buffer_slice(PyObject *self, int begin, int end); -static int Buffer_ass_item(PyObject *self, int i, PyObject *v); -static int Buffer_ass_slice(PyObject *self, int begin, int end, +static int Buffer_len(Buffer *self); +static PyObject *Buffer_item(Buffer *self, int i); +static PyObject *Buffer_slice(Buffer *self, int begin, int end); +static int Buffer_ass_item(Buffer *self, int i, PyObject *v); +static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq); +static PyObject *Buffer_subscript(Buffer *self, PyObject *item); +static int Buffer_ass_subscript(Buffer *self, PyObject *item, + PyObject *value); static PySequenceMethods Buffer_SeqMethods = { (lenfunc) Buffer_len, /*sq_length */ @@ -68,12 +71,80 @@ static PySequenceMethods Buffer_SeqMethods = { (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; -static void Buffer_dealloc(PyObject *self); -static PyObject *Buffer_tolist(PyObject *self, void *arg); -static PyObject *Buffer_dimensions(PyObject *self, void *arg); -static PyObject *Buffer_repr(PyObject *self); -static PyMethodDef Buffer_methods[]; -static PyGetSetDef Buffer_getseters[]; + +static PyMappingMethods Buffer_AsMapping = { + (lenfunc)Buffer_len, + (binaryfunc)Buffer_subscript, + (objobjargproc)Buffer_ass_subscript +}; + +static void Buffer_dealloc(Buffer *self); +static PyObject *Buffer_repr(Buffer *self); + +static PyObject *Buffer_to_list(Buffer *self) +{ + int i, len= self->dimensions[0]; + PyObject *list= PyList_New(len); + + for (i=0; i<len; i++) { + PyList_SET_ITEM(list, i, Buffer_item(self, i)); + } + + return list; +} + +static PyObject *Buffer_to_list_recursive(Buffer *self) +{ + PyObject *list; + + if(self->ndimensions > 1) { + int i, len= self->dimensions[0]; + list= PyList_New(len); + + for (i=0; i<len; i++) { + Buffer *sub= (Buffer *)Buffer_item(self, i); + PyList_SET_ITEM(list, i, Buffer_to_list_recursive(sub)); + Py_DECREF(sub); + } + } + else { + list= Buffer_to_list(self); + } + + return list; +} + +/* *DEPRECATED* 2011/7/17 bgl.Buffer.list */ +static PyObject *Buffer_list(Buffer *self, void *UNUSED(arg)) +{ + fprintf(stderr, "Warning: 'Buffer.list' deprecated, use '[:]' instead\n"); + return Buffer_to_list(self); +} + +static PyObject *Buffer_dimensions(Buffer *self, void *UNUSED(arg)) +{ + PyObject *list= PyList_New(self->ndimensions); + int i; + + for (i= 0; i<self->ndimensions; i++) { + PyList_SET_ITEM(list, i, PyLong_FromLong(self->dimensions[i])); + } + + return list; +} + +static PyMethodDef Buffer_methods[] = { + {"to_list", (PyCFunction)Buffer_to_list_recursive, METH_NOARGS, + "return the buffer as a list"}, + {NULL, NULL, 0, NULL} +}; + +static PyGetSetDef Buffer_getseters[] = { + {(char *)"list", (getter)Buffer_list, NULL, NULL, NULL}, + {(char *)"dimensions", (getter)Buffer_dimensions, NULL, NULL, NULL}, + {NULL, NULL, NULL, NULL, NULL} +}; + PyTypeObject BGL_bufferType = { PyVarObject_HEAD_INIT(NULL, 0) @@ -88,7 +159,7 @@ PyTypeObject BGL_bufferType = { (reprfunc) Buffer_repr, /*tp_repr */ NULL, /*tp_as_number */ &Buffer_SeqMethods, /*tp_as_sequence */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + &Buffer_AsMapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ @@ -229,7 +300,8 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject int ndimensions = 0; if(kwds && PyDict_Size(kwds)) { - PyErr_SetString(PyExc_TypeError, "bgl.Buffer(): takes no keyword args"); + PyErr_SetString(PyExc_TypeError, + "bgl.Buffer(): takes no keyword args"); return NULL; } @@ -286,7 +358,7 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject buffer= BGL_MakeBuffer(type, ndimensions, dimensions, NULL); if (init && ndimensions) { - if (Buffer_ass_slice((PyObject *) buffer, 0, dimensions[0], init)) { + if (Buffer_ass_slice(buffer, 0, dimensions[0], init)) { Py_DECREF(buffer); return NULL; } @@ -297,51 +369,48 @@ static PyObject *Buffer_new(PyTypeObject *UNUSED(type), PyObject *args, PyObject /*@ Buffer sequence methods */ -static int Buffer_len(PyObject *self) +static int Buffer_len(Buffer *self) { - Buffer *buf= (Buffer *) self; - return buf->dimensions[0]; + return self->dimensions[0]; } -static PyObject *Buffer_item(PyObject *self, int i) +static PyObject *Buffer_item(Buffer *self, int i) { - Buffer *buf= (Buffer *) self; - - if (i >= buf->dimensions[0]) { + if (i >= self->dimensions[0] || i < 0) { PyErr_SetString(PyExc_IndexError, "array index out of range"); return NULL; } - if (buf->ndimensions==1) { - switch (buf->type) { - case GL_BYTE: return Py_BuildValue("b", buf->buf.asbyte[i]); - case GL_SHORT: return Py_BuildValue("h", buf->buf.asshort[i]); - case GL_INT: return Py_BuildValue("i", buf->buf.asint[i]); - case GL_FLOAT: return PyFloat_FromDouble(buf->buf.asfloat[i]); - case GL_DOUBLE: return Py_BuildValue("d", buf->buf.asdouble[i]); + if (self->ndimensions==1) { + switch (self->type) { + case GL_BYTE: return Py_BuildValue("b", self->buf.asbyte[i]); + case GL_SHORT: return Py_BuildValue("h", self->buf.asshort[i]); + case GL_INT: return Py_BuildValue("i", self->buf.asint[i]); + case GL_FLOAT: return PyFloat_FromDouble(self->buf.asfloat[i]); + case GL_DOUBLE: return Py_BuildValue("d", self->buf.asdouble[i]); } } else { Buffer *newbuf; int j, length, size; - + length= 1; - for (j=1; j<buf->ndimensions; j++) { - length*= buf->dimensions[j]; + for (j=1; j < self->ndimensions; j++) { + length *= self->dimensions[j]; } - size= BGL_typeSize(buf->type); + size= BGL_typeSize(self->type); newbuf= (Buffer *) PyObject_NEW(Buffer, &BGL_bufferType); Py_INCREF(self); - newbuf->parent= self; + newbuf->parent= (PyObject *)self; - newbuf->ndimensions= buf->ndimensions-1; - newbuf->type= buf->type; - newbuf->buf.asvoid= buf->buf.asbyte + i*length*size; + newbuf->ndimensions= self->ndimensions - 1; + newbuf->type= self->type; + newbuf->buf.asvoid= self->buf.asbyte + i*length*size; newbuf->dimensions= MEM_mallocN(newbuf->ndimensions*sizeof(int), "Buffer dimensions"); - memcpy(newbuf->dimensions, buf->dimensions+1, + memcpy(newbuf->dimensions, self->dimensions+1, newbuf->ndimensions*sizeof(int)); return (PyObject *) newbuf; @@ -350,16 +419,14 @@ static PyObject *Buffer_item(PyObject *self, int i) return NULL; } -static PyObject *Buffer_slice(PyObject *self, int begin, int end) +static PyObject *Buffer_slice(Buffer *self, int begin, int end) { - Buffer *buf= (Buffer *) self; PyObject *list; int count; - if (begin<0) begin= 0; - if (end>buf->dimensions[0]) - end= buf->dimensions[0]; - if (begin>end) begin= end; + if (begin < 0) begin= 0; + if (end > self->dimensions[0]) end= self->dimensions[0]; + if (begin > end) begin= end; list= PyList_New(end-begin); @@ -369,21 +436,19 @@ static PyObject *Buffer_slice(PyObject *self, int begin, int end) return list; } -static int Buffer_ass_item(PyObject *self, int i, PyObject *v) +static int Buffer_ass_item(Buffer *self, int i, PyObject *v) { - Buffer *buf= (Buffer *) self; - - if (i >= buf->dimensions[0]) { + if (i >= self->dimensions[0] || i < 0) { PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); return -1; } - if (buf->ndimensions!=1) { - PyObject *row= Buffer_item(self, i); + if (self->ndimensions!=1) { + Buffer *row= (Buffer *)Buffer_item(self, i); if (row) { - int ret= Buffer_ass_slice(row, 0, buf->dimensions[1], v); + int ret= Buffer_ass_slice(row, 0, self->dimensions[1], v); Py_DECREF(row); return ret; } @@ -392,31 +457,30 @@ static int Buffer_ass_item(PyObject *self, int i, PyObject *v) } } - switch(buf->type) { + switch(self->type) { case GL_BYTE: - return PyArg_Parse(v, "b:Expected ints", &buf->buf.asbyte[i]) ? 0:-1; + return PyArg_Parse(v, "b:Expected ints", &self->buf.asbyte[i]) ? 0:-1; case GL_SHORT: - return PyArg_Parse(v, "h:Expected ints", &buf->buf.asshort[i]) ? 0:-1; + return PyArg_Parse(v, "h:Expected ints", &self->buf.asshort[i]) ? 0:-1; case GL_INT: - return PyArg_Parse(v, "i:Expected ints", &buf->buf.asint[i]) ? 0:-1; + return PyArg_Parse(v, "i:Expected ints", &self->buf.asint[i]) ? 0:-1; case GL_FLOAT: - return PyArg_Parse(v, "f:Expected floats", &buf->buf.asfloat[i]) ? 0:-1; + return PyArg_Parse(v, "f:Expected floats", &self->buf.asfloat[i]) ? 0:-1; case GL_DOUBLE: - return PyArg_Parse(v, "d:Expected floats", &buf->buf.asdouble[i]) ? 0:-1; + return PyArg_Parse(v, "d:Expected floats", &self->buf.asdouble[i]) ? 0:-1; default: return 0; /* should never happen */ } } -static int Buffer_ass_slice(PyObject *self, int begin, int end, PyObject *seq) +static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq) { - Buffer *buf= (Buffer *) self; PyObject *item; int count, err=0; - if (begin<0) begin= 0; - if (end>buf->dimensions[0]) end= buf->dimensions[0]; - if (begin>end) begin= end; + if (begin < 0) begin= 0; + if (end > self->dimensions[0]) end= self->dimensions[0]; + if (begin > end) begin= end; if (!PySequence_Check(seq)) { PyErr_Format(PyExc_TypeError, @@ -448,62 +512,94 @@ static int Buffer_ass_slice(PyObject *self, int begin, int end, PyObject *seq) return err; } -static void Buffer_dealloc(PyObject *self) +static PyObject *Buffer_subscript(Buffer *self, PyObject *item) { - Buffer *buf = (Buffer *)self; + if (PyIndex_Check(item)) { + Py_ssize_t i; + i = PyNumber_AsSsize_t(item, PyExc_IndexError); + if (i == -1 && PyErr_Occurred()) + return NULL; + if (i < 0) + i += self->dimensions[0]; + return Buffer_item(self, i); + } + else if (PySlice_Check(item)) { + Py_ssize_t start, stop, step, slicelength; - if (buf->parent) Py_DECREF(buf->parent); - else MEM_freeN (buf->buf.asvoid); + if (PySlice_GetIndicesEx((void *)item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0) + return NULL; - MEM_freeN (buf->dimensions); - - PyObject_DEL(self); + if (slicelength <= 0) { + return PyTuple_New(0); + } + else if (step == 1) { + return Buffer_slice(self, start, stop); + } + else { + PyErr_SetString(PyExc_IndexError, + "slice steps not supported with vectors"); + return NULL; + } + } + else { + PyErr_Format(PyExc_TypeError, + "buffer indices must be integers, not %.200s", + Py_TYPE(item)->tp_name); + return NULL; + } } -static PyObject *Buffer_to_list(PyObject *self) +static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value) { - int i, len= ((Buffer *)self)->dimensions[0]; - PyObject *list= PyList_New(len); - - for (i=0; i<len; i++) { - PyList_SET_ITEM(list, i, Buffer_item(self, i)); + if (PyIndex_Check(item)) { + Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); + if (i == -1 && PyErr_Occurred()) + return -1; + if (i < 0) + i += self->dimensions[0]; + return Buffer_ass_item(self, i, value); } + else if (PySlice_Check(item)) { + Py_ssize_t start, stop, step, slicelength; - return list; + if (PySlice_GetIndicesEx((void *)item, self->dimensions[0], &start, &stop, &step, &slicelength) < 0) + return -1; + + if (step == 1) + return Buffer_ass_slice(self, start, stop, value); + else { + PyErr_SetString(PyExc_IndexError, + "slice steps not supported with vectors"); + return -1; + } + } + else { + PyErr_Format(PyExc_TypeError, + "buffer indices must be integers, not %.200s", + Py_TYPE(item)->tp_name); + return -1; + } } -static PyObject *Buffer_dimensions(PyObject *self, void *UNUSED(arg)) + +static void Buffer_dealloc(Buffer *self) { - Buffer *buffer= (Buffer *) self; - PyObject *list= PyList_New(buffer->ndimensions); - int i; + if (self->parent) Py_DECREF(self->parent); + else MEM_freeN (self->buf.asvoid); - for (i= 0; i<buffer->ndimensions; i++) { - PyList_SET_ITEM(list, i, PyLong_FromLong(buffer->dimensions[i])); - } + MEM_freeN(self->dimensions); - return list; + PyObject_DEL(self); } -static PyMethodDef Buffer_methods[] = { - {"to_list", (PyCFunction)Buffer_to_list, METH_NOARGS, - "return the buffer as a list"}, - {NULL, NULL, 0, NULL} -}; - -static PyGetSetDef Buffer_getseters[] = { - {(char *)"dimensions", (getter)Buffer_dimensions, NULL, NULL, NULL}, - {NULL, NULL, NULL, NULL, NULL} -}; -static PyObject *Buffer_repr(PyObject *self) +static PyObject *Buffer_repr(Buffer *self) { - PyObject *list= Buffer_to_list(self); + PyObject *list= Buffer_to_list_recursive(self); PyObject *repr; const char *typestr= "UNKNOWN"; - Buffer *buffer= (Buffer *)self; - switch(buffer->type) { + switch(self->type) { case GL_BYTE: typestr= "GL_BYTE"; break; case GL_SHORT: typestr= "GL_SHORT"; break; case GL_INT: typestr= "GL_BYTE"; break; diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index 287ba45a1cf..93a4b3ec269 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -25,13 +25,13 @@ set(INC .. + ../../blenkernel ../../blenlib + ../../blenloader + ../../editors/include ../../makesdna ../../makesrna - ../../blenkernel - ../../blenloader ../../windowmanager - ../../editors/include ../../../../intern/guardedalloc ) @@ -88,9 +88,6 @@ if(WITH_PYTHON_SAFETY) endif() if(WITH_AUDASPACE) - list(APPEND INC - ../../../intern/audaspace/intern - ) add_definitions(-DWITH_AUDASPACE) endif() diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index fb4c285a458..3f637feadf7 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -55,10 +55,10 @@ #include "MEM_guardedalloc.h" /* external util modules */ -#include "../generic/mathutils.h" +#include "../generic/IDProp.h" #include "../generic/bgl.h" #include "../generic/blf_py_api.h" -#include "../generic/IDProp.h" +#include "../mathutils/mathutils.h" PyObject *bpy_package_py= NULL; diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index f091a511e93..8bd6e6c611c 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -66,10 +66,10 @@ #include "../generic/py_capi_utils.h" /* inittab initialization functions */ -#include "../generic/noise_py_api.h" -#include "../generic/mathutils.h" #include "../generic/bgl.h" #include "../generic/blf_py_api.h" +#include "../generic/noise_py_api.h" +#include "../mathutils/mathutils.h" /* for internal use, when starting and ending python scripts */ @@ -175,8 +175,8 @@ extern PyObject *AUD_initPython(void); static struct _inittab bpy_internal_modules[]= { {(char *)"noise", BPyInit_noise}, - {(char *)"mathutils", BPyInit_mathutils}, -// {(char *)"mathutils.geometry", BPyInit_mathutils_geometry}, + {(char *)"mathutils", PyInit_mathutils}, +// {(char *)"mathutils.geometry", PyInit_mathutils_geometry}, {(char *)"bgl", BPyInit_bgl}, {(char *)"blf", BPyInit_blf}, #ifdef WITH_AUDASPACE diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4f6edb02a7c..6e1b9c807f3 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -346,7 +346,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item); #ifdef USE_MATHUTILS -#include "../generic/mathutils.h" /* so we can have mathutils callbacks */ +#include "../mathutils/mathutils.h" /* so we can have mathutils callbacks */ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, Py_ssize_t start, Py_ssize_t stop, Py_ssize_t length); static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback); @@ -4548,7 +4548,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { NULL, /* printfunc tp_print; */ NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* tp_compare */ /* deprecated in python 3.0! */ NULL, /* tp_repr */ /* Method suites for standard classes */ diff --git a/source/blender/python/mathutils/CMakeLists.txt b/source/blender/python/mathutils/CMakeLists.txt new file mode 100755 index 00000000000..b28496d612e --- /dev/null +++ b/source/blender/python/mathutils/CMakeLists.txt @@ -0,0 +1,52 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Campbell Barton +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + . + ../../blenlib + ../../blenkernel + ../../makesdna + ../../../../intern/guardedalloc +) + +set(INC_SYS + ${PYTHON_INCLUDE_DIRS} +) + +set(SRC + mathutils.c + mathutils_Color.c + mathutils_Euler.c + mathutils_Matrix.c + mathutils_Quaternion.c + mathutils_Vector.c + mathutils_geometry.c + + mathutils.h + mathutils_Color.h + mathutils_Euler.h + mathutils_Matrix.h + mathutils_Quaternion.h + mathutils_Vector.h + mathutils_geometry.h +) + + +blender_add_lib(bf_python_mathutils "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/python/generic/mathutils.c b/source/blender/python/mathutils/mathutils.c index bba08e312b7..4a0fa509a0d 100644..100755 --- a/source/blender/python/generic/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils.c 38409 2011-07-15 04:01:47Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -75,7 +75,7 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max do { i--; if(((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_TypeError, "%.200s: sequence index %d expected a number, " "found '%.200s' type, ", error_prefix, i, Py_TYPE(item)->tp_name); @@ -345,7 +345,7 @@ static struct PyModuleDef M_Mathutils_module_def = { NULL, /* m_free */ }; -PyMODINIT_FUNC BPyInit_mathutils(void) +PyMODINIT_FUNC PyInit_mathutils(void) { PyObject *submodule; PyObject *item; @@ -371,7 +371,7 @@ PyMODINIT_FUNC BPyInit_mathutils(void) PyModule_AddObject(submodule, "Color", (PyObject *)&color_Type); /* submodule */ - PyModule_AddObject(submodule, "geometry", (item=BPyInit_mathutils_geometry())); + PyModule_AddObject(submodule, "geometry", (item=PyInit_mathutils_geometry())); /* XXX, python doesnt do imports with this usefully yet * 'from mathutils.geometry import PolyFill' * ...fails without this. */ diff --git a/source/blender/python/generic/mathutils.h b/source/blender/python/mathutils/mathutils.h index 449708d1ac1..300c054c061 100644..100755 --- a/source/blender/python/generic/mathutils.h +++ b/source/blender/python/mathutils/mathutils.h @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils.h 38674 2011-07-25 01:44:19Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -67,7 +67,7 @@ int BaseMathObject_traverse(BaseMathObject *self, visitproc visit, void *arg); int BaseMathObject_clear(BaseMathObject *self); void BaseMathObject_dealloc(BaseMathObject * self); -PyMODINIT_FUNC BPyInit_mathutils(void); +PyMODINIT_FUNC PyInit_mathutils(void); int EXPP_FloatsAreEqual(float A, float B, int floatSteps); int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps); @@ -108,4 +108,6 @@ int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index); int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix); int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix); +int column_vector_multiplication(float rvec[4], VectorObject *vec, MatrixObject *mat); + #endif /* MATHUTILS_H */ diff --git a/source/blender/python/generic/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index fd187fd92fd..37730ba4649 100644..100755 --- a/source/blender/python/generic/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Color.c 38409 2011-07-15 04:01:47Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -259,7 +259,7 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq) return -1; if(size != (end - begin)){ - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "color[begin:end] = []: " "size mismatch in slice assignment"); return -1; @@ -296,7 +296,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item) return Color_slice(self, start, stop); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with color"); return NULL; } @@ -328,7 +328,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu if (step == 1) return Color_ass_slice(self, start, stop, value); else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with color"); return -1; } @@ -371,7 +371,7 @@ static PyObject *Color_add(PyObject *v1, PyObject *v2) float col[COLOR_SIZE]; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Color addition: " "arguments not valid for this operation"); return NULL; @@ -393,7 +393,7 @@ static PyObject *Color_iadd(PyObject *v1, PyObject *v2) ColorObject *color1 = NULL, *color2 = NULL; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Color addition: " "arguments not valid for this operation"); return NULL; @@ -418,7 +418,7 @@ static PyObject *Color_sub(PyObject *v1, PyObject *v2) float col[COLOR_SIZE]; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Color subtraction: " "arguments not valid for this operation"); return NULL; @@ -440,7 +440,7 @@ static PyObject *Color_isub(PyObject *v1, PyObject *v2) ColorObject *color1= NULL, *color2= NULL; if (!ColorObject_Check(v1) || !ColorObject_Check(v2)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Color subtraction: " "arguments not valid for this operation"); return NULL; @@ -555,7 +555,9 @@ static PyObject *Color_imul(PyObject *v1, PyObject *v2) mul_vn_fl(color->col, COLOR_SIZE, scalar); } else { - PyErr_SetString(PyExc_TypeError, "Color multiplication: arguments not acceptable for this operation"); + PyErr_SetString(PyExc_TypeError, + "Color multiplication: " + "arguments not acceptable for this operation"); return NULL; } @@ -846,9 +848,7 @@ PyObject *newColorObject(float *col, int type, PyTypeObject *base_type) self->wrapped = Py_NEW; } else { - PyErr_SetString(PyExc_RuntimeError, - "Color(): invalid type, internal error"); - return NULL; + Py_FatalError("Color(): invalid type!"); } } diff --git a/source/blender/python/generic/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h index 0fc880363f4..0afb0ee4dc1 100644..100755 --- a/source/blender/python/generic/mathutils_Color.h +++ b/source/blender/python/mathutils/mathutils_Color.h @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Color.h 38409 2011-07-15 04:01:47Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/python/generic/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 2888b0667f1..afff9275aa0 100644..100755 --- a/source/blender/python/generic/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Euler.c 38409 2011-07-15 04:01:47Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -38,10 +38,6 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#ifndef int32_t -#include "BLO_sys_types.h" -#endif - #define EULER_SIZE 3 //----------------------------------mathutils.Euler() ------------------- @@ -89,7 +85,7 @@ static const char *euler_order_str(EulerObject *self) short euler_order_from_string(const char *str, const char *error_prefix) { if((str[0] && str[1] && str[2] && str[3]=='\0')) { - switch(*((int32_t *)str)) { + switch(*((PY_INT32_T *)str)) { case 'X'|'Y'<<8|'Z'<<16: return EULER_ORDER_XYZ; case 'X'|'Z'<<8|'Y'<<16: return EULER_ORDER_XZY; case 'Y'|'X'<<8|'Z'<<16: return EULER_ORDER_YXZ; @@ -99,7 +95,7 @@ short euler_order_from_string(const char *str, const char *error_prefix) } } - PyErr_Format(PyExc_TypeError, + PyErr_Format(PyExc_ValueError, "%s: invalid euler order '%s'", error_prefix, str); return -1; @@ -209,7 +205,7 @@ static PyObject *Euler_rotate_axis(EulerObject * self, PyObject *args) return NULL; } if(!(ELEM3(*axis, 'X', 'Y', 'Z') && axis[1]=='\0')){ - PyErr_SetString(PyExc_TypeError, "euler.rotate(): " + PyErr_SetString(PyExc_ValueError, "euler.rotate(): " "expected axis to be 'X', 'Y' or 'Z'"); return NULL; } @@ -449,7 +445,7 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq) return -1; if(size != (end - begin)){ - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "euler[begin:end] = []: " "size mismatch in slice assignment"); return -1; @@ -486,7 +482,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item) return Euler_slice(self, start, stop); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with eulers"); return NULL; } @@ -519,7 +515,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu if (step == 1) return Euler_ass_slice(self, start, stop, value); else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with euler"); return -1; } @@ -701,9 +697,7 @@ PyObject *newEulerObject(float *eul, short order, int type, PyTypeObject *base_t self->wrapped = Py_NEW; } else { - PyErr_SetString(PyExc_RuntimeError, - "Euler(): invalid type, internal error"); - return NULL; + Py_FatalError("Euler(): invalid type!"); } self->order= order; diff --git a/source/blender/python/generic/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h index 849e16c2bb7..2df3d6198b8 100644..100755 --- a/source/blender/python/generic/mathutils_Euler.h +++ b/source/blender/python/mathutils/mathutils_Euler.h @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Euler.h 38409 2011-07-15 04:01:47Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/python/generic/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 4343485bb3a..1a1a9f8aff3 100644..100755 --- a/source/blender/python/generic/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Matrix.c 38674 2011-07-25 01:44:19Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -35,7 +35,6 @@ #include "mathutils.h" #include "BLI_math.h" -#include "BLI_blenlib.h" #include "BLI_utildefines.h" static PyObject *Matrix_copy(MatrixObject *self); @@ -225,7 +224,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) if(vec && PyUnicode_Check(vec)) { axis= _PyUnicode_AsString((PyObject *)vec); if(axis==NULL || axis[0]=='\0' || axis[1]!='\0' || axis[0] < 'X' || axis[0] > 'Z') { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "mathutils.RotationMatrix(): " "3rd argument axis value must be a 3D vector " "or a string in 'X', 'Y', 'Z'"); @@ -240,19 +239,19 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) angle= angle_wrap_rad(angle); if(matSize != 2 && matSize != 3 && matSize != 4) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "mathutils.RotationMatrix(): " "can only return a 2x2 3x3 or 4x4 matrix"); return NULL; } if(matSize == 2 && (vec != NULL)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "mathutils.RotationMatrix(): " "cannot create a 2x2 rotation matrix around arbitrary axis"); return NULL; } if((matSize == 3 || matSize == 4) && (axis == NULL) && (vec == NULL)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "mathutils.RotationMatrix(): " "axis of rotation for 3d and 4d matrices is required"); return NULL; @@ -300,7 +299,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) } else { /* should never get here */ - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "mathutils.RotationMatrix(): unknown error"); return NULL; } @@ -365,7 +364,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) return NULL; } if(matSize != 2 && matSize != 3 && matSize != 4) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "Matrix.Scale(): " "can only return a 2x2 3x3 or 4x4 matrix"); return NULL; @@ -451,7 +450,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) return NULL; } if(matSize != 2 && matSize != 3 && matSize != 4) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "mathutils.Matrix.OrthoProjection(): " "can only return a 2x2 3x3 or 4x4 matrix"); return NULL; @@ -568,7 +567,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) return NULL; } if(matSize != 2 && matSize != 3 && matSize != 4) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "mathutils.Matrix.Shear(): " "can only return a 2x2 3x3 or 4x4 matrix"); return NULL; @@ -578,7 +577,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) float const factor= PyFloat_AsDouble(fac); if(factor==-1.0f && PyErr_Occurred()) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "mathutils.Matrix.Shear(): " "the factor to be a float"); return NULL; @@ -595,7 +594,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) mat[1] = factor; } else { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "Matrix.Shear(): " "expected: X, Y or wrong matrix size for shearing plane"); return NULL; @@ -627,7 +626,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) mat[2] = factor[1]; } else { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "mathutils.Matrix.Shear(): " "expected: X, Y, XY, XZ, YZ"); return NULL; @@ -686,7 +685,7 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) /*must be 3-4 cols, 3-4 rows, square matrix*/ if((self->col_size < 3) || (self->row_size < 3) || (self->col_size != self->row_size)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "matrix.to_quat(): " "inappropriate matrix size - expects 3x3 or 4x4 matrix"); return NULL; @@ -750,7 +749,7 @@ static PyObject *Matrix_to_euler(MatrixObject *self, PyObject *args) mat= tmat; } else { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "matrix.to_euler(): " "inappropriate matrix size - expects 3x3 or 4x4 matrix"); return NULL; @@ -879,7 +878,7 @@ static PyObject *Matrix_to_3x3(MatrixObject *self) return NULL; if((self->col_size < 3) || (self->row_size < 3)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "matrix.to_3x3(): inappropriate matrix size"); return NULL; } @@ -903,7 +902,7 @@ static PyObject *Matrix_to_translation(MatrixObject *self) return NULL; if((self->col_size < 3) || self->row_size < 4){ - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "matrix.to_translation(): " "inappropriate matrix size"); return NULL; @@ -933,7 +932,7 @@ static PyObject *Matrix_to_scale(MatrixObject *self) /*must be 3-4 cols, 3-4 rows, square matrix*/ if((self->col_size < 3) || (self->row_size < 3)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "matrix.to_scale(): " "inappropriate matrix size, 3x3 minimum size"); return NULL; @@ -969,7 +968,7 @@ static PyObject *Matrix_invert(MatrixObject *self) return NULL; if(self->row_size != self->col_size){ - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "matrix.invert(ed): " "only square matrices are supported"); return NULL; @@ -1050,7 +1049,7 @@ static PyObject *Matrix_rotate(MatrixObject *self, PyObject *value) return NULL; if(self->col_size != 3 || self->row_size != 3) { - PyErr_SetString(PyExc_ValueError, + PyErr_SetString(PyExc_TypeError, "Matrix must have 3x3 dimensions"); return NULL; } @@ -1082,7 +1081,7 @@ static PyObject *Matrix_decompose(MatrixObject *self) float size[3]; if(self->col_size != 4 || self->row_size != 4) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "matrix.decompose(): " "inappropriate matrix size - expects 4x4 matrix"); return NULL; @@ -1125,7 +1124,7 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) return NULL; if(self->row_size != mat2->row_size || self->col_size != mat2->col_size) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "matrix.lerp(): " "expects both matrix objects of the same dimensions"); return NULL; @@ -1142,7 +1141,7 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args) blend_m3_m3m3((float (*)[3])mat, (float (*)[3])self->contigPtr, (float (*)[3])mat2->contigPtr, fac); } else { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "matrix.lerp(): " "only 3x3 and 4x4 matrices supported"); return NULL; @@ -1168,7 +1167,7 @@ static PyObject *Matrix_determinant(MatrixObject *self) return NULL; if(self->row_size != self->col_size){ - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "matrix.determinant: " "only square matrices are supported"); return NULL; @@ -1192,7 +1191,7 @@ static PyObject *Matrix_transpose(MatrixObject *self) return NULL; if(self->row_size != self->col_size){ - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "matrix.transpose(d): " "only square matrices are supported"); return NULL; @@ -1261,7 +1260,7 @@ static PyObject *Matrix_identity(MatrixObject *self) return NULL; if(self->row_size != self->col_size){ - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "matrix.identity: " "only square matrices are supported"); return NULL; @@ -1319,21 +1318,20 @@ static PyObject *Matrix_repr(MatrixObject *self) } } switch(self->row_size) { - case 2: return PyUnicode_FromFormat("Matrix(%R,\n" - " %R)", rows[0], rows[1]); + case 2: return PyUnicode_FromFormat("Matrix((%R,\n" + " %R))", rows[0], rows[1]); - case 3: return PyUnicode_FromFormat("Matrix(%R,\n" - " %R,\n" - " %R)", rows[0], rows[1], rows[2]); + case 3: return PyUnicode_FromFormat("Matrix((%R,\n" + " %R,\n" + " %R))", rows[0], rows[1], rows[2]); - case 4: return PyUnicode_FromFormat("Matrix(%R,\n" - " %R,\n" - " %R,\n" - " %R)", rows[0], rows[1], rows[2], rows[3]); + case 4: return PyUnicode_FromFormat("Matrix((%R,\n" + " %R,\n" + " %R,\n" + " %R))", rows[0], rows[1], rows[2], rows[3]); } - PyErr_SetString(PyExc_RuntimeError, - "internal error!"); + Py_FatalError("Matrix(): invalid row size!"); return NULL; } @@ -1409,7 +1407,7 @@ static int Matrix_ass_item(MatrixObject *self, int i, PyObject *value) return -1; if(i >= self->row_size || i < 0){ - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "matrix[attribute] = x: bad column"); return -1; } @@ -1473,7 +1471,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va if(PySequence_Fast_GET_SIZE(value_fast) != size) { Py_DECREF(value_fast); - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "matrix[begin:end] = []: " "size mismatch in slice assignment"); return -1; @@ -1509,7 +1507,7 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) mat2 = (MatrixObject*)m2; if(!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Matrix addition: " "arguments not valid for this operation"); return NULL; @@ -1519,7 +1517,7 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) return NULL; if(mat1->row_size != mat2->row_size || mat1->col_size != mat2->col_size){ - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Matrix addition: " "matrices must have the same dimensions for this operation"); return NULL; @@ -1540,7 +1538,7 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) mat2 = (MatrixObject*)m2; if(!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Matrix addition: " "arguments not valid for this operation"); return NULL; @@ -1550,7 +1548,7 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) return NULL; if(mat1->row_size != mat2->row_size || mat1->col_size != mat2->col_size){ - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Matrix addition: " "matrices must have the same dimensions for this operation"); return NULL; @@ -1588,32 +1586,24 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) if(mat1 && mat2) { /*MATRIX * MATRIX*/ - if(mat1->row_size != mat2->col_size){ - PyErr_SetString(PyExc_AttributeError, - "Matrix multiplication: " - "matrix A rowsize must equal matrix B colsize"); - return NULL; - } - else { - float mat[16]= {0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; - double dot = 0.0f; - int x, y, z; - - for(x = 0; x < mat2->row_size; x++) { - for(y = 0; y < mat1->col_size; y++) { - for(z = 0; z < mat1->row_size; z++) { - dot += (mat1->matrix[z][y] * mat2->matrix[x][z]); - } - mat[((x * mat1->col_size) + y)] = (float)dot; - dot = 0.0f; + float mat[16]= {0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + double dot = 0.0f; + int x, y, z; + + for(x = 0; x < mat2->row_size; x++) { + for(y = 0; y < mat1->col_size; y++) { + for(z = 0; z < mat1->row_size; z++) { + dot += (mat1->matrix[z][y] * mat2->matrix[x][z]); } + mat[((x * mat1->col_size) + y)] = (float)dot; + dot = 0.0f; } - - return newMatrixObject(mat, mat2->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); } + + return newMatrixObject(mat, mat2->row_size, mat1->col_size, Py_NEW, Py_TYPE(mat1)); } else if(mat2) { /*FLOAT/INT * MATRIX */ @@ -1622,8 +1612,20 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) } } else if(mat1) { + /*VEC * MATRIX */ + if(VectorObject_Check(m2)) { + VectorObject *vec2= (VectorObject *)m2; + float tvec[4]; + if(BaseMath_ReadCallback(vec2) == -1) + return NULL; + if(column_vector_multiplication(tvec, vec2, mat1) == -1) { + return NULL; + } + + return newVectorObject(tvec, vec2->size, Py_NEW, Py_TYPE(m2)); + } /*FLOAT/INT * MATRIX */ - if (((scalar= PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred())==0) { + else if (((scalar= PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred())==0) { return matrix_mul_float(mat1, scalar); } } @@ -1683,14 +1685,14 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item) return Matrix_slice(self, start, stop); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with matricies"); return NULL; } } else { PyErr_Format(PyExc_TypeError, - "vector indices must be integers, not %.200s", + "matrix indices must be integers, not %.200s", Py_TYPE(item)->tp_name); return NULL; } @@ -1715,7 +1717,7 @@ static int Matrix_ass_subscript(MatrixObject* self, PyObject* item, PyObject* va if (step == 1) return Matrix_ass_slice(self, start, stop, value); else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with matricies"); return -1; } @@ -2021,8 +2023,7 @@ PyObject *newMatrixObject(float *mat, const unsigned short rowSize, const unsign self->wrapped = Py_NEW; } else { - PyErr_SetString(PyExc_RuntimeError, - "Matrix(): invalid type, internal error"); + Py_FatalError("Matrix(): invalid type!"); return NULL; } } diff --git a/source/blender/python/generic/mathutils_Matrix.h b/source/blender/python/mathutils/mathutils_Matrix.h index aa736d1e959..84a92bae2be 100644..100755 --- a/source/blender/python/generic/mathutils_Matrix.h +++ b/source/blender/python/mathutils/mathutils_Matrix.h @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Matrix.h 38409 2011-07-15 04:01:47Z campbellbarton $ * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/python/generic/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 977ff7ccbc7..d43cae9edd7 100644..100755 --- a/source/blender/python/generic/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Quaternion.c 38674 2011-07-25 01:44:19Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -248,7 +248,7 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args) return NULL; if(fac > 1.0f || fac < 0.0f) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "quat.slerp(): " "interpolation factor must be between 0.0 and 1.0"); return NULL; @@ -582,7 +582,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb return -1; if(size != (end - begin)){ - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "quaternion[begin:end] = []: " "size mismatch in slice assignment"); return -1; @@ -620,7 +620,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item) return Quaternion_slice(self, start, stop); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with quaternions"); return NULL; } @@ -653,7 +653,7 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb if (step == 1) return Quaternion_ass_slice(self, start, stop, value); else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with quaternion"); return -1; } @@ -675,7 +675,7 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2) QuaternionObject *quat1 = NULL, *quat2 = NULL; if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Quaternion addition: " "arguments not valid for this operation"); return NULL; @@ -698,7 +698,7 @@ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2) QuaternionObject *quat1 = NULL, *quat2 = NULL; if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "Quaternion addition: " "arguments not valid for this operation"); return NULL; @@ -753,8 +753,30 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) return quat_mul_float(quat2, scalar); } } - else if (quat1) { /* QUAT*FLOAT */ - if((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) { + else if (quat1) { + /* QUAT * VEC */ + if (VectorObject_Check(q2)) { + VectorObject *vec2 = (VectorObject *)q2; + float tvec[3]; + + if(vec2->size != 3) { + PyErr_SetString(PyExc_ValueError, + "Vector multiplication: " + "only 3D vector rotations (with quats) " + "currently supported"); + return NULL; + } + if(BaseMath_ReadCallback(vec2) == -1) { + return NULL; + } + + copy_v3_v3(tvec, vec2->vec); + mul_qt_v3(quat1->quat, tvec); + + return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec2)); + } + /* QUAT * FLOAT */ + else if((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) { return quat_mul_float(quat1, scalar); } } @@ -1142,9 +1164,7 @@ PyObject *newQuaternionObject(float *quat, int type, PyTypeObject *base_type) self->wrapped = Py_NEW; } else { - PyErr_SetString(PyExc_RuntimeError, - "Quaternion(): invalid type, internal error"); - return NULL; + Py_FatalError("Quaternion(): invalid type!"); } } return (PyObject *) self; diff --git a/source/blender/python/generic/mathutils_Quaternion.h b/source/blender/python/mathutils/mathutils_Quaternion.h index d606621390a..4ba70895680 100644..100755 --- a/source/blender/python/generic/mathutils_Quaternion.h +++ b/source/blender/python/mathutils/mathutils_Quaternion.h @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Quaternion.h 38409 2011-07-15 04:01:47Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/python/generic/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index b8fdc2f0890..5d0e467f6e8 100644..100755 --- a/source/blender/python/generic/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Vector.c 38674 2011-07-25 01:44:19Z campbellbarton $ * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -34,10 +34,11 @@ #include "mathutils.h" -#include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_utildefines.h" +extern void PyC_LineSpit(void); + #define MAX_DIMENSIONS 4 /* Swizzle axes get packed into a single value that is used as a closure. Each @@ -442,8 +443,7 @@ static PyObject *Vector_to_track_quat(VectorObject *self, PyObject *args) } } else { - PyErr_SetString(PyExc_ValueError, - axis_err_msg); + PyErr_SetString(PyExc_ValueError, axis_err_msg); return NULL; } } @@ -667,7 +667,7 @@ static PyObject *Vector_rotation_difference(VectorObject *self, PyObject *value) float quat[4], vec_a[3], vec_b[3]; if(self->size < 3) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "vec.difference(value): " "expects both vectors to be size 3 or 4"); return NULL; @@ -1083,7 +1083,7 @@ static PyObject *Vector_isub(PyObject *v1, PyObject *v2) * note: vector/matrix multiplication IS NOT COMMUTATIVE!!!! * note: assume read callbacks have been done first. */ -static int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec, MatrixObject * mat) +int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject* vec, MatrixObject * mat) { float vec_cpy[MAX_DIMENSIONS]; double dot = 0.0f; @@ -1094,7 +1094,7 @@ static int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject vec_cpy[3] = 1.0f; } else { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_TypeError, "matrix * vector: " "matrix.row_size and len(vector) must be the same, " "except for 3D vector * 4x4 matrix."); @@ -1147,7 +1147,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) double dot = 0.0f; if(vec1->size != vec2->size) { - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "vectors must have the same dimensions for this operation"); return NULL; @@ -1161,8 +1161,29 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) } else if (vec1) { if (MatrixObject_Check(v2)) { + extern void PyC_LineSpit(void); + /* VEC * MATRIX */ + /* this is deprecated!, use the reverse instead */ float tvec[MAX_DIMENSIONS]; + + +/* ------ to be removed ------*/ +#ifndef MATH_STANDALONE +#ifdef WITH_ASSERT_ABORT + PyErr_SetString(PyExc_ValueError, + "(Vector * Matrix) is now removed, reverse the " + "order (promoted to an Error for Debug builds)"); + return NULL; +#else + printf("Warning: (Vector * Matrix) is now deprecated, " + "reverse the multiplication order in the script.\n"); + PyC_LineSpit(); +#endif +#endif /* ifndef MATH_STANDALONE */ +/* ------ to be removed ------*/ + + if(BaseMath_ReadCallback((MatrixObject *)v2) == -1) return NULL; if(column_vector_multiplication(tvec, vec1, (MatrixObject*)v2) == -1) { @@ -1177,7 +1198,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) float tvec[3]; if(vec1->size != 3) { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "only 3D vector rotations (with quats) currently supported"); return NULL; @@ -1185,6 +1206,24 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) if(BaseMath_ReadCallback(quat2) == -1) { return NULL; } + + +/* ------ to be removed ------*/ +#ifndef MATH_STANDALONE +#ifdef WITH_ASSERT_ABORT + PyErr_SetString(PyExc_ValueError, + "(Vector * Quat) is now removed, reverse the " + "order (promoted to an Error for Debug builds)"); + return NULL; +#else + printf("Warning: (Vector * Quat) is now deprecated, " + "reverse the multiplication order in the script.\n"); + PyC_LineSpit(); +#endif +#endif /* ifndef MATH_STANDALONE */ +/* ------ to be removed ------*/ + + copy_v3_v3(tvec, vec1->vec); mul_qt_v3(quat2->quat, tvec); return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1)); @@ -1228,6 +1267,24 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) if(column_vector_multiplication(rvec, vec, (MatrixObject*)v2) == -1) return NULL; + +/* ------ to be removed ------*/ +#ifndef MATH_STANDALONE +#ifdef WITH_ASSERT_ABORT + PyErr_SetString(PyExc_ValueError, + "(Vector *= Matrix) is now removed, reverse the " + "order (promoted to an Error for Debug builds) " + "and uses the non in-place multiplication."); + return NULL; +#else + printf("Warning: (Vector *= Matrix) is now deprecated, " + "reverse the (non in-place) multiplication order in the script.\n"); + PyC_LineSpit(); +#endif +#endif /* ifndef MATH_STANDALONE */ +/* ------ to be removed ------*/ + + memcpy(vec->vec, rvec, sizeof(float) * vec->size); } else if (QuaternionObject_Check(v2)) { @@ -1235,7 +1292,7 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) QuaternionObject *quat2 = (QuaternionObject*)v2; if(vec->size != 3) { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "Vector multiplication: " "only 3D vector rotations (with quats) currently supported"); return NULL; @@ -1244,6 +1301,25 @@ static PyObject *Vector_imul(PyObject *v1, PyObject *v2) if(BaseMath_ReadCallback(quat2) == -1) { return NULL; } + + +/* ------ to be removed ------*/ +#ifndef MATH_STANDALONE +#ifdef WITH_ASSERT_ABORT + PyErr_SetString(PyExc_ValueError, + "(Vector *= Quat) is now removed, reverse the " + "order (promoted to an Error for Debug builds) " + "and uses the non in-place multiplication."); + return NULL; +#else + printf("Warning: (Vector *= Quat) is now deprecated, " + "reverse the (non in-place) multiplication order in the script.\n"); + PyC_LineSpit(); +#endif +#endif /* ifndef MATH_STANDALONE */ +/* ------ to be removed ------*/ + + mul_qt_v3(quat2->quat, vec->vec); } else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC *= FLOAT */ @@ -1485,7 +1561,7 @@ static PyObject *Vector_subscript(VectorObject* self, PyObject* item) return Vector_slice(self, start, stop); } else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors"); return NULL; } @@ -1517,7 +1593,7 @@ static int Vector_ass_subscript(VectorObject* self, PyObject* item, PyObject* va if (step == 1) return Vector_ass_slice(self, start, stop, value); else { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_IndexError, "slice steps not supported with vectors"); return -1; } @@ -1620,7 +1696,7 @@ static int Vector_setLength(VectorObject *self, PyObject *value) } if (param < 0.0) { - PyErr_SetString(PyExc_TypeError, + PyErr_SetString(PyExc_ValueError, "cannot set a vectors length to a negative value"); return -1; } @@ -2174,7 +2250,7 @@ static int row_vector_multiplication(float rvec[4], VectorObject* vec, MatrixObj if(mat->colSize != vec_size){ if(mat->colSize == 4 && vec_size != 3){ - PyErr_SetString(PyExc_AttributeError, + PyErr_SetString(PyExc_ValueError, "vector * matrix: matrix column size " "and the vector size must be the same"); return -1; @@ -2390,9 +2466,7 @@ PyObject *newVectorObject(float *vec, const int size, const int type, PyTypeObje self->wrapped = Py_NEW; } else { - PyErr_SetString(PyExc_RuntimeError, - "Vector(): invalid type, internal error"); - return NULL; + Py_FatalError("Vector(): invalid type!"); } } return (PyObject *) self; diff --git a/source/blender/python/generic/mathutils_Vector.h b/source/blender/python/mathutils/mathutils_Vector.h index 0ede836ce44..e430a100836 100644..100755 --- a/source/blender/python/generic/mathutils_Vector.h +++ b/source/blender/python/mathutils/mathutils_Vector.h @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_Vector.h 38409 2011-07-15 04:01:47Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 4c359a15a09..acfb8a91416 100644..100755 --- a/source/blender/python/generic/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1,5 +1,5 @@ -/* - * $Id$ +/* + * $Id: mathutils_geometry.c 38409 2011-07-15 04:01:47Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -37,16 +37,16 @@ #include "mathutils_geometry.h" /* Used for PolyFill */ -#include "MEM_guardedalloc.h" +#ifndef MATH_STANDALONE /* define when building outside blender */ +# include "MEM_guardedalloc.h" +# include "BLI_blenlib.h" +# include "BLI_boxpack2d.h" +# include "BKE_displist.h" +# include "BKE_curve.h" +#endif -#include "BLI_blenlib.h" -#include "BLI_boxpack2d.h" #include "BLI_math.h" #include "BLI_utildefines.h" - -#include "BKE_displist.h" - -#include "BKE_curve.h" #define SWAP_FLOAT(a, b, tmp) tmp=a; a=b; b=tmp #define eps 0.000001 @@ -346,132 +346,6 @@ static PyObject *M_Geometry_area_tri(PyObject *UNUSED(self), PyObject* args) } } -/*----------------------------------geometry.PolyFill() -------------------*/ -PyDoc_STRVAR(M_Geometry_tesselate_polygon_doc, -".. function:: tesselate_polygon(veclist_list)\n" -"\n" -" Takes a list of polylines (each point a vector) and returns the point indices for a polyline filled with triangles.\n" -"\n" -" :arg veclist_list: list of polylines\n" -" :rtype: list\n" -); -/* PolyFill function, uses Blenders scanfill to fill multiple poly lines */ -static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *polyLineSeq) -{ - PyObject *tri_list; /*return this list of tri's */ - PyObject *polyLine, *polyVec; - int i, len_polylines, len_polypoints, ls_error= 0; - - /* display listbase */ - ListBase dispbase={NULL, NULL}; - DispList *dl; - float *fp; /*pointer to the array of malloced dl->verts to set the points from the vectors */ - int index, *dl_face, totpoints=0; - - if(!PySequence_Check(polyLineSeq)) { - PyErr_SetString(PyExc_TypeError, - "expected a sequence of poly lines"); - return NULL; - } - - len_polylines= PySequence_Size(polyLineSeq); - - for(i= 0; i < len_polylines; ++i) { - polyLine= PySequence_GetItem(polyLineSeq, i); - if (!PySequence_Check(polyLine)) { - freedisplist(&dispbase); - Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/ - PyErr_SetString(PyExc_TypeError, - "One or more of the polylines is not a sequence of mathutils.Vector's"); - return NULL; - } - - len_polypoints= PySequence_Size(polyLine); - if (len_polypoints>0) { /* dont bother adding edges as polylines */ -#if 0 - if (EXPP_check_sequence_consistency(polyLine, &vector_Type) != 1) { - freedisplist(&dispbase); - Py_DECREF(polyLine); - PyErr_SetString(PyExc_TypeError, - "A point in one of the polylines is not a mathutils.Vector type"); - return NULL; - } -#endif - dl= MEM_callocN(sizeof(DispList), "poly disp"); - BLI_addtail(&dispbase, dl); - dl->type= DL_INDEX3; - dl->nr= len_polypoints; - dl->type= DL_POLY; - dl->parts= 1; /* no faces, 1 edge loop */ - dl->col= 0; /* no material */ - dl->verts= fp= MEM_callocN(sizeof(float)*3*len_polypoints, "dl verts"); - dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index"); - - for(index= 0; index<len_polypoints; ++index, fp+=3) { - polyVec= PySequence_GetItem(polyLine, index); - if(VectorObject_Check(polyVec)) { - - if(BaseMath_ReadCallback((VectorObject *)polyVec) == -1) - ls_error= 1; - - fp[0]= ((VectorObject *)polyVec)->vec[0]; - fp[1]= ((VectorObject *)polyVec)->vec[1]; - if(((VectorObject *)polyVec)->size > 2) - fp[2]= ((VectorObject *)polyVec)->vec[2]; - else - fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */ - } - else { - ls_error= 1; - } - - totpoints++; - Py_DECREF(polyVec); - } - } - Py_DECREF(polyLine); - } - - if(ls_error) { - freedisplist(&dispbase); /* possible some dl was allocated */ - PyErr_SetString(PyExc_TypeError, - "A point in one of the polylines " - "is not a mathutils.Vector type"); - return NULL; - } - else if (totpoints) { - /* now make the list to return */ - filldisplist(&dispbase, &dispbase, 0); - - /* The faces are stored in a new DisplayList - thats added to the head of the listbase */ - dl= dispbase.first; - - tri_list= PyList_New(dl->parts); - if(!tri_list) { - freedisplist(&dispbase); - PyErr_SetString(PyExc_RuntimeError, - "failed to make a new list"); - return NULL; - } - - index= 0; - dl_face= dl->index; - while(index < dl->parts) { - PyList_SET_ITEM(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2])); - dl_face+= 3; - index++; - } - freedisplist(&dispbase); - } - else { - /* no points, do this so scripts dont barf */ - freedisplist(&dispbase); /* possible some dl was allocated */ - tri_list= PyList_New(0); - } - - return tri_list; -} PyDoc_STRVAR(M_Geometry_intersect_line_line_2d_doc, ".. function:: intersect_line_line_2d(lineA_p1, lineA_p2, lineB_p1, lineB_p2)\n" @@ -556,7 +430,7 @@ static PyObject *M_Geometry_intersect_line_plane(PyObject *UNUSED(self), PyObjec } if(ELEM4(2, line_a->size, line_b->size, plane_co->size, plane_no->size)) { - PyErr_SetString(PyExc_RuntimeError, + PyErr_SetString(PyExc_ValueError, "geometry.intersect_line_plane(...): " " can't use 2D Vectors"); return NULL; @@ -614,7 +488,7 @@ static PyObject *M_Geometry_intersect_line_sphere(PyObject *UNUSED(self), PyObje } if(ELEM3(2, line_a->size, line_b->size, sphere_co->size)) { - PyErr_SetString(PyExc_RuntimeError, + PyErr_SetString(PyExc_ValueError, "geometry.intersect_line_sphere(...): " " can't use 2D Vectors"); return NULL; @@ -844,25 +718,288 @@ static PyObject *M_Geometry_intersect_point_quad_2d(PyObject *UNUSED(self), PyOb return PyLong_FromLong(isect_point_quad_v2(pt_vec->vec, quad_p1->vec, quad_p2->vec, quad_p3->vec, quad_p4->vec)); } +PyDoc_STRVAR(M_Geometry_barycentric_transform_doc, +".. function:: barycentric_transform(point, tri_a1, tri_a2, tri_a3, tri_b1, tri_b2, tri_b3)\n" +"\n" +" Return a transformed point, the transformation is defined by 2 triangles.\n" +"\n" +" :arg point: The point to transform.\n" +" :type point: :class:`mathutils.Vector`\n" +" :arg tri_a1: source triangle vertex.\n" +" :type tri_a1: :class:`mathutils.Vector`\n" +" :arg tri_a2: source triangle vertex.\n" +" :type tri_a2: :class:`mathutils.Vector`\n" +" :arg tri_a3: source triangle vertex.\n" +" :type tri_a3: :class:`mathutils.Vector`\n" +" :arg tri_a1: target triangle vertex.\n" +" :type tri_a1: :class:`mathutils.Vector`\n" +" :arg tri_a2: target triangle vertex.\n" +" :type tri_a2: :class:`mathutils.Vector`\n" +" :arg tri_a3: target triangle vertex.\n" +" :type tri_a3: :class:`mathutils.Vector`\n" +" :return: The transformed point\n" +" :rtype: :class:`mathutils.Vector`'s\n" +); +static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObject *args) +{ + VectorObject *vec_pt; + VectorObject *vec_t1_tar, *vec_t2_tar, *vec_t3_tar; + VectorObject *vec_t1_src, *vec_t2_src, *vec_t3_src; + float vec[3]; + + if(!PyArg_ParseTuple(args, "O!O!O!O!O!O!O!:barycentric_transform", + &vector_Type, &vec_pt, + &vector_Type, &vec_t1_src, + &vector_Type, &vec_t2_src, + &vector_Type, &vec_t3_src, + &vector_Type, &vec_t1_tar, + &vector_Type, &vec_t2_tar, + &vector_Type, &vec_t3_tar) + ) { + return NULL; + } + + if( vec_pt->size != 3 || + vec_t1_src->size != 3 || + vec_t2_src->size != 3 || + vec_t3_src->size != 3 || + vec_t1_tar->size != 3 || + vec_t2_tar->size != 3 || + vec_t3_tar->size != 3) + { + PyErr_SetString(PyExc_ValueError, + "One of more of the vector arguments wasn't a 3D vector"); + return NULL; + } + + barycentric_transform(vec, vec_pt->vec, + vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec, + vec_t1_src->vec, vec_t2_src->vec, vec_t3_src->vec); + + return newVectorObject(vec, 3, Py_NEW, NULL); +} + +#ifndef MATH_STANDALONE + +PyDoc_STRVAR(M_Geometry_interpolate_bezier_doc, +".. function:: interpolate_bezier(knot1, handle1, handle2, knot2, resolution)\n" +"\n" +" Interpolate a bezier spline segment.\n" +"\n" +" :arg knot1: First bezier spline point.\n" +" :type knot1: :class:`mathutils.Vector`\n" +" :arg handle1: First bezier spline handle.\n" +" :type handle1: :class:`mathutils.Vector`\n" +" :arg handle2: Second bezier spline handle.\n" +" :type handle2: :class:`mathutils.Vector`\n" +" :arg knot2: Second bezier spline point.\n" +" :type knot2: :class:`mathutils.Vector`\n" +" :arg resolution: Number of points to return.\n" +" :type resolution: int\n" +" :return: The interpolated points\n" +" :rtype: list of :class:`mathutils.Vector`'s\n" +); +static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* args) +{ + VectorObject *vec_k1, *vec_h1, *vec_k2, *vec_h2; + int resolu; + int dims; + int i; + float *coord_array, *fp; + PyObject *list; + + float k1[4]= {0.0, 0.0, 0.0, 0.0}; + float h1[4]= {0.0, 0.0, 0.0, 0.0}; + float k2[4]= {0.0, 0.0, 0.0, 0.0}; + float h2[4]= {0.0, 0.0, 0.0, 0.0}; + + + if(!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier", + &vector_Type, &vec_k1, + &vector_Type, &vec_h1, + &vector_Type, &vec_h2, + &vector_Type, &vec_k2, &resolu) + ) { + return NULL; + } + + if(resolu <= 1) { + PyErr_SetString(PyExc_ValueError, + "resolution must be 2 or over"); + return NULL; + } + + if(BaseMath_ReadCallback(vec_k1) == -1 || BaseMath_ReadCallback(vec_h1) == -1 || BaseMath_ReadCallback(vec_k2) == -1 || BaseMath_ReadCallback(vec_h2) == -1) + return NULL; + + dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); + + for(i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i]; + for(i=0; i < vec_h1->size; i++) h1[i]= vec_h1->vec[i]; + for(i=0; i < vec_k2->size; i++) k2[i]= vec_k2->vec[i]; + for(i=0; i < vec_h2->size; i++) h2[i]= vec_h2->vec[i]; + + coord_array= MEM_callocN(dims * (resolu) * sizeof(float), "interpolate_bezier"); + for(i=0; i<dims; i++) { + forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array+i, resolu-1, sizeof(float)*dims); + } + + list= PyList_New(resolu); + fp= coord_array; + for(i=0; i<resolu; i++, fp= fp+dims) { + PyList_SET_ITEM(list, i, newVectorObject(fp, dims, Py_NEW, NULL)); + } + MEM_freeN(coord_array); + return list; +} + + +PyDoc_STRVAR(M_Geometry_tesselate_polygon_doc, +".. function:: tesselate_polygon(veclist_list)\n" +"\n" +" Takes a list of polylines (each point a vector) and returns the point indices for a polyline filled with triangles.\n" +"\n" +" :arg veclist_list: list of polylines\n" +" :rtype: list\n" +); +/* PolyFill function, uses Blenders scanfill to fill multiple poly lines */ +static PyObject *M_Geometry_tesselate_polygon(PyObject *UNUSED(self), PyObject *polyLineSeq) +{ + PyObject *tri_list; /*return this list of tri's */ + PyObject *polyLine, *polyVec; + int i, len_polylines, len_polypoints, ls_error= 0; + + /* display listbase */ + ListBase dispbase={NULL, NULL}; + DispList *dl; + float *fp; /*pointer to the array of malloced dl->verts to set the points from the vectors */ + int index, *dl_face, totpoints=0; + + if(!PySequence_Check(polyLineSeq)) { + PyErr_SetString(PyExc_TypeError, + "expected a sequence of poly lines"); + return NULL; + } + + len_polylines= PySequence_Size(polyLineSeq); + + for(i= 0; i < len_polylines; ++i) { + polyLine= PySequence_GetItem(polyLineSeq, i); + if (!PySequence_Check(polyLine)) { + freedisplist(&dispbase); + Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/ + PyErr_SetString(PyExc_TypeError, + "One or more of the polylines is not a sequence of mathutils.Vector's"); + return NULL; + } + + len_polypoints= PySequence_Size(polyLine); + if (len_polypoints>0) { /* dont bother adding edges as polylines */ +#if 0 + if (EXPP_check_sequence_consistency(polyLine, &vector_Type) != 1) { + freedisplist(&dispbase); + Py_DECREF(polyLine); + PyErr_SetString(PyExc_TypeError, + "A point in one of the polylines is not a mathutils.Vector type"); + return NULL; + } +#endif + dl= MEM_callocN(sizeof(DispList), "poly disp"); + BLI_addtail(&dispbase, dl); + dl->type= DL_INDEX3; + dl->nr= len_polypoints; + dl->type= DL_POLY; + dl->parts= 1; /* no faces, 1 edge loop */ + dl->col= 0; /* no material */ + dl->verts= fp= MEM_callocN(sizeof(float)*3*len_polypoints, "dl verts"); + dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index"); + + for(index= 0; index<len_polypoints; ++index, fp+=3) { + polyVec= PySequence_GetItem(polyLine, index); + if(VectorObject_Check(polyVec)) { + + if(BaseMath_ReadCallback((VectorObject *)polyVec) == -1) + ls_error= 1; + + fp[0]= ((VectorObject *)polyVec)->vec[0]; + fp[1]= ((VectorObject *)polyVec)->vec[1]; + if(((VectorObject *)polyVec)->size > 2) + fp[2]= ((VectorObject *)polyVec)->vec[2]; + else + fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */ + } + else { + ls_error= 1; + } + + totpoints++; + Py_DECREF(polyVec); + } + } + Py_DECREF(polyLine); + } + + if(ls_error) { + freedisplist(&dispbase); /* possible some dl was allocated */ + PyErr_SetString(PyExc_TypeError, + "A point in one of the polylines " + "is not a mathutils.Vector type"); + return NULL; + } + else if (totpoints) { + /* now make the list to return */ + filldisplist(&dispbase, &dispbase, 0); + + /* The faces are stored in a new DisplayList + thats added to the head of the listbase */ + dl= dispbase.first; + + tri_list= PyList_New(dl->parts); + if(!tri_list) { + freedisplist(&dispbase); + PyErr_SetString(PyExc_RuntimeError, + "failed to make a new list"); + return NULL; + } + + index= 0; + dl_face= dl->index; + while(index < dl->parts) { + PyList_SET_ITEM(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2])); + dl_face+= 3; + index++; + } + freedisplist(&dispbase); + } + else { + /* no points, do this so scripts dont barf */ + freedisplist(&dispbase); /* possible some dl was allocated */ + tri_list= PyList_New(0); + } + + return tri_list; +} + + static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) { int len, i; PyObject *list_item, *item_1, *item_2; boxPack *box; - - + + /* Error checking must already be done */ if(!PyList_Check(value)) { PyErr_SetString(PyExc_TypeError, "can only back a list of [x, y, w, h]"); return -1; } - + len= PyList_Size(value); - + (*boxarray)= MEM_mallocN(len*sizeof(boxPack), "boxPack box"); - - + + for(i= 0; i < len; i++) { list_item= PyList_GET_ITEM(value, i); if(!PyList_Check(list_item) || PyList_Size(list_item) < 4) { @@ -871,16 +1008,17 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) "can only pack a list of [x, y, w, h]"); return -1; } - + box= (*boxarray)+i; - + item_1= PyList_GET_ITEM(list_item, 2); item_2= PyList_GET_ITEM(list_item, 3); - + box->w= (float)PyFloat_AsDouble(item_1); box->h= (float)PyFloat_AsDouble(item_2); box->index= i; + /* accounts for error case too and overwrites with own error */ if (box->w < 0.0f || box->h < 0.0f) { MEM_freeN(*boxarray); PyErr_SetString(PyExc_TypeError, @@ -899,9 +1037,9 @@ static void boxPack_ToPyObject(PyObject *value, boxPack **boxarray) int len, i; PyObject *list_item; boxPack *box; - + len= PyList_Size(value); - + for(i= 0; i < len; i++) { box= (*boxarray)+i; list_item= PyList_GET_ITEM(value, box->index); @@ -927,7 +1065,7 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis int len; PyObject *ret; - + if(!PyList_Check(boxlist)) { PyErr_SetString(PyExc_TypeError, "expected a list of boxes [[x, y, w, h], ... ]"); @@ -953,138 +1091,8 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis return ret; } -PyDoc_STRVAR(M_Geometry_interpolate_bezier_doc, -".. function:: interpolate_bezier(knot1, handle1, handle2, knot2, resolution)\n" -"\n" -" Interpolate a bezier spline segment.\n" -"\n" -" :arg knot1: First bezier spline point.\n" -" :type knot1: :class:`mathutils.Vector`\n" -" :arg handle1: First bezier spline handle.\n" -" :type handle1: :class:`mathutils.Vector`\n" -" :arg handle2: Second bezier spline handle.\n" -" :type handle2: :class:`mathutils.Vector`\n" -" :arg knot2: Second bezier spline point.\n" -" :type knot2: :class:`mathutils.Vector`\n" -" :arg resolution: Number of points to return.\n" -" :type resolution: int\n" -" :return: The interpolated points\n" -" :rtype: list of :class:`mathutils.Vector`'s\n" -); -static PyObject *M_Geometry_interpolate_bezier(PyObject *UNUSED(self), PyObject* args) -{ - VectorObject *vec_k1, *vec_h1, *vec_k2, *vec_h2; - int resolu; - int dims; - int i; - float *coord_array, *fp; - PyObject *list; - - float k1[4]= {0.0, 0.0, 0.0, 0.0}; - float h1[4]= {0.0, 0.0, 0.0, 0.0}; - float k2[4]= {0.0, 0.0, 0.0, 0.0}; - float h2[4]= {0.0, 0.0, 0.0, 0.0}; - - - if(!PyArg_ParseTuple(args, "O!O!O!O!i:interpolate_bezier", - &vector_Type, &vec_k1, - &vector_Type, &vec_h1, - &vector_Type, &vec_h2, - &vector_Type, &vec_k2, &resolu) - ) { - return NULL; - } - - if(resolu <= 1) { - PyErr_SetString(PyExc_ValueError, - "resolution must be 2 or over"); - return NULL; - } - - if(BaseMath_ReadCallback(vec_k1) == -1 || BaseMath_ReadCallback(vec_h1) == -1 || BaseMath_ReadCallback(vec_k2) == -1 || BaseMath_ReadCallback(vec_h2) == -1) - return NULL; - - dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); - - for(i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i]; - for(i=0; i < vec_h1->size; i++) h1[i]= vec_h1->vec[i]; - for(i=0; i < vec_k2->size; i++) k2[i]= vec_k2->vec[i]; - for(i=0; i < vec_h2->size; i++) h2[i]= vec_h2->vec[i]; - - coord_array= MEM_callocN(dims * (resolu) * sizeof(float), "interpolate_bezier"); - for(i=0; i<dims; i++) { - forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array+i, resolu-1, sizeof(float)*dims); - } - - list= PyList_New(resolu); - fp= coord_array; - for(i=0; i<resolu; i++, fp= fp+dims) { - PyList_SET_ITEM(list, i, newVectorObject(fp, dims, Py_NEW, NULL)); - } - MEM_freeN(coord_array); - return list; -} - -PyDoc_STRVAR(M_Geometry_barycentric_transform_doc, -".. function:: barycentric_transform(point, tri_a1, tri_a2, tri_a3, tri_b1, tri_b2, tri_b3)\n" -"\n" -" Return a transformed point, the transformation is defined by 2 triangles.\n" -"\n" -" :arg point: The point to transform.\n" -" :type point: :class:`mathutils.Vector`\n" -" :arg tri_a1: source triangle vertex.\n" -" :type tri_a1: :class:`mathutils.Vector`\n" -" :arg tri_a2: source triangle vertex.\n" -" :type tri_a2: :class:`mathutils.Vector`\n" -" :arg tri_a3: source triangle vertex.\n" -" :type tri_a3: :class:`mathutils.Vector`\n" -" :arg tri_a1: target triangle vertex.\n" -" :type tri_a1: :class:`mathutils.Vector`\n" -" :arg tri_a2: target triangle vertex.\n" -" :type tri_a2: :class:`mathutils.Vector`\n" -" :arg tri_a3: target triangle vertex.\n" -" :type tri_a3: :class:`mathutils.Vector`\n" -" :return: The transformed point\n" -" :rtype: :class:`mathutils.Vector`'s\n" -); -static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObject *args) -{ - VectorObject *vec_pt; - VectorObject *vec_t1_tar, *vec_t2_tar, *vec_t3_tar; - VectorObject *vec_t1_src, *vec_t2_src, *vec_t3_src; - float vec[3]; +#endif /* MATH_STANDALONE */ - if(!PyArg_ParseTuple(args, "O!O!O!O!O!O!O!:barycentric_transform", - &vector_Type, &vec_pt, - &vector_Type, &vec_t1_src, - &vector_Type, &vec_t2_src, - &vector_Type, &vec_t3_src, - &vector_Type, &vec_t1_tar, - &vector_Type, &vec_t2_tar, - &vector_Type, &vec_t3_tar) - ) { - return NULL; - } - - if( vec_pt->size != 3 || - vec_t1_src->size != 3 || - vec_t2_src->size != 3 || - vec_t3_src->size != 3 || - vec_t1_tar->size != 3 || - vec_t2_tar->size != 3 || - vec_t3_tar->size != 3) - { - PyErr_SetString(PyExc_ValueError, - "One of more of the vector arguments wasnt a 3D vector"); - return NULL; - } - - barycentric_transform(vec, vec_pt->vec, - vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec, - vec_t1_src->vec, vec_t2_src->vec, vec_t3_src->vec); - - return newVectorObject(vec, 3, Py_NEW, NULL); -} static PyMethodDef M_Geometry_methods[]= { {"intersect_ray_tri", (PyCFunction) M_Geometry_intersect_ray_tri, METH_VARARGS, M_Geometry_intersect_ray_tri_doc}, @@ -1096,12 +1104,14 @@ static PyMethodDef M_Geometry_methods[]= { {"intersect_line_plane", (PyCFunction) M_Geometry_intersect_line_plane, METH_VARARGS, M_Geometry_intersect_line_plane_doc}, {"intersect_line_sphere", (PyCFunction) M_Geometry_intersect_line_sphere, METH_VARARGS, M_Geometry_intersect_line_sphere_doc}, {"intersect_line_sphere_2d", (PyCFunction) M_Geometry_intersect_line_sphere_2d, METH_VARARGS, M_Geometry_intersect_line_sphere_2d_doc}, - {"interpolate_bezier", (PyCFunction) M_Geometry_interpolate_bezier, METH_VARARGS, M_Geometry_interpolate_bezier_doc}, {"area_tri", (PyCFunction) M_Geometry_area_tri, METH_VARARGS, M_Geometry_area_tri_doc}, {"normal", (PyCFunction) M_Geometry_normal, METH_VARARGS, M_Geometry_normal_doc}, + {"barycentric_transform", (PyCFunction) M_Geometry_barycentric_transform, METH_VARARGS, M_Geometry_barycentric_transform_doc}, +#ifndef MATH_STANDALONE + {"interpolate_bezier", (PyCFunction) M_Geometry_interpolate_bezier, METH_VARARGS, M_Geometry_interpolate_bezier_doc}, {"tesselate_polygon", (PyCFunction) M_Geometry_tesselate_polygon, METH_O, M_Geometry_tesselate_polygon_doc}, {"box_pack_2d", (PyCFunction) M_Geometry_box_pack_2d, METH_O, M_Geometry_box_pack_2d_doc}, - {"barycentric_transform", (PyCFunction) M_Geometry_barycentric_transform, METH_VARARGS, M_Geometry_barycentric_transform_doc}, +#endif {NULL, NULL, 0, NULL} }; @@ -1118,7 +1128,7 @@ static struct PyModuleDef M_Geometry_module_def= { }; /*----------------------------MODULE INIT-------------------------*/ -PyMODINIT_FUNC BPyInit_mathutils_geometry(void) +PyMODINIT_FUNC PyInit_mathutils_geometry(void) { PyObject *submodule= PyModule_Create(&M_Geometry_module_def); return submodule; diff --git a/source/blender/python/generic/mathutils_geometry.h b/source/blender/python/mathutils/mathutils_geometry.h index 929b8cc8d75..0b07fc12c69 100644..100755 --- a/source/blender/python/generic/mathutils_geometry.h +++ b/source/blender/python/mathutils/mathutils_geometry.h @@ -1,5 +1,5 @@ /* - * $Id$ + * $Id: mathutils_geometry.h 38409 2011-07-15 04:01:47Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -38,6 +38,6 @@ #include "mathutils.h" -PyMODINIT_FUNC BPyInit_mathutils_geometry(void); +PyMODINIT_FUNC PyInit_mathutils_geometry(void); #endif /* MATHUTILS_GEOMETRY_H */ diff --git a/source/blender/quicktime/CMakeLists.txt b/source/blender/quicktime/CMakeLists.txt index 6ce4954f053..b647466d2a8 100644 --- a/source/blender/quicktime/CMakeLists.txt +++ b/source/blender/quicktime/CMakeLists.txt @@ -26,17 +26,15 @@ set(INC . - ../quicktime - ../makesdna - ../makesrna - ../blenlib - ../blenkernel ../avi + ../blenkernel + ../blenlib + ../blenloader ../imbuf ../imbuf/intern - ../blenloader + ../makesdna + ../makesrna ../render/extern/include - ../include ../windowmanager ../../../intern/guardedalloc ) diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index 003f0b839f8..90aef816e2c 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -26,17 +26,17 @@ set(INC - intern/include extern/include + intern/include + ../blenkernel ../blenlib ../blenloader + ../imbuf ../makesdna ../makesrna - ../blenkernel - ../imbuf - ../../../intern/smoke/extern - ../../../intern/mikktspace ../../../intern/guardedalloc + ../../../intern/mikktspace + ../../../intern/smoke/extern ) set(INC_SYS @@ -125,8 +125,12 @@ if(WITH_MOD_SMOKE) endif() if(WITH_CODEC_QUICKTIME) - list(APPEND INC ../quicktime) - list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS}) + list(APPEND INC + ../quicktime + ) + list(APPEND INC_SYS + ${QUICKTIME_INCLUDE_DIRS} + ) add_definitions(-DWITH_QUICKTIME) endif() diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 583b792f240..b385b507707 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -3375,7 +3375,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) /* test for 100% transparant */ ok= 1; - if(ma->alpha==0.0f && ma->spectra==0.0f && ma->filter==0.0f && (ma->mode & MA_TRANSP)) { + if(ma->alpha==0.0f && ma->spectra==0.0f && ma->filter==0.0f && (ma->mode & MA_TRANSP) && (ma->mode & MA_RAYMIRROR)==0) { ok= 0; /* texture on transparency? */ for(a=0; a<MAX_MTEX; a++) { @@ -5685,7 +5685,7 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay, Object *camera; float mat[4][4]; float amb[3]; - const short onlyselected= !ELEM3(type, RE_BAKE_LIGHT, RE_BAKE_ALL, RE_BAKE_SHADOW); + const short onlyselected= !ELEM4(type, RE_BAKE_LIGHT, RE_BAKE_ALL, RE_BAKE_SHADOW, RE_BAKE_AO); const short nolamps= ELEM3(type, RE_BAKE_NORMALS, RE_BAKE_TEXTURE, RE_BAKE_DISPLACEMENT); re->main= bmain; @@ -5778,6 +5778,14 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay, if(re->r.mode & R_RAYTRACE) makeraytree(re); + /* point density texture */ + if(!re->test_break(re->tbh)) + make_pointdensities(re); + + /* voxel data texture */ + if(!re->test_break(re->tbh)) + make_voxeldata(re); + /* occlusion */ if((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && !re->test_break(re->tbh)) if(re->wrld.ao_gather_method == WO_AOGATHER_APPROX) diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 3aca334cffe..a7e19c8db4f 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2577,27 +2577,7 @@ void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter) /* Margin */ if(filter) { - char *temprect; - int i; - - /* extend the mask +2 pixels from the image, - * this is so colors dont blend in from outside */ - - for(i=0; i< filter; i++) - IMB_mask_filter_extend(mask, ibuf->x, ibuf->y); - - temprect = MEM_dupallocN(mask); - - /* expand twice to clear this many pixels, so they blend back in */ - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y); - - /* clear all pixels in the margin */ - IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN); - MEM_freeN(temprect); - - for(i= 0; i < filter; i++) - IMB_filter_extend(ibuf, mask); + IMB_filter_extend(ibuf, mask, filter); } /* if the bake results in new alpha then change the image setting */ diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index f9c1d800c02..20ac3ba7077 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -26,23 +26,23 @@ set(INC . - ../nodes - ../gpu ../blenfont - ../blenlib - ../makesdna - ../makesrna ../blenkernel - ../imbuf + ../blenlib ../blenloader ../editors/include + ../gpu + ../imbuf + ../makesdna + ../makesrna + ../nodes ../render/extern/include - ../../../intern/guardedalloc - ../../../intern/memutil + ../../gameengine/BlenderRoutines ../../../intern/elbeem/extern ../../../intern/ghost + ../../../intern/guardedalloc + ../../../intern/memutil ../../../intern/opennl/extern - ../../../source/gameengine/BlenderRoutines ) set(INC_SYS @@ -89,18 +89,26 @@ if(WITH_OPENCOLLADA) endif() if(WITH_CODEC_QUICKTIME) - list(APPEND INC ../quicktime) - list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS}) + list(APPEND INC + ../quicktime + ) + list(APPEND INC_SYS + ${QUICKTIME_INCLUDE_DIRS} + ) add_definitions(-DWITH_QUICKTIME) endif() if(WITH_CODEC_FFMPEG) - list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS}) + list(APPEND INC_SYS + ${FFMPEG_INCLUDE_DIRS} + ) add_definitions(-DWITH_FFMPEG) endif() if(WITH_PYTHON) - list(APPEND INC ../python) + list(APPEND INC + ../python + ) add_definitions(-DWITH_PYTHON) if(WITH_PYTHON_SECURITY) diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 98ffaac004e..fc41c2b37a1 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -273,6 +273,7 @@ void WM_operator_py_idname(char *to, const char *from); /* *************** menu types ******************** */ struct MenuType *WM_menutype_find(const char *idname, int quiet); int WM_menutype_add(struct MenuType* mt); +int WM_menutype_contains(struct MenuType* mt); void WM_menutype_freelink(struct MenuType* mt); void WM_menutype_free(void); diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index bcd5cf38f88..a535c0bc1f8 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -175,6 +175,12 @@ int WM_menutype_add(MenuType* mt) return 1; } +/* inefficient but only used for tooltip code */ +int WM_menutype_contains(MenuType* mt) +{ + return (mt != NULL && BLI_findindex(&menutypes, mt) != -1); +} + void WM_menutype_freelink(MenuType* mt) { BLI_freelinkN(&menutypes, mt); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 26d1b4454bd..daaaee771fd 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -139,15 +139,15 @@ void WM_init(bContext *C, int argc, const char **argv) RNA_types_init_gettext(); wm_operatortype_init(); - + set_free_windowmanager_cb(wm_close_and_free); /* library.c */ set_blender_test_break_cb(wm_window_testbreak); /* blender.c */ DAG_editors_update_cb(ED_render_id_flush_update); /* depsgraph.c */ - + ED_spacetypes_init(); /* editors/space_api/spacetype.c */ - + ED_file_init(); /* for fsmenu */ - ED_init_node_butfuncs(); + ED_init_node_butfuncs(); WM_read_homefile_proc(C, &wmbase); /* note: there is a bug where python needs initializing before loading the diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 3067d298567..ea8e6d9bb31 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3567,10 +3567,12 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) /* items for modal map */ WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); - WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, GESTURE_MODAL_CANCEL); + /* Note: cancel only on press otherwise you cannot map this to RMB-gesture */ + WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_BEGIN); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT); + WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_SELECT); #if 0 // Durian guys like this WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_SHIFT, 0, GESTURE_MODAL_BEGIN); diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 9c60cdac22b..ddfdfc97bdc 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -121,6 +121,7 @@ endif() bf_intern_guardedalloc bf_intern_memutil bf_python_ext + bf_python_mathutils bf_blenlib bf_imbuf_cineon bf_imbuf_openexr diff --git a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt index 80f3642748a..f852d061cf7 100644 --- a/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt +++ b/source/blenderplayer/bad_level_call_stubs/CMakeLists.txt @@ -29,12 +29,12 @@ remove_strict_flags() set(INC . - .. + .. + ../../blender/blenkernel + ../../blender/blenloader + ../../blender/makesdna + ../../blender/makesrna ../../../intern/guardedalloc - ../../../source/blender/makesdna - ../../../source/blender/blenloader - ../../../source/blender/makesrna - ../../../source/blender/blenkernel ) set(INC_SYS diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 7bf5fe9dde3..548d272ffd2 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -136,7 +136,6 @@ int RE_RenderInProgress(struct Render *re){return 0;} struct Scene *RE_GetScene(struct Render *re){return (struct Scene *) NULL;} void RE_Database_Free(struct Render *re){} void RE_FreeRender(struct Render *re){} -void RE_shade_external(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr){} void RE_DataBase_GetView(struct Render *re, float mat[][4]){} int externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta){return 0;} float texture_value_blend(float tex, float out, float fact, float facg, int blendtype, int flip){return 0.0f;} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 630c85656a4..c51adae90a6 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -455,8 +455,10 @@ elseif(WIN32) endif() install( # same as linux!, deduplicate - DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale - DESTINATION ${TARGETDIR_VER}/datafiles + DIRECTORY + ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale + ${CMAKE_SOURCE_DIR}/release/bin/.blender/fonts + DESTINATION ${TARGETDIR_VER}/datafiles/locale PATTERN ".svn" EXCLUDE ) @@ -676,8 +678,8 @@ elseif(APPLE) install_dir( DIRECTORY - ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale - \${TARGETDIR_VER}/datafiles/ + ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/ + \${TARGETDIR_VER}/datafiles/locale ) endif() @@ -779,6 +781,7 @@ endif() bf_intern_opennl bf_python bf_python_ext + bf_python_mathutils bf_ikplugin bf_modifiers bf_blenkernel diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index 28f567cc3cd..5a7304765e4 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -1,33 +1,33 @@ set(INC . - ../../../intern/string + ../Converter + ../Expressions + ../GameLogic + ../Ketsji + ../Network + ../Network/LoopBackNetwork + ../Physics/Bullet + ../Physics/common + ../Rasterizer + ../Rasterizer/RAS_OpenGLRasterizer + ../SceneGraph + ../../blender + ../../blender/blenfont + ../../blender/blenkernel + ../../blender/blenlib + ../../blender/blenloader + ../../blender/editors/include + ../../blender/gpu + ../../blender/imbuf + ../../blender/makesdna + ../../blender/makesrna + ../../blender/windowmanager + ../../../extern/bullet2/src ../../../intern/container ../../../intern/guardedalloc - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../source/gameengine/Converter - ../../../source/blender/imbuf ../../../intern/moto/include - ../../../source/gameengine/Ketsji - ../../../source/blender/blenlib - ../../../source/blender/blenkernel - ../../../source/blender/blenfont - ../../../source/blender/editors/include - ../../../source/blender/windowmanager - ../../../source/blender - ../../../source/blender/makesdna - ../../../source/blender/makesrna - ../../../source/gameengine/Rasterizer - ../../../source/gameengine/GameLogic - ../../../source/gameengine/Expressions - ../../../source/gameengine/Network - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Physics/common - ../../../source/gameengine/Physics/Bullet - ../../../source/gameengine/Network/LoopBackNetwork - ../../../source/blender/blenloader - ../../../source/blender/gpu - ../../../extern/bullet2/src + ../../../intern/string ${GLEW_INCLUDE_PATH} ) diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index af114457663..7b9c5d4b4d6 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1976,8 +1976,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, frame_type = RAS_FrameSettings::e_frame_scale; } - aspect_width = blenderscene->gm.xsch; - aspect_height = blenderscene->gm.ysch; + aspect_width = blenderscene->r.xsch*blenderscene->r.xasp; + aspect_height = blenderscene->r.ysch*blenderscene->r.yasp; } RAS_FrameSettings frame_settings( diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index c905b8634a0..45a7701d404 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -26,36 +26,35 @@ set(INC . - ../../../intern/string - ../../../intern/guardedalloc + ../BlenderRoutines + ../Expressions + ../GameLogic + ../Ketsji + ../Ketsji/KXNetwork + ../Network + ../Network/LoopBackNetwork + ../Physics/Bullet + ../Physics/Dummy + ../Physics/common + ../Rasterizer + ../Rasterizer/RAS_OpenGLRasterizer + ../Rasterizer/RAS_OpenGLRasterizer + ../SceneGraph + ../../blender + ../../blender/blenkernel + ../../blender/blenlib + ../../blender/blenloader + ../../blender/gpu + ../../blender/ikplugin + ../../blender/imbuf + ../../blender/makesdna + ../../blender/makesrna + ../../blender/windowmanager + ../../../extern/bullet2/src ../../../intern/container - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../source/gameengine/Converter - ../../../source/gameengine/BlenderRoutines - ../../../source/blender/imbuf + ../../../intern/guardedalloc ../../../intern/moto/include - ../../../source/gameengine/Ketsji - ../../../source/gameengine/Ketsji/KXNetwork - ../../../source/blender/blenlib - ../../../source/blender/blenkernel - ../../../source/blender/windowmanager - ../../../source/blender - ../../../source/blender/makesdna - ../../../source/blender/makesrna - ../../../source/gameengine/Rasterizer - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../source/gameengine/GameLogic - ../../../source/gameengine/Expressions - ../../../source/gameengine/Network - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Physics/common - ../../../source/gameengine/Physics/Bullet - ../../../source/gameengine/Physics/Dummy - ../../../source/gameengine/Network/LoopBackNetwork - ../../../source/blender/blenloader - ../../../source/blender/gpu - ../../../source/blender/ikplugin - ../../../extern/bullet2/src + ../../../intern/string ) set(INC_SYS diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt index 83d44e1b318..ad987091790 100644 --- a/source/gameengine/Expressions/CMakeLists.txt +++ b/source/gameengine/Expressions/CMakeLists.txt @@ -26,11 +26,11 @@ set(INC . - ../../../intern/string + ../SceneGraph + ../../blender/blenloader ../../../intern/guardedalloc ../../../intern/moto/include - ../../../source/gameengine/SceneGraph - ../../../source/blender/blenloader + ../../../intern/string ) set(INC_SYS diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 3a25df73f9b..92be769ed71 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -1184,46 +1184,10 @@ void PyObjectPlus::SetDeprecationWarnings(bool ignoreDeprecationWarnings) m_ignore_deprecation_warnings = ignoreDeprecationWarnings; } -void PyDebugLine() -{ - // import sys; print '\t%s:%d' % (sys._getframe(0).f_code.co_filename, sys._getframe(0).f_lineno) - - PyObject *getframe, *frame; - PyObject *f_lineno, *f_code, *co_filename; - - getframe = PySys_GetObject((char *)"_getframe"); // borrowed - if (getframe) { - frame = PyObject_CallObject(getframe, NULL); - if (frame) { - f_lineno= PyObject_GetAttrString(frame, "f_lineno"); - f_code= PyObject_GetAttrString(frame, "f_code"); - if (f_lineno && f_code) { - co_filename= ((PyCodeObject *)f_code)->co_filename; /* borrow */ - if (co_filename) { - - printf("\t%s:%d\n", _PyUnicode_AsString(co_filename), (int)PyLong_AsSsize_t(f_lineno)); - - Py_DECREF(f_lineno); - Py_DECREF(f_code); - Py_DECREF(frame); - return; - } - } - - Py_XDECREF(f_lineno); - Py_XDECREF(f_code); - Py_DECREF(frame); - } - - } - PyErr_Clear(); - printf("\tERROR - Could not access sys._getframe(0).f_lineno or sys._getframe().f_code.co_filename\n"); -} - void PyObjectPlus::ShowDeprecationWarning_func(const char* old_way,const char* new_way) { printf("Method %s is deprecated, please use %s instead.\n", old_way, new_way); - PyDebugLine(); + PyC_LineSpit(); } void PyObjectPlus::ClearDeprecationWarning() diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 157124ebc81..51cfb5471c0 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -54,7 +54,8 @@ #ifdef WITH_PYTHON #ifdef USE_MATHUTILS extern "C" { -#include "../../blender/python/generic/mathutils.h" /* so we can have mathutils callbacks */ +#include "../../blender/python/mathutils/mathutils.h" /* so we can have mathutils callbacks */ +#include "../../blender/python/generic/py_capi_utils.h" /* for PyC_LineSpit only */ } #endif diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index b6721650bad..bd417165337 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -25,13 +25,13 @@ # ***** END GPL LICENSE BLOCK ***** set(INC - . - ../../../intern/string + . + ../Expressions + ../Rasterizer + ../SceneGraph ../../../intern/container - ../../../source/gameengine/Expressions - ../../../source/gameengine/SceneGraph ../../../intern/moto/include - ../../../source/gameengine/Rasterizer + ../../../intern/string ) set(INC_SYS @@ -39,8 +39,6 @@ set(INC_SYS ) set(SRC - Joystick/SCA_Joystick.cpp - Joystick/SCA_JoystickEvents.cpp SCA_2DFilterActuator.cpp SCA_ANDController.cpp SCA_ActuatorEventManager.cpp @@ -81,10 +79,9 @@ set(SRC SCA_TimeEventManager.cpp SCA_XNORController.cpp SCA_XORController.cpp + Joystick/SCA_Joystick.cpp + Joystick/SCA_JoystickEvents.cpp - Joystick/SCA_Joystick.h - Joystick/SCA_JoystickDefines.h - Joystick/SCA_JoystickPrivate.h SCA_2DFilterActuator.h SCA_ANDController.h SCA_ActuatorEventManager.h @@ -125,10 +122,15 @@ set(SRC SCA_TimeEventManager.h SCA_XNORController.h SCA_XORController.h + Joystick/SCA_Joystick.h + Joystick/SCA_JoystickDefines.h + Joystick/SCA_JoystickPrivate.h ) if(WITH_SDL) - list(APPEND INC_SYS ${SDL_INCLUDE_DIR}) + list(APPEND INC_SYS + ${SDL_INCLUDE_DIR} + ) else() add_definitions(-DDISABLE_SDL) endif() diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 0e08f157a6a..48ba09e67d2 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -89,7 +89,7 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) { int i; // do this once only - if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1 ){ + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO) == -1 ){ echo("Error-Initializing-SDL: " << SDL_GetError()); return NULL; } @@ -124,7 +124,7 @@ void SCA_Joystick::ReleaseInstance() m_instance[i]= NULL; } - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO); #endif } } diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index d16ec6a2f22..8c5897fa48e 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -26,31 +26,31 @@ set(INC . - ../../../../intern/string + ../ghost + ../../BlenderRoutines + ../../Converter + ../../Expressions + ../../GameLogic + ../../Ketsji + ../../Network + ../../Network/LoopBackNetwork + ../../Physics/common + ../../Rasterizer + ../../Rasterizer/RAS_OpenGLRasterizer + ../../SceneGraph + ../../../blender + ../../../blender/blenfont + ../../../blender/blenkernel + ../../../blender/blenlib + ../../../blender/blenloader + ../../../blender/gpu + ../../../blender/imbuf + ../../../blender/makesdna + ../../../../intern/container ../../../../intern/ghost ../../../../intern/guardedalloc - ../../../../intern/container ../../../../intern/moto/include - ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../../source/gameengine/Converter - ../../../../source/gameengine/BlenderRoutines - ../../../../source/blender/imbuf - ../../../../source/gameengine/Ketsji - ../../../../source/blender/blenlib - ../../../../source/blender/blenfont - ../../../../source/blender/blenkernel - ../../../../source/blender - ../../../../source/blender/makesdna - ../../../../source/gameengine/Rasterizer - ../../../../source/gameengine/GameLogic - ../../../../source/gameengine/Expressions - ../../../../source/gameengine/Network - ../../../../source/gameengine/SceneGraph - ../../../../source/gameengine/Physics/common - ../../../../source/gameengine/Network/LoopBackNetwork - ../../../../source/gameengine/GamePlayer/ghost - ../../../../source/blender/blenloader - ../../../../source/blender/gpu + ../../../../intern/string ) set(INC_SYS @@ -61,7 +61,6 @@ set(INC_SYS ) set(SRC - bmfont.cpp GPC_Canvas.cpp GPC_Engine.cpp GPC_KeyboardDevice.cpp @@ -71,6 +70,7 @@ set(SRC GPC_RawLogoArrays.cpp GPC_RenderTools.cpp GPC_System.cpp + bmfont.cpp GPC_Canvas.h GPC_Engine.h diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index 5ac121099c3..944ec9abd67 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -26,32 +26,32 @@ set(INC . - ../../../../intern/string + ../common + ../../BlenderRoutines + ../../Converter + ../../Expressions + ../../GameLogic + ../../Ketsji + ../../Network + ../../Network/LoopBackNetwork + ../../Physics/common + ../../Rasterizer + ../../Rasterizer/RAS_OpenGLRasterizer + ../../SceneGraph + ../../../blender + ../../../blender/blenfont + ../../../blender/blenkernel + ../../../blender/blenlib + ../../../blender/blenloader + ../../../blender/gpu + ../../../blender/imbuf + ../../../blender/makesdna + ../../../blender/makesrna + ../../../../intern/container ../../../../intern/ghost ../../../../intern/guardedalloc - ../../../../intern/container ../../../../intern/moto/include - ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../../source/gameengine/BlenderRoutines - ../../../../source/gameengine/Converter - ../../../../source/blender/imbuf - ../../../../source/gameengine/Ketsji - ../../../../source/blender/blenfont - ../../../../source/blender/blenlib - ../../../../source/blender/blenkernel - ../../../../source/blender - ../../../../source/blender/makesdna - ../../../../source/blender/makesrna - ../../../../source/gameengine/Rasterizer - ../../../../source/gameengine/GameLogic - ../../../../source/gameengine/Expressions - ../../../../source/gameengine/Network - ../../../../source/gameengine/SceneGraph - ../../../../source/gameengine/Physics/common - ../../../../source/gameengine/Network/LoopBackNetwork - ../../../../source/gameengine/GamePlayer/common - ../../../../source/blender/blenloader - ../../../../source/blender/gpu + ../../../../intern/string ) set(INC_SYS @@ -62,9 +62,9 @@ set(INC_SYS set(SRC GPG_Application.cpp GPG_Canvas.cpp - GPG_ghost.cpp GPG_KeyboardDevice.cpp GPG_System.cpp + GPG_ghost.cpp GPG_Application.h GPG_Canvas.h diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index b5a63f44729..8222bf4b65f 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -26,32 +26,32 @@ set(INC . - ../../../intern/string - ../../../intern/guardedalloc + KXNetwork + ../BlenderRoutines + ../Converter + ../Expressions + ../GameLogic + ../Network + ../Network/LoopBackNetwork + ../Physics/common + ../Rasterizer + ../Rasterizer/RAS_OpenGLRasterizer + ../SceneGraph + ../../blender + ../../blender/blenfont + ../../blender/blenkernel + ../../blender/blenlib + ../../blender/blenloader + ../../blender/gpu + ../../blender/imbuf + ../../blender/makesdna + ../../blender/python + ../../blender/python/generic + ../../blender/python/mathutils ../../../intern/container - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../source/gameengine/Converter - ../../../source/gameengine/BlenderRoutines - ../../../source/blender/imbuf + ../../../intern/guardedalloc ../../../intern/moto/include - ../../../source/gameengine/Ketsji - ../../../source/blender/blenlib - ../../../source/blender/blenfont - ../../../source/blender/blenkernel - ../../../source/blender/python - ../../../source/blender/python/generic - ../../../source/blender - ../../../source/blender/makesdna - ../../../source/gameengine/Rasterizer - ../../../source/gameengine/GameLogic - ../../../source/gameengine/Expressions - ../../../source/gameengine/Ketsji/KXNetwork - ../../../source/gameengine/Network - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Physics/common - ../../../source/gameengine/Network/LoopBackNetwork - ../../../source/blender/blenloader - ../../../source/blender/gpu + ../../../intern/string ) set(INC_SYS @@ -128,6 +128,10 @@ set(SRC KX_WorldInfo.cpp KX_WorldIpoController.cpp + BL_BlenderShader.h + BL_Material.h + BL_Shader.h + BL_Texture.h KX_ArmatureSensor.h KX_BlenderMaterial.h KX_BulletPhysicsController.h @@ -200,16 +204,14 @@ set(SRC KX_VisibilityActuator.h KX_WorldInfo.h KX_WorldIpoController.h - BL_BlenderShader.h - BL_Material.h - BL_Shader.h - BL_Texture.h ) add_definitions(-DGLEW_STATIC) if(WITH_SDL) - list(APPEND INC_SYS ${SDL_INCLUDE_DIR}) + list(APPEND INC_SYS + ${SDL_INCLUDE_DIR} + ) else() add_definitions(-DDISABLE_SDL) endif() @@ -228,7 +230,7 @@ endif() if(WITH_BULLET) list(APPEND INC ../../../extern/bullet2/src - ../../../source/gameengine/Physics/Bullet + ../Physics/Bullet ) add_definitions(-DUSE_BULLET) endif() diff --git a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt index b8149566801..1ebf1153150 100644 --- a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt +++ b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt @@ -26,14 +26,14 @@ set(INC . - ../../../../intern/string + .. + ../../Expressions + ../../GameLogic + ../../Network + ../../SceneGraph ../../../../intern/container ../../../../intern/moto/include - ../../../../source/gameengine/Ketsji - ../../../../source/gameengine/GameLogic - ../../../../source/gameengine/Expressions - ../../../../source/gameengine/SceneGraph - ../../../../source/gameengine/Network + ../../../../intern/string ) set(INC_SYS diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index ea0b00e52fd..0aa36b4cd5f 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1220,7 +1220,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) projmat.setValue(m_overrideCamProjMat.getPointer()); cam->SetProjectionMatrix(projmat); } - } else if (cam->hasValidProjectionMatrix() && !cam->GetViewport() ) + } else if (cam->hasValidProjectionMatrix()) { m_rasterizer->SetProjectionMatrix(cam->GetProjectionMatrix()); } else diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index 9b198f85664..4864482c33b 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -49,7 +49,7 @@ #ifdef WITH_PYTHON #ifdef USE_MATHUTILS extern "C" { -#include "../../blender/python/generic/mathutils.h" /* so we can have mathutils callbacks */ +#include "../../blender/python/mathutils/mathutils.h" /* so we can have mathutils callbacks */ } #endif diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index a927de60cd8..f643030e3a2 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -54,7 +54,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 "mathutils.h" // 'mathutils' module copied here so the blenderlayer can use. #include "bgl.h" #include "blf_py_api.h" @@ -1749,7 +1749,7 @@ static void restorePySysObjects(void) // Copied from bpy_interface.c static struct _inittab bge_internal_modules[]= { - {(char *)"mathutils", BPyInit_mathutils}, + {(char *)"mathutils", PyInit_mathutils}, {(char *)"bgl", BPyInit_bgl}, {(char *)"blf", BPyInit_blf}, {(char *)"aud", AUD_initPython}, diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 08642262724..62caa602c23 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -6,7 +6,8 @@ Import ('env') sources = env.Glob('*.cpp') defs = [ 'GLEW_STATIC' ] -incs = '. #source/blender/python/generic' # Only for Mathutils! and bpy_internal_import.h, be very careful +incs = '. #source/blender/python/generic' # Only for bpy_internal_import.h, be very careful +incs += ' #source/blender/python/mathutils' # Only for mathutils, be very careful incs += ' #intern/string #intern/guardedalloc #intern/container' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' diff --git a/source/gameengine/Network/CMakeLists.txt b/source/gameengine/Network/CMakeLists.txt index e1f3bfaac77..4d6d035c63d 100644 --- a/source/gameengine/Network/CMakeLists.txt +++ b/source/gameengine/Network/CMakeLists.txt @@ -26,9 +26,9 @@ set(INC . - ../../../intern/string ../../../intern/container ../../../intern/moto/include + ../../../intern/string ) set(INC_SYS diff --git a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt index 9c3936987f2..c816a30f1a8 100644 --- a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt +++ b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt @@ -26,9 +26,9 @@ set(INC . - ../../../../intern/string + .. ../../../../intern/container - ../../../../source/gameengine/Network + ../../../../intern/string ) set(INC_SYS diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt index aadd11cc036..971c8f979f3 100644 --- a/source/gameengine/Physics/Bullet/CMakeLists.txt +++ b/source/gameengine/Physics/Bullet/CMakeLists.txt @@ -30,19 +30,19 @@ remove_strict_flags() set(INC . ../common - ../../../../extern/bullet2/src - ../../../../intern/moto/include - ../../../../intern/guardedalloc - ../../../../intern/container - ../../../../intern/string - ../../Rasterizer - ../../Ketsji ../../Expressions ../../GameLogic + ../../Ketsji + ../../Rasterizer ../../SceneGraph - ../../../../source/blender/makesdna - ../../../../source/blender/blenlib - ../../../../source/blender/blenkernel + ../../../blender/blenkernel + ../../../blender/blenlib + ../../../blender/makesdna + ../../../../extern/bullet2/src + ../../../../intern/container + ../../../../intern/guardedalloc + ../../../../intern/moto/include + ../../../../intern/string ) set(INC_SYS diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index b705d3151b2..23d746f88bc 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -26,14 +26,14 @@ set(INC . - ../../../source/blender/makesdna - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Ketsji - ../../../intern/string + ../Expressions + ../Ketsji + ../SceneGraph + ../../blender/makesdna ../../../intern/container - ../../../intern/moto/include ../../../intern/guardedalloc - ../Expressions + ../../../intern/moto/include + ../../../intern/string ) set(INC_SYS diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index a005bb1108d..b0ef6fab251 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -25,18 +25,18 @@ # ***** END GPL LICENSE BLOCK ***** set(INC - ../../../../intern/string + .. + ../../BlenderRoutines + ../../Ketsji + ../../SceneGraph + ../../../blender/blenkernel + ../../../blender/blenlib + ../../../blender/blenloader + ../../../blender/gpu + ../../../blender/makesdna ../../../../intern/container ../../../../intern/moto/include - ../../../../source/gameengine/Rasterizer - ../../../../source/gameengine/Ketsji - ../../../../source/gameengine/SceneGraph - ../../../../source/gameengine/BlenderRoutines - ../../../../source/blender/gpu - ../../../../source/blender/makesdna - ../../../../source/blender/blenkernel - ../../../../source/blender/blenlib - ../../../../source/blender/blenloader + ../../../../intern/string ) set(INC_SYS diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt index c412363dc3b..04683a5f99b 100644 --- a/source/gameengine/VideoTexture/CMakeLists.txt +++ b/source/gameengine/VideoTexture/CMakeLists.txt @@ -26,26 +26,26 @@ set(INC . - ../../../source/gameengine/Ketsji - ../../../source/gameengine/Expressions - ../../../source/gameengine/GameLogic - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Rasterizer - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../source/gameengine/BlenderRoutines - ../../../source/blender/blenlib - ../../../source/blender/blenkernel - ../../../source/blender/makesdna - ../../../source/blender/editors/include - ../../../source/blender/imbuf - ../../../source/blender/python - ../../../source/blender/python/generic - ../../../source/blender/gpu + ../BlenderRoutines + ../Expressions + ../GameLogic + ../Ketsji + ../Rasterizer + ../Rasterizer/RAS_OpenGLRasterizer + ../SceneGraph + ../../blender/blenkernel + ../../blender/blenlib + ../../blender/editors/include + ../../blender/gpu + ../../blender/imbuf + ../../blender/makesdna + ../../blender/python + ../../blender/python/generic ../../../intern/container - ../../../intern/string - ../../../intern/moto/include - ../../../intern/guardedalloc ../../../intern/ffmpeg + ../../../intern/guardedalloc + ../../../intern/moto/include + ../../../intern/string ) set(INC_SYS diff --git a/source/tests/CMakeLists.txt b/source/tests/CMakeLists.txt index d1696223ec6..8fd0d6e7099 100644 --- a/source/tests/CMakeLists.txt +++ b/source/tests/CMakeLists.txt @@ -196,7 +196,7 @@ add_test(export_x3d_cube ${TEST_BLENDER_EXE} --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- --run={'FINISHED'}&bpy.ops.export_scene.x3d\(filepath='${TEST_OUT_DIR}/export_x3d_cube.x3d',use_selection=False\) --md5_source=${TEST_OUT_DIR}/export_x3d_cube.x3d - --md5=6ae36be272d6f84c697e84a8b6463273 --md5_method=FILE + --md5=5e804c689896116331fa190a9fabbad4 --md5_method=FILE ) add_test(export_x3d_nurbs ${TEST_BLENDER_EXE} @@ -212,7 +212,7 @@ add_test(export_x3d_all_objects ${TEST_BLENDER_EXE} --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- --run={'FINISHED'}&bpy.ops.export_scene.x3d\(filepath='${TEST_OUT_DIR}/export_x3d_all_objects.x3d',use_selection=False\) --md5_source=${TEST_OUT_DIR}/export_x3d_all_objects.x3d - --md5=bba48ca191e8891adb27c59ed4ce4735 --md5_method=FILE + --md5=2809ec13a4cab55d265ce7525c5db1b7 --md5_method=FILE ) @@ -261,7 +261,7 @@ add_test(export_3ds_all_objects ${TEST_BLENDER_EXE} --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- --run={'FINISHED'}&bpy.ops.export_scene.autodesk_3ds\(filepath='${TEST_OUT_DIR}/export_3ds_all_objects.3ds',use_selection=False\) --md5_source=${TEST_OUT_DIR}/export_3ds_all_objects.3ds - --md5=cdf8fa8475fda0b9ef565ac09339254b --md5_method=FILE + --md5=0940ea889498cd437d503670738639ae --md5_method=FILE ) @@ -273,7 +273,7 @@ add_test(export_fbx_cube ${TEST_BLENDER_EXE} --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- --run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_cube.fbx',use_selection=False,use_metadata=False\) --md5_source=${TEST_OUT_DIR}/export_fbx_cube.fbx - --md5=642a5a1fa199d5b9bbf1643519ae974d --md5_method=FILE + --md5=83dca99a0cb338852b8c85951a44c68a --md5_method=FILE ) add_test(export_fbx_nurbs ${TEST_BLENDER_EXE} @@ -281,7 +281,7 @@ add_test(export_fbx_nurbs ${TEST_BLENDER_EXE} --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- --run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_nurbs.fbx',use_selection=False,use_metadata=False\) --md5_source=${TEST_OUT_DIR}/export_fbx_nurbs.fbx - --md5=ec1e8965bdbc3bf70707d77f82c2cb9c --md5_method=FILE + --md5=c7d9491ffa6264e820ed1e12df63f871 --md5_method=FILE ) add_test(export_fbx_all_objects ${TEST_BLENDER_EXE} @@ -289,5 +289,5 @@ add_test(export_fbx_all_objects ${TEST_BLENDER_EXE} --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- --run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_all_objects.fbx',use_selection=False,use_metadata=False\) --md5_source=${TEST_OUT_DIR}/export_fbx_all_objects.fbx - --md5=af3b65665687ac92e4aba07b017d87fe --md5_method=FILE + --md5=22867f82e1615fd1eae18cfaac8ba035 --md5_method=FILE ) diff --git a/source/tests/check_deprecated.py b/source/tests/check_deprecated.py new file mode 100755 index 00000000000..11c7ce646b9 --- /dev/null +++ b/source/tests/check_deprecated.py @@ -0,0 +1,144 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +# <pep8 compliant> + +import os +from os.path import splitext + +DEPRECATE_DAYS = 120 + +SKIP_DIRS = ("extern", + "scons", + os.path.join("source", "tests"), # not this dir + ) + +def is_c_header(filename): + ext = splitext(filename)[1] + return (ext in (".h", ".hpp", ".hxx")) + + +def is_c(filename): + ext = splitext(filename)[1] + return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc")) + + +def is_c_any(filename): + return is_c(filename) or is_c_header(filename) + +def is_py(filename): + ext = splitext(filename)[1] + return (ext == ".py") + +def is_source_any(filename): + return is_c_any(filename) or is_py(filename) + +def source_list(path, filename_check=None): + for dirpath, dirnames, filenames in os.walk(path): + + # skip '.svn' + if dirpath.startswith("."): + continue + + for filename in filenames: + if filename_check is None or filename_check(filename): + yield os.path.join(dirpath, filename) + + +def deprecations(): + """ + Searches out source code for lines like + + /* *DEPRECATED* 2011/7/17 bgl.Buffer.list info text */ + + Or... + + # *DEPRECATED* 2010/12/22 some.py.func more info */ + + """ + import datetime + SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", "..")))) + + SKIP_DIRS_ABS = [os.path.join(SOURCE_DIR, p) for p in SKIP_DIRS] + + deprecations_ls = [] + + scan_tot = 0 + + print("scanning in %r for '*DEPRECATED* YYYY/MM/DD info'" % SOURCE_DIR) + + for fn in source_list(SOURCE_DIR, is_source_any): + # print(fn) + skip = False + for p in SKIP_DIRS_ABS: + if fn.startswith(p): + skip = True + break + if skip: + continue + + file = open(fn, 'r', encoding="utf8") + for i, l in enumerate(file): + # logic for deprecation warnings + if '*DEPRECATED*' in l: + try: + l = l.strip() + data = l.split('*DEPRECATED*', 1)[-1].strip().strip() + data = [w.strip() for w in data.split('/', 2)] + data[-1], info = data[-1].split(' ', 1) + info = info.split("*/", 1)[0] + if len(data) != 3: + print(" poorly formatting line:\n" + " %r:%d\n" + " %s"% + (fn, i + 1, l) + ) + else: + data = datetime.datetime(*tuple([int(w) for w in data])) + + deprecations_ls.append((data, (fn, i + 1), info)) + except: + print("Error file - %r:%d" % (fn, i + 1)) + import traceback + traceback.print_exc() + + scan_tot += 1 + + print(" scanned %d files" % scan_tot) + + return deprecations_ls + +def main(): + import datetime + now = datetime.datetime.now()\ + + deps = deprecations() + + print("\nAll deprecations...") + for data, fileinfo, info in deps: + days_old = (now - data).days + if days_old > DEPRECATE_DAYS: + info = "*** REMOVE! *** " + info + print(" %r, days-old(%.2d), %s:%d - %s" % (data, days_old, fileinfo[0], fileinfo[1], info)) + if deps: + print("\ndone!") + else: + print("\nnone found!") + +if __name__ == '__main__': + main() |