diff --git a/CMakeLists.txt b/CMakeLists.txt index 81263095bf8..b2243e6bd74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1053,12 +1053,15 @@ if(CMAKE_COMPILER_IS_GNUCC) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type) # system headers sometimes do this, disable for now, was: -Werror=strict-prototypes - ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_STRICT_PROTOTYPES -Wstrict-prototypes) + ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings) + # disable because it gives warnings for printf() & friends. + # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion) + ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall) ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof) diff --git a/SConstruct b/SConstruct index 583cc0b144b..954422e0b3d 100644 --- a/SConstruct +++ b/SConstruct @@ -153,13 +153,11 @@ if cc: if cxx: env['CXX'] = cxx -if env['CC'] in ['cl', 'cl.exe'] and sys.platform=='win32': - if bitness == 64: - platform = 'win64-vc' - else: - platform = 'win32-vc' -elif env['CC'] in ['gcc'] and sys.platform=='win32': - platform = 'win32-mingw' +if sys.platform=='win32': + if env['CC'] in ['cl', 'cl.exe']: + platform = 'win64-vc' if bitness == 64 else 'win32-vc' + elif env['CC'] in ['gcc']: + platform = 'win32-mingw' env.SConscriptChdir(0) @@ -197,6 +195,10 @@ else: opts = btools.read_opts(env, optfiles, B.arguments) opts.Update(env) +if sys.platform=='win32': + if bitness==64: + env.Append(CFLAGS=['-DWIN64']) # -DWIN32 needed too, as it's used all over to target Windows generally + if not env['BF_FANCY']: B.bc.disable() @@ -641,6 +643,16 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'): '${BF_FFMPEG_LIBPATH}/avdevice-52.dll', '${BF_FFMPEG_LIBPATH}/avutil-50.dll', '${BF_FFMPEG_LIBPATH}/swscale-0.dll'] + + # Since the thumb handler is loaded by Explorer, architecture is + # strict: the x86 build fails on x64 Windows. We need to ship + # both builds in x86 packages. + if bitness == 32: + dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll') + dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll') + + dllsources.append('#source/icons/blender.exe.manifest') + windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources) allinstall += windlls diff --git a/build_files/buildbot/config/user-config-i686.py b/build_files/buildbot/config/user-config-i686.py new file mode 100644 index 00000000000..7b093868e6b --- /dev/null +++ b/build_files/buildbot/config/user-config-i686.py @@ -0,0 +1,85 @@ +BF_BUILDDIR = '../blender-build/linux-glibc27-i686' +BF_INSTALLDIR = '../blender-install/linux-glibc27-i686' + +# Python configuration +BF_PYTHON_VERSION = '3.2' +BF_PYTHON_ABI_FLAGS = 'mu' +BF_PYTHON = '/opt/python3.2' + +WITH_BF_STATICPYTHON = True + +# OpenCollada configuration +WITH_BF_COLLADA = True +BF_OPENCOLLADA = '/opt/opencollada' +BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include' +BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver buffer ftoa libxml2-static libexpat-static libpcre-static' +BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib /home/sources/staticlibs/lib32' +BF_PCRE_LIB = '' +BF_EXPAT_LIB = '' + +# FFMPEG configuration +WITH_BF_FFMPEG = True +WITH_BF_STATICFFMPEG = True + +# Used for linking against system ffmpeg, but it gives pixelization,, so fall back to ffmpeg from 2.52 temporary +#BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libavutil.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libdc1394.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libraw1394.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libfaad.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libspeex.a ${BF_FFMPEG_LIBPATH}/libbz2.a ${BF_FFMPEG_LIBPATH}/liboil-0.3.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libgsm.a' + +BF_FFMPEG = '/home/sources/staticlibs/ffmpeg' +BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib32' +BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libextern_libavformat.a ${BF_FFMPEG_LIBPATH}/libextern_libswscale.a ' + \ + '${BF_FFMPEG_LIBPATH}/libextern_libavcodec.a ${BF_FFMPEG_LIBPATH}/libextern_libavdevice.a ' + \ + '${BF_FFMPEG_LIBPATH}/libextern_libavutil.a ${BF_FFMPEG_LIBPATH}/libextern_xvidcore.a ' + \ + '${BF_FFMPEG_LIBPATH}/libextern_libmp3lame.a ${BF_FFMPEG_LIBPATH}/libextern_x264.a' + +# Don't depend on system's libstdc++ +WITH_BF_STATICCXX = True +BF_CXX_LIB_STATIC = '/usr/lib/gcc/i486-linux-gnu/4.3.2/libstdc++.a' + +WITH_BF_OPENAL = True +WITH_BF_STATICOPENAL = True +BF_OPENAL_LIB_STATIC = '/opt/openal/lib/libopenal.a' + +WITH_BF_GETTEXT_STATIC = True +BF_FREETYPE_LIB_STATIC = True + +WITH_BF_OPENEXR = True +WITH_BF_STATICOPENEXR = True + +WITH_BF_TIFF = True +WITH_BF_STATICTIFF = True +BF_TIFF_LIB_STATIC = '${BF_TIFF}/lib/libtiff.a' + +WITH_BF_JPEG = True +BF_JPEG_LIB = 'libjpeg' +BF_JPEG_LIBPATH = '/home/sources/staticlibs/lib32' + +WITH_BF_PNG = True +BF_PNG_LIB = 'libpng' +BF_PNG_LIBPATH = '/home/sources/staticlibs/lib32' + +WITH_BF_STATICLIBSAMPLERATE = True + +WITH_BF_STATICZLIB = True +BF_ZLIB_LIB_STATIC= '${BF_ZLIB}/lib/libz.a' + +WITH_BF_SDL = True +WITH_BF_OGG = True + +WITH_BF_OPENMP = True + +WITH_BF_GAMEENGINE = True +WITH_BF_BULLET = True + +# Blender player (would be enabled in it's own config) +WITH_BF_PLAYER = False + +# Compilation and optimization +BF_DEBUG = False +REL_CFLAGS = ['-O2'] +REL_CCFLAGS = ['-O2'] +PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib32'] diff --git a/build_files/buildbot/config/user-config-player-i686.py b/build_files/buildbot/config/user-config-player-i686.py new file mode 100644 index 00000000000..cc589a70f8b --- /dev/null +++ b/build_files/buildbot/config/user-config-player-i686.py @@ -0,0 +1,65 @@ +BF_BUILDDIR = '../blender-build/linux-glibc27-i686' +BF_INSTALLDIR = '../blender-install/linux-glibc27-i686' + +# Python configuration +BF_PYTHON_VERSION = '3.2' +BF_PYTHON_ABI_FLAGS = 'mu' +BF_PYTHON = '/opt/python3.2' + +WITH_BF_STATICPYTHON = True + +# OpenCollada configuration +WITH_BF_COLLADA = False + +# FFMPEG configuration +WITH_BF_FFMPEG = False + +# Don't depend on system's libstdc++ +WITH_BF_STATICCXX = True +BF_CXX_LIB_STATIC = '/usr/lib/gcc/i486-linux-gnu/4.3.2/libstdc++.a' + +WITH_BF_OPENAL = True +WITH_BF_STATICOPENAL = True +BF_OPENAL_LIB_STATIC = '/opt/openal/lib/libopenal.a' + +WITH_BF_GETTEXT_STATIC = True +BF_FREETYPE_LIB_STATIC = True + +WITH_BF_OPENEXR = False +WITH_BF_STATICOPENEXR = True + +WITH_BF_TIFF = False +WITH_BF_STATICTIFF = True +BF_TIFF_LIB_STATIC = '${BF_TIFF}/lib/libtiff.a' + +WITH_BF_JPEG = True +BF_JPEG_LIB = 'libjpeg' +BF_JPEG_LIBPATH = '/home/sources/staticlibs/lib32' + +WITH_BF_PNG = True +BF_PNG_LIB = 'libpng' +BF_PNG_LIBPATH = '/home/sources/staticlibs/lib32' + +WITH_BF_STATICLIBSAMPLERATE = True + +WITH_BF_ZLIB = False +BF_ZLIB_LIB_STATIC= '${BF_ZLIB}/lib/libz.a' + +WITH_BF_STATICZLIB = False +WITH_BF_SDL = True +WITH_BF_OGG = False + +WITH_BF_OPENMP = True + +WITH_BF_GAMEENGINE = True +WITH_BF_BULLET = True + +# Do not build blender when building blenderplayer +WITH_BF_NOBLENDER = True +WITH_BF_PLAYER = True + +# Compilation and optimization +BF_DEBUG = False +REL_CFLAGS = ['-O2'] +REL_CCFLAGS = ['-O2'] +PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib32'] diff --git a/build_files/buildbot/config/user-config-player-x86_64.py b/build_files/buildbot/config/user-config-player-x86_64.py new file mode 100644 index 00000000000..40ecc959a37 --- /dev/null +++ b/build_files/buildbot/config/user-config-player-x86_64.py @@ -0,0 +1,65 @@ +BF_BUILDDIR = '../blender-build/linux-glibc27-x86_64' +BF_INSTALLDIR = '../blender-install/linux-glibc27-x86_64' + +# Python configuration +BF_PYTHON_VERSION = '3.2' +BF_PYTHON_ABI_FLAGS = 'mu' +BF_PYTHON = '/opt/python3.2' + +WITH_BF_STATICPYTHON = True + +# OpenCollada configuration +WITH_BF_COLLADA = False + +# FFMPEG configuration +WITH_BF_FFMPEG = False + +# Don't depend on system's libstdc++ +WITH_BF_STATICCXX = True +BF_CXX_LIB_STATIC = '/usr/lib/gcc/x86_64-linux-gnu/4.3.2/libstdc++.a' + +WITH_BF_OPENAL = True +WITH_BF_STATICOPENAL = True +BF_OPENAL_LIB_STATIC = '/opt/openal/lib/libopenal.a' + +WITH_BF_GETTEXT_STATIC = True +BF_FREETYPE_LIB_STATIC = True + +WITH_BF_OPENEXR = False +WITH_BF_STATICOPENEXR = True + +WITH_BF_TIFF = False +WITH_BF_STATICTIFF = True +BF_TIFF_LIB_STATIC = '${BF_TIFF}/lib/libtiff.a' + +WITH_BF_JPEG = True +BF_JPEG_LIB = 'libjpeg' +BF_JPEG_LIBPATH = '/home/sources/staticlibs/lib64' + +WITH_BF_PNG = True +BF_PNG_LIB = 'libpng' +BF_PNG_LIBPATH = '/home/sources/staticlibs/lib64' + +WITH_BF_STATICLIBSAMPLERATE = True + +WITH_BF_ZLIB = False +BF_ZLIB_LIB_STATIC= '${BF_ZLIB}/lib/libz.a' + +WITH_BF_STATICZLIB = False +WITH_BF_SDL = True +WITH_BF_OGG = False + +WITH_BF_OPENMP = True + +WITH_BF_GAMEENGINE = True +WITH_BF_BULLET = True + +# Do not build blender when building blenderplayer +WITH_BF_NOBLENDER = True +WITH_BF_PLAYER = True + +# Compilation and optimization +BF_DEBUG = False +REL_CFLAGS = ['-O2'] +REL_CCFLAGS = ['-O2'] +PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib64'] diff --git a/build_files/buildbot/config/user-config-x86_64.py b/build_files/buildbot/config/user-config-x86_64.py new file mode 100644 index 00000000000..2d62ed25b02 --- /dev/null +++ b/build_files/buildbot/config/user-config-x86_64.py @@ -0,0 +1,85 @@ +BF_BUILDDIR = '../blender-build/linux-glibc27-x86_64' +BF_INSTALLDIR = '../blender-install/linux-glibc27-x86_64' + +# Python configuration +BF_PYTHON_VERSION = '3.2' +BF_PYTHON_ABI_FLAGS = 'mu' +BF_PYTHON = '/opt/python3.2' + +WITH_BF_STATICPYTHON = True + +# OpenCollada configuration +WITH_BF_COLLADA = True +BF_OPENCOLLADA = '/opt/opencollada' +BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include' +BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver buffer ftoa libxml2-static libexpat-static libpcre-static' +BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib /home/sources/staticlibs/lib64' +BF_PCRE_LIB = '' +BF_EXPAT_LIB = '' + +# FFMPEG configuration +WITH_BF_FFMPEG = True +WITH_BF_STATICFFMPEG = True + +# Used for linking against system ffmpeg, but it gives pixelization,, so fall back to ffmpeg from 2.52 temporary +#BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libavutil.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libdc1394.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libraw1394.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libfaad.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libspeex.a ${BF_FFMPEG_LIBPATH}/libbz2.a ${BF_FFMPEG_LIBPATH}/liboil-0.3.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \ +# '${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libgsm.a' + +BF_FFMPEG = '/home/sources/staticlibs/ffmpeg' +BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib64' +BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libextern_libavformat.a ${BF_FFMPEG_LIBPATH}/libextern_libswscale.a ' + \ + '${BF_FFMPEG_LIBPATH}/libextern_libavcodec.a ${BF_FFMPEG_LIBPATH}/libextern_libavdevice.a ' + \ + '${BF_FFMPEG_LIBPATH}/libextern_libavutil.a ${BF_FFMPEG_LIBPATH}/libextern_xvidcore.a ' + \ + '${BF_FFMPEG_LIBPATH}/libextern_libmp3lame.a ${BF_FFMPEG_LIBPATH}/libextern_x264.a' + +# Don't depend on system's libstdc++ +WITH_BF_STATICCXX = True +BF_CXX_LIB_STATIC = '/usr/lib/gcc/x86_64-linux-gnu/4.3.2/libstdc++.a' + +WITH_BF_OPENAL = True +WITH_BF_STATICOPENAL = True +BF_OPENAL_LIB_STATIC = '/opt/openal/lib/libopenal.a' + +WITH_BF_GETTEXT_STATIC = True +BF_FREETYPE_LIB_STATIC = True + +WITH_BF_OPENEXR = True +WITH_BF_STATICOPENEXR = True + +WITH_BF_TIFF = True +WITH_BF_STATICTIFF = True +BF_TIFF_LIB_STATIC = '${BF_TIFF}/lib/libtiff.a' + +WITH_BF_JPEG = True +BF_JPEG_LIB = 'libjpeg' +BF_JPEG_LIBPATH = '/home/sources/staticlibs/lib64' + +WITH_BF_PNG = True +BF_PNG_LIB = 'libpng' +BF_PNG_LIBPATH = '/home/sources/staticlibs/lib64' + +WITH_BF_STATICLIBSAMPLERATE = True + +WITH_BF_STATICZLIB = True +BF_ZLIB_LIB_STATIC= '${BF_ZLIB}/lib/libz.a' + +WITH_BF_SDL = True +WITH_BF_OGG = True + +WITH_BF_OPENMP = True + +WITH_BF_GAMEENGINE = True +WITH_BF_BULLET = True + +# Blender player (would be enabled in it's own config) +WITH_BF_PLAYER = False + +# Compilation and optimization +BF_DEBUG = False +REL_CFLAGS = ['-O2'] +REL_CCFLAGS = ['-O2'] +PLATFORM_LINKFLAGS = ['-L/home/sources/staticlibs/lib64'] diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index f97e53384b0..06c11b368b0 100644 --- a/build_files/buildbot/master_unpack.py +++ b/build_files/buildbot/master_unpack.py @@ -45,7 +45,9 @@ def get_platform(filename): filename = strip_extension(filename) tokens = filename.split("-") - platforms = 'osx', 'mac', 'bsd', 'win', 'linux', 'source', 'irix', 'solaris' + platforms = ('osx', 'mac', 'bsd', + 'win', 'linux', 'source', + 'irix', 'solaris') platform_tokens = [] found = False @@ -90,15 +92,16 @@ packagename = os.path.basename(package) platform = get_platform(packagename) if platform == '': - sys.stderr.write('Failed to detect platform from package: %r\n' % packagename) + sys.stderr.write('Failed to detect platform ' + + 'from package: %r\n' % packagename) sys.exit(1) # extract -dir = 'public_html/download' +directory = 'public_html/download' try: zf = z.open(package) - f = file(os.path.join(dir, packagename), "wb") + f = file(os.path.join(directory, packagename), "wb") shutil.copyfileobj(zf, f) @@ -112,10 +115,10 @@ except Exception, ex: # remove other files from the same platform try: - for f in os.listdir(dir): + for f in os.listdir(directory): if platform.lower() in f.lower(): if f != packagename: - os.remove(os.path.join(dir, f)) + os.remove(os.path.join(directory, f)) except Exception, ex: sys.stderr.write('Failed to remove old packages: %s\n' % str(ex)) sys.exit(1) diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index 54150a93e61..e6dd4840bd6 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -54,7 +54,70 @@ if builder.find('cmake') != -1: else: # scons os.chdir(blender_dir) + scons_cmd = ['python', 'scons/scons.py'] scons_options = [] - retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) - sys.exit(retcode) + if builder.startswith('linux'): + import shutil + + cores = 1 + if hasattr(os, 'sysconf'): + if 'SC_NPROCESSORS_ONLN' in os.sysconf_names: + cores = os.sysconf('SC_NPROCESSORS_ONLN') + + if cores > 1: + # there're two chroot environments in one machine, + # so use only a half of power for better performance + cores = cores / 2 + + # We're using the same rules as release builder, so tweak + # build and install dirs + build_dir = os.path.join('..', 'build', builder) + install_dir = os.path.join('..', 'install', builder) + + common_options = ['BF_NUMJOBS=' + str(cores), + 'BF_BUILDDIR=' + build_dir, + 'BF_INSTALLDIR=' + install_dir] + + # Clean all directories first + retcode = subprocess.call(scons_cmd + common_options + ['clean']) + if retcode != 0: + print('Error cleaning build directory') + sys.exit(retcode) + + if os.path.isdir(install_dir): + shutil.rmtree(install_dir) + + buildbot_dir = os.path.dirname(os.path.realpath(__file__)) + config_dir = os.path.join(buildbot_dir, 'config') + + configs = [] + if builder == 'linux_x86_64_scons': + configs = ['user-config-player-x86_64.py', + 'user-config-x86_64.py'] + elif builder == 'linux_i386_scons': + configs = ['user-config-player-i686.py', + 'user-config-i686.py'] + + for config in configs: + config_fpath = os.path.join(config_dir, config) + + scons_options = [] + scons_options += common_options + + if config.find('player') == -1: + scons_options.append('blender') + else: + scons_options.append('blenderplayer') + + scons_options.append('BF_CONFIG=' + config_fpath) + + retcode = subprocess.call(scons_cmd + scons_options) + if retcode != 0: + print('Error building rules wuth config ' + config) + sys.exit(retcode) + + sys.exit(0) + else: + retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) + sys.exit(retcode) diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py index 74d00bf9249..81402b3aca4 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -37,8 +37,39 @@ builder = sys.argv[1] # scons does own packaging if builder.find('scons') != -1: os.chdir('../blender') - retcode = subprocess.call(['python', 'scons/scons.py', 'BF_QUICK=slnt', 'buildslave']) - sys.exit(retcode) + scons_options = ['BF_QUICK=slnt', 'buildslave'] + + if builder.startswith('linux'): + buildbot_dir = os.path.dirname(os.path.realpath(__file__)) + config_dir = os.path.join(buildbot_dir, 'config') + build_dir = os.path.join('..', 'build', builder) + install_dir = os.path.join('..', 'install', builder) + + scons_options += ['WITH_BF_NOBLENDER=True', 'WITH_BF_PLAYER=False', + 'BF_BUILDDIR=' + build_dir, + 'BF_INSTALLDIR=' + install_dir, + 'WITHOUT_BF_INSTALL=True'] + + config = None + + if builder == 'linux_x86_64_scons': + config = 'user-config-x86_64.py' + elif builder == 'linux_i386_scons': + config = 'user-config-x86_64.py' + + if config is not None: + config_fpath = os.path.join(config_dir, config) + scons_options.append('BF_CONFIG=' + config_fpath) + + blender = os.path.join(install_dir, 'blender') + blenderplayer = os.path.join(install_dir, 'blenderplayer') + subprocess.call(['strip', '--strip-all', blender, blenderplayer]) + + retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) + sys.exit(retcode) + else: + retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) + sys.exit(retcode) # clean release directory if it already exists dir = 'release' diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index 1bad1835434..601cf865ab4 100644 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -114,7 +114,6 @@ def cmake_advanced_info(): """ def create_eclipse_project(CMAKE_DIR): - import sys if sys.platform == "win32": cmd = 'cmake %r -G"Eclipse CDT4 - MinGW Makefiles"' % CMAKE_DIR else: @@ -125,7 +124,7 @@ def cmake_advanced_info(): includes = [] defines = [] - import os + create_eclipse_project(CMAKE_DIR) diff --git a/build_files/cmake/example_scripts/make_quicky.py b/build_files/cmake/example_scripts/make_quicky.py index d7c43f4b86e..a4e0d3371f1 100755 --- a/build_files/cmake/example_scripts/make_quicky.py +++ b/build_files/cmake/example_scripts/make_quicky.py @@ -43,8 +43,8 @@ def main(): targets = set() # collect targets - file = open("Makefile", "r") - for line in file: + makefile = open("Makefile", "r") + for line in makefile: line = line.rstrip() if not line or line[0] in ". \t@$#": continue @@ -59,7 +59,7 @@ def main(): continue targets.add(line) - file.close() + makefile.close() # remove cmake targets bad = set([ diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 073147266bb..24dc058c4b0 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -265,7 +265,7 @@ endmacro() # needs to be removed for some external libs which we dont maintain. # utility macro -macro(_remove_strict_flags +macro(remove_flag flag) string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") @@ -285,12 +285,12 @@ endmacro() macro(remove_strict_flags) if(CMAKE_COMPILER_IS_GNUCC) - _remove_strict_flags("-Wstrict-prototypes") - _remove_strict_flags("-Wunused-parameter") - _remove_strict_flags("-Wwrite-strings") - _remove_strict_flags("-Wshadow") - _remove_strict_flags("-Werror=[^ ]+") - _remove_strict_flags("-Werror") + remove_flag("-Wstrict-prototypes") + remove_flag("-Wunused-parameter") + remove_flag("-Wwrite-strings") + remove_flag("-Wshadow") + remove_flag("-Werror=[^ ]+") + remove_flag("-Werror") endif() if(MSVC) @@ -350,7 +350,12 @@ macro(get_blender_version) message(FATAL_ERROR "Version parsing failed for BLENDER_SUBVERSION") endif() - if(NOT ${_out_version_char} MATCHES "[a-z]+") + # clumsy regex, only single char are ok but it could be unset + + string(LENGTH "${_out_version_char}" _out_version_char_len) + if(NOT _out_version_char_len EQUAL 1) + set(_out_version_char "") + elseif(NOT ${_out_version_char} MATCHES "[a-z]+") message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION_CHAR") endif() diff --git a/build_files/package_spec/debian/control b/build_files/package_spec/debian/control index 7329a552dbc..be703e05071 100644 --- a/build_files/package_spec/debian/control +++ b/build_files/package_spec/debian/control @@ -2,10 +2,10 @@ Source: blender Section: graphics Priority: extra Maintainer: Dan Eicher -Build-Depends: debhelper (>= 7.0.50~), cmake, python3, python, libfreetype6-dev, libglu1-mesa-dev, libilmbase-dev, libopenexr-dev, libjpeg62-dev, libopenal-dev, libpng12-dev, libsamplerate0-dev, libsdl-dev, libtiff4-dev, libx11-dev, libxi-dev, zlib1g-dev, python3.1-dev, libopenjpeg-dev +Build-Depends: debhelper (>= 7.0.50~), cmake, python3, python, libfreetype6-dev, libglu1-mesa-dev, libilmbase-dev, libopenexr-dev, libjpeg62-dev, libopenal-dev, libpng12-dev, libsamplerate0-dev, libsdl-dev, libtiff4-dev, libx11-dev, libxi-dev, zlib1g-dev, python3.2-dev, libopenjpeg-dev Standards-Version: 3.9.1 Homepage: http://blender.org/ -X-Python3-Version: >= 3.1, << 3.2 +X-Python3-Version: >= 3.2, << 3.3 Package: blender-snapshot Architecture: any diff --git a/build_files/package_spec/debian/rules b/build_files/package_spec/debian/rules index 14cc9e02ae4..7a3d2d52adc 100755 --- a/build_files/package_spec/debian/rules +++ b/build_files/package_spec/debian/rules @@ -19,6 +19,9 @@ override_dh_auto_configure: -DWITH_PYTHON_INSTALL:BOOL=OFF \ -DWITH_OPENCOLLADA:BOOL=OFF +override_dh_auto_test: + # don't run CTest + override_dh_install: dh_install @@ -26,7 +29,7 @@ override_dh_install: rm -rf debian/blender-snapshot/usr/share/doc/blender override_dh_python3: - dh_python3 -V 3.1-3.2 /usr/share/blender/$(REL)/scripts + dh_python3 -V 3.2-3.3 /usr/share/blender/$(REL)/scripts get-orig-source: rm -rf get-orig-source $(TARBALL) diff --git a/build_files/package_spec/pacman/PKGBUILD b/build_files/package_spec/pacman/PKGBUILD index 988e246f0cc..0c4164b1242 100644 --- a/build_files/package_spec/pacman/PKGBUILD +++ b/build_files/package_spec/pacman/PKGBUILD @@ -3,11 +3,11 @@ # custom blender vars blender_srcdir=$(dirname $startdir)"/../.." # value may be formatted: 35042:35051M -blender_revision=$(svnversion $blender_srcdir | cut -d: -f2 | tr -dc 0-9) -blender_version=$(grep BLENDER_VERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9) +blender_revision=$(svnversion $blender_srcdir | cut -d: -f2 | awk '{print $3}') +blender_version=$(grep BLENDER_VERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}') blender_version=$(expr $blender_version / 100).$(expr $blender_version % 100) # 256 -> 2.56 blender_version_char=$(sed -ne 's/.*BLENDER_VERSION_CHAR.*\([a-z]\)$/\1/p' $blender_srcdir/source/blender/blenkernel/BKE_blender.h) -# blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9) +# blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}') # map the version a -> 1 # not to be confused with blender's internal subversions @@ -25,7 +25,7 @@ arch=('i686' 'x86_64') url="www.blender.org" license=('GPL') groups=() -depends=('libjpeg' 'libpng' 'openjpeg' 'libtiff' 'openexr' 'python>=3.1' 'gettext' 'libxi' 'libxmu' 'mesa' 'freetype2' 'openal' 'sdl' 'libsndfile' 'libsamplerate' 'ffmpeg') +depends=('libjpeg' 'libpng' 'openjpeg' 'libtiff' 'openexr' 'python>=3.2' 'gettext' 'libxi' 'libxmu' 'mesa' 'freetype2' 'openal' 'sdl' 'libsndfile' 'libsamplerate' 'ffmpeg') makedepends=('cmake' 'svn') optdepends=() provides=() diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 1d276d77466..ad4df1a60c1 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -489,7 +489,7 @@ def AppIt(target=None, source=None, env=None): shutil.rmtree(cmd) shutil.copytree(sourcedir, cmd) cmd = "cat %s | sed s/\$\{MACOSX_BUNDLE_SHORT_VERSION_STRING\}/%s/ | "%(sourceinfo,VERSION) - cmd += "sed s/\$\{MACOSX_BUNDLE_LONG_VERSION_STRING\}/%s,\ `date +'%%Y-%%b-%%d'`/ > %s"%(VERSION,targetinfo) + cmd += "sed s/\$\{MACOSX_BUNDLE_LONG_VERSION_STRING\}/%s,\ %s/g > %s"%(VERSION,time.strftime("%Y-%b-%d"),targetinfo) commands.getoutput(cmd) cmd = 'cp %s/%s %s/%s.app/Contents/MacOS/%s'%(builddir, binary,installdir, binary, binary) commands.getoutput(cmd) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 17ee80e6dbd..a646b9084c2 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -530,6 +530,8 @@ def buildbot_zip(src, dest, package_name, extension): print("writing %s to %s" % (dest, bb_zip_name)) bb_zip.write(dest, os.path.split(dest)[1]) bb_zip.close() + print("removing unneeded packed file %s (to keep install directory clean)" % (dest)) + os.remove(dest) print("done.") def buildslave_print(target, source, env): @@ -545,8 +547,18 @@ def buildslave(target=None, source=None, env=None): else: extension = '.tar.bz2' + platform = env['OURPLATFORM'].split('-')[0] + if platform == 'linux2': + import platform + + bitness = platform.architecture()[0] + if bitness == '64bit': + platform = 'linux-glibc27-x86_64' + elif bitness == '32bit': + platform = 'linux-glibc27-i686' + outdir = os.path.abspath(env['BF_INSTALLDIR']) - package_name = 'blender-' + VERSION+'-'+REVISION + '-' + env['OURPLATFORM'].split('-')[0] + package_name = 'blender-' + VERSION+'-'+REVISION + '-' + platform package_dir = os.path.normpath(outdir + os.sep + '..' + os.sep + package_name) package_archive = os.path.normpath(outdir + os.sep + '..' + os.sep + package_name + extension) @@ -611,7 +623,7 @@ def NSIS_Installer(target=None, source=None, env=None): #### change to suit install dir #### inst_dir = install_base_dir + env['BF_INSTALLDIR'] - os.chdir("windows/installer") + os.chdir(rel_dir) ns = open("00.sconsblender.nsi","r") diff --git a/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py b/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py new file mode 100644 index 00000000000..c1cae149495 --- /dev/null +++ b/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py @@ -0,0 +1,31 @@ +""" +Keying Nested Properties +++++++++++++++++++++++++ + +Note that when keying data paths which contain nested properties this must be +done from the :class:`ID` subclass, in this case the :class:`Armature` rather +then the bone. +""" + +import bpy +from bpy.props import PointerProperty + + +# define a nested property +class MyPropGroup(bpy.types.PropertyGroup): + nested = bpy.props.FloatProperty(name="Nested", default=0.0) + +# register it so its available for all bones +bpy.utils.register_class(MyPropGroup) +bpy.types.Bone.my_prop = PointerProperty(type=MyPropGroup, + name="MyProp") + +# get a bone +obj = bpy.data.objects["Armature"] +arm = obj.data + +# set the keyframe at frame 1 +arm.bones["Bone"].my_prop_group.nested = 10 +arm.keyframe_insert(data_path='bones["Bone"].my_prop.nested', + frame=1, + group="Nested Group") diff --git a/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.py b/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.py new file mode 100644 index 00000000000..91c1b6f8178 --- /dev/null +++ b/doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.py @@ -0,0 +1,14 @@ +""" +Basic Keyframing +++++++++++++++++ + +This is the most simple example of inserting a keyframe from python. +""" + +import bpy + +obj = bpy.context.object + +# set the keyframe at frame 1 +obj.location = 3.0, 4.0, 10.0 +obj.keyframe_insert(data_path="location", frame=1) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 4ed7ae36e86..46b305bb39b 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -27,7 +27,7 @@ For HTML generation ------------------- - Run this script from blenders root path once you have compiled blender - ./blender.bin -b -P doc/python_api/sphinx_doc_gen.py + ./blender.bin --background --python doc/python_api/sphinx_doc_gen.py This will generate python files in doc/python_api/sphinx-in/, assuming that ./blender.bin is or links to the blender executable @@ -75,7 +75,7 @@ else: "Freestyle", ) - FILTER_BPY_TYPES = ("PropertyGroup", "Panel", "Menu", "Operator", "RenderEngine") # allow + FILTER_BPY_TYPES = ("bpy_struct", "Panel", "Menu", "Operator", "RenderEngine") # allow FILTER_BPY_OPS = ("import.scene", ) # allow # for quick rebuilds @@ -274,7 +274,7 @@ def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier): else: raise TypeError("type was not GetSetDescriptorType, MethodDescriptorType or ClassMethodDescriptorType") - write_example_ref(ident, fw, module_name + "." + type_name + "." + identifier) + write_example_ref(ident + " ", fw, module_name + "." + type_name + "." + identifier) fw("\n") @@ -469,6 +469,7 @@ def pycontext2sphinx(BASEPATH): "edit_text": ("Text", False), "editable_bones": ("EditBone", True), "fluid": ("FluidSimulationModifier", False), + "image_paint_object": ("Object", False), "lamp": ("Lamp", False), "lattice": ("Lattice", False), "material": ("Material", False), @@ -498,7 +499,6 @@ def pycontext2sphinx(BASEPATH): "smoke": ("SmokeModifier", False), "soft_body": ("SoftBodyModifier", False), "texture": ("Texture", False), - "texture_paint_object": ("Object", False), "texture_slot": ("MaterialTextureSlot", False), "vertex_paint_object": ("Object", False), "visible_bases": ("ObjectBase", True), diff --git a/doc/python_api/sphinx_doc_gen.sh b/doc/python_api/sphinx_doc_gen.sh index c027db83831..052e8072ac8 100755 --- a/doc/python_api/sphinx_doc_gen.sh +++ b/doc/python_api/sphinx_doc_gen.sh @@ -12,9 +12,17 @@ SSH_UPLOAD="/data/www/vhosts/www.blender.org/documentation" # blender_python_api # "_".join(str(v) for v in bpy.app.version) # custom blender vars blender_srcdir=$(dirname $0)/../../ -blender_version=$(grep BLENDER_VERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9) -blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | tr -dc 0-9) -BLENDER_VERSION=$(expr $blender_version / 100)_$(expr $blender_version % 100)_$blender_subversion +blender_version=$(grep "BLENDER_VERSION\s" $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}') +blender_version_char=$(grep BLENDER_VERSION_CHAR $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}') +blender_version_cycle=$(grep BLENDER_VERSION_CYCLE $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}') +blender_subversion=$(grep BLENDER_SUBVERSION $blender_srcdir/source/blender/blenkernel/BKE_blender.h | awk '{print $3}') + +if [ "$blender_version_cycle" == "release" ] +then + BLENDER_VERSION=$(expr $blender_version / 100)_$(expr $blender_version % 100)$blender_version_char"_release" +else + BLENDER_VERSION=$(expr $blender_version / 100)_$(expr $blender_version % 100)_$blender_subversion +fi SSH_UPLOAD_FULL=$SSH_UPLOAD/"blender_python_api_"$BLENDER_VERSION diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp index 1a561957368..8af16b9cf6f 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp @@ -254,20 +254,21 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& inpu } #endif // - m_cachedSeparatingAxis = newCachedSeparatingAxis; //redundant m_simplexSolver->compute_points(pointOnA, pointOnB); //are we getting any closer ? if (previousSquaredDistance - squaredDistance <= SIMD_EPSILON * previousSquaredDistance) { - m_simplexSolver->backup_closest(m_cachedSeparatingAxis); +// m_simplexSolver->backup_closest(m_cachedSeparatingAxis); checkSimplex = true; m_degenerateSimplex = 12; break; } + m_cachedSeparatingAxis = newCachedSeparatingAxis; + //degeneracy, this is typically due to invalid/uninitialized worldtransforms for a btCollisionObject if (m_curIter++ > gGjkMaxIter) { @@ -294,7 +295,7 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& inpu if (!check) { //do we need this backup_closest here ? - m_simplexSolver->backup_closest(m_cachedSeparatingAxis); +// m_simplexSolver->backup_closest(m_cachedSeparatingAxis); m_degenerateSimplex = 13; break; } @@ -303,7 +304,7 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& inpu if (checkSimplex) { m_simplexSolver->compute_points(pointOnA, pointOnB); - normalInB = pointOnA-pointOnB; + normalInB = m_cachedSeparatingAxis; btScalar lenSqr =m_cachedSeparatingAxis.length2(); //valid normal diff --git a/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp b/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp index 345dca6a11c..5b467883d84 100644 --- a/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp +++ b/extern/bullet2/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp @@ -698,7 +698,7 @@ void btRaycastVehicle::updateFriction(btScalar timeStep) btVector3 sideImp = m_axle[wheel] * m_sideImpulse[wheel]; #if defined ROLLING_INFLUENCE_FIX // fix. It only worked if car's up was along Y - VT. - btVector3 vChassisWorldUp = getRigidBody()->getCenterOfMassTransform().getBasis().getColumn(1); + btVector3 vChassisWorldUp = getRigidBody()->getCenterOfMassTransform().getBasis().getColumn(m_indexUpAxis); rel_pos -= vChassisWorldUp * (vChassisWorldUp.dot(rel_pos) * (1.f-wheelInfo.m_rollInfluence)); #else rel_pos[m_indexUpAxis] *= wheelInfo.m_rollInfluence; diff --git a/intern/ghost/GHOST_IEvent.h b/intern/ghost/GHOST_IEvent.h index 4c8c4d4a392..bb13179fbfe 100644 --- a/intern/ghost/GHOST_IEvent.h +++ b/intern/ghost/GHOST_IEvent.h @@ -34,6 +34,7 @@ #ifndef _GHOST_IEVENT_H_ #define _GHOST_IEVENT_H_ +#include #include "GHOST_Types.h" class GHOST_IWindow; diff --git a/intern/memutil/MEM_Allocator.h b/intern/memutil/MEM_Allocator.h index 9e9ce47c84f..14d62a2434d 100644 --- a/intern/memutil/MEM_Allocator.h +++ b/intern/memutil/MEM_Allocator.h @@ -29,6 +29,7 @@ #ifndef MEM_ALLOCATOR_H #define MEM_ALLOCATOR_H +#include #include "guardedalloc/MEM_guardedalloc.h" #include "guardedalloc/MEM_sys_types.h" diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c index 8ccb19e35e6..c05ada84773 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*M_PI)/180); + const float fThresCos = (const float) cos((fAngularThreshold*(float)M_PI)/180.0f); // verify all call-backs have been set if( pContext->m_pInterface->m_getNumFaces==NULL || @@ -645,7 +645,7 @@ void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], const SMikk int iL=iL_in, iR=iR_in; assert((iR_in-iL_in)>0); // at least 2 entries - // seperate (by fSep) all points between iL_in and iR_in in pTmpVert[] + // separate (by fSep) all points between iL_in and iR_in in pTmpVert[] while(iL < iR) { tbool bReadyLeftSwap = TFALSE, bReadyRightSwap = TFALSE; diff --git a/intern/opennl/CMakeLists.txt b/intern/opennl/CMakeLists.txt index 7fbbfa633ce..699d2dec795 100644 --- a/intern/opennl/CMakeLists.txt +++ b/intern/opennl/CMakeLists.txt @@ -27,6 +27,10 @@ # External project, better not fix warnings. remove_strict_flags() +# remove debug flag here since this is not a blender maintained library +# and debug gives a lot of prints on UV unwrapping. developers can enable if they need to. +remove_flag("-DDEBUG") + set(INC extern superlu diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 62a9f691acf..3877f711b7f 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -107,7 +107,7 @@ def modules(module_cache): import traceback traceback.print_exc() raise - + return mod else: return None @@ -246,7 +246,6 @@ def disable(module_name, default_set=True): :type module_name: string """ import sys - import traceback import bpy_types as _bpy_types mod = sys.modules.get(module_name) @@ -259,6 +258,7 @@ def disable(module_name, default_set=True): try: mod.unregister() except: + import traceback traceback.print_exc() else: print("addon_utils.disable", module_name, "not loaded") diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index a8f5925f467..b7c52a35fdf 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -195,7 +195,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): for mod in modules_from_path(path, loaded_modules): test_register(mod) - # deal with addons seperately + # deal with addons separately _addon_utils.reset_all(reload_scripts) # run the active integration preset @@ -347,7 +347,6 @@ def keyconfig_set(filepath): print("loading preset:", filepath) keyconfigs = _bpy.context.window_manager.keyconfigs - kc_orig = keyconfigs.active keyconfigs_old = keyconfigs[:] diff --git a/release/scripts/modules/bpyml_ui.py b/release/scripts/modules/bpyml_ui.py index 2462dd60e3e..1e0522974d1 100644 --- a/release/scripts/modules/bpyml_ui.py +++ b/release/scripts/modules/bpyml_ui.py @@ -65,7 +65,7 @@ def _parse_rna_args(base, py_node): def _call_recursive(context, base, py_node): - prop = base.bl_rna.properties.get(py_node[TAG]) + # prop = base.bl_rna.properties.get(py_node[TAG]) if py_node[TAG] in base.bl_rna.properties: value = py_node[ARGS].get("expr") if value: @@ -73,7 +73,7 @@ def _call_recursive(context, base, py_node): setattr(base, py_node[TAG], value) else: value = py_node[ARGS]['value'] # have to have this - setattr(base, name, value) + setattr(base, py_node[TAG], value) else: args = _parse_rna_args(base, py_node) func_new = getattr(base, py_node[TAG]) diff --git a/release/scripts/modules/mesh_utils.py b/release/scripts/modules/mesh_utils.py index f65aa8b306f..5bacff7b0cc 100644 --- a/release/scripts/modules/mesh_utils.py +++ b/release/scripts/modules/mesh_utils.py @@ -19,7 +19,7 @@ # -def mesh_linked_faces(me): +def mesh_linked_faces(mesh): ''' Splits the mesh into connected parts, these parts are returned as lists of faces. diff --git a/release/scripts/presets/interaction/maya.py b/release/scripts/presets/interaction/maya.py index 4b4bb3c4f0a..ec7ecaf4639 100644 --- a/release/scripts/presets/interaction/maya.py +++ b/release/scripts/presets/interaction/maya.py @@ -7,4 +7,4 @@ bpy.context.user_preferences.inputs.select_mouse = 'LEFT' bpy.context.user_preferences.inputs.view_zoom_method = 'DOLLY' bpy.context.user_preferences.inputs.view_zoom_axis = 'HORIZONTAL' bpy.context.user_preferences.inputs.view_rotate_method = 'TURNTABLE' -bpy.context.user_preferences.inputs.invert_mouse_wheel_zoom = True \ No newline at end of file +bpy.context.user_preferences.inputs.invert_mouse_wheel_zoom = True diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py index 2a42cfbacb8..d5f7a63366a 100644 --- a/release/scripts/startup/bl_operators/__init__.py +++ b/release/scripts/startup/bl_operators/__init__.py @@ -31,6 +31,7 @@ _modules = ( "object_align", "object", "object_randomize_transform", + "object_quick_effects", "presets", "screen_play_rendered_anim", "sequencer", diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 82e631e31d2..462db3a2c5e 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -60,12 +60,18 @@ class EditExternally(bpy.types.Operator): filepath = bpy.path.abspath(self.filepath) if not os.path.exists(filepath): - self.report('ERROR', "Image path %r not found." % filepath) + self.report({'ERROR'}, "Image path %r not found." % filepath) return {'CANCELLED'} cmd = self._editor_guess(context) + [filepath] - subprocess.Popen(cmd) + try: + subprocess.Popen(cmd) + except: + import traceback + traceback.print_exc() + self.report({'ERROR'}, "Image editor not found, please specify in User Preferences > File") + return {'CANCELLED'} return {'FINISHED'} @@ -73,6 +79,8 @@ class EditExternally(bpy.types.Operator): try: filepath = context.space_data.image.filepath except: + import traceback + traceback.print_exc() self.report({'ERROR'}, "Image not found on disk") return {'CANCELLED'} @@ -104,7 +112,7 @@ class SaveDirty(bpy.types.Operator): class ProjectEdit(bpy.types.Operator): - """Edit a snapshot if the viewport in an external image editor""" + """Edit a snapshot of the viewport in an external image editor""" bl_idname = "image.project_edit" bl_label = "Project Edit" bl_options = {'REGISTER'} @@ -163,7 +171,10 @@ class ProjectEdit(bpy.types.Operator): image_new.file_format = 'PNG' image_new.save() - bpy.ops.image.external_edit(filepath=filepath_final) + try: + bpy.ops.image.external_edit(filepath=filepath_final) + except RuntimeError as re: + self.report({'ERROR'}, str(re)) return {'FINISHED'} @@ -180,6 +191,8 @@ class ProjectApply(bpy.types.Operator): try: image = bpy.data.images[image_name] except KeyError: + import traceback + traceback.print_exc() self.report({'ERROR'}, "Could not find image '%s'" % image_name) return {'CANCELLED'} diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py new file mode 100644 index 00000000000..b50bb2dc3cc --- /dev/null +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -0,0 +1,291 @@ +# ##### 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 ##### + +# + +from mathutils import Vector +import bpy +from bpy.props import BoolProperty, EnumProperty, IntProperty, FloatProperty, FloatVectorProperty + + +class MakeFur(bpy.types.Operator): + bl_idname = "object.make_fur" + bl_label = "Make Fur" + bl_options = {'REGISTER', 'UNDO'} + + density = EnumProperty(items=( + ('LIGHT', "Light", ""), + ('MEDIUM', "Medium", ""), + ('HEAVY', "Heavy", "")), + name="Fur Density", + description="", + default='MEDIUM') + + view_percentage = IntProperty(name="View %", + default=10, min=1, max=100, soft_min=1, soft_max=100) + + length = FloatProperty(name="Length", + default=0.1, min=0.001, max=100, soft_min=0.01, soft_max=10) + + def execute(self, context): + fake_context = bpy.context.copy() + 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.") + return {'CANCELLED'} + + mat = bpy.data.materials.new("Fur Material") + mat.strand.tip_size = 0.25 + mat.strand.blend_distance = 0.5 + + for obj in mesh_objects: + fake_context["active_object"] = obj + bpy.ops.object.particle_system_add(fake_context) + + psys = obj.particle_systems[-1] + psys.settings.type = 'HAIR' + + if self.density == 'LIGHT': + psys.settings.count = 100 + elif self.density == 'MEDIUM': + psys.settings.count = 1000 + elif self.density == 'HEAVY': + psys.settings.count = 10000 + + psys.settings.child_nbr = self.view_percentage + psys.settings.hair_length = self.length + psys.settings.use_strand_primitive = True + psys.settings.use_hair_bspline = True + psys.settings.child_type = 'INTERPOLATED' + + obj.data.materials.append(mat) + obj.particle_systems[-1].settings.material = len(obj.data.materials) + + return {'FINISHED'} + + +def obj_bb_minmax(obj, min_co, max_co): + for i in range(0, 8): + bb_vec = Vector((obj.bound_box[i][0], obj.bound_box[i][1], obj.bound_box[i][2])) * obj.matrix_world + + min_co[0] = min(bb_vec[0], min_co[0]) + min_co[1] = min(bb_vec[1], min_co[1]) + min_co[2] = min(bb_vec[2], min_co[2]) + max_co[0] = max(bb_vec[0], max_co[0]) + max_co[1] = max(bb_vec[1], max_co[1]) + max_co[2] = max(bb_vec[2], max_co[2]) + + +class MakeSmoke(bpy.types.Operator): + bl_idname = "object.make_smoke" + bl_label = "Make 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) + + def execute(self, context): + mesh_objects = [obj for obj in context.selected_objects if obj.type == 'MESH'] + min_co = Vector((100000, 100000, 100000)) + max_co = Vector((-100000, -100000, -100000)) + + if not mesh_objects: + self.report({'ERROR'}, "Select at least one mesh object.") + return {'CANCELLED'} + + for obj in mesh_objects: + # make each selected object a smoke flow + bpy.ops.object.modifier_add({"object": obj}, type='SMOKE') + obj.modifiers[-1].smoke_type = 'FLOW' + + psys = obj.particle_systems[-1] + if self.style == 'PUFF': + psys.settings.frame_end = psys.settings.frame_start + psys.settings.emit_from = 'VOLUME' + psys.settings.distribution = 'RAND' + elif self.style == 'FIRE': + psys.settings.effector_weights.gravity = -1 + psys.settings.lifetime = 5 + psys.settings.count = 100000 + + obj.modifiers[-2].flow_settings.initial_velocity = True + obj.modifiers[-2].flow_settings.temperature = 2 + + psys.settings.use_render_emitter = self.show_flows + if not self.show_flows: + obj.draw_type = 'WIRE' + + # store bounding box min/max for the domain object + obj_bb_minmax(obj, min_co, max_co) + + # add the smoke domain object + bpy.ops.mesh.primitive_cube_add() + obj = context.active_object + obj.name = "Smoke Domain" + + # give the smoke some room above the flows + obj.location = 0.5 * (max_co + min_co) + Vector((0.0, 0.0, 1.0)) + obj.scale = 0.5 * (max_co - min_co) + Vector((1.0, 1.0, 2.0)) + + # setup smoke domain + bpy.ops.object.modifier_add({"object": obj}, type='SMOKE') + obj.modifiers[-1].smoke_type = 'DOMAIN' + if self.style == 'FIRE': + obj.modifiers[-1].domain_settings.use_dissolve_smoke = True + obj.modifiers[-1].domain_settings.dissolve_speed = 20 + obj.modifiers[-1].domain_settings.use_high_resolution = True + + # create a volume material with a voxel data texture for the domain + bpy.ops.object.material_slot_add({"object": obj}) + + mat = obj.material_slots[0].material + mat.name = "Smoke Domain Material" + mat.type = 'VOLUME' + 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 + + # 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 + + ramp = mat.texture_slots[1].texture.color_ramp + + elem = ramp.elements.new(0.333) + elem.color[0] = elem.color[3] = 1 + elem.color[1] = elem.color[2] = 0 + + elem = ramp.elements.new(0.666) + elem.color[0] = elem.color[1] = elem.color[3] = 1 + elem.color[2] = 0 + + mat.texture_slots[1].use_map_emission = True + mat.texture_slots[1].blend_type = 'MULTIPLY' + + return {'FINISHED'} + + +class MakeFluid(bpy.types.Operator): + bl_idname = "object.make_fluid" + bl_label = "Make Fluid" + bl_options = {'REGISTER', 'UNDO'} + + 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) + + def execute(self, context): + mesh_objects = [obj for obj in context.selected_objects if (obj.type == 'MESH' and not 0 in obj.dimensions)] + min_co = Vector((100000, 100000, 100000)) + max_co = Vector((-100000, -100000, -100000)) + + if not mesh_objects: + self.report({'ERROR'}, "Select at least one mesh object.") + return {'CANCELLED'} + + for obj in mesh_objects: + # make each selected object a fluid + bpy.ops.object.modifier_add({"object": obj}, type='FLUID_SIMULATION') + + # 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 + + if self.style == 'INFLOW': + mod.settings.type = 'INFLOW' + mod.settings.inflow_velocity = self.initial_velocity.copy() + else: + mod.settings.type = 'FLUID' + mod.settings.initial_velocity = self.initial_velocity.copy() + + obj.hide_render = not self.show_flows + if not self.show_flows: + obj.draw_type = 'WIRE' + + # store bounding box min/max for the domain object + obj_bb_minmax(obj, min_co, max_co) + + # add the fluid domain object + bpy.ops.mesh.primitive_cube_add() + obj = context.active_object + obj.name = "Fluid Domain" + + # 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]))) + + # setup smoke domain + bpy.ops.object.modifier_add({"object": obj}, type='FLUID_SIMULATION') + obj.modifiers[-1].settings.type = 'DOMAIN' + + # make the domain smooth so it renders nicely + bpy.ops.object.shade_smooth() + + # create a ray-transparent material for the domain + bpy.ops.object.material_slot_add({"object": obj}) + + mat = obj.material_slots[0].material + mat.name = "Fluid Domain Material" + mat.specular_intensity = 1 + mat.specular_hardness = 100 + mat.use_transparency = True + mat.alpha = 0.0 + mat.transparency_method = 'RAYTRACE' + mat.raytrace_transparency.ior = 1.33 + mat.raytrace_transparency.depth = 4 + + if self.start_baking: + bpy.ops.fluid.bake() + + return {'FINISHED'} diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index d72c600ef78..9dc5086086f 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -84,7 +84,7 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even): uniform(0.0, 0.0), uniform(0.0, 0.0), uniform(0.0, 0.0) -from bpy.props import IntProperty, BoolProperty, FloatProperty, FloatVectorProperty +from bpy.props import IntProperty, BoolProperty, FloatVectorProperty class RandomizeLocRotSize(bpy.types.Operator): diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index e6f71ef9573..1cef67dc710 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -19,7 +19,6 @@ # import bpy -import os class AddPresetBase(): diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 6ed46191099..e6018c185a0 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -74,20 +74,20 @@ def execute_context_assign(self, context): return {'FINISHED'} -class BRUSH_OT_set_active_number(bpy.types.Operator): +class BRUSH_OT_active_index_set(bpy.types.Operator): '''Set active sculpt/paint brush from it's number''' - bl_idname = "brush.set_active_number" + bl_idname = "brush.active_index_set" bl_label = "Set Brush Number" mode = StringProperty(name="mode", description="Paint mode to set brush for", maxlen=1024) - number = IntProperty(name="number", + index = IntProperty(name="number", description="Brush number") _attr_dict = {"sculpt": "use_paint_sculpt", "vertex_paint": "use_paint_vertex", "weight_paint": "use_paint_weight", - "image_paint": "use_paint_texture"} + "image_paint": "use_paint_image"} def execute(self, context): attr = self._attr_dict.get(self.mode) @@ -95,7 +95,7 @@ class BRUSH_OT_set_active_number(bpy.types.Operator): return {'CANCELLED'} for i, brush in enumerate((cur for cur in bpy.data.brushes if getattr(cur, attr))): - if i == self.number: + if i == self.index: getattr(context.tool_settings, self.mode).brush = brush return {'FINISHED'} @@ -596,7 +596,10 @@ class WM_OT_doc_view(bpy.types.Operator): bl_label = "View Documentation" doc_id = doc_id - _prefix = "http://www.blender.org/documentation/blender_python_api_%s" % "_".join(str(v) for v in bpy.app.version) + if bpy.app.version_cycle == "release": + _prefix = "http://www.blender.org/documentation/blender_python_api_%s%s_release" % ("_".join(str(v) for v in bpy.app.version[:2]), bpy.app.version_char) + else: + _prefix = "http://www.blender.org/documentation/blender_python_api_%s" % "_".join(str(v) for v in bpy.app.version) def _nested_class_string(self, class_string): ls = [] @@ -859,6 +862,7 @@ class WM_OT_keyconfig_activate(bpy.types.Operator): bpy.utils.keyconfig_set(self.filepath) return {'FINISHED'} + class WM_OT_appconfig_default(bpy.types.Operator): bl_idname = "wm.appconfig_default" bl_label = "Default Application Configuration" @@ -868,13 +872,14 @@ class WM_OT_appconfig_default(bpy.types.Operator): context.window_manager.keyconfigs.active = context.window_manager.keyconfigs.default - filepath = os.path.join(bpy.utils.preset_paths("interaction")[0], "blender.py") - + filepath = os.path.join(bpy.utils.preset_paths("interaction")[0], "blender.py") + if os.path.exists(filepath): - bpy.ops.script.execute_preset(filepath = filepath, menu_idname = "USERPREF_MT_interaction_presets") - + bpy.ops.script.execute_preset(filepath=filepath, menu_idname="USERPREF_MT_interaction_presets") + return {'FINISHED'} + class WM_OT_appconfig_activate(bpy.types.Operator): bl_idname = "wm.appconfig_activate" bl_label = "Activate Application Configuration" @@ -884,14 +889,15 @@ class WM_OT_appconfig_activate(bpy.types.Operator): def execute(self, context): import os bpy.utils.keyconfig_set(self.filepath) - + filepath = self.filepath.replace("keyconfig", "interaction") - + if os.path.exists(filepath): - bpy.ops.script.execute_preset(filepath = filepath, menu_idname = "USERPREF_MT_interaction_presets") - + bpy.ops.script.execute_preset(filepath=filepath, menu_idname="USERPREF_MT_interaction_presets") + return {'FINISHED'} + class WM_OT_sysinfo(bpy.types.Operator): '''Generate System Info''' bl_idname = "wm.sysinfo" diff --git a/release/scripts/startup/bl_ui/properties_animviz.py b/release/scripts/startup/bl_ui/properties_animviz.py index ac25c643cab..cebe58291d8 100644 --- a/release/scripts/startup/bl_ui/properties_animviz.py +++ b/release/scripts/startup/bl_ui/properties_animviz.py @@ -17,8 +17,6 @@ # ##### END GPL LICENSE BLOCK ##### # -import bpy - # Generic Panels (Independent of DataType) diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 9c678bd96b2..df464ed7fb0 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -29,7 +29,7 @@ from bl_ui.properties_physics_common import ( def particle_panel_enabled(context, psys): - if psys == None: + if psys is None: return True phystype = psys.settings.physics_type if psys.settings.type in {'EMITTER', 'REACTOR'} and phystype in {'NO', 'KEYED'}: @@ -98,10 +98,10 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, bpy.types.Panel): col.operator("object.particle_system_add", icon='ZOOMIN', text="") col.operator("object.particle_system_remove", icon='ZOOMOUT', text="") - if psys == None: + if psys is None: part = particle_get_settings(context) - if part == None: + if part is None: return layout.template_ID(context.space_data, "pin_id") @@ -192,7 +192,7 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, bpy.types.Panel): if settings.is_fluid: return False if particle_panel_poll(PARTICLE_PT_emission, context): - return psys == None or not context.particle_system.point_cache.use_external + return psys is None or not context.particle_system.point_cache.use_external return False def draw(self, context): @@ -201,7 +201,7 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, bpy.types.Panel): psys = context.particle_system part = particle_get_settings(context) - layout.enabled = particle_panel_enabled(context, psys) and (psys == None or not psys.has_multiple_caches) + layout.enabled = particle_panel_enabled(context, psys) and (psys is None or not psys.has_multiple_caches) row = layout.row() row.active = part.distribution != 'GRID' @@ -341,7 +341,7 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel, bpy.types.Panel): if settings.type == 'HAIR' and not settings.use_advanced_hair: return False - return settings.physics_type != 'BOIDS' and (psys == None or not psys.point_cache.use_external) + return settings.physics_type != 'BOIDS' and (psys is None or not psys.point_cache.use_external) else: return False @@ -363,7 +363,7 @@ class PARTICLE_PT_velocity(ParticleButtonsPanel, bpy.types.Panel): sub.prop(part, "tangent_phase", slider=True) col = split.column() - col.label(text="Emitter Object") + col.label(text="Emitter Object:") col.prop(part, "object_align_factor", text="") layout.label(text="Other:") @@ -391,7 +391,7 @@ class PARTICLE_PT_rotation(ParticleButtonsPanel, bpy.types.Panel): if settings.type == 'HAIR' and not settings.use_advanced_hair: return False - return settings.physics_type != 'BOIDS' and (psys == None or not psys.point_cache.use_external) + return settings.physics_type != 'BOIDS' and (psys is None or not psys.point_cache.use_external) else: return False @@ -440,7 +440,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel): if settings.type == 'HAIR' and not settings.use_advanced_hair: return False - return psys == None or not psys.point_cache.use_external + return psys is None or not psys.point_cache.use_external else: return False @@ -750,23 +750,23 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel): @classmethod def poll(cls, context): - psys = context.particle_system + settings = particle_get_settings(context) engine = context.scene.render.engine - if psys is None: - return False - if psys.settings is None: + if settings is None: return False + return engine in cls.COMPAT_ENGINES def draw(self, context): layout = self.layout psys = context.particle_system - part = psys.settings + part = particle_get_settings(context) row = layout.row() row.prop(part, "material") - row.prop(psys, "parent") + if psys: + row.prop(psys, "parent") split = layout.split() @@ -881,16 +881,19 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel): col = row.column() col.prop(part, "billboard_offset") - col = layout.column() - col.prop_search(psys, "billboard_normal_uv", ob.data, "uv_textures") - col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_textures") + if psys: + col = layout.column() + col.prop_search(psys, "billboard_normal_uv", ob.data, "uv_textures") + col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_textures") split = layout.split(percentage=0.33) split.label(text="Split uv's:") split.prop(part, "billboard_uv_split", text="Number of splits") - col = layout.column() - col.active = part.billboard_uv_split > 1 - col.prop_search(psys, "billboard_split_uv", ob.data, "uv_textures") + + if psys: + col = layout.column() + col.active = part.billboard_uv_split > 1 + col.prop_search(psys, "billboard_split_uv", ob.data, "uv_textures") row = col.row() row.label(text="Animate:") @@ -924,11 +927,9 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, bpy.types.Panel): @classmethod def poll(cls, context): - psys = context.particle_system + settings = particle_get_settings(context) engine = context.scene.render.engine - if psys is None: - return False - if psys.settings is None: + if settings is None: return False return engine in cls.COMPAT_ENGINES @@ -953,7 +954,7 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, bpy.types.Panel): else: row.label(text="") - if part.draw_percentage != 100: + if part.draw_percentage != 100 and psys is not None: if part.type == 'HAIR': if psys.use_hair_dynamics and psys.point_cache.is_baked == False: layout.row().label(text="Display percentage makes dynamics inaccurate without baking!") @@ -1143,7 +1144,7 @@ class PARTICLE_PT_vertexgroups(ParticleButtonsPanel, bpy.types.Panel): @classmethod def poll(cls, context): - if context.particle_system == None: + if context.particle_system is None: return False return particle_panel_poll(cls, context) diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index 1ba9a628c1a..1de30ffdea8 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -33,48 +33,52 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False): row.prop(dopesheet, "show_only_selected", text="") row.prop(dopesheet, "show_hidden", text="") - if genericFiltersOnly: - return - - row = layout.row(align=True) - row.prop(dopesheet, "show_transforms", text="") - - if is_nla: - row.prop(dopesheet, "show_missing_nla", text="") - - row = layout.row(align=True) - row.prop(dopesheet, "show_scenes", text="") - row.prop(dopesheet, "show_worlds", text="") - row.prop(dopesheet, "show_nodes", text="") - - if bpy.data.meshes: - row.prop(dopesheet, "show_meshes", text="") - if bpy.data.shape_keys: - row.prop(dopesheet, "show_shapekeys", text="") - if bpy.data.materials: - row.prop(dopesheet, "show_materials", text="") - if bpy.data.lamps: - row.prop(dopesheet, "show_lamps", text="") - if bpy.data.textures: - row.prop(dopesheet, "show_textures", text="") - if bpy.data.cameras: - row.prop(dopesheet, "show_cameras", text="") - if bpy.data.curves: - row.prop(dopesheet, "show_curves", text="") - if bpy.data.metaballs: - row.prop(dopesheet, "show_metaballs", text="") - if bpy.data.lattices: - row.prop(dopesheet, "show_lattices", text="") - if bpy.data.armatures: - row.prop(dopesheet, "show_armatures", text="") - if bpy.data.particles: - row.prop(dopesheet, "show_particles", text="") - - if bpy.data.groups: + if not genericFiltersOnly: row = layout.row(align=True) - row.prop(dopesheet, "show_only_group_objects", text="") - if dopesheet.show_only_group_objects: - row.prop(dopesheet, "filter_group", text="") + row.prop(dopesheet, "show_transforms", text="") + + if is_nla: + row.prop(dopesheet, "show_missing_nla", text="") + + row = layout.row(align=True) + row.prop(dopesheet, "show_scenes", text="") + row.prop(dopesheet, "show_worlds", text="") + row.prop(dopesheet, "show_nodes", text="") + + if bpy.data.meshes: + row.prop(dopesheet, "show_meshes", text="") + if bpy.data.shape_keys: + row.prop(dopesheet, "show_shapekeys", text="") + if bpy.data.materials: + row.prop(dopesheet, "show_materials", text="") + if bpy.data.lamps: + row.prop(dopesheet, "show_lamps", text="") + if bpy.data.textures: + row.prop(dopesheet, "show_textures", text="") + if bpy.data.cameras: + row.prop(dopesheet, "show_cameras", text="") + if bpy.data.curves: + row.prop(dopesheet, "show_curves", text="") + if bpy.data.metaballs: + row.prop(dopesheet, "show_metaballs", text="") + if bpy.data.lattices: + row.prop(dopesheet, "show_lattices", text="") + if bpy.data.armatures: + row.prop(dopesheet, "show_armatures", text="") + if bpy.data.particles: + row.prop(dopesheet, "show_particles", text="") + + if bpy.data.groups: + row = layout.row(align=True) + row.prop(dopesheet, "show_only_group_objects", text="") + if dopesheet.show_only_group_objects: + row.prop(dopesheet, "filter_group", text="") + + if not is_nla: + row = layout.row(align=True) + row.prop(dopesheet, "show_only_matching_fcurves", text="") + if dopesheet.show_only_matching_fcurves: + row.prop(dopesheet, "filter_fcurve_name", text="") ####################################### diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index b2965d0c37a..aaf7336c5c7 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -667,7 +667,7 @@ class IMAGE_PT_paint(bpy.types.Panel): col.prop(brush, "blend", text="Blend") - if brush.imagepaint_tool == 'CLONE': + if brush.image_tool == 'CLONE': col.separator() col.prop(brush, "clone_image", text="Image") col.prop(brush, "clone_alpha", text="Alpha") @@ -699,13 +699,13 @@ class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, bpy.types.Panel): col = layout.column(align=True) - col.prop(brush, "imagepaint_tool", expand=False, text="") + col.prop(brush, "image_tool", expand=False, text="") row = layout.row(align=True) row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT') row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT') row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT') - row.prop(brush, "use_paint_texture", text="", icon='TPAINT_HLT') + row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT') class IMAGE_PT_paint_stroke(BrushButtonsPanel, bpy.types.Panel): diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index b6265903890..24aca6065ac 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -350,7 +350,7 @@ class INFO_MT_help(bpy.types.Menu): layout = self.layout layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:Manual' - layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-256-beta/' + layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-257/' layout.separator() diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 59d9aef12f2..a81561de93f 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -21,7 +21,7 @@ import bpy import os import addon_utils -from bpy.props import StringProperty, BoolProperty, EnumProperty +from bpy.props import StringProperty, BoolProperty def ui_items_general(col, context): @@ -119,6 +119,7 @@ class USERPREF_MT_interaction_presets(bpy.types.Menu): preset_operator = "script.execute_preset" draw = bpy.types.Menu.draw_preset + class USERPREF_MT_appconfigs(bpy.types.Menu): bl_label = "AppPresets" preset_subdir = "keyconfig" @@ -130,6 +131,7 @@ class USERPREF_MT_appconfigs(bpy.types.Menu): # now draw the presets bpy.types.Menu.draw_preset(self, context) + class USERPREF_MT_splash(bpy.types.Menu): bl_label = "Splash" @@ -647,7 +649,7 @@ class USERPREF_PT_theme(bpy.types.Panel): layout.separator() layout.separator() - elif theme.theme_area == 'COLOR_SETS': + elif theme.theme_area == 'BONE_COLOR_SETS': col = split.column() for i, ui in enumerate(theme.bone_color_sets): diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 22d630643c9..c83affef0e8 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -240,9 +240,21 @@ class VIEW3D_MT_uv_map(bpy.types.Menu): layout = self.layout layout.operator("uv.unwrap") + + layout.operator_context = 'INVOKE_DEFAULT' + layout.operator("uv.smart_project") + layout.operator("uv.lightmap_pack") + layout.operator("uv.follow_active_quads") + + layout.separator() + + layout.operator_context = 'EXEC_DEFAULT' layout.operator("uv.cube_project") layout.operator("uv.cylinder_project") layout.operator("uv.sphere_project") + + layout.separator() + layout.operator("uv.project_from_view") layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True @@ -250,6 +262,7 @@ class VIEW3D_MT_uv_map(bpy.types.Menu): layout.operator("uv.reset") + # ********** View menus ********** @@ -1039,6 +1052,10 @@ class VIEW3D_MT_paint_weight(bpy.types.Menu): layout.operator("object.vertex_group_invert", text="Invert") layout.operator("object.vertex_group_clean", text="Clean") layout.operator("object.vertex_group_levels", text="Levels") + + layout.separator() + + layout.operator("paint.weight_set") # ********** Sculpt menu ********** @@ -1248,7 +1265,15 @@ class VIEW3D_MT_pose_propagate(bpy.types.Menu): layout = self.layout layout.operator("pose.propagate") + + layout.separator() + layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY' + layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY' + + layout.separator() + + layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS' class VIEW3D_MT_pose_library(bpy.types.Menu): diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 795e73675eb..e70395efa84 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -331,12 +331,9 @@ class VIEW3D_PT_tools_armatureedit_options(View3DPanel, bpy.types.Panel): bl_label = "Armature Options" def draw(self, context): - layout = self.layout - arm = context.active_object.data - col = layout.column(align=True) - col.prop(arm, "use_mirror_x") + self.layout.prop(arm, "use_mirror_x") # ********** default tools for editmode_mball **************** @@ -431,12 +428,9 @@ class VIEW3D_PT_tools_posemode_options(View3DPanel, bpy.types.Panel): bl_label = "Pose Options" def draw(self, context): - layout = self.layout - arm = context.active_object.data - col = layout.column(align=True) - col.prop(arm, "use_auto_ik") + self.layout.prop(arm, "use_auto_ik") # ********** default tools for paint modes **************** @@ -455,7 +449,7 @@ class PaintPanel(): return ts.vertex_paint elif context.weight_paint_object: return ts.weight_paint - elif context.texture_paint_object: + elif context.image_paint_object: return ts.image_paint elif context.particle_edit_object: return ts.particle_edit @@ -522,7 +516,7 @@ class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel): row.prop(brush, "unprojected_radius", text="Radius", slider=True) else: row.prop(brush, "use_locked_size", toggle=True, text="", icon='UNLOCKED') - row.prop(brush, "size", text="Radius", slider=True) + row.prop(brush, "size", slider=True) row.prop(brush, "use_pressure_size", toggle=True, text="") @@ -619,13 +613,13 @@ class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel): # Texture Paint Mode # - elif context.texture_paint_object and brush: + elif context.image_paint_object and brush: col = layout.column() col.template_color_wheel(brush, "color", value_slider=True) col.prop(brush, "color", text="") row = col.row(align=True) - row.prop(brush, "size", text="Radius", slider=True) + row.prop(brush, "size", slider=True) row.prop(brush, "use_pressure_size", toggle=True, text="") row = col.row(align=True) @@ -650,7 +644,7 @@ class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel): col = layout.column() row = col.row(align=True) - row.prop(brush, "size", text="Radius", slider=True) + row.prop(brush, "size", slider=True) row.prop(brush, "use_pressure_size", toggle=True, text="") row = col.row(align=True) @@ -668,7 +662,7 @@ class VIEW3D_PT_tools_brush(PaintPanel, bpy.types.Panel): col.prop(brush, "color", text="") row = col.row(align=True) - row.prop(brush, "size", text="Radius", slider=True) + row.prop(brush, "size", slider=True) row.prop(brush, "use_pressure_size", toggle=True, text="") row = col.row(align=True) @@ -689,7 +683,7 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel): def poll(cls, context): settings = cls.paint_settings(context) return (settings and settings.brush and (context.sculpt_object or - context.texture_paint_object)) + context.image_paint_object)) def draw(self, context): layout = self.layout @@ -701,7 +695,7 @@ class VIEW3D_PT_tools_brush_texture(PaintPanel, bpy.types.Panel): col = layout.column() col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8) - if brush.use_paint_texture: + if brush.use_paint_image: col.prop(brush, "use_fixed_texture") if context.sculpt_object: @@ -787,7 +781,7 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): def poll(cls, context): settings = cls.paint_settings(context) return (settings and settings.brush and - (context.sculpt_object or context.texture_paint_object or + (context.sculpt_object or context.image_paint_object or context.vertex_paint_object or context.weight_paint_object)) def draw(self, context): @@ -795,25 +789,22 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): settings = __class__.paint_settings(context) brush = settings.brush - ## Unused - # texture_paint = context.texture_paint_object - # sculpt = context.sculpt_object col = layout.column(align=True) if context.sculpt_object: col.prop(brush, "sculpt_tool", expand=False, text="") col.operator("brush.reset") - elif context.texture_paint_object: - col.prop(brush, "imagepaint_tool", expand=False, text="") + elif context.image_paint_object: + col.prop(brush, "image_tool", expand=False, text="") elif context.vertex_paint_object or context.weight_paint_object: - col.prop(brush, "vertexpaint_tool", expand=False, text="") + col.prop(brush, "vertex_tool", expand=False, text="") row = layout.row(align=True) row.prop(brush, "use_paint_sculpt", text="", icon='SCULPTMODE_HLT') row.prop(brush, "use_paint_vertex", text="", icon='VPAINT_HLT') row.prop(brush, "use_paint_weight", text="", icon='WPAINT_HLT') - row.prop(brush, "use_paint_texture", text="", icon='TPAINT_HLT') + row.prop(brush, "use_paint_image", text="", icon='TPAINT_HLT') class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): @@ -826,14 +817,14 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): return (settings and settings.brush and (context.sculpt_object or context.vertex_paint_object or context.weight_paint_object or - context.texture_paint_object)) + context.image_paint_object)) def draw(self, context): layout = self.layout settings = __class__.paint_settings(context) brush = settings.brush - texture_paint = context.texture_paint_object + image_paint = context.image_paint_object col = layout.column() @@ -884,7 +875,7 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): col.separator() - if not texture_paint: + if not image_paint: row = col.row() row.prop(brush, "use_smooth_stroke") @@ -910,7 +901,7 @@ class VIEW3D_PT_tools_brush_stroke(PaintPanel, bpy.types.Panel): #col.separator() - #if texture_paint: + #if image_paint: # row.prop(brush, "use_pressure_spacing", toggle=True, text="") @@ -986,7 +977,6 @@ class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel): return (context.sculpt_object and context.tool_settings.sculpt) def draw(self, context): - layout = self.layout sculpt = context.tool_settings.sculpt @@ -995,21 +985,16 @@ class VIEW3D_PT_sculpt_symmetry(PaintPanel, bpy.types.Panel): split = layout.split() col = split.column() - col.label(text="Mirror:") col.prop(sculpt, "use_symmetry_x", text="X") col.prop(sculpt, "use_symmetry_y", text="Y") col.prop(sculpt, "use_symmetry_z", text="Z") - col = split.column() + split.prop(sculpt, "radial_symmetry", text="Radial") - col.prop(sculpt, "radial_symmetry", text="Radial") + layout.separator() - col = layout.column() - - col.separator() - - col.prop(sculpt, "use_symmetry_feather", text="Feather") + layout.prop(sculpt, "use_symmetry_feather", text="Feather") class VIEW3D_PT_tools_brush_appearance(PaintPanel, bpy.types.Panel): @@ -1018,7 +1003,7 @@ class VIEW3D_PT_tools_brush_appearance(PaintPanel, bpy.types.Panel): @classmethod def poll(cls, context): - return (context.sculpt_object and context.tool_settings.sculpt) or (context.vertex_paint_object and context.tool_settings.vertex_paint) or (context.weight_paint_object and context.tool_settings.weight_paint) or (context.texture_paint_object and context.tool_settings.image_paint) + return (context.sculpt_object and context.tool_settings.sculpt) or (context.vertex_paint_object and context.tool_settings.vertex_paint) or (context.weight_paint_object and context.tool_settings.weight_paint) or (context.image_paint_object and context.tool_settings.image_paint) def draw(self, context): layout = self.layout @@ -1135,13 +1120,13 @@ class VIEW3D_PT_tools_vertexpaint(View3DPanel, bpy.types.Panel): class VIEW3D_PT_tools_projectpaint(View3DPanel, bpy.types.Panel): - bl_context = "texturepaint" + bl_context = "imagepaint" bl_label = "Project Paint" @classmethod def poll(cls, context): brush = context.tool_settings.image_paint.brush - return (brush and brush.imagepaint_tool != 'SOFTEN') + return (brush and brush.image_tool != 'SOFTEN') def draw_header(self, context): ipaint = context.tool_settings.image_paint @@ -1184,7 +1169,7 @@ class VIEW3D_PT_tools_projectpaint(View3DPanel, bpy.types.Panel): col = layout.column() sub = col.column() row = sub.row() - row.active = (settings.brush.imagepaint_tool == 'CLONE') + row.active = (settings.brush.image_tool == 'CLONE') row.prop(ipaint, "use_clone_layer", text="Layer") row.menu("VIEW3D_MT_tools_projectpaint_clone", text=context.active_object.data.uv_texture_clone.name) @@ -1211,14 +1196,14 @@ class VIEW3D_PT_imagepaint_options(PaintPanel): @classmethod def poll(cls, context): - return (context.texture_paint_object and context.tool_settings.image_paint) + return (context.image_paint_object and context.tool_settings.image_paint) def draw(self, context): layout = self.layout + + tool_settings = context.tool_settings col = layout.column() - - tool_settings = context.tool_settings col.label(text="Unified Settings:") col.prop(tool_settings, "sculpt_paint_use_unified_size", text="Size") col.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Strength") diff --git a/release/scripts/templates/operator_modal_timer.py b/release/scripts/templates/operator_modal_timer.py new file mode 100644 index 00000000000..d2267191cf5 --- /dev/null +++ b/release/scripts/templates/operator_modal_timer.py @@ -0,0 +1,45 @@ +import bpy + + +class ModalTimerOperator(bpy.types.Operator): + '''Operator which runs its self from a timer.''' + bl_idname = "wm.modal_timer_operator" + bl_label = "Modal Timer Operator" + + _timer = None + + def modal(self, context, event): + if event.type == 'ESC': + return self.cancel() + + if event.type == 'TIMER': + # change theme color, silly! + color = context.user_preferences.themes[0].view_3d.back + color.s = 1.0 + color.h += 0.01 + + return {'PASS_THROUGH'} + + def execute(self, context): + context.window_manager.modal_handler_add(self) + self._timer = context.window_manager.event_timer_add(0.1, context.window) + return {'RUNNING_MODAL'} + + def cancel(self, context): + context.window_manager.event_timer_remove(self._timer) + return {'CANCELLED'} + + +def register(): + bpy.utils.register_class(ModalTimerOperator) + + +def unregister(): + bpy.utils.unregister_class(ModalTimerOperator) + + +if __name__ == "__main__": + register() + + # test call + bpy.ops.wm.modal_timer_operator() diff --git a/release/text/readme.html b/release/text/readme.html index 7aa9c047d43..1014d8ef80a 100644 --- a/release/text/readme.html +++ b/release/text/readme.html @@ -12,23 +12,22 @@ -

Blender 2.56a Beta

+

Blender 2.57


About

Welcome to Blender, the free, open source 3D application for modeling, animation, rendering, compositing, video editing and game creation. Blender is available for Linux, Mac OS X, Windows, Solaris and FreeBSD and has a large world-wide community.

Blender can be used freely for any purpose, including commercial use and distribution. It's free and open-source software, released under the GNU GPL licence. The entire source code is available on our website.

For more information, visit blender.org.


-

2.56a Beta

-

The Blender Foundation and online developer community is proud to present Blender 2.56a Beta. This release is the fourth official beta release of the Blender 2.5 series, and represents the culmination of many years of redesign and development work. More information about this release.

+

2.57

+

The Blender Foundation and online developer community is proud to present Blender 2.57. This release is the first official stable release of the Blender 2.5 series, and represents the culmination of many years of redesign and development work. More information about this release.

What to Expect:

• Big improvements - This is our most exciting version to date, already a significant improvement in many ways over 2.49

• Missing/Incomplete Features - Although most of it is there, not all functionality from pre-2.5 versions has been restored yet. Some functionality may be re-implemented a different way.

-

• Bugs - We've fixed a lot lately, but there are still quite a few bugs. This is beta software, we're still working on it!

• Changes - If you're used to the old Blenders, Blender 2.5 may seem quite different at first, but it won't be long before it grows on you even more than before.


Bugs

-

Blender 2.56a Beta is unfinished software. If you encounter a bug, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender 2.56a. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.

+

Although Blender 2.57 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender 2.57. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.


Package Contents

The downloaded Blender package includes:

@@ -52,7 +51,7 @@

Links

Users:

General information www.blender.org
- Full release log www.blender.org/development/release-logs/blender-256-beta/
+ Full release log www.blender.org/development/release-logs/blender-257/
Tutorials www.blender.org/education-help/
Manual wiki.blender.org/index.php/Doc:Manual
User Forum www.blenderartists.org
diff --git a/release/windows/installer/00.sconsblender.nsi b/release/windows/installer/00.sconsblender.nsi index e5ebf8b2f64..68d884beb68 100644 --- a/release/windows/installer/00.sconsblender.nsi +++ b/release/windows/installer/00.sconsblender.nsi @@ -6,19 +6,20 @@ ; Requires the MoreInfo plugin - http://nsis.sourceforge.net/MoreInfo_plug-in ; +SetCompressor /SOLID lzma + +Name "Blender [VERSION]" + +!define MULTIUSER_EXECUTIONLEVEL Admin + !include "MUI.nsh" !include "WinVer.nsh" !include "FileFunc.nsh" !include "WordFunc.nsh" !include "nsDialogs.nsh" +!include "MultiUser.nsh" !include "x64.nsh" -RequestExecutionLevel user - -SetCompressor /SOLID lzma - -Name "Blender [VERSION]" - !define MUI_ABORTWARNING !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Blender. It is recommended that you close all other applications before starting Setup." @@ -60,21 +61,17 @@ UninstallIcon "[RELDIR]\00.installer.ico" ;Language Strings ;Description - LangString DESC_SecCopyUI ${LANG_ENGLISH} "Copy all required files to the application folder." - LangString DESC_Section2 ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)" - LangString DESC_Section3 ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop." - LangString DESC_Section4 ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc." + LangString DESC_InstallFiles ${LANG_ENGLISH} "Copy all required files to the application folder." + LangString DESC_StartMenu ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)" + LangString DESC_DesktopShortcut ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop." + LangString DESC_BlendRegister ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc." LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Specify User Data Location" ;-------------------------------- ;Data Caption "Blender [VERSION] Installer" OutFile "[DISTDIR]\..\blender-[VERSION]-windows[BITNESS].exe" -;InstallDir "$PROGRAMFILES[BITNESS]\Blender Foundation\Blender" -; Install to user profile dir. While it is non-standard, it allows -; users to install without having to have the installer run in elevated mode. -InstallDir "$PROFILE\Blender Foundation\Blender" - +InstallDir $INSTDIR ; $INSTDIR is set inside .onInit BrandingText "Blender Foundation | http://www.blender.org" ComponentText "This will install Blender [VERSION] on your computer." @@ -85,7 +82,7 @@ SilentUnInstall normal Var BLENDERHOME Var SHORTVERSION ; This is blender_version_decimal() from path_util.c -; custom controls +; Custom controls Var HWND Var HWND_APPDATA @@ -94,7 +91,23 @@ Var HWND_HOMEDIR Function .onInit ClearErrors + !insertmacro MULTIUSER_INIT ; Checks if user has admin rights StrCpy $SHORTVERSION "[SHORTVERSION]" + + ${If} ${RunningX64} + ${If} "[BITNESS]" == "32" + ${OrIf} "[BITNESS]" == "-mingw" + StrCpy $INSTDIR "$PROGRAMFILES32\Blender Foundation\Blender" ; Can't use InstallDir inside Section + ${ElseIf} "[BITNESS]" == "64" + StrCpy $INSTDIR "$PROGRAMFILES64\Blender Foundation\Blender" + ${EndIf} + ${Else} + StrCpy $INSTDIR "$PROGRAMFILES\Blender Foundation\Blender" + ${EndIf} +FunctionEnd + +Function un.onInit + !insertmacro MULTIUSER_UNINIT FunctionEnd Function DataLocation @@ -105,12 +118,12 @@ Function DataLocation Abort ${EndIf} - ${NSD_CreateLabel} 0 0 100% 12u "Please specify where you wish to install Blender's user data files." - ${NSD_CreateRadioButton} 0 20 100% 12u "Use the Application Data directory" + ${NSD_CreateLabel} 0 0 100% 24u "Please specify where you wish to install Blender's user data files. Be aware that if you choose to use your Application Data directory, your preferences and scripts will only be accessible by the current user account." + ${NSD_CreateRadioButton} 0 50 100% 12u "Use Application Data directory (recommended)" Pop $HWND_APPDATA - ${NSD_CreateRadioButton} 0 50 100% 12u "Use the installation directory (ie. location chosen to install blender.exe)." + ${NSD_CreateRadioButton} 0 80 100% 12u "Use installation directory" Pop $HWND_INSTDIR - ${NSD_CreateRadioButton} 0 80 100% 12u "I have defined a %HOME% variable, please install files here." + ${NSD_CreateRadioButton} 0 110 100% 12u "I have defined a %HOME% variable, please install files there" Pop $HWND_HOMEDIR ${If} ${AtMostWinME} @@ -128,7 +141,9 @@ FunctionEnd Function DataLocationOnLeave ${NSD_GetState} $HWND_APPDATA $R0 ${If} $R0 == "1" + SetShellVarContext current StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender" + SetShellVarContext all ${Else} ${NSD_GetState} $HWND_INSTDIR $R0 ${If} $R0 == "1" @@ -142,15 +157,15 @@ Function DataLocationOnLeave ${EndIf} FunctionEnd -Section "Blender-[VERSION] (required)" SecCopyUI +Section "Blender [VERSION] (required)" InstallFiles SectionIn RO ; Set output path to the installation directory. SetOutPath $INSTDIR - ; the contents of Blender installation root dir + ; The contents of Blender installation root dir [ROOTDIRCONTS] - ; all datafiles (python, scripts, config) + ; All datafiles (python, scripts, config) [DODATAFILES] SetOutPath $INSTDIR @@ -162,13 +177,19 @@ Section "Blender-[VERSION] (required)" SecCopyUI WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" "$BLENDERHOME" WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]" ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender (remove only)" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "Publisher" "Blender Foundation" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "URLInfoAbout" "http://www.blender.org/" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayVersion" "[VERSION]" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayIcon" "$INSTDIR\blender.exe" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoRepair " 1 WriteUninstaller "uninstall.exe" SectionEnd -Section "Add Start Menu shortcuts" Section2 +Section "Add Start Menu Shortcuts" StartMenu SetShellVarContext all CreateDirectory "$SMPROGRAMS\Blender Foundation\Blender\" CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 @@ -176,45 +197,38 @@ Section "Add Start Menu shortcuts" Section2 CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Readme.lnk" "$INSTDIR\readme.html" "" "" 0 CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Copyright.lnk" "$INSTDIR\Copyright.txt" "" "$INSTDIR\copyright.txt" 0 CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\GPL-license.lnk" "$INSTDIR\GPL-license.txt" "" "$INSTDIR\GPL-license.txt" 0 + System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons SectionEnd -Section "Add Desktop Blender-[VERSION] shortcut" Section3 +Section "Add Desktop Shortcut" DesktopShortcut CreateShortCut "$DESKTOP\Blender.lnk" "$INSTDIR\blender.exe" "" "$INSTDIR\blender.exe" 0 + System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons SectionEnd -Section "Open .blend files with Blender-[VERSION]" Section4 - - ${If} ${RunningX64} - SetRegView 64 - ${EndIf} - WriteRegStr HKCR ".blend" "" "blendfile" - WriteRegStr HKCR "blendfile" "" "Blender .blend File" - WriteRegStr HKCR "blendfile\shell" "" "open" - WriteRegStr HKCR "blendfile\DefaultIcon" "" $INSTDIR\blender.exe,1 - WriteRegStr HKCR "blendfile\shell\open\command" "" \ - '"$INSTDIR\blender.exe" "%1"' - +Section "Open .blend files with Blender" BlendRegister +ExecWait '"$INSTDIR\blender.exe" -r' SectionEnd -UninstallText "This will uninstall Blender [VERSION], and all installed files. Before continuing make sure you have created backup of all the files you may want to keep: startup.blend, bookmarks.txt, recent-files.txt. Hit next to continue." +UninstallText "This will uninstall Blender [VERSION], and all installed files. Before continuing make sure you have created backup of all the files you may want to keep: startup.blend, bookmarks.txt, recent-files.txt. Hit 'Uninstall' to continue." Section "Uninstall" - ; remove registry keys + ; Remove registry keys ${If} ${RunningX64} SetRegView 64 ${EndIf} + ReadRegStr $BLENDERHOME HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" + DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blender" DeleteRegKey HKLM "SOFTWARE\BlenderFoundation" + DeleteRegKey HKCR ".blend" + DeleteRegKey HKCR "blendfile" + DeleteRegKey HKCR "CLSID\{D45F043D-F17F-4e8a-8435-70971D9FA46D}" SetShellVarContext all - ; remove files + ; Remove files [DELROOTDIRCONTS] - ; remove bundled python - RmDir /r $INSTDIR\$SHORTVERSION\python - Delete "$INSTDIR\uninstall.exe" MessageBox MB_YESNO "Recursively erase contents of $BLENDERHOME\$SHORTVERSION\scripts? NOTE: This includes all installed scripts and *any* file and directory you have manually created, installed later or copied. This also including .blend files." IDNO NextNoScriptRemove @@ -226,26 +240,27 @@ NextNoConfigRemove: MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\plugins? NOTE: This includes files and subdirectories in this directory" IDNO NextNoPluginRemove RMDir /r "$BLENDERHOME\$SHORTVERSION\plugins" NextNoPluginRemove: - ; try to remove dirs, but leave them if they contain anything + ; Try to remove dirs, but leave them if they contain anything RMDir "$BLENDERHOME\$SHORTVERSION\plugins" RMDir "$BLENDERHOME\$SHORTVERSION\config" RMDir "$BLENDERHOME\$SHORTVERSION\scripts" RMDir "$BLENDERHOME\$SHORTVERSION" RMDir "$BLENDERHOME" - ; remove shortcuts + ; Remove shortcuts Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*" Delete "$DESKTOP\Blender.lnk" - ; remove all link related directories and files - RMDir "$SMPROGRAMS\Blender Foundation\Blender" - RMDir "$SMPROGRAMS\Blender Foundation" + ; Remove all link related directories and files + RMDir /r "$SMPROGRAMS\Blender Foundation" ; Clear out installation dir - RMDir "$INSTDIR" + RMDir /r "$INSTDIR" + + System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; Refresh icons SectionEnd !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyUI} $(DESC_SecCopyUI) - !insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2) - !insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3) - !insertmacro MUI_DESCRIPTION_TEXT ${Section4} $(DESC_Section4) + !insertmacro MUI_DESCRIPTION_TEXT ${InstallFiles} $(DESC_InstallFiles) + !insertmacro MUI_DESCRIPTION_TEXT ${StartMenu} $(DESC_StartMenu) + !insertmacro MUI_DESCRIPTION_TEXT ${DesktopShortcut} $(DESC_DesktopShortcut) + !insertmacro MUI_DESCRIPTION_TEXT ${BlendRegister} $(DESC_BlendRegister) !insertmacro MUI_FUNCTION_DESCRIPTION_END diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 6f8e9bbe8df..f222db71455 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -52,8 +52,8 @@ extern "C" { /* used by packaging tools */ /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR a - /* alpha/beta/rc/releases */ -#define BLENDER_VERSION_CYCLE beta + /* alpha/beta/rc/release, docs use this */ +#define BLENDER_VERSION_CYCLE rc struct ListBase; struct MemFile; diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index f0c58e0a511..0491116d199 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -51,7 +51,7 @@ struct BevList; #define SEGMENTSV(nu) ( ((nu)->flagv & CU_NURB_CYCLIC) ? (nu)->pntsv : (nu)->pntsv-1 ) #define CU_DO_TILT(cu, nu) (((nu->flag & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1) -#define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || ((cu)->flag & CU_PATH_RADIUS) || (cu)->bevobj || (cu)->ext1!=0.0 || (cu)->ext2!=0.0) ? 1:0) +#define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || ((cu)->flag & CU_PATH_RADIUS) || (cu)->bevobj || (cu)->ext1!=0.0f || (cu)->ext2!=0.0f) ? 1:0) void unlink_curve( struct Curve *cu); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 9b1651b12cd..4dfc53e1734 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -157,8 +157,6 @@ typedef struct ParticleBillboardData typedef struct ParticleCollisionElement { - Object *ob; - /* pointers to original data */ float *x[4], *v[4]; @@ -171,6 +169,9 @@ typedef struct ParticleCollisionElement /* count of original data (1-4) */ int tot; + /* index of the collision face */ + int index; + /* flags for inversed normal / particle already inside element at start */ short inv_nor, inside; } ParticleCollisionElement; diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index a1a8b1b28cb..943712167c6 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -50,10 +50,11 @@ struct Scene; struct Text; struct Text; -#define SCE_COPY_EMPTY 0 -#define SCE_COPY_LINK_OB 1 -#define SCE_COPY_LINK_DATA 2 -#define SCE_COPY_FULL 3 +#define SCE_COPY_NEW 0 +#define SCE_COPY_EMPTY 1 +#define SCE_COPY_LINK_OB 2 +#define SCE_COPY_LINK_DATA 3 +#define SCE_COPY_FULL 4 #define SETLOOPER(_sce_basis, _sce_iter, _base) _sce_iter= _sce_basis, _base= _setlooper_base_step(&_sce_iter, NULL); _base; _base= _setlooper_base_step(&_sce_iter, _base) struct Base *_setlooper_base_step(struct Scene **sce_iter, struct Base *base); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index c53871cabd2..33bff1cd6a7 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -258,6 +258,7 @@ int seq_single_check(struct Sequence *seq); void seq_single_fix(struct Sequence *seq); int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test); void seq_translate(struct Scene *scene, struct Sequence *seq, int delta); +void seq_sound_init(struct Scene *scene, struct Sequence *seq); struct Sequence *seq_foreground_frame_get(struct Scene *scene, int frame); struct ListBase *seq_seqbase(struct ListBase *seqbase, struct Sequence *seq); void seq_offset_animdata(struct Scene *scene, struct Sequence *seq, int ofs); diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 2cfd17a95f3..a311ca15e5e 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1342,6 +1342,17 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, NormCopy(EDGE_getNo(e, lvl, x), _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } + else { + /* set to zero here otherwise the normals are uninitialized memory + * render: tests/animation/knight.blend with valgrind. + * we could be more clever and interpolate vertex normals but these are + * most likely not used so just zero out. */ + int x; + + for (x=0; xmvert[indices[vert_index]].no; - for(i=0; i<3; i++) - fNorm[i]=no[i]/32767.0f; - normalize_v3(fNorm); + short *no = pMesh->mvert[indices[vert_index]].no; + normal_short_to_float_v3(fNorm, no); + normalize_v3(fNorm); /* XXX, is this needed */ } } static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int face_num, const int iVert) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 59467c761ba..7bf893a3d60 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -283,23 +283,31 @@ void BKE_animdata_make_local(AnimData *adt) make_local_strips(&nlt->strips); } -void BKE_relink_animdata(struct AnimData *adt) + +/* When duplicating data (i.e. objects), drivers referring to the original data will + * get updated to point to the duplicated data (if drivers belong to the new data) + */ +void BKE_relink_animdata (AnimData *adt) { + /* sanity check */ + if (adt == NULL) + return; + /* drivers */ if (adt->drivers.first) { FCurve *fcu; - + /* check each driver against all the base paths to see if any should go */ for (fcu= adt->drivers.first; fcu; fcu=fcu->next) { ChannelDriver *driver= fcu->driver; DriverVar *dvar; - + /* driver variables */ for (dvar= driver->variables.first; dvar; dvar=dvar->next) { /* only change the used targets, since the others will need fixing manually anyway */ DRIVER_TARGETS_USED_LOOPER(dvar) { - if(dtar->id->newid) { + if (dtar->id && dtar->id->newid) { dtar->id= dtar->id->newid; } } @@ -1846,23 +1854,19 @@ void nladata_flush_channels (ListBase *channels) /* ---------------------- */ -/* NLA Evaluation function (mostly for use through do_animdata) - * - All channels that will be affected are not cleared anymore. Instead, we just evaluate into - * some temp channels, where values can be accumulated in one go. +/* NLA Evaluation function - values are calculated and stored in temporary "NlaEvalChannels" + * ! This is exported so that keyframing code can use this for make use of it for anim layers support + * > echannels: (list) evaluation channels with calculated values */ -static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) +static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData *adt, float ctime) { NlaTrack *nlt; short track_index=0; short has_strips = 0; ListBase estrips= {NULL, NULL}; - ListBase echannels= {NULL, NULL}; NlaEvalStrip *nes; - // TODO: need to zero out all channels used, otherwise we have problems with threadsafety - // and also when the user jumps between different times instead of moving sequentially... - /* 1. get the stack of strips to evaluate at current time (influence calculated here) */ for (nlt=adt->nla_tracks.first; nlt; nlt=nlt->next, track_index++) { /* stop here if tweaking is on and this strip is the tweaking track (it will be the first one that's 'disabled')... */ @@ -1937,13 +1941,30 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) /* 2. for each strip, evaluate then accumulate on top of existing channels, but don't set values yet */ for (nes= estrips.first; nes; nes= nes->next) - nlastrip_evaluate(ptr, &echannels, NULL, nes); + nlastrip_evaluate(ptr, echannels, NULL, nes); + + /* 3. free temporary evaluation data that's not used elsewhere */ + BLI_freelistN(&estrips); +} + +/* NLA Evaluation function (mostly for use through do_animdata) + * - All channels that will be affected are not cleared anymore. Instead, we just evaluate into + * some temp channels, where values can be accumulated in one go. + */ +static void animsys_calculate_nla (PointerRNA *ptr, AnimData *adt, float ctime) +{ + ListBase echannels= {NULL, NULL}; - /* 3. flush effects of accumulating channels in NLA to the actual data they affect */ + // TODO: need to zero out all channels used, otherwise we have problems with threadsafety + // and also when the user jumps between different times instead of moving sequentially... + + /* evaluate the NLA stack, obtaining a set of values to flush */ + animsys_evaluate_nla(&echannels, ptr, adt, ctime); + + /* flush effects of accumulating channels in NLA to the actual data they affect */ nladata_flush_channels(&echannels); - /* 4. free temporary evaluation data */ - BLI_freelistN(&estrips); + /* free temp data */ BLI_freelistN(&echannels); } @@ -2037,7 +2058,7 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re /* evaluate NLA-stack * - active action is evaluated as part of the NLA stack as the last item */ - animsys_evaluate_nla(&id_ptr, adt, ctime); + animsys_calculate_nla(&id_ptr, adt, ctime); } /* evaluate Active Action only */ else if (adt->action) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 99c70564d66..ddfa738449d 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -438,7 +438,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) scale[1]= len_v3(pchan->pose_mat[1]); scale[2]= len_v3(pchan->pose_mat[2]); - if(fabs(scale[0] - scale[1]) > 1e-6f || fabs(scale[1] - scale[2]) > 1e-6f) { + if(fabsf(scale[0] - scale[1]) > 1e-6f || fabsf(scale[1] - scale[2]) > 1e-6f) { unit_m4(scalemat); scalemat[0][0]= scale[0]; scalemat[1][1]= scale[1]; @@ -734,11 +734,11 @@ static float dist_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, f fac= distfactor_to_bone(cop, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, bone->dist); - if (fac>0.0) { + if (fac > 0.0f) { fac*=bone->weight; contrib= fac; - if(contrib>0.0) { + if(contrib > 0.0f) { if(vec) { if(bone->segments>1) // applies on cop and bbonemat @@ -1277,7 +1277,7 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa } /* when converting to axis-angle, we need a special exception for the case when there is no axis */ - if (IS_EQ(axis[0], axis[1]) && IS_EQ(axis[1], axis[2])) { + if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) { /* for now, rotate around y-axis then (so that it simply becomes the roll) */ axis[1]= 1.0f; } @@ -1336,7 +1336,7 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) /* was 0.0000000000001, caused bug [#23954], smaller values give unstable * roll when toggling editmode */ - if (dot_v3v3(axis,axis) > 0.00001) { + if (dot_v3v3(axis,axis) > 0.00001f) { /* if nor is *not* a multiple of target ... */ normalize_v3(axis); @@ -1379,7 +1379,7 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) bone->length= len_v3v3(bone->head, bone->tail); /* this is called on old file reading too... */ - if(bone->xwidth==0.0) { + if(bone->xwidth==0.0f) { bone->xwidth= 0.1f; bone->zwidth= 0.1f; bone->segments= 1; @@ -1970,12 +1970,12 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o /* calculate volume preservation factor which is * basically the inverse of the y-scaling factor */ - if (fabs(scaleFac) != 0.0f) { - scale= 1.0 / fabs(scaleFac); + if (fabsf(scaleFac) != 0.0f) { + scale= 1.0f / fabsf(scaleFac); /* we need to clamp this within sensible values */ // NOTE: these should be fine for now, but should get sanitised in future - scale= MIN2(MAX2(scale, 0.0001) , 100000); + CLAMP(scale, 0.0001f, 100000.0f); } else scale= 1.0f; diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 286cd3b2499..11ea3384c96 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -233,7 +233,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * t = hit.dist/col.original_ray_length; /* avoid head-on collision */ - if(dot_v3v3(col.pce.nor, pa->prev_state.ave) < -0.99) { + if(dot_v3v3(col.pce.nor, pa->prev_state.ave) < -0.99f) { /* don't know why, but uneven range [0.0,1.0] */ /* works much better than even [-1.0,1.0] */ bbd->wanted_co[0] = BLI_frand(); @@ -439,7 +439,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va mul = dot_v3v3(vec, vec); /* leader is not moving */ - if(mul < 0.01) { + if(mul < 0.01f) { len = len_v3(loc); /* too close to leader */ if(len < 2.0f * val->personal_space * pa->size) { @@ -476,7 +476,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va else { VECCOPY(loc, flbr->oloc); sub_v3_v3v3(vec, flbr->loc, flbr->oloc); - mul_v3_fl(vec, 1.0/bbd->timestep); + mul_v3_fl(vec, 1.0f/bbd->timestep); } /* fac is seconds behind leader */ @@ -499,7 +499,7 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va mul = dot_v3v3(vec, vec); /* leader is not moving */ - if(mul < 0.01) { + if(mul < 0.01f) { len = len_v3(loc); /* too close to leader */ if(len < 2.0f * val->personal_space * pa->size) { @@ -730,7 +730,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData * if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) { val->max_speed = boids->land_max_speed * bpa->data.health/boids->health; val->max_acc = boids->land_max_acc * val->max_speed; - val->max_ave = boids->land_max_ave * M_PI * bpa->data.health/boids->health; + val->max_ave = boids->land_max_ave * (float)M_PI * bpa->data.health/boids->health; val->min_speed = 0.0f; /* no minimum speed on land */ val->personal_space = boids->land_personal_space; val->jump_speed = boids->land_jump_speed * bpa->data.health/boids->health; @@ -738,7 +738,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData * else { val->max_speed = boids->air_max_speed * bpa->data.health/boids->health; val->max_acc = boids->air_max_acc * val->max_speed; - val->max_ave = boids->air_max_ave * M_PI * bpa->data.health/boids->health; + val->max_ave = boids->air_max_ave * (float)M_PI * bpa->data.health/boids->health; val->min_speed = boids->air_min_speed * boids->air_max_speed; val->personal_space = boids->air_personal_space; val->jump_speed = 0.0f; /* no jumping in air */ @@ -872,7 +872,7 @@ static void boid_climb(BoidSettings *boids, ParticleData *pa, float *surface_co, VECCOPY(nor, surface_nor); /* gather apparent gravity */ - VECADDFAC(bpa->gravity, bpa->gravity, surface_nor, -1.0); + VECADDFAC(bpa->gravity, bpa->gravity, surface_nor, -1.0f); normalize_v3(bpa->gravity); /* raise boid it's size from surface */ @@ -1010,7 +1010,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) /* decide on jumping & liftoff */ if(bpa->data.mode == eBoidMode_OnLand) { /* fuzziness makes boids capable of misjudgement */ - float mul = 1.0 + state->rule_fuzziness; + float mul = 1.0f + state->rule_fuzziness; if(boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) { float cvel[3], dir[3]; @@ -1021,7 +1021,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) VECCOPY(cvel, bbd->wanted_co); normalize_v2(cvel); - if(dot_v2v2(cvel, dir) > 0.95 / mul) + if(dot_v2v2(cvel, dir) > 0.95f / mul) bpa->data.mode = eBoidMode_Liftoff; } else if(val.jump_speed > 0.0f) { @@ -1129,7 +1129,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); /* level = how many particle sizes above ground */ - level = (pa->prev_state.co[2] - ground_co[2])/(2.0f * pa->size) - 0.5; + level = (pa->prev_state.co[2] - ground_co[2])/(2.0f * pa->size) - 0.5f; landing_level = - boids->landing_smoothness * pa->prev_state.vel[2] * pa_mass; @@ -1328,7 +1328,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) boid_climb(boids, pa, ground_co, ground_nor); } /* land boid when really near ground */ - else if(pa->state.co[2] <= ground_co[2] + 1.01 * pa->size * boids->height){ + else if(pa->state.co[2] <= ground_co[2] + 1.01f * pa->size * boids->height){ pa->state.co[2] = ground_co[2] + pa->size * boids->height; pa->state.vel[2] = 0.0f; bpa->data.mode = eBoidMode_OnLand; @@ -1370,7 +1370,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) boid_climb(boids, pa, ground_co, ground_nor); } /* ground is too far away so boid falls */ - else if(pa->state.co[2]-ground_co[2] > 1.1 * pa->size * boids->height) + else if(pa->state.co[2]-ground_co[2] > 1.1f * pa->size * boids->height) bpa->data.mode = eBoidMode_Falling; else { /* constrain to surface */ @@ -1402,7 +1402,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* save direction to state.ave unless the boid is falling */ /* (boids can't effect their direction when falling) */ - if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1*pa->size) { + if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1f*pa->size) { copy_v3_v3(pa->state.ave, pa->state.vel); pa->state.ave[2] *= bbd->part->boids->pitch; normalize_v3(pa->state.ave); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 869123de97f..be73ee0656b 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -912,13 +912,13 @@ void brush_painter_break_stroke(BrushPainter *painter) static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pressure) { if (brush_use_alpha_pressure(brush)) - brush_set_alpha(brush, MAX2(0.0, painter->startalpha*pressure)); + brush_set_alpha(brush, MAX2(0.0f, painter->startalpha*pressure)); if (brush_use_size_pressure(brush)) - brush_set_size(brush, MAX2(1.0, painter->startsize*pressure)); + brush_set_size(brush, MAX2(1.0f, painter->startsize*pressure)); if (brush->flag & BRUSH_JITTER_PRESSURE) - brush->jitter = MAX2(0.0, painter->startjitter*pressure); + brush->jitter = MAX2(0.0f, painter->startjitter*pressure); if (brush->flag & BRUSH_SPACING_PRESSURE) - brush->spacing = MAX2(1.0, painter->startspacing*(1.5f-pressure)); + brush->spacing = MAX2(1.0f, painter->startspacing*(1.5f-pressure)); } void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) @@ -1075,7 +1075,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl else painter->accumtime -= painttime; - while (painter->accumtime >= brush->rate) { + while (painter->accumtime >= (double)brush->rate) { brush_apply_pressure(painter, brush, pressure); brush_jitter_pos(brush, pos, finalpos); @@ -1085,7 +1085,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl totpaintops += func(user, painter->cache.ibuf, painter->lastmousepos, finalpos); - painter->accumtime -= brush->rate; + painter->accumtime -= (double)brush->rate; } painter->lasttime= curtime; @@ -1111,7 +1111,7 @@ float brush_curve_strength_clamp(Brush *br, float p, const float len) else p= p/len; p= curvemapping_evaluateF(br->curve, 0, p); - if(p < 0.0) p= 0.0f; + if(p < 0.0f) p= 0.0f; else if(p > 1.0f) p= 1.0f; return p; } @@ -1158,10 +1158,10 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) * if the texture didn't give an RGB value, copy the intensity across */ if(hasrgb & TEX_RGB) - texres.tin = (0.35 * texres.tr + 0.45 * - texres.tg + 0.2 * texres.tb); + texres.tin = (0.35f * texres.tr + 0.45f * + texres.tg + 0.2f * texres.tb); - texres.tin = texres.tin * 255.0; + texres.tin = texres.tin * 255.0f; ((char*)texcache)[(iy*side+ix)*4] = (char)texres.tin; ((char*)texcache)[(iy*side+ix)*4+1] = (char)texres.tin; ((char*)texcache)[(iy*side+ix)*4+2] = (char)texres.tin; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index d3afb93b5dd..5520e4d1d41 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -131,7 +131,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else { - if(fabs(A00) > FLT_EPSILON) + if(fabsf(A00) > FLT_EPSILON) S = -B0/A00; else S = 0.0f; @@ -156,7 +156,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else { - if(fabs(A11) > FLT_EPSILON) + if(fabsf(A11) > FLT_EPSILON) T = -B1 / A11; else T = 0.0f; @@ -182,7 +182,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else { - if(fabs(A11) > FLT_EPSILON) + if(fabsf(A11) > FLT_EPSILON) T = -B1 / A11; else T = 0.0; @@ -208,7 +208,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else { - if(fabs(A00) > FLT_EPSILON) + if(fabsf(A00) > FLT_EPSILON) S = -B0 / A00; else S = 0.0f; @@ -220,7 +220,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const { // Minimum at interior lv float invDet; - if(fabs(Det) > FLT_EPSILON) + if(fabsf(Det) > FLT_EPSILON) invDet = 1.0f / Det; else invDet = 0.0f; @@ -251,7 +251,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else { - if(fabs(denom) > FLT_EPSILON) + if(fabsf(denom) > FLT_EPSILON) S = numer / denom; else S = 0.0f; @@ -278,7 +278,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else { - if(fabs(A11) > FLT_EPSILON) + if(fabsf(A11) > FLT_EPSILON) T = -B1 / A11; else T = 0.0f; @@ -304,7 +304,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else { - if(fabs(denom) > FLT_EPSILON) + if(fabsf(denom) > FLT_EPSILON) T = numer / denom; else T = 0.0f; @@ -331,7 +331,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else { - if(fabs(A00) > FLT_EPSILON) + if(fabsf(A00) > FLT_EPSILON) S = -B0 / A00; else S = 0.0f; @@ -362,7 +362,7 @@ static float nearest_point_in_tri_surface(const float *v0,const float *v1,const } else { - if(fabs(denom) > FLT_EPSILON) + if(fabsf(denom) > FLT_EPSILON) S = numer / denom; else S = 0.0f; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index fc0d5d90687..cbe7382c3a9 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1604,9 +1604,7 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *UNUSED(me)) VECCOPY(mv->co, eve->co); - mv->no[0] = eve->no[0] * 32767.0; - mv->no[1] = eve->no[1] * 32767.0; - mv->no[2] = eve->no[2] * 32767.0; + normal_float_to_short_v3(mv->no, eve->no); mv->bweight = (unsigned char) (eve->bweight * 255.0f); mv->flag = 0; diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index b4c69bddefc..46f3e124bcc 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -421,14 +421,14 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex } if(bezt->h1==HD_VECT) { /* vector */ - dx/=3.0; - dy/=3.0; + dx/=3.0f; + dy/=3.0f; *(p2-3)= *p2-dx; *(p2-2)= *(p2+1)-dy; } if(bezt->h2==HD_VECT) { - dx1/=3.0; - dy1/=3.0; + dx1/=3.0f; + dy1/=3.0f; *(p2+3)= *p2+dx1; *(p2+4)= *(p2+1)+dy1; } @@ -700,7 +700,7 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) for(a=0; atotpoint-1; a++) { dx= cmp[a].x - cmp[a+1].x; dy= cmp[a].y - cmp[a+1].y; - if( sqrt(dx*dx + dy*dy) < thresh ) { + if( sqrtf(dx*dx + dy*dy) < thresh ) { if(a==0) { cmp[a+1].flag|= 2; if(cmp[a+1].flag & CUMA_SELECT) @@ -962,7 +962,7 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size) DO_INLINE int get_bin_float(float f) { - int bin= (int)((f*255) + 0.5); /* 0.5 to prevent quantisation differences */ + int bin= (int)((f*255.0f) + 0.5f); /* 0.5 to prevent quantisation differences */ /* note: clamp integer instead of float to avoid problems with NaN */ CLAMP(bin, 0, 255); @@ -1054,7 +1054,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) bin_lum = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); /* convert to number of lines with logarithmic scale */ - scopes->sample_lines = (scopes->accuracy*0.01) * (scopes->accuracy*0.01) * ibuf->y; + scopes->sample_lines = (scopes->accuracy*0.01f) * (scopes->accuracy*0.01f) * ibuf->y; if (scopes->sample_full) scopes->sample_lines = ibuf->y; @@ -1105,7 +1105,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) } /* we still need luma for histogram */ - luma = 0.299*rgb[0] + 0.587*rgb[1] + 0.114 * rgb[2]; + luma = 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2]; /* check for min max */ if(ycc_mode == -1 ) { @@ -1155,8 +1155,8 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) if (bin_lum[x] > nl) nl = bin_lum[x]; } - div = 1.f/(double)n; - divl = 1.f/(double)nl; + div = 1.0/(double)n; + divl = 1.0/(double)nl; for (x=0; x<256; x++) { scopes->hist.data_r[x] = bin_r[x] * div; scopes->hist.data_g[x] = bin_g[x] * div; diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 710e7a28041..4e5a1977ab0 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -790,7 +790,7 @@ static const char *data_mode_strings[] = { "sculpt_mode", "weightpaint", "vertexpaint", - "texturepaint", + "imagepaint", "particlemode", "objectmode", NULL diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 105c357906f..7a5e0d5c33d 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -333,19 +333,19 @@ void tex_space_curve(Curve *cu) cu->size[1]= (max[1]-min[1])/2.0f; cu->size[2]= (max[2]-min[2])/2.0f; - cu->rot[0]= cu->rot[1]= cu->rot[2]= 0.0; + cu->rot[0]= cu->rot[1]= cu->rot[2]= 0.0f; - if(cu->size[0]==0.0) cu->size[0]= 1.0; - else if(cu->size[0]>0.0 && cu->size[0]<0.00001) cu->size[0]= 0.00001; - else if(cu->size[0]<0.0 && cu->size[0]> -0.00001) cu->size[0]= -0.00001; + if(cu->size[0]==0.0f) cu->size[0]= 1.0f; + else if(cu->size[0]>0.0f && cu->size[0]<0.00001f) cu->size[0]= 0.00001f; + else if(cu->size[0]<0.0f && cu->size[0]> -0.00001f) cu->size[0]= -0.00001f; - if(cu->size[1]==0.0) cu->size[1]= 1.0; - else if(cu->size[1]>0.0 && cu->size[1]<0.00001) cu->size[1]= 0.00001; - else if(cu->size[1]<0.0 && cu->size[1]> -0.00001) cu->size[1]= -0.00001; + if(cu->size[1]==0.0f) cu->size[1]= 1.0f; + else if(cu->size[1]>0.0f && cu->size[1]<0.00001f) cu->size[1]= 0.00001f; + else if(cu->size[1]<0.0f && cu->size[1]> -0.00001f) cu->size[1]= -0.00001f; - if(cu->size[2]==0.0) cu->size[2]= 1.0; - else if(cu->size[2]>0.0 && cu->size[2]<0.00001) cu->size[2]= 0.00001; - else if(cu->size[2]<0.0 && cu->size[2]> -0.00001) cu->size[2]= -0.00001; + if(cu->size[2]==0.0f) cu->size[2]= 1.0f; + else if(cu->size[2]>0.0f && cu->size[2]<0.00001f) cu->size[2]= 0.00001f; + else if(cu->size[2]<0.0f && cu->size[2]> -0.00001f) cu->size[2]= -0.00001f; } } @@ -590,7 +590,7 @@ static void calcknots(float *knots, short aantal, short order, short type) k= 0.0; for(a=1;a<=t;a++) { knots[a-1]= k; - if(a>=order && a<=aantal) k+= 1.0; + if(a>=order && a<=aantal) k+= 1.0f; } } else if(type==2) { @@ -598,15 +598,15 @@ static void calcknots(float *knots, short aantal, short order, short type) if(order==4) { k= 0.34; for(a=0;a=order && a<=aantal) k+= (0.5); - knots[a]= (float)floor(k); + if(a>=order && a<=aantal) k+= 0.5f; + knots[a]= floorf(k); } } else { @@ -630,7 +630,7 @@ static void makecyclicknots(float *knots, short pnts, short order) for(a=1; a= orderpluspnts) i2= opp2-j; for(i= i1; i<=i2; i++) { - if(basis[i]!=0.0) + if(basis[i]!=0.0f) d= ((t-knots[i])*basis[i]) / (knots[i+j-1]-knots[i]); else - d= 0.0; + d= 0.0f; - if(basis[i+1]!=0.0) + if(basis[i+1] != 0.0f) e= ((knots[i+j]-t)*basis[i+1]) / (knots[i+j]-knots[i+1]); else e= 0.0; @@ -740,7 +740,7 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas *end= 0; for(i=i1; i<=i2; i++) { - if(basis[i]>0.0) { + if(basis[i] > 0.0f) { *end= i; if(*start==1000) *start= i; } @@ -782,7 +782,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int i= nu->pntsu*nu->pntsv; ratcomp=0; while(i--) { - if(bp->vec[3]!=1.0) { + if(bp->vec[3] != 1.0f) { ratcomp= 1; break; } @@ -888,7 +888,7 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int } else bp++; - if(*fp!=0.0) { + if(*fp != 0.0f) { in[0]+= (*fp) * bp->vec[0]; in[1]+= (*fp) * bp->vec[1]; in[2]+= (*fp) * bp->vec[2]; @@ -964,7 +964,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu *fp= basisu[i]*bp->vec[3]; sumdiv+= *fp; } - if(sumdiv!=0.0) if(sumdiv<0.999 || sumdiv>1.001) { + if(sumdiv != 0.0f) if(sumdiv < 0.999f || sumdiv > 1.001f) { /* is normalizing needed? */ fp= sum; for(i= istart; i<=iend; i++, fp++) { @@ -980,7 +980,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu if(i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu); else bp++; - if(*fp!=0.0) { + if(*fp != 0.0f) { coord_fp[0]+= (*fp) * bp->vec[0]; coord_fp[1]+= (*fp) * bp->vec[1]; @@ -1264,7 +1264,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) if (cu->bevobj->type!=OB_CURVE) return; bevcu= cu->bevobj->data; - if(bevcu->ext1==0.0 && bevcu->ext2==0.0) { + if(bevcu->ext1==0.0f && bevcu->ext2==0.0f) { ListBase bevdisp= {NULL, NULL}; facx= cu->bevobj->size[0]; facy= cu->bevobj->size[1]; @@ -1305,10 +1305,10 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) freedisplist(&bevdisp); } } - else if(cu->ext1==0.0 && cu->ext2==0.0) { + else if(cu->ext1==0.0f && cu->ext2==0.0f) { ; } - else if(cu->ext2==0.0) { + else if(cu->ext2==0.0f) { dl= MEM_callocN(sizeof(DispList), "makebevelcurve2"); dl->verts= MEM_mallocN(2*3*sizeof(float), "makebevelcurve2"); BLI_addtail(disp, dl); @@ -1337,13 +1337,13 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) /* a circle */ fp= dl->verts; - dangle= (2.0f*M_PI/(nr)); + dangle= (2.0f*(float)M_PI/(nr)); angle= -(nr-1)*dangle; for(a=0; aext2)); - fp[2]= (float)(sin(angle)*(cu->ext2)) - cu->ext1; + fp[1]= (cosf(angle)*(cu->ext2)); + fp[2]= (sinf(angle)*(cu->ext2)) - cu->ext1; angle+= dangle; fp+= 3; } @@ -1374,15 +1374,15 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) for(a=0; aext2)); - fp[2]= (float)(sin(angle)*(cu->ext2)) - cu->ext1; + fp[1]= (float)(cosf(angle)*(cu->ext2)); + fp[2]= (float)(sinf(angle)*(cu->ext2)) - cu->ext1; angle+= dangle; fp+= 3; } } /* part 2, sidefaces */ - if(cu->ext1!=0.0) { + if(cu->ext1!=0.0f) { nr= 2; dl= MEM_callocN(sizeof(DispList), "makebevelcurve p2"); @@ -1432,8 +1432,8 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) for(a=0; aext2)); - fp[2]= (float)(sin(angle)*(cu->ext2)) + cu->ext1; + fp[1]= (float)(cosf(angle)*(cu->ext2)); + fp[2]= (float)(sinf(angle)*(cu->ext2)) + cu->ext1; angle+= dangle; fp+= 3; } @@ -1452,7 +1452,7 @@ static int cu_isectLL(float *v1, float *v2, float *v3, float *v4, short cox, sho float deler; deler= (v1[cox]-v2[cox])*(v3[coy]-v4[coy])-(v3[cox]-v4[cox])*(v1[coy]-v2[coy]); - if(deler==0.0) return -1; + if(deler==0.0f) return -1; *labda= (v1[coy]-v3[coy])*(v3[cox]-v4[cox])-(v1[cox]-v3[cox])*(v3[coy]-v4[coy]); *labda= -(*labda/deler); @@ -1467,8 +1467,8 @@ static int cu_isectLL(float *v1, float *v2, float *v3, float *v4, short cox, sho vec[cox]= *labda*(v2[cox]-v1[cox])+v1[cox]; vec[coy]= *labda*(v2[coy]-v1[coy])+v1[coy]; - if(*labda>=0.0 && *labda<=1.0 && *mu>=0.0 && *mu<=1.0) { - if(*labda==0.0 || *labda==1.0 || *mu==0.0 || *mu==1.0) return 1; + if(*labda>=0.0f && *labda<=1.0f && *mu>=0.0f && *mu<=1.0f) { + if(*labda==0.0f || *labda==1.0f || *mu==0.0f || *mu==1.0f) return 1; return 2; } return 0; @@ -1513,7 +1513,7 @@ static short bevelinside(BevList *bl1,BevList *bl2) /* if lab==0.0 or lab==1.0 then the edge intersects exactly a transition only allow for one situation: we choose lab= 1.0 */ - if(mode>=0 && lab!=0.0) { + if(mode >= 0 && lab != 0.0f) { if(vec[0]nr; while(nr--) { - if(RAD2DEG(angle_v2v2(bevp0->tan, bevp1->tan)) > 90) + if(RAD2DEGF(angle_v2v2(bevp0->tan, bevp1->tan)) > 90.0f) negate_v3(bevp1->tan); bevp0= bevp1; @@ -1889,7 +1889,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) /* flip rotation if needs be */ cross_v3_v3v3(cross_tmp, vec_1, vec_2); normalize_v3(cross_tmp); - if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90/(180.0/M_PI)) + if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90.0f/(float)(180.0/M_PI)) angle = -angle; bevp2= (BevPoint *)(bl+1); @@ -2283,7 +2283,7 @@ void makeBevelList(Object *ob) inp= (bevp1->vec[0]- bevp0->vec[0]) * (bevp0->vec[1]- bevp2->vec[1]) + (bevp0->vec[1]- bevp1->vec[1]) * (bevp0->vec[0]- bevp2->vec[0]); - if(inp>0.0) sd->dir= 1; + if(inp > 0.0f) sd->dir= 1; else sd->dir= 0; sd++; @@ -2483,11 +2483,11 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) if(mode==2 && next && prev) { // keep horizontal if extrema float ydiff1= prev->vec[1][1] - bezt->vec[1][1]; float ydiff2= next->vec[1][1] - bezt->vec[1][1]; - if( (ydiff1<=0.0 && ydiff2<=0.0) || (ydiff1>=0.0 && ydiff2>=0.0) ) { + if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) { bezt->vec[0][1]= bezt->vec[1][1]; } else { // handles should not be beyond y coord of two others - if(ydiff1<=0.0) { + if(ydiff1 <= 0.0f) { if(prev->vec[1][1] > bezt->vec[0][1]) { bezt->vec[0][1]= prev->vec[1][1]; leftviolate= 1; @@ -2511,11 +2511,11 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) if(mode==2 && next && prev) { // keep horizontal if extrema float ydiff1= prev->vec[1][1] - bezt->vec[1][1]; float ydiff2= next->vec[1][1] - bezt->vec[1][1]; - if( (ydiff1<=0.0 && ydiff2<=0.0) || (ydiff1>=0.0 && ydiff2>=0.0) ) { + if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) { bezt->vec[2][1]= bezt->vec[1][1]; } else { // handles should not be beyond y coord of two others - if(ydiff1<=0.0) { + if(ydiff1 <= 0.0f) { if(next->vec[1][1] < bezt->vec[2][1]) { bezt->vec[2][1]= next->vec[1][1]; rightviolate= 1; @@ -2556,17 +2556,17 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) } if(bezt->h1==HD_VECT) { /* vector */ - dx/=3.0; - dy/=3.0; - dz/=3.0; + dx/=3.0f; + dy/=3.0f; + dz/=3.0f; *(p2-3)= *p2-dx; *(p2-2)= *(p2+1)-dy; *(p2-1)= *(p2+2)-dz; } if(bezt->h2==HD_VECT) { - dx1/=3.0; - dy1/=3.0; - dz1/=3.0; + dx1/=3.0f; + dy1/=3.0f; + dz1/=3.0f; *(p2+3)= *p2+dx1; *(p2+4)= *(p2+1)+dy1; *(p2+5)= *(p2+2)+dz1; @@ -2574,8 +2574,8 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) len2= len_v3v3(p2, p2+3); len1= len_v3v3(p2, p2-3); - if(len1==0.0) len1=1.0; - if(len2==0.0) len2=1.0; + if(len1==0.0f) len1= 1.0f; + if(len2==0.0f) len2= 1.0f; if(bezt->f1 & SELECT) { /* order of calculation */ if(bezt->h2==HD_ALIGN) { /* aligned */ @@ -2700,18 +2700,18 @@ void autocalchandlesNurb(Nurb *nu, int flag) if(flag==0 || (bezt1->f1 & flag) ) { bezt1->h1= 0; /* distance too short: vectorhandle */ - if( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001) { + if( len_v3v3( bezt1->vec[1], bezt0->vec[1] ) < 0.0001f) { bezt1->h1= HD_VECT; leftsmall= 1; } else { /* aligned handle? */ - if(dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001) { + if(dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001f) { align= 1; bezt1->h1= HD_ALIGN; } /* or vector handle? */ - if(dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001) + if(dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001f) bezt1->h1= HD_VECT; } @@ -2720,7 +2720,7 @@ void autocalchandlesNurb(Nurb *nu, int flag) if(flag==0 || (bezt1->f3 & flag) ) { bezt1->h2= 0; /* distance too short: vectorhandle */ - if( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001) { + if( len_v3v3( bezt1->vec[1], bezt2->vec[1] ) < 0.0001f) { bezt1->h2= HD_VECT; rightsmall= 1; } @@ -2729,7 +2729,7 @@ void autocalchandlesNurb(Nurb *nu, int flag) if(align) bezt1->h2= HD_ALIGN; /* or vector handle? */ - if(dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001) + if(dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001f) bezt1->h2= HD_VECT; } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 35c4fb5311c..c8e5998774d 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -178,8 +178,8 @@ void addnormalsDispList(ListBase *lb) if(dl->type==DL_INDEX3) { if(dl->nors==NULL) { dl->nors= MEM_callocN(sizeof(float)*3, "dlnors"); - if(dl->verts[2]<0.0) dl->nors[2]= -1.0; - else dl->nors[2]= 1.0; + if(dl->verts[2] < 0.0f) dl->nors[2]= -1.0f; + else dl->nors[2]= 1.0f; } } else if(dl->type==DL_SURF) { @@ -413,10 +413,10 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co VECCOPY(shi.orn, shi.vn); } if(ma->texco & TEXCO_REFL) { - float inp= 2.0*(shi.vn[2]); + float inp= 2.0f * (shi.vn[2]); shi.ref[0]= (inp*shi.vn[0]); shi.ref[1]= (inp*shi.vn[1]); - shi.ref[2]= (-1.0+inp*shi.vn[2]); + shi.ref[2]= (-1.0f + inp*shi.vn[2]); } } @@ -589,9 +589,7 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un mul_v3_m4v3(vec, mat, mv->co); - vec[0]+= 0.001*vn[0]; - vec[1]+= 0.001*vn[1]; - vec[2]+= 0.001*vn[2]; + mul_v3_v3fl(vec, vn, 0.001f); fastshade_customdata(&dm->faceData, i, j, ma); fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2); @@ -1160,7 +1158,7 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) /* horizontal size */ minx= dl->verts[0]; dx= dl->verts[3*(dl->nr-1)] - minx; - if(dx>0.0) { + if(dx > 0.0f) { fp= dl->verts; for(a=0; anr; a++, fp+=3) { @@ -1741,7 +1739,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (!dlbev.first && cu->width==1.0f) { curve_to_displist(cu, nubase, dispbase, forRender); } else { - float widfac= cu->width-1.0; + float widfac= cu->width - 1.0f; BevList *bl= cu->bev.first; Nurb *nu= nubase->first; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 216dffc1e4a..ee46bef6038 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -495,7 +495,7 @@ static float wind_func(struct RNG *rng, float strength) float ret; float sign = 0; - sign = ((float)random > 64.0) ? 1.0: -1.0; // dividing by 2 is not giving equal sign distribution + sign = ((float)random > 64.0f) ? 1.0f: -1.0f; // dividing by 2 is not giving equal sign distribution ret = sign*((float)random / force)*strength/128.0f; @@ -517,7 +517,7 @@ static float falloff_func(float fac, int usemin, float mindist, int usemax, floa if(!usemin) mindist = 0.0; - return pow((double)1.0+fac-mindist, (double)-power); + return pow((double)(1.0f+fac-mindist), (double)(-power)); } static float falloff_func_dist(PartDeflect *pd, float fac) @@ -653,7 +653,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin sim.psys= eff->psys; /* TODO: time from actual previous calculated frame (step might not be 1) */ - state.time = cfra - 1.0; + state.time = cfra - 1.0f; ret = psys_get_particle_state(&sim, *efd->index, &state, 0); /* TODO */ @@ -687,13 +687,16 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin /* use z-axis as normal*/ normalize_v3_v3(efd->nor, ob->obmat[2]); - /* for vortex the shape chooses between old / new force */ if(eff->pd && eff->pd->shape == PFIELD_SHAPE_PLANE) { - /* efd->loc is closes point on effector xy-plane */ float temp[3], translate[3]; sub_v3_v3v3(temp, point->loc, ob->obmat[3]); project_v3_v3v3(translate, temp, efd->nor); - add_v3_v3v3(efd->loc, ob->obmat[3], translate); + + /* for vortex the shape chooses between old / new force */ + if(eff->pd->forcefield == PFIELD_VORTEX) + add_v3_v3v3(efd->loc, ob->obmat[3], translate); + else /* normally efd->loc is closest point on effector xy-plane */ + sub_v3_v3v3(efd->loc, point->loc, translate); } else { VECCOPY(efd->loc, ob->obmat[3]); @@ -702,7 +705,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin if(real_velocity) { VECCOPY(efd->vel, ob->obmat[3]); - where_is_object_time(eff->scene, ob, cfra - 1.0); + where_is_object_time(eff->scene, ob, cfra - 1.0f); sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]); } @@ -928,10 +931,10 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected case PFIELD_LENNARDJ: fac = pow((efd->size + point->size) / efd->distance, 6.0); - fac = - fac * (1.0 - fac) / efd->distance; + fac = - fac * (1.0f - fac) / efd->distance; /* limit the repulsive term drastically to avoid huge forces */ - fac = ((fac>2.0) ? 2.0 : fac); + fac = ((fac>2.0f) ? 2.0f : fac); mul_v3_fl(force, strength * fac); break; diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index c749655cdc2..7cb3adf96bf 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -182,12 +182,10 @@ static void mesh_add_normals_flags(Mesh *me) v2= me->mvert+mface->v2; v3= me->mvert+mface->v3; v4= me->mvert+mface->v4; - + normal_tri_v3( nor,v1->co, v2->co, v3->co); - sno[0]= 32767.0*nor[0]; - sno[1]= 32767.0*nor[1]; - sno[2]= 32767.0*nor[2]; - + normal_float_to_short_v3(sno, nor); + simple_vertex_normal_blend(v1->no, sno); simple_vertex_normal_blend(v2->no, sno); simple_vertex_normal_blend(v3->no, sno); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index a5391ee20cc..b1272ee2d53 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1119,7 +1119,7 @@ static float dvar_eval_rotDiff (ChannelDriver *driver, DriverVar *dvar) angle = 2.0f * (saacos(quat[0])); angle= ABS(angle); - return (angle > M_PI) ? (float)((2.0f * M_PI) - angle) : (float)(angle); + return (angle > (float)M_PI) ? (float)((2.0f * (float)M_PI) - angle) : (float)(angle); } /* evaluate 'location difference' driver variable */ @@ -1652,9 +1652,9 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o) int nr= 0; c0= q0 - x; - c1= 3.0 * (q1 - q0); - c2= 3.0 * (q0 - 2.0*q1 + q2); - c3= q3 - q0 + 3.0 * (q1 - q2); + c1= 3.0f * (q1 - q0); + c2= 3.0f * (q0 - 2.0f*q1 + q2); + c3= q3 - q0 + 3.0f * (q1 - q2); if (c3 != 0.0) { a= c2/c3; @@ -1670,17 +1670,17 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o) t= sqrt(d); o[0]= (float)(sqrt3d(-q+t) + sqrt3d(-q-t) - a); - if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1; + if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1; else return 0; } else if (d == 0.0) { t= sqrt3d(-q); o[0]= (float)(2*t - a); - if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++; + if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++; o[nr]= (float)(-t-a); - if ((o[nr] >= SMALL) && (o[nr] <= 1.000001)) return nr+1; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1; else return nr; } else { @@ -1690,13 +1690,13 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o) q= sqrt(3 - 3*p*p); o[0]= (float)(2*t*p - a); - if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++; + if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++; o[nr]= (float)(-t * (p + q) - a); - if ((o[nr] >= SMALL) && (o[nr] <= 1.000001)) nr++; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) nr++; o[nr]= (float)(-t * (p - q) - a); - if ((o[nr] >= SMALL) && (o[nr] <= 1.000001)) return nr+1; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1; else return nr; } } @@ -1713,22 +1713,22 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o) p= sqrt(p); o[0]= (float)((-b-p) / (2 * a)); - if ((o[0] >= SMALL) && (o[0] <= 1.000001)) nr++; + if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++; o[nr]= (float)((-b+p)/(2*a)); - if ((o[nr] >= SMALL) && (o[nr] <= 1.000001)) return nr+1; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1; else return nr; } else if (p == 0) { o[0]= (float)(-b / (2 * a)); - if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1; + if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1; else return 0; } } else if (b != 0.0) { o[0]= (float)(-c/b); - if ((o[0] >= SMALL) && (o[0] <= 1.000001)) return 1; + if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1; else return 0; } else if (c == 0.0) { diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 25d6860cb50..844f25e6d21 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -346,7 +346,7 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa case FCM_GENERATOR_FN_LN: /* natural log */ { /* check that value is greater than 1? */ - if (arg > 1.0f) { + if (arg > 1.0) { fn= log; } else { @@ -358,7 +358,7 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa case FCM_GENERATOR_FN_SQRT: /* square root */ { /* no negative numbers */ - if (arg > 0.0f) { + if (arg > 0.0) { fn= sqrt; } else { @@ -374,7 +374,7 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa /* execute function callback to set value if appropriate */ if (fn) { - float value= (float)(data->amplitude*fn(arg) + data->value_offset); + float value= (float)(data->amplitude*(float)fn(arg) + data->value_offset); if (data->flag & FCM_GENERATOR_ADDITIVE) *cvalue += value; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index b521dbad17a..5c1922b469b 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -490,19 +490,19 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i nu2->bp[0].vec[0] = x1; nu2->bp[0].vec[1] = y1; nu2->bp[0].vec[2] = 0; - nu2->bp[0].vec[3] = 1.0; + nu2->bp[0].vec[3] = 1.0f; nu2->bp[1].vec[0] = x2; nu2->bp[1].vec[1] = y1; nu2->bp[1].vec[2] = 0; - nu2->bp[1].vec[3] = 1.0; + nu2->bp[1].vec[3] = 1.0f; nu2->bp[2].vec[0] = x2; nu2->bp[2].vec[1] = y2; nu2->bp[2].vec[2] = 0; - nu2->bp[2].vec[3] = 1.0; + nu2->bp[2].vec[3] = 1.0f; nu2->bp[3].vec[0] = x1; nu2->bp[3].vec[1] = y2; nu2->bp[3].vec[2] = 0; - nu2->bp[3].vec[3] = 1.0; + nu2->bp[3].vec[3] = 1.0f; BLI_addtail(&(cu->nurb), nu2); @@ -574,7 +574,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float memcpy(bezt2, bezt1, i * sizeof(struct BezTriple)); nu2->bezt = bezt2; - if (shear != 0.0) { + if (shear != 0.0f) { bezt2 = nu2->bezt; for (i= nu2->pntsu; i > 0; i--) { @@ -584,7 +584,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float bezt2++; } } - if(rot!=0.0) { + if(rot != 0.0f) { bezt2= nu2->bezt; for (i=nu2->pntsu; i > 0; i--) { fp= bezt2->vec[0]; @@ -709,8 +709,8 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) // Count the wchar_t string length slen = wcslen(mem); - if (cu->ulheight == 0.0) - cu->ulheight = 0.05; + if (cu->ulheight == 0.0f) + cu->ulheight = 0.05f; if (cu->strinfo==NULL) /* old file */ cu->strinfo = MEM_callocN((slen+4) * sizeof(CharInfo), "strinfo compat"); @@ -815,7 +815,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) twidth = char_width(cu, che, info); // Calculate positions - if((tb->w != 0.0) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w + cu->xof*cu->fsize) { + if((tb->w != 0.0f) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w + cu->xof*cu->fsize) { // fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]); for (j=i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak==0); j--) { if (mem[j]==' ' || mem[j]=='-') { @@ -855,7 +855,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) linedata3[lnr]= tb->w/cu->fsize; linedata4[lnr]= wsnr; - if ( (tb->h != 0.0) && + if ( (tb->h != 0.0f) && ((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize)) - cu->yof) && (cu->totbox > (curbox+1)) ) { maxlen= 0; @@ -886,7 +886,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) ct->charnr= cnr++; tabfac= (xof-cu->xof+0.01f); - tabfac= (float)(2.0*ceil(tabfac/2.0)); + tabfac= 2.0f*ceilf(tabfac/2.0f); xof= cu->xof+tabfac; } else { @@ -900,7 +900,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) if (cu->selboxes && (i>=selstart) && (i<=selend)) { sb = &(cu->selboxes[i-selstart]); - sb->y = yof*cu->fsize-linedist*cu->fsize*0.1; + sb->y = yof*cu->fsize-linedist*cu->fsize*0.1f; sb->h = linedist*cu->fsize; sb->w = xof*cu->fsize; } @@ -909,12 +909,12 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) wsfac = cu->wordspace; wsnr++; } - else wsfac = 1.0; + else wsfac = 1.0f; // Set the width of the character twidth = char_width(cu, che, info); - xof += (twidth*wsfac*(1.0+(info->kern/40.0)) ) + xtrax; + xof += (twidth*wsfac*(1.0f+(info->kern/40.0f)) ) + xtrax; if (sb) sb->w = (xof*cu->fsize) - sb->w; @@ -951,7 +951,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) ct++; } } else if((cu->spacemode==CU_FLUSH) && - (cu->tb[0].w != 0.0)) { + (cu->tb[0].w != 0.0f)) { for(i=0;i1) linedata[i]= (linedata3[i]-linedata[i])/(linedata2[i]-1); @@ -964,7 +964,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) ct++; } } - else if((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0)) { + else if((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) { float curofs= 0.0f; for (i=0; i<=slen; i++) { for (j=i; (mem[j]) && (mem[j]!='\n') && @@ -1015,9 +1015,9 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) /* length correction */ distfac= sizefac*cucu->path->totdist/(maxx-minx); - timeofs= 0.0; + timeofs= 0.0f; - if(distfac > 1.0) { + if(distfac > 1.0f) { /* path longer than text: spacemode involves */ distfac= 1.0f/distfac; @@ -1051,7 +1051,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) dtime= distfac*0.5f*twidth; ctime= timeofs + distfac*( ct->xof - minx); - CLAMP(ctime, 0.0, 1.0); + CLAMP(ctime, 0.0f, 1.0f); /* calc the right loc AND the right rot separately */ /* vec, tvec need 4 items */ @@ -1173,17 +1173,17 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) if ( (i<(slen-1)) && (mem[i+1] != '\n') && (mem[i+1] != '\r') && ((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_CHINFO_UNDERLINE)) && ((custrinfo[i+1].flag & CU_CHINFO_WRAP)==0) ) { - uloverlap = xtrax + 0.1; + uloverlap = xtrax + 0.1f; } // Find the character, the characters has to be in the memory already // since character checking has been done earlier already. che= find_vfont_char(vfd, cha); twidth = char_width(cu, che, info); - ulwidth = cu->fsize * ((twidth* (1.0+(info->kern/40.0)))+uloverlap); - build_underline(cu, ct->xof*cu->fsize, ct->yof*cu->fsize + (cu->ulpos-0.05)*cu->fsize, + ulwidth = cu->fsize * ((twidth* (1.0f+(info->kern/40.0f)))+uloverlap); + build_underline(cu, ct->xof*cu->fsize, ct->yof*cu->fsize + (cu->ulpos-0.05f)*cu->fsize, ct->xof*cu->fsize + ulwidth, - ct->yof*cu->fsize + (cu->ulpos-0.05)*cu->fsize - cu->ulheight*cu->fsize, + ct->yof*cu->fsize + (cu->ulpos-0.05f)*cu->fsize - cu->ulheight*cu->fsize, i, info->mat_nr); } ct++; diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 1a1b073352e..8f6408f1939 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -161,8 +161,8 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt /* Utility functions for BKE_image_buf_fill_checker_color */ -#define BLEND_FLOAT(real, add) (real+add <= 1.0) ? (real+add) : 1.0 -#define BLEND_CHAR(real, add) ((real + (char)(add * 255.0)) <= 255) ? (real + (char)(add * 255.0)) : 255 +#define BLEND_FLOAT(real, add) (real+add <= 1.0f) ? (real+add) : 1.0f +#define BLEND_CHAR(real, add) ((real + (char)(add * 255.0f)) <= 255) ? (real + (char)(add * 255.0f)) : 255 static int is_pow2(int n) { diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index f8c7a71f210..4b532362cd8 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -422,7 +422,7 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl) t[3]= k1->pos+ofs; k[3]= k1; - if(ofs>2.1+lastpos) break; + if(ofs > 2.1f + lastpos) break; } bsplinetype= 0; @@ -448,7 +448,7 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl) } d= t[2]-t[1]; - if(d==0.0) { + if(d == 0.0f) { if(bsplinetype==0) { return 1; /* both keys equal */ } @@ -649,8 +649,8 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key /* are we going to be nasty? */ if(flagflo) { ktot+= kd; - while(ktot>=1.0) { - ktot-= 1.0; + while(ktot >= 1.0f) { + ktot -= 1.0f; k1+= elemsize; kref+= elemsize; } @@ -953,8 +953,8 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key if(flagdo & 1) { if(flagflo & 1) { k1tot+= k1d; - while(k1tot>=1.0) { - k1tot-= 1.0; + while(k1tot >= 1.0f) { + k1tot -= 1.0f; k1+= elemsize; } } @@ -963,8 +963,8 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key if(flagdo & 2) { if(flagflo & 2) { k2tot+= k2d; - while(k2tot>=1.0) { - k2tot-= 1.0; + while(k2tot >= 1.0f) { + k2tot -= 1.0f; k2+= elemsize; } } @@ -973,8 +973,8 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key if(flagdo & 4) { if(flagflo & 4) { k3tot+= k3d; - while(k3tot>=1.0) { - k3tot-= 1.0; + while(k3tot >= 1.0f) { + k3tot -= 1.0f; k3+= elemsize; } } @@ -983,8 +983,8 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key if(flagdo & 8) { if(flagflo & 8) { k4tot+= k4d; - while(k4tot>=1.0) { - k4tot-= 1.0; + while(k4tot >= 1.0f) { + k4tot -= 1.0f; k4+= elemsize; } } @@ -1473,7 +1473,7 @@ KeyBlock *add_keyblock(Key *key, const char *name) // XXX kb->pos is the confusing old horizontal-line RVK crap in old IPO Editor... if(key->type == KEY_RELATIVE) - kb->pos= curpos+0.1; + kb->pos= curpos + 0.1f; else { #if 0 // XXX old animation system curpos= bsystem_time(scene, 0, (float)CFRA, 0.0); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index f66afff0741..9d93bb1c25d 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -1031,13 +1031,8 @@ void lattice_calc_modifiers(Scene *scene, Object *ob) struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt) { - if(oblatt->type == OB_LATTICE) - { - Lattice *lt = (Lattice*)oblatt->data; - if(lt->editlatt) lt= lt->editlatt->latt; - return lt->dvert; - } - - return NULL; + Lattice *lt = (Lattice*)oblatt->data; + BLI_assert(oblatt->type == OB_LATTICE); + if(lt->editlatt) lt= lt->editlatt->latt; + return lt->dvert; } - diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e368c9b3bde..8628e215328 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1007,9 +1007,9 @@ void automatname(Material *ma) if(ma->mode & MA_SHLESS) ref= 1.0; else ref= ma->ref; - r= (int)(4.99*(ref*ma->r)); - g= (int)(4.99*(ref*ma->g)); - b= (int)(4.99*(ref*ma->b)); + r= (int)(4.99f*(ref*ma->r)); + g= (int)(4.99f*(ref*ma->g)); + b= (int)(4.99f*(ref*ma->b)); nr= r + 5*g + 25*b; if(nr>124) nr= 124; new_id(&G.main->mat, (ID *)ma, colname_array[nr]); @@ -1175,10 +1175,10 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) } break; case MA_RAMP_DIFF: - *r = facm*(*r) + fac*fabs(*r-col[0]); + *r = facm*(*r) + fac*fabsf(*r-col[0]); if(g) { - *g = facm*(*g) + fac*fabs(*g-col[1]); - *b = facm*(*b) + fac*fabs(*b-col[2]); + *g = facm*(*g) + fac*fabsf(*g-col[1]); + *b = facm*(*b) + fac*fabsf(*b-col[2]); } break; case MA_RAMP_DARK: diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index dd96736b8c3..e6e32be9634 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -587,13 +587,13 @@ float densfunc(MetaElem *ball, float x, float y, float z) if(ball->flag & MB_NEGATIVE) { dist2= 1.0f-(dist2/ball->rad2); - if(dist2 < 0.0) return 0.5f; + if(dist2 < 0.0f) return 0.5f; return 0.5f-ball->s*dist2*dist2*dist2; } else { dist2= 1.0f-(dist2/ball->rad2); - if(dist2 < 0.0) return -0.5f; + if(dist2 < 0.0f) return -0.5f; return ball->s*dist2*dist2*dist2 -0.5f; } @@ -685,8 +685,8 @@ float metaball(float x, float y, float z) ml_p= ml_p->next; } - dens+= -0.5*(metaball_tree->pos - node->pos); - dens+= 0.5*(metaball_tree->neg - node->neg); + dens+= -0.5f*(metaball_tree->pos - node->pos); + dens+= 0.5f*(metaball_tree->neg - node->neg); } else{ for(a=0; acorners[i]->value > 0.0) index += (1<corners[i]->value > 0.0f) index += (1<next) { INTLIST *edges; @@ -906,7 +906,7 @@ void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, i corn3= old->corners[c3]; corn4= old->corners[c4]; - pos = corn1->value > 0.0 ? 1 : 0; + pos = corn1->value > 0.0f ? 1 : 0; /* test if no surface crossing */ if( (corn2->value > 0) == pos && (corn3->value > 0) == pos && (corn4->value > 0) == pos) return; @@ -1219,9 +1219,9 @@ void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) v->x = p->function(point->x+delta, point->y, point->z)-f; v->y = p->function(point->x, point->y+delta, point->z)-f; v->z = p->function(point->x, point->y, point->z+delta)-f; - f = (float)sqrt(v->x*v->x + v->y*v->y + v->z*v->z); + f = sqrtf(v->x*v->x + v->y*v->y + v->z*v->z); - if (f != 0.0) { + if (f != 0.0f) { v->x /= f; v->y /= f; v->z /= f; @@ -1230,16 +1230,16 @@ void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) if(FALSE) { MB_POINT temp; - delta*= 2.0; + delta *= 2.0f; f = p->function(point->x, point->y, point->z); temp.x = p->function(point->x+delta, point->y, point->z)-f; temp.y = p->function(point->x, point->y+delta, point->z)-f; temp.z = p->function(point->x, point->y, point->z+delta)-f; - f = (float)sqrt(temp.x*temp.x + temp.y*temp.y + temp.z*temp.z); + f = sqrtf(temp.x*temp.x + temp.y*temp.y + temp.z*temp.z); - if (f != 0.0) { + if (f != 0.0f) { temp.x /= f; temp.y /= f; temp.z /= f; @@ -1248,9 +1248,9 @@ void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) v->y+= temp.y; v->z+= temp.z; - f = (float)sqrt(v->x*v->x + v->y*v->y + v->z*v->z); + f = sqrtf(v->x*v->x + v->y*v->y + v->z*v->z); - if (f != 0.0) { + if (f != 0.0f) { v->x /= f; v->y /= f; v->z /= f; @@ -1317,7 +1317,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, /* Aproximation by linear interpolation is faster then binary subdivision, * but it results sometimes (mb->thresh < 0.2) into the strange results */ - if((mb->thresh >0.2) && (f==1)){ + if((mb->thresh > 0.2f) && (f==1)){ if((dy == 0.0f) && (dz == 0.0f)){ p->x = neg.x - negative*dx/(positive-negative); p->y = neg.y; @@ -1344,7 +1344,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, while (1) { if (i++ == RES) return; p->x = 0.5f*(pos.x + neg.x); - if ((function(p->x,p->y,p->z)) > 0.0) pos.x = p->x; else neg.x = p->x; + if ((function(p->x,p->y,p->z)) > 0.0f) pos.x = p->x; else neg.x = p->x; } } @@ -1354,7 +1354,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, while (1) { if (i++ == RES) return; p->y = 0.5f*(pos.y + neg.y); - if ((function(p->x,p->y,p->z)) > 0.0) pos.y = p->y; else neg.y = p->y; + if ((function(p->x,p->y,p->z)) > 0.0f) pos.y = p->y; else neg.y = p->y; } } @@ -1364,7 +1364,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, while (1) { if (i++ == RES) return; p->z = 0.5f*(pos.z + neg.z); - if ((function(p->x,p->y,p->z)) > 0.0) pos.z = p->z; else neg.z = p->z; + if ((function(p->x,p->y,p->z)) > 0.0f) pos.z = p->z; else neg.z = p->z; } } @@ -1376,7 +1376,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, if (i++ == RES) return; - if ((function(p->x, p->y, p->z)) > 0.0){ + if ((function(p->x, p->y, p->z)) > 0.0f){ pos.x = p->x; pos.y = p->y; pos.z = p->z; @@ -1437,7 +1437,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) /* Skip, when Stiffness of MetaElement is too small ... MetaElement can't be * visible alone ... but still can influence others MetaElements :-) */ - if(f > 0.0) { + if(f > 0.0f) { OUT.x = IN.x = in.x= 0.0; OUT.y = IN.y = in.y= 0.0; OUT.z = IN.z = in.z= 0.0; @@ -1495,7 +1495,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) workp.y = in.y; workp.z = in.z; workp_v = in_v; - max_len = sqrt((out.x-in.x)*(out.x-in.x) + (out.y-in.y)*(out.y-in.y) + (out.z-in.z)*(out.z-in.z)); + max_len = sqrtf((out.x-in.x)*(out.x-in.x) + (out.y-in.y)*(out.y-in.y) + (out.z-in.z)*(out.z-in.z)); nx = abs((out.x - in.x)/mbproc->size); ny = abs((out.y - in.y)/mbproc->size); @@ -1515,7 +1515,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) /* compute value of implicite function */ tmp_v = mbproc->function(workp.x, workp.y, workp.z); /* add cube to the stack, when value of implicite function crosses zero value */ - if((tmp_v<0.0 && workp_v>=0.0)||(tmp_v>0.0 && workp_v<=0.0)) { + if((tmp_v<0.0f && workp_v>=0.0f)||(tmp_v>0.0f && workp_v<=0.0f)) { /* indexes of CUBE, which includes "first point" */ c_i= (int)floor(workp.x/mbproc->size); @@ -1529,7 +1529,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) else add_cube(mbproc, c_i, c_j, c_k, 1); } - len = sqrt((workp.x-in.x)*(workp.x-in.x) + (workp.y-in.y)*(workp.y-in.y) + (workp.z-in.z)*(workp.z-in.z)); + len = sqrtf((workp.x-in.x)*(workp.x-in.x) + (workp.y-in.y)*(workp.y-in.y) + (workp.z-in.z)*(workp.z-in.z)); workp_v = tmp_v; } @@ -1627,13 +1627,13 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ /* when metaball object hase zero scale, then MetaElem ot this MetaBall * will not be put to mainb array */ - if(bob->size[0]==0.0 || bob->size[1]==0.0 || bob->size[2]==0.0) { + if(bob->size[0]==0.0f || bob->size[1]==0.0f || bob->size[2]==0.0f) { zero_size= 1; } else if(bob->parent) { struct Object *pob=bob->parent; while(pob) { - if(pob->size[0]==0.0 || pob->size[1]==0.0 || pob->size[2]==0.0) { + if(pob->size[0]==0.0f || pob->size[1]==0.0f || pob->size[2]==0.0f) { zero_size= 1; break; } @@ -1662,7 +1662,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ /* too big stiffness seems only ugly due to linear interpolation * no need to have possibility for too big stiffness */ - if(ml->s > 10.0) ml->s = 10.0; + if(ml->s > 10.0f) ml->s = 10.0f; /* Rotation of MetaElem is stored in quat */ quat_to_mat4( temp3,ml->quat); @@ -2228,7 +2228,7 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) if(G.moving && mb->flag==MB_UPDATE_HALFRES) width*= 2; } /* nr_cubes is just for safety, minimum is totsize */ - nr_cubes= (int)(0.5+totsize/width); + nr_cubes= (int)(0.5f+totsize/width); /* init process */ mbproc.function = metaball; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index bc3e6b4c4dd..7302abe8968 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -362,9 +362,9 @@ void tex_space_mesh(Mesh *me) if(me->texflag & AUTOSPACE) { for (a=0; a<3; a++) { - if(size[a]==0.0) size[a]= 1.0; - else if(size[a]>0.0 && size[a]<0.00001) size[a]= 0.00001; - else if(size[a]<0.0 && size[a]> -0.00001) size[a]= -0.00001; + if(size[a]==0.0f) size[a]= 1.0f; + else if(size[a]>0.0f && size[a]<0.00001f) size[a]= 0.00001f; + else if(size[a]<0.0f && size[a]> -0.00001f) size[a]= -0.00001f; } copy_v3_v3(me->loc, loc); @@ -751,9 +751,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me) verts= dl->verts; while(a--) { VECCOPY(mvert->co, verts); - mvert->no[0]= (short int)(nors[0]*32767.0); - mvert->no[1]= (short int)(nors[1]*32767.0); - mvert->no[2]= (short int)(nors[2]*32767.0); + normal_float_to_short_v3(mvert->no, nors); mvert++; nors+= 3; verts+= 3; @@ -1303,6 +1301,8 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, } /* build smooth normals for uninitialized normals at faces set to flat */ + /* For such faces the renderer/3Dview and exporters will be using the face normal */ + /* The vertex normals built inside this if-statement are entirely to support the needs of the modeler */ if(found_flat!=0) { const int nr_bits= sizeof(int)*8; const int nr_words= (numVerts+(nr_bits-1))/nr_bits; @@ -1435,7 +1435,7 @@ UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned sub_v2_v2v2(uvdiff, uv2, uv); - if(fabs(uv[0]-uv2[0]) < limit[0] && fabs(uv[1]-uv2[1]) < limit[1]) { + if(fabsf(uv[0]-uv2[0]) < limit[0] && fabsf(uv[1]-uv2[1]) < limit[1]) { if(lastv) lastv->next= next; else vlist= next; iterv->next= newvlist; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 6694f74cd1e..c02b5dda9ce 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -296,7 +296,7 @@ NlaStrip *add_nlastrip (bAction *act) calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); strip->start = strip->actstart; - strip->end = (IS_EQ(strip->actstart, strip->actend)) ? (strip->actstart + 1.0f): (strip->actend); + strip->end = (IS_EQF(strip->actstart, strip->actend)) ? (strip->actstart + 1.0f): (strip->actend); /* strip should be referenced as-is */ strip->scale= 1.0f; @@ -347,19 +347,20 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act) */ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short mode) { - float actlength, repeat, scale; + float actlength, scale; + // float repeat; // UNUSED /* get number of repeats */ - if (IS_EQ(strip->repeat, 0.0f)) strip->repeat = 1.0f; - repeat = strip->repeat; + if (IS_EQF(strip->repeat, 0.0f)) strip->repeat = 1.0f; + // repeat = strip->repeat; // UNUSED /* scaling */ - if (IS_EQ(strip->scale, 0.0f)) strip->scale= 1.0f; + if (IS_EQF(strip->scale, 0.0f)) strip->scale= 1.0f; scale = (float)fabs(strip->scale); /* scale must be positive - we've got a special flag for reversing */ /* length of referenced action */ actlength = strip->actend - strip->actstart; - if (IS_EQ(actlength, 0.0f)) actlength = 1.0f; + if (IS_EQF(actlength, 0.0f)) actlength = 1.0f; /* reversed = play strip backwards */ if (strip->flag & NLASTRIP_FLAG_REVERSE) { @@ -371,7 +372,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short return (strip->end + (strip->actstart * scale - cframe)) / scale; } else /* if (mode == NLATIME_CONVERT_EVAL) */{ - if (IS_EQ(cframe, strip->end) && IS_EQ(strip->repeat, ((int)strip->repeat))) { + if (IS_EQF(cframe, strip->end) && IS_EQF(strip->repeat, ((int)strip->repeat))) { /* this case prevents the motion snapping back to the first frame at the end of the strip * by catching the case where repeats is a whole number, which means that the end of the strip * could also be interpreted as the end of the start of a repeat @@ -382,7 +383,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short /* - the 'fmod(..., actlength*scale)' is needed to get the repeats working * - the '/ scale' is needed to ensure that scaling influences the timing within the repeat */ - return strip->actend - fmod(cframe - strip->start, actlength*scale) / scale; + return strip->actend - fmodf(cframe - strip->start, actlength*scale) / scale; } } } @@ -394,7 +395,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short return strip->actstart + (cframe - strip->start) / scale; } else /* if (mode == NLATIME_CONVERT_EVAL) */{ - if (IS_EQ(cframe, strip->end) && IS_EQ(strip->repeat, ((int)strip->repeat))) { + if (IS_EQF(cframe, strip->end) && IS_EQF(strip->repeat, ((int)strip->repeat))) { /* this case prevents the motion snapping back to the first frame at the end of the strip * by catching the case where repeats is a whole number, which means that the end of the strip * could also be interpreted as the end of the start of a repeat @@ -405,7 +406,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short /* - the 'fmod(..., actlength*scale)' is needed to get the repeats working * - the '/ scale' is needed to ensure that scaling influences the timing within the repeat */ - return strip->actstart + fmod(cframe - strip->start, actlength*scale) / scale; + return strip->actstart + fmodf(cframe - strip->start, actlength*scale) / scale; } } } @@ -507,7 +508,7 @@ short BKE_nlastrips_has_space (ListBase *strips, float start, float end) NlaStrip *strip; /* sanity checks */ - if ((strips == NULL) || IS_EQ(start, end)) + if ((strips == NULL) || IS_EQF(start, end)) return 0; if (start > end) { puts("BKE_nlastrips_has_space() error... start and end arguments swapped"); @@ -800,13 +801,13 @@ void BKE_nlameta_flush_transforms (NlaStrip *mstrip) * don't flush if nothing changed yet * TODO: maybe we need a flag to say always flush? */ - if (IS_EQ(oStart, mstrip->start) && IS_EQ(oEnd, mstrip->end)) + if (IS_EQF(oStart, mstrip->start) && IS_EQF(oEnd, mstrip->end)) return; /* check if scale changed */ oLen = oEnd - oStart; nLen = mstrip->end - mstrip->start; - if (IS_EQ(nLen, oLen) == 0) + if (IS_EQF(nLen, oLen) == 0) scaleChanged= 1; /* for each child-strip, calculate new start/end points based on this new info */ @@ -927,7 +928,7 @@ short BKE_nlatrack_has_space (NlaTrack *nlt, float start, float end) * - track must be editable * - bounds cannot be equal (0-length is nasty) */ - if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQ(start, end)) + if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQF(start, end)) return 0; if (start > end) { @@ -1044,7 +1045,7 @@ short BKE_nlastrip_within_bounds (NlaStrip *strip, float min, float max) const float boundsLen= (float)fabs(max - min); /* sanity checks */ - if ((strip == NULL) || IS_EQ(stripLen, 0.0f) || IS_EQ(boundsLen, 0.0f)) + if ((strip == NULL) || IS_EQF(stripLen, 0.0f) || IS_EQF(boundsLen, 0.0f)) return 0; /* only ok if at least part of the strip is within the bounding window @@ -1084,12 +1085,12 @@ void BKE_nlastrip_recalculate_bounds (NlaStrip *strip) /* calculate new length factors */ actlen= strip->actend - strip->actstart; - if (IS_EQ(actlen, 0.0f)) actlen= 1.0f; + if (IS_EQF(actlen, 0.0f)) actlen= 1.0f; mapping= strip->scale * strip->repeat; /* adjust endpoint of strip in response to this */ - if (IS_EQ(mapping, 0.0f) == 0) + if (IS_EQF(mapping, 0.0f) == 0) strip->end = (actlen * mapping) + strip->start; } @@ -1313,11 +1314,11 @@ static void nlastrip_get_endpoint_overlaps (NlaStrip *strip, NlaTrack *track, fl /* if this strip is not part of an island of continuous strips, it can be used * - this check needs to be done for each end of the strip we try and use... */ - if ((nls->next == NULL) || IS_EQ(nls->next->start, nls->end)==0) { + if ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end)==0) { if ((nls->end > strip->start) && (nls->end < strip->end)) *start= &nls->end; } - if ((nls->prev == NULL) || IS_EQ(nls->prev->end, nls->start)==0) { + if ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start)==0) { if ((nls->start < strip->end) && (nls->start > strip->start)) *end= &nls->start; } @@ -1349,7 +1350,7 @@ static void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls) * is directly followed/preceeded by another strip, forming an * 'island' of continuous strips */ - if ( (ps || ns) && ((nls->prev == NULL) || IS_EQ(nls->prev->end, nls->start)==0) ) + if ( (ps || ns) && ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start)==0) ) { /* start overlaps - pick the largest overlap */ if ( ((ps && ns) && (*ps > *ns)) || (ps) ) @@ -1360,7 +1361,7 @@ static void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls) else /* no overlap allowed/needed */ nls->blendin= 0.0f; - if ( (pe || ne) && ((nls->next == NULL) || IS_EQ(nls->next->start, nls->end)==0) ) + if ( (pe || ne) && ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end)==0) ) { /* end overlaps - pick the largest overlap */ if ( ((pe && ne) && (*pe > *ne)) || (pe) ) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index a07baa92998..dc1f80ce1d4 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2725,7 +2725,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) node= getExecutableNode(ntree); if(node) { if(ntree->progress && totnode) - ntree->progress(ntree->prh, (1.0 - curnode/(float)totnode)); + ntree->progress(ntree->prh, (1.0f - curnode/(float)totnode)); if(ntree->stats_draw) { char str[64]; sprintf(str, "Compositing %d %s", curnode, node->name); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 7baed103226..6f3b8b0b85c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1573,6 +1573,9 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) if(gob) { ob->rotmode= target->rotmode; mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat); + if(gob->dup_group) { /* should always be true */ + sub_v3_v3(ob->obmat[3], gob->dup_group->dupli_ofs); + } object_apply_mat4(ob, ob->obmat, FALSE, TRUE); } else { @@ -2566,6 +2569,9 @@ void object_handle_update(Scene *scene, Object *ob) Object *obg= ob->proxy_from->proxy_group; invert_m4_m4(obg->imat, obg->obmat); mul_m4_m4m4(ob->obmat, ob->proxy_from->obmat, obg->imat); + if(obg->dup_group) { /* should always be true */ + add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs); + } } else copy_m4_m4(ob->obmat, ob->proxy_from->obmat); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f937d7265aa..e96dc638a88 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -660,7 +660,7 @@ static float psys_render_projected_area(ParticleSystem *psys, float *center, flo } /* screen space radius */ - radius= sqrt(area/M_PI); + radius= sqrt(area/(float)M_PI); /* make smaller using fallof once over screen edge */ *viewport= 1.0f; @@ -869,7 +869,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) powrate= log(0.5f)/log(part->simplify_rate*0.5f); if(part->simplify_flag & PART_SIMPLIFY_VIEWPORT) - vprate= pow(1.0 - part->simplify_viewport, 5.0); + vprate= pow(1.0f - part->simplify_viewport, 5.0); else vprate= 1.0; @@ -880,7 +880,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) if((arearatio < 1.0f || viewport < 1.0f) && elem->totchild) { /* lambda is percentage of elements to keep */ - lambda= (arearatio < 1.0f)? pow(arearatio, powrate): 1.0f; + lambda= (arearatio < 1.0f)? powf(arearatio, powrate): 1.0f; lambda *= viewport; lambda= MAX2(lambda, 1.0f/elem->totchild); @@ -1990,25 +1990,25 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float inp_y=dot_v3v3(y_vec, vec_one); inp_z=dot_v3v3(z_vec, vec_one); - if(inp_y>0.5){ + if(inp_y > 0.5f){ copy_v3_v3(state_co, y_vec); mul_v3_fl(y_vec, amplitude*(float)cos(t)); mul_v3_fl(z_vec, amplitude/2.f*(float)sin(2.f*t)); } - else if(inp_z>0.0){ - mul_v3_v3fl(state_co, z_vec, (float)sin(M_PI/3.f)); + else if(inp_z > 0.0f){ + mul_v3_v3fl(state_co, z_vec, (float)sin((float)M_PI/3.f)); VECADDFAC(state_co,state_co,y_vec,-0.5f); - mul_v3_fl(y_vec, -amplitude * (float)cos(t + M_PI/3.f)); - mul_v3_fl(z_vec, amplitude/2.f * (float)cos(2.f*t + M_PI/6.f)); + mul_v3_fl(y_vec, -amplitude * (float)cos(t + (float)M_PI/3.f)); + mul_v3_fl(z_vec, amplitude/2.f * (float)cos(2.f*t + (float)M_PI/6.f)); } else{ - mul_v3_v3fl(state_co, z_vec, -(float)sin(M_PI/3.f)); + mul_v3_v3fl(state_co, z_vec, -(float)sin((float)M_PI/3.f)); madd_v3_v3fl(state_co, y_vec, -0.5f); - mul_v3_fl(y_vec, amplitude * (float)-sin(t + M_PI/6.f)); - mul_v3_fl(z_vec, amplitude/2.f * (float)-sin(2.f*t + M_PI/3.f)); + mul_v3_fl(y_vec, amplitude * (float)-sin(t + (float)M_PI/6.f)); + mul_v3_fl(z_vec, amplitude/2.f * (float)-sin(2.f*t + (float)M_PI/3.f)); } mul_v3_fl(state_co, amplitude); @@ -2047,15 +2047,15 @@ static float do_clump(ParticleKey *state, ParticleKey *par, float time, float cl { float clump = 0.f; - if(par && clumpfac!=0.0){ + if(par && clumpfac!=0.0f){ float cpow; - if(clumppow<0.0) + if(clumppow < 0.0f) cpow=1.0f+clumppow; else cpow=1.0f+9.0f*clumppow; - if(clumpfac<0.0) /* clump roots instead of tips */ + if(clumpfac < 0.0f) /* clump roots instead of tips */ clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time,(double)cpow); else clump = clumpfac*pa_clump*(float)pow((double)time,(double)cpow); @@ -2129,7 +2129,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) if(data->strength <= 0.0f) continue; - guidetime = time / (1.0 - pd->free_end); + guidetime = time / (1.0f - pd->free_end); if(guidetime>1.0f) continue; @@ -2152,7 +2152,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) VECCOPY(vec_to_point, data->vec_to_point); - if(guidetime != 0.0){ + if(guidetime != 0.0f) { /* curve direction */ cross_v3_v3v3(temp, eff->guide_dir, guidedir); angle = dot_v3v3(eff->guide_dir, guidedir)/(len_v3(eff->guide_dir)); @@ -2167,7 +2167,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) /* curve taper */ if(cu->taperobj) - mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0), 100)); + mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0f), 100)); else{ /* curve size*/ if(cu->flag & CU_PATH_RADIUS) { @@ -2191,10 +2191,10 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) totstrength *= weight; } - if(totstrength != 0.0){ - if(totstrength > 1.0) + if(totstrength != 0.0f){ + if(totstrength > 1.0f) mul_v3_fl(effect, 1.0f / totstrength); - CLAMP(totstrength, 0.0, 1.0); + CLAMP(totstrength, 0.0f, 1.0f); //VECADD(effect,effect,pa_zero); interp_v3_v3v3(state->co, state->co, effect, totstrength); @@ -2210,8 +2210,8 @@ static void do_rough(float *loc, float mat[4][4], float t, float fac, float size float rough[3]; float rco[3]; - if(thres!=0.0) - if((float)fabs((float)(-1.5+loc[0]+loc[1]+loc[2]))<1.5f*thres) return; + if(thres != 0.0f) + if((float)fabs((float)(-1.5f+loc[0]+loc[1]+loc[2]))<1.5f*thres) return; VECCOPY(rco,loc); mul_v3_fl(rco,t); @@ -2254,7 +2254,7 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK pd_point_from_particle(sim, sim->psys->particles+i, &eff_key, &epoint); pdDoEffectors(sim->psys->effectors, sim->colliders, sim->psys->part->effector_weights, &epoint, force, NULL); - mul_v3_fl(force, effector*pow((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); + mul_v3_fl(force, effector*powf((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); add_v3_v3(force, vec); @@ -2333,7 +2333,7 @@ void psys_find_parents(ParticleSimulationData *sim) int p, totparent,totchild=sim->psys->totchild; float co[3], orco[3]; int from=PART_FROM_FACE; - totparent=(int)(totchild*part->parents*0.3); + totparent=(int)(totchild*part->parents*0.3f); if(G.rendering && part->child_nbr && part->ren_child_nbr) totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; @@ -2409,7 +2409,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c } if(totchild && part->childtype==PART_CHILD_FACES){ - totparent=(int)(totchild*part->parents*0.3); + totparent=(int)(totchild*part->parents*0.3f); if(G.rendering && part->child_nbr && part->ren_child_nbr) totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; @@ -2549,7 +2549,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle normalize_v3(v1); normalize_v3(v2); - d = saacos(dot_v3v3(v1, v2)) * 180.f / M_PI; + d = saacos(dot_v3v3(v1, v2)) * 180.0f/(float)M_PI; } if(p_max > p_min) @@ -3063,8 +3063,8 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf ParticleInterpolationData pind; ParticleKey result; - float birthtime = 0.0, dietime = 0.0; - float t, time = 0.0, keytime = 0.0, frs_sec; + float birthtime = 0.0f, dietime = 0.0f; + float t, time = 0.0f, keytime = 0.0f, frs_sec; float hairmat[4][4], rotmat[3][3], prev_tangent[3] = {0.0f, 0.0f, 0.0f}; int k, i; int steps = (int)pow(2.0, (double)pset->draw_step); @@ -3697,8 +3697,8 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, fl } #define SET_PARTICLE_TEXTURE(type, pvalue, texfac) if((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend);} -#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) if(event & type) { if(pvalue < 0.f) pvalue = 1.f+pvalue; CLAMP(pvalue, 0.0, 1.0); } -#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) if(event & type) { CLAMP(pvalue, -1.0, 1.0); } +#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) if(event & type) { if(pvalue < 0.f) pvalue = 1.f+pvalue; CLAMP(pvalue, 0.0f, 1.0f); } +#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) if(event & type) { CLAMP(pvalue, -1.0f, 1.0f); } static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, float *fw, float *orco, ParticleTexture *ptex, int event, float cfra) { @@ -3898,7 +3898,7 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED size*=part->childsize; - if(part->childrandsize!=0.0) + if(part->childrandsize != 0.0f) size *= 1.0f - part->childrandsize * PSYS_FRAND(cpa - psys->child + 26); return size; @@ -4002,7 +4002,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * memset(keys, 0, 4*sizeof(ParticleKey)); t=state->time; - CLAMP(t, 0.0, 1.0); + CLAMP(t, 0.0f, 1.0f); if(pparticles + p; @@ -4199,8 +4199,8 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta state->time = psys_get_child_time(psys, cpa, cfra, NULL, NULL); if(!always) - if((state->time < 0.0 && !(part->flag & PART_UNBORN)) - || (state->time > 1.0 && !(part->flag & PART_DIED))) + if((state->time < 0.0f && !(part->flag & PART_UNBORN)) + || (state->time > 1.0f && !(part->flag & PART_DIED))) return 0; state->time= (cfra - (part->sta + (part->end - part->sta) * PSYS_FRAND(p + 23))) / (part->lifetime * PSYS_FRAND(p + 24)); @@ -4240,7 +4240,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta key1=&pa->state; offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad); - CLAMP(t,0.0,1.0); + CLAMP(t, 0.0f, 1.0f); unit_m4(mat); do_child_modifiers(sim, NULL, key1, key1->rot, cpa, cpa->fuv, mat, state, t); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 088ab78ce47..13f5d619daa 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -635,8 +635,8 @@ static void hammersley_create(float *out, int n, int seed, float amount) int k, kk; rng = rng_new(31415926 + n + seed); - offs[0]= rng_getDouble(rng) + amount; - offs[1]= rng_getDouble(rng) + amount; + offs[0]= rng_getDouble(rng) + (double)amount; + offs[1]= rng_getDouble(rng) + (double)amount; rng_free(rng); for (k = 0; k < n; k++) { @@ -659,8 +659,8 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount) if(num==0) return; - rad1= (float)(1.0/sqrt((float)num)); - rad2= (float)(1.0/((float)num)); + rad1= (float)(1.0f/sqrtf((float)num)); + rad2= (float)(1.0f/((float)num)); rad3= (float)sqrt((float)num)/((float)num); rng = rng_new(31415926 + num + seed2); @@ -890,7 +890,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch if(ctx->tree){ KDTreeNearest ptn[10]; int w,maxw;//, do_seams; - float maxd,mind,/*dd,*/totw=0.0; + float maxd,mind,/*dd,*/totw= 0.0f; int parent[10]; float pweight[10]; @@ -1210,10 +1210,10 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D if(mf->v4) { tweight += vweight[mf->v4]; - tweight /= 4.0; + tweight /= 4.0f; } else { - tweight /= 3.0; + tweight /= 3.0f; } element_weight[i]*=tweight; @@ -1271,7 +1271,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D /* For hair, sort by origindex (allows optimizations in rendering), */ /* however with virtual parents the children need to be in random order. */ - if(part->type == PART_HAIR && !(part->childtype==PART_CHILD_FACES && part->parents!=0.0)) { + if(part->type == PART_HAIR && !(part->childtype==PART_CHILD_FACES && part->parents!=0.0f)) { COMPARE_ORIG_INDEX = NULL; if(from == PART_FROM_VERT) { @@ -1606,11 +1606,11 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, normalize_v3(nor); /* -tangent */ - if(part->tanfac!=0.0){ + if(part->tanfac!=0.0f){ //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f; float phase=0.0f; - mul_v3_fl(vtan,-(float)cos(M_PI*(part->tanphase+phase))); - fac=-(float)sin(M_PI*(part->tanphase+phase)); + mul_v3_fl(vtan,-(float)cos((float)M_PI*(part->tanphase+phase))); + fac=-(float)sin((float)M_PI*(part->tanphase+phase)); VECADDFAC(vtan,vtan,utan,fac); mul_mat3_m4_v3(ob->obmat,vtan); @@ -1624,7 +1624,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* -velocity */ - if(part->randfac!=0.0){ + if(part->randfac != 0.0f){ r_vel[0] = 2.0f * (PSYS_FRAND(p + 10) - 0.5f); r_vel[1] = 2.0f * (PSYS_FRAND(p + 11) - 0.5f); r_vel[2] = 2.0f * (PSYS_FRAND(p + 12) - 0.5f); @@ -1668,7 +1668,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, zero_v3(pa->state.vel); /* boids store direction in ave */ - if(fabs(nor[2])==1.0f) { + if(fabsf(nor[2])==1.0f) { sub_v3_v3v3(pa->state.ave, loc, ob->obmat[3]); normalize_v3(pa->state.ave); } @@ -1821,7 +1821,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, else{ pa->lifetime = part->lifetime * ptex.life; - if(part->randlife != 0.0) + if(part->randlife != 0.0f) pa->lifetime *= 1.0f - part->randlife * PSYS_FRAND(p + 21); } @@ -1987,7 +1987,7 @@ void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra ParticleSettings *part = psys->part; *sfra = MAX2(1, (int)part->sta); - *efra = MIN2((int)(part->end + part->lifetime + 1.0), scene->r.efra); + *efra = MIN2((int)(part->end + part->lifetime + 1.0f), scene->r.efra); } /************************************************/ @@ -2063,10 +2063,15 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d float force[3],acceleration[3],impulse[3],dx[4][3],dv[4][3],oldpos[3]; float pa_mass= (part->flag & PART_SIZEMASS ? part->mass * pa->size : part->mass); int i, steps=1; - - copy_v3_v3(oldpos, pa->state.co); + int integrator = part->integrator; - switch(part->integrator){ + copy_v3_v3(oldpos, pa->state.co); + + /* Verlet integration behaves strangely with moving emitters, so do first step with euler. */ + if(pa->prev_state.time < 0.f && integrator == PART_INT_VERLET) + integrator = PART_INT_EULER; + + switch(integrator){ case PART_INT_EULER: steps=1; break; @@ -2100,7 +2105,7 @@ static void integrate_particle(ParticleSettings *part, ParticleData *pa, float d /* calculate next state */ add_v3_v3(states[i].vel, impulse); - switch(part->integrator){ + switch(integrator){ case PART_INT_EULER: madd_v3_v3v3fl(pa->state.co, states->co, states->vel, dtime); madd_v3_v3v3fl(pa->state.vel, states->vel, acceleration, dtime); @@ -2329,7 +2334,7 @@ static void sph_density_accum_cb(void *userdata, int index, float squared_dist) pfr->neighbors[pfr->tot_neighbors].psys = pfr->npsys; pfr->tot_neighbors++; - q = (1.f - sqrt(squared_dist)/pfr->h) * pfr->massfac; + q = (1.f - sqrtf(squared_dist)/pfr->h) * pfr->massfac; if(pfr->use_size) q *= npa->size; @@ -2511,7 +2516,7 @@ static void basic_force_cb(void *efdata_v, ParticleKey *state, float *force, flo madd_v3_v3fl(force, state->vel, -part->dragfac * pa->size * pa->size * len_v3(state->vel)); /* brownian force */ - if(part->brownfac != 0.0){ + if(part->brownfac != 0.0f){ force[0] += (BLI_frand()-0.5f) * part->brownfac; force[1] += (BLI_frand()-0.5f) * part->brownfac; force[2] += (BLI_frand()-0.5f) * part->brownfac; @@ -2554,7 +2559,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa /* finally we do guides */ time=(cfra-pa->time)/pa->lifetime; - CLAMP(time,0.0,1.0); + CLAMP(time, 0.0f, 1.0f); VECCOPY(tkey.co,pa->state.co); VECCOPY(tkey.vel,pa->state.vel); @@ -2594,8 +2599,8 @@ static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, f } rotfac=len_v3(pa->state.ave); - if(rotfac==0.0){ /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */ - rot1[0]=1.0; + if(rotfac == 0.0f){ /* unit_qt(in VecRotToQuat) doesn't give unit quat [1,0,0,0]?? */ + rot1[0]=1.0f; rot1[1]=rot1[2]=rot1[3]=0; } else{ @@ -2653,7 +2658,7 @@ static float nr_distance_to_edge(float *p, float radius, ParticleCollisionElemen cross_v3_v3v3(c, v1, v2); - return fabs(len_v3(c)/len_v3(v0)) - radius; + return fabsf(len_v3(c)/len_v3(v0)) - radius; } static float nr_distance_to_vert(float *p, float radius, ParticleCollisionElement *pce, float *UNUSED(nor)) { @@ -2984,6 +2989,11 @@ void BKE_psys_collision_neartest_cb(void *userdata, int index, const BVHTreeRay pce.tot = 3; pce.inside = 0; + pce.index = index; + + /* don't collide with same face again */ + if(col->hit == col->current && col->pce.index == index && col->pce.tot == 3) + return; do { @@ -3088,8 +3098,8 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR float frict = pd->pdef_frict + pd->pdef_rfrict * 2 * (BLI_frand() - 0.5f); float distance, nor[3], dot; - CLAMP(damp,0.0,1.0); - CLAMP(frict,0.0,1.0); + CLAMP(damp,0.0f, 1.0f); + CLAMP(frict,0.0f, 1.0f); /* get exact velocity right before collision */ madd_v3_v3v3fl(v0, col->ve1, col->acc, dt1); @@ -3136,7 +3146,7 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR /* convert to angular velocity*/ cross_v3_v3v3(ave, vr_tan, pce->nor); - mul_v3_fl(ave, 1.0f/MAX2(pa->size, 0.001)); + mul_v3_fl(ave, 1.0f/MAX2(pa->size, 0.001f)); /* only friction will cause change in linear & angular velocity */ interp_v3_v3v3(pa->state.ave, pa->state.ave, ave, frict); @@ -3324,7 +3334,7 @@ static void psys_update_path_cache(ParticleSimulationData *sim, float cfra) if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) { distribute_particles(sim, PART_FROM_CHILD); - if(part->childtype==PART_CHILD_FACES && part->parents!=0.0) + if(part->childtype==PART_CHILD_FACES && part->parents != 0.0f) psys_find_parents(sim); } } @@ -3577,11 +3587,11 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) timestep = psys_get_timestep(sim); dtime= dfra*timestep; - if(dfra<0.0){ + if(dfra < 0.0f) { LOOP_EXISTING_PARTICLES { psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra); pa->size = part->size*ptex.size; - if(part->randsize > 0.0) + if(part->randsize > 0.0f) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); reset_particle(sim, pa, dtime, cfra); @@ -3636,7 +3646,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra); pa->size = part->size*ptex.size; - if(part->randsize > 0.0) + if(part->randsize > 0.0f) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); birthtime = pa->time; @@ -3780,7 +3790,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra) LOOP_PARTICLES { psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra); pa->size = part->size*ptex.size; - if(part->randsize > 0.0) + if(part->randsize > 0.0f) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); psys->lattice= psys_get_lattice(sim); @@ -4305,7 +4315,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) LOOP_EXISTING_PARTICLES { pa->size = part->size; - if(part->randsize > 0.0) + if(part->randsize > 0.0f) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); reset_particle(&sim, pa, 0.0, cfra); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 618945b27bd..587d1dc01a2 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2557,7 +2557,7 @@ static void *ptcache_bake_thread(void *ptr) { ptcache_dt_to_str(run, ctime-stime); ptcache_dt_to_str(etd, fetd); - printf("Baked for %s, current frame: %i/%i (%.3fs), ETC: %s \r", run, *data->cfra_ptr-sfra+1, efra-sfra+1, (float)(ctime-ptime), etd); + printf("Baked for %s, current frame: %i/%i (%.3fs), ETC: %s \r", run, *data->cfra_ptr-sfra+1, efra-sfra+1, ctime-ptime, etd); } ptime = ctime; } diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index bebfcaed78f..3dfef2e9d78 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -416,8 +416,8 @@ static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y, rt2= (char *)rect2; rt= (char *)out; - fac2= (int)(256.0*facf0); - fac4= (int)(256.0*facf1); + fac2= (int)(256.0f*facf0); + fac4= (int)(256.0f*facf1); while(y--) { @@ -493,9 +493,9 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, /* rt = rt1 over rt2 (alpha from rt1) */ fac= fac2; - mfac= 1.0 - (fac2*rt1[3]) ; + mfac= 1.0f - (fac2*rt1[3]) ; - if(fac <= 0.0) { + if(fac <= 0.0f) { memcpy(rt, rt2, 4 * sizeof(float)); } else if(mfac <=0) { memcpy(rt, rt1, 4 * sizeof(float)); @@ -515,11 +515,11 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, while(x--) { fac= fac4; - mfac= 1.0 - (fac4*rt1[3]); + mfac= 1.0f - (fac4*rt1[3]); - if(fac <= 0.0) { + if(fac <= 0.0f) { memcpy(rt, rt2, 4 * sizeof(float)); - } else if(mfac <= 0.0) { + } else if(mfac <= 0.0f) { memcpy(rt, rt1, 4 * sizeof(float)); } else { rt[0] = fac*rt1[0] + mfac*rt2[0]; @@ -572,8 +572,8 @@ static void do_alphaunder_effect_byte( rt2= rect2; rt= out; - fac2= (int)(256.0*facf0); - fac4= (int)(256.0*facf1); + fac2= (int)(256.0f*facf0); + fac4= (int)(256.0f*facf1); while(y--) { @@ -654,13 +654,13 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, /* this complex optimalisation is because the * 'skybuf' can be crossed in */ - if( rt2[3]<=0 && fac2>=1.0) { + if( rt2[3]<=0 && fac2 >= 1.0f) { memcpy(rt, rt1, 4 * sizeof(float)); - } else if(rt2[3]>=1.0) { + } else if(rt2[3] >= 1.0f) { memcpy(rt, rt2, 4 * sizeof(float)); } else { mfac = rt2[3]; - fac = fac2 * (1.0 - mfac); + fac = fac2 * (1.0f - mfac); if(fac == 0) { memcpy(rt, rt2, 4 * sizeof(float)); @@ -680,14 +680,14 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, x= xo; while(x--) { - if(rt2[3]<=0 && fac4 >= 1.0) { + if(rt2[3]<=0 && fac4 >= 1.0f) { memcpy(rt, rt1, 4 * sizeof(float)); - } else if(rt2[3]>=1.0) { + } else if(rt2[3]>=1.0f) { memcpy(rt, rt2, 4 * sizeof(float)); } else { mfac= rt2[3]; - fac= fac4*(1.0-mfac); + fac= fac4*(1.0f-mfac); if(fac == 0) { memcpy(rt, rt2, 4 * sizeof(float)); @@ -744,9 +744,9 @@ static void do_cross_effect_byte(float facf0, float facf1, int x, int y, rt2= rect2; rt= out; - fac2= (int)(256.0*facf0); + fac2= (int)(256.0f*facf0); fac1= 256-fac2; - fac4= (int)(256.0*facf1); + fac4= (int)(256.0f*facf1); fac3= 256-fac4; while(y--) { @@ -792,9 +792,9 @@ static void do_cross_effect_float(float facf0, float facf1, int x, int y, rt= out; fac2= facf0; - fac1= 1.0 - fac2; + fac1= 1.0f - fac2; fac4= facf1; - fac3= 1.0 - fac4; + fac3= 1.0f - fac4; while(y--) { @@ -879,8 +879,8 @@ static void makeGammaTables(float gamma) int i; valid_gamma = gamma; - valid_inv_gamma = 1.0 / gamma; - color_step = 1.0 / RE_GAMMA_TABLE_SIZE; + valid_inv_gamma = 1.0f / gamma; + color_step = 1.0f / RE_GAMMA_TABLE_SIZE; inv_color_step = (float) RE_GAMMA_TABLE_SIZE; /* We could squeeze out the two range tables to gain some memory. */ @@ -956,19 +956,19 @@ static void gamtabs(float gamma) /* gamtab: in short, out short */ for(a=0; a<65536; a++) { val= a; - val/= 65535.0; + val/= 65535.0f; - if(gamma==2.0) val= sqrt(val); - else if(gamma!=1.0) val= pow(val, igamma); + if(gamma==2.0f) val= sqrt(val); + else if(gamma!=1.0f) val= pow(val, igamma); - gamtab[a]= (65535.99*val); + gamtab[a]= (65535.99f*val); } /* inverse gamtab1 : in byte, out short */ for(a=1; a<=256; a++) { - if(gamma==2.0) igamtab1[a-1]= a*a-1; - else if(gamma==1.0) igamtab1[a-1]= 256*a-1; + if(gamma==2.0f) igamtab1[a-1]= a*a-1; + else if(gamma==1.0f) igamtab1[a-1]= 256*a-1; else { - val= a/256.0; + val= a/256.0f; igamtab1[a-1]= (65535.0*pow(val, gamma)) -1 ; } } @@ -1011,7 +1011,7 @@ static void do_gammacross_effect_byte(float facf0, float UNUSED(facf1), rt2= (unsigned char *)rect2; rt= (unsigned char *)out; - fac2= (int)(256.0*facf0); + fac2= (int)(256.0f*facf0); fac1= 256-fac2; while(y--) { @@ -1067,7 +1067,7 @@ static void do_gammacross_effect_float(float facf0, float UNUSED(facf1), rt= out; fac2= facf0; - fac1= 1.0 - fac2; + fac1= 1.0f - fac2; while(y--) { @@ -1137,8 +1137,8 @@ static void do_add_effect_byte(float facf0, float facf1, int x, int y, rt2= (char *)rect2; rt= (char *)out; - fac1= (int)(256.0*facf0); - fac3= (int)(256.0*facf1); + fac1= (int)(256.0f*facf0); + fac3= (int)(256.0f*facf1); while(y--) { @@ -1253,8 +1253,8 @@ static void do_sub_effect_byte(float facf0, float facf1, rt2= (char *)rect2; rt= (char *)out; - fac1= (int)(256.0*facf0); - fac3= (int)(256.0*facf1); + fac1= (int)(256.0f*facf0); + fac3= (int)(256.0f*facf1); while(y--) { @@ -1371,8 +1371,8 @@ static void do_drop_effect_byte(float facf0, float facf1, int x, int y, width= x; height= y; - fac1= (int)(70.0*facf0); - fac2= (int)(70.0*facf1); + fac1= (int)(70.0f*facf0); + fac2= (int)(70.0f*facf1); rt2= (char*) (rect2i + YOFF*width); rt1= (char*) rect1i; @@ -1412,8 +1412,8 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y, width= x; height= y; - fac1= 70.0*facf0; - fac2= 70.0*facf1; + fac1= 70.0f*facf0; + fac2= 70.0f*facf1; rt2= (rect2i + YOFF*width); rt1= rect1i; @@ -1430,10 +1430,10 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y, for (x=XOFF; x fac*a*(b-1)+axaux= c*px + py*s ;//+centx @@ -1519,10 +1519,10 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, x= xo; while(x--) { - rt[0]= rt1[0] + fac1*rt1[0]*(rt2[0]-1.0); - rt[1]= rt1[1] + fac1*rt1[1]*(rt2[1]-1.0); - rt[2]= rt1[2] + fac1*rt1[2]*(rt2[2]-1.0); - rt[3]= rt1[3] + fac1*rt1[3]*(rt2[3]-1.0); + rt[0]= rt1[0] + fac1*rt1[0]*(rt2[0]-1.0f); + rt[1]= rt1[1] + fac1*rt1[1]*(rt2[1]-1.0f); + rt[2]= rt1[2] + fac1*rt1[2]*(rt2[2]-1.0f); + rt[3]= rt1[3] + fac1*rt1[3]*(rt2[3]-1.0f); rt1+= 4; rt2+= 4; rt+= 4; } @@ -1533,10 +1533,10 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, x= xo; while(x--) { - rt[0]= rt1[0] + fac3*rt1[0]*(rt2[0]-1.0); - rt[1]= rt1[1] + fac3*rt1[1]*(rt2[1]-1.0); - rt[2]= rt1[2] + fac3*rt1[2]*(rt2[2]-1.0); - rt[3]= rt1[3] + fac3*rt1[3]*(rt2[3]-1.0); + rt[0]= rt1[0] + fac3*rt1[0]*(rt2[0]-1.0f); + rt[1]= rt1[1] + fac3*rt1[1]*(rt2[1]-1.0f); + rt[2]= rt1[2] + fac3*rt1[2]*(rt2[2]-1.0f); + rt[3]= rt1[3] + fac3*rt1[3]*(rt2[3]-1.0f); rt1+= 4; rt2+= 4; rt+= 4; } @@ -1582,11 +1582,11 @@ typedef struct WipeZone { static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo) { wipezone->flip = (wipe->angle < 0); - wipezone->angle = pow(fabs(wipe->angle)/45.0f, log(xo)/log(2.0f)); + wipezone->angle = pow(fabsf(wipe->angle)/45.0f, log(xo)/log(2.0f)); wipezone->xo = xo; wipezone->yo = yo; wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f)); - wipezone->pythangle = 1.0f/sqrt(wipe->angle*wipe->angle + 1.0f); + wipezone->pythangle = 1.0f/sqrtf(wipe->angle*wipe->angle + 1.0f); if(wipe->wipetype == DO_SINGLE_WIPE) wipezone->invwidth = 1.0f/wipezone->width; @@ -1661,7 +1661,7 @@ float hyp3,hyp4,b4,b5 else { b1 = posy - (-angle)*posx; b2 = y - (-angle)*x; - hyp = fabs(angle*x+y+(-posy-angle*posx))*wipezone->pythangle; + hyp = fabsf(angle*x+y+(-posy-angle*posx))*wipezone->pythangle; } if(angle < 0) { @@ -2137,7 +2137,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x } // Rotate - rotate_radians = (M_PI*transform->rotIni)/180.0f; + rotate_radians = ((float)M_PI*transform->rotIni)/180.0f; transform_image(x,y, ibuf1, out, scale_x, scale_y, translate_x, translate_y, rotate_radians, transform->interpolation); } @@ -2203,7 +2203,7 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height, /* posted to comp.graphics.algorithms by */ /* Blancmange (bmange@airdmhor.gen.nz) */ - k = -1.0/(2.0*3.14159*blur*blur); + k = -1.0f/(2.0f*(float)M_PI*blur*blur); for (ix = 0;ix< halfWidth;ix++){ weight = (float)exp(k*(ix*ix)); filter[halfWidth - ix] = weight; @@ -2372,7 +2372,7 @@ static void RVBlurBitmap2_float ( float* map, int width,int height, /* posted to comp.graphics.algorithms by */ /* Blancmange (bmange@airdmhor.gen.nz) */ - k = -1.0/(2.0*3.14159*blur*blur); + k = -1.0f/(2.0f*(float)M_PI*blur*blur); fval=0; for (ix = 0;ix< halfWidth;ix++){ weight = (float)exp(k*(ix*ix)); @@ -2529,10 +2529,10 @@ static void RVAddBitmaps_float (float* a, float* b, float* c, for (y=0;ystartdisp); - *facf1 = (float)(*facf0 + 0.5); + *facf1 = (float)(*facf0 + 0.5f); *facf0 /= seq->len; *facf1 /= seq->len; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 96fac075412..7a6eb1adc9f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -218,13 +218,25 @@ Editing *seq_give_editing(Scene *scene, int alloc) return scene->ed; } +static void seq_free_clipboard_recursive(Sequence *seq_parent) +{ + Sequence *seq, *nseq; + + for(seq= seq_parent->seqbase.first; seq; seq= nseq) { + nseq= seq->next; + seq_free_clipboard_recursive(seq); + } + + seq_free_sequence(NULL, seq_parent); +} + void seq_free_clipboard(void) { Sequence *seq, *nseq; for(seq= seqbase_clipboard.first; seq; seq= nseq) { nseq= seq->next; - seq_free_sequence(NULL, seq); + seq_free_clipboard_recursive(seq); } seqbase_clipboard.first= seqbase_clipboard.last= NULL; } @@ -333,7 +345,7 @@ unsigned int seq_hash_render_data(const SeqRenderData * a) rval ^= a->preview_render_size; rval ^= ((intptr_t) a->bmain) << 6; rval ^= ((intptr_t) a->scene) << 6; - rval ^= (int) (a->motion_blur_shutter * 100.0) << 10; + rval ^= (int) (a->motion_blur_shutter * 100.0f) << 10; rval ^= a->motion_blur_samples << 24; return rval; @@ -962,7 +974,7 @@ static void multibuf(ImBuf *ibuf, float fmul) int a, mul, icol; - mul= (int)(256.0*fmul); + mul= (int)(256.0f * fmul); rt= (char *)ibuf->rect; rt_float = ibuf->rect_float; @@ -1014,10 +1026,10 @@ static float give_stripelem_index(Sequence *seq, float cfra) else nr= cfra - sta; } - if (seq->strobe < 1.0) seq->strobe = 1.0; + if (seq->strobe < 1.0f) seq->strobe = 1.0f; - if (seq->strobe > 1.0) { - nr -= fmod((double)nr, (double)seq->strobe); + if (seq->strobe > 1.0f) { + nr -= fmodf((double)nr, (double)seq->strobe); } return nr; @@ -1370,7 +1382,7 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) /* tweak to give more subtle results * values above 1.0 are scaled */ if(cb.lift[c] > 1.0f) - cb.lift[c] = pow(cb.lift[c] - 1.0f, 2.0f) + 1.0f; + cb.lift[c] = pow(cb.lift[c] - 1.0f, 2.0) + 1.0; cb.lift[c] = 2.0f - cb.lift[c]; } @@ -1378,8 +1390,8 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) if (cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAIN) { for (c = 0; c < 3; c++) { - if (cb.gain[c] != 0.0) { - cb.gain[c] = 1.0/cb.gain[c]; + if (cb.gain[c] != 0.0f) { + cb.gain[c] = 1.0f / cb.gain[c]; } else { cb.gain[c] = 1000000; /* should be enough :) */ } @@ -1388,8 +1400,8 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) if (!(cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAMMA)) { for (c = 0; c < 3; c++) { - if (cb.gamma[c] != 0.0) { - cb.gamma[c] = 1.0/cb.gamma[c]; + if (cb.gamma[c] != 0.0f) { + cb.gamma[c] = 1.0f/cb.gamma[c]; } else { cb.gamma[c] = 1000000; /* should be enough :) */ } @@ -1416,7 +1428,7 @@ static void make_cb_table_byte(float lift, float gain, float gamma, int y; for (y = 0; y < 256; y++) { - float v= color_balance_fl((float)y * (1.0 / 255.0f), lift, gain, gamma, mul); + float v= color_balance_fl((float)y * (1.0f / 255.0f), lift, gain, gamma, mul); CLAMP(v, 0.0f, 1.0f); table[y] = v * 255; } @@ -1428,7 +1440,7 @@ static void make_cb_table_float(float lift, float gain, float gamma, int y; for (y = 0; y < 256; y++) { - float v= color_balance_fl((float)y * (1.0 / 255.0f), lift, gain, gamma, mul); + float v= color_balance_fl((float)y * (1.0f / 255.0f), lift, gain, gamma, mul); table[y] = v; } } @@ -1547,14 +1559,14 @@ int input_have_to_preprocess( mul = seq->mul; if(seq->blend_mode == SEQ_BLEND_REPLACE) { - mul *= seq->blend_opacity / 100.0; + mul *= seq->blend_opacity / 100.0f; } - if (mul != 1.0) { + if (mul != 1.0f) { return TRUE; } - if (seq->sat != 1.0) { + if (seq->sat != 1.0f) { return TRUE; } @@ -1643,7 +1655,7 @@ static ImBuf * input_preprocess( mul = seq->mul; if(seq->blend_mode == SEQ_BLEND_REPLACE) { - mul *= seq->blend_opacity / 100.0; + mul *= seq->blend_opacity / 100.0f; } if(seq->flag & SEQ_USE_COLOR_BALANCE && seq->strip->color_balance) { @@ -1660,7 +1672,7 @@ static ImBuf * input_preprocess( } } - if(mul != 1.0) { + if(mul != 1.0f) { multibuf(ibuf, mul); } @@ -1765,7 +1777,7 @@ static ImBuf* seq_render_effect_strip_impl( if (fcu) { fac = facf = evaluate_fcurve(fcu, cfra); if( context.scene->r.mode & R_FIELDS ) { - facf = evaluate_fcurve(fcu, cfra + 0.5); + facf = evaluate_fcurve(fcu, cfra + 0.5f); } } else { fac = facf = seq->effect_fader; @@ -2144,7 +2156,7 @@ static int seq_must_swap_input_in_blend_mode(Sequence * seq) static int seq_get_early_out_for_blend_mode(Sequence * seq) { struct SeqEffectHandle sh = get_sequence_blend(seq); - float facf = seq->blend_opacity / 100.0; + float facf = seq->blend_opacity / 100.0f; int early_out = sh.early_out(seq, facf, facf); if (ELEM(early_out, EARLY_DO_EFFECT, EARLY_NO_INPUT)) { @@ -2252,7 +2264,7 @@ static ImBuf* seq_render_strip_stack( ImBuf * ibuf1 = out; ImBuf * ibuf2 = seq_render_strip(context, seq, cfra); - float facf = seq->blend_opacity / 100.0; + float facf = seq->blend_opacity / 100.0f; int swap_input = seq_must_swap_input_in_blend_mode(seq); if (swap_input) { @@ -2974,6 +2986,24 @@ void seq_translate(Scene *evil_scene, Sequence *seq, int delta) calc_sequence_disp(evil_scene, seq); } +void seq_sound_init(Scene *scene, Sequence *seq) +{ + if(seq->type==SEQ_META) { + Sequence *seq_child; + for(seq_child= seq->seqbase.first; seq_child; seq_child= seq_child->next) { + seq_sound_init(scene, seq_child); + } + } + else { + if(seq->sound) { + seq->scene_sound = sound_add_scene_sound(scene, seq, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); + } + if(seq->scene) { + sound_scene_add_scene_sound(scene, seq, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); + } + } +} + Sequence *seq_foreground_frame_get(Scene *scene, int frame) { Editing *ed= seq_give_editing(scene, FALSE); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index cfc98b4a67d..52e1faaabee 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -329,7 +329,7 @@ static float sound_get_volume(Scene* scene, Sequence* sequence, float time) fcu= list_find_fcurve(&adt->action->curves, buf, 0); if(fcu) - return evaluate_fcurve(fcu, time * FPS); + return evaluate_fcurve(fcu, time * (float)FPS); else return sequence->volume; } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 54bd4a86a5e..3041a4c59e6 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -851,7 +851,11 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for(x = 1; x < edgeSize - 1; x++, i++) { vd= ccgSubSurf_getEdgeData(ss, e, x); copy_v3_v3(mvert[i].co, vd->co); - /* XXX, This gives errors with -fpe, the normals dont seem to be unit length - campbell */ + /* This gives errors with -debug-fpe + * the normals dont seem to be unit length. + * this is most likely caused by edges with no + * faces which are now zerod out, see comment in: + * ccgSubSurf__calcVertNormals(), - campbell */ normal_float_to_short_v3(mvert[i].no, vd->no); } } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index c0261d3b5a3..5dbaee2a7b8 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -223,9 +223,9 @@ void init_mapping(TexMapping *texmap) size_to_mat3( smat,texmap->size); - eul[0]= (M_PI/180.0f)*texmap->rot[0]; - eul[1]= (M_PI/180.0f)*texmap->rot[1]; - eul[2]= (M_PI/180.0f)*texmap->rot[2]; + eul[0]= DEG2RADF(texmap->rot[0]); + eul[1]= DEG2RADF(texmap->rot[1]); + eul[2]= DEG2RADF(texmap->rot[2]); eul_to_mat3( rmat,eul); mul_m3_m3m3(mat, rmat, smat); @@ -342,8 +342,11 @@ int do_colorband(ColorBand *coba, float in, float out[4]) if(cbd2->pos!=cbd1->pos) fac= (in-cbd1->pos)/(cbd2->pos-cbd1->pos); - else - fac= 0.0f; + else { + /* was setting to 0.0 in 2.56 & previous, but this + * is incorrect for the last element, see [#26732] */ + fac= (a != coba->tot) ? 0.0f : 1.0f; + } if (coba->ipotype==4) { /* constant */ @@ -373,10 +376,10 @@ int do_colorband(ColorBand *coba, float in, float out[4]) out[1]= t[3]*cbd3->g +t[2]*cbd2->g +t[1]*cbd1->g +t[0]*cbd0->g; out[2]= t[3]*cbd3->b +t[2]*cbd2->b +t[1]*cbd1->b +t[0]*cbd0->b; out[3]= t[3]*cbd3->a +t[2]*cbd2->a +t[1]*cbd1->a +t[0]*cbd0->a; - CLAMP(out[0], 0.0, 1.0); - CLAMP(out[1], 0.0, 1.0); - CLAMP(out[2], 0.0, 1.0); - CLAMP(out[3], 0.0, 1.0); + CLAMP(out[0], 0.0f, 1.0f); + CLAMP(out[1], 0.0f, 1.0f); + CLAMP(out[2], 0.0f, 1.0f); + CLAMP(out[3], 0.0f, 1.0f); } else { diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index d4084412f63..37e604fa0cb 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -344,9 +344,7 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC /* Convert to a string */ { - char conv_str[6] = {'%', '.', '0', 'l', 'f', '\0'}; /* "%.2lf" when prec is 2, must be under 10 */ - conv_str[2] += prec; - len= snprintf(str, len_max, conv_str, (float)value_conv); + len= snprintf(str, len_max, "%.*lf", prec, value_conv); if(len >= len_max) len= len_max; diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index 0385ad5846f..ee8c3d5e10c 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -185,6 +185,9 @@ void vec_apply_track(float vec[3], short axis); float lens_to_angle(float lens); float angle_to_lens(float angle); +float angle_wrap_rad(float angle); +float angle_wrap_deg(float angle); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index bee5c031fc9..a376d048412 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -206,7 +206,7 @@ # ifdef __GNUC__ /* just want to check if __func__ is available */ # define BLI_assert(a) \ do { \ - if (0 == (a)) { \ + if (!(a)) { \ fprintf(stderr, \ "BLI_assert failed: %s, %s(), %d at \'%s\'\n", \ __FILE__, __func__, __LINE__, STRINGIFY(a)); \ diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index 957e5fd0b78..d0eb3c7d67d 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -127,7 +127,7 @@ typedef struct _DIR { struct dirent direntry; } DIR; -void RegisterBlendExtension(char * str); +void RegisterBlendExtension(void); DIR *opendir (const char *path); struct dirent *readdir(DIR *dp); int closedir (DIR *dp); diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 0f4f6c8e45d..0fe028eb3c0 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -88,10 +88,10 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf // adjust font size height= ((double) face->bbox.yMax - (double) face->bbox.yMin); - if(height != 0.0) - scale = 1.0 / height; + if(height != 0.0f) + scale = 1.0f / height; else - scale = 1.0 / 1000.0; + scale = 1.0f / 1000.0f; // // Generate the character 3D data @@ -167,20 +167,20 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf if(k < npoints[j] - 1 ) { if( ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l+1] == FT_Curve_Tag_Conic) { - dx = (ftoutline.points[l].x + ftoutline.points[l+1].x)* scale / 2.0; - dy = (ftoutline.points[l].y + ftoutline.points[l+1].y)* scale / 2.0; + dx = (ftoutline.points[l].x + ftoutline.points[l+1].x)* scale / 2.0f; + dy = (ftoutline.points[l].y + ftoutline.points[l+1].y)* scale / 2.0f; //left handle - bezt->vec[0][0] = (dx + (2 * ftoutline.points[l].x)* scale) / 3.0; - bezt->vec[0][1] = (dy + (2 * ftoutline.points[l].y)* scale) / 3.0; + bezt->vec[0][0] = (dx + (2 * ftoutline.points[l].x)* scale) / 3.0f; + bezt->vec[0][1] = (dy + (2 * ftoutline.points[l].y)* scale) / 3.0f; //midpoint (virtual on-curve point) bezt->vec[1][0] = dx; bezt->vec[1][1] = dy; //right handle - bezt->vec[2][0] = (dx + (2 * ftoutline.points[l+1].x)* scale) / 3.0; - bezt->vec[2][1] = (dy + (2 * ftoutline.points[l+1].y)* scale) / 3.0; + bezt->vec[2][0] = (dx + (2 * ftoutline.points[l+1].x)* scale) / 3.0f; + bezt->vec[2][1] = (dy + (2 * ftoutline.points[l+1].y)* scale) / 3.0f; bezt->h1= bezt->h2= HD_ALIGN; bezt->radius= 1.0f; @@ -197,12 +197,12 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->vec[0][1] = ftoutline.points[l-1].y* scale; bezt->h1= HD_FREE; } else if(ftoutline.tags[l - 1] == FT_Curve_Tag_Conic) { - bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l - 1].x))* scale / 3.0; - bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l - 1].y))* scale / 3.0; + bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l - 1].x))* scale / 3.0f; + bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l - 1].y))* scale / 3.0f; bezt->h1= HD_FREE; } else { - bezt->vec[0][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[l-1].x)* scale / 3.0; - bezt->vec[0][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[l-1].y)* scale / 3.0; + bezt->vec[0][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[l-1].x)* scale / 3.0f; + bezt->vec[0][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[l-1].y)* scale / 3.0f; bezt->h1= HD_VECT; } } else { //first point on curve @@ -211,12 +211,12 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->vec[0][1] = ftoutline.points[ftoutline.contours[j]].y * scale; bezt->h1= HD_FREE; } else if(ftoutline.tags[ftoutline.contours[j]] == FT_Curve_Tag_Conic) { - bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[ftoutline.contours[j]].x))* scale / 3.0 ; - bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[ftoutline.contours[j]].y))* scale / 3.0 ; + bezt->vec[0][0] = (ftoutline.points[l].x + (2 * ftoutline.points[ftoutline.contours[j]].x))* scale / 3.0f; + bezt->vec[0][1] = (ftoutline.points[l].y + (2 * ftoutline.points[ftoutline.contours[j]].y))* scale / 3.0f; bezt->h1= HD_FREE; } else { - bezt->vec[0][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[ftoutline.contours[j]].x)* scale / 3.0; - bezt->vec[0][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[ftoutline.contours[j]].y)* scale / 3.0; + bezt->vec[0][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[ftoutline.contours[j]].x)* scale / 3.0f; + bezt->vec[0][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[ftoutline.contours[j]].y)* scale / 3.0f; bezt->h1= HD_VECT; } } @@ -232,12 +232,12 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->vec[2][1] = ftoutline.points[l+1].y* scale; bezt->h2= HD_FREE; } else if(ftoutline.tags[l+1] == FT_Curve_Tag_Conic) { - bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l+1].x))* scale / 3.0; - bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l+1].y))* scale / 3.0; + bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[l+1].x))* scale / 3.0f; + bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[l+1].y))* scale / 3.0f; bezt->h2= HD_FREE; } else { - bezt->vec[2][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[l+1].x)* scale / 3.0; - bezt->vec[2][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[l+1].y)* scale / 3.0; + bezt->vec[2][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[l+1].x)* scale / 3.0f; + bezt->vec[2][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[l+1].y)* scale / 3.0f; bezt->h2= HD_VECT; } } else { //last point on curve @@ -246,12 +246,12 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->vec[2][1] = ftoutline.points[m].y* scale; bezt->h2= HD_FREE; } else if(ftoutline.tags[m] == FT_Curve_Tag_Conic) { - bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[m].x))* scale / 3.0 ; - bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[m].y))* scale / 3.0 ; + bezt->vec[2][0] = (ftoutline.points[l].x + (2 * ftoutline.points[m].x))* scale / 3.0f; + bezt->vec[2][1] = (ftoutline.points[l].y + (2 * ftoutline.points[m].y))* scale / 3.0f; bezt->h2= HD_FREE; } else { - bezt->vec[2][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[m].x)* scale / 3.0; - bezt->vec[2][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[m].y)* scale / 3.0; + bezt->vec[2][0] = ftoutline.points[l].x* scale - (ftoutline.points[l].x - ftoutline.points[m].x)* scale / 3.0f; + bezt->vec[2][1] = ftoutline.points[l].y* scale - (ftoutline.points[l].y - ftoutline.points[m].y)* scale / 3.0f; bezt->h2= HD_VECT; } } @@ -261,10 +261,10 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf // len_squared_v2v2, see if there's a distance between the three points // len_squared_v2v2 again, to check the angle between the handles // finally, check if one of them is a vector handle - if((dist_to_line_v2(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001) && - (len_squared_v2v2(bezt->vec[0], bezt->vec[1]) > 0.0001*0.0001) && - (len_squared_v2v2(bezt->vec[1], bezt->vec[2]) > 0.0001*0.0001) && - (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > 0.0002*0.0001) && + if((dist_to_line_v2(bezt->vec[0],bezt->vec[1],bezt->vec[2]) < 0.001f) && + (len_squared_v2v2(bezt->vec[0], bezt->vec[1]) > 0.0001f*0.0001f) && + (len_squared_v2v2(bezt->vec[1], bezt->vec[2]) > 0.0001f*0.0001f) && + (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > 0.0002f*0.0001f) && (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > MAX2(len_squared_v2v2(bezt->vec[0], bezt->vec[1]), len_squared_v2v2(bezt->vec[1], bezt->vec[2]))) && bezt->h1 != HD_VECT && bezt->h2 != HD_VECT) { diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 4e37de93ded..dfd715ccbf2 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1675,3 +1675,19 @@ float angle_to_lens(float angle) { return 16.0f / tanf(angle * 0.5f); } + +/* 'mod_inline(-3,4)= 1', 'fmod(-3,4)= -3' */ +static float mod_inline(float a, float b) +{ + return a - (b * floorf(a / b)); +} + +float angle_wrap_rad(float angle) +{ + return mod_inline(angle + (float)M_PI, (float)M_PI*2.0f) - (float)M_PI; +} + +float angle_wrap_deg(float angle) +{ + return mod_inline(angle + 180.0f, 360.0f) - 180.0f; +} diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 0dc09606533..689c6398705 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -587,20 +587,7 @@ int BLI_path_frame(char *path, int frame, int digits) if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */ char tmp[FILE_MAX]; -#if 0 // neat but breaks on non ascii strings. - char format[64]; - sprintf(format, "%%.%ds%%.%dd%%s", ch_sta, ch_end-ch_sta); /* example result: "%.12s%.5d%s" */ - sprintf(tmp, format, path, frame, path+ch_end); -#else - char format[8]; - char *p; - sprintf(format, "%%.%dd", ch_end-ch_sta); /* example result: "%.5d" */ - memcpy(tmp, path, sizeof(char) * ch_sta); - p= tmp + ch_sta; - p += sprintf(p, format, frame); - memcpy(p, path + ch_end, strlen(path + ch_end)); - *(tmp+strlen(path)) = '\0'; -#endif + sprintf(tmp, "%.*s%.*d%s", ch_sta, path, ch_end-ch_sta, frame, path+ch_end); strcpy(path, tmp); return 1; } @@ -615,19 +602,9 @@ int BLI_path_frame_range(char *path, int sta, int end, int digits) ensure_digits(path, digits); if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */ - char tmp[FILE_MAX], format[64]; -#if 0 // neat but breaks on non ascii strings. - sprintf(format, "%%.%ds%%.%dd_%%.%dd%%s", ch_sta, ch_end-ch_sta, ch_end-ch_sta); /* example result: "%.12s%.5d-%.5d%s" */ - sprintf(tmp, format, path, sta, end, path+ch_end); + char tmp[FILE_MAX]; + sprintf(tmp, "%.*s%.*d-%.*d%s", ch_sta, path, ch_end-ch_sta, sta, ch_end-ch_sta, end, path+ch_end); strcpy(path, tmp); -#else - char *tmp_pt; - BLI_snprintf(format, sizeof(format), "%%.%dd-%%.%dd%%s", digits, digits); - memcpy(tmp, path, ch_sta * sizeof(char)); - tmp_pt = &tmp[ch_sta]; - tmp_pt += BLI_snprintf(tmp_pt, sizeof(tmp)-ch_sta, format, sta, end, &path[ch_end]); - memcpy(path, tmp, (int)(tmp_pt - tmp) + 1); -#endif return 1; } return 0; diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index a6dae7958cc..2f750545223 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -43,6 +43,7 @@ #include "BLI_string.h" #include "BKE_utildefines.h" +#include "BKE_global.h" #define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY #include "BLI_winstuff.h" @@ -64,39 +65,108 @@ int BLI_getInstallationDir( char * str ) { return 1; } +void RegisterBlendExtension_Fail(HKEY root) +{ + printf("failed\n"); + if (root) + RegCloseKey(root); + if (!G.background) + MessageBox(0,"Could not register file extension.","Blender error",MB_OK|MB_ICONERROR); + TerminateProcess(GetCurrentProcess(),1); +} -void RegisterBlendExtension(char * str) { +void RegisterBlendExtension(void) { LONG lresult; HKEY hkey = 0; + HKEY root = 0; + BOOL usr_mode = FALSE; DWORD dwd = 0; - char buffer[128]; - - lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\shell\\open\\command", 0, - "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); + char buffer[256]; - if (lresult == ERROR_SUCCESS) { - sprintf(buffer, "\"%s\" \"%%1\"", str); - lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1); - RegCloseKey(hkey); + char BlPath[MAX_PATH]; + char InstallDir[FILE_MAXDIR]; + char SysDir[FILE_MAXDIR]; + char* ThumbHandlerDLL; + char RegCmd[MAX_PATH*2]; + char MBox[256]; + BOOL IsWOW64; + + printf("Registering file extension..."); + GetModuleFileName(0,BlPath,MAX_PATH); + + // root is HKLM by default + lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); + if (lresult != ERROR_SUCCESS) + { + // try HKCU on failure + usr_mode = TRUE; + lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); + if (lresult != ERROR_SUCCESS) + RegisterBlendExtension_Fail(0); } - lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\DefaultIcon", 0, - "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); - + lresult = RegCreateKeyEx(root, "blendfile", 0, + NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); if (lresult == ERROR_SUCCESS) { - sprintf(buffer, "\"%s\",1", str); - lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1); + sprintf(buffer,"%s","Blender File"); + lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1); RegCloseKey(hkey); } + if (lresult != ERROR_SUCCESS) + RegisterBlendExtension_Fail(root); - lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".blend", 0, - "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); + lresult = RegCreateKeyEx(root, "blendfile\\shell\\open\\command", 0, + NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); + if (lresult == ERROR_SUCCESS) { + sprintf(buffer, "\"%s\" \"%%1\"", BlPath); + lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1); + RegCloseKey(hkey); + } + if (lresult != ERROR_SUCCESS) + RegisterBlendExtension_Fail(root); + lresult = RegCreateKeyEx(root, "blendfile\\DefaultIcon", 0, + NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); + if (lresult == ERROR_SUCCESS) { + sprintf(buffer, "\"%s\",1", BlPath); + lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1); + RegCloseKey(hkey); + } + if (lresult != ERROR_SUCCESS) + RegisterBlendExtension_Fail(root); + + lresult = RegCreateKeyEx(root, ".blend", 0, + NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); if (lresult == ERROR_SUCCESS) { sprintf(buffer, "%s", "blendfile"); - lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1); + lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1); RegCloseKey(hkey); } + if (lresult != ERROR_SUCCESS) + RegisterBlendExtension_Fail(root); + + BLI_getInstallationDir(InstallDir); + GetSystemDirectory(SysDir,FILE_MAXDIR); +#ifdef WIN64 + ThumbHandlerDLL = "BlendThumb64.dll"; +#else + IsWow64Process(GetCurrentProcess(),&IsWOW64); + if (IsWOW64 == TRUE) + ThumbHandlerDLL = "BlendThumb64.dll"; + else + ThumbHandlerDLL = "BlendThumb.dll"; +#endif + snprintf(RegCmd,MAX_PATH*2,"%s\\regsvr32 /s \"%s\\%s\"",SysDir,InstallDir,ThumbHandlerDLL); + system(RegCmd); + + RegCloseKey(root); + printf("success (%s)\n",usr_mode ? "user" : "system"); + if (!G.background) + { + sprintf(MBox,"File extension registered for %s.",usr_mode ? "the current user. To register for all users, run as an administrator" : "all users"); + MessageBox(0,MBox,"Blender",MB_OK|MB_ICONINFORMATION); + } + TerminateProcess(GetCurrentProcess(),0); } DIR *opendir (const char *path) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6e93aa3ec90..9a3520153c1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12183,6 +12183,8 @@ static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt) static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part) { + int a; + expand_doit(fd, mainvar, part->dup_ob); expand_doit(fd, mainvar, part->dup_group); expand_doit(fd, mainvar, part->eff_group); @@ -12190,6 +12192,13 @@ static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSetting if(part->adt) expand_animdata(fd, mainvar, part->adt); + + for(a=0; amtex[a]) { + expand_doit(fd, mainvar, part->mtex[a]->tex); + expand_doit(fd, mainvar, part->mtex[a]->object); + } + } } static void expand_group(FileData *fd, Main *mainvar, Group *group) @@ -12443,50 +12452,19 @@ static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm) } } -static void expand_modifier(FileData *fd, Main *mainvar, ModifierData *md) +static void expand_object_expandModifiers(void *userData, Object *UNUSED(ob), + ID **idpoin) { - if (md->type==eModifierType_Lattice) { - LatticeModifierData *lmd = (LatticeModifierData*) md; - - expand_doit(fd, mainvar, lmd->object); - } - else if (md->type==eModifierType_Curve) { - CurveModifierData *cmd = (CurveModifierData*) md; - - expand_doit(fd, mainvar, cmd->object); - } - else if (md->type==eModifierType_Array) { - ArrayModifierData *amd = (ArrayModifierData*) md; - - expand_doit(fd, mainvar, amd->curve_ob); - expand_doit(fd, mainvar, amd->offset_ob); - } - else if (md->type==eModifierType_Mirror) { - MirrorModifierData *mmd = (MirrorModifierData*) md; - - expand_doit(fd, mainvar, mmd->mirror_ob); - } - else if (md->type==eModifierType_Displace) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; - - expand_doit(fd, mainvar, dmd->map_object); - expand_doit(fd, mainvar, dmd->texture); - } - else if (md->type==eModifierType_Smoke) { - SmokeModifierData *smd = (SmokeModifierData*) md; - - if(smd->type==MOD_SMOKE_TYPE_DOMAIN && smd->domain) - { - expand_doit(fd, mainvar, smd->domain->coll_group); - expand_doit(fd, mainvar, smd->domain->fluid_group); - expand_doit(fd, mainvar, smd->domain->eff_group); - } - } + struct { FileData *fd; Main *mainvar; } *data= userData; + + FileData *fd= data->fd; + Main *mainvar= data->mainvar; + + expand_doit(fd, mainvar, *idpoin); } static void expand_object(FileData *fd, Main *mainvar, Object *ob) { - ModifierData *md; ParticleSystem *psys; bSensor *sens; bController *cont; @@ -12496,9 +12474,14 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) int a; expand_doit(fd, mainvar, ob->data); - - for (md=ob->modifiers.first; md; md=md->next) { - expand_modifier(fd, mainvar, md); + + /* expand_object_expandModifier() */ + if(ob->modifiers.first) { + struct { FileData *fd; Main *mainvar; } data; + data.fd= fd; + data.mainvar= mainvar; + + modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data); } expand_pose(fd, mainvar, ob->pose); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index b0bbe49a182..72341e1caa2 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -103,7 +103,7 @@ DocumentImporter::DocumentImporter(bContext *C, const char *filename) : DocumentImporter::~DocumentImporter() { - std::map::iterator etit; + TagsMap::iterator etit; etit = uid_tags_map.begin(); while(etit!=uid_tags_map.end()) { delete etit->second; @@ -863,98 +863,161 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) { if(mImportStage!=General) return true; - + Lamp *lamp = NULL; std::string la_id, la_name; - + + TagsMap::iterator etit; + ExtraTags *et = 0; + etit = uid_tags_map.find(light->getUniqueId().toAscii()); + if(etit != uid_tags_map.end()) + et = etit->second; + la_id = light->getOriginalId(); la_name = light->getName(); if (la_name.size()) lamp = (Lamp*)add_lamp((char*)la_name.c_str()); else lamp = (Lamp*)add_lamp((char*)la_id.c_str()); - + if (!lamp) { fprintf(stderr, "Cannot create lamp. \n"); return true; } - if (light->getColor().isValid()) { - COLLADAFW::Color col = light->getColor(); - lamp->r = col.getRed(); - lamp->g = col.getGreen(); - lamp->b = col.getBlue(); + + // if we find an ExtraTags for this, use that instead. + if(et && et->isProfile("blender")) { + et->setData("type", &(lamp->type)); + et->setData("flag", &(lamp->flag)); + et->setData("mode", &(lamp->mode)); + et->setData("gamma", &(lamp->k)); + et->setData("red", &(lamp->r)); + et->setData("green", &(lamp->g)); + et->setData("blue", &(lamp->b)); + et->setData("shadow_r", &(lamp->shdwr)); + et->setData("shadow_g", &(lamp->shdwg)); + et->setData("shadow_b", &(lamp->shdwb)); + et->setData("energy", &(lamp->energy)); + et->setData("dist", &(lamp->dist)); + et->setData("spotsize", &(lamp->spotsize)); + et->setData("spotblend", &(lamp->spotblend)); + et->setData("halo_intensity", &(lamp->haint)); + et->setData("att1", &(lamp->att1)); + et->setData("att2", &(lamp->att2)); + et->setData("falloff_type", &(lamp->falloff_type)); + et->setData("clipsta", &(lamp->clipsta)); + et->setData("clipend", &(lamp->clipend)); + et->setData("shadspotsize", &(lamp->shadspotsize)); + et->setData("bias", &(lamp->bias)); + et->setData("soft", &(lamp->soft)); + et->setData("compressthresh", &(lamp->compressthresh)); + et->setData("bufsize", &(lamp->bufsize)); + et->setData("samp", &(lamp->samp)); + et->setData("buffers", &(lamp->buffers)); + et->setData("filtertype", &(lamp->filtertype)); + et->setData("bufflag", &(lamp->bufflag)); + et->setData("buftype", &(lamp->buftype)); + et->setData("ray_samp", &(lamp->ray_samp)); + et->setData("ray_sampy", &(lamp->ray_sampy)); + et->setData("ray_sampz", &(lamp->ray_sampz)); + et->setData("ray_samp_type", &(lamp->ray_samp_type)); + et->setData("area_shape", &(lamp->area_shape)); + et->setData("area_size", &(lamp->area_size)); + et->setData("area_sizey", &(lamp->area_sizey)); + et->setData("area_sizez", &(lamp->area_sizez)); + et->setData("adapt_thresh", &(lamp->adapt_thresh)); + et->setData("ray_samp_method", &(lamp->ray_samp_method)); + et->setData("shadhalostep", &(lamp->shadhalostep)); + et->setData("sun_effect_type", &(lamp->shadhalostep)); + et->setData("skyblendtype", &(lamp->skyblendtype)); + et->setData("horizon_brightness", &(lamp->horizon_brightness)); + et->setData("spread", &(lamp->spread)); + et->setData("sun_brightness", &(lamp->sun_brightness)); + et->setData("sun_size", &(lamp->sun_size)); + et->setData("backscattered_light", &(lamp->backscattered_light)); + et->setData("sun_intensity", &(lamp->sun_intensity)); + et->setData("atm_turbidity", &(lamp->atm_turbidity)); + et->setData("atm_extinction_factor", &(lamp->atm_extinction_factor)); + et->setData("atm_distance_factor", &(lamp->atm_distance_factor)); + et->setData("skyblendfac", &(lamp->skyblendfac)); + et->setData("sky_exposure", &(lamp->sky_exposure)); + et->setData("sky_colorspace", &(lamp->sky_colorspace)); } - float constatt = light->getConstantAttenuation().getValue(); - float linatt = light->getLinearAttenuation().getValue(); - float quadatt = light->getQuadraticAttenuation().getValue(); - float d = 25.0f; - float att1 = 0.0f; - float att2 = 0.0f; - - float e = 1.0f/constatt; - - /* NOTE: We assume for now that inv square is used for quadratic light - * and inv linear for linear light. Exported blender lin/quad weighted - * most likely will result in wrong import. */ - /* quadratic light */ - if(IS_EQ(linatt, 0.0f) && quadatt > 0.0f) { - //quadatt = att2/(d*d*(e*2)); - float invquadatt = 1.0f/quadatt; - float d2 = invquadatt / (2 * e); - d = sqrtf(d2); - } - // linear light - else if(IS_EQ(quadatt, 0.0f) && linatt > 0.0f) { - //linatt = att1/(d*e); - float invlinatt = 1.0f/linatt; - d = invlinatt / e; - } else { - printf("no linear nor quad light, using defaults for attenuation, import will be incorrect: Lamp %s\n", lamp->id.name); - att2 = 1.0f; - } - - lamp->dist = d; - lamp->energy = e; - - COLLADAFW::Light::LightType type = light->getLightType(); - switch(type) { - case COLLADAFW::Light::AMBIENT_LIGHT: - { - lamp->type = LA_HEMI; + else { + float constatt = light->getConstantAttenuation().getValue(); + float linatt = light->getLinearAttenuation().getValue(); + float quadatt = light->getQuadraticAttenuation().getValue(); + float d = 25.0f; + float att1 = 0.0f; + float att2 = 0.0f; + float e = 1.0f; + + if (light->getColor().isValid()) { + COLLADAFW::Color col = light->getColor(); + lamp->r = col.getRed(); + lamp->g = col.getGreen(); + lamp->b = col.getBlue(); } - break; - case COLLADAFW::Light::SPOT_LIGHT: - { - lamp->type = LA_SPOT; - lamp->falloff_type = LA_FALLOFF_INVSQUARE; - lamp->att1 = att1; - lamp->att2 = att2; - lamp->spotsize = light->getFallOffAngle().getValue(); - lamp->spotblend = light->getFallOffExponent().getValue(); + + if(IS_EQ(linatt, 0.0f) && quadatt > 0.0f) { + att2 = quadatt; + d = (1.0f/quadatt) * 2; } - break; - case COLLADAFW::Light::DIRECTIONAL_LIGHT: - { - /* our sun is very strong, so pick a smaller energy level */ - lamp->type = LA_SUN; - lamp->energy = 1.0; - lamp->mode |= LA_NO_SPEC; + // linear light + else if(IS_EQ(quadatt, 0.0f) && linatt > 0.0f) { + att1 = linatt; + d = (1.0f/linatt) * 2; + } else if (IS_EQ(constatt, 1.0f)) { + att1 = 1.0f; + } else { + // assuming point light (const att = 1.0); + att1 = 1.0f; } - break; - case COLLADAFW::Light::POINT_LIGHT: - { - lamp->type = LA_LOCAL; - lamp->falloff_type = LA_FALLOFF_INVSQUARE; - lamp->att1 = att1; - lamp->att2 = att2; - } - break; - case COLLADAFW::Light::UNDEFINED: - { - fprintf(stderr, "Current lamp type is not supported. \n"); - lamp->type = LA_LOCAL; - } - break; - } + d *= ( 1.0f / unit_converter.getLinearMeter()); + + lamp->energy = e; + lamp->dist = d; + + COLLADAFW::Light::LightType type = light->getLightType(); + switch(type) { + case COLLADAFW::Light::AMBIENT_LIGHT: + { + lamp->type = LA_HEMI; + } + break; + case COLLADAFW::Light::SPOT_LIGHT: + { + lamp->type = LA_SPOT; + lamp->falloff_type = LA_FALLOFF_INVSQUARE; + lamp->att1 = att1; + lamp->att2 = att2; + lamp->spotsize = light->getFallOffAngle().getValue(); + lamp->spotblend = light->getFallOffExponent().getValue(); + } + break; + case COLLADAFW::Light::DIRECTIONAL_LIGHT: + { + /* our sun is very strong, so pick a smaller energy level */ + lamp->type = LA_SUN; + lamp->mode |= LA_NO_SPEC; + } + break; + case COLLADAFW::Light::POINT_LIGHT: + { + lamp->type = LA_LOCAL; + lamp->falloff_type = LA_FALLOFF_INVSQUARE; + lamp->att1 = att1; + lamp->att2 = att2; + } + break; + case COLLADAFW::Light::UNDEFINED: + { + fprintf(stderr, "Current lamp type is not supported. \n"); + lamp->type = LA_LOCAL; + } + break; + } + } + this->uid_lamp_map[light->getUniqueId()] = lamp; return true; } @@ -1007,15 +1070,15 @@ bool DocumentImporter::writeKinematicsScene( const COLLADAFW::KinematicsScene* k ExtraTags* DocumentImporter::getExtraTags(const COLLADAFW::UniqueId &uid) { - if(uid_tags_map.find(uid)==uid_tags_map.end()) { + if(uid_tags_map.find(uid.toAscii())==uid_tags_map.end()) { return NULL; } - return uid_tags_map[uid]; + return uid_tags_map[uid.toAscii()]; } bool DocumentImporter::addExtraTags( const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags) { - uid_tags_map[uid] = extra_tags; + uid_tags_map[uid.toAscii()] = extra_tags; return true; } diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h index 1905dfe6a3e..e57d621eeef 100644 --- a/source/blender/collada/DocumentImporter.h +++ b/source/blender/collada/DocumentImporter.h @@ -139,13 +139,17 @@ private: ArmatureImporter armature_importer; MeshImporter mesh_importer; AnimationImporter anim_importer; + + /** TagsMap typedef for uid_tags_map. */ + typedef std::map TagsMap; + /** Tags map of unique id as a string and ExtraTags instance. */ + TagsMap uid_tags_map; std::map uid_image_map; std::map uid_material_map; std::map uid_effect_map; std::map uid_camera_map; std::map uid_lamp_map; - std::map uid_tags_map; std::map material_texture_mapping_map; std::map object_map; std::map node_map; diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp index 9dc5f4e4ee6..9999a61a470 100644 --- a/source/blender/collada/ExtraHandler.cpp +++ b/source/blender/collada/ExtraHandler.cpp @@ -47,9 +47,6 @@ bool ExtraHandler::elementBegin( const char* elementName, const char** attribute bool ExtraHandler::elementEnd(const char* elementName ) { - currentUid = COLLADAFW::UniqueId(); - currentExtraTags = 0; - currentElement.clear(); return true; } @@ -60,7 +57,7 @@ bool ExtraHandler::textData(const char* text, size_t textLength) if(currentElement.length() == 0) return false; BLI_snprintf(buf, textLength+1, "%s", text); - currentExtraTags->addTag(std::string(currentElement), std::string(buf)); + currentExtraTags->addTag(currentElement, std::string(buf)); return true; } diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index 772c20c6c4f..653d4a377cd 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -27,24 +27,96 @@ */ #include +#include #include "BLI_string.h" #include #include "ExtraTags.h" -ExtraTags::ExtraTags(const std::string profile) +ExtraTags::ExtraTags( std::string profile) { this->profile = profile; + this->tags = std::map(); } ExtraTags::~ExtraTags() { } -bool ExtraTags::addTag(const std::string tag, const std::string data) +bool ExtraTags::isProfile( std::string profile) { - std::cout << "ready to add " << tag << ": " << data << "." << std::endl; + return this->profile == profile; +} + +bool ExtraTags::addTag( std::string tag, std::string data) +{ + tags[tag] = data; return true; } + +int ExtraTags::asInt( std::string tag, bool *ok) +{ + if(tags.find(tag) == tags.end()) { + *ok = false; + return -1; + } + *ok = true; + return atoi(tags[tag].c_str()); +} + +float ExtraTags::asFloat( std::string tag, bool *ok) +{ + if(tags.find(tag) == tags.end()) { + *ok = false; + return -1.0f; + } + *ok = true; + return (float)atof(tags[tag].c_str()); +} + +std::string ExtraTags::asString( std::string tag, bool *ok) +{ + if(tags.find(tag) == tags.end()) { + *ok = false; + return ""; + } + *ok = true; + return tags[tag]; +} + + +void ExtraTags::setData(std::string tag, short *data) +{ + bool ok = false; + int tmp = 0; + tmp = asInt(tag, &ok); + if(ok) + *data = (short)tmp; +} +void ExtraTags::setData(std::string tag, int *data) +{ + bool ok = false; + int tmp = 0; + tmp = asInt(tag, &ok); + if(ok) + *data = tmp; +} +void ExtraTags::setData(std::string tag, float *data) +{ + bool ok = false; + float tmp = 0.0f; + tmp = asFloat(tag, &ok); + if(ok) + *data = tmp; +} +void ExtraTags::setData(std::string tag, char *data) +{ + bool ok = false; + int tmp = 0; + tmp = asInt(tag, &ok); + if(ok) + *data = (char)tmp; +} + diff --git a/source/blender/collada/ExtraTags.h b/source/blender/collada/ExtraTags.h index 09a86741481..710d26e8cad 100644 --- a/source/blender/collada/ExtraTags.h +++ b/source/blender/collada/ExtraTags.h @@ -42,7 +42,22 @@ public: virtual ~ExtraTags(); /** Handle the beginning of an element. */ - bool addTag( const std::string tag, const std::string data); + bool addTag(std::string tag, std::string data); + + /** Set given short pointer to value of tag, if it exists. */ + void setData(std::string tag, short *data); + + /** Set given int pointer to value of tag, if it exists. */ + void setData(std::string tag, int *data); + + /** Set given float pointer to value of tag, if it exists. */ + void setData(std::string tag, float *data); + + /** Set given char pointer to value of tag, if it exists. */ + void setData(std::string tag, char *data); + + /** Return true if the extra tags is for specified profile. */ + bool isProfile(std::string profile); private: /** Disable default copy constructor. */ @@ -50,5 +65,16 @@ private: /** Disable default assignment operator. */ const ExtraTags& operator= ( const ExtraTags& pre ); + /** The profile for which the tags are. */ std::string profile; + + /** Map of tag and text pairs. */ + std::map tags; + + /** Get text data for tag as an int. */ + int asInt(std::string tag, bool *ok); + /** Get text data for tag as a float. */ + float asFloat(std::string tag, bool *ok); + /** Get text data for tag as a string. */ + std::string asString(std::string tag, bool *ok); }; diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index d267ee530fb..89599c62768 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -66,32 +66,22 @@ void LightsExporter::operator()(Object *ob) Lamp *la = (Lamp*)ob->data; std::string la_id(get_light_id(ob)); std::string la_name(id_name(la)); - COLLADASW::Color col(la->r, la->g, la->b); - float att1, att2; + COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy); float e, d, constatt, linatt, quadatt; - att1 = att2 = 0.0f; + float r; + + d = la->dist; + r = d/2.0f; + + constatt = 1.0f; if(la->falloff_type==LA_FALLOFF_INVLINEAR) { - att1 = 1.0f; - att2 = 0.0f; + linatt = 1.0f / r; + quadatt = 0.0f; } - else if(la->falloff_type==LA_FALLOFF_INVSQUARE) { - att1 = 0.0f; - att2 = 1.0f; - } - else if(la->falloff_type==LA_FALLOFF_SLIDERS) { - att1 = la->att1; - att2 = la->att2; - } - - e = la->energy; - d = la->dist; - - constatt = linatt = quadatt = MAXFLOAT; - if(e > 0.0f) { - constatt = 1.0f/e; - linatt = att1/(d*e); - quadatt = att2/(d*d*(e*2)); + else { + linatt = 0.0f; + quadatt = 1.0f / r; } // sun @@ -152,6 +142,9 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la) cla.addExtraTechniqueParameter("blender", "flag", la->flag); cla.addExtraTechniqueParameter("blender", "mode", la->mode); cla.addExtraTechniqueParameter("blender", "gamma", la->k); + cla.addExtraTechniqueParameter("blender", "red", la->r); + cla.addExtraTechniqueParameter("blender", "green", la->g); + cla.addExtraTechniqueParameter("blender", "blue", la->b); cla.addExtraTechniqueParameter("blender", "shadow_r", la->shdwr); cla.addExtraTechniqueParameter("blender", "shadow_g", la->shdwg); cla.addExtraTechniqueParameter("blender", "shadow_b", la->shdwb); diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 34142cf63f6..54c6c991a5f 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -818,7 +818,9 @@ static bAnimListElem *make_new_animlistelem (void *data, short datatype, void *o /* ----------------------------------------- */ -/* NOTE: when this function returns true, the F-Curve is to be skipped */ +/* 'Only Selected' selected data filtering + * NOTE: when this function returns true, the F-Curve is to be skipped + */ static int skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode) { if (GS(owner_id->name) == ID_OB) { @@ -890,6 +892,37 @@ static int skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_id return 0; } +/* (Display-)Name-based F-Curve filtering + * NOTE: when this function returns true, the F-Curve is to be skipped + */ +static short skip_fcurve_with_name (bDopeSheet *ads, FCurve *fcu, ID *owner_id) +{ + bAnimListElem ale_dummy = {0}; + bAnimChannelType *acf; + + /* create a dummy wrapper for the F-Curve */ + ale_dummy.type = ANIMTYPE_FCURVE; + ale_dummy.id = owner_id; + ale_dummy.data = fcu; + + /* get type info for channel */ + acf = ANIM_channel_get_typeinfo(&ale_dummy); + if (acf && acf->name) { + char name[256]; /* hopefully this will be enough! */ + + /* get name */ + acf->name(&ale_dummy, name); + + /* check for partial match with the match string, assuming case insensitive filtering + * if match, this channel shouldn't be ignored! + */ + return BLI_strcasestr(name, ads->searchstr) == NULL; + } + + /* just let this go... */ + return 1; +} + /* find the next F-Curve that is usable for inclusion */ static FCurve *animdata_filter_fcurve_next (bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id) { @@ -899,7 +932,7 @@ static FCurve *animdata_filter_fcurve_next (bDopeSheet *ads, FCurve *first, bAct * NOTE: we need to check if the F-Curves belong to the same group, as this gets called for groups too... */ for (fcu= first; ((fcu) && (fcu->grp==grp)); fcu= fcu->next) { - /* special exception for Pose-Channel Based F-Curves: + /* special exception for Pose-Channel/Sequence-Strip/Node Based F-Curves: * - the 'Only Selected' data filter should be applied to Pose-Channel data too, but those are * represented as F-Curves. The way the filter for objects worked was to be the first check * after 'normal' visibility, so this is done first here too... @@ -911,7 +944,7 @@ static FCurve *animdata_filter_fcurve_next (bDopeSheet *ads, FCurve *first, bAct if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode)) continue; } - + /* only include if visible (Graph Editor check, not channels check) */ if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & FCURVE_VISIBLE)) { /* only work with this channel and its subchannels if it is editable */ @@ -920,6 +953,12 @@ static FCurve *animdata_filter_fcurve_next (bDopeSheet *ads, FCurve *first, bAct if ( ANIMCHANNEL_SELOK(SEL_FCU(fcu)) && ANIMCHANNEL_SELEDITOK(SEL_FCU(fcu)) ) { /* only include if this curve is active */ if (!(filter_mode & ANIMFILTER_ACTIVE) || (fcu->flag & FCURVE_ACTIVE)) { + /* name based filtering... */ + if ( ((ads) && (ads->filterflag & ADS_FILTER_BY_FCU_NAME)) && (owner_id) ) { + if (skip_fcurve_with_name(ads, fcu, owner_id)) + continue; + } + /* this F-Curve can be used, so return it */ return fcu; } diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 720413650fa..67773d358d0 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -182,16 +182,16 @@ static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3 t2= cotan_weight(v2, v3, v1); t3= cotan_weight(v3, v1, v2); - if(RAD2DEG(angle_v3v3v3(v2, v1, v3)) > 90) obtuse= 1; - else if(RAD2DEG(angle_v3v3v3(v1, v2, v3)) > 90) obtuse= 2; - else if(RAD2DEG(angle_v3v3v3(v1, v3, v2)) > 90) obtuse= 3; + if(RAD2DEGF(angle_v3v3v3(v2, v1, v3)) > 90) obtuse= 1; + else if(RAD2DEGF(angle_v3v3v3(v1, v2, v3)) > 90) obtuse= 2; + else if(RAD2DEGF(angle_v3v3v3(v1, v3, v2)) > 90) obtuse= 3; if (obtuse > 0) { area= area_tri_v3(v1, v2, v3); - varea[i1] += (obtuse == 1)? area: area*0.5; - varea[i2] += (obtuse == 2)? area: area*0.5; - varea[i3] += (obtuse == 3)? area: area*0.5; + varea[i1] += (obtuse == 1)? area: area*0.5f; + varea[i2] += (obtuse == 2)? area: area*0.5f; + varea[i3] += (obtuse == 3)? area: area*0.5f; } else { len1= len_v3v3(v2, v3); @@ -492,7 +492,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) sub_v3_v3v3(data.vec, end, data.start); madd_v3_v3v3fl(data.start, data.start, data.vec, 1e-5); - mul_v3_fl(data.vec, 1.0f - 2e-5); + mul_v3_fl(data.vec, 1.0f - 2e-5f); /* pass normalized vec + distance to bvh */ hit.index = -1; @@ -1041,9 +1041,9 @@ void rigid_deform_end(int cancel) #define MESHDEFORM_TAG_INTERIOR 2 #define MESHDEFORM_TAG_EXTERIOR 3 -#define MESHDEFORM_LEN_THRESHOLD 1e-6 +#define MESHDEFORM_LEN_THRESHOLD 1e-6f -#define MESHDEFORM_MIN_INFLUENCE 0.0005 +#define MESHDEFORM_MIN_INFLUENCE 0.0005f static int MESHDEFORM_OFFSET[7][3] = {{0,0,0}, {1,0,0}, {-1,0,0}, {0,1,0}, {0,-1,0}, {0,0,1}, {0,0,-1}}; @@ -1146,7 +1146,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], isectco[1]= (1.0f - u - v)*vert0[1] + u*vert1[1] + v*vert2[1]; isectco[2]= (1.0f - u - v)*vert0[2] + u*vert1[2] + v*vert2[2]; - uvw[0]= 1.0 - u - v; + uvw[0]= 1.0f - u - v; uvw[1]= u; uvw[2]= v; diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index e47ec0029a0..203d76086b3 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -63,6 +63,7 @@ #include "ED_armature.h" #include "ED_keyframes_draw.h" +#include "ED_markers.h" #include "ED_screen.h" #include "armature_intern.h" @@ -862,16 +863,30 @@ void POSE_OT_breakdown (wmOperatorType *ot) /* "termination conditions" - i.e. when we stop */ typedef enum ePosePropagate_Termination { - /* stop when we run out of keyframes */ - POSE_PROPAGATE_LAST_KEY = 0, + /* stop after the current hold ends */ + POSE_PROPAGATE_SMART_HOLDS = 0, + /* only do on the last keyframe */ + POSE_PROPAGATE_LAST_KEY, /* stop after the next keyframe */ POSE_PROPAGATE_NEXT_KEY, /* stop after the specified frame */ POSE_PROPAGATE_BEFORE_FRAME, - /* stop after */ - POSE_PROPAGATE_SMART_HOLDS + /* stop when we run out of keyframes */ + POSE_PROPAGATE_BEFORE_END, + + /* only do on the frames where markers are selected */ + POSE_PROPAGATE_SELECTED_MARKERS } ePosePropagate_Termination; +/* termination data needed for some modes - assumes only one of these entries will be needed at a time */ +typedef union tPosePropagate_ModeData { + /* smart holds + before frame: frame number to stop on */ + float end_frame; + + /* selected markers: listbase for CfraElem's marking these frames */ + ListBase sel_markers; +} tPosePropagate_ModeData; + /* --------------------------------- */ /* get frame on which the "hold" for the bone ends @@ -1028,7 +1043,8 @@ static float pose_propagate_get_refVal (Object *ob, FCurve *fcu) } /* propagate just works along each F-Curve in turn */ -static void pose_propagate_fcurve (wmOperator *op, Object *ob, tPChanFCurveLink *UNUSED(pfl), FCurve *fcu, float startFrame, float endFrame) +static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, + float startFrame, tPosePropagate_ModeData modeData) { const int mode = RNA_enum_get(op->ptr, "mode"); @@ -1065,14 +1081,33 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, tPChanFCurveLink /* additional termination conditions based on the operator 'mode' property go here... */ if (ELEM(mode, POSE_PROPAGATE_BEFORE_FRAME, POSE_PROPAGATE_SMART_HOLDS)) { /* stop if keyframe is outside the accepted range */ - if (bezt->vec[1][0] > endFrame) - break; + if (bezt->vec[1][0] > modeData.end_frame) + break; } else if (mode == POSE_PROPAGATE_NEXT_KEY) { /* stop after the first keyframe has been processed */ if (first == 0) break; } + else if (mode == POSE_PROPAGATE_LAST_KEY) { + /* only affect this frame if it will be the last one */ + if (i != (fcu->totvert-1)) + continue; + } + else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) { + /* only allow if there's a marker on this frame */ + CfraElem *ce = NULL; + + /* stop on matching marker if there is one */ + for (ce = modeData.sel_markers.first; ce; ce = ce->next) { + if (ce->cfra == (int)(floor(bezt->vec[1][0] + 0.5f))) + break; + } + + /* skip this keyframe if no marker */ + if (ce == NULL) + continue; + } /* just flatten handles, since values will now be the same either side... */ // TODO: perhaps a fade-out modulation of the value is required here (optional once again)? @@ -1095,7 +1130,7 @@ static int pose_propagate_exec (bContext *C, wmOperator *op) ListBase pflinks = {NULL, NULL}; tPChanFCurveLink *pfl; - float endFrame = RNA_float_get(op->ptr, "end_frame"); + tPosePropagate_ModeData modeData; const int mode = RNA_enum_get(op->ptr, "mode"); /* sanity checks */ @@ -1111,6 +1146,16 @@ static int pose_propagate_exec (bContext *C, wmOperator *op) /* isolate F-Curves related to the selected bones */ poseAnim_mapping_get(C, &pflinks, ob, act); + /* mode-specific data preprocessing (requiring no access to curves) */ + if (mode == POSE_PROPAGATE_SELECTED_MARKERS) { + /* get a list of selected markers */ + ED_markers_make_cfra_list(&scene->markers, &modeData.sel_markers, SELECT); + } + else { + /* assume everything else wants endFrame */ + modeData.end_frame = RNA_float_get(op->ptr, "end_frame"); + } + /* for each bone, perform the copying required */ for (pfl = pflinks.first; pfl; pfl = pfl->next) { LinkData *ld; @@ -1120,17 +1165,20 @@ static int pose_propagate_exec (bContext *C, wmOperator *op) /* we store in endFrame the end frame of the "long keyframe" (i.e. a held value) starting * from the keyframe that occurs after the current frame */ - endFrame = pose_propagate_get_boneHoldEndFrame(ob, pfl, (float)CFRA); + modeData.end_frame = pose_propagate_get_boneHoldEndFrame(ob, pfl, (float)CFRA); } /* go through propagating pose to keyframes, curve by curve */ for (ld = pfl->fcurves.first; ld; ld= ld->next) - pose_propagate_fcurve(op, ob, pfl, (FCurve *)ld->data, (float)CFRA, endFrame); + pose_propagate_fcurve(op, ob, (FCurve *)ld->data, (float)CFRA, modeData); } /* free temp data */ poseAnim_mapping_free(&pflinks); + if (mode == POSE_PROPAGATE_SELECTED_MARKERS) + BLI_freelistN(&modeData.sel_markers); + /* updates + notifiers */ poseAnim_mapping_refresh(C, scene, ob); @@ -1142,10 +1190,12 @@ static int pose_propagate_exec (bContext *C, wmOperator *op) void POSE_OT_propagate (wmOperatorType *ot) { static EnumPropertyItem terminate_items[]= { - {POSE_PROPAGATE_LAST_KEY, "LAST_KEY", 0, "Last Keyframe", ""}, - {POSE_PROPAGATE_NEXT_KEY, "NEXT_KEY", 0, "Next Keyframe", ""}, - {POSE_PROPAGATE_BEFORE_FRAME, "BEFORE_FRAME", 0, "Before Frame", "Propagate pose to all keyframes between current frame and 'Frame' property"}, {POSE_PROPAGATE_SMART_HOLDS, "WHILE_HELD", 0, "While Held", "Propagate pose to all keyframes after current frame that don't change (Default behaviour)"}, + {POSE_PROPAGATE_NEXT_KEY, "NEXT_KEY", 0, "To Next Keyframe", "Propagate pose to first keyframe following the current frame only"}, + {POSE_PROPAGATE_LAST_KEY, "LAST_KEY", 0, "To Last Keyframe", "Propagate pose to the last keyframe only (i.e. making action cyclic)"}, + {POSE_PROPAGATE_BEFORE_FRAME, "BEFORE_FRAME", 0, "Before Frame", "Propagate pose to all keyframes between current frame and 'Frame' property"}, + {POSE_PROPAGATE_BEFORE_END, "BEFORE_END", 0, "Before Last Keyframe", "Propagate pose to all keyframes from current frame until no more are found"}, + {POSE_PROPAGATE_SELECTED_MARKERS, "SELECTED_MARKERS", 0, "On Selected Markers", "Propagate pose to all keyframes occurring on frames with Scene Markers after the current frame"}, {0, NULL, 0, NULL, NULL}}; /* identifiers */ @@ -1163,7 +1213,7 @@ void POSE_OT_propagate (wmOperatorType *ot) /* properties */ // TODO: add "fade out" control for tapering off amount of propagation as time goes by? ot->prop= RNA_def_enum(ot->srna, "mode", terminate_items, POSE_PROPAGATE_SMART_HOLDS, "Terminate Mode", "Method used to determine when to stop propagating pose to keyframes"); - RNA_def_float(ot->srna, "end_frame", 250.0, FLT_MIN, FLT_MAX, "End Frame", "Frame to stop propagating frames to", 1.0, 250.0); + RNA_def_float(ot->srna, "end_frame", 250.0, FLT_MIN, FLT_MAX, "End Frame", "Frame to stop propagating frames to (for 'Before Frame' mode)", 1.0, 250.0); } /* **************************************************** */ diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 16e84db0ba7..7ade93076e5 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -128,7 +128,6 @@ static void fcurves_to_pchan_links_get (ListBase *pfLinks, Object *ob, bAction * /* get sets of F-Curves providing transforms for the bones in the Pose */ -// TODO: separate the inner workings out to another helper func, since we need option of whether to take selected or visible bones... void poseAnim_mapping_get (bContext *C, ListBase *pfLinks, Object *ob, bAction *act) { /* for each Pose-Channel which gets affected, get the F-Curves for that channel @@ -139,6 +138,17 @@ void poseAnim_mapping_get (bContext *C, ListBase *pfLinks, Object *ob, bAction * fcurves_to_pchan_links_get(pfLinks, ob, act, pchan); } CTX_DATA_END; + + /* if no PoseChannels were found, try a second pass, doing visible ones instead + * i.e. if nothing selected, do whole pose + */ + if (pfLinks->first == NULL) { + CTX_DATA_BEGIN(C, bPoseChannel*, pchan, visible_pose_bones) + { + fcurves_to_pchan_links_get(pfLinks, ob, act, pchan); + } + CTX_DATA_END; + } } /* free F-Curve <-> PoseChannel links */ diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index c8aabdfe033..1c9ad8fe247 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -156,6 +156,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_SEL); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_SEL); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_SEL); /* same as above [#26623] */ RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_ALL); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 12d1327da68..9b5f1546898 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -87,6 +87,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" /* Undo stuff */ typedef struct { @@ -4755,7 +4756,7 @@ void CURVE_OT_extrude(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* to give to transform */ - RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); + RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); } /***************** make cyclic operator **********************/ @@ -5629,7 +5630,7 @@ void CURVE_OT_duplicate(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* to give to transform */ - RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); + RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); } /********************** delete operator *********************/ diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 276f60bdf7f..7abdb1f8f07 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -81,6 +81,7 @@ enum { GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */ GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */ GP_DRAWDATA_IEDITHACK = (1<<4), /* special hack for drawing strokes in Image Editor (weird coordinates) */ + GP_DRAWDATA_NO_XRAY = (1<<5), /* dont draw xray in 3D view (which is default) */ }; /* thickness above which we should use special drawing */ @@ -506,8 +507,35 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int /* check which stroke-drawer to use */ if (gps->totpoints == 1) gp_draw_stroke_point(gps->points, lthick, gps->flag, offsx, offsy, winx, winy); - else if (dflag & GP_DRAWDATA_ONLY3D) + else if (dflag & GP_DRAWDATA_ONLY3D) { + const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY); + int mask_orig; + if(no_xray) { + glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); + glDepthMask(0); + glEnable(GL_DEPTH_TEST); + + /* first arg is normally rv3d->dist, but this isnt available here and seems to work quite well without */ + bglPolygonOffset(1.0f, 1.0f); + /* + glEnable(GL_POLYGON_OFFSET_LINE); + glPolygonOffset(-1.0f, -1.0f); + */ + } + gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug); + + if(no_xray) { + glDepthMask(mask_orig); + glDisable(GL_DEPTH_TEST); + + bglPolygonOffset(0.0, 0.0); + /* + glDisable(GL_POLYGON_OFFSET_LINE); + glPolygonOffset(0, 0); + */ + } + } else if (gps->totpoints > 1) gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy); } @@ -516,7 +544,8 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int /* draw grease-pencil datablock */ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) { - bGPDlayer *gpl, *actlay=NULL; + bGPDlayer *gpl; + // bGPDlayer *actlay=NULL; // UNUSED /* reset line drawing style (in case previous user didn't reset) */ setlinestyle(0); @@ -541,8 +570,8 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy continue; /* if layer is active one, store pointer to it */ - if (gpl->flag & GP_LAYER_ACTIVE) - actlay= gpl; + // if (gpl->flag & GP_LAYER_ACTIVE) + // actlay= gpl; /* get frame to draw */ gpf= gpencil_layer_getframe(gpl, cfra, 0); @@ -555,7 +584,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy QUATCOPY(tcolor, gpl->color); // additional copy of color (for ghosting) glColor4f(color[0], color[1], color[2], color[3]); glPointSize((float)(gpl->thickness + 2)); - + + /* apply xray layer setting */ + if(gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY; + else dflag &= ~GP_DRAWDATA_NO_XRAY; + /* draw 'onionskins' (frame left + right) */ if (gpl->flag & GP_LAYER_ONIONSKIN) { /* drawing method - only immediately surrounding (gstep = 0), or within a frame range on either side (gstep > 0)*/ diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 47a9c007951..8df89a29f28 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -91,7 +91,7 @@ static void gp_ui_dellayer_cb (bContext *C, void *gpd, void *gpl) /* ------- Drawing Code ------- */ /* draw the controls for a given layer */ -static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl) +static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, const short is_v3d) { uiLayout *box=NULL, *split=NULL; uiLayout *col=NULL, *subcol=NULL; @@ -214,6 +214,10 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl) subcol= uiLayoutColumn(col, 1); uiItemR(subcol, &ptr, "use_onion_skinning", 0, "Onion Skinning", ICON_NONE); uiItemR(subcol, &ptr, "ghost_range_max", 0, "Frames", ICON_NONE); // XXX shorter name here? i.e. GStep + + if(is_v3d) { + uiItemR(subcol, &ptr, "show_x_ray", 0, "X-Ray", ICON_NONE); + } } } @@ -232,6 +236,7 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi bGPDlayer *gpl; uiLayout *col, *row; short v3d_stroke_opts = STROKE_OPTS_NORMAL; + const short is_v3d= CTX_wm_view3d(C) != NULL; /* make new PointerRNA for Grease Pencil block */ RNA_id_pointer_create((ID *)gpd, &gpd_ptr); @@ -255,7 +260,7 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi /* draw each layer --------------------------------------------- */ for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { col= uiLayoutColumn(layout, 1); - gp_drawui_layer(col, gpd, gpl); + gp_drawui_layer(col, gpd, gpl, is_v3d); } /* draw gpd drawing settings first ------------------------------------- */ @@ -264,7 +269,7 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi uiItemL(col, "Drawing Settings:", ICON_NONE); /* check whether advanced 3D-View drawing space options can be used */ - if (CTX_wm_view3d(C)) { + if (is_v3d) { if (gpd->flag & (GP_DATA_DEPTH_STROKE|GP_DATA_DEPTH_VIEW)) v3d_stroke_opts = STROKE_OPTS_V3D_ON; else diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 2f2f9c37bdc..17e7c0c221b 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1594,6 +1594,18 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } +/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ +static int gpencil_area_exists(bContext *C, ScrArea *satest) +{ + bScreen *sc= CTX_wm_screen(C); + ScrArea *sa; + + for(sa= sc->areabase.first; sa; sa= sa->next) + if(sa==satest) + return 1; + return 0; +} + /* events handling during interactive drawing part of operator */ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) { @@ -1659,6 +1671,8 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) } } + + /* handle mode-specific events */ if (p->status == GP_STATUS_PAINTING) { /* handle painting mouse-movements? */ @@ -1705,8 +1719,12 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) } } - /* update status indicators - cursor, header, etc. */ - gpencil_draw_status_indicators(p); + /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ + if(0==gpencil_area_exists(C, p->sa)) + estate= OPERATOR_CANCELLED; + else + /* update status indicators - cursor, header, etc. */ + gpencil_draw_status_indicators(p); /* process last operations before exiting */ switch (estate) { diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 93537928c92..166046aa64e 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1528,18 +1528,13 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen) if(ui_is_but_unit(but)) { ui_get_but_string_unit(but, str, maxlen, value, 0); } - else if(but->a2) { /* amount of digits defined */ - if(but->a2==1) BLI_snprintf(str, maxlen, "%.1f", value); - else if(but->a2==2) BLI_snprintf(str, maxlen, "%.2f", value); - else if(but->a2==3) BLI_snprintf(str, maxlen, "%.3f", value); - else if(but->a2==4) BLI_snprintf(str, maxlen, "%.4f", value); - else if(but->a2==5) BLI_snprintf(str, maxlen, "%.5f", value); - else if(but->a2==6) BLI_snprintf(str, maxlen, "%.6f", value); - else if(but->a2==7) BLI_snprintf(str, maxlen, "%.7f", value); - else BLI_snprintf(str, maxlen, "%.4f", value); + else { + int prec= (int)but->a2; + if(prec==0) prec= 3; + else CLAMP(prec, 1, 7); + + BLI_snprintf(str, maxlen, "%.*f", prec, value); } - else - BLI_snprintf(str, maxlen, "%.3f", value); } else BLI_snprintf(str, maxlen, "%d", (int)value); @@ -1913,7 +1908,7 @@ void ui_check_but(uiBut *but) { /* if something changed in the button */ double value; - float okwidth; +// float okwidth; // UNUSED // int transopts= ui_translate_buttons(); ui_is_but_sel(but); @@ -1967,7 +1962,7 @@ void ui_check_but(uiBut *but) /* safety is 4 to enable small number buttons (like 'users') */ - okwidth= -4 + (but->x2 - but->x1); + // okwidth= -4 + (but->x2 - but->x1); // UNUSED /* name: */ switch( but->type ) { @@ -1989,27 +1984,20 @@ void ui_check_but(uiBut *but) value= ui_get_but_val(but); if(ui_is_but_float(but)) { - if(value == FLT_MAX) sprintf(but->drawstr, "%sinf", but->str); - else if(value == -FLT_MAX) sprintf(but->drawstr, "%s-inf", but->str); + if(value == (double) FLT_MAX) sprintf(but->drawstr, "%sinf", but->str); + else if(value == (double) -FLT_MAX) sprintf(but->drawstr, "%s-inf", but->str); /* support length type buttons */ else if(ui_is_but_unit(but)) { char new_str[sizeof(but->drawstr)]; ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); } - else if(but->a2) { /* amount of digits defined */ - if(but->a2==1) sprintf(but->drawstr, "%s%.1f", but->str, value); - else if(but->a2==2) sprintf(but->drawstr, "%s%.2f", but->str, value); - else if(but->a2==3) sprintf(but->drawstr, "%s%.3f", but->str, value); - else if(but->a2==4) sprintf(but->drawstr, "%s%.4f", but->str, value); - else if(but->a2==5) sprintf(but->drawstr, "%s%.5f", but->str, value); - else if(but->a2==6) sprintf(but->drawstr, "%s%.6f", but->str, value); - else if(but->a2==7) sprintf(but->drawstr, "%s%.7f", but->str, value); - else sprintf(but->drawstr, "%s%.4f", but->str, value); - } else { - if(but->hardmax<10.001f) sprintf(but->drawstr, "%s%.3f", but->str, value); - else sprintf(but->drawstr, "%s%.2f", but->str, value); + int prec= (int)but->a2; + if(prec==0) prec= (but->hardmax < 10.001f) ? 3 : 2; + else CLAMP(prec, 1, 7); + + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value); } } else { @@ -2026,22 +2014,16 @@ void ui_check_but(uiBut *but) case LABEL: if(ui_is_but_float(but)) { + int prec= (int)but->a2; value= ui_get_but_val(but); - if(but->a2) { /* amount of digits defined */ - if(but->a2==1) sprintf(but->drawstr, "%s%.1f", but->str, value); - else if(but->a2==2) sprintf(but->drawstr, "%s%.2f", but->str, value); - else if(but->a2==3) sprintf(but->drawstr, "%s%.3f", but->str, value); - else if(but->a2==4) sprintf(but->drawstr, "%s%.4f", but->str, value); - else if(but->a2==5) sprintf(but->drawstr, "%s%.5f", but->str, value); - else if(but->a2==6) sprintf(but->drawstr, "%s%.6f", but->str, value); - else if(but->a2==7) sprintf(but->drawstr, "%s%.7f", but->str, value); - else sprintf(but->drawstr, "%s%.4f", but->str, value); - } - else { - sprintf(but->drawstr, "%s%.2f", but->str, value); - } + if(prec==0) prec= 3; + else CLAMP(prec, 1, 7); + + BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value); + } + else { + strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); } - else strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); break; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 648eee07ca0..47713cdb13c 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3671,12 +3671,12 @@ static int in_scope_resize_zone(uiBut *but, int UNUSED(x), int y) static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx, int my) { Histogram *hist = (Histogram *)but->poin; - rcti rect; + /* rcti rect; */ int changed= 1; float dx, dy, yfac=1.f; - rect.xmin= but->x1; rect.xmax= but->x2; - rect.ymin= but->y1; rect.ymax= but->y2; + /* rect.xmin= but->x1; rect.xmax= but->x2; */ + /* rect.ymin= but->y1; rect.ymax= but->y2; */ dx = mx - data->draglastx; dy = my - data->draglasty; @@ -3754,12 +3754,12 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, int my) { Scopes *scopes = (Scopes *)but->poin; - rcti rect; + /* rcti rect; */ int changed= 1; float dx, dy, yfac=1.f; - rect.xmin= but->x1; rect.xmax= but->x2; - rect.ymin= but->y1; rect.ymax= but->y2; + /* rect.xmin= but->x1; rect.xmax= but->x2; */ + /* rect.ymin= but->y1; rect.ymax= but->y2; */ dx = mx - data->draglastx; dy = my - data->draglasty; @@ -3837,12 +3837,12 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int mx, int my) { Scopes *scopes = (Scopes *)but->poin; - rcti rect; + /* rcti rect; */ int changed= 1; /* float dx, dy; */ - rect.xmin= but->x1; rect.xmax= but->x2; - rect.ymin= but->y1; rect.ymax= but->y2; + /* rect.xmin= but->x1; rect.xmax= but->x2; */ + /* rect.ymin= but->y1; rect.ymax= but->y2; */ /* dx = mx - data->draglastx; */ /* dy = my - data->draglasty; */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 03c50d213c1..37af293e3aa 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -129,7 +129,7 @@ typedef struct IconTexture { /* ******************* STATIC LOCAL VARS ******************* */ /* static here to cache results of icon directory scan, so it's not * scanning the filesystem each time the menu is drawn */ -static struct ListBase iconfilelist = {0, 0}; +static struct ListBase iconfilelist = {NULL, NULL}; static IconTexture icongltex = {0, 0, 0, 0.0f, 0.0f}; /* **************************************************** */ @@ -144,7 +144,7 @@ static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int new_icon = MEM_callocN(sizeof(Icon), "texicon"); - new_icon->obj = 0; /* icon is not for library object */ + new_icon->obj = NULL; /* icon is not for library object */ new_icon->type = 0; di = MEM_callocN(sizeof(DrawInfo), "drawinfo"); @@ -184,14 +184,14 @@ static void def_internal_vicon( int icon_id, VectorDrawFunc drawFunc) new_icon = MEM_callocN(sizeof(Icon), "texicon"); - new_icon->obj = 0; /* icon is not for library object */ + new_icon->obj = NULL; /* icon is not for library object */ new_icon->type = 0; di = MEM_callocN(sizeof(DrawInfo), "drawinfo"); di->type= ICON_TYPE_VECTOR; di->data.vector.func =drawFunc; - new_icon->drawinfo_free = 0; + new_icon->drawinfo_free = NULL; new_icon->drawinfo = di; BKE_icon_set(icon_id, new_icon); @@ -667,7 +667,7 @@ static void init_iconfile_list(struct ListBase *list) if (dir[i].string) MEM_freeN(dir[i].string); } free(dir); - dir= 0; + dir= NULL; } static void free_iconfile_list(struct ListBase *list) @@ -1072,11 +1072,11 @@ static int ui_id_brush_get_icon(bContext *C, ID *id) tool = br->sculpt_tool; } else if(mode == OB_MODE_VERTEX_PAINT) { - items = brush_vertexpaint_tool_items; + items = brush_vertex_tool_items; tool = br->vertexpaint_tool; } else if(mode == OB_MODE_TEXTURE_PAINT) { - items = brush_imagepaint_tool_items; + items = brush_image_tool_items; tool = br->imagepaint_tool; } diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 25dbcf81c26..b47194ba1b4 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1097,6 +1097,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) }*/ } else if(event->type==PADPLUSKEY || event->type==PADMINUS) { +#if 0 // XXX make float panel exception? int zoom=0; /* if panel is closed, only zoom if mouse is over the header */ @@ -1107,7 +1108,6 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) else zoom=1; -#if 0 // XXX make float panel exception? if(zoom) { ScrArea *sa= CTX_wm_area(C); SpaceLink *sl= sa->spacedata.first; diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index b4b049d8b4d..7be089fdf32 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -291,7 +291,9 @@ void uiStyleInit(void) uiStyle *style= U.uistyles.first; /* recover from uninitialized dpi */ - CLAMP(U.dpi, 72, 240); + if(U.dpi == 0) + U.dpi= 72; + CLAMP(U.dpi, 48, 128); /* default builtin */ if(font==NULL) { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index caeca5bbaa0..d089ca45cfd 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -330,13 +330,13 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiBut *but; uiBlock *block; PointerRNA idptr; - ListBase *lb; + // ListBase *lb; // UNUSED ID *id, *idfrom; idptr= RNA_property_pointer_get(&template->ptr, template->prop); id= idptr.data; idfrom= template->ptr.id.data; - lb= template->idlb; + // lb= template->idlb; block= uiLayoutGetBlock(layout); uiBlockBeginAlign(block); @@ -920,7 +920,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) PointerRNA ptr; char typestr[32]; short proxy_protected, xco=0, yco=0; - int rb_col; + // int rb_col; // UNUSED /* get constraint typeinfo */ cti= constraint_get_typeinfo(con); @@ -957,7 +957,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) /* Draw constraint header */ /* rounded header */ - rb_col= (con->flag & CONSTRAINT_ACTIVE)?50:20; + // rb_col= (con->flag & CONSTRAINT_ACTIVE)?50:20; // UNUSED /* open/close */ uiBlockSetEmboss(block, UI_EMBOSSN); @@ -1442,6 +1442,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) scopes->wavefrm_height= (scopes->wavefrm_height<=20)?20:scopes->wavefrm_height; bt= uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); + (void)bt; // UNUSED MEM_freeN(cb); } @@ -2389,6 +2390,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiLayout *ui_abs; ui_abs= uiLayoutAbsolute(layout, 0); + (void)ui_abs; // UNUSED uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, 0, UI_UNIT_Y*0.1, UI_UNIT_X*0.8, UI_UNIT_Y*0.8, NULL, 0.0f, 0.0f, 0, 0, "Stop this job"); diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index b72ae1a2a77..f22c8eb4bfe 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -145,16 +145,22 @@ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(Proper continue; if(label_align != '\0') { + PropertyType type = RNA_property_type(prop); + int is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(ptr, prop)); + name= RNA_property_ui_name(prop); if(label_align=='V') { col= uiLayoutColumn(layout, 1); - uiItemL(col, name, ICON_NONE); + + if(!is_boolean) + uiItemL(col, name, ICON_NONE); } else if(label_align=='H') { split = uiLayoutSplit(layout, 0.5f, 0); - uiItemL(uiLayoutColumn(split, 0), name, ICON_NONE); + col= uiLayoutColumn(split, 0); + uiItemL(col, (is_boolean)? "": name, ICON_NONE); col= uiLayoutColumn(split, 0); } else { @@ -163,12 +169,9 @@ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(Proper /* may meed to add more cases here. * don't override enum flag names */ - if(flag & PROP_ENUM_FLAG) { - name= NULL; - } - else { - name= ""; /* name is shown above, empty name for button below */ - } + + /* name is shown above, empty name for button below */ + name= (flag & PROP_ENUM_FLAG || is_boolean)? NULL: ""; } else { col= layout; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index b57d8fda712..29b4779bc69 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2092,12 +2092,10 @@ void ui_draw_link_bezier(rcti *rect) float coord_array[LINK_RESOL+1][2]; if(ui_link_bezier_points(rect, coord_array, LINK_RESOL)) { - float dist; - int i; - /* we can reuse the dist variable here to increment the GL curve eval amount*/ - dist = 1.0f/(float)LINK_RESOL; - + // const float dist= 1.0f/(float)LINK_RESOL; // UNUSED + int i; + glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index d272b03fc22..1a2a2906f1a 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -415,8 +415,83 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo return (unsigned char *)cp; } + +#define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a; +#define SETCOLF(col, r, g, b, a) col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255; #define SETCOLTEST(col, r, g, b, a) if(col[3]==0) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;} +/* use this call to init new bone color sets in Theme */ +static void ui_theme_init_boneColorSets(bTheme *btheme) +{ + int i; + + /* define default color sets - currently we only define 15 of these, though that should be ample */ + /* set 1 */ + SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255); + SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255); + SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255); + /* set 2 */ + SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255); + SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255); + SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255); + /* set 3 */ + SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255); + SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255); + SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255); + /* set 4 */ + SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255); + SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255); + SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255); + /* set 5 */ + SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255); + SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255); + SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255); + /* set 6 */ + SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255); + SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255); + SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255); + /* set 7 */ + SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255); + SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255); + SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255); + /* set 8 */ + SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255); + SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255); + SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255); + /* set 9 */ + SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255); + SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255); + SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255); + /* set 10 */ + SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255); + SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255); + SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255); + /* set 11 */ + SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255); + SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255); + SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255); + /* set 12 */ + SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255); + SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255); + SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255); + /* set 13 */ + SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255); + SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255); + SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255); + /* set 14 */ + SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255); + SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255); + SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255); + /* set 15 */ + SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255); + SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255); + SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255); + + /* reset flags too */ + for (i = 0; i < 20; i++) + btheme->tarm[i].flag = 0; +} + /* use this call to init new variables in themespace, if they're same for all */ static void ui_theme_init_new_do(ThemeSpace *ts) { @@ -462,8 +537,6 @@ static void ui_theme_init_new(bTheme *btheme) } -#define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a; -#define SETCOLF(col, r, g, b, a) col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255; /* initialize default theme Note: when you add new colors, created & saved themes need initialized @@ -488,7 +561,11 @@ void ui_theme_init_default(void) /* UI buttons */ ui_widget_color_init(&btheme->tui); - + btheme->tui.iconfile[0]= 0; + + /* Bone Color Sets */ + ui_theme_init_boneColorSets(btheme); + /* common (new) variables */ ui_theme_init_new(btheme); @@ -525,6 +602,16 @@ void ui_theme_init_default(void) SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255); SETCOL(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255); SETCOL(btheme->tv3d.face_dot, 255, 133, 0, 255); + SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128); + SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0); + SETCOL(btheme->tv3d.edge_sharp, 255, 32, 32, 255); + SETCOL(btheme->tv3d.header_text, 0, 0, 0, 255); + SETCOL(btheme->tv3d.header_text_hi, 255, 255, 255, 255); + SETCOL(btheme->tv3d.button_text, 0, 0, 0, 255); + SETCOL(btheme->tv3d.button_text_hi, 255, 255, 255, 255); + SETCOL(btheme->tv3d.button_title, 0, 0, 0, 255); + SETCOL(btheme->tv3d.title, 0, 0, 0, 255); + btheme->tv3d.facedot_size= 4; SETCOL(btheme->tv3d.extra_edge_len, 32, 0, 0, 255); @@ -1216,69 +1303,8 @@ void init_userdef_do_versions(void) SETCOL(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255); /* bone custom-color sets */ - // FIXME: this check for initialised colors is bad - if (btheme->tarm[0].solid[3] == 0) { - /* set 1 */ - SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255); - SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255); - SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255); - /* set 2 */ - SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255); - SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255); - SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255); - /* set 3 */ - SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255); - SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255); - SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255); - /* set 4 */ - SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255); - SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255); - SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255); - /* set 5 */ - SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255); - SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255); - SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255); - /* set 6 */ - SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255); - SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255); - SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255); - /* set 7 */ - SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255); - SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255); - SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255); - /* set 8 */ - SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255); - SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255); - SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255); - /* set 9 */ - SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255); - SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255); - SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255); - /* set 10 */ - SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255); - SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255); - SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255); - /* set 11 */ - SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255); - SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255); - SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255); - /* set 12 */ - SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255); - SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255); - SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255); - /* set 13 */ - SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255); - SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255); - SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255); - /* set 14 */ - SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255); - SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255); - SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255); - /* set 15 */ - SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255); - SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255); - SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255); - } + if (btheme->tarm[0].solid[3] == 0) + ui_theme_init_boneColorSets(btheme); } } if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) { diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index cec7d7a3d54..af3716b4677 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -452,7 +452,7 @@ static float edgetag_cut_cost(int e1, int e2, int vert) sub_v3_v3v3(d1, v->co, v1->co); sub_v3_v3v3(d2, v2->co, v->co); - cost = cost + 0.5f*cost*(2.0f - fabs(d1[0]*d2[0] + d1[1]*d2[1] + d1[2]*d2[2])); + cost = cost + 0.5f*cost*(2.0f - fabsf(d1[0]*d2[0] + d1[1]*d2[1] + d1[2]*d2[2])); return cost; } diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 887228c9772..f78a23f039d 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -599,7 +599,7 @@ static void edge_normal_compare(EditEdge *eed, EditFace *efa1) if(efa1==efa2) return; inp= efa1->n[0]*efa2->n[0] + efa1->n[1]*efa2->n[1] + efa1->n[2]*efa2->n[2]; - if(inp<0.999 && inp >-0.999) eed->f2= 1; + if(inp<0.999f && inp >-0.999f) eed->f2= 1; if(efa1->v4) cent_quad_v3(cent1, efa1->v1->co, efa1->v2->co, efa1->v3->co, efa1->v4->co); else cent_tri_v3(cent1, efa1->v1->co, efa1->v2->co, efa1->v3->co); @@ -610,7 +610,7 @@ static void edge_normal_compare(EditEdge *eed, EditFace *efa1) normalize_v3(cent1); inp= cent1[0]*efa1->n[0] + cent1[1]*efa1->n[1] + cent1[2]*efa1->n[2]; - if(inp < -0.001 ) eed->f1= 1; + if(inp < -0.001f) eed->f1= 1; } #if 0 @@ -799,10 +799,8 @@ void make_editMesh(Scene *scene, Object *ob) if(!is_paint_sel) eve->f |= (mvert->flag & 1); - if (mvert->flag & ME_HIDE) eve->h= 1; - eve->no[0]= mvert->no[0]/32767.0; - eve->no[1]= mvert->no[1]/32767.0; - eve->no[2]= mvert->no[2]/32767.0; + if (mvert->flag & ME_HIDE) eve->h= 1; + normal_short_to_float_v3(eve->no, mvert->no); eve->bweight= ((float)mvert->bweight)/255.0f; @@ -936,7 +934,7 @@ void load_editMesh(Scene *scene, Object *obedit) EditFace *efa, *efa_act; EditEdge *eed; EditSelection *ese; - float *fp, *newkey, *oldkey, nor[3]; + float *fp, *newkey, *oldkey; int i, a, ototvert; /* this one also tests of edges are not in faces: */ @@ -995,9 +993,7 @@ void load_editMesh(Scene *scene, Object *obedit) VECCOPY(mvert->co, eve->co); /* vertex normal */ - VECCOPY(nor, eve->no); - mul_v3_fl(nor, 32767.0); - VECCOPY(mvert->no, nor); + normal_float_to_short_v3(mvert->no, eve->no); /* note: it used to remove me->dvert when it was not in use, cancelled that... annoying when you have a fresh vgroup */ @@ -1009,7 +1005,7 @@ void load_editMesh(Scene *scene, Object *obedit) mvert->flag |= (eve->f & SELECT); if (eve->h) mvert->flag |= ME_HIDE; - mvert->bweight= (char)(255.0*eve->bweight); + mvert->bweight= (char)(255.0f*eve->bweight); eve= eve->next; mvert++; @@ -1030,8 +1026,8 @@ void load_editMesh(Scene *scene, Object *obedit) if(eed->h & EM_FGON) medge->flag |= ME_FGON; // different defines yes if(eed->h & 1) medge->flag |= ME_HIDE; - medge->crease= (char)(255.0*eed->crease); - medge->bweight= (char)(255.0*eed->bweight); + medge->crease= (char)(255.0f*eed->crease); + medge->bweight= (char)(255.0f*eed->bweight); CustomData_from_em_block(&em->edata, &me->edata, eed->data, a); eed->tmp.l = a++; @@ -1663,7 +1659,7 @@ static void *editMesh_to_undoMesh(void *emv) evec->h= eve->h; evec->keyindex= eve->keyindex; eve->tmp.l = a; /*store index*/ - evec->bweight= (short)(eve->bweight*255.0); + evec->bweight= (short)(eve->bweight*255.0f); CustomData_from_em_block(&em->vdata, &um->vdata, eve->data, a); } @@ -1677,8 +1673,8 @@ static void *editMesh_to_undoMesh(void *emv) eedc->h= eed->h; eedc->seam= eed->seam; eedc->sharp= eed->sharp; - eedc->crease= (short)(eed->crease*255.0); - eedc->bweight= (short)(eed->bweight*255.0); + eedc->crease= (short)(eed->crease*255.0f); + eedc->bweight= (short)(eed->bweight*255.0f); eedc->fgoni= eed->fgoni; eed->tmp.l = a; /*store index*/ CustomData_from_em_block(&em->edata, &um->edata, eed->data, a); diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 3a9859cefcb..ec84d7f830f 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -45,6 +45,7 @@ #include "RNA_define.h" #include "RNA_access.h" +#include "RNA_enum_types.h" #include "BLI_blenlib.h" #include "BLI_math.h" @@ -1099,9 +1100,9 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se phi= 0; phid/=2; for(a=0; a<=tot; a++) { - vec[0]= dia*sin(phi); + vec[0]= dia*sinf(phi); vec[1]= 0.0; - vec[2]= dia*cos(phi); + vec[2]= dia*cosf(phi); eve= addvertlist(em, vec, NULL); eve->f= 1+2+4; if(a==0) v1= eve; @@ -1226,8 +1227,8 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se for(b=0; b<=ext; b++) { for(a=0; apoll= ED_operator_editmesh; /* to give to transform */ - RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); + RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); } diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index db990e033df..d3945a53f0d 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -353,8 +353,8 @@ void EM_editselection_plane(float *plane, EditSelection *ese) we cant make a crossvec from a vec thats the same as the vec unlikely but possible, so make sure if the normal is (0,0,1) that vec isnt the same or in the same direction even.*/ - if (eve->no[0]<0.5) vec[0]=1; - else if (eve->no[1]<0.5) vec[1]=1; + if (eve->no[0]<0.5f) vec[0]=1; + else if (eve->no[1]<0.5f) vec[1]=1; else vec[2]=1; cross_v3_v3v3(plane, eve->no, vec); } @@ -1206,7 +1206,7 @@ short extrudeflag_edges_indiv(EditMesh *em, short flag, float *nor) if(eed->v1->f & eed->v2->f & flag) eed->f |= flag; } - if(nor[0]==0.0 && nor[1]==0.0 && nor[2]==0.0) return 'g'; // g is grab + if(is_zero_v3(nor)) return 'g'; // g is grab return 'n'; // n is for normal constraint } @@ -1328,18 +1328,18 @@ static short extrudeflag_edge(Object *obedit, EditMesh *em, short UNUSED(flag), } if (mmd->flag & MOD_MIR_AXIS_X) - if ( (fabs(co1[0]) < mmd->tolerance) && - (fabs(co2[0]) < mmd->tolerance) ) + if ( (fabsf(co1[0]) < mmd->tolerance) && + (fabsf(co2[0]) < mmd->tolerance) ) ++eed->f2; if (mmd->flag & MOD_MIR_AXIS_Y) - if ( (fabs(co1[1]) < mmd->tolerance) && - (fabs(co2[1]) < mmd->tolerance) ) + if ( (fabsf(co1[1]) < mmd->tolerance) && + (fabsf(co2[1]) < mmd->tolerance) ) ++eed->f2; if (mmd->flag & MOD_MIR_AXIS_Z) - if ( (fabs(co1[2]) < mmd->tolerance) && - (fabs(co2[2]) < mmd->tolerance) ) + if ( (fabsf(co1[2]) < mmd->tolerance) && + (fabsf(co2[2]) < mmd->tolerance) ) ++eed->f2; } } @@ -1485,7 +1485,7 @@ static short extrudeflag_edge(Object *obedit, EditMesh *em, short UNUSED(flag), EM_select_flush(em); - if(nor[0]==0.0 && nor[1]==0.0 && nor[2]==0.0) return 'g'; // grab + if(is_zero_v3(nor)) return 'g'; // grab return 'n'; // normal constraint } @@ -1612,17 +1612,17 @@ short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor, int } if (mmd->flag & MOD_MIR_AXIS_X) - if ( (fabs(co1[0]) < mmd->tolerance) && - (fabs(co2[0]) < mmd->tolerance) ) + if ( (fabsf(co1[0]) < mmd->tolerance) && + (fabsf(co2[0]) < mmd->tolerance) ) ++eed->f2; if (mmd->flag & MOD_MIR_AXIS_Y) - if ( (fabs(co1[1]) < mmd->tolerance) && - (fabs(co2[1]) < mmd->tolerance) ) + if ( (fabsf(co1[1]) < mmd->tolerance) && + (fabsf(co2[1]) < mmd->tolerance) ) ++eed->f2; if (mmd->flag & MOD_MIR_AXIS_Z) - if ( (fabs(co1[2]) < mmd->tolerance) && - (fabs(co2[2]) < mmd->tolerance) ) + if ( (fabsf(co1[2]) < mmd->tolerance) && + (fabsf(co2[2]) < mmd->tolerance) ) ++eed->f2; } } @@ -1774,7 +1774,7 @@ short extrudeflag_vert(Object *obedit, EditMesh *em, short flag, float *nor, int // since its vertex select mode now, it also deselects higher order EM_selectmode_flush(em); - if(nor[0]==0.0 && nor[1]==0.0 && nor[2]==0.0) return 'g'; // g is grab, for correct undo print + if(is_zero_v3(nor)) return 'g'; // g is grab, for correct undo print return 'n'; } @@ -2028,6 +2028,8 @@ void recalc_editnormals(EditMesh *em) } /* build smooth normals for uninitialized normals at faces set to flat */ + /* For such faces the renderer/3Dview and exporters will be using the face normal */ + /* The vertex normals built inside this if-statement are entirely to support the needs of the modeler */ if(found_flat!=0) { for(efa= em->faces.first; efa; efa=efa->next) { efa->v1->tmp.t= 0; @@ -2367,7 +2369,7 @@ UvVertMap *EM_make_uv_vert_map(EditMesh *em, int selected, int do_face_idx_array sub_v2_v2v2(uvdiff, uv2, uv); - if(fabs(uv[0]-uv2[0]) < limit[0] && fabs(uv[1]-uv2[1]) < limit[1]) { + if(fabsf(uv[0]-uv2[0]) < limit[0] && fabsf(uv[1]-uv2[1]) < limit[1]) { if(lastv) lastv->next= next; else vlist= next; iterv->next= newvlist; diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index a6f05b8c2f6..375ec474382 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -735,7 +735,7 @@ static EnumPropertyItem prop_similar_types[] = { /* this as a way to compare the ares, perim of 2 faces thay will scale to different sizes *0.5 so smaller faces arnt ALWAYS selected with a thresh of 1.0 */ -#define SCALE_CMP(a,b) ((a+a*thresh >= b) && (a-(a*thresh*0.5) <= b)) +#define SCALE_CMP(a,b) ((a+a*thresh >= b) && (a-(a*thresh*0.5f) <= b)) static int similar_face_select__internal(EditMesh *em, int mode, float thresh) { @@ -828,8 +828,8 @@ static int similar_face_select__internal(EditMesh *em, int mode, float thresh) float angle; for(efa= em->faces.first; efa; efa= efa->next) { if (!(efa->f & SELECT) && !efa->h) { - angle= RAD2DEG(angle_v2v2(base_efa->n, efa->n)); - if (angle/180.0<=thresh) { + angle= RAD2DEGF(angle_v2v2(base_efa->n, efa->n)); + if (angle/180.0f<=thresh) { EM_select_face(efa, 1); selcount++; deselcount--; @@ -843,10 +843,10 @@ static int similar_face_select__internal(EditMesh *em, int mode, float thresh) base_dot= dot_v3v3(base_efa->cent, base_efa->n); for(efa= em->faces.first; efa; efa= efa->next) { if (!(efa->f & SELECT) && !efa->h) { - angle= RAD2DEG(angle_v2v2(base_efa->n, efa->n)); - if (angle/180.0<=thresh) { + angle= RAD2DEGF(angle_v2v2(base_efa->n, efa->n)); + if (angle/180.0f<=thresh) { dot=dot_v3v3(efa->cent, base_efa->n); - if (fabs(base_dot-dot) <= thresh) { + if (fabsf(base_dot-dot) <= thresh) { EM_select_face(efa, 1); selcount++; deselcount--; @@ -960,7 +960,7 @@ static int similar_edge_select__internal(EditMesh *em, int mode, float thresh) else if (eed->f2==0) /* first access, assign the face */ eed->tmp.f= efa; else if (eed->f2==1) /* second, we assign the angle*/ - eed->tmp.fp= RAD2DEG(angle_v2v2(eed->tmp.f->n, efa->n))/180; + eed->tmp.fp= RAD2DEGF(angle_v2v2(eed->tmp.f->n, efa->n))/180; eed->f2++; /* f2==0 no face assigned. f2==1 one face found. f2==2 angle calculated.*/ } j++; @@ -990,12 +990,12 @@ static int similar_edge_select__internal(EditMesh *em, int mode, float thresh) for(eed= em->edges.first; eed; eed= eed->next) { if (!(eed->f & SELECT) && !eed->h) { sub_v3_v3v3(dir, eed->v1->co, eed->v2->co); - angle= RAD2DEG(angle_v2v2(base_dir, dir)); + angle= RAD2DEGF(angle_v2v2(base_dir, dir)); - if (angle>90) /* use the smallest angle between the edges */ - angle= fabs(angle-180.0f); + if (angle>90.0f) /* use the smallest angle between the edges */ + angle= fabsf(angle-180.0f); - if (angle/90.0<=thresh) { + if (angle / 90.0f<=thresh) { EM_select_edge(eed, 1); selcount++; deselcount--; @@ -1024,7 +1024,7 @@ static int similar_edge_select__internal(EditMesh *em, int mode, float thresh) !(eed->f & SELECT) && !eed->h && eed->f2==2 && - (fabs(base_eed->tmp.fp-eed->tmp.fp)<=thresh) + (fabsf(base_eed->tmp.fp-eed->tmp.fp)<=thresh) ) { EM_select_edge(eed, 1); selcount++; @@ -1038,7 +1038,7 @@ static int similar_edge_select__internal(EditMesh *em, int mode, float thresh) if ( !(eed->f & SELECT) && !eed->h && - (fabs(base_eed->crease-eed->crease) <= thresh) + (fabsf(base_eed->crease-eed->crease) <= thresh) ) { EM_select_edge(eed, 1); selcount++; @@ -1160,8 +1160,8 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) float angle; for(eve= em->verts.first; eve; eve= eve->next) { if (!(eve->f & SELECT) && !eve->h) { - angle= RAD2DEG(angle_v2v2(base_eve->no, eve->no)); - if (angle/180.0<=thresh) { + angle= RAD2DEGF(angle_v2v2(base_eve->no, eve->no)); + if (angle/180.0f<=thresh) { eve->f |= SELECT; selcount++; deselcount--; @@ -2971,7 +2971,7 @@ static int select_sharp_edges_exec(bContext *C, wmOperator *op) } sharpness= RNA_float_get(op->ptr, "sharpness"); - fsharpness = ((180.0 - sharpness) * M_PI) / 180.0; + fsharpness = ((180.0f - sharpness) * (float)M_PI) / 180.0f; /* count edges, use tmp.l */ eed= em->edges.first; @@ -3031,7 +3031,7 @@ static int select_sharp_edges_exec(bContext *C, wmOperator *op) angle = saacos(efa1[i]->n[0]*efa2[i]->n[0] + efa1[i]->n[1]*efa2[i]->n[1] + efa1[i]->n[2]*efa2[i]->n[2]); - if (fabs(angle) >= fsharpness) + if (fabsf(angle) >= fsharpness) EM_select_edge(eed, 1); } } @@ -3087,7 +3087,7 @@ static void select_linked_flat_faces(EditMesh *em, wmOperator *op, float sharpne return; } - fsharpness = ((180.0 - sharpness) * M_PI) / 180.0; + fsharpness = ((180.0f - sharpness) * (float)M_PI) / 180.0f; i=0; /* count edges, use tmp.l */ @@ -3153,7 +3153,7 @@ static void select_linked_flat_faces(EditMesh *em, wmOperator *op, float sharpne efa1[i]->n[1]*efa2[i]->n[1] + efa1[i]->n[2]*efa2[i]->n[2]); /* invalidate: edge too sharp */ - if (fabs(angle) >= fsharpness) + if (fabsf(angle) >= fsharpness) eed->tmp.l = -1; } else { @@ -3937,10 +3937,10 @@ void EM_recalc_normal_direction(EditMesh *em, int inside, int select) /* makes f } /* first normal is oriented this way or the other */ if(inside) { - if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] > 0.0) flipface(em, startvl); + if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] > 0.0f) flipface(em, startvl); } else { - if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] < 0.0) flipface(em, startvl); + if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] < 0.0f) flipface(em, startvl); } eed= startvl->e1; @@ -4136,15 +4136,15 @@ static int smooth_vertex(bContext *C, wmOperator *op) switch(mmd->axis){ case 0: - if (fabs(eve->co[0]) < mmd->tolerance) + if (fabsf(eve->co[0]) < mmd->tolerance) eve->f2 |= 1; break; case 1: - if (fabs(eve->co[1]) < mmd->tolerance) + if (fabsf(eve->co[1]) < mmd->tolerance) eve->f2 |= 2; break; case 2: - if (fabs(eve->co[2]) < mmd->tolerance) + if (fabsf(eve->co[2]) < mmd->tolerance) eve->f2 |= 4; break; } @@ -4157,9 +4157,7 @@ static int smooth_vertex(bContext *C, wmOperator *op) eed= em->edges.first; while(eed) { if( (eed->v1->f & SELECT) || (eed->v2->f & SELECT) ) { - fvec[0]= (eed->v1->co[0]+eed->v2->co[0])/2.0; - fvec[1]= (eed->v1->co[1]+eed->v2->co[1])/2.0; - fvec[2]= (eed->v1->co[2]+eed->v2->co[2])/2.0; + mid_v3_v3v3(fvec, eed->v1->co, eed->v2->co); if((eed->v1->f & SELECT) && eed->v1->f1<255) { eed->v1->f1++; @@ -4188,14 +4186,14 @@ static int smooth_vertex(bContext *C, wmOperator *op) } adr = eve->tmp.p; - fac= 0.5/(float)eve->f1; + fac= 0.5f/(float)eve->f1; if(xaxis) - eve->co[0]= 0.5*eve->co[0]+fac*adr[0]; + eve->co[0]= 0.5f*eve->co[0]+fac*adr[0]; if(yaxis) - eve->co[1]= 0.5*eve->co[1]+fac*adr[1]; + eve->co[1]= 0.5f*eve->co[1]+fac*adr[1]; if(zaxis) - eve->co[2]= 0.5*eve->co[2]+fac*adr[2]; + eve->co[2]= 0.5f*eve->co[2]+fac*adr[2]; /* clip if needed by mirror modifier */ @@ -4290,7 +4288,7 @@ static int mesh_noise_exec(bContext *C, wmOperator *op) if(tex->type==TEX_STUCCI) { float b2, vec[3]; - float ofs= tex->turbul/200.0; + float ofs= tex->turbul/200.0f; for(eve= em->verts.first; eve; eve= eve->next) { if(eve->f & SELECT) { b2= BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2]); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 40387b82205..eb0eb1833a6 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -980,7 +980,7 @@ static int spin_mesh(bContext *C, wmOperator *op, float *dvec, int steps, float cent[2]-= obedit->obmat[3][2]; mul_m3_v3(imat, cent); - phi= degr*M_PI/360.0; + phi= degr*(float)M_PI/360.0f; phi/= steps; if(ts->editbutflag & B_CLOCKWISE) phi= -phi; @@ -1144,10 +1144,8 @@ static int screw_mesh_exec(bContext *C, wmOperator *op) VECCOPY(nor, obedit->obmat[2]); - if(nor[0]*dvec[0]+nor[1]*dvec[1]+nor[2]*dvec[2]>0.000) { - dvec[0]= -dvec[0]; - dvec[1]= -dvec[1]; - dvec[2]= -dvec[2]; + if(nor[0]*dvec[0]+nor[1]*dvec[1]+nor[2]*dvec[2]>0.0f) { + negate_v3(dvec); } if(spin_mesh(C, op, dvec, turns*steps, 360.0f*turns, 0)) { @@ -1476,7 +1474,7 @@ static void alter_co(float *co, EditEdge *edge, float smooth, float fractal, int vec1[2]+= fac*nor2[2]; /* falloff for multi subdivide */ - smooth *= sqrt(fabs(1.0f - 2.0f*fabs(0.5f-perc))); + smooth *= sqrtf(fabs(1.0f - 2.0f*fabsf(0.5f-perc))); vec1[0]*= smooth*len; vec1[1]*= smooth*len; @@ -2675,15 +2673,15 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float eve->f2= 0; switch(mmd->axis){ case 0: - if (fabs(eve->co[0]) < mmd->tolerance) + if (fabsf(eve->co[0]) < mmd->tolerance) eve->f2 |= 1; break; case 1: - if (fabs(eve->co[1]) < mmd->tolerance) + if (fabsf(eve->co[1]) < mmd->tolerance) eve->f2 |= 2; break; case 2: - if (fabs(eve->co[2]) < mmd->tolerance) + if (fabsf(eve->co[2]) < mmd->tolerance) eve->f2 |= 4; break; } @@ -3226,13 +3224,13 @@ static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert normal_tri_v3( noA2,v1->co, v3->co, v4->co); if(noA1[0] == noA2[0] && noA1[1] == noA2[1] && noA1[2] == noA2[2]) normalADiff = 0.0; - else normalADiff = RAD2DEG(angle_v2v2(noA1, noA2)); + else normalADiff = RAD2DEGF(angle_v2v2(noA1, noA2)); //if(!normalADiff) normalADiff = 179; normal_tri_v3( noB1,v2->co, v3->co, v4->co); normal_tri_v3( noB2,v4->co, v1->co, v2->co); if(noB1[0] == noB2[0] && noB1[1] == noB2[1] && noB1[2] == noB2[2]) normalBDiff = 0.0; - else normalBDiff = RAD2DEG(angle_v2v2(noB1, noB2)); + else normalBDiff = RAD2DEGF(angle_v2v2(noB1, noB2)); //if(!normalBDiff) normalBDiff = 179; measure += (normalADiff/360) + (normalBDiff/360); @@ -3247,10 +3245,10 @@ static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert diff = 0.0; diff = ( - fabs(RAD2DEG(angle_v2v2(edgeVec1, edgeVec2)) - 90) + - fabs(RAD2DEG(angle_v2v2(edgeVec2, edgeVec3)) - 90) + - fabs(RAD2DEG(angle_v2v2(edgeVec3, edgeVec4)) - 90) + - fabs(RAD2DEG(angle_v2v2(edgeVec4, edgeVec1)) - 90)) / 360; + fabsf(RAD2DEGF(angle_v2v2(edgeVec1, edgeVec2)) - 90) + + fabsf(RAD2DEGF(angle_v2v2(edgeVec2, edgeVec3)) - 90) + + fabsf(RAD2DEGF(angle_v2v2(edgeVec3, edgeVec4)) - 90) + + fabsf(RAD2DEGF(angle_v2v2(edgeVec4, edgeVec1)) - 90)) / 360; if(!diff) return 0.0; measure += diff; @@ -3272,7 +3270,7 @@ static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert return measure; } -#define T2QUV_LIMIT 0.005 +#define T2QUV_LIMIT 0.005f #define T2QCOL_LIMIT 3 static int compareFaceAttribs(EditMesh *em, EditFace *f1, EditFace *f2, EditEdge *eed) { diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 1cbd7e82b95..d47e02dc63c 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -48,6 +48,7 @@ #include "RNA_define.h" #include "RNA_access.h" +#include "RNA_enum_types.h" #include "BKE_depsgraph.h" #include "BKE_context.h" @@ -326,7 +327,7 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* to give to transform */ - RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); + RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); } /***************************** Delete operator *****************************/ diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f630b05d8f2..144c80465df 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -172,6 +172,8 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit, float *loc, fl void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) { PropertyRNA *prop; + + /* note: this property gets hidden for add-camera operator */ RNA_def_boolean(ot->srna, "view_align", 0, "Align to View", "Align the new object to the view."); if(do_editmode) { @@ -478,6 +480,8 @@ static int object_camera_add_exec(bContext *C, wmOperator *op) void OBJECT_OT_camera_add(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name= "Add Camera"; ot->description = "Add a camera object to the scene"; @@ -491,6 +495,11 @@ void OBJECT_OT_camera_add(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); + + /* hide this for cameras, default */ + prop= RNA_struct_type_find_property(ot->srna, "view_align"); + RNA_def_property_flag(prop, PROP_HIDDEN); + } @@ -1703,7 +1712,7 @@ void OBJECT_OT_duplicate(wmOperatorType *ot) /* to give to transform */ RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data."); - prop= RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); + prop= RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); RNA_def_property_flag(prop, PROP_HIDDEN); } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index b57935bc392..ff1b693d0e1 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -309,15 +309,21 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * cache= psys->pathcache; for(a=0; asteps+1; - totedge+= key->steps; + + if(key->steps > 0) { + totvert+= key->steps+1; + totedge+= key->steps; + } } cache= psys->childcache; for(a=0; asteps+1; - totedge+= key->steps; + + if(key->steps > 0) { + totvert+= key->steps+1; + totedge+= key->steps; + } } if(totvert==0) return 0; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index a724e5850ec..76c917291a8 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -80,12 +80,9 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg); static Lattice *vgroup_edit_lattice(Object *ob) { - if(ob->type==OB_LATTICE) { - Lattice *lt= ob->data; - return (lt->editlatt)? lt->editlatt->latt: lt; - } - - return NULL; + Lattice *lt= ob->data; + BLI_assert(ob->type==OB_LATTICE); + return (lt->editlatt)? lt->editlatt->latt: lt; } int ED_vgroup_object_is_edit_mode(Object *ob) @@ -511,7 +508,7 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) static float get_vert_def_nr(Object *ob, int def_nr, int vertnum) { - MDeformVert *dvert= NULL; + MDeformVert *dvert; EditVert *eve; Mesh *me; int i; @@ -526,14 +523,22 @@ static float get_vert_def_nr(Object *ob, int def_nr, int vertnum) dvert= CustomData_em_get(&me->edit_mesh->vdata, eve->data, CD_MDEFORMVERT); vertnum= 0; } - else + else { + if(vertnum >= me->totvert) { + return 0.0f; + } dvert = me->dvert; + } } else if(ob->type==OB_LATTICE) { Lattice *lt= vgroup_edit_lattice(ob); - - if(lt->dvert) + + if(lt->dvert) { + if(vertnum >= lt->pntsu*lt->pntsv*lt->pntsw) { + return 0.0f; + } dvert = lt->dvert; + } } if(dvert==NULL) diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 697f016f2d4..3f2fcaab94a 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -430,7 +430,7 @@ static int key_test_depth(PEData *data, float co[3]) } #endif - if((float)uz - 0.00001 > depth) + if((float)uz - 0.00001f > depth) return 0; else return 1; @@ -3246,7 +3246,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, floa if(isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)){ if(cur_d<*min_d){ *min_d=cur_d; - min_w[0]= 1.0 - cur_uv[0] - cur_uv[1]; + min_w[0]= 1.0f - cur_uv[0] - cur_uv[1]; min_w[1]= cur_uv[0]; min_w[2]= cur_uv[1]; min_w[3]= 0.0f; @@ -3260,7 +3260,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, floa if(isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)){ if(cur_d<*min_d){ *min_d=cur_d; - min_w[0]= 1.0 - cur_uv[0] - cur_uv[1]; + min_w[0]= 1.0f - cur_uv[0] - cur_uv[1]; min_w[1]= 0.0f; min_w[2]= cur_uv[0]; min_w[3]= cur_uv[1]; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index c4c30df87ed..4aa9b942cf3 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -809,7 +809,7 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects, } } -int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) +static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) { Scene *scene= CTX_data_scene(C); int i; diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 956618eb1bb..857a36c3029 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -147,12 +147,12 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat float *rf= rectf; float srgb[3]; char *rc= rectc; - const float dither = ibuf->dither / 255.0; + const float dither = ibuf->dither / 255.0f; /* XXX temp. because crop offset */ if( rectc >= (char *)(ibuf->rect)) { for(x1= 0; x1dither / 255.0; + const float dither = ibuf->dither / 255.0f; /* XXX temp. because crop offset */ if( rectc >= (char *)(ibuf->rect)) { for(x1= 0; x1regionbase.first==NULL) { st->free(sl); BLI_freelinkN(&sa->spacedata, sl); + if(slold == sl) { + slold= NULL; + } sl= NULL; } diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 475e0fea699..2def3561cf0 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -62,7 +62,7 @@ const char *screen_context_dir[] = { "visible_pose_bones", "selected_pose_bones", "active_bone", "active_pose_bone", "active_base", "active_object", "object", "edit_object", "sculpt_object", "vertex_paint_object", "weight_paint_object", - "texture_paint_object", "particle_edit_object", + "image_paint_object", "particle_edit_object", "sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */ NULL}; @@ -340,7 +340,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } - else if(CTX_data_equals(member, "texture_paint_object")) { + else if(CTX_data_equals(member, "image_paint_object")) { if(obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) CTX_data_id_pointer_set(result, &obact->id); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index a40c62360c9..39da86b1962 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1585,6 +1585,9 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) are no longer in the same screen */ for(ar=sa->regionbase.first; ar; ar=ar->next) uiFreeBlocks(C, &ar->uiblocks); + + /* prevent hanging header prints */ + ED_area_headerprint(sa, NULL); } if(sa && sa->full) { diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index d07cc61e680..02b25562545 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1918,7 +1918,18 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int screen_full_area_exec(bContext *C, wmOperator *UNUSED(op)) { - ED_screen_full_toggle(C, CTX_wm_window(C), CTX_wm_area(C)); + bScreen *screen = CTX_wm_screen(C); + ScrArea *sa=NULL; + + /* search current screen for 'fullscreen' areas */ + /* prevents restoring info header, when mouse is over it */ + for (sa=screen->areabase.first; sa; sa=sa->next) { + if (sa->full) break; + } + + if(sa==NULL) sa= CTX_wm_area(C); + + ED_screen_full_toggle(C, CTX_wm_window(C), sa); return OPERATOR_FINISHED; } @@ -2766,7 +2777,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e else sync= (scene->flag & SCE_FRAME_DROP); if((scene->audio.flag & AUDIO_SYNC) && !(sad->flag & ANIMPLAY_FLAG_REVERSE) && finite(time = sound_sync_scene(scene))) - scene->r.cfra = time * FPS + 0.5; + scene->r.cfra = (double)time * FPS + 0.5; else { if (sync) { @@ -3162,26 +3173,39 @@ static void SCREEN_OT_delete(wmOperatorType *ot) static int scene_new_exec(bContext *C, wmOperator *op) { Scene *newscene, *scene= CTX_data_scene(C); + bScreen *screen= CTX_wm_screen(C); Main *bmain= CTX_data_main(C); int type= RNA_enum_get(op->ptr, "type"); + + if(type == SCE_COPY_NEW) { + newscene= add_scene("Scene"); + } + else { /* different kinds of copying */ + newscene= copy_scene(scene, type); + + /* these can't be handled in blenkernel curently, so do them here */ + if(type == SCE_COPY_LINK_DATA) { + ED_object_single_users(bmain, newscene, 0); + } + else if(type == SCE_COPY_FULL) { + ED_object_single_users(bmain, newscene, 1); + } + } - newscene= copy_scene(scene, type); - - /* these can't be handled in blenkernel curently, so do them here */ - if(type == SCE_COPY_LINK_DATA) - ED_object_single_users(bmain, newscene, 0); - else if(type == SCE_COPY_FULL) - ED_object_single_users(bmain, newscene, 1); - + /* this notifier calls ED_screen_set_scene, doing a lot of UI stuff, not for inside event loops */ WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); + if(screen) + screen->scene= newscene; + return OPERATOR_FINISHED; } static void SCENE_OT_new(wmOperatorType *ot) { static EnumPropertyItem type_items[]= { - {SCE_COPY_EMPTY, "EMPTY", 0, "Empty", "Add empty scene"}, + {SCE_COPY_NEW, "NEW", 0, "New", "Add new scene"}, + {SCE_COPY_EMPTY, "EMPTY", 0, "Copy Settings", "Make a copy without any objects"}, {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene"}, {SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene"}, {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene"}, diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index eb9fbea22f4..3b4b828d0f6 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -28,10 +28,12 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_brush_types.h" #include "BKE_brush.h" #include "BKE_context.h" #include "BKE_paint.h" +#include "BKE_main.h" #include "ED_sculpt.h" #include "ED_screen.h" @@ -42,12 +44,14 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "RNA_enum_types.h" #include "paint_intern.h" #include "sculpt_intern.h" #include //#include +#include /* Brush operators */ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op)) @@ -191,6 +195,148 @@ static void BRUSH_OT_reset(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* generic functions for setting the active brush based on the tool */ +static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode) +{ + struct Brush *brush; + + if(!brush_orig && !(brush_orig= bmain->brush.first)) { + return NULL; + } + + /* get the next brush with the active tool */ + for( brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first; + brush != brush_orig; + brush= brush->id.next ? brush->id.next : bmain->brush.first) + { + if( (brush->ob_mode & ob_mode) && + (*(((char *)brush) + tool_offset) == tool) + ) { + return brush; + } + } + + return NULL; + +} + +static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, const size_t tool_offset, const int ob_mode) +{ + struct Brush *brush, *brush_orig= paint_brush(paint); + + brush= brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); + + if(brush) { + paint_brush_set(paint, brush); + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +static int brush_sculpt_tool_set_exec(bContext *C, wmOperator *op) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + + return brush_generic_tool_set(bmain, &scene->toolsettings->sculpt->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, sculpt_tool), OB_MODE_SCULPT); +} + +static void BRUSH_OT_sculpt_tool_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Sculpt Tool Set"; + ot->description= "Set the sculpt tool"; + ot->idname= "BRUSH_OT_sculpt_tool_set"; + + /* api callbacks */ + ot->exec= brush_sculpt_tool_set_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + ot->prop= RNA_def_enum(ot->srna, "tool", brush_sculpt_tool_items, 0, "Tool", ""); +} + +static int brush_vertex_tool_set_exec(bContext *C, wmOperator *op) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + + return brush_generic_tool_set(bmain, &scene->toolsettings->vpaint->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, vertexpaint_tool), OB_MODE_VERTEX_PAINT); +} + +static void BRUSH_OT_vertex_tool_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Vertex Paint Tool Set"; + ot->description= "Set the vertex paint tool"; + ot->idname= "BRUSH_OT_vertex_tool_set"; + + /* api callbacks */ + ot->exec= brush_vertex_tool_set_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + ot->prop= RNA_def_enum(ot->srna, "tool", brush_vertex_tool_items, 0, "Tool", ""); +} + +static int brush_weight_tool_set_exec(bContext *C, wmOperator *op) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + /* vertexpaint_tool is used for weight paint mode */ + return brush_generic_tool_set(bmain, &scene->toolsettings->wpaint->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, vertexpaint_tool), OB_MODE_WEIGHT_PAINT); +} + +static void BRUSH_OT_weight_tool_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Weight Paint Tool Set"; + ot->description= "Set the weight paint tool"; + ot->idname= "BRUSH_OT_weight_tool_set"; + + /* api callbacks */ + ot->exec= brush_weight_tool_set_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + ot->prop= RNA_def_enum(ot->srna, "tool", brush_vertex_tool_items, 0, "Tool", ""); +} + +static int brush_image_tool_set_exec(bContext *C, wmOperator *op) +{ + Main *bmain= CTX_data_main(C); + Scene *scene= CTX_data_scene(C); + + return brush_generic_tool_set(bmain, &scene->toolsettings->imapaint.paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, imagepaint_tool), OB_MODE_TEXTURE_PAINT); +} + +static void BRUSH_OT_image_tool_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Image Paint Tool Set"; + ot->description= "Set the image tool"; + ot->idname= "BRUSH_OT_image_tool_set"; + + /* api callbacks */ + ot->exec= brush_image_tool_set_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + ot->prop= RNA_def_enum(ot->srna, "tool", brush_image_tool_items, 0, "Tool", ""); +} + + /**************************** registration **********************************/ void ED_operatortypes_paint(void) @@ -201,6 +347,12 @@ void ED_operatortypes_paint(void) WM_operatortype_append(BRUSH_OT_curve_preset); WM_operatortype_append(BRUSH_OT_reset); + /* note, particle uses a different system, can be added with existing operators in wm.py */ + WM_operatortype_append(BRUSH_OT_sculpt_tool_set); + WM_operatortype_append(BRUSH_OT_vertex_tool_set); + WM_operatortype_append(BRUSH_OT_weight_tool_set); + WM_operatortype_append(BRUSH_OT_image_tool_set); + /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); WM_operatortype_append(PAINT_OT_texture_paint_radial_control); @@ -239,66 +391,66 @@ static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode) { wmKeyMapItem *kmi; - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", ONEKEY, KM_PRESS, 0, 0); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 0); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", TWOKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "index", 0); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 1); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", THREEKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "index", 1); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 2); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", FOURKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "index", 2); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 3); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", FIVEKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "index", 3); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 4); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", SIXKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "index", 4); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 5); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", SEVENKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "index", 5); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 6); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", EIGHTKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "index", 6); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 7); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", NINEKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "index", 7); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 8); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", ZEROKEY, KM_PRESS, 0, 0); + RNA_int_set(kmi->ptr, "index", 8); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 9); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", ONEKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 9); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ONEKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 10); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", TWOKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 10); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", TWOKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 11); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", THREEKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 11); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", THREEKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 12); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", FOURKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 12); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FOURKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 13); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", FIVEKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 13); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", FIVEKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 14); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", SIXKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 14); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SIXKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 15); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", SEVENKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 15); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", SEVENKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 16); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", EIGHTKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 16); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", EIGHTKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 17); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", NINEKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 17); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", NINEKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 18); - kmi= WM_keymap_add_item(keymap, "BRUSH_OT_set_active_number", ZEROKEY, KM_PRESS, KM_SHIFT, 0); + RNA_int_set(kmi->ptr, "index", 18); + kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set", ZEROKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "mode", mode); - RNA_int_set(kmi->ptr, "number", 19); + RNA_int_set(kmi->ptr, "index", 19); } static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path)) @@ -345,6 +497,16 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "sculpt"); ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size"); + RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", DKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_DRAW); + RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", SKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_SMOOTH); + RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", PKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_PINCH); + RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", IKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_INFLATE); + RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", GKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_GRAB); + RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", LKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_LAYER); + RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", TKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "tool", SCULPT_TOOL_FLATTEN); /* was just TKEY in 2.4x */ + RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", CKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_CLAY); + RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", CKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "tool", SCULPT_TOOL_CREASE); + /* */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.stroke_method"); @@ -415,7 +577,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size"); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ - RNA_string_set(kmi->ptr, "data_path", "texture_paint_object.data.use_paint_mask"); + RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask"); /* face-mask mode */ keymap= WM_keymap_find(keyconf, "Face Mask", 0, 0); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 7d8c3c70708..19c726616da 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1687,7 +1687,7 @@ static int weight_paint_set_exec(bContext *C, wmOperator *UNUSED(op)) void PAINT_OT_weight_set(wmOperatorType *ot) { /* identifiers */ - ot->name= "Weight Set"; + ot->name= "Set Weight"; ot->idname= "PAINT_OT_weight_set"; /* api callbacks */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 1d818818908..225852b951e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2916,7 +2916,7 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio ss->cache->initial_mouse[1] = 0; } - mode = RNA_int_get(op->ptr, "mode"); + mode = RNA_enum_get(op->ptr, "mode"); cache->invert = mode == BRUSH_STROKE_INVERT; cache->alt_smooth = mode == BRUSH_STROKE_SMOOTH; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 0a98178a890..b3aa9349da8 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -711,7 +711,7 @@ void ACTION_OT_duplicate (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* to give to transform */ - RNA_def_int(ot->srna, "mode", TFM_TIME_TRANSLATE, 0, INT_MAX, "Mode", "", 0, INT_MAX); + RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); } /* ******************** Delete Keyframes Operator ************************* */ diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index e07efcadb65..6c3f80cda41 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -39,8 +39,7 @@ #include "BLI_blenlib.h" - - +#include "ED_anim_api.h" #include "ED_transform.h" #include "action_intern.h" diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index f9687e99c87..bee872dbe60 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -455,7 +455,7 @@ static void columnselect_action_keys (bAnimContext *ac, short mode) break; case ACTKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ - ED_markers_make_cfra_list(ac->markers, &ked.list, 1); + ED_markers_make_cfra_list(ac->markers, &ked.list, SELECT); break; default: /* invalid option */ diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 0a7ab797e77..22170bb439f 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -304,6 +304,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR); + RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_CHAR); /* same as above [#26623] */ #ifdef WITH_PYTHON WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */ diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 9f79a959ed5..17e7b1b5b18 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -389,7 +389,6 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa DriverTarget *dtar= &dvar->targets[0]; PointerRNA dtar_ptr; uiLayout *row, *col; - uiBlock *block; /* initialise RNA pointer to the target */ RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); @@ -407,9 +406,8 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa RNA_id_pointer_create(dtar->id, &root_ptr); col= uiLayoutColumn(layout, 1); - block= uiLayoutGetBlock(col); - /* rna path */ - uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, "Path"); + /* rna path */ + uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, "Path"); } } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 1bb6e6f6edb..962cadba1f3 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -830,7 +830,7 @@ void GRAPH_OT_duplicate (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* to give to transform */ - RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); + RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); } /* ******************** Delete Keyframes Operator ************************* */ diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index e75fbeb8efc..8510446768d 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -45,6 +45,7 @@ #include "UI_view2d.h" +#include "ED_anim_api.h" #include "ED_screen.h" #include "ED_transform.h" diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 8bec0803c5e..920f477e7eb 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -459,7 +459,7 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode) break; case GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ - ED_markers_make_cfra_list(ac->markers, &ked.list, 1); + ED_markers_make_cfra_list(ac->markers, &ked.list, SELECT); break; default: /* invalid option */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index c560b68c01b..41939969fa4 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -798,7 +798,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) void IMAGE_OT_open(wmOperatorType *ot) { /* identifiers */ - ot->name= "Open"; + ot->name= "Open Image"; ot->idname= "IMAGE_OT_open"; /* api callbacks */ @@ -856,7 +856,7 @@ static int replace_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) void IMAGE_OT_replace(wmOperatorType *ot) { /* identifiers */ - ot->name= "Replace"; + ot->name= "Replace Image"; ot->idname= "IMAGE_OT_replace"; /* api callbacks */ @@ -1076,7 +1076,7 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) void IMAGE_OT_save_as(wmOperatorType *ot) { /* identifiers */ - ot->name= "Save As"; + ot->name= "Save As Image"; ot->idname= "IMAGE_OT_save_as"; /* api callbacks */ @@ -1147,7 +1147,7 @@ static int save_exec(bContext *C, wmOperator *op) void IMAGE_OT_save(wmOperatorType *ot) { /* identifiers */ - ot->name= "Save"; + ot->name= "Save Image"; ot->idname= "IMAGE_OT_save"; /* api callbacks */ @@ -1259,7 +1259,7 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op)) void IMAGE_OT_reload(wmOperatorType *ot) { /* identifiers */ - ot->name= "Reload"; + ot->name= "Reload Image"; ot->idname= "IMAGE_OT_reload"; /* api callbacks */ @@ -1341,7 +1341,7 @@ void IMAGE_OT_new(wmOperatorType *ot) static float default_color[4]= {0.0f, 0.0f, 0.0f, 1.0f}; /* identifiers */ - ot->name= "New"; + ot->name= "New Image"; ot->idname= "IMAGE_OT_new"; /* api callbacks */ @@ -1349,7 +1349,7 @@ void IMAGE_OT_new(wmOperatorType *ot) ot->invoke= image_new_invoke; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_UNDO; /* properties */ RNA_def_string(ot->srna, "name", "untitled", 21, "Name", "Image datablock name."); @@ -1514,7 +1514,7 @@ static int pack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) void IMAGE_OT_pack(wmOperatorType *ot) { /* identifiers */ - ot->name= "Pack"; + ot->name= "Pack Image"; ot->description= "Pack an image as embedded data into the .blend file"; ot->idname= "IMAGE_OT_pack"; @@ -1591,7 +1591,7 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even void IMAGE_OT_unpack(wmOperatorType *ot) { /* identifiers */ - ot->name= "Unpack"; + ot->name= "Unpack Image"; ot->description= "Save an image packed in the .blend file to disk"; ot->idname= "IMAGE_OT_unpack"; @@ -1803,7 +1803,7 @@ static int sample_cancel(bContext *C, wmOperator *op) void IMAGE_OT_sample(wmOperatorType *ot) { /* identifiers */ - ot->name= "Sample"; + ot->name= "Sample Color"; ot->idname= "IMAGE_OT_sample"; /* api callbacks */ diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 701b0fc1de7..d58fb7b11f0 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -322,11 +322,11 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) * inactive regions, so use this for now. --matt */ -#define INFO_TIMEOUT 5.0 -#define INFO_COLOR_TIMEOUT 3.0 -#define ERROR_TIMEOUT 10.0 -#define ERROR_COLOR_TIMEOUT 6.0 -#define COLLAPSE_TIMEOUT 0.25 +#define INFO_TIMEOUT 5.0f +#define INFO_COLOR_TIMEOUT 3.0f +#define ERROR_TIMEOUT 10.0f +#define ERROR_COLOR_TIMEOUT 6.0f +#define COLLAPSE_TIMEOUT 0.25f static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { wmWindowManager *wm= CTX_wm_manager(C); @@ -353,7 +353,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm color_timeout = (report->type & RPT_ERROR_ALL)?ERROR_COLOR_TIMEOUT:INFO_COLOR_TIMEOUT; /* clear the report display after timeout */ - if (reports->reporttimer->duration > timeout) { + if ((float)reports->reporttimer->duration > timeout) { WM_event_remove_timer(wm, NULL, reports->reporttimer); reports->reporttimer = NULL; @@ -381,8 +381,8 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm rti->widthfac=1.0; } - progress = reports->reporttimer->duration / timeout; - color_progress = reports->reporttimer->duration / color_timeout; + progress = (float)reports->reporttimer->duration / timeout; + color_progress = (float)reports->reporttimer->duration / color_timeout; /* save us from too many draws */ if(color_progress <= 1.0f) { diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 0068e42ba19..bd2e8077eab 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -198,7 +198,7 @@ static void info_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap= WM_keymap_find(keyconf, "Window", 0, 0); - WM_keymap_verify_item(keymap, "INFO_OT_reports_display_update", TIMER, KM_ANY, KM_ANY, 0); + WM_keymap_verify_item(keymap, "INFO_OT_reports_display_update", TIMERREPORT, KM_ANY, KM_ANY, 0); /* info space */ keymap= WM_keymap_find(keyconf, "Info", SPACE_INFO, 0); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index d9cd11b751f..d058ea746b6 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -678,7 +678,7 @@ void NLA_OT_duplicate (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* to give to transform */ - RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); + RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); } /* ******************** Delete Strips Operator ***************************** */ diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index f37c62de473..3877e7abf5e 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1175,7 +1175,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) fx = (bufx > 0.0f ? ((float)mx - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f); fy = (bufy > 0.0f ? ((float)my - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f); - if(fx>=0.0 && fy>=0.0 && fx<1.0 && fy<1.0) { + if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { float *fp; char *cp; int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 944b7229372..2f95e8fa64c 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -303,20 +303,20 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire /* set up co-ordinates/dimensions for either left or right handle */ if (direction == SEQ_LEFTHANDLE) { rx1 = x1; - rx2 = x1+handsize*0.75; + rx2 = x1+handsize * 0.75f; - v1[0]= x1+handsize/4; v1[1]= y1+( ((y1+y2)/2.0 - y1)/2); - v2[0]= x1+handsize/4; v2[1]= y2-( ((y1+y2)/2.0 - y1)/2); - v3[0]= v2[0] + handsize/4; v3[1]= (y1+y2)/2.0; + v1[0]= x1+handsize/4; v1[1]= y1+( ((y1+y2)/2.0f - y1)/2); + v2[0]= x1+handsize/4; v2[1]= y2-( ((y1+y2)/2.0f - y1)/2); + v3[0]= v2[0] + handsize/4; v3[1]= (y1+y2)/2.0f; whichsel = SEQ_LEFTSEL; } else if (direction == SEQ_RIGHTHANDLE) { - rx1 = x2-handsize*0.75; + rx1 = x2-handsize*0.75f; rx2 = x2; - v1[0]= x2-handsize/4; v1[1]= y1+( ((y1+y2)/2.0 - y1)/2); - v2[0]= x2-handsize/4; v2[1]= y2-( ((y1+y2)/2.0 - y1)/2); - v3[0]= v2[0] - handsize/4; v3[1]= (y1+y2)/2.0; + v1[0]= x2-handsize/4; v1[1]= y1+( ((y1+y2)/2.0f - y1)/2); + v2[0]= x2-handsize/4; v2[1]= y2-( ((y1+y2)/2.0f - y1)/2); + v3[0]= v2[0] - handsize/4; v3[1]= (y1+y2)/2.0f; whichsel = SEQ_RIGHTSEL; } @@ -351,11 +351,11 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire if (direction == SEQ_LEFTHANDLE) { sprintf(str, "%d", seq->startdisp); x1= rx1; - y1 -= 0.45; + y1 -= 0.45f; } else { sprintf(str, "%d", seq->enddisp - 1); - x1= x2 - handsize*0.75; - y1= y2 + 0.05; + x1= x2 - handsize*0.75f; + y1= y2 + 0.05f; } UI_view2d_text_cache_add(v2d, x1, y1, str, col); } @@ -441,7 +441,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) glColor3ubv((GLubyte *)col); - for(a=y1; a< y2; a+= pixely*2.0 ) { + for(a=y1; a< y2; a+= pixely * 2.0f) { fdrawline(x1, a, (float)(seq->start), a); } } @@ -459,7 +459,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) glColor3ubv((GLubyte *)col); - for(a=y1; a< y2; a+= pixely*2.0 ) { + for(a=y1; a< y2; a+= pixely * 2.0f) { fdrawline((float)(seq->start+seq->len), a, x2, a); } } @@ -541,8 +541,8 @@ static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, floa glPolygonStipple(stipple_halftone); } - ymid1 = (y2-y1)*0.25 + y1; - ymid2 = (y2-y1)*0.65 + y1; + ymid1 = (y2-y1)*0.25f + y1; + ymid2 = (y2-y1)*0.65f + y1; glShadeModel(GL_SMOOTH); glBegin(GL_QUADS); @@ -719,8 +719,8 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { viewrectx *= scene->r.xasp / scene->r.yasp; - viewrectx /= proxy_size / 100.0; - viewrecty /= proxy_size / 100.0; + viewrectx /= proxy_size / 100.0f; + viewrecty /= proxy_size / 100.0f; } if(frame_ofs == 0) { @@ -835,10 +835,10 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0); glBegin(GL_LINE_LOOP); - glVertex2f(x1-0.5, y1-0.5); - glVertex2f(x1-0.5, y2+0.5); - glVertex2f(x2+0.5, y2+0.5); - glVertex2f(x2+0.5, y1-0.5); + glVertex2f(x1-0.5f, y1-0.5f); + glVertex2f(x1-0.5f, y2+0.5f); + glVertex2f(x2+0.5f, y2+0.5f); + glVertex2f(x2+0.5f, y1-0.5f); glEnd(); /* safety border */ @@ -968,7 +968,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) else if (seq == last_seq) continue; else if (MIN2(seq->startdisp, seq->start) > v2d->cur.xmax) continue; else if (MAX2(seq->enddisp, seq->start+seq->len) < v2d->cur.xmin) continue; - else if (seq->machine+1.0 < v2d->cur.ymin) continue; + else if (seq->machine+1.0f < v2d->cur.ymin) continue; else if (seq->machine > v2d->cur.ymax) continue; /* strip passed all tests unscathed... so draw it now */ @@ -1022,9 +1022,9 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); if (ed && ed->metastack.first) - glClearColor(col[0], col[1], col[2]-0.1, 0.0); + glClearColor(col[0], col[1], col[2]-0.1f, 0.0f); else - glClearColor(col[0], col[1], col[2], 0.0); + glClearColor(col[0], col[1], col[2], 0.0f); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 48bdcb88618..115d1ad7bae 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -62,6 +62,7 @@ #include "WM_types.h" #include "RNA_define.h" +#include "RNA_enum_types.h" /* for menu/popup icons etc etc*/ @@ -336,7 +337,7 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, short mval[2]) } seq= seq->next; } - return 0; + return NULL; } @@ -460,12 +461,12 @@ static void reload_image_strip(Scene *scene, char *UNUSED(name)) - if(last_seq==0 || last_seq->type!=SEQ_IMAGE) return; + if(last_seq==NULL || last_seq->type!=SEQ_IMAGE) return; seqact= last_seq; /* last_seq changes in alloc_sequence */ /* search sfile */ // sfile= scrarea_find_space_of_type(curarea, SPACE_FILE); - if(sfile==0) return; + if(sfile == NULL) return; waitcursor(1); @@ -478,7 +479,7 @@ static void reload_image_strip(Scene *scene, char *UNUSED(name)) seqact->len= seq->len; calc_sequence(scene, seqact); - seq->strip= 0; + seq->strip= NULL; seq_free_sequence(scene, seq); BLI_remlink(ed->seqbasep, seq); @@ -496,7 +497,7 @@ static void change_sequence(Scene *scene) Scene *sce; short event; - if(last_seq==0) return; + if(last_seq == NULL) return; if(last_seq->type & SEQ_EFFECT) { event = pupmenu("Change Effect%t" @@ -589,7 +590,7 @@ static void change_sequence(Scene *scene) int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str) { Editing *ed = seq_give_editing(scene, FALSE); - Sequence *seq1= 0, *seq2= 0, *seq3= 0, *seq; + Sequence *seq1= NULL, *seq2= NULL, *seq3= NULL, *seq; *error_str= NULL; @@ -603,9 +604,9 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen return 0; } if((seq != activeseq) && (seq != seq2)) { - if(seq2==0) seq2= seq; - else if(seq1==0) seq1= seq; - else if(seq3==0) seq3= seq; + if(seq2 == NULL) seq2= seq; + else if(seq1 == NULL) seq1= seq; + else if(seq3 == NULL) seq3= seq; else { *error_str= "Can't apply effect to more than 3 sequence strips"; return 0; @@ -616,7 +617,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen /* make sequence selection a little bit more intuitive for 3 strips: the last-strip should be sequence3 */ - if (seq3 != 0 && seq2 != 0) { + if (seq3 != NULL && seq2 != NULL) { Sequence *tmp = seq2; seq2 = seq3; seq3 = tmp; @@ -625,21 +626,21 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen switch(get_sequence_effect_num_inputs(type)) { case 0: - *selseq1 = *selseq2 = *selseq3 = 0; + *selseq1 = *selseq2 = *selseq3 = NULL; return 1; /* succsess */ case 1: - if(seq2==0) { + if(seq2==NULL) { *error_str= "Need at least one selected sequence strip"; return 0; } - if(seq1==0) seq1= seq2; - if(seq3==0) seq3= seq2; + if(seq1==NULL) seq1= seq2; + if(seq3==NULL) seq3= seq2; case 2: - if(seq1==0 || seq2==0) { + if(seq1==NULL || seq2==NULL) { *error_str= "Need 2 selected sequence strips"; return 0; } - if(seq3==0) seq3= seq2; + if(seq3 == NULL) seq3= seq2; } if (seq1==NULL && seq2==NULL && seq3==NULL) { @@ -721,7 +722,7 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) { TransSeq ts; - Sequence *seqn = 0; + Sequence *seqn = NULL; int skip_dup = FALSE; /* backup values */ @@ -815,7 +816,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) { TransSeq ts; - Sequence *seqn = 0; + Sequence *seqn = NULL; int skip_dup = FALSE; /* backup values */ @@ -1678,7 +1679,7 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* to give to transform */ - RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX); + RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); } /* delete operator */ @@ -2012,8 +2013,8 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) BLI_movelisttolist(ed->seqbasep, &last_seq->seqbase); - last_seq->seqbase.first= 0; - last_seq->seqbase.last= 0; + last_seq->seqbase.first= NULL; + last_seq->seqbase.last= NULL; BLI_remlink(ed->seqbasep, last_seq); seq_free_sequence(scene, last_seq); @@ -2671,21 +2672,6 @@ void SEQUENCER_OT_copy(wmOperatorType *ot) /* properties */ } -static void seq_offset(Scene *scene, Sequence *seq, int ofs) -{ - if(seq->type == SEQ_META) { - Sequence *iseq; - for(iseq= seq->seqbase.first; iseq; iseq= iseq->next) { - seq_offset(scene, iseq, ofs); - } - } - else { - seq->start += ofs; - } - - calc_sequence_disp(scene, seq); -} - static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); @@ -2702,14 +2688,8 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) /* transform pasted strips before adding */ if(ofs) { for(iseq= nseqbase.first; iseq; iseq= iseq->next) { - seq_offset(scene, iseq, ofs); - /* XXX, ffmpeg too? */ - if(iseq->sound) { - iseq->scene_sound = sound_add_scene_sound(scene, iseq, iseq->startdisp, iseq->enddisp, iseq->startofs + iseq->anim_startofs); - } - if(iseq->scene) { - sound_scene_add_scene_sound(scene, iseq, iseq->startdisp, iseq->enddisp, iseq->startofs + iseq->anim_startofs); - } + seq_translate(scene, iseq, ofs); + seq_sound_init(scene, iseq); } } diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index d91d675042f..b617d012237 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -42,16 +42,16 @@ static void rgb_to_yuv(float rgb[3], float yuv[3]) { - yuv[0]= 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]; - yuv[1]= 0.492*(rgb[2] - yuv[0]); - yuv[2]= 0.877*(rgb[0] - yuv[0]); + yuv[0]= 0.299f*rgb[0] + 0.587f*rgb[1] + 0.114f*rgb[2]; + yuv[1]= 0.492f*(rgb[2] - yuv[0]); + yuv[2]= 0.877f*(rgb[0] - yuv[0]); /* Normalize */ - yuv[1]*= 255.0/(122*2.0); - yuv[1]+= 0.5; + yuv[1]*= 255.0f/(122*2.0f); + yuv[1]+= 0.5f; - yuv[2]*= 255.0/(157*2.0); - yuv[2]+= 0.5; + yuv[2]*= 255.0f/(157*2.0f); + yuv[2]+= 0.5f; } static void scope_put_pixel(unsigned char* table, unsigned char * pos) @@ -132,7 +132,7 @@ static void wform_put_gridrow(unsigned char * tgt, float perc, int w, int h) { int i; - tgt += (int) (perc/100.0 * h) * w * 4; + tgt += (int) (perc/100.0f * h) * w * 4; for (i = 0; i < w*2; i++) { tgt[0] = 255; @@ -167,7 +167,7 @@ static struct ImBuf *make_waveform_view_from_ibuf_byte(struct ImBuf * ibuf) } for (y = 0; y < ibuf->y; y++) { - unsigned char * last_p = 0; + unsigned char * last_p = NULL; for (x = 0; x < ibuf->x; x++) { unsigned char * rgb = src + 4 * (ibuf->x * y + x); @@ -182,7 +182,7 @@ static struct ImBuf *make_waveform_view_from_ibuf_byte(struct ImBuf * ibuf) p += 4 * w; scope_put_pixel(wtable, p); - if (last_p != 0) { + if (last_p != NULL) { wform_put_line(w, last_p, p); } last_p = p; @@ -213,17 +213,17 @@ static struct ImBuf *make_waveform_view_from_ibuf_float(struct ImBuf * ibuf) } for (y = 0; y < ibuf->y; y++) { - unsigned char * last_p = 0; + unsigned char * last_p = NULL; for (x = 0; x < ibuf->x; x++) { float * rgb = src + 4 * (ibuf->x * y + x); - float v = 1.0 * - ( 0.299*rgb[0] - + 0.587*rgb[1] - + 0.114*rgb[2]); + float v = 1.0f * + ( 0.299f*rgb[0] + + 0.587f*rgb[1] + + 0.114f*rgb[2]); unsigned char * p = tgt; - CLAMP(v, 0.0, 1.0); + CLAMP(v, 0.0f, 1.0f); p += 4 * (w * ((int) (v * (h - 3)) + 1) + x + 1); @@ -231,7 +231,7 @@ static struct ImBuf *make_waveform_view_from_ibuf_float(struct ImBuf * ibuf) p += 4 * w; scope_put_pixel(wtable, p); - if (last_p != 0) { + if (last_p != NULL) { wform_put_line(w, last_p, p); } last_p = p; @@ -274,7 +274,7 @@ static struct ImBuf *make_sep_waveform_view_from_ibuf_byte(struct ImBuf * ibuf) } for (y = 0; y < ibuf->y; y++) { - unsigned char * last_p[3] = {0,0,0}; + unsigned char *last_p[3] = {NULL, NULL, NULL}; for (x = 0; x < ibuf->x; x++) { int c; @@ -288,7 +288,7 @@ static struct ImBuf *make_sep_waveform_view_from_ibuf_byte(struct ImBuf * ibuf) p += 4 * w; scope_put_pixel_single(wtable, p, c); - if (last_p[c] != 0) { + if (last_p[c] != NULL) { wform_put_line_single( w, last_p[c], p, c); } @@ -324,7 +324,7 @@ static struct ImBuf *make_sep_waveform_view_from_ibuf_float( } for (y = 0; y < ibuf->y; y++) { - unsigned char * last_p[3] = {0, 0, 0}; + unsigned char *last_p[3] = {NULL, NULL, NULL}; for (x = 0; x < ibuf->x; x++) { int c; @@ -333,7 +333,7 @@ static struct ImBuf *make_sep_waveform_view_from_ibuf_float( unsigned char * p = tgt; float v = rgb[c]; - CLAMP(v, 0.0, 1.0); + CLAMP(v, 0.0f, 1.0f); p += 4 * (w * ((int) (v * (h - 3)) + 1) + c * sw + x/3 + 1); @@ -342,7 +342,7 @@ static struct ImBuf *make_sep_waveform_view_from_ibuf_float( p += 4 * w; scope_put_pixel_single(wtable, p, c); - if (last_p[c] != 0) { + if (last_p[c] != NULL) { wform_put_line_single( w, last_p[c], p, c); } @@ -367,7 +367,7 @@ struct ImBuf *make_sep_waveform_view_from_ibuf(struct ImBuf * ibuf) static void draw_zebra_byte(struct ImBuf * src,struct ImBuf * ibuf, float perc) { - unsigned int limit = 255 * perc / 100.0; + unsigned int limit = 255.0f * perc / 100.0f; unsigned char * p = (unsigned char*) src->rect; unsigned char * o = (unsigned char*) ibuf->rect; int x; @@ -398,7 +398,7 @@ static void draw_zebra_byte(struct ImBuf * src,struct ImBuf * ibuf, float perc) static void draw_zebra_float(struct ImBuf * src,struct ImBuf * ibuf,float perc) { - float limit = perc / 100.0; + float limit = perc / 100.0f; float * p = src->rect_float; unsigned char * o = (unsigned char*) ibuf->rect; int x; @@ -456,7 +456,7 @@ static void draw_histogram_marker(struct ImBuf * ibuf, int x) static void draw_histogram_bar(struct ImBuf * ibuf, int x,float val, int col) { unsigned char * p = (unsigned char*) ibuf->rect; - int barh = ibuf->y * val * 0.9; + int barh = ibuf->y * val * 0.9f; int i; p += 4 * (x + ibuf->x); @@ -513,13 +513,13 @@ static struct ImBuf *make_histogram_view_from_ibuf_byte( static int get_bin_float(float f) { - if (f < -0.25) { - f = -0.25; - } else if (f > 1.25) { - f = 1.25; + if (f < -0.25f) { + f = -0.25f; + } else if (f > 1.25f) { + f = 1.25f; } - return (int) (((f + 0.25) / 1.5) * 512); + return (int) (((f + 0.25f) / 1.5f) * 512); } static struct ImBuf *make_histogram_view_from_ibuf_float( @@ -582,9 +582,9 @@ static void vectorscope_put_cross(unsigned char r, unsigned char g, int x = 0; int y = 0; - rgb[0]= (float)r/255.0; - rgb[1]= (float)g/255.0; - rgb[2]= (float)b/255.0; + rgb[0]= (float)r/255.0f; + rgb[1]= (float)g/255.0f; + rgb[2]= (float)b/255.0f; rgb_to_yuv(rgb, yuv); p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) @@ -633,9 +633,9 @@ static struct ImBuf *make_vectorscope_view_from_ibuf_byte(struct ImBuf * ibuf) char * src1 = src + 4 * (ibuf->x * y + x); char * p; - rgb[0]= (float)src1[0]/255.0; - rgb[1]= (float)src1[1]/255.0; - rgb[2]= (float)src1[2]/255.0; + rgb[0]= (float)src1[0]/255.0f; + rgb[1]= (float)src1[1]/255.0f; + rgb[2]= (float)src1[2]/255.0f; rgb_to_yuv(rgb, yuv); p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) @@ -682,9 +682,9 @@ static struct ImBuf *make_vectorscope_view_from_ibuf_float(struct ImBuf * ibuf) memcpy(rgb, src1, 3 * sizeof(float)); - CLAMP(rgb[0], 0.0, 1.0); - CLAMP(rgb[1], 0.0, 1.0); - CLAMP(rgb[2], 0.0, 1.0); + CLAMP(rgb[0], 0.0f, 1.0f); + CLAMP(rgb[1], 0.0f, 1.0f); + CLAMP(rgb[2], 0.0f, 1.0f); rgb_to_yuv(rgb, yuv); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index e3bc70e3542..550f2c937fd 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -343,6 +343,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", DKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_CHAR); /* same as above [#26623] */ RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 6ba047d741a..2601d1ffdf3 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1763,7 +1763,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) else UI_ThemeColor(TH_TEXT); - sprintf(linenr, "%d", i + linecount + 1); + sprintf(linenr, "%*d", st->linenrs_tot, i + linecount + 1); /* itoa(i + linecount + 1, linenr, 10); */ /* not ansi-c :/ */ text_font_draw(st, TXT_OFFSET - 7, y, linenr); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 5d75d645695..72d7977e132 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1078,7 +1078,7 @@ void ED_spacetype_view3d(void) st->context= view3d_context; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); + art= MEM_callocN(sizeof(ARegionType), "spacetype view3d main region"); art->regionid = RGN_TYPE_WINDOW; art->keymapflag= ED_KEYMAP_GPENCIL; art->draw= view3d_main_area_draw; @@ -1091,7 +1091,7 @@ void ED_spacetype_view3d(void) BLI_addhead(&st->regiontypes, art); /* regions: listview/buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); + art= MEM_callocN(sizeof(ARegionType), "spacetype view3d buttons region"); art->regionid = RGN_TYPE_UI; art->prefsizex= 180; // XXX art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; @@ -1103,7 +1103,7 @@ void ED_spacetype_view3d(void) view3d_buttons_register(art); /* regions: tool(bar) */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); + art= MEM_callocN(sizeof(ARegionType), "spacetype view3d tools region"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex= 160; // XXX art->prefsizey= 50; // XXX @@ -1119,7 +1119,7 @@ void ED_spacetype_view3d(void) #endif /* regions: tool properties */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); + art= MEM_callocN(sizeof(ARegionType), "spacetype view3d tool properties region"); art->regionid = RGN_TYPE_TOOL_PROPS; art->prefsizex= 0; art->prefsizey= 120; @@ -1133,7 +1133,7 @@ void ED_spacetype_view3d(void) /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); + art= MEM_callocN(sizeof(ARegionType), "spacetype view3d header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey= HEADERY; art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 4277a7e85e3..549a547b846 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -137,7 +137,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float { uiBlock *block= (layout)? uiLayoutAbsoluteBlock(layout): NULL; MDeformVert *dvert=NULL; - TransformProperties *tfp= v3d->properties_storage; + TransformProperties *tfp; float median[6], ve_median[6]; int tot, totw, totweight, totedge, totradius; char defstr[320]; @@ -146,6 +146,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float tot= totw= totweight= totedge= totradius= 0; defstr[0]= 0; + /* make sure we got storage */ + if(v3d->properties_storage==NULL) + v3d->properties_storage= MEM_callocN(sizeof(TransformProperties), "TransformProperties"); + tfp= v3d->properties_storage; + if(ob->type==OB_MESH) { Mesh *me= ob->data; EditMesh *em = BKE_mesh_get_editmesh(me); @@ -272,8 +277,10 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } - if(tot==0) return; - + if(tot==0) { + uiDefBut(block, LABEL, 0, "Nothing selected",0, 130, 200, 20, NULL, 0, 0, 0, 0, ""); + return; + } median[0] /= (float)tot; median[1] /= (float)tot; median[2] /= (float)tot; @@ -1214,7 +1221,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa) View3D *v3d= CTX_wm_view3d(C); //uiBut *bt; Object *ob= OBACT; - TransformProperties *tfp; + // TransformProperties *tfp; // UNUSED PointerRNA obptr; uiLayout *col, *row; float lim; @@ -1222,12 +1229,13 @@ static void view3d_panel_object(const bContext *C, Panel *pa) if(ob==NULL) return; /* make sure we got storage */ + /* if(v3d->properties_storage==NULL) v3d->properties_storage= MEM_callocN(sizeof(TransformProperties), "TransformProperties"); tfp= v3d->properties_storage; // XXX uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - /* + if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) { } else { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f5037ca24a1..1c830b7022a 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2120,6 +2120,11 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, } } + /* must be before xray draw which clears the depth buffer */ + if(v3d->zbuf) glDisable(GL_DEPTH_TEST); + draw_gpencil_view3d_ext(scene, v3d, ar, 1); + if(v3d->zbuf) glEnable(GL_DEPTH_TEST); + /* transp and X-ray afterdraw stuff */ if(v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); if(v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! @@ -2132,8 +2137,6 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, } /* draw grease-pencil stuff */ - draw_gpencil_view3d_ext(scene, v3d, ar, 1); - ED_region_pixelspace(ar); /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ @@ -2451,7 +2454,14 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) } // REEB_draw(); - + + if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + /* must be before xray draw which clears the depth buffer */ + if(v3d->zbuf) glDisable(GL_DEPTH_TEST); + draw_gpencil_view3d((bContext *)C, 1); + if(v3d->zbuf) glEnable(GL_DEPTH_TEST); + } + /* Transp and X-ray afterdraw stuff */ if(v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); if(v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! @@ -2472,12 +2482,8 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) v3d->zbuf= FALSE; glDisable(GL_DEPTH_TEST); } - - if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { - /* draw grease-pencil stuff (3d-space strokes) */ - //if (v3d->flag2 & V3D_DISPGP) - draw_gpencil_view3d((bContext *)C, 1); + if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { BDR_drawSketch(C); } diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 4914020fc02..7d84a47bddf 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -563,7 +563,8 @@ static int flyApply(bContext *C, FlyInfo *fly) moffset[2], /* mouse offset from the views center */ tmp_quat[4]; /* used for rotating the view */ - int cent_orig[2], /* view center */ + int +// cent_orig[2], /* view center */ //XXX- can avoid using // cent[2], /* view center modified */ xmargin, ymargin; /* x and y margin are define the safe area where the mouses movement wont rotate the view */ unsigned char @@ -582,8 +583,9 @@ static int flyApply(bContext *C, FlyInfo *fly) xmargin= ar->winx/20.0f; ymargin= ar->winy/20.0f; - cent_orig[0]= ar->winrct.xmin + ar->winx/2; - cent_orig[1]= ar->winrct.ymin + ar->winy/2; + // UNUSED + // cent_orig[0]= ar->winrct.xmin + ar->winx/2; + // cent_orig[1]= ar->winrct.ymin + ar->winy/2; { diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 3b6b7257c9c..246ed853cc8 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -147,6 +147,21 @@ static void handle_view3d_lock(bContext *C) - uiTemplateLayers in interface/ code for buttons - ED_view3d_scene_layer_set for RNA */ +static void view3d_layers_editmode_ensure(Scene *scene, View3D *v3d) +{ + /* sanity check - when in editmode disallow switching the editmode layer off since its confusing + * an alternative would be to always draw the editmode object. */ + if(scene->obedit && (scene->obedit->lay & v3d->lay)==0) { + int bit; + for(bit=0; bit<32; bit++) { + if(scene->obedit->lay & (1<lay |= 1<lay == ((1<<20)-1)) { /* return to active layer only */ v3d->lay = v3d->layact; - } else { + + view3d_layers_editmode_ensure(scene, v3d); + } + else { v3d->lay |= (1<<20)-1; } } @@ -181,19 +199,10 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) v3d->lay |= (1<lay = (1<obedit && (scene->obedit->lay & v3d->lay)==0) { - for(bit=0; bit<32; bit++) { - if(scene->obedit->lay & (1<lay |= 1<lay & (1<layact= 1<mval[0], cent[1] - t->mval[1]), 0, 0, 1); + glRotatef(-RAD2DEGF(atan2f(cent[0] - t->mval[0], cent[1] - t->mval[1])), 0, 0, 1); setlinestyle(0); glLineWidth(3.0); @@ -1303,8 +1303,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1]; float angle = atan2f(dy, dx); float dist = sqrtf(dx*dx + dy*dy); - float delta_angle = MIN2(15 / dist, M_PI/4); - float spacing_angle = MIN2(5 / dist, M_PI/12); + float delta_angle = MIN2(15.0f / dist, (float)M_PI/4.0f); + float spacing_angle = MIN2(5.0f / dist, (float)M_PI/12.0f); UI_ThemeColor(TH_WIRE); setlinestyle(3); @@ -1323,14 +1323,14 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) glPushMatrix(); glTranslatef(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0); - glRotatef(180 / M_PI * (angle - delta_angle), 0, 0, 1); + glRotatef(RAD2DEGF(angle - delta_angle), 0, 0, 1); drawArrowHead(DOWN, 5); glPopMatrix(); glTranslatef(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0); - glRotatef(180 / M_PI * (angle + delta_angle), 0, 0, 1); + glRotatef(RAD2DEGF(angle + delta_angle), 0, 0, 1); drawArrowHead(UP, 5); @@ -1647,11 +1647,6 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int break; case TFM_EDGE_SLIDE: initEdgeSlide(t); - if(t->state == TRANS_CANCEL) - { - postTrans(C, t); - return 0; - } break; case TFM_BONE_ROLL: initBoneRoll(t); @@ -1706,6 +1701,13 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int break; } + if(t->state == TRANS_CANCEL) + { + postTrans(C, t); + return 0; + } + + /* overwrite initial values if operator supplied a non-null vector */ if (RNA_property_is_set(op->ptr, "value")) { @@ -1919,7 +1921,7 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl eulO_to_axis_angle( axis, angle,eul, EULER_ORDER_DEFAULT); /* when converting to axis-angle, we need a special exception for the case when there is no axis */ - if (IS_EQ(axis[0], axis[1]) && IS_EQ(axis[1], axis[2])) { + if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) { /* for now, rotate around y-axis then (so that it simply becomes the roll) */ axis[1]= 1.0f; } @@ -2235,8 +2237,8 @@ void initWarp(TransInfo *t) t->idx_max = 0; t->num.idx_max = 0; t->snap[0] = 0.0f; - t->snap[1] = 5.0f / 180 * M_PI; - t->snap[2] = 1.0f / 180 * M_PI; + t->snap[1] = 5.0f / 180.0f * (float)M_PI; + t->snap[2] = 1.0f / 180.0f * (float)M_PI; t->num.increment = 1.0f; @@ -2259,7 +2261,7 @@ void initWarp(TransInfo *t) mid_v3_v3v3(t->center, min, max); - if (max[0] == min[0]) max[0] += 0.1; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */ + if (max[0] == min[0]) max[0] += 0.1f; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */ t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */ } @@ -2323,11 +2325,11 @@ int Warp(TransInfo *t, short UNUSED(mval[2])) sprintf(str, "Warp: %s", c); - circumfac = circumfac / 180 * M_PI; + circumfac = DEG2RADF(circumfac); } else { /* default header print */ - sprintf(str, "Warp: %.3f", circumfac * 180 / M_PI); + sprintf(str, "Warp: %.3f", RAD2DEGF(circumfac)); } t->values[0] = circumfac; @@ -3176,18 +3178,12 @@ int Rotation(TransInfo *t, short UNUSED(mval[2])) outputNumInput(&(t->num), c); sprintf(str, "Rot: %s %s %s", &c[0], t->con.text, t->proptext); - + /* Clamp between -180 and 180 */ - while (final >= 180.0) - final -= 360.0; - - while (final <= -180.0) - final += 360.0; - - final *= (float)(M_PI / 180.0); + final= angle_wrap_rad(DEG2RADF(final)); } else { - sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext); + sprintf(str, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext); } if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) @@ -3287,11 +3283,11 @@ int Trackball(TransInfo *t, short UNUSED(mval[2])) sprintf(str, "Trackball: %s %s %s", &c[0], &c[20], t->proptext); - phi[0] *= (float)(M_PI / 180.0); - phi[1] *= (float)(M_PI / 180.0); + phi[0] = DEG2RADF(phi[0]); + phi[1] = DEG2RADF(phi[1]); } else { - sprintf(str, "Trackball: %.2f %.2f %s", 180.0*phi[0]/M_PI, 180.0*phi[1]/M_PI, t->proptext); + sprintf(str, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext); } vec_rot_to_mat3( smat,axis1, phi[0]); @@ -3380,7 +3376,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { if(!(t->flag & T_2D_EDIT) && t->scene->unit.system) bUnit_AsString(distvec, sizeof(distvec), dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0); - else if( dist > 1e10 || dist < -1e10 ) /* prevent string buffer overflow */ + else if( dist > 1e10f || dist < -1e10f ) /* prevent string buffer overflow */ sprintf(distvec, "%.4e", dist); else sprintf(distvec, "%.4f", dist); @@ -3646,10 +3642,10 @@ int Tilt(TransInfo *t, short UNUSED(mval[2])) sprintf(str, "Tilt: %s %s", &c[0], t->proptext); - final *= (float)(M_PI / 180.0); + final = DEG2RADF(final); } else { - sprintf(str, "Tilt: %.2f %s", 180.0*final/M_PI, t->proptext); + sprintf(str, "Tilt: %.2f %s", RAD2DEGF(final), t->proptext); } for(i = 0 ; i < t->total; i++, td++) { @@ -4637,7 +4633,7 @@ static int createSlideVerts(TransInfo *t) } add_v3_v3(start, end); - mul_v3_fl(start, 0.5*(1.0/totvec)); + mul_v3_fl(start, 0.5f*(1.0f/totvec)); VECCOPY(vec, start); start[0] = t->mval[0]; start[1] = t->mval[1]; @@ -4921,8 +4917,8 @@ int doEdgeSlide(TransInfo *t, float perc) tempsv = BLI_ghash_lookup(vertgh,ev); edgelen = len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co); newlen = (edgelen != 0.0f)? (len / edgelen): 0.0f; - if(newlen > 1.0) {newlen = 1.0;} - if(newlen < 0.0) {newlen = 0.0;} + if(newlen > 1.0f) {newlen = 1.0;} + if(newlen < 0.0f) {newlen = 0.0;} if(flip == 0) { interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen)); if (uvlay_tot) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) { @@ -5045,10 +5041,10 @@ int BoneRoll(TransInfo *t, short UNUSED(mval[2])) sprintf(str, "Roll: %s", &c[0]); - final *= (float)(M_PI / 180.0); + final = DEG2RADF(final); } else { - sprintf(str, "Roll: %.2f", 180.0*final/M_PI); + sprintf(str, "Roll: %.2f", RAD2DEGF(final)); } /* set roll values */ @@ -5356,8 +5352,8 @@ int SeqSlide(TransInfo *t, short UNUSED(mval[2])) applyNumInput(&t->num, t->values); } - t->values[0] = floor(t->values[0] + 0.5); - t->values[1] = floor(t->values[1] + 0.5); + t->values[0] = floor(t->values[0] + 0.5f); + t->values[1] = floor(t->values[1] + 0.5f); headerSeqSlide(t, t->values, str); applySeqSlide(t, t->values); @@ -5515,6 +5511,11 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, void initTimeTranslate(TransInfo *t) { + /* this tool is only really available in the Action Editor... */ + if (t->spacetype != SPACE_ACTION) { + t->state = TRANS_CANCEL; + } + t->mode = TFM_TIME_TRANSLATE; t->transform = TimeTranslate; @@ -5663,8 +5664,11 @@ void initTimeSlide(TransInfo *t) /* set flag for drawing stuff */ saction->flag |= SACTION_MOVING; + } else { + t->state = TRANS_CANCEL; } + t->mode = TFM_TIME_SLIDE; t->transform = TimeSlide; t->flag |= T_FREE_CUSTOMDATA; @@ -5771,7 +5775,7 @@ int TimeSlide(TransInfo *t, short mval[2]) /* handle numeric-input stuff */ t->vec[0] = 2.0f*(cval[0]-sval[0]) / (maxx-minx); applyNumInput(&t->num, &t->vec[0]); - t->values[0] = (maxx-minx) * t->vec[0] / 2.0 + sval[0]; + t->values[0] = (maxx-minx) * t->vec[0] / 2.0f + sval[0]; headerTimeSlide(t, sval[0], str); applyTimeSlide(t, sval[0]); @@ -5789,6 +5793,11 @@ void initTimeScale(TransInfo *t) { int center[2]; + /* this tool is only really available in the Action Editor... */ + if (t->spacetype != SPACE_ACTION) { + t->state = TRANS_CANCEL; + } + t->mode = TFM_TIME_SCALE; t->transform = TimeScale; diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 1e6fae7609e..0012334cf92 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -191,11 +191,11 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 if(in[0]==0.0f && in[1]==0.0f && in[2]==0.0f) return; - angle = fabs(angle_v3v3(axis, t->viewinv[2])); - if (angle > M_PI / 2) { - angle = M_PI - angle; + angle = fabsf(angle_v3v3(axis, t->viewinv[2])); + if (angle > (float)M_PI / 2.0f) { + angle = (float)M_PI - angle; } - angle = 180.0f * angle / M_PI; + angle = RAD2DEGF(angle); /* For when view is parallel to constraint... will cause NaNs otherwise So we take vertical motion in 3D space and apply it to the @@ -228,12 +228,12 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 /* give arbitrary large value if projection is impossible */ factor = dot_v3v3(axis, norm); - if (1 - fabs(factor) < 0.0002f) { + if (1.0f - fabsf(factor) < 0.0002f) { VECCOPY(out, axis); if (factor > 0) { - mul_v3_fl(out, 1000000000); + mul_v3_fl(out, 1000000000.0f); } else { - mul_v3_fl(out, -1000000000); + mul_v3_fl(out, -1000000000.0f); } } else { add_v3_v3v3(v2, t->con.center, axis); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 05bf96461a8..99214fe4780 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -356,7 +356,7 @@ static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan) bConstraint *con= pchan->constraints.first; for(;con; con= con->next) { - if(con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0)) { + if(con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) { bKinematicConstraint *data= con->data; if(data->tar==NULL) @@ -757,7 +757,7 @@ static void pchan_autoik_adjust (bPoseChannel *pchan, short chainlen) /* check if pchan has ik-constraint */ for (con= pchan->constraints.first; con; con= con->next) { - if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0)) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) { bKinematicConstraint *data= con->data; /* only accept if a temporary one (for auto-ik) */ @@ -2802,7 +2802,7 @@ static void posttrans_fcurve_clean (FCurve *fcu) if (BEZSELECTED(bezt) == 0) { /* check beztriple should be removed according to cache */ for (index= 0; index < len; index++) { - if (IS_EQ(bezt->vec[1][0], selcache[index])) { + if (IS_EQF(bezt->vec[1][0], selcache[index])) { delete_fcurve_key(fcu, i, 0); break; } @@ -2975,7 +2975,7 @@ void flushTransGPactionData (TransInfo *t) /* flush data! */ for (i = 0; i < t->total; i++, tfd++) { - *(tfd->sdata)= (int)floor(tfd->val + 0.5); + *(tfd->sdata)= (int)floor(tfd->val + 0.5f); } } @@ -3358,8 +3358,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) mul_v3_fl(mtx[1], yscale); /* smtx is global (i.e. view) to data conversion */ - if (IS_EQ(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f/xscale); - if (IS_EQ(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f/yscale); + if (IS_EQF(xscale, 0.0f) == 0) mul_v3_fl(smtx[0], 1.0f/xscale); + if (IS_EQF(yscale, 0.0f) == 0) mul_v3_fl(smtx[1], 1.0f/yscale); } /* loop 2: build transdata arrays */ @@ -4137,7 +4137,7 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list) if (list) { for (con= list->first; con; con=con->next) { /* only consider constraint if it is enabled, and has influence on result */ - if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0)) { + if ((con->flag & CONSTRAINT_DISABLE)==0 && (con->enforce!=0.0f)) { /* (affirmative) returns for specific constraints here... */ /* constraints that require this regardless */ if (con->type == CONSTRAINT_TYPE_CHILDOF) return 1; diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index e8d82fb211c..45ed983fce5 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -274,7 +274,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], floa mi->imval[1] = mval[1]; } - *angle += dphi; + *angle += (double)dphi; output[0] = *angle; } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index fcbe4171a08..da1a1b91654 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -560,29 +560,29 @@ static void test_manipulator_axis(const bContext *C) viewvector(rv3d, rv3d->twmat[3], vec); angle = fabs(angle_v3v3(rv3d->twmat[0], vec)); - if (angle > M_PI / 2) { - angle = M_PI - angle; + if (angle > (float)M_PI / 2.0f) { + angle = (float)M_PI - angle; } - angle = rv3d->twangle[0] = 180.0f * angle / M_PI; - if (angle < 5) { + angle = rv3d->twangle[0] = RAD2DEGF(angle); + if (angle < 5.0f) { rv3d->twdrawflag &= ~(MAN_TRANS_X|MAN_SCALE_X); } angle = fabs(angle_v3v3(rv3d->twmat[1], vec)); - if (angle > M_PI / 2) { - angle = M_PI - angle; + if (angle > (float)M_PI / 2.0f) { + angle = (float)M_PI - angle; } - angle = rv3d->twangle[1] = 180.0f * angle / M_PI; - if (angle < 5) { + angle = rv3d->twangle[1] = RAD2DEGF(angle); + if (angle < 5.0f) { rv3d->twdrawflag &= ~(MAN_TRANS_Y|MAN_SCALE_Y); } angle = fabs(angle_v3v3(rv3d->twmat[2], vec)); - if (angle > M_PI / 2) { - angle = M_PI - angle; + if (angle > (float)M_PI / 2.0f) { + angle = (float)M_PI - angle; } - angle = rv3d->twangle[2] = 180.0f * angle / M_PI; - if (angle < 5) { + angle = rv3d->twangle[2] = RAD2DEGF(angle); + if (angle < 5.0f) { rv3d->twdrawflag &= ~(MAN_TRANS_Z|MAN_SCALE_Z); } } @@ -832,7 +832,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, if(arcs) { /* clipplane makes nice handles, calc here because of multmatrix but with translate! */ VECCOPY(plane, rv3d->viewinv[2]); - plane[3]= -0.02*size; // clip just a bit more + plane[3]= -0.02f*size; // clip just a bit more glClipPlane(GL_CLIP_PLANE0, plane); } /* sets view screen aligned */ diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index c31722d97cb..4edaabb9508 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -110,6 +110,39 @@ static TransformModeItem transform_modes[] = {NULL, 0} }; +EnumPropertyItem transform_mode_types[] = +{ + {TFM_INIT, "INIT", 0, "Init", ""}, + {TFM_DUMMY, "DUMMY", 0, "Dummy", ""}, + {TFM_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, + {TFM_ROTATION, "ROTATION", 0, "Rotation", ""}, + {TFM_RESIZE, "RESIZE", 0, "Resize", ""}, + {TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""}, + {TFM_SHEAR, "SHEAR", 0, "Shear", ""}, + {TFM_WARP, "WARP", 0, "Warp", ""}, + {TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""}, + {TFM_TILT, "TILT", 0, "Tilt", ""}, + {TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""}, + {TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""}, + {TFM_CREASE, "CREASE", 0, "Crease", ""}, + {TFM_MIRROR, "MIRROR", 0, "Mirror", ""}, + {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""}, + {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""}, + {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""}, + {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""}, + {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""}, + {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""}, + {TFM_TIME_SCALE, "TIME_SCALE", 0, "Time_Scale", ""}, + {TFM_TIME_EXTEND, "TIME_EXTEND", 0, "Time_Extend", ""}, + {TFM_BAKE_TIME, "BAKE_TIME", 0, "Bake_Time", ""}, + {TFM_BEVEL, "BEVEL", 0, "Bevel", ""}, + {TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""}, + {TFM_ALIGN, "ALIGN", 0, "Align", ""}, + {TFM_EDGE_SLIDE, "EDGESLIDE", 0, "Edge Slide", ""}, + {TFM_SEQ_SLIDE, "SEQSLIDE", 0, "Sequence Slide", ""}, + {0, NULL, 0, NULL, NULL} +}; + static int snap_type_exec(bContext *C, wmOperator *op) { ToolSettings *ts= CTX_data_tool_settings(C); @@ -755,37 +788,7 @@ void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot) void TRANSFORM_OT_transform(struct wmOperatorType *ot) { - static EnumPropertyItem transform_mode_types[] = { - {TFM_INIT, "INIT", 0, "Init", ""}, - {TFM_DUMMY, "DUMMY", 0, "Dummy", ""}, - {TFM_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, - {TFM_ROTATION, "ROTATION", 0, "Rotation", ""}, - {TFM_RESIZE, "RESIZE", 0, "Resize", ""}, - {TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""}, - {TFM_SHEAR, "SHEAR", 0, "Shear", ""}, - {TFM_WARP, "WARP", 0, "Warp", ""}, - {TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""}, - {TFM_TILT, "TILT", 0, "Tilt", ""}, - {TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""}, - {TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""}, - {TFM_CREASE, "CREASE", 0, "Crease", ""}, - {TFM_MIRROR, "MIRROR", 0, "Mirror", ""}, - {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""}, - {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""}, - {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""}, - {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""}, - {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""}, - {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""}, - {TFM_TIME_SCALE, "TIME_SCALE", 0, "Time_Scale", ""}, - {TFM_TIME_EXTEND, "TIME_EXTEND", 0, "Time_Extend", ""}, - {TFM_BAKE_TIME, "BAKE_TIME", 0, "Bake_Time", ""}, - {TFM_BEVEL, "BEVEL", 0, "Bevel", ""}, - {TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""}, - {TFM_ALIGN, "ALIGN", 0, "Align", ""}, - {TFM_EDGE_SLIDE, "EDGESLIDE", 0, "Edge Slide", ""}, - {TFM_SEQ_SLIDE, "SEQSLIDE", 0, "Sequence Slide", ""}, - {0, NULL, 0, NULL, NULL} - }; + PropertyRNA *prop; /* identifiers */ ot->name = "Transform"; @@ -800,7 +803,8 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot) ot->cancel = transform_cancel; ot->poll = ED_operator_areaactive; - RNA_def_enum(ot->srna, "mode", transform_mode_types, 0, "Mode", ""); + prop= RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 44de86c1e30..022e09b3da4 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -645,7 +645,7 @@ float RotationBetween(TransInfo *t, float p1[3], float p2[3]) cross_v3_v3v3(tmp, start, end); - if (dot_v3v3(tmp, axis) < 0.0) + if (dot_v3v3(tmp, axis) < 0.0f) angle = -acos(dot_v3v3(start, end)); else angle = acos(dot_v3v3(start, end)); @@ -661,11 +661,11 @@ float RotationBetween(TransInfo *t, float p1[3], float p2[3]) angle = atan2(start[1],start[0]) - atan2(end[1],end[0]); } - if (angle > M_PI) { - angle = angle - 2 * M_PI; + if (angle > (float)M_PI) { + angle = angle - 2 * (float)M_PI; } - else if (angle < -(M_PI)) { - angle = 2 * M_PI + angle; + else if (angle < -((float)M_PI)) { + angle = 2.0f * (float)M_PI + angle; } return angle; @@ -1134,7 +1134,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh * this takes care of series of connected edges a bit slanted w.r.t the viewport * otherwise, it would stick to the verts of the closest edge and not slide along merrily * */ - if (new_dist <= *dist && new_depth < *depth * 1.001) + if (new_dist <= *dist && new_depth < *depth * 1.001f) { float n1[3], n2[3]; @@ -1670,7 +1670,7 @@ static void removeDoublesPeel(ListBase *depth_peels) { DepthPeel *next_peel = peel->next; - if (peel && next_peel && ABS(peel->depth - next_peel->depth) < 0.0015) + if (peel && next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f) { peel->next = next_peel->next; @@ -1939,7 +1939,7 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3) // Early bailing out if no need to snap - if (fac[action] == 0.0) + if (fac[action] == 0.0f) return; /* evil hack - snapping needs to be adapted for image aspect ratio */ @@ -1948,6 +1948,6 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea } for (i=0; i<=max_index; i++) { - val[i]= fac[action]*asp[i]*(float)floor(val[i]/(fac[action]*asp[i]) +.5); + val[i]= fac[action]*asp[i]*(float)floor(val[i]/(fac[action]*asp[i]) +0.5f); } } diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index a5954cdc215..1b58a1e2a58 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -85,7 +85,7 @@ void outputNumInput(NumInput *n, char *str) else inv[0] = 0; - if( n->val[i] > 1e10 || n->val[i] < -1e10 ) + if( n->val[i] > 1e10f || n->val[i] < -1e10f ) sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], cur); else switch (n->ctrl[i]) { @@ -281,7 +281,7 @@ char handleNumInput(NumInput *n, wmEvent *event) if (!n->ctrl[idx]) n->ctrl[idx] = 1; - if (fabs(n->val[idx]) > 9999999.0f); + if (fabsf(n->val[idx]) > 9999999.0f); else if (n->ctrl[idx] == 1) { n->val[idx] *= 10; n->val[idx] += Val; @@ -303,7 +303,7 @@ char handleNumInput(NumInput *n, wmEvent *event) } } - printf("%f\n", n->val[idx]); + // printf("%f\n", n->val[idx]); /* REDRAW SINCE NUMBERS HAVE CHANGED */ return 1; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 252f9c66266..e29c34b9092 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -352,12 +352,12 @@ void uvedit_uv_deselect(Scene *scene, EditFace *efa, MTFace *tf, int i) void uv_center(float uv[][2], float cent[2], int quad) { if(quad) { - cent[0] = (uv[0][0] + uv[1][0] + uv[2][0] + uv[3][0]) / 4.0; - cent[1] = (uv[0][1] + uv[1][1] + uv[2][1] + uv[3][1]) / 4.0; + cent[0] = (uv[0][0] + uv[1][0] + uv[2][0] + uv[3][0]) / 4.0f; + cent[1] = (uv[0][1] + uv[1][1] + uv[2][1] + uv[3][1]) / 4.0f; } else { - cent[0] = (uv[0][0] + uv[1][0] + uv[2][0]) / 3.0; - cent[1] = (uv[0][1] + uv[1][1] + uv[2][1]) / 3.0; + cent[0] = (uv[0][0] + uv[1][0] + uv[2][0]) / 3.0f; + cent[1] = (uv[0][1] + uv[1][1] + uv[2][1]) / 3.0f; } } @@ -436,8 +436,8 @@ static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent, } if(change) { - cent[0]= (min[0]+max[0])/2.0; - cent[1]= (min[1]+max[1])/2.0; + cent[0]= (min[0]+max[0])/2.0f; + cent[1]= (min[1]+max[1])/2.0f; BKE_mesh_end_editmesh(obedit->data, em); return 1; @@ -578,9 +578,9 @@ static void find_nearest_uv_vert(Scene *scene, Image *ima, EditMesh *em, float c for(i=0; iuv[i][0])+penalty[0] + fabs(co[1]-tf->uv[i][1])+penalty[1]; + dist= fabsf(co[0]-tf->uv[i][0])+penalty[0] + fabsf(co[1]-tf->uv[i][1]) + penalty[1]; else - dist= fabs(co[0]-tf->uv[i][0]) + fabs(co[1]-tf->uv[i][1]); + dist= fabsf(co[0]-tf->uv[i][0]) + fabsf(co[1]-tf->uv[i][1]); if(dist<=mindist) { if(dist==mindist) @@ -1057,7 +1057,7 @@ static void UV_OT_align(wmOperatorType *ot) /* api callbacks */ ot->exec= align_exec; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_enum(ot->srna, "axis", axis_items, 'a', "Axis", "Axis to align UV locations on."); @@ -1438,7 +1438,7 @@ static int sticky_select(float *limit, int hitv[4], int v, float *hituv[4], floa for(i=0; i<4; i++) { if(hitv[i] == v) { if(sticky == SI_STICKY_LOC) { - if(fabs(hituv[i][0]-uv[0]) < limit[0] && fabs(hituv[i][1]-uv[1]) < limit[1]) + if(fabsf(hituv[i][0]-uv[0]) < limit[0] && fabsf(hituv[i][1]-uv[1]) < limit[1]) return 1; } else if(sticky == SI_STICKY_VERTEX) @@ -1761,7 +1761,7 @@ static void UV_OT_select(wmOperatorType *ot) /* api callbacks */ ot->exec= select_exec; ot->invoke= select_invoke; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_boolean(ot->srna, "extend", 0, @@ -1810,7 +1810,7 @@ static void UV_OT_select_loop(wmOperatorType *ot) /* api callbacks */ ot->exec= select_loop_exec; ot->invoke= select_loop_invoke; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_boolean(ot->srna, "extend", 0, @@ -1890,7 +1890,7 @@ static void UV_OT_select_linked(wmOperatorType *ot) /* api callbacks */ ot->exec= select_linked_exec; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */ /* properties */ RNA_def_boolean(ot->srna, "extend", 0, @@ -1918,7 +1918,7 @@ static void UV_OT_select_linked_pick(wmOperatorType *ot) /* api callbacks */ ot->invoke= select_linked_pick_invoke; ot->exec= select_linked_pick_exec; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_boolean(ot->srna, "extend", 0, @@ -2256,7 +2256,7 @@ static void UV_OT_select_border(wmOperatorType *ot) ot->invoke= WM_border_select_invoke; ot->exec= border_select_exec; ot->modal= WM_border_select_modal; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2280,7 +2280,7 @@ static void select_uv_inside_ellipse(Scene *scene, int select, EditFace *efa, MT y= (uv[1] - offset[1])*ell[1]; r2 = x*x + y*y; - if(r2 < 1.0) { + if(r2 < 1.0f) { if(select) uvedit_uv_select(scene, efa, tface, select_index); else uvedit_uv_deselect(scene, efa, tface, select_index); } @@ -2345,7 +2345,7 @@ static void UV_OT_circle_select(wmOperatorType *ot) ot->invoke= WM_gesture_circle_invoke; ot->modal= WM_gesture_circle_modal; ot->exec= circle_select_exec; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2386,7 +2386,7 @@ static int snap_cursor_exec(bContext *C, wmOperator *op) Image *ima= CTX_data_edit_image(C); int change= 0; - switch(RNA_boolean_get(op->ptr, "target")) { + switch(RNA_enum_get(op->ptr, "target")) { case 0: snap_cursor_to_pixels(sima); change= 1; @@ -2419,7 +2419,7 @@ static void UV_OT_snap_cursor(wmOperatorType *ot) /* api callbacks */ ot->exec= snap_cursor_exec; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_enum(ot->srna, "target", target_items, 0, "Target", "Target to snap the selected UV's to."); @@ -2623,7 +2623,7 @@ static int snap_selection_exec(bContext *C, wmOperator *op) Image *ima= CTX_data_edit_image(C); int change= 0; - switch(RNA_boolean_get(op->ptr, "target")) { + switch(RNA_enum_get(op->ptr, "target")) { case 0: change= snap_uvs_to_pixels(sima, scene, obedit); break; @@ -2660,7 +2660,7 @@ static void UV_OT_snap_selection(wmOperatorType *ot) /* api callbacks */ ot->exec= snap_selection_exec; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* properties */ RNA_def_enum(ot->srna, "target", target_items, 0, "Target", "Target to snap the selected UV's to."); @@ -3080,7 +3080,7 @@ static void UV_OT_cursor_set(wmOperatorType *ot) /* api callbacks */ ot->exec= set_2d_cursor_exec; ot->invoke= set_2d_cursor_invoke; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -3124,7 +3124,7 @@ static int set_tile_invoke(bContext *C, wmOperator *op, wmEvent *event) y= event->y - ar->winrct.ymin; UI_view2d_region_to_view(&ar->v2d, x, y, &fx, &fy); - if(fx>=0.0 && fy>=0.0 && fx<1.0 && fy<1.0) { + if(fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { fx= fx*ima->xrep; fy= fy*ima->yrep; @@ -3148,7 +3148,7 @@ static void UV_OT_tile_set(wmOperatorType *ot) /* api callbacks */ ot->exec= set_tile_exec; ot->invoke= set_tile_invoke; - ot->poll= ED_operator_uvedit; + ot->poll= ED_operator_image_active; /* requires space image */; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 5d376a73814..23af1eafdb7 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -370,7 +370,7 @@ static void p_triangle_angles(float *v1, float *v2, float *v3, float *a1, float { *a1 = p_vec_angle(v3, v1, v2); *a2 = p_vec_angle(v1, v2, v3); - *a3 = M_PI - *a2 - *a1; + *a3 = (float)M_PI - *a2 - *a1; } static void p_face_angles(PFace *f, float *a1, float *a2, float *a3) @@ -786,12 +786,12 @@ static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep) uvp2 = ep->orig_uv; } - if((fabs(uv1[0]-uvp1[0]) > limit[0]) || (fabs(uv1[1]-uvp1[1]) > limit[1])) { + if((fabsf(uv1[0]-uvp1[0]) > limit[0]) || (fabsf(uv1[1]-uvp1[1]) > limit[1])) { e->flag |= PEDGE_SEAM; ep->flag |= PEDGE_SEAM; return P_TRUE; } - if((fabs(uv2[0]-uvp2[0]) > limit[0]) || (fabs(uv2[1]-uvp2[1]) > limit[1])) { + if((fabsf(uv2[0]-uvp2[0]) > limit[0]) || (fabsf(uv2[1]-uvp2[1]) > limit[1])) { e->flag |= PEDGE_SEAM; ep->flag |= PEDGE_SEAM; return P_TRUE; @@ -2259,8 +2259,8 @@ static void p_abf_setup_system(PAbfSystem *sys) for (i = 0; i < sys->ninterior; i++) sys->lambdaLength[i] = 1.0; - sys->minangle = 7.5f*M_PI/180.0f; - sys->maxangle = M_PI - sys->minangle; + sys->minangle = 7.5*M_PI/180.0; + sys->maxangle = (float)M_PI - sys->minangle; } static void p_abf_free_system(PAbfSystem *sys) @@ -2373,7 +2373,7 @@ static float p_abf_compute_gradient(PAbfSystem *sys, PChart *chart) norm += galpha1*galpha1 + galpha2*galpha2 + galpha3*galpha3; - gtriangle = sys->alpha[e1->u.id] + sys->alpha[e2->u.id] + sys->alpha[e3->u.id] - M_PI; + gtriangle = sys->alpha[e1->u.id] + sys->alpha[e2->u.id] + sys->alpha[e3->u.id] - (float)M_PI; sys->bTriangle[f->u.id] = -gtriangle; norm += gtriangle*gtriangle; } @@ -2424,9 +2424,9 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart) PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next; PVert *v1 = e1->vert, *v2 = e2->vert, *v3 = e3->vert; - wi1 = 1.0/sys->weight[e1->u.id]; - wi2 = 1.0/sys->weight[e2->u.id]; - wi3 = 1.0/sys->weight[e3->u.id]; + wi1 = 1.0f/sys->weight[e1->u.id]; + wi2 = 1.0f/sys->weight[e2->u.id]; + wi3 = 1.0f/sys->weight[e3->u.id]; /* bstar1 = (J1*dInv*bAlpha - bTriangle) */ b = sys->bAlpha[e1->u.id]*wi1; @@ -2435,7 +2435,7 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart) b -= sys->bTriangle[f->u.id]; /* si = J1*d*J1t */ - si = 1.0/(wi1 + wi2 + wi3); + si = 1.0f/(wi1 + wi2 + wi3); /* J1t*si*bstar1 - bAlpha */ beta[0] = b*si - sys->bAlpha[e1->u.id]; @@ -2457,7 +2457,7 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart) vid[0] = v1->u.id; vid[3] = ninterior + v1->u.id; - sys->J2dt[e1->u.id][0] = j2[0][0] = 1.0*wi1; + sys->J2dt[e1->u.id][0] = j2[0][0] = 1.0f * wi1; sys->J2dt[e2->u.id][0] = j2[1][0] = p_abf_compute_sin_product(sys, v1, e2->u.id)*wi2; sys->J2dt[e3->u.id][0] = j2[2][0] = p_abf_compute_sin_product(sys, v1, e3->u.id)*wi3; @@ -2478,7 +2478,7 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart) vid[4] = ninterior + v2->u.id; sys->J2dt[e1->u.id][1] = j2[0][1] = p_abf_compute_sin_product(sys, v2, e1->u.id)*wi1; - sys->J2dt[e2->u.id][1] = j2[1][1] = 1.0*wi2; + sys->J2dt[e2->u.id][1] = j2[1][1] = 1.0f*wi2; sys->J2dt[e3->u.id][1] = j2[2][1] = p_abf_compute_sin_product(sys, v2, e3->u.id)*wi3; nlRightHandSideAdd(0, v2->u.id, j2[1][1]*beta[1]); @@ -2499,7 +2499,7 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart) sys->J2dt[e1->u.id][2] = j2[0][2] = p_abf_compute_sin_product(sys, v3, e1->u.id)*wi1; sys->J2dt[e2->u.id][2] = j2[1][2] = p_abf_compute_sin_product(sys, v3, e2->u.id)*wi2; - sys->J2dt[e3->u.id][2] = j2[2][2] = 1.0*wi3; + sys->J2dt[e3->u.id][2] = j2[2][2] = 1.0f * wi3; nlRightHandSideAdd(0, v3->u.id, j2[2][2]*beta[2]); nlRightHandSideAdd(0, ninterior + v3->u.id, j2[0][2]*beta[0] + j2[1][2]*beta[1]); @@ -2599,8 +2599,8 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart) /* clamp */ e = f->edge; do { - if (sys->alpha[e->u.id] > M_PI) - sys->alpha[e->u.id] = M_PI; + if (sys->alpha[e->u.id] > (float)M_PI) + sys->alpha[e->u.id] = (float)M_PI; else if (sys->alpha[e->u.id] < 0.0f) sys->alpha[e->u.id] = 0.0f; } while (e != f->edge); @@ -2674,9 +2674,9 @@ static PBool p_chart_abf_solve(PChart *chart) sys.alpha[e2->u.id] = sys.beta[e2->u.id] = a2; sys.alpha[e3->u.id] = sys.beta[e3->u.id] = a3; - sys.weight[e1->u.id] = 2.0/(a1*a1); - sys.weight[e2->u.id] = 2.0/(a2*a2); - sys.weight[e3->u.id] = 2.0/(a3*a3); + sys.weight[e1->u.id] = 2.0f/(a1*a1); + sys.weight[e2->u.id] = 2.0f/(a2*a2); + sys.weight[e3->u.id] = 2.0f/(a3*a3); } for (v=chart->verts; v; v=v->nextlink) { @@ -2689,7 +2689,7 @@ static PBool p_chart_abf_solve(PChart *chart) e = e->next->next->pair; } while (e && (e != v->edge)); - scale = (anglesum == 0.0f)? 0.0f: 2*M_PI/anglesum; + scale = (anglesum == 0.0f)? 0.0f: 2.0f*(float)M_PI/anglesum; e = v->edge; do { @@ -3089,7 +3089,7 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) /* angle based lscm formulation */ ratio = (sina3 == 0.0f)? 1.0f: sina2/sina3; - cosine = cos(a1)*ratio; + cosine = cosf(a1)*ratio; sine = sina1*ratio; #if 0 @@ -3109,7 +3109,7 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) nlCoefficient(2*v3->u.id+1, 1.0); nlEnd(NL_ROW); #else - nlMatrixAdd(row, 2*v1->u.id, cosine - 1.0); + nlMatrixAdd(row, 2*v1->u.id, cosine - 1.0f); nlMatrixAdd(row, 2*v1->u.id+1, -sine); nlMatrixAdd(row, 2*v2->u.id, -cosine); nlMatrixAdd(row, 2*v2->u.id+1, sine); @@ -3117,7 +3117,7 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart) row++; nlMatrixAdd(row, 2*v1->u.id, sine); - nlMatrixAdd(row, 2*v1->u.id+1, cosine - 1.0); + nlMatrixAdd(row, 2*v1->u.id+1, cosine - 1.0f); nlMatrixAdd(row, 2*v2->u.id, -sine); nlMatrixAdd(row, 2*v2->u.id+1, -cosine); nlMatrixAdd(row, 2*v3->u.id+1, 1.0); @@ -3221,7 +3221,7 @@ static float p_face_stretch(PFace *f) T = sqrt(0.5f*(a + c)); if (f->flag & PFACE_FILLED) - T *= 0.2; + T *= 0.2f; return T; } @@ -3269,9 +3269,9 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng) trusted_radius /= 2 * nedges; - random_angle = rng_getFloat(rng) * 2.0 * M_PI; - dir[0] = trusted_radius * cos(random_angle); - dir[1] = trusted_radius * sin(random_angle); + random_angle = rng_getFloat(rng) * 2.0f * (float)M_PI; + dir[0] = trusted_radius * cosf(random_angle); + dir[1] = trusted_radius * sinf(random_angle); /* calculate old and new stretch */ low = 0; @@ -3283,7 +3283,7 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng) /* binary search for lowest stretch position */ for (j = 0; j < P_STRETCH_ITER; j++) { - mid = 0.5 * (low + high); + mid = 0.5f * (low + high); v->uv[0]= orig_uv[0] + mid*dir[0]; v->uv[1]= orig_uv[1] + mid*dir[1]; stretch = p_stretch_compute_vertex(v); @@ -3437,7 +3437,7 @@ static float p_chart_minimum_area_angle(PChart *chart) p2 = points[i]; p3 = (i == npoints-1)? points[0]: points[i+1]; - angles[i] = M_PI - p_vec2_angle(p1->uv, p2->uv, p3->uv); + angles[i] = (float)M_PI - p_vec2_angle(p1->uv, p2->uv, p3->uv); if (points[i]->uv[1] < miny) { miny = points[i]->uv[1]; @@ -3477,7 +3477,7 @@ static float p_chart_minimum_area_angle(PChart *chart) minarea = 1e10; minangle = 0.0; - while (rotated <= M_PI/2) { /* INVESTIGATE: how far to rotate? */ + while (rotated <= (float)(M_PI/2.0)) { /* INVESTIGATE: how far to rotate? */ /* rotate with the smallest angle */ mini = 0; mina = 1e10; @@ -3506,7 +3506,7 @@ static float p_chart_minimum_area_angle(PChart *chart) len = len_v2v2(p1->uv, p1n->uv); if (len > 0.0f) { - len = 1.0/len; + len = 1.0f/len; v[0] = (p1n->uv[0] - p1->uv[0])*len; v[1] = (p1n->uv[1] - p1->uv[1])*len; @@ -3523,8 +3523,8 @@ static float p_chart_minimum_area_angle(PChart *chart) } /* try keeping rotation as small as possible */ - if (minangle > M_PI/4) - minangle -= M_PI/2; + if (minangle > (float)(M_PI/4)) + minangle -= (float)(M_PI/2.0); MEM_freeN(angles); MEM_freeN(points); @@ -3586,7 +3586,7 @@ static void p_barycentric_2d(float *v1, float *v2, float *v3, float *p, float *b b[1] = (h[0]*c[1] - h[1]*c[0])*div; b[2] = (a[0]*h[1] - a[1]*h[0])*div; - b[0] = 1.0 - b[1] - b[2]; + b[0] = 1.0f - b[1] - b[2]; } } @@ -3596,7 +3596,7 @@ static PBool p_triangle_inside(SmoothTriangle *t, float *co) p_barycentric_2d(t->co1, t->co2, t->co3, co, b); - if ((b[0] >= 0.0) && (b[1] >= 0.0) && (b[2] >= 0.0f)) { + if ((b[0] >= 0.0f) && (b[1] >= 0.0f) && (b[2] >= 0.0f)) { co[0] = t->oco1[0]*b[0] + t->oco2[0]*b[1] + t->oco3[0]*b[2]; co[1] = t->oco1[1]*b[0] + t->oco2[1]*b[1] + t->oco3[1]*b[2]; return P_TRUE; @@ -3752,10 +3752,10 @@ static void p_smooth(PChart *chart) p_chart_uv_bbox(chart, minv, maxv); median = p_smooth_median_edge_length(chart)*0.10f; - if (median == 0.0) + if (median == 0.0f) return; - invmedian = 1.0/median; + invmedian = 1.0f/median; /* compute edge distortion */ avglen2d = avglen3d = 0.0; @@ -3874,7 +3874,7 @@ static void p_smooth(PChart *chart) p_barycentric_2d(e1->vert->uv, e2->vert->uv, e3->vert->uv, p, b); - if ((b[0] > 0.0) && (b[1] > 0.0) && (b[2] > 0.0)) { + if ((b[0] > 0.0f) && (b[1] > 0.0f) && (b[2] > 0.0f)) { nodes[i] = e1->vert->u.distortion*b[0]; nodes[i] += e2->vert->u.distortion*b[1]; nodes[i] += e3->vert->u.distortion*b[2]; @@ -4366,7 +4366,7 @@ void param_pack(ParamHandle *handle, float margin) /* multiply the margin by the area to give predictable results not dependant on UV scale, * ...Without using the area running pack multiple times also gives a bad feedback loop. * multiply by 0.1 so the margin value from the UI can be from 0.0 to 1.0 but not give a massive margin */ - margin = (margin*(float)area) * 0.1; + margin = (margin*(float)area) * 0.1f; unpacked= 0; for (i = 0; i < phandle->ncharts; i++) { chart = phandle->charts[i]; @@ -4388,9 +4388,9 @@ void param_pack(ParamHandle *handle, float margin) boxPack2D(boxarray, phandle->ncharts-unpacked, &tot_width, &tot_height); if (tot_height>tot_width) - scale = 1.0/tot_height; + scale = 1.0f/tot_height; else - scale = 1.0/tot_width; + scale = 1.0f/tot_width; for (i = 0; i < phandle->ncharts-unpacked; i++) { box = boxarray+i; @@ -4428,7 +4428,7 @@ void param_average(ParamHandle *handle) for (f=chart->faces; f; f=f->nextlink) { chart->u.pack.area += p_face_area(f); - chart->u.pack.rescale += fabs(p_face_uv_area_signed(f)); + chart->u.pack.rescale += fabsf(p_face_uv_area_signed(f)); } tot_facearea += chart->u.pack.area; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 368d43a674e..416c65c6297 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -707,11 +707,11 @@ static void correct_uv_aspect(EditMesh *em) if(efa->f & SELECT) { tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - tf->uv[0][0]= ((tf->uv[0][0]-0.5)*scale)+0.5; - tf->uv[1][0]= ((tf->uv[1][0]-0.5)*scale)+0.5; - tf->uv[2][0]= ((tf->uv[2][0]-0.5)*scale)+0.5; + tf->uv[0][0]= ((tf->uv[0][0]-0.5f)*scale)+0.5f; + tf->uv[1][0]= ((tf->uv[1][0]-0.5f)*scale)+0.5f; + tf->uv[2][0]= ((tf->uv[2][0]-0.5f)*scale)+0.5f; if(efa->v4) - tf->uv[3][0]= ((tf->uv[3][0]-0.5)*scale)+0.5; + tf->uv[3][0]= ((tf->uv[3][0]-0.5f)*scale)+0.5f; } } } @@ -722,11 +722,11 @@ static void correct_uv_aspect(EditMesh *em) if(efa->f & SELECT) { tf= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - tf->uv[0][1]= ((tf->uv[0][1]-0.5)*scale)+0.5; - tf->uv[1][1]= ((tf->uv[1][1]-0.5)*scale)+0.5; - tf->uv[2][1]= ((tf->uv[2][1]-0.5)*scale)+0.5; + tf->uv[0][1]= ((tf->uv[0][1]-0.5f)*scale)+0.5f; + tf->uv[1][1]= ((tf->uv[1][1]-0.5f)*scale)+0.5f; + tf->uv[2][1]= ((tf->uv[2][1]-0.5f)*scale)+0.5f; if(efa->v4) - tf->uv[3][1]= ((tf->uv[3][1]-0.5)*scale)+0.5; + tf->uv[3][1]= ((tf->uv[3][1]-0.5f)*scale)+0.5f; } } } @@ -802,8 +802,8 @@ static void uv_map_clip_correct(EditMesh *em, wmOperator *op) nverts= (efa->v4)? 4: 3; for(b=0; buv[b][0], 0.0, 1.0); - CLAMP(tf->uv[b][1], 0.0, 1.0); + CLAMP(tf->uv[b][0], 0.0f, 1.0f); + CLAMP(tf->uv[b][1], 0.0f, 1.0f); } } } @@ -1082,7 +1082,7 @@ static void uv_map_mirror(EditFace *efa, MTFace *tf) for(i=0; iuv[mi][0] - tf->uv[i][0]; - if(dx > 0.5) tf->uv[i][0] += 1.0; + if(dx > 0.5f) tf->uv[i][0] += 1.0f; } } } @@ -1253,24 +1253,24 @@ static int cube_project_exec(bContext *C, wmOperator *op) else if(no[1]>=no[0] && no[1]>=no[2]) coy= 2; else { cox= 1; coy= 2; } - tf->uv[0][0]= 0.5+0.5*cube_size*(loc[cox] + efa->v1->co[cox]); - tf->uv[0][1]= 0.5+0.5*cube_size*(loc[coy] + efa->v1->co[coy]); + tf->uv[0][0]= 0.5f+0.5f*cube_size*(loc[cox] + efa->v1->co[cox]); + tf->uv[0][1]= 0.5f+0.5f*cube_size*(loc[coy] + efa->v1->co[coy]); dx = floor(tf->uv[0][0]); dy = floor(tf->uv[0][1]); tf->uv[0][0] -= dx; tf->uv[0][1] -= dy; - tf->uv[1][0]= 0.5+0.5*cube_size*(loc[cox] + efa->v2->co[cox]); - tf->uv[1][1]= 0.5+0.5*cube_size*(loc[coy] + efa->v2->co[coy]); + tf->uv[1][0]= 0.5f+0.5f*cube_size*(loc[cox] + efa->v2->co[cox]); + tf->uv[1][1]= 0.5f+0.5f*cube_size*(loc[coy] + efa->v2->co[coy]); tf->uv[1][0] -= dx; tf->uv[1][1] -= dy; - tf->uv[2][0]= 0.5+0.5*cube_size*(loc[cox] + efa->v3->co[cox]); - tf->uv[2][1]= 0.5+0.5*cube_size*(loc[coy] + efa->v3->co[coy]); + tf->uv[2][0]= 0.5f+0.5f*cube_size*(loc[cox] + efa->v3->co[cox]); + tf->uv[2][1]= 0.5f+0.5f*cube_size*(loc[coy] + efa->v3->co[coy]); tf->uv[2][0] -= dx; tf->uv[2][1] -= dy; if(efa->v4) { - tf->uv[3][0]= 0.5+0.5*cube_size*(loc[cox] + efa->v4->co[cox]); - tf->uv[3][1]= 0.5+0.5*cube_size*(loc[coy] + efa->v4->co[coy]); + tf->uv[3][0]= 0.5f+0.5f*cube_size*(loc[cox] + efa->v4->co[cox]); + tf->uv[3][1]= 0.5f+0.5f*cube_size*(loc[coy] + efa->v4->co[coy]); tf->uv[3][0] -= dx; tf->uv[3][1] -= dy; } diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 510ae31db51..200b42526f0 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -106,7 +106,7 @@ void GPU_render_text(MTFace *tface, int mode, line_height= MAX4(v1[1], v2[1], v3[1], v4[2]) - MIN4(v1[1], v2[1], v3[1], v4[2]); else line_height= MAX3(v1[1], v2[1], v3[1]) - MIN3(v1[1], v2[1], v3[1]); - line_height *= 1.2; /* could be an option? */ + line_height *= 1.2f; /* could be an option? */ /* end multiline */ @@ -358,7 +358,7 @@ static void gpu_set_blend_mode(GPUBlendMode blendmode) * turn off alpha test in this case */ /* added after 2.45 to clip alpha */ - if(U.glalphaclip == 1.0) { + if(U.glalphaclip == 1.0f) { glDisable(GL_ALPHA_TEST); } else { @@ -1288,8 +1288,8 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4 /* spot lamp */ negate_v3_v3(direction, base->object->obmat[2]); glLightfv(GL_LIGHT0+count, GL_SPOT_DIRECTION, direction); - glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, la->spotsize/2.0); - glLightf(GL_LIGHT0+count, GL_SPOT_EXPONENT, 128.0*la->spotblend); + glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, la->spotsize/2.0f); + glLightf(GL_LIGHT0+count, GL_SPOT_EXPONENT, 128.0f*la->spotblend); } else glLightf(GL_LIGHT0+count, GL_SPOT_CUTOFF, 180.0); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 8e71f259557..4155b7a8ac0 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1060,7 +1060,7 @@ static void do_material_tex(GPUShadeInput *shi) else newnor = tnor; - norfac = MIN2(fabsf(mtex->norfac), 1.0); + norfac = MIN2(fabsf(mtex->norfac), 1.0f); if(norfac == 1.0f && !GPU_link_changed(stencil)) { shi->vn = newnor; @@ -1308,7 +1308,7 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) /* exposure correction */ if(world->exp!=0.0f || world->range!=1.0f) { linfac= 1.0 + pow((2.0*world->exp + 0.5), -10); - logfac= log((linfac-1.0)/linfac)/world->range; + logfac= log((linfac-1.0f)/linfac)/world->range; GPU_link(mat, "set_value", GPU_uniform(&linfac), &ulinfac); GPU_link(mat, "set_value", GPU_uniform(&logfac), &ulogfac); @@ -1481,10 +1481,10 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l lamp->spotsi= la->spotsize; if(lamp->mode & LA_HALO) - if(lamp->spotsi > 170.0) - lamp->spotsi = 170.0; + if(lamp->spotsi > 170.0f) + lamp->spotsi = 170.0f; lamp->spotsi= cos(M_PI*lamp->spotsi/360.0); - lamp->spotbl= (1.0 - lamp->spotsi)*la->spotblend; + lamp->spotbl= (1.0f - lamp->spotsi)*la->spotblend; lamp->k= la->k; lamp->dist= la->dist; diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 9043cb5f6a6..9d916321c3e 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -511,7 +511,8 @@ typedef struct bDopeSheet { ID *source; /* currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil) */ ListBase chanbase; /* cache for channels (only initialised when pinned) */ // XXX not used! - struct Group *filter_grp; /* object group for ADS_FILTER_ONLYOBGROUP filtering option */ + struct Group *filter_grp; /* object group for ADS_FILTER_ONLYOBGROUP filtering option */ + char searchstr[64]; /* string to search for in displayed names of F-Curves for ADS_FILTER_BY_FCU_NAME filtering option */ int filterflag; /* flags to use for filtering data */ int flag; /* standard flags */ @@ -555,6 +556,7 @@ typedef enum eDopeSheet_FilterFlag { /* general filtering 3 */ ADS_FILTER_INCL_HIDDEN = (1<<26), /* include 'hidden' channels too (i.e. those from hidden Objects/Bones) */ + ADS_FILTER_BY_FCU_NAME = (1<<27), /* for F-Curves, filter by the displayed name (i.e. to isolate all Location curves only) */ /* combination filters (some only used at runtime) */ ADS_FILTER_NOOBDATA = (ADS_FILTER_NOCAM|ADS_FILTER_NOMAT|ADS_FILTER_NOLAM|ADS_FILTER_NOCUR|ADS_FILTER_NOPART|ADS_FILTER_NOARM) diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index ffccc08048e..6eb5f64ffc3 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -119,6 +119,8 @@ typedef struct bGPDlayer { #define GP_LAYER_SELECT (1<<5) /* current frame for layer can't be changed */ #define GP_LAYER_FRAMELOCK (1<<6) + /* don't render xray (which is default) */ +#define GP_LAYER_NO_XRAY (1<<7) /* Grease-Pencil Annotations - 'DataBlock' */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 521895bc20f..9ca36e02483 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -549,6 +549,7 @@ extern StructRNA RNA_ThemeView3D; extern StructRNA RNA_ThemeWidgetColors; extern StructRNA RNA_ThemeWidgetStateColors; extern StructRNA RNA_TimelineMarker; +extern StructRNA RNA_Timer; extern StructRNA RNA_ToolSettings; extern StructRNA RNA_TouchSensor; extern StructRNA RNA_TrackToConstraint; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index abba8a36211..0126c62ccea 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -74,8 +74,8 @@ extern EnumPropertyItem event_type_items[]; extern EnumPropertyItem operator_return_items[]; extern EnumPropertyItem brush_sculpt_tool_items[]; -extern EnumPropertyItem brush_vertexpaint_tool_items[]; -extern EnumPropertyItem brush_imagepaint_tool_items[]; +extern EnumPropertyItem brush_vertex_tool_items[]; +extern EnumPropertyItem brush_image_tool_items[]; extern EnumPropertyItem texture_type_items[]; @@ -95,6 +95,8 @@ extern EnumPropertyItem operator_context_items[]; extern EnumPropertyItem wm_report_items[]; +extern EnumPropertyItem transform_mode_types[]; + extern EnumPropertyItem property_type_items[]; extern EnumPropertyItem property_unit_items[]; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 4ca73f81965..aabb2c92996 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -778,43 +778,41 @@ int RNA_property_array_item_index(PropertyRNA *prop, char name) { PropertySubType subtype= rna_ensure_property(prop)->subtype; - name= toupper(name); - /* get index based on string name/alias */ /* maybe a function to find char index in string would be better than all the switches */ if (ELEM(subtype, PROP_QUATERNION, PROP_AXISANGLE)) { switch (name) { - case 'W': + case 'w': return 0; - case 'X': + case 'x': return 1; - case 'Y': + case 'y': return 2; - case 'Z': + case 'z': return 3; } } else if(ELEM6(subtype, PROP_TRANSLATION, PROP_DIRECTION, PROP_XYZ, PROP_EULER, PROP_VELOCITY, PROP_ACCELERATION)) { switch (name) { - case 'X': + case 'x': return 0; - case 'Y': + case 'y': return 1; - case 'Z': + case 'z': return 2; - case 'W': + case 'w': return 3; } } else if (ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA)) { switch (name) { - case 'R': + case 'r': return 0; - case 'G': + case 'g': return 1; - case 'B': + case 'b': return 2; - case 'A': + case 'a': return 3; } } diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 1cf596af69d..2e71cfc959e 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -236,6 +236,18 @@ static void rna_def_dopesheet(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Filtering Group", "Group that included Object should be a member of"); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + /* FCurve Display Name Search Settings */ + prop= RNA_def_property(srna, "show_only_matching_fcurves", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_BY_FCU_NAME); + RNA_def_property_ui_text(prop, "Only Matching F-Curves", "Only include F-Curves with names containing search text"); + RNA_def_property_ui_icon(prop, ICON_VIEWZOOM, 0); + RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + + prop= RNA_def_property(srna, "filter_fcurve_name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "searchstr"); + RNA_def_property_ui_text(prop, "F-Curve Name Filter", "F-Curve live filtering string"); + RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + /* NLA Specific Settings */ prop= RNA_def_property(srna, "show_missing_nla", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NLA_NOACT); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 06dcaa5441e..09577fdf067 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -69,7 +69,7 @@ EnumPropertyItem brush_sculpt_tool_items[] = { {0, NULL, 0, NULL, NULL}}; -EnumPropertyItem brush_vertexpaint_tool_items[] = { +EnumPropertyItem brush_vertex_tool_items[] = { {0, "MIX", ICON_BRUSH_MIX, "Mix", "Use mix blending mode while painting"}, {1, "ADD", ICON_BRUSH_ADD, "Add", "Use add blending mode while painting"}, {2, "SUB", ICON_BRUSH_SUBTRACT, "Subtract", "Use subtract blending mode while painting"}, @@ -79,7 +79,7 @@ EnumPropertyItem brush_vertexpaint_tool_items[] = { {6, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"}, {0, NULL, 0, NULL, NULL}}; -EnumPropertyItem brush_imagepaint_tool_items[] = { +EnumPropertyItem brush_image_tool_items[] = { {PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""}, {PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""}, {PAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SMEAR, "Smear", ""}, @@ -130,7 +130,7 @@ static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA * rna_Brush_update(bmain, scene, ptr); } -static void rna_Brush_vertexpaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Brush *br= (Brush*)ptr->data; rna_Brush_reset_icon(br, "vertex_paint"); @@ -140,7 +140,7 @@ static void rna_Brush_vertexpaint_tool_update(Main *bmain, Scene *scene, Pointer static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Brush *br= (Brush*)ptr->data; - rna_Brush_reset_icon(br, "texture_paint"); + rna_Brush_reset_icon(br, "image_paint"); rna_Brush_update(bmain, scene, ptr); } @@ -383,13 +383,15 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Sculpt Tool", ""); RNA_def_property_update(prop, 0, "rna_Brush_sculpt_tool_update"); - prop= RNA_def_property(srna, "vertexpaint_tool", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, brush_vertexpaint_tool_items); + prop= RNA_def_property(srna, "vertex_tool", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "vertexpaint_tool"); + RNA_def_property_enum_items(prop, brush_vertex_tool_items); RNA_def_property_ui_text(prop, "Vertex/Weight Paint Tool", ""); - RNA_def_property_update(prop, 0, "rna_Brush_vertexpaint_tool_update"); + RNA_def_property_update(prop, 0, "rna_Brush_vertex_tool_update"); - prop= RNA_def_property(srna, "imagepaint_tool", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, brush_imagepaint_tool_items); + prop= RNA_def_property(srna, "image_tool", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "imagepaint_tool"); + RNA_def_property_enum_items(prop, brush_image_tool_items); RNA_def_property_ui_text(prop, "Image Paint Tool", ""); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update"); @@ -428,7 +430,7 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_int_funcs(prop, "rna_Brush_get_size", "rna_Brush_set_size", NULL); RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0); - RNA_def_property_ui_text(prop, "Size", "Radius of the brush in pixels"); + RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); RNA_def_property_update(prop, 0, "rna_Brush_update"); prop= RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE); @@ -694,7 +696,7 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_WEIGHT_PAINT); RNA_def_property_ui_text(prop, "Use Weight", "Use this brush in weight paint mode"); - prop= RNA_def_property(srna, "use_paint_texture", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_paint_image", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_TEXTURE_PAINT); RNA_def_property_ui_text(prop, "Use Texture", "Use this brush in texture paint mode"); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 0c6eef3ee24..6940b2a3543 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -75,25 +75,25 @@ EnumPropertyItem constraint_type_items[] ={ {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT_DATA, "Shrinkwrap", ""}, {0, NULL, 0, NULL, NULL}}; -EnumPropertyItem space_pchan_items[] = { +static EnumPropertyItem space_pchan_items[] = { {0, "WORLD", 0, "World Space", ""}, {2, "POSE", 0, "Pose Space", ""}, {3, "LOCAL_WITH_PARENT", 0, "Local With Parent", ""}, {1, "LOCAL", 0, "Local Space", ""}, {0, NULL, 0, NULL, NULL}}; -EnumPropertyItem space_object_items[] = { +static EnumPropertyItem space_object_items[] = { {0, "WORLD", 0, "World Space", ""}, {1, "LOCAL", 0, "Local Space", ""}, {0, NULL, 0, NULL, NULL}}; -EnumPropertyItem constraint_ik_type_items[] ={ +static EnumPropertyItem constraint_ik_type_items[] ={ {CONSTRAINT_IK_COPYPOSE, "COPY_POSE", 0, "Copy Pose", ""}, {CONSTRAINT_IK_DISTANCE, "DISTANCE", 0, "Distance", ""}, {0, NULL, 0, NULL, NULL}, }; -EnumPropertyItem constraint_ik_axisref_items[] ={ +static EnumPropertyItem constraint_ik_axisref_items[] ={ {0, "BONE", 0, "Bone", ""}, {CONSTRAINT_IK_TARGETAXIS, "TARGET", 0, "Target", ""}, {0, NULL, 0, NULL, NULL}, diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 12f15911bda..b3937b33226 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -2855,7 +2855,7 @@ void RNA_def_property_free_pointers(PropertyRNA *prop) } } -void RNA_def_property_free(StructOrFunctionRNA *cont_, PropertyRNA *prop) +static void rna_def_property_free(StructOrFunctionRNA *cont_, PropertyRNA *prop) { ContainerRNA *cont= cont_; @@ -2880,7 +2880,7 @@ int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *ide for(prop= cont->properties.first; prop; prop= prop->next) { if(strcmp(prop->identifier, identifier)==0) { if(prop->flag & PROP_RUNTIME) { - RNA_def_property_free(cont_, prop); + rna_def_property_free(cont_, prop); return 1; } else { diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index c9cbe9c9e38..228b00e7937 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -45,7 +45,7 @@ static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr) { bGPDlayer *gpl= (bGPDlayer *)ptr->data; - + /* surely there must be other criteria too... */ if (gpl->flag & GP_LAYER_LOCKED) return 0; @@ -53,22 +53,43 @@ static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr) return 1; } -static void rna_GPencilLayer_active_set(PointerRNA *ptr, int value) +static PointerRNA rna_GPencil_active_layer_get(PointerRNA *ptr) { bGPdata *gpd= ptr->id.data; - bGPDlayer *gpl= ptr->data; - - /* disabled all other layers anyway */ - if (GS(gpd->id.name) == ID_GD) { + + if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */ bGPDlayer *gl; - - for (gl= gpd->layers.first; gl; gl= gl->next) - gl->flag &= ~GP_LAYER_ACTIVE; - } - - /* if enabling value, make it active */ - if (value) - gpl->flag |= GP_LAYER_ACTIVE; + + for (gl= gpd->layers.first; gl; gl= gl->next) { + if(gl->flag & GP_LAYER_ACTIVE) { + break; + } + } + + if(gl) { + return rna_pointer_inherit_refine(ptr, &RNA_GPencilLayer, gl); + } + } + + return rna_pointer_inherit_refine(ptr, NULL, NULL); +} + +static void rna_GPencil_active_layer_set(PointerRNA *ptr, PointerRNA value) +{ + bGPdata *gpd= ptr->id.data; + + if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */ + bGPDlayer *gl; + + for (gl= gpd->layers.first; gl; gl= gl->next) { + if(gl == value.data) { + gl->flag |= GP_LAYER_ACTIVE; + } + else { + gl->flag &= ~GP_LAYER_ACTIVE; + } + } + } } #else @@ -218,13 +239,16 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_FRAMELOCK); RNA_def_property_ui_text(prop, "Frame Locked", "Lock current frame displayed by layer"); RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL); - + + /* expose as layers.active */ + /* prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ACTIVE); RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencilLayer_active_set"); RNA_def_property_ui_text(prop, "Active", "Set active layer for editing"); RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL); - + */ + prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_SELECT); RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the DopeSheet"); @@ -235,6 +259,47 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG); RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes)"); RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL); + + /* X-Ray */ + prop= RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY); + RNA_def_property_ui_text(prop, "X Ray", ""); + RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL); +} + +static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + +// FunctionRNA *func; +// PropertyRNA *parm; + + RNA_def_property_srna(cprop, "GreasePencilLayers"); + srna= RNA_def_struct(brna, "GreasePencilLayers", NULL); + RNA_def_struct_sdna(srna, "bGPdata"); + RNA_def_struct_ui_text(srna, "Grease Pencil Layers", "Collection of grease pencil layers"); + +#if 0 + func= RNA_def_function(srna, "new", "rna_GPencil_layer_new"); + RNA_def_function_ui_description(func, "Add a new spline to the curve."); + parm= RNA_def_enum(func, "type", curve_type_items, CU_POLY, "", "type for the new spline."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "spline", "Spline", "", "The newly created spline."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_GPencil_layer_remove"); + RNA_def_function_ui_description(func, "Remove a spline from a curve."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); +#endif + + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "GreasePencil"); + RNA_def_property_pointer_funcs(prop, "rna_GPencil_active_layer_get", "rna_GPencil_active_layer_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Active Layer", "Active grease pencil layer"); } static void rna_def_gpencil_data(BlenderRNA *brna) @@ -259,6 +324,7 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "layers", NULL); RNA_def_property_struct_type(prop, "GPencilLayer"); RNA_def_property_ui_text(prop, "Layers", ""); + rna_def_gpencil_layers(brna, prop); /* Flags */ prop= RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); @@ -278,7 +344,7 @@ static void rna_def_gpencil_data(BlenderRNA *brna) void RNA_def_gpencil(BlenderRNA *brna) { rna_def_gpencil_data(brna); - + rna_def_gpencil_layer(brna); rna_def_gpencil_frame(brna); rna_def_gpencil_stroke(brna); diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 48cab3b13d1..ded89e8b66b 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -104,7 +104,7 @@ static void rna_ShapeKey_value_range(PointerRNA *ptr, float *min, float *max) } /* epsilon for how close one end of shapekey range can get to the other */ -#define SHAPEKEY_SLIDER_TOL 0.001 +#define SHAPEKEY_SLIDER_TOL 0.001f static void rna_ShapeKey_slider_min_range(PointerRNA *ptr, float *min, float *max) { @@ -348,7 +348,7 @@ static char *rna_ShapeKey_path(PointerRNA *ptr) ID *id= ptr->id.data; if ((id) && (GS(id->name) != ID_KE)) - return BLI_sprintfN("shape_keys.keys[\"%s\"]", kb->name); + return BLI_sprintfN("shape_keys.key_blocks[\"%s\"]", kb->name); else return BLI_sprintfN("key_blocks[\"%s\"]", kb->name); } diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 5f274a09f5d..c689c4ae90a 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -138,13 +138,13 @@ static void rna_Lamp_sky_update(Main *bmain, Scene *scene, PointerRNA *ptr) static float rna_Lamp_spot_size_get(PointerRNA *ptr) { Lamp *la= ptr->id.data; - return la->spotsize * (M_PI / 180.0); + return DEG2RADF(la->spotsize); } static void rna_Lamp_spot_size_set(PointerRNA *ptr, float value) { Lamp *la= ptr->id.data; - la->spotsize= value * (180.0 / M_PI); + la->spotsize= RAD2DEGF(value); } @@ -649,7 +649,7 @@ static void rna_def_spot_lamp(BlenderRNA *brna) prop= RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_ANGLE); // RNA_def_property_float_sdna(prop, NULL, "spotsize"); - RNA_def_property_range(prop, M_PI/180.0f, M_PI); + RNA_def_property_range(prop, M_PI/180.0, M_PI); RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam in degrees"); RNA_def_property_float_funcs(prop, "rna_Lamp_spot_size_get", "rna_Lamp_spot_size_set", NULL); /* only for deg/rad conversion */ RNA_def_property_update(prop, 0, "rna_Lamp_draw_update"); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 140a4b435be..c4a5e4966d3 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -437,9 +437,12 @@ static void modifier_object_set(Object *self, Object **ob_p, int type, PointerRN { Object *ob= value.data; - if(!self || ob != self) - if(!ob || type == OB_EMPTY || ob->type == type) + if(!self || ob != self) { + if(!ob || type == OB_EMPTY || ob->type == type) { + id_lib_extern((ID *)ob); *ob_p= ob; + } + } } static void rna_LatticeModifier_object_set(PointerRNA *ptr, PointerRNA value) diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index a921bbbafad..719cc6755d6 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -163,7 +163,7 @@ static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, float value) len= data->end - data->start; actlen= data->actend - data->actstart; - if (IS_EQ(actlen, 0.0f)) actlen= 1.0f; + if (IS_EQF(actlen, 0.0f)) actlen= 1.0f; /* now, adjust the 'scale' setting to reflect this (so that this change can be valid) */ data->scale= len / ((actlen) * data->repeat); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 1531b6a9dc0..c22809c6b22 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -505,7 +505,7 @@ static void rna_PartSetting_pathstartend_range(PointerRNA *ptr, float *min, floa if(settings->type==PART_HAIR) { *min = 0.0f; - *max = (settings->draw & PART_ABS_PATH_TIME) ? 100.0f : 1.0; + *max = (settings->draw & PART_ABS_PATH_TIME) ? 100.0f : 1.0f; } else { *min = (settings->draw & PART_ABS_PATH_TIME) ? settings->sta : 0.0f; diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 658e1dc3b80..9b8b23e3c47 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -823,7 +823,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "pose_mat"); RNA_def_property_multi_array(prop, 2, matrix_dimsize); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Pose Matrix", "Final 4x4 matrix for this channel"); + RNA_def_property_ui_text(prop, "Pose Matrix", "Final 4x4 matrix after constraints and drivers are applied (object space)"); /* Head/Tail Coordinates (in Pose Space) - Automatically calculated... */ prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index ca3852c0fd0..10c784b51e7 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -734,12 +734,12 @@ static int rna_enum_check_separator(CollectionPropertyIterator *iter, void *data static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { PropertyRNA *prop= (PropertyRNA*)ptr->data; - EnumPropertyRNA *eprop; + // EnumPropertyRNA *eprop; // UNUSED EnumPropertyItem *item= NULL; int totitem, free= 0; rna_idproperty_check(&prop, ptr); - eprop= (EnumPropertyRNA*)prop; + // eprop= (EnumPropertyRNA*)prop; RNA_property_enum_items(NULL, ptr, prop, &item, &totitem, &free); rna_iterator_array_begin(iter, (void*)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index cee152d86ad..f8b44b6e63f 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -79,9 +79,9 @@ EnumPropertyItem proportional_falloff_items[] ={ EnumPropertyItem proportional_editing_items[] = { - {PROP_EDIT_OFF, "DISABLED", ICON_PROP_OFF, "Disable", ""}, - {PROP_EDIT_ON, "ENABLED", ICON_PROP_ON, "Enable", ""}, - {PROP_EDIT_CONNECTED, "CONNECTED", ICON_PROP_CON, "Connected", ""}, + {PROP_EDIT_OFF, "DISABLED", ICON_PROP_OFF, "Disable", "Proportional Editing disabled"}, + {PROP_EDIT_ON, "ENABLED", ICON_PROP_ON, "Enable", "Proportional Editing enabled"}, + {PROP_EDIT_CONNECTED, "CONNECTED", ICON_PROP_CON, "Connected", "Proportional Editing using connected geometry only"}, {0, NULL, 0, NULL, NULL}}; /* keep for operators, not used here */ @@ -225,7 +225,7 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report } base= scene_add_base(scene, ob); - ob->id.us++; + id_us_plus(&ob->id); /* this is similar to what object_add_type and add_object do */ base->lay= scene->lay; @@ -1133,7 +1133,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "proportional_edit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "proportional"); RNA_def_property_enum_items(prop, proportional_editing_items); - RNA_def_property_ui_text(prop, "Proportional Editing", "Proportional editing mode"); + RNA_def_property_ui_text(prop, "Proportional Editing", "Proportional Editing mode, allows transforms with distance fall-off"); RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ prop= RNA_def_property(srna, "use_proportional_edit_objects", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index d190277f9aa..d129fccc717 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -153,6 +153,16 @@ static void rna_def_area(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_Area_type_update"); + prop= RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "winx"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Width", "Area width"); + + prop= RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "winy"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Height", "Area height"); + RNA_def_function(srna, "tag_redraw", "ED_area_tag_redraw"); func= RNA_def_function(srna, "header_text_set", "ED_area_headerprint"); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 6ba2f724e5e..58f19fe8799 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -469,7 +469,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) prop= RNA_def_property(srna, "size", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 100, 10, 3); - RNA_def_property_ui_text(prop, "Size", "Brush size"); + RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.001, 1.0); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 829ff59618b..2ee19b07d86 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -46,7 +46,7 @@ static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag= 0; if(!prop) { - printf("rna_uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("rna_uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f481dbfa61d..c5a1db46e6c 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1718,7 +1718,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna) static EnumPropertyItem active_theme_area[] = { {0, "USER_INTERFACE", ICON_UI, "User Interface", ""}, - {18, "COLOR_SETS", ICON_COLOR, "Bone Color Sets", ""}, + {18, "BONE_COLOR_SETS", ICON_COLOR, "Bone Color Sets", ""}, {1, "VIEW_3D", ICON_VIEW3D, "3D View", ""}, {2, "TIMELINE", ICON_TIME, "Timeline", ""}, {3, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", ""}, diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 0d1463428bb..df029c9d871 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -918,8 +918,8 @@ static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void * int idlen = strlen(_operator_idname) + 4; int namelen = strlen(_operator_name) + 1; int desclen = strlen(_operator_descr) + 1; - char *ch, *ch_arr; - ch_arr= ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */ + char *ch; + ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */ WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */ dummyot.idname= ch; ch += idlen; @@ -985,8 +985,8 @@ static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, v int idlen = strlen(_operator_idname) + 4; int namelen = strlen(_operator_name) + 1; int desclen = strlen(_operator_descr) + 1; - char *ch, *ch_arr; - ch_arr= ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */ + char *ch; + ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */ WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */ dummyot.idname= ch; ch += idlen; @@ -1418,6 +1418,36 @@ static void rna_def_event(BlenderRNA *brna) RNA_define_verify_sdna(1); // not in sdna } +static void rna_def_timer(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "Timer", NULL); + RNA_def_struct_ui_text(srna, "Timer", "Window event timer"); + RNA_def_struct_sdna(srna, "wmTimer"); + + RNA_define_verify_sdna(0); // not in sdna + + /* could wrap more, for now this is enough */ + prop= RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "timestep"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Time Step", ""); + + prop= RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "delta"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds"); + + prop= RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "duration"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds"); + + RNA_define_verify_sdna(1); // not in sdna +} + static void rna_def_window(BlenderRNA *brna) { StructRNA *srna; @@ -1801,6 +1831,7 @@ void RNA_def_wm(BlenderRNA *brna) rna_def_macro_operator(brna); rna_def_operator_type_macro(brna); rna_def_event(brna); + rna_def_timer(brna); rna_def_window(brna); rna_def_windowmanager(brna); rna_def_keyconfig(brna); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 4891d8b1078..5a0708865b6 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -73,6 +73,17 @@ static int rna_event_modal_handler_add(struct bContext *C, struct wmOperator *op return WM_event_add_modal_handler(C, operator) != NULL; } +/* XXX, need a way for python to know event types, 0x0110 is hard coded */ +struct wmTimer *rna_event_timer_add(struct wmWindowManager *wm, float time_step, wmWindow *win) +{ + return WM_event_add_timer(wm, win, 0x0110, time_step); +} + +void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer) +{ + WM_event_remove_timer(wm, timer->win, timer); +} + #else #define WM_GEN_INVOKE_EVENT (1<<0) @@ -118,6 +129,22 @@ void RNA_api_wm(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_function_return(func, RNA_def_boolean(func, "handle", 1, "", "")); + + func= RNA_def_function(srna, "event_timer_add", "rna_event_timer_add"); + parm= RNA_def_property(func, "time_step", PROP_FLOAT, PROP_NONE); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_range(parm, 0.0, FLT_MAX); + RNA_def_property_ui_text(parm, "Time Step", "Interval in seconds between timer events"); + parm= RNA_def_pointer(func, "window", "Window", "", "Window to attach the timer to or None."); + parm= RNA_def_pointer(func, "result", "Timer", "", ""); + RNA_def_function_return(func, parm); + + + func= RNA_def_function(srna, "event_timer_remove", "rna_event_timer_remove"); + parm= RNA_def_pointer(func, "timer", "Timer", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + /* invoke functions, for use with python */ func= RNA_def_function(srna, "invoke_props_popup", "WM_operator_props_popup"); RNA_def_function_ui_description(func, "Operator popup invoke."); @@ -222,6 +249,9 @@ void RNA_api_operator(StructRNA *srna) RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL); parm= RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + parm= RNA_def_enum_flag(func, "result", operator_return_items, OPERATOR_CANCELLED, "result", ""); // better name? + RNA_def_function_return(func, parm); } void RNA_api_macro(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 981ff3d97cd..7166d51da5a 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -291,7 +291,7 @@ static void rna_def_lighting(BlenderRNA *brna) prop= RNA_def_property(srna, "indirect_bounces", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "ao_indirect_bounces"); RNA_def_property_range(prop, 1, SHRT_MAX); - RNA_def_property_ui_text(prop, "Bounces", "Number of indirect diffuse light bounces to use for approximate ambient occlusion"); + RNA_def_property_ui_text(prop, "Bounces", "Number of indirect diffuse light bounces"); RNA_def_property_update(prop, 0, "rna_World_update"); /* gathering parameters */ @@ -304,7 +304,7 @@ static void rna_def_lighting(BlenderRNA *brna) prop= RNA_def_property(srna, "passes", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "ao_approx_passes"); RNA_def_property_range(prop, 0, 10); - RNA_def_property_ui_text(prop, "Passes", "Number of preprocessing passes to reduce overocclusion (for approximate ambient occlusion)"); + RNA_def_property_ui_text(prop, "Passes", "Number of preprocessing passes to reduce overocclusion"); RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); @@ -338,14 +338,14 @@ static void rna_def_lighting(BlenderRNA *brna) prop= RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ao_approx_error"); RNA_def_property_range(prop, 0.0001, 10); - RNA_def_property_ui_text(prop, "Error Tolerance", "Low values are slower and higher quality (for Approximate)"); + RNA_def_property_ui_text(prop, "Error Tolerance", "Low values are slower and higher quality"); RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "correction", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ao_approx_correction"); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_range(prop, 0, 1, 0.1, 2); - RNA_def_property_ui_text(prop, "Correction", "Ad-hoc correction for over-occlusion due to the approximation (for Approximate)"); + RNA_def_property_ui_text(prop, "Correction", "Ad-hoc correction for over-occlusion due to the approximation"); RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE); @@ -355,7 +355,7 @@ static void rna_def_lighting(BlenderRNA *brna) prop= RNA_def_property(srna, "use_cache", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AOCACHE); - RNA_def_property_ui_text(prop, "Pixel Cache", "Cache AO results in pixels and interpolate over neighbouring pixels for speedup (for Approximate)"); + RNA_def_property_ui_text(prop, "Pixel Cache", "Cache AO results in pixels and interpolate over neighbouring pixels for speedup"); RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); @@ -573,4 +573,3 @@ void RNA_def_world(BlenderRNA *brna) } #endif - diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 237a0f9b216..36e804607cf 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -191,14 +191,14 @@ static int edgecut_get(EdgeHash *edgehash, int v1, int v2) } -const short add_faces[24] = { +static const short add_faces[24] = { 0, 0, 0, 2, 0, 1, 2, 2, 0, 2, 1, 2, 2, 2, 2, 3, 0, 0, 0, 1, 0, 1, 1, 2 }; -MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFace *mf) +static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFace *mf) { MFace *df = CDDM_get_face(split, cur); DM_copy_face_data(dm, split, i, cur, 1); diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index b13d86a609e..d8e94e92bfa 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -147,6 +147,17 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } } +static void foreachIDLink(ModifierData *md, Object *ob, + IDWalkFunc walk, void *userData) +{ + SmokeModifierData *smd = (SmokeModifierData*) md; + + if(smd->type==MOD_SMOKE_TYPE_DOMAIN && smd->domain) { + walk(userData, ob, (ID **)&smd->domain->coll_group); + walk(userData, ob, (ID **)&smd->domain->fluid_group); + walk(userData, ob, (ID **)&smd->domain->eff_group); + } +} ModifierTypeInfo modifierType_Smoke = { /* name */ "Smoke", @@ -172,5 +183,5 @@ ModifierTypeInfo modifierType_Smoke = { /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, + /* foreachIDLink */ foreachIDLink, }; diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_hueSatVal.c b/source/blender/nodes/intern/SHD_nodes/SHD_hueSatVal.c index dd09b4e1b70..91fd995dbbe 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_hueSatVal.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_hueSatVal.c @@ -52,12 +52,12 @@ static bNodeSocketType sh_node_hue_sat_out[]= { /* note: it would be possible to use CMP version for both nodes */ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float *hue, float *sat, float *val, float *in, float *fac) { - if(*fac!=0.0f && (*hue!=0.5f || *sat!=1.0 || *val!=1.0)) { + if(*fac!=0.0f && (*hue!=0.5f || *sat!=1.0f || *val!=1.0f)) { float col[3], hsv[3], mfac= 1.0f - *fac; rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2); hsv[0]+= (*hue - 0.5f); - if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0; + if(hsv[0]>1.0f) hsv[0]-=1.0f; else if(hsv[0]<0.0f) hsv[0]+= 1.0f; hsv[1]*= *sat; hsv[2]*= *val; hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2); diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_invert.c b/source/blender/nodes/intern/SHD_nodes/SHD_invert.c index 888d1514146..f8d6e54859e 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_invert.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_invert.c @@ -59,7 +59,7 @@ bNodeStack **out) /* if fac, blend result against original input */ if (in[0]->vec[0] < 1.0f) { - facm = 1.0 - in[0]->vec[0]; + facm = 1.0f - in[0]->vec[0]; col[0] = in[0]->vec[0]*col[0] + (facm*in[1]->vec[0]); col[1] = in[0]->vec[0]*col[1] + (facm*in[1]->vec[1]); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_at.c b/source/blender/nodes/intern/TEX_nodes/TEX_at.c index c66935c1ab8..d5980b786b0 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_at.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_at.c @@ -31,7 +31,8 @@ */ -#include "../TEX_util.h" +#include "../TEX_util.h" +#include "TEX_node.h" static bNodeSocketType inputs[]= { { SOCK_RGBA, 1, "Texture", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c index fe9b7cfadb8..0eb982496a9 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_bricks.c @@ -31,7 +31,9 @@ */ -#include "../TEX_util.h" +#include "../TEX_util.h" +#include "TEX_node.h" + #include static bNodeSocketType inputs[]= { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c index b2da0d60570..c6c25ba1a8a 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c @@ -31,7 +31,8 @@ */ -#include "../TEX_util.h" +#include "../TEX_util.h" +#include "TEX_node.h" #include static bNodeSocketType inputs[]= { @@ -53,9 +54,9 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** float sz = tex_input_value(in[2], p, thread); /* 0.00001 because of unit sized stuff */ - int xi = (int)fabs(floor(0.00001 + x / sz)); - int yi = (int)fabs(floor(0.00001 + y / sz)); - int zi = (int)fabs(floor(0.00001 + z / sz)); + int xi = (int)fabs(floor(0.00001f + x / sz)); + int yi = (int)fabs(floor(0.00001f + y / sz)); + int zi = (int)fabs(floor(0.00001f + z / sz)); if( (xi % 2 == yi % 2) == (zi % 2) ) { tex_input_rgba(out, in[0], p, thread); diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c index bde78e72399..6eae78ec3de 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_compose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_compose.c @@ -31,7 +31,8 @@ */ -#include "../TEX_util.h" +#include "../TEX_util.h" +#include "TEX_node.h" static bNodeSocketType inputs[]= { { SOCK_VALUE, 1, "Red", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }, diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c index c43aa9e4f32..3c46971f0d4 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_coord.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_coord.c @@ -32,6 +32,7 @@ #include "../TEX_util.h" +#include "TEX_node.h" static bNodeSocketType outputs[]= { { SOCK_VECTOR, 0, "Coordinates", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f }, diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c index 0eb3927f9a8..e388efd17c0 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c @@ -32,6 +32,7 @@ #include "../TEX_util.h" +#include "TEX_node.h" /* **************** CURVE Time ******************** */ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c index 1da9b6c681d..f27d8c98716 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c @@ -31,7 +31,8 @@ */ -#include "../TEX_util.h" +#include "../TEX_util.h" +#include "TEX_node.h" #include static bNodeSocketType inputs[]= { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c index 5f61a9e8045..b460844ba4a 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_distance.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_distance.c @@ -34,6 +34,7 @@ #include #include "BLI_math.h" #include "../TEX_util.h" +#include "TEX_node.h" static bNodeSocketType inputs[]= { { SOCK_VECTOR, 1, "Coordinate 1", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f }, diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c index 52e88cbc2d9..471d8db2c03 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c @@ -32,6 +32,7 @@ #include "../TEX_util.h" +#include "TEX_node.h" static bNodeSocketType inputs[]= { @@ -54,11 +55,11 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2); hsv[0]+= (hue - 0.5f); - if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0; + if(hsv[0]>1.0f) hsv[0]-=1.0f; else if(hsv[0]<0.0f) hsv[0]+= 1.0f; hsv[1]*= sat; - if(hsv[1]>1.0) hsv[1]= 1.0; else if(hsv[1]<0.0) hsv[1]= 0.0; + if(hsv[1]>1.0f) hsv[1]= 1.0f; else if(hsv[1]<0.0f) hsv[1]= 0.0f; hsv[2]*= val; - if(hsv[2]>1.0) hsv[2]= 1.0; else if(hsv[2]<0.0) hsv[2]= 0.0; + if(hsv[2]>1.0f) hsv[2]= 1.0f; else if(hsv[2]<0.0f) hsv[2]= 0.0f; hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2); out[0]= mfac*in[0] + fac*col[0]; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c index 59144d60b6f..fcb18ab3342 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_image.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_image.c @@ -33,6 +33,7 @@ #include "../TEX_util.h" +#include "TEX_node.h" static bNodeSocketType outputs[]= { { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c index bfee670a8ae..e908bdcff07 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_invert.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_invert.c @@ -32,6 +32,7 @@ #include "../TEX_util.h" +#include "TEX_node.h" /* **************** INVERT ******************** */ static bNodeSocketType inputs[]= { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c index a84573f1d09..e00781741a0 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c @@ -32,7 +32,7 @@ #include "../TEX_util.h" - +#include "TEX_node.h" /* **************** SCALAR MATH ******************** */ @@ -116,8 +116,8 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor out[0]= pow(in0, in1); } else { float y_mod_1 = fmod(in1, 1); - if (y_mod_1 > 0.999 || y_mod_1 < 0.001) { - *out = pow(in0, floor(in1 + 0.5)); + if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { + *out = pow(in0, floor(in1 + 0.5f)); } else { *out = 0.0; } diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c index 44cec5d670d..c7668c27b99 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_mixRgb.c @@ -32,6 +32,7 @@ #include "../TEX_util.h" +#include "TEX_node.h" /* **************** MIX RGB ******************** */ static bNodeSocketType inputs[]= { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c index 63a3a7ae15c..046ad724507 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c @@ -32,6 +32,7 @@ #include "../TEX_util.h" +#include "TEX_node.h" /* **************** COMPOSITE ******************** */ static bNodeSocketType inputs[]= { @@ -65,7 +66,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(o tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); target->tin = (target->tr + target->tg + target->tb) / 3.0f; - target->talpha = 1.0f; + target->talpha = 1; if(target->nor) { if(in[1] && in[1]->hasinput) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c index 58de1fd19e5..294c1f7322f 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_proc.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_proc.c @@ -32,6 +32,8 @@ #include "../TEX_util.h" +#include "TEX_node.h" + #include "RE_shader_ext.h" /* diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c index c31fc25bea2..1be6152a2b3 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c @@ -34,6 +34,7 @@ #include #include "../TEX_util.h" +#include "TEX_node.h" static bNodeSocketType inputs[]= { { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, @@ -53,8 +54,8 @@ static void rotate(float new_co[3], float a, float ax[3], float co[3]) float perp[3]; float cp[3]; - float cos_a = cos(a * 2 * M_PI); - float sin_a = sin(a * 2 * M_PI); + float cos_a = cos(a * (float)(2*M_PI)); + float sin_a = sin(a * (float)(2*M_PI)); // x' = xcosa + n(n.x)(1-cosa) + (x*n)sina diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c index 7b8a52d1923..d4d77b5fd5a 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_texture.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_texture.c @@ -32,6 +32,8 @@ #include "../TEX_util.h" +#include "TEX_node.h" + #include "RE_shader_ext.h" static bNodeSocketType inputs[]= { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c index a8fdae69244..8f7d6d837d7 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_translate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_translate.c @@ -33,6 +33,7 @@ #include #include "../TEX_util.h" +#include "TEX_node.h" static bNodeSocketType inputs[]= { { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c index 65b96f16adc..e430c0c9a95 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToNor.c @@ -32,6 +32,7 @@ #include "../TEX_util.h" +#include "TEX_node.h" static bNodeSocketType inputs[]= { { SOCK_VALUE, 1, "Val", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c index 867b6be083e..19fa6c67c09 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c @@ -33,6 +33,7 @@ #include "../TEX_util.h" +#include "TEX_node.h" /* **************** VALTORGB ******************** */ static bNodeSocketType valtorgb_in[]= { diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c index 3deedf16f03..e917e525e17 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_viewer.c @@ -31,7 +31,8 @@ */ -#include "../TEX_util.h" +#include "../TEX_util.h" +#include "TEX_node.h" #include static bNodeSocketType inputs[]= { diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index 885b61fb97e..54fc9e7853d 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -35,4 +35,4 @@ if env['BF_BUILDINFO']: defs.append('BUILD_DATE') sources = env.Glob('intern/*.c') -env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [361,160]) +env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core'], priority = [361]) diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index f4d88b33a48..0ea4e083e3e 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -55,6 +55,27 @@ static Main *bpy_import_main= NULL; +/* 'builtins' is most likely PyEval_GetBuiltins() */ +void bpy_import_init(PyObject *builtins) +{ + PyObject *item; + PyObject *mod; + + PyDict_SetItemString(builtins, "__import__", item=PyCFunction_New(&bpy_import_meth, NULL)); Py_DECREF(item); + + /* move reload here + * XXX, use import hooks */ + mod= PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0); + if(mod) { + PyDict_SetItemString(PyModule_GetDict(mod), "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item); + Py_DECREF(mod); + } + else { + BLI_assert(!"unable to load 'imp' module."); + } +} + + static void free_compiled_text(Text *text) { if(text->compiled) { diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h index 7aabdcf3bf2..0ef31229f8d 100644 --- a/source/blender/python/generic/bpy_internal_import.h +++ b/source/blender/python/generic/bpy_internal_import.h @@ -47,6 +47,8 @@ struct Text; +void bpy_import_init(PyObject *builtins); + PyObject* bpy_text_import(struct Text *text); PyObject* bpy_text_import_name(char *name, int *found); PyObject* bpy_text_reimport(PyObject *module, int *found); diff --git a/source/blender/python/generic/mathutils_Matrix.c b/source/blender/python/generic/mathutils_Matrix.c index 936c761bf90..41d9626db16 100644 --- a/source/blender/python/generic/mathutils_Matrix.c +++ b/source/blender/python/generic/mathutils_Matrix.c @@ -226,8 +226,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) } } - /* clamp angle between -360 and 360 in radians */ - angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2; + angle= angle_wrap_rad(angle); if(matSize != 2 && matSize != 3 && matSize != 4) { PyErr_SetString(PyExc_AttributeError, "mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix"); diff --git a/source/blender/python/generic/mathutils_Quaternion.c b/source/blender/python/generic/mathutils_Quaternion.c index 43d3cbc62b0..be1fa6db035 100644 --- a/source/blender/python/generic/mathutils_Quaternion.c +++ b/source/blender/python/generic/mathutils_Quaternion.c @@ -861,7 +861,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN return -1; } - angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2; + angle= angle_wrap_rad(angle); /* If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations */ if( EXPP_FloatsAreEqual(axis[0], 0.0f, 10) && @@ -955,7 +955,7 @@ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kw case 2: if (mathutils_array_parse(quat, 3, 3, seq, "mathutils.Quaternion()") == -1) return NULL; - angle= fmod(angle + M_PI*2, M_PI*4) - M_PI*2; /* clamp because of precision issues */ + angle= angle_wrap_rad(angle); /* clamp because of precision issues */ axis_angle_to_quat(quat, quat, angle); break; /* PyArg_ParseTuple assures no more then 2 */ diff --git a/source/blender/python/generic/mathutils_Vector.c b/source/blender/python/generic/mathutils_Vector.c index f1e417b154e..912d1310967 100644 --- a/source/blender/python/generic/mathutils_Vector.c +++ b/source/blender/python/generic/mathutils_Vector.c @@ -552,7 +552,7 @@ static PyObject *Vector_dot(VectorObject *self, PyObject *value) return NULL; for(x = 0; x < self->size; x++) { - dot += self->vec[x] * tvec[x]; + dot += (double)(self->vec[x] * tvec[x]); } return PyFloat_FromDouble(dot); @@ -591,8 +591,8 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) return NULL; for(x = 0; x < size; x++) { - test_v1 += self->vec[x] * self->vec[x]; - test_v2 += tvec[x] * tvec[x]; + test_v1 += (double)(self->vec[x] * self->vec[x]); + test_v2 += (double)(tvec[x] * tvec[x]); } if (!test_v1 || !test_v2){ /* avoid exception */ @@ -608,7 +608,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args) //dot product for(x = 0; x < self->size; x++) { - dot += self->vec[x] * tvec[x]; + dot += (double)(self->vec[x] * tvec[x]); } dot /= (sqrt(test_v1) * sqrt(test_v2)); @@ -679,13 +679,13 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value) //get dot products for(x = 0; x < size; x++) { - dot += self->vec[x] * tvec[x]; - dot2 += tvec[x] * tvec[x]; + dot += (double)(self->vec[x] * tvec[x]); + dot2 += (double)(tvec[x] * tvec[x]); } //projection dot /= dot2; for(x = 0; x < size; x++) { - vec[x] = (float)(dot * tvec[x]); + vec[x] = (float)dot * tvec[x]; } return newVectorObject(vec, size, Py_NEW, Py_TYPE(self)); } @@ -1034,7 +1034,7 @@ static int column_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject for(x = 0; x < mat->col_size; x++) { for(y = 0; y < mat->row_size; y++) { - dot += mat->matrix[y][x] * vec_cpy[y]; + dot += (double)(mat->matrix[y][x] * vec_cpy[y]); } rvec[z++] = (float)dot; dot = 0.0f; @@ -1079,7 +1079,7 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2) /*dot product*/ for(i = 0; i < vec1->size; i++) { - dot += vec1->vec[i] * vec2->vec[i]; + dot += (double)(vec1->vec[i] * vec2->vec[i]); } return PyFloat_FromDouble(dot); } @@ -1257,7 +1257,7 @@ static double vec_magnitude_nosqrt(float *data, int size) int i; for(i=0; isize; i++){ - dot += (self->vec[i] * self->vec[i]); + dot += (double)(self->vec[i] * self->vec[i]); } return PyFloat_FromDouble(sqrt(dot)); } @@ -1517,17 +1517,17 @@ static int Vector_setLength(VectorObject *self, PyObject *value) return -1; } - if (param < 0.0f) { + if (param < 0.0) { PyErr_SetString(PyExc_TypeError, "cannot set a vectors length to a negative value"); return -1; } - if (param == 0.0f) { + if (param == 0.0) { fill_vn(self->vec, self->size, 0.0f); return 0; } for(i = 0; i < self->size; i++){ - dot += (self->vec[i] * self->vec[i]); + dot += (double)(self->vec[i] * self->vec[i]); } if (!dot) /* cant sqrt zero */ diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index d59d87c14b9..99b20167dba 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -59,6 +59,8 @@ static PyTypeObject BlenderAppType; static PyStructSequence_Field app_info_fields[]= { {(char *)"version", (char *)"The Blender version as a tuple of 3 numbers. eg. (2, 50, 11)"}, {(char *)"version_string", (char *)"The Blender version formatted as a string"}, + {(char *)"version_char", (char *)"The Blender version character (for minor releases)"}, + {(char *)"version_cycle", (char *)"The release status of this build alpha/beta/rc/release"}, {(char *)"binary_path", (char *)"The location of blenders executable, useful for utilities that spawn new instances"}, {(char *)"background", (char *)"Boolean, True when blender is running without a user interface (started with -b)"}, @@ -103,6 +105,8 @@ static PyObject *make_app_info(void) SetObjItem(Py_BuildValue("(iii)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION)); SetObjItem(PyUnicode_FromFormat("%d.%02d (sub %d)", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION)); + SetStrItem(STRINGIFY(BLENDER_VERSION_CHAR)); + SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE)); SetStrItem(bprogname); SetObjItem(PyBool_FromLong(G.background)); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 8833079d742..80c4a6cf2f6 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -170,9 +170,13 @@ static void bpy_python_start_path(void) { char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL); - if(py_path_bundle==NULL) + if(py_path_bundle==NULL) { + /* Common enough to have bundled *nix python but complain on OSX/Win */ +#if defined(__APPLE__) || defined(_WIN32) + fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n"); +#endif return; - + } /* set the environment path */ printf("found bundled python: %s\n", py_path_bundle); @@ -272,27 +276,7 @@ void BPY_python_start(int argc, const char **argv) /* bpy.* and lets us import it */ BPy_init_modules(); - { /* our own import and reload functions */ - PyObject *item; - PyObject *mod; - //PyObject *m= PyImport_AddModule("__builtin__"); - //PyObject *d= PyModule_GetDict(m); - PyObject *d= PyEval_GetBuiltins(); -// PyDict_SetItemString(d, "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item); - PyDict_SetItemString(d, "__import__", item=PyCFunction_New(&bpy_import_meth, NULL)); Py_DECREF(item); - - /* move reload here - * XXX, use import hooks */ - mod= PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0); - if(mod) { - PyDict_SetItemString(PyModule_GetDict(mod), "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item); - Py_DECREF(mod); - } - else { - BLI_assert(!"unable to load 'imp' module."); - } - - } + bpy_import_init(PyEval_GetBuiltins()); pyrna_alloc_types(); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ecf66ca4700..add088d181a 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -225,18 +225,18 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash) BLI_ghashIterator_init(&weakinfo_hash_iter, weakinfo_hash); - #ifdef DEBUG_RNA_WEAKREF +#ifdef DEBUG_RNA_WEAKREF fprintf(stdout, "id_release_weakref: '%s', %d items\n", id->name, BLI_ghash_size(weakinfo_hash)); - #endif +#endif while (!BLI_ghashIterator_isDone(&weakinfo_hash_iter)) { PyObject *weakref= (PyObject *)BLI_ghashIterator_getKey(&weakinfo_hash_iter); PyObject *item= PyWeakref_GET_OBJECT(weakref); if(item != Py_None) { - #ifdef DEBUG_RNA_WEAKREF +#ifdef DEBUG_RNA_WEAKREF PyC_ObSpit("id_release_weakref item ", item); - #endif +#endif pyrna_invalidate((BPy_DummyPointerRNA *)item); } @@ -252,9 +252,9 @@ static void id_release_weakref_list(struct ID *id, GHash *weakinfo_hash) if(BLI_ghash_size(id_weakref_pool) == 0) { BLI_ghash_free(id_weakref_pool, NULL, NULL); id_weakref_pool= NULL; - #ifdef DEBUG_RNA_WEAKREF +#ifdef DEBUG_RNA_WEAKREF printf("id_release_weakref freeing pool\n"); - #endif +#endif } } @@ -275,11 +275,13 @@ void BPY_id_release(struct ID *id) #endif #ifdef USE_PYRNA_INVALIDATE_WEAKREF - PyGILState_STATE gilstate= PyGILState_Ensure(); + if(id_weakref_pool) { + PyGILState_STATE gilstate= PyGILState_Ensure(); - id_release_weakref(id); + id_release_weakref(id); - PyGILState_Release(gilstate); + PyGILState_Release(gilstate); + } #endif /* USE_PYRNA_INVALIDATE_WEAKREF */ (void)id; @@ -640,6 +642,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) } break; case PROP_COLOR: + case PROP_COLOR_GAMMA: if(len==3) { /* color */ if(is_thick) { ret= newColorObject(NULL, Py_NEW, NULL); // TODO, get order from RNA @@ -6186,22 +6189,6 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class return NULL; } - /* call classed register function () */ - py_cls_meth= PyObject_GetAttrString(py_class, "register"); - if(py_cls_meth == NULL) { - PyErr_Clear(); - } - else { - PyObject *ret= PyObject_CallObject(py_cls_meth, NULL); - if(ret) { - Py_DECREF(ret); - } - else { - return NULL; - } - } - - /* get the context, so register callback can do necessary refreshes */ C= BPy_GetContext(); @@ -6235,6 +6222,21 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class if(pyrna_deferred_register_class(srna_new, py_class)!=0) return NULL; + /* call classed register method () */ + py_cls_meth= PyObject_GetAttrString(py_class, "register"); + if(py_cls_meth == NULL) { + PyErr_Clear(); + } + else { + PyObject *ret= PyObject_CallObject(py_cls_meth, NULL); + if(ret) { + Py_DECREF(ret); + } + else { + return NULL; + } + } + Py_RETURN_NONE; } @@ -6296,7 +6298,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla return NULL; } - /* call classed register function */ + /* call classed unregister method */ py_cls_meth= PyObject_GetAttrString(py_class, "unregister"); if(py_cls_meth == NULL) { PyErr_Clear(); diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 8705efb055a..ba19f155842 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -64,6 +64,7 @@ #endif /* --- end bpy build options --- */ +struct ID; extern PyTypeObject pyrna_struct_meta_idprop_Type; extern PyTypeObject pyrna_struct_Type; @@ -192,4 +193,6 @@ void BPY_modules_update(struct bContext *C); //XXX temp solution extern PyMethodDef meth_bpy_register_class; extern PyMethodDef meth_bpy_unregister_class; +void BPY_id_release(struct ID *id); + #endif diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index 284eac19fdd..b7f638b6441 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -46,6 +46,7 @@ #include "bpy_rna.h" #include "bpy_util.h" +#include "bpy_rna_anim.h" #define TRUE 1 #define FALSE 0 diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index 2aa8c37e9a4..a63c4f7f253 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -37,15 +37,15 @@ #ifndef TEXTURE_EXT_H #define TEXTURE_EXT_H -#define BRICONT texres->tin= (texres->tin-0.5)*tex->contrast+tex->bright-0.5; \ -if(texres->tin<0.0) texres->tin= 0.0; else if(texres->tin>1.0) texres->tin= 1.0; +#define BRICONT texres->tin= (texres->tin-0.5f)*tex->contrast+tex->bright-0.5f; \ +if(texres->tin<0.0f) texres->tin= 0.0f; else if(texres->tin>1.0f) texres->tin= 1.0f; -#define BRICONTRGB texres->tr= tex->rfac*((texres->tr-0.5)*tex->contrast+tex->bright-0.5); \ -if(texres->tr<0.0) texres->tr= 0.0; \ -texres->tg= tex->gfac*((texres->tg-0.5)*tex->contrast+tex->bright-0.5); \ -if(texres->tg<0.0) texres->tg= 0.0; \ -texres->tb= tex->bfac*((texres->tb-0.5)*tex->contrast+tex->bright-0.5); \ -if(texres->tb<0.0) texres->tb= 0.0; \ +#define BRICONTRGB texres->tr= tex->rfac*((texres->tr-0.5f)*tex->contrast+tex->bright-0.5f); \ +if(texres->tr<0.0f) texres->tr= 0.0f; \ +texres->tg= tex->gfac*((texres->tg-0.5f)*tex->contrast+tex->bright-0.5f); \ +if(texres->tg<0.0f) texres->tg= 0.0f; \ +texres->tb= tex->bfac*((texres->tb-0.5f)*tex->contrast+tex->bright-0.5f); \ +if(texres->tb<0.0f) texres->tb= 0.0f; \ if(tex->saturation != 1.0f) { \ float _hsv[3]; \ rgb_to_hsv(texres->tr, texres->tg, texres->tb, _hsv, _hsv+1, _hsv+2); \ @@ -53,7 +53,7 @@ if(tex->saturation != 1.0f) { \ hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2], &texres->tr, &texres->tg, &texres->tb); \ } \ -#define RGBTOBW(r,g,b) ( r*0.35 + g*0.45 + b*0.2 ) /* keep this in sync with gpu_shader_material.glsl:rgbtobw */ +#define RGBTOBW(r,g,b) ( r*0.35f + g*0.45f + b*0.2f ) /* keep this in sync with gpu_shader_material.glsl:rgbtobw */ struct HaloRen; struct ShadeInput; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index f51ed550813..62f47dcd3b5 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -3195,12 +3195,14 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) int end, do_autosmooth=0, totvert = 0; int use_original_normals= 0; int recalc_normals = 0; // false by default + int negative_scale; me= ob->data; mul_m4_m4m4(mat, ob->obmat, re->viewmat); invert_m4_m4(ob->imat, mat); copy_m3_m4(imat, ob->imat); + negative_scale= is_negative_m4(mat); if(me->totvert==0) return; @@ -3282,13 +3284,13 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, mvert->co); if(do_autosmooth==0) { /* autosmooth on original unrotated data to prevent differences between frames */ - ver->n[0]=mvert->no[0]; - ver->n[1]=mvert->no[1]; - ver->n[2]=mvert->no[2]; + normal_short_to_float_v3(ver->n, mvert->no); mul_m4_v3(mat, ver->co); mul_transposed_m3_v3(imat, ver->n); normalize_v3(ver->n); - negate_v3(ver->n); + + if(!negative_scale) + negate_v3(ver->n); } if(orco) { @@ -4634,7 +4636,10 @@ void RE_Database_Free(Render *re) re->totvlak=re->totvert=re->totstrand=re->totlamp=re->tothalo= 0; re->i.convertdone= 0; - + + re->backbuf= NULL; + re->bakebuf= NULL; + if(re->scene) if(re->scene->r.scemode & R_FREE_IMAGE) if((re->r.scemode & R_PREVIEWBUTS)==0) diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index c4065b30cb0..1e40ab886ae 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -730,6 +730,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe TexResult texr1, texr2; texr1.nor= texr2.nor= NULL; + texr1.talpha= texr2.talpha= texres->talpha; /* boxclip expects this initialized */ add_v3_v3(vec, dxt); face1= envcube_isect(env, vec, sco); diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 36577cb171a..264c82e4f47 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -158,9 +158,9 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, TexResult *texre if((xs+ys) & 1) return retval; } /* scale around center, (0.5, 0.5) */ - if(tex->checkerdist<1.0) { - fx= (fx-0.5)/(1.0-tex->checkerdist) +0.5; - fy= (fy-0.5)/(1.0-tex->checkerdist) +0.5; + if(tex->checkerdist<1.0f) { + fx= (fx-0.5f)/(1.0f-tex->checkerdist) +0.5f; + fy= (fy-0.5f)/(1.0f-tex->checkerdist) +0.5f; } } @@ -168,7 +168,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, TexResult *texre y = (int)floorf(fy*ibuf->y); if(tex->extend == TEX_CLIPCUBE) { - if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y || texvec[2]<-1.0 || texvec[2]>1.0) { + if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y || texvec[2]<-1.0f || texvec[2]>1.0f) { return retval; } } @@ -400,7 +400,7 @@ static float clipx_rctf(rctf *rf, float x1, float x2) rf->xmin = rf->xmax; return 0.0; } - else if(size!=0.0) { + else if(size!=0.0f) { return (rf->xmax - rf->xmin)/size; } return 1.0; @@ -423,7 +423,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2) rf->ymin = rf->ymax; return 0.0; } - else if(size!=0.0) { + else if(size!=0.0f) { return (rf->ymax - rf->ymin)/size; } return 1.0; @@ -482,12 +482,12 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) ibuf_get_color(col, ibuf, x, y); - if(mulx==1.0) { + if(mulx==1.0f) { texres->ta+= col[3]; texres->tr+= col[0]; texres->tg+= col[1]; texres->tb+= col[2]; - div+= 1.0; + div+= 1.0f; } else { texres->ta+= mulx*col[3]; @@ -500,7 +500,7 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) } } - if(div!=0.0) { + if(div!=0.0f) { div= 1.0f/div; texres->tb*= div; texres->tg*= div; @@ -521,6 +521,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max * clipped-away parts are sampled as well. */ /* note: actually minx etc isnt in the proper range... this due to filter size and offset vectors for bump */ + /* note: talpha must be initialized */ TexResult texr; rctf *rf, stack[8]; float opp, tot, alphaclip= 1.0; @@ -543,7 +544,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max else { alphaclip= clipx_rctf(rf, 0.0, (float)(ibuf->x)); - if(alphaclip<=0.0) { + if(alphaclip<=0.0f) { texres->tr= texres->tb= texres->tg= texres->ta= 0.0; return; } @@ -558,7 +559,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max else { alphaclip*= clipy_rctf(rf, 0.0, (float)(ibuf->y)); - if(alphaclip<=0.0) { + if(alphaclip<=0.0f) { texres->tr= texres->tb= texres->tg= texres->ta= 0.0; return; } @@ -578,7 +579,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max if(texres->talpha) texres->ta+= opp*texr.ta; rf++; } - if(tot!= 0.0) { + if(tot!= 0.0f) { texres->tr/= tot; texres->tg/= tot; texres->tb/= tot; @@ -590,7 +591,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max if(texres->talpha==0) texres->ta= 1.0; - if(alphaclip!=1.0) { + if(alphaclip!=1.0f) { /* premul it all */ texres->tr*= alphaclip; texres->tg*= alphaclip; @@ -963,7 +964,7 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl alphaclip*= clipy_rctf(&rf, 0.0, (float)(ibuf->y)); alphaclip= MAX2(alphaclip, 0.0f); - if(alphaclip!=1.0) { + if(alphaclip!=1.0f) { /* premul it all */ texres->tr*= alphaclip; texres->tg*= alphaclip; @@ -1099,8 +1100,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, } // side faces of unit-cube - minx = (minx > 0.25f) ? 0.25f : ((minx < 1e-5f) ? 1e-5 : minx); - miny = (miny > 0.25f) ? 0.25f : ((miny < 1e-5f) ? 1e-5 : miny); + minx = (minx > 0.25f) ? 0.25f : ((minx < 1e-5f) ? 1e-5f : minx); + miny = (miny > 0.25f) ? 0.25f : ((miny < 1e-5f) ? 1e-5f : miny); // repeat and clip @@ -1485,9 +1486,9 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *DXT, f if(tex->imaflag & TEX_IMAROT) SWAP(float, minx, miny); - if(minx>0.25) minx= 0.25; + if(minx>0.25f) minx= 0.25f; else if(minx<0.00001f) minx= 0.00001f; /* side faces of unit-cube */ - if(miny>0.25) miny= 0.25; + if(miny>0.25f) miny= 0.25f; else if(miny<0.00001f) miny= 0.00001f; @@ -1551,41 +1552,41 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *DXT, f } /* scale around center, (0.5, 0.5) */ - if(tex->checkerdist<1.0) { - fx= (fx-0.5)/(1.0-tex->checkerdist) +0.5; - fy= (fy-0.5)/(1.0-tex->checkerdist) +0.5; - minx/= (1.0-tex->checkerdist); - miny/= (1.0-tex->checkerdist); + if(tex->checkerdist<1.0f) { + fx= (fx-0.5f)/(1.0f-tex->checkerdist) +0.5f; + fy= (fy-0.5f)/(1.0f-tex->checkerdist) +0.5f; + minx/= (1.0f-tex->checkerdist); + miny/= (1.0f-tex->checkerdist); } } if(tex->extend == TEX_CLIPCUBE) { - if(fx+minx<0.0 || fy+miny<0.0 || fx-minx>1.0 || fy-miny>1.0 || texvec[2]<-1.0 || texvec[2]>1.0) { + if(fx+minx<0.0f || fy+miny<0.0f || fx-minx>1.0f || fy-miny>1.0f || texvec[2]<-1.0f || texvec[2]>1.0f) { return retval; } } else if(tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) { - if(fx+minx<0.0 || fy+miny<0.0 || fx-minx>1.0 || fy-miny>1.0) { + if(fx+minx<0.0f || fy+miny<0.0f || fx-minx>1.0f || fy-miny>1.0f) { return retval; } } else { if(imapextend) { - if(fx>1.0) fx = 1.0; - else if(fx<0.0) fx= 0.0; + if(fx>1.0f) fx = 1.0f; + else if(fx<0.0f) fx= 0.0f; } else { - if(fx>1.0) fx -= (int)(fx); - else if(fx<0.0) fx+= 1-(int)(fx); + if(fx>1.0f) fx -= (int)(fx); + else if(fx<0.0f) fx+= 1-(int)(fx); } if(imapextend) { - if(fy>1.0) fy = 1.0; - else if(fy<0.0) fy= 0.0; + if(fy>1.0f) fy = 1.0f; + else if(fy<0.0f) fy= 0.0f; } else { - if(fy>1.0) fy -= (int)(fy); - else if(fy<0.0) fy+= 1-(int)(fy); + if(fy>1.0f) fy -= (int)(fy); + else if(fy<0.0f) fy+= 1-(int)(fy); } } @@ -1602,7 +1603,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *DXT, f dx= minx; dy= miny; maxd= MAX2(dx, dy); - if(maxd>0.5) maxd= 0.5; + if(maxd>0.5f) maxd= 0.5f; pixsize = 1.0f/ (float) MIN2(ibuf->x, ibuf->y); @@ -1693,7 +1694,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *DXT, f fx= 2.0f*(pixsize-maxd)/pixsize; - if(fx>=1.0) { + if(fx>=1.0f) { texres->ta= texr.ta; texres->tb= texr.tb; texres->tg= texr.tg; texres->tr= texr.tr; } else { @@ -1779,7 +1780,8 @@ void image_sample(Image *ima, float fx, float fy, float dx, float dy, float *res if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) ibuf->rect+= (ibuf->x*ibuf->y); - + + texres.talpha= 1; /* boxsample expects to be initialized */ boxsample(ibuf, fx, fy, fx+dx, fy+dy, &texres, 0, 1); result[0]= texres.tr; result[1]= texres.tg; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index 8f070421890..0aa65479a4f 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -194,6 +194,7 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { negate_v3(shi->vn); negate_v3(shi->vno); + negate_v3(shi->nmapnorm); } /* init material vars */ diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index b30e4241c06..6d19846d80a 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1543,6 +1543,7 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { negate_v3(shi->vn); negate_v3(shi->vno); + negate_v3(shi->nmapnorm); } /* if nodetree, use the material that we are currently preprocessing diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 8dcd3fa34d1..09ea924c0d2 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -469,7 +469,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int pop WM_event_remove_timer(wm, NULL, wm_reports->reporttimer); /* Records time since last report was added */ - wm_reports->reporttimer= WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.05); + wm_reports->reporttimer= WM_event_add_timer(wm, CTX_wm_window(C), TIMERREPORT, 0.05); rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo"); wm_reports->reporttimer->customdata = rti; @@ -1721,7 +1721,7 @@ void wm_event_do_handlers(bContext *C) } if(playing == 0) { - int ncfra = sound_sync_scene(scene) * FPS + 0.5; + int ncfra = sound_sync_scene(scene) * (float)FPS + 0.5f; if(ncfra != scene->r.cfra) { scene->r.cfra = ncfra; ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1); diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index eddd7ae1642..de4afa79448 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -134,7 +134,7 @@ int wm_gesture_evaluate(wmGesture *gesture) int dx= rect->xmax - rect->xmin; int dy= rect->ymax - rect->ymin; if(ABS(dx)+ABS(dy) > TWEAK_THRESHOLD) { - int theta= (int)floor(4.0f*atan2((float)dy, (float)dx)/M_PI + 0.5); + int theta= (int)floor(4.0f*atan2f((float)dy, (float)dx)/(float)M_PI + 0.5f); int val= EVT_GESTURE_W; if(theta==0) val= EVT_GESTURE_E; diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index fcdcb802820..0d88f8ea1a6 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -458,7 +458,7 @@ void WM_exit(bContext *C) GHOST_DisposeSystemPaths(); if(MEM_get_memory_blocks_in_use()!=0) { - printf("Error Totblock: %d\n", MEM_get_memory_blocks_in_use()); + printf("Error: Not freed memory blocks: %d\n", MEM_get_memory_blocks_in_use()); MEM_printmemlist(); } wm_autosave_delete(); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a1cfe4a0390..8f10b164f8f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1041,8 +1041,13 @@ int WM_operator_ui_popup(bContext *C, wmOperator *op, int width, int height) int WM_operator_redo_popup(bContext *C, wmOperator *op) { + /* CTX_wm_reports(C) because operator is on stack, not active in event system */ if((op->type->flag & OPTYPE_REGISTER)==0) { - BKE_reportf(op->reports, RPT_ERROR, "Operator '%s' does not have register enabled, incorrect invoke function.", op->type->idname); + BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s' does not have register enabled, incorrect invoke function.", op->type->idname); + return OPERATOR_CANCELLED; + } + if(op->type->poll && op->type->poll(C)==0) { + BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Operator redo '%s': wrong context.", op->type->idname); return OPERATOR_CANCELLED; } @@ -2761,11 +2766,11 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) else if(mode == WM_RADIALCONTROL_STRENGTH) { new_value = 1 - dist / WM_RADIAL_CONTROL_DISPLAY_SIZE; } else if(mode == WM_RADIALCONTROL_ANGLE) - new_value = ((int)(atan2(delta[1], delta[0]) * (180.0 / M_PI)) + 180); + new_value = ((int)(atan2f(delta[1], delta[0]) * (float)(180.0 / M_PI)) + 180); if(event->ctrl) { if(mode == WM_RADIALCONTROL_STRENGTH) - new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f; + new_value = ((int)ceilf(new_value * 10.f) * 10.0f) / 100.f; else new_value = ((int)new_value + 5) / 10*10; } diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 39545a0ad01..ee080e7c0aa 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -86,8 +86,14 @@ #define TIMER0 0x0111 /* timer event, slot for internal use */ #define TIMER1 0x0112 /* timer event, slot for internal use */ #define TIMER2 0x0113 /* timer event, slot for internal use */ -#define TIMERJOBS 0x0114 /* timer event, internal use */ -#define TIMERAUTOSAVE 0x0115 /* timer event, internal use */ +#define TIMERJOBS 0x0114 /* timer event, jobs system */ +#define TIMERAUTOSAVE 0x0115 /* timer event, autosave */ +#define TIMERREPORT 0x0116 /* timer event, reports */ +#define TIMERF 0x011F /* last timer */ + +/* test whether the event is timer event */ +#define ISTIMER(event) (event >= TIMER && event <= TIMERF) + /* standard keyboard */ #define AKEY 'a' @@ -231,9 +237,6 @@ /* test whether the event is a mouse button */ #define ISMOUSE(event) (event >= LEFTMOUSE && event <= MOUSEROTATE) - /* test whether the event is timer event */ -#define ISTIMER(event) (event >= TIMER && event <= TIMERAUTOSAVE) - /* test whether the event is tweak event */ #define ISTWEAK(event) (event >= EVT_TWEAK_L && event <= EVT_GESTURE) diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index beda933a91d..a4d3e1b13fc 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -99,7 +99,6 @@ if(UNIX) extern_bullet bf_intern_guardedalloc bf_intern_memutil - bf_python bf_python_ext bf_blenlib bf_imbuf_cineon diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 4ad8d588ae4..728557bc99b 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -92,9 +92,16 @@ struct wmEvent; struct wmKeyConfig; struct wmKeyMap; struct wmOperator; +struct wmWindow; struct wmWindowManager; struct View3D; struct ToolSettings; +struct bContextDataResult; +struct bConstraintTarget; +struct bPythonConstraint; +struct bConstraintOb; +struct Context; +struct ChannelDriver; /*new render funcs */ @@ -160,7 +167,9 @@ int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, struct wmEv void WM_event_add_notifier(const struct bContext *C, unsigned int type, void *reference){} void WM_main_add_notifier(unsigned int type, void *reference){} void ED_armature_bone_rename(struct bArmature *arm, char *oldnamep, char *newnamep){} -struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op){return (struct wmEventHandler *)NULL;}; +struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op){return (struct wmEventHandler *)NULL;} +struct wmTimer *WM_event_add_timer(struct wmWindowManager *wm, struct wmWindow *win, int event_type, double timestep){return (struct wmTimer *)NULL;} +void WM_event_remove_timer(struct wmWindowManager *wm, struct wmWindow *win, struct wmTimer *timer){} void ED_armature_edit_bone_remove(struct bArmature *arm, struct EditBone *exBone){} void object_test_constraints (struct Object *owner){} void ED_object_parent(struct Object *ob, struct Object *par, int type, const char *substr){} @@ -400,6 +409,19 @@ float sculpt_get_brush_alpha(struct Brush *brush){return 0.0f;} void sculpt_set_brush_alpha(struct Brush *brush, float alpha){} void ED_sculpt_modifiers_changed(struct Object *ob){}; + +/* bpy/python internal api */ +void operator_wrapper(struct wmOperatorType *ot, void *userdata) {} +void BPY_text_free_code(struct Text *text) {} +void BPY_id_release(struct Text *text) {} +int BPY_context_member_get(struct Context *C, const char *member, struct bContextDataResult *result) { return 0; } +void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct) {} +float BPY_driver_exec(struct ChannelDriver *driver) {return 0.0f;} /* might need this one! */ +void BPY_DECREF(void *pyob_ptr) {} +void BPY_pyconstraint_exec(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets) {} +void macro_wrapper(struct wmOperatorType *ot, void *userdata) {} ; + + char blender_path[] = ""; #endif // WITH_GAMEENGINE diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 3beeac5e3d8..d6effdd27f4 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -102,6 +102,17 @@ set(SRC ) if(WIN32 AND NOT UNIX) + string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1) + string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2) + string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3) + add_definitions( + -DBLEN_VER_RC_STR_M=${BLENDER_VERSION} + -DBLEN_VER_RC_1=${bver1} + -DBLEN_VER_RC_2=${bver2} + -DBLEN_VER_RC_3=${bver3} + -DBLEN_VER_RC_4=0 + ) + list(APPEND SRC ../icons/winblender.rc ) @@ -538,6 +549,20 @@ elseif(WIN32) endif() endif() + if(NOT CMAKE_CL_64) + install( + FILES + ${LIBDIR}/thumbhandler/lib/BlendThumb.dll + DESTINATION ${TARGETDIR}/ + ) + else() + install( + FILES + ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll + DESTINATION ${TARGETDIR}/ + ) + endif() + elseif(APPLE) set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist) diff --git a/source/creator/creator.c b/source/creator/creator.c index 1d3ddc84f00..0bc51784c26 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -289,6 +289,7 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) #ifdef WIN32 BLI_argsPrintArgDoc(ba, "-R"); + BLI_argsPrintArgDoc(ba, "-r"); #endif BLI_argsPrintArgDoc(ba, "--version"); @@ -488,12 +489,12 @@ static int without_borders(int UNUSED(argc), const char **UNUSED(argv), void *UN static int register_extension(int UNUSED(argc), const char **UNUSED(argv), void *data) { #ifdef WIN32 - char *path = BLI_argsArgv(data)[0]; - RegisterBlendExtension(path); + if (data) + G.background = 1; + RegisterBlendExtension(); #else (void)data; /* unused */ #endif - return 0; } @@ -1096,7 +1097,8 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 2, "-p", "--window-geometry", " \n\tOpen with lower left corner at , and width and height as , ", prefsize, NULL); BLI_argsAdd(ba, 2, "-w", "--window-border", "\n\tForce opening with borders (default)", with_borders, NULL); BLI_argsAdd(ba, 2, "-W", "--window-borderless", "\n\tForce opening without borders", without_borders, NULL); - BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension (windows only)", register_extension, ba); + BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension, then exit (Windows only)", register_extension, NULL); + BLI_argsAdd(ba, 2, "-r", NULL, "\n\tSilently register .blend extension, then exit (Windows only)", register_extension, ba); /* third pass: disabling things and forcing settings */ BLI_argsAddCase(ba, 3, "-nojoystick", 1, NULL, 0, "\n\tDisable joystick support", no_joystick, syshandle); diff --git a/source/gameengine/Converter/BL_ArmatureChannel.cpp b/source/gameengine/Converter/BL_ArmatureChannel.cpp index 626d8a19deb..df3a575850b 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.cpp +++ b/source/gameengine/Converter/BL_ArmatureChannel.cpp @@ -37,6 +37,7 @@ #include "BL_ArmatureConstraint.h" #include "BLI_math.h" #include "BLI_string.h" +#include #ifdef WITH_PYTHON diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 7d06cc64ee9..157124ebc81 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -45,6 +45,7 @@ #include "STR_String.h" #include "MT_Vector3.h" #include "SG_QList.h" +#include /*------------------------------ * Python defines diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index b32114722d4..6aee6bd19e7 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -38,6 +38,7 @@ #include "PyObjectPlus.h" #include +#include #include diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 4226399f192..946d2b3c39c 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1637,176 +1637,6 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack return m; } -// Python Sandbox code -// override builtin functions import() and open() - - -PyObject *KXpy_open(PyObject *self, PyObject *args) { - PyErr_SetString(PyExc_RuntimeError, "Sandbox: open() function disabled!\nGame Scripts should not use this function."); - return NULL; -} - -PyObject *KXpy_file(PyObject *self, PyObject *args) { - PyErr_SetString(PyExc_RuntimeError, "Sandbox: file() function disabled!\nGame Scripts should not use this function."); - return NULL; -} - -PyObject *KXpy_execfile(PyObject *self, PyObject *args) { - PyErr_SetString(PyExc_RuntimeError, "Sandbox: execfile() function disabled!\nGame Scripts should not use this function."); - return NULL; -} - -PyObject *KXpy_compile(PyObject *self, PyObject *args) { - PyErr_SetString(PyExc_RuntimeError, "Sandbox: compile() function disabled!\nGame Scripts should not use this function."); - return NULL; -} - -PyObject *KXpy_import(PyObject *self, PyObject *args) -{ - char *name; - int found; - PyObject *globals = NULL; - PyObject *locals = NULL; - PyObject *fromlist = NULL; - PyObject *l, *m, *n; - int level; /* not used yet */ - - if (!PyArg_ParseTuple(args, "s|OOOi:m_import", - &name, &globals, &locals, &fromlist, &level)) - return NULL; - - /* check for builtin modules */ - m = PyImport_AddModule("sys"); - l = PyObject_GetAttrString(m, "builtin_module_names"); - n = PyUnicode_FromString(name); - - if (PySequence_Contains(l, n)) { - return PyImport_ImportModuleEx(name, globals, locals, fromlist); - } - - /* quick hack for GamePython modules - TODO: register builtin modules properly by ExtendInittab */ - if (!strcmp(name, "GameLogic") || !strcmp(name, "GameKeys") || !strcmp(name, "PhysicsConstraints") || - !strcmp(name, "Rasterizer") || !strcmp(name, "mathutils") || !strcmp(name, "bgl") || !strcmp(name, "geometry")) { - return PyImport_ImportModuleEx(name, globals, locals, fromlist); - } - - /* Import blender texts as python modules */ - m= bpy_text_import_name(name, &found); - if (m) - return m; - - if(found==0) /* if its found but could not import then it has its own error */ - PyErr_Format(PyExc_ImportError, "Import of external Module %.20s not allowed.", name); - - return NULL; - -} - -PyObject *KXpy_reload(PyObject *self, PyObject *args) { - - /* Used to be sandboxed, bettet to allow importing of internal text only */ -#if 0 - PyErr_SetString(PyExc_RuntimeError, "Sandbox: reload() function disabled!\nGame Scripts should not use this function."); - return NULL; -#endif - int found; - PyObject *module = NULL; - PyObject *newmodule = NULL; - - /* check for a module arg */ - if( !PyArg_ParseTuple( args, "O:bpy_reload_meth", &module ) ) - return NULL; - - newmodule= bpy_text_reimport( module, &found ); - if (newmodule) - return newmodule; - - if (found==0) /* if its found but could not import then it has its own error */ - PyErr_SetString(PyExc_ImportError, "reload(module): failed to reload from blenders internal text"); - - return newmodule; -} - -/* override python file type functions */ -#if 0 -static int -file_init(PyObject *self, PyObject *args, PyObject *kwds) -{ - KXpy_file(NULL, NULL); - return -1; -} - -static PyObject * -file_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - return KXpy_file(NULL, NULL); -} -#endif - -static PyMethodDef meth_open[] = {{ "open", KXpy_open, METH_VARARGS, "(disabled)"}}; -static PyMethodDef meth_reload[] = {{ "reload", KXpy_reload, METH_VARARGS, "(disabled)"}}; -static PyMethodDef meth_file[] = {{ "file", KXpy_file, METH_VARARGS, "(disabled)"}}; -static PyMethodDef meth_execfile[] = {{ "execfile", KXpy_execfile, METH_VARARGS, "(disabled)"}}; -static PyMethodDef meth_compile[] = {{ "compile", KXpy_compile, METH_VARARGS, "(disabled)"}}; - -static PyMethodDef meth_import[] = {{ "import", KXpy_import, METH_VARARGS, "our own import"}}; - -//static PyObject *g_oldopen = 0; -//static PyObject *g_oldimport = 0; -//static int g_security = 0; - -static void setSandbox(TPythonSecurityLevel level) -{ - PyObject *m = PyImport_AddModule("__builtin__"); - PyObject *d = PyModule_GetDict(m); - PyObject *item; - switch (level) { - case psl_Highest: - //if (!g_security) { - //g_oldopen = PyDict_GetItemString(d, "open"); - - // functions we cant trust - PyDict_SetItemString(d, "open", item=PyCFunction_New(meth_open, NULL)); Py_DECREF(item); - PyDict_SetItemString(d, "reload", item=PyCFunction_New(meth_reload, NULL)); Py_DECREF(item); - PyDict_SetItemString(d, "file", item=PyCFunction_New(meth_file, NULL)); Py_DECREF(item); - PyDict_SetItemString(d, "execfile", item=PyCFunction_New(meth_execfile, NULL)); Py_DECREF(item); - PyDict_SetItemString(d, "compile", item=PyCFunction_New(meth_compile, NULL)); Py_DECREF(item); - - // our own import - PyDict_SetItemString(d, "__import__", PyCFunction_New(meth_import, NULL)); - //g_security = level; - - // Overiding file dosnt stop it being accessed if your sneaky - // f = [ t for t in (1).__class__.__mro__[-1].__subclasses__() if t.__name__ == 'file'][0]('/some_file.txt', 'w') - // f.write('...') - // so overwrite the file types functions. be very careful here still, since python uses python. - // ps - python devs frown deeply upon this. - - /* this could mess up pythons internals, if we are serious about sandboxing - * issues like the one above need to be solved, possibly modify __subclasses__ is safer? */ -#if 0 - PyFile_Type.tp_init = file_init; - PyFile_Type.tp_new = file_new; -#endif - //} - break; - /* - case psl_Lowest: - if (g_security) { - PyDict_SetItemString(d, "open", g_oldopen); - PyDict_SetItemString(d, "__import__", g_oldimport); - g_security = level; - } - */ - default: - /* Allow importing internal text, from bpy_internal_import.py */ - PyDict_SetItemString(d, "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item); - PyDict_SetItemString(d, "__import__", item=PyCFunction_New(&bpy_import_meth, NULL)); Py_DECREF(item); - break; - } -} - /* Explanation of * * - backupPySysObjects() : stores sys.path in gp_OrigPythonSysPath @@ -1963,8 +1793,8 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur PySys_SetObject("argv", py_argv); Py_DECREF(py_argv); } - - setSandbox(level); + + bpy_import_init(PyEval_GetBuiltins()); /* mathutils types are used by the BGE even if we dont import them */ { @@ -2016,7 +1846,6 @@ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLev Py_NoSiteFlag=1; Py_FrozenFlag=1; - setSandbox(level); initPyTypes(); bpy_import_main_set(maggie); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index f28ce953d0b..c87157ee993 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -470,8 +470,12 @@ void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctr if (newMass) body->getCollisionShape()->calculateLocalInertia(newMass, inertia); body->setMassProps(newMass, inertia); + m_dynamicsWorld->addRigidBody(body, newCollisionGroup, newCollisionMask); + } + else + { + m_dynamicsWorld->addCollisionObject(obj, newCollisionGroup, newCollisionMask); } - m_dynamicsWorld->addCollisionObject(obj, newCollisionGroup, newCollisionMask); } // to avoid nasty interaction, we must update the property of the controller as well ctrl->m_cci.m_mass = newMass; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 586e75d2d00..51e00b9111f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -125,7 +125,11 @@ protected: virtual void debugDrawWorld(); // virtual bool proceedDeltaTimeOneStep(float timeStep); - virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep){}; + virtual void setFixedTimeStep(bool useFixedTimeStep,float fixedTimeStep) + { + //based on DEFAULT_PHYSICS_TIC_RATE of 60 hertz + setNumTimeSubSteps(fixedTimeStep/60.f); + } //returns 0.f if no fixed timestep is used virtual float getFixedTimeStep(){ return 0.f;}; diff --git a/source/icons/SConscript b/source/icons/SConscript index ca6308781e9..4bb27a7d4fb 100644 --- a/source/icons/SConscript +++ b/source/icons/SConscript @@ -1,9 +1,12 @@ #!/usr/bin/python Import ('env') +import btools -if env['OURPLATFORM'] == 'linuxcross': - source = 'linuxcrossblender.rcscons' -else: - source = 'winblender.rcscons' +env['RCFLAGS'].append("-DWINDRES") +env['RCFLAGS'].append("-DBLEN_VER_RC_STR_M=" + btools.VERSION) +env['RCFLAGS'].append("-DBLEN_VER_RC_1=" + btools.VERSION[0]) +env['RCFLAGS'].append("-DBLEN_VER_RC_2=" + btools.VERSION[2]) +env['RCFLAGS'].append("-DBLEN_VER_RC_3=" + btools.VERSION[3]) +env['RCFLAGS'].append("-DBLEN_VER_RC_4=0") -env.BlenderRes('winresource', source, ['core'], priority=[95]) +env.BlenderRes('winresource', 'winblender.rc', ['core'], priority=[95]) diff --git a/source/icons/blender.exe.manifest b/source/icons/blender.exe.manifest new file mode 100644 index 00000000000..bc13bf4c586 --- /dev/null +++ b/source/icons/blender.exe.manifest @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/source/icons/linuxcrossblender.rcscons b/source/icons/linuxcrossblender.rcscons deleted file mode 100644 index cf3083aa472..00000000000 --- a/source/icons/linuxcrossblender.rcscons +++ /dev/null @@ -1,2 +0,0 @@ -APPICON ICON "source/icons/winblender.ico" -BLENDERFILE ICON "source/icons/winblenderfile.ico" diff --git a/source/icons/winblender.rc b/source/icons/winblender.rc index 77e62111d2d..d1b67725b57 100644 --- a/source/icons/winblender.rc +++ b/source/icons/winblender.rc @@ -1,2 +1,45 @@ -APPICON ICON "winblender.ico" -BLENDERFILE ICON "winblenderfile.ico" +#define BLENDERFILE 1 +#define IDR_VERSION1 1 + +#ifdef WINDRES + #include "winresrc.h" + #define IDC_STATIC (-1) + #define STRINGIFY_(x) #x + #define STRINGIFY(x) STRINGIFY_(x) + #define BLEN_VER_RC_STR STRINGIFY(BLEN_VER_RC_STR_M) + 1 RT_MANIFEST "blender.exe.manifest" +#endif + +APPICON ICON DISCARDABLE "winblender.ico" +BLENDERFILE ICON DISCARDABLE "winblenderfile.ico" + +IDR_VERSION1 VERSIONINFO +FILEVERSION BLEN_VER_RC_1, BLEN_VER_RC_2, BLEN_VER_RC_3, BLEN_VER_RC_4 +PRODUCTVERSION BLEN_VER_RC_1, BLEN_VER_RC_2, BLEN_VER_RC_3, BLEN_VER_RC_4 +FILEOS 0x00000004 +FILETYPE 0x00000001 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "04090000" + BEGIN +#if defined(FREE_WINDOWS) || !defined(WINDRES) // this doesnt work for mingw. + VALUE "FileVersion", "Unknown" + VALUE "ProductVersion", "Unknown" +#else + VALUE "FileVersion", BLEN_VER_RC_STR + VALUE "ProductVersion", BLEN_VER_RC_STR +#endif + VALUE "CompanyName", "Blender Foundation" + VALUE "FileDescription", "Blender" + VALUE "LegalCopyright", "GPLv2 (Blender Foundation)" + VALUE "OriginalFilename", "blender.exe" + VALUE "ProductName", "Blender" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x0000 + END +END + diff --git a/source/icons/winblender.rcscons b/source/icons/winblender.rcscons deleted file mode 100644 index 97579f1ffe0..00000000000 --- a/source/icons/winblender.rcscons +++ /dev/null @@ -1,2 +0,0 @@ -APPICON ICON "source\\icons\\winblender.ico" -BLENDERFILE ICON "source\\icons\\winblenderfile.ico" diff --git a/source/tests/bl_run_operators.py b/source/tests/bl_run_operators.py index f1f21d3bd71..668b4e69228 100644 --- a/source/tests/bl_run_operators.py +++ b/source/tests/bl_run_operators.py @@ -113,11 +113,6 @@ def ctx_editmode_mball(): bpy.ops.object.mode_set(mode='EDIT') -def ctx_editmode_mball(): - bpy.ops.object.metaball_add() - bpy.ops.object.mode_set(mode='EDIT') - - def ctx_editmode_text(): bpy.ops.object.text_add() bpy.ops.object.mode_set(mode='EDIT')