From 2513b194a219b87f4751a86b6b4b804de6c50f93 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Mar 2011 12:40:06 +0000 Subject: [PATCH 001/261] pedantic edit, no need to initialize var. --- .../scripts/startup/bl_operators/__init__.py | 58 +++++++++++++++++++ source/gameengine/Ketsji/KX_PythonInit.cpp | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 release/scripts/startup/bl_operators/__init__.py diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py new file mode 100644 index 00000000000..599cd6c1889 --- /dev/null +++ b/release/scripts/startup/bl_operators/__init__.py @@ -0,0 +1,58 @@ +# ##### 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 ##### + +# + +if "bpy" in locals(): + from imp import reload as _reload + for val in _modules_loaded.values(): + _reload(val) +_modules = ( + "add_mesh_torus", + "animsys_update", + "fcurve_euler_filter", + "image", + "mesh", + "nla", + "object_align", + "object", + "object_randomize_transform", + "presets", + "screen_play_rendered_anim", + "sequencer", + "uvcalc_follow_active", + "uvcalc_lightmap", + "uvcalc_smart_project", + "vertexpaint_dirt", + "wm", +) +__import__(name=__name__, fromlist=_modules) +_namespace = globals() +_modules_loaded = {name: _namespace[name] for name in _modules} +del _namespace + + +import bpy + + +def register(): + bpy.utils.register_module(__name__) + + +def unregister(): + bpy.utils.unregister_module(__name__) diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 5d5367653b7..95831b38bfa 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -642,7 +642,6 @@ static PyObject *gLibLoad(PyObject*, PyObject* args) { KX_Scene *kx_scene= gp_KetsjiScene; char *path; - char abs_path[FILE_MAX] = {0}; char *group; Py_buffer py_buffer; py_buffer.buf = NULL; @@ -653,6 +652,7 @@ static PyObject *gLibLoad(PyObject*, PyObject* args) if (!py_buffer.buf) { + char abs_path[FILE_MAX]; // Make the path absolute BLI_strncpy(abs_path, path, sizeof(abs_path)); BLI_path_abs(abs_path, gp_GamePythonPath); From f0d7fbc4b7fb9649b56e9ce67e3326f9f7e069da Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 21 Mar 2011 16:42:21 +0000 Subject: [PATCH 002/261] CMake package_archive target to create a .zip/.tar.bz2 package on mac/unix, to be used by buildbot. --- GNUmakefile | 4 ++ build_files/cmake/packaging.cmake | 30 +++++++++- build_files/package_spec/build_archive.py | 69 +++++++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100755 build_files/package_spec/build_archive.py diff --git a/GNUmakefile b/GNUmakefile index 772cec3c471..42d7c33e46b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -90,6 +90,10 @@ package_debian: package_pacman: cd build_files/package_spec/pacman ; MAKEFLAGS="-j$(NPROCS)" makepkg --asroot +package_archive: + cd $(BUILD_DIR) ; make -s package_archive + @echo archive in "$(BUILD_DIR)/release" + # forward build targets test: cd $(BUILD_DIR) ; ctest . --output-on-failure diff --git a/build_files/cmake/packaging.cmake b/build_files/cmake/packaging.cmake index b21c13f80b4..ee07857db26 100644 --- a/build_files/cmake/packaging.cmake +++ b/build_files/cmake/packaging.cmake @@ -51,7 +51,35 @@ if(APPLE) # Libraries are bundled directly set(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE) -endif(APPLE) +endif() set(CPACK_PACKAGE_EXECUTABLES "blender") include(CPack) + +# Target for build_archive.py script, to automatically pass along +# version, revision, platform, build directory +macro(add_package_archive packagename extension) + set(build_archive python ${CMAKE_SOURCE_DIR}/build_files/package_spec/build_archive.py) + set(package_output ${CMAKE_BINARY_DIR}/release/${packagename}.${extension}) + + add_custom_target(package_archive DEPENDS ${package_output}) + + add_custom_command( + OUTPUT ${package_output} + COMMAND ${build_archive} ${packagename} ${extension} bin release + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +endmacro() + +if(APPLE) + add_package_archive( + "blender-${BLENDER_VERSION}-r${BUILD_REV}-OSX-${CMAKE_OSX_ARCHITECTURES}" + "zip") +elseif(UNIX) + # platform name could be tweaked, to include glibc, and ensure processor is correct (i386 vs i686) + string(TOLOWER ${CMAKE_SYSTEM_NAME} PACKAGE_SYSTEM_NAME) + + add_package_archive( + "blender-${BLENDER_VERSION}-r${BUILD_REV}-${PACKAGE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}" + "tar.bz2") +endif() + diff --git a/build_files/package_spec/build_archive.py b/build_files/package_spec/build_archive.py new file mode 100755 index 00000000000..79e42af7b69 --- /dev/null +++ b/build_files/package_spec/build_archive.py @@ -0,0 +1,69 @@ +#!/usr/bin/python + +import os +import shutil +import subprocess +import sys + +# todo: +# strip executables + +# get parameters +if len(sys.argv) < 5: + sys.stderr.write('Excepted arguments: ./build_archive.py name extension install_dir output_dir') + sys.exit(1) + +package_name = sys.argv[1] +extension = sys.argv[2] +install_dir = sys.argv[3] +output_dir = sys.argv[4] + +package_archive = os.path.join(output_dir, package_name + '.' + extension) +package_dir = package_name + +# remove existing package with the same name +try: + if os.path.exists(package_archive): + os.remove(package_archive) + if os.path.exists(package_dir): + shutil.rmtree(package_dir) +except: + sys.stderr.write('Failed to clean up old package files: ' + sys.exc_info()[0] + '\n') + sys.exit(1) + +# create temporary package dir +try: + shutil.copytree(install_dir, package_dir) + + for f in os.listdir(package_dir): + if f.startswith('makes'): + os.remove(os.path.join(package_dir, f)) +except: + sys.stderr.write('Failed to copy install directory: ' + sys.exc_info()[0] + '\n') + sys.exit(1) + +# create archive +try: + if not os.path.exists(output_dir): + os.mkdir(output_dir) + + if extension == 'zip': + archive_cmd = ['zip', '-9', '-r', package_archive, package_dir] + elif extension == 'tar.bz2': + archive_cmd = ['tar', 'cjf', package_archive, package_dir] + else: + sys.stderr.write('Unknown archive extension: ' + extension) + sys.exit(-1) + + subprocess.call(archive_cmd) +except: + sys.stderr.write('Failed to create package archive: ' + sys.exc_info()[0] + '\n') + sys.exit(1) + +# empty temporary package dir +try: + shutil.rmtree(package_dir) +except: + sys.stderr.write('Failed to clean up package directory: ' + sys.exc_info()[0] + '\n') + sys.exit(1) + From 9a75ba4463eddf55493c516f6b9e851771ff6fe5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 21 Mar 2011 16:46:26 +0000 Subject: [PATCH 003/261] Buildbot initial configuration files, for http://builder.blender.org Maintained in svn to make it easier for others to contribute changes, actually updating builder.blender.org requires manual update on the server. --- build_files/buildbot/master.cfg | 203 ++++++++++++++++++++++++++ build_files/buildbot/master_unpack.py | 117 +++++++++++++++ build_files/buildbot/slave_pack.py | 87 +++++++++++ 3 files changed, 407 insertions(+) create mode 100644 build_files/buildbot/master.cfg create mode 100644 build_files/buildbot/master_unpack.py create mode 100644 build_files/buildbot/slave_pack.py diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg new file mode 100644 index 00000000000..0b37e055584 --- /dev/null +++ b/build_files/buildbot/master.cfg @@ -0,0 +1,203 @@ +# -*- python -*- +# ex: set syntax=python: + +# Dictionary that the buildmaster pays attention to. +c = BuildmasterConfig = {} + +# BUILD SLAVES +# +# We load the slaves and their passwords from a separator file, so we can have +# this one in SVN. + +from buildbot.buildslave import BuildSlave +import master_private + +c['slaves'] = [] + +for slave in master_private.slaves: + c['slaves'].append(BuildSlave(slave['name'], slave['password'])) + +# TCP port through which slaves connect + +c['slavePortnum'] = 9989 + +# CHANGE SOURCES + +from buildbot.changes.svnpoller import SVNPoller + +c['change_source'] = SVNPoller( + 'https://svn.blender.org/svnroot/bf-blender/trunk/', + pollinterval=1200) + +# BUILDERS +# +# The 'builders' list defines the Builders, which tell Buildbot how to perform a build: +# what steps, and which slaves can execute them. Note that any particular build will +# only take place on one slave. + +from buildbot.process.factory import BuildFactory +from buildbot.steps.source import SVN +from buildbot.steps.shell import ShellCommand +from buildbot.steps.shell import Compile +from buildbot.steps.shell import Test +from buildbot.steps.transfer import FileUpload +from buildbot.steps.transfer import FileDownload +from buildbot.steps.master import MasterShellCommand +from buildbot.config import BuilderConfig + +# add builder utility + +c['builders'] = [] +buildernames = [] + +def add_builder(c, name, factory): + slavenames = [] + + for slave in master_private.slaves: + if name in slave['builders']: + slavenames.append(slave['name']) + + f = factory(name) + c['builders'].append(BuilderConfig(name=name, slavenames=slavenames, factory=f, category='blender')) + buildernames.append(name) + +# common steps + +def svn_step(): + return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/blender', mode='update', defaultBranch='trunk', workdir='blender') + +def lib_svn_step(dir): + return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir) + +def cmake_compile_step(): + return Compile(command=['make'], workdir='blender') + +def cmake_test_step(): + return Test(workdir='blender') # make test + +def scons_compile_step(): + return Compile(command=['python', 'scons/scons.py'], workdir='blender') + +class SlavePack(ShellCommand): + pack_script = 'slave_pack.py' + def start(self): + if self.getProperty('buildername').find('scons')>=0: + self.setCommand(['python', pack_script, 'scons']) + else: + self.setCommand(['python', pack_script, 'cmake']) + ShellCommand.start(self) + +def file_upload(f, id): + filename = 'buildbot_upload_' + id + '.zip' + pack_script = 'slave_pack.py' + unpack_script = 'master_unpack.py' + + f.addStep(FileDownload(name='download', mastersrc=pack_script, slavedest=pack_script)) + f.addStep(ShellCommand(name='package', command=['python', pack_script], description='packaging', descriptionDone='packaged')) + f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024)) + f.addStep(MasterShellCommand(name='unpack', command=['python', unpack_script, filename], description='unpacking', descriptionDone='unpacked')) + +# linux cmake + +def linux_cmake(id): + f = BuildFactory() + f.addStep(svn_step()) + f.addStep(cmake_compile_step()) + f.addStep(cmake_test_step()) + file_upload(f, id) + return f + +add_builder(c, 'linux_x86_64_cmake', linux_cmake) + +# mac cmake + +def mac_cmake(id): + f = BuildFactory() + f.addStep(svn_step()) + f.addStep(lib_svn_step('darwin-9.x.universal')) + f.addStep(cmake_compile_step()) + f.addStep(cmake_test_step()) + file_upload(f, id) + return f + +add_builder(c, 'mac_x86_64_cmake', mac_cmake) + +# win32 scons + +# TODO: add scons test target +def win32_scons(id): + f = BuildFactory() + f.addStep(svn_step()) + f.addStep(lib_svn_step('windows')) + f.addStep(scons_compile_step()) + file_upload(f, id) + return f + +add_builder(c, 'win32_scons', win32_scons) + +# SCHEDULERS +# +# Decide how to react to incoming changes. + +from buildbot.scheduler import Scheduler +from buildbot.schedulers import timed + +c['schedulers'] = [] +#c['schedulers'].append(Scheduler(name="all", branch=None, +# treeStableTimer=None, +# builderNames=[])) +#c['schedulers'].append(timed.Periodic(name="nightly", +# builderNames=buildernames, +# periodicBuildTimer=24*60*60)) + +c['schedulers'].append(timed.Nightly(name='nightly', + builderNames=buildernames, + hour=3, + minute=0)) + +# STATUS TARGETS +# +# 'status' is a list of Status Targets. The results of each build will be +# pushed to these targets. buildbot/status/*.py has a variety to choose from, +# including web pages, email senders, and IRC bots. + +c['status'] = [] + +from buildbot.status import html +from buildbot.status.web import auth, authz + +authz_cfg=authz.Authz( + # change any of these to True to enable; see the manual for more + # options + gracefulShutdown = False, + forceBuild = True, # use this to test your slave once it is set up + forceAllBuilds = False, + pingBuilder = False, + stopBuild = False, + stopAllBuilds = False, + cancelPendingBuild = False, +) + +c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) + +# PROJECT IDENTITY + +c['projectName'] = "Blender" +c['projectURL'] = "http://www.blender.org" + +# the 'buildbotURL' string should point to the location where the buildbot's +# internal web server (usually the html.WebStatus page) is visible. This +# typically uses the port number set in the Waterfall 'status' entry, but +# with an externally-visible host name which the buildbot cannot figure out +# without some help. + +c['buildbotURL'] = "http://builder.blender.org/" + +# DB URL +# +# This specifies what database buildbot uses to store change and scheduler +# state. You can leave this at its default for all but the largest +# installations. + +c['db_url'] = "sqlite:///state.sqlite" + diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py new file mode 100644 index 00000000000..c905b55a669 --- /dev/null +++ b/build_files/buildbot/master_unpack.py @@ -0,0 +1,117 @@ +# ##### 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 ##### + +# Runs on Buildbot master, to unpack incoming unload.zip into latest +# builds directory and remove older builds. + +import os +import shutil +import sys +import zipfile + +# extension stripping +def strip_extension(filename): + extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] + + for ext in extensions: + if filename.endswith(ext): + filename = filename[:-len(ext)] + + return filename + +# extract platform from package name +def get_platform(filename): + # name is blender-version-platform.extension. we want to get the + # platform out, but there may be some variations, so we fiddle a + # bit to handle current and hopefully future names + filename = strip_extension(filename) + filename = strip_extension(filename) + + tokens = filename.split("-") + platforms = ['osx', 'mac', 'bsd', 'windows', 'linux', 'source', 'irix', 'solaris'] + platform_tokens = [] + found = False + + for i, token in enumerate(tokens): + if not found: + for platform in platforms: + if token.lower().find(platform) != -1: + found = True + + if found: + platform_tokens += [token] + + return '-'.join(platform_tokens) + +# get filename +if len(sys.argv) < 2: + sys.stderr.write("Not enough arguments, expecting file to unpack\n") + sys.exit(1) + +filename = sys.argv[1] + +# open zip file +if not os.path.exists(filename): + sys.stderr.write("File " + filename + " not found.\n") + sys.exit(1) + +try: + z = zipfile.ZipFile(filename, "r") +except Exception, ex: + sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') + sys.exit(1) + +if len(z.namelist()) != 1: + sys.stderr.write("Expected on file in " + filename + ".") + sys.exit(1) + +package = z.namelist()[0] +packagename = os.path.basename(package) + +# detect platform +platform = get_platform(packagename) + +if platform == '': + sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') + sys.exit(1) + +# extract +dir = 'public_html/latest_builds' + +try: + zf = z.open(package) + f = file(os.path.join(dir, packagename), "wb") + + shutil.copyfileobj(zf, f) + + zf.close() + z.close() +except Exception, ex: + sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') + sys.exit(1) + +# remove other files from the same platform +try: + for f in os.listdir(dir): + if f.lower().find(platform.lower()) != -1: + if f != packagename: + os.remove(os.path.join(dir, f)) +except Exception, ex: + sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') + sys.exit(1) + diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py new file mode 100644 index 00000000000..5fdcda51f5c --- /dev/null +++ b/build_files/buildbot/slave_pack.py @@ -0,0 +1,87 @@ +# ##### 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 ##### + +# Runs on buildbot slave, creating a release package using the build +# system and zipping it into buildbot_upload.zip. This is then uploaded +# to the master in the next buildbot step. + +import os +import subprocess +import sys +import zipfile + +# find release directory +def find_release_directory(): + for d in os.listdir('.'): + if os.path.isdir(d): + rd = os.path.join(d, 'release') + if os.path.exists(rd): + return rd + + return None + +# clean release directory if it already exists +dir = find_release_directory() + +if dir: + for f in os.listdir(dir): + if os.path.isfile(os.path.join(dir, f)): + os.remove(os.path.join(dir, f)) + +# create release package +try: + os.chdir('../blender') + subprocess.call(['make', 'package_archive']) + os.chdir('../build') +except Exception, ex: + sys.stderr.write('Make package release failed' + str(ex) + '\n') + sys.exit(1) + +# find release directory, must exist this time +dir = find_release_directory() + +if not dir: + sys.stderr.write("Failed to find release directory.\n") + sys.exit(1) + +# find release package +file = None +filepath = None + +for f in os.listdir(dir): + rf = os.path.join(dir, f) + if os.path.isfile(rf) and f.startswith('blender'): + file = f + filepath = rf + +if not file: + sys.stderr.write("Failed to find release package.\n") + sys.exit(1) + +# create zip file +try: + upload_zip = "buildbot_upload.zip" + if os.path.exists(upload_zip): + os.remove(upload_zip) + z = zipfile.ZipFile(upload_zip, "w", compression=zipfile.ZIP_STORED) + z.write(filepath, arcname=file) + z.close() +except Exception, ex: + sys.stderr.write('Create buildbot_upload.zip failed' + str(ex) + '\n') + sys.exit(1) + From 67cbf22211af8864b32b55ce337290d832e8107f Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 21 Mar 2011 17:10:55 +0000 Subject: [PATCH 004/261] Bugfix #26549 Using environment map type "load" increased user counter on each preview render. Also noticed that this type of envmap use wasn't threadsafe, causing imbufs being allocated for all threads. Also fixed that. --- source/blender/blenkernel/intern/texture.c | 5 +- source/blender/render/intern/source/envmap.c | 83 +++++++++++--------- 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 12aef5f4b29..3ce4acf5902 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -788,7 +788,10 @@ Tex *localize_texture(Tex *tex) } if(texn->coba) texn->coba= MEM_dupallocN(texn->coba); - if(texn->env) texn->env= BKE_copy_envmap(texn->env); + if(texn->env) { + texn->env= BKE_copy_envmap(texn->env); + id_us_min(texn->env->ima); + } if(texn->pd) texn->pd= MEM_dupallocN(texn->pd); if(texn->vd) { texn->vd= MEM_dupallocN(texn->vd); diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 2e75e0c9870..c4065b30cb0 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -75,47 +75,54 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf) { int dx, part; - BKE_free_envmapdata(env); + /* after lock we test cube[1], if set the other thread has done it fine */ + BLI_lock_thread(LOCK_IMAGE); + if(env->cube[1]==NULL) { + + BKE_free_envmapdata(env); - dx= ibuf->y; - dx/= 2; - if (3*dx == ibuf->x) { - env->type = ENV_CUBE; - } else if (ibuf->x == ibuf->y) { - env->type = ENV_PLANE; - } else { - printf("Incorrect envmap size\n"); - env->ok= 0; - env->ima->ok= 0; - return; - } - - if (env->type == ENV_CUBE) { - for(part=0; part<6; part++) { - env->cube[part]= IMB_allocImBuf(dx, dx, 24, IB_rect|IB_rectfloat); + dx= ibuf->y; + dx/= 2; + if (3*dx == ibuf->x) { + env->type = ENV_CUBE; + env->ok= ENV_OSA; + } else if (ibuf->x == ibuf->y) { + env->type = ENV_PLANE; + env->ok= ENV_OSA; + } else { + printf("Incorrect envmap size\n"); + env->ok= 0; + env->ima->ok= 0; } - IMB_float_from_rect(ibuf); - IMB_rectcpy(env->cube[0], ibuf, - 0, 0, 0, 0, dx, dx); - IMB_rectcpy(env->cube[1], ibuf, - 0, 0, dx, 0, dx, dx); - IMB_rectcpy(env->cube[2], ibuf, - 0, 0, 2*dx, 0, dx, dx); - IMB_rectcpy(env->cube[3], ibuf, - 0, 0, 0, dx, dx, dx); - IMB_rectcpy(env->cube[4], ibuf, - 0, 0, dx, dx, dx, dx); - IMB_rectcpy(env->cube[5], ibuf, - 0, 0, 2*dx, dx, dx, dx); - env->ok= ENV_OSA; - } - else { /* ENV_PLANE */ - env->cube[1]= IMB_dupImBuf(ibuf); - IMB_float_from_rect(env->cube[1]); - - env->ok= ENV_OSA; - } + if(env->ok) { + if (env->type == ENV_CUBE) { + for(part=0; part<6; part++) { + env->cube[part]= IMB_allocImBuf(dx, dx, 24, IB_rect|IB_rectfloat); + } + IMB_float_from_rect(ibuf); + + IMB_rectcpy(env->cube[0], ibuf, + 0, 0, 0, 0, dx, dx); + IMB_rectcpy(env->cube[1], ibuf, + 0, 0, dx, 0, dx, dx); + IMB_rectcpy(env->cube[2], ibuf, + 0, 0, 2*dx, 0, dx, dx); + IMB_rectcpy(env->cube[3], ibuf, + 0, 0, 0, dx, dx, dx); + IMB_rectcpy(env->cube[4], ibuf, + 0, 0, dx, dx, dx, dx); + IMB_rectcpy(env->cube[5], ibuf, + 0, 0, 2*dx, dx, dx, dx); + + } + else { /* ENV_PLANE */ + env->cube[1]= IMB_dupImBuf(ibuf); + IMB_float_from_rect(env->cube[1]); + } + } + } + BLI_unlock_thread(LOCK_IMAGE); } /* ------------------------------------------------------------------------- */ From 2304256a6c9c5aab201334b7a9febf4532bfe27b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Mar 2011 22:10:24 +0000 Subject: [PATCH 005/261] quiet warning --- source/blender/blenkernel/intern/texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 3ce4acf5902..c0261d3b5a3 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -790,7 +790,7 @@ Tex *localize_texture(Tex *tex) if(texn->coba) texn->coba= MEM_dupallocN(texn->coba); if(texn->env) { texn->env= BKE_copy_envmap(texn->env); - id_us_min(texn->env->ima); + id_us_min(&texn->env->ima->id); } if(texn->pd) texn->pd= MEM_dupallocN(texn->pd); if(texn->vd) { From 379f55f54ca67ed29a221a57777729c422e5e3af Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Mar 2011 22:17:01 +0000 Subject: [PATCH 006/261] fix for error printing class register error, remove an unneeded check. --- release/scripts/modules/bpy/utils.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 8f1fdc28402..f4f7d065259 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -182,8 +182,6 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): _global_loaded_modules[:] = [] - user_path = user_script_path() - for base_path in script_paths(): for path_subdir in ("startup", "modules"): path = _os.path.join(base_path, path_subdir) @@ -194,9 +192,6 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): if path_subdir == "modules": continue - if user_path != base_path and path_subdir == "": - continue # avoid loading 2.4x scripts - for mod in modules_from_path(path, loaded_modules): test_register(mod) @@ -441,7 +436,6 @@ def register_module(module, verbose=False): cls_func() except: print("bpy.utils.register_module(): failed to registering class %r" % cls) - print("\t", path, "line", line) import traceback traceback.print_exc() if verbose: @@ -463,7 +457,6 @@ def unregister_module(module, verbose=False): cls_func() except: print("bpy.utils.unregister_module(): failed to unregistering class %r" % cls) - print("\t", path, "line", line) import traceback traceback.print_exc() if verbose: From 4bca2e455d5d5232cfbf36897427cb75f66e54aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Mar 2011 22:37:08 +0000 Subject: [PATCH 007/261] use spaces rather then tabs + minor pep8 edits. --- build_files/buildbot/master.cfg | 131 ++++++++++++++------------ build_files/buildbot/master_unpack.py | 97 +++++++++---------- build_files/buildbot/slave_pack.py | 4 +- 3 files changed, 122 insertions(+), 110 deletions(-) diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg index 0b37e055584..c4c8d8108e1 100644 --- a/build_files/buildbot/master.cfg +++ b/build_files/buildbot/master.cfg @@ -15,7 +15,7 @@ import master_private c['slaves'] = [] for slave in master_private.slaves: - c['slaves'].append(BuildSlave(slave['name'], slave['password'])) + c['slaves'].append(BuildSlave(slave['name'], slave['password'])) # TCP port through which slaves connect @@ -36,7 +36,7 @@ c['change_source'] = SVNPoller( # only take place on one slave. from buildbot.process.factory import BuildFactory -from buildbot.steps.source import SVN +from buildbot.steps.source import SVN from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import Compile from buildbot.steps.shell import Test @@ -50,88 +50,100 @@ from buildbot.config import BuilderConfig c['builders'] = [] buildernames = [] -def add_builder(c, name, factory): - slavenames = [] - for slave in master_private.slaves: - if name in slave['builders']: - slavenames.append(slave['name']) - - f = factory(name) - c['builders'].append(BuilderConfig(name=name, slavenames=slavenames, factory=f, category='blender')) - buildernames.append(name) +def add_builder(c, name, factory): + slavenames = [] + + for slave in master_private.slaves: + if name in slave['builders']: + slavenames.append(slave['name']) + + f = factory(name) + c['builders'].append(BuilderConfig(name=name, slavenames=slavenames, factory=f, category='blender')) + buildernames.append(name) # common steps + def svn_step(): - return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/blender', mode='update', defaultBranch='trunk', workdir='blender') + return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/blender', mode='update', defaultBranch='trunk', workdir='blender') + def lib_svn_step(dir): - return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir) + return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir) + def cmake_compile_step(): - return Compile(command=['make'], workdir='blender') + return Compile(command=['make'], workdir='blender') + def cmake_test_step(): - return Test(workdir='blender') # make test + return Test(workdir='blender') # make test + def scons_compile_step(): - return Compile(command=['python', 'scons/scons.py'], workdir='blender') + return Compile(command=['python', 'scons/scons.py'], workdir='blender') + class SlavePack(ShellCommand): - pack_script = 'slave_pack.py' - def start(self): - if self.getProperty('buildername').find('scons')>=0: - self.setCommand(['python', pack_script, 'scons']) - else: - self.setCommand(['python', pack_script, 'cmake']) - ShellCommand.start(self) + pack_script = 'slave_pack.py' + + def start(self): + if self.getProperty('buildername').find('scons') >= 0: + self.setCommand(['python', pack_script, 'scons']) + else: + self.setCommand(['python', pack_script, 'cmake']) + ShellCommand.start(self) + def file_upload(f, id): - filename = 'buildbot_upload_' + id + '.zip' - pack_script = 'slave_pack.py' - unpack_script = 'master_unpack.py' + filename = 'buildbot_upload_' + id + '.zip' + pack_script = 'slave_pack.py' + unpack_script = 'master_unpack.py' - f.addStep(FileDownload(name='download', mastersrc=pack_script, slavedest=pack_script)) - f.addStep(ShellCommand(name='package', command=['python', pack_script], description='packaging', descriptionDone='packaged')) - f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024)) - f.addStep(MasterShellCommand(name='unpack', command=['python', unpack_script, filename], description='unpacking', descriptionDone='unpacked')) + f.addStep(FileDownload(name='download', mastersrc=pack_script, slavedest=pack_script)) + f.addStep(ShellCommand(name='package', command=['python', pack_script], description='packaging', descriptionDone='packaged')) + f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100 * 1024 * 1024)) + f.addStep(MasterShellCommand(name='unpack', command=['python', unpack_script, filename], description='unpacking', descriptionDone='unpacked')) # linux cmake + def linux_cmake(id): - f = BuildFactory() - f.addStep(svn_step()) - f.addStep(cmake_compile_step()) - f.addStep(cmake_test_step()) - file_upload(f, id) - return f + f = BuildFactory() + f.addStep(svn_step()) + f.addStep(cmake_compile_step()) + f.addStep(cmake_test_step()) + file_upload(f, id) + return f add_builder(c, 'linux_x86_64_cmake', linux_cmake) # mac cmake + def mac_cmake(id): - f = BuildFactory() - f.addStep(svn_step()) - f.addStep(lib_svn_step('darwin-9.x.universal')) - f.addStep(cmake_compile_step()) - f.addStep(cmake_test_step()) - file_upload(f, id) - return f + f = BuildFactory() + f.addStep(svn_step()) + f.addStep(lib_svn_step('darwin-9.x.universal')) + f.addStep(cmake_compile_step()) + f.addStep(cmake_test_step()) + file_upload(f, id) + return f add_builder(c, 'mac_x86_64_cmake', mac_cmake) # win32 scons + # TODO: add scons test target def win32_scons(id): - f = BuildFactory() - f.addStep(svn_step()) - f.addStep(lib_svn_step('windows')) - f.addStep(scons_compile_step()) - file_upload(f, id) - return f + f = BuildFactory() + f.addStep(svn_step()) + f.addStep(lib_svn_step('windows')) + f.addStep(scons_compile_step()) + file_upload(f, id) + return f add_builder(c, 'win32_scons', win32_scons) @@ -147,8 +159,8 @@ c['schedulers'] = [] # treeStableTimer=None, # builderNames=[])) #c['schedulers'].append(timed.Periodic(name="nightly", -# builderNames=buildernames, -# periodicBuildTimer=24*60*60)) +# builderNames=buildernames, +# periodicBuildTimer=24*60*60)) c['schedulers'].append(timed.Nightly(name='nightly', builderNames=buildernames, @@ -166,16 +178,16 @@ c['status'] = [] from buildbot.status import html from buildbot.status.web import auth, authz -authz_cfg=authz.Authz( +authz_cfg = authz.Authz( # change any of these to True to enable; see the manual for more # options - gracefulShutdown = False, - forceBuild = True, # use this to test your slave once it is set up - forceAllBuilds = False, - pingBuilder = False, - stopBuild = False, - stopAllBuilds = False, - cancelPendingBuild = False, + gracefulShutdown=False, + forceBuild=True, # use this to test your slave once it is set up + forceAllBuilds=False, + pingBuilder=False, + stopBuild=False, + stopAllBuilds=False, + cancelPendingBuild=False, ) c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) @@ -200,4 +212,3 @@ c['buildbotURL'] = "http://builder.blender.org/" # installations. c['db_url'] = "sqlite:///state.sqlite" - diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index c905b55a669..8580fd3d6d6 100644 --- a/build_files/buildbot/master_unpack.py +++ b/build_files/buildbot/master_unpack.py @@ -18,67 +18,69 @@ # Runs on Buildbot master, to unpack incoming unload.zip into latest # builds directory and remove older builds. - + import os import shutil import sys import zipfile + # extension stripping def strip_extension(filename): - extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] + extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] - for ext in extensions: - if filename.endswith(ext): - filename = filename[:-len(ext)] + for ext in extensions: + if filename.endswith(ext): + filename = filename[:-len(ext)] + + return filename - return filename # extract platform from package name def get_platform(filename): - # name is blender-version-platform.extension. we want to get the - # platform out, but there may be some variations, so we fiddle a - # bit to handle current and hopefully future names - filename = strip_extension(filename) - filename = strip_extension(filename) + # name is blender-version-platform.extension. we want to get the + # platform out, but there may be some variations, so we fiddle a + # bit to handle current and hopefully future names + filename = strip_extension(filename) + filename = strip_extension(filename) - tokens = filename.split("-") - platforms = ['osx', 'mac', 'bsd', 'windows', 'linux', 'source', 'irix', 'solaris'] - platform_tokens = [] - found = False + tokens = filename.split("-") + platforms = ['osx', 'mac', 'bsd', 'windows', 'linux', 'source', 'irix', 'solaris'] + platform_tokens = [] + found = False - for i, token in enumerate(tokens): - if not found: - for platform in platforms: - if token.lower().find(platform) != -1: - found = True + for i, token in enumerate(tokens): + if not found: + for platform in platforms: + if token.lower().find(platform) != -1: + found = True - if found: - platform_tokens += [token] + if found: + platform_tokens += [token] - return '-'.join(platform_tokens) + return '-'.join(platform_tokens) # get filename if len(sys.argv) < 2: - sys.stderr.write("Not enough arguments, expecting file to unpack\n") - sys.exit(1) + sys.stderr.write("Not enough arguments, expecting file to unpack\n") + sys.exit(1) filename = sys.argv[1] # open zip file if not os.path.exists(filename): - sys.stderr.write("File " + filename + " not found.\n") - sys.exit(1) + sys.stderr.write("File " + filename + " not found.\n") + sys.exit(1) try: - z = zipfile.ZipFile(filename, "r") + z = zipfile.ZipFile(filename, "r") except Exception, ex: - sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') + sys.exit(1) if len(z.namelist()) != 1: - sys.stderr.write("Expected on file in " + filename + ".") - sys.exit(1) + sys.stderr.write("Expected on file in " + filename + ".") + sys.exit(1) package = z.namelist()[0] packagename = os.path.basename(package) @@ -87,31 +89,30 @@ packagename = os.path.basename(package) platform = get_platform(packagename) if platform == '': - sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') - sys.exit(1) + sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') + sys.exit(1) # extract dir = 'public_html/latest_builds' try: - zf = z.open(package) - f = file(os.path.join(dir, packagename), "wb") + zf = z.open(package) + f = file(os.path.join(dir, packagename), "wb") - shutil.copyfileobj(zf, f) + shutil.copyfileobj(zf, f) - zf.close() - z.close() + zf.close() + z.close() except Exception, ex: - sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') + sys.exit(1) # remove other files from the same platform try: - for f in os.listdir(dir): - if f.lower().find(platform.lower()) != -1: - if f != packagename: - os.remove(os.path.join(dir, f)) + for f in os.listdir(dir): + if f.lower().find(platform.lower()) != -1: + if f != packagename: + os.remove(os.path.join(dir, f)) except Exception, ex: - sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') - sys.exit(1) - + sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') + sys.exit(1) diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py index 5fdcda51f5c..6710591d0d7 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -25,6 +25,7 @@ import subprocess import sys import zipfile + # find release directory def find_release_directory(): for d in os.listdir('.'): @@ -32,7 +33,7 @@ def find_release_directory(): rd = os.path.join(d, 'release') if os.path.exists(rd): return rd - + return None # clean release directory if it already exists @@ -84,4 +85,3 @@ try: except Exception, ex: sys.stderr.write('Create buildbot_upload.zip failed' + str(ex) + '\n') sys.exit(1) - From d781ecff7534a11989d4753fd1d2641469b326d8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Mar 2011 23:30:56 +0000 Subject: [PATCH 008/261] fix for grease pencil conversion to bezier curve reading past the end of the array. --- build_files/package_spec/build_archive.py | 59 +++++++++---------- source/blender/editors/gpencil/gpencil_edit.c | 2 +- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/build_files/package_spec/build_archive.py b/build_files/package_spec/build_archive.py index 79e42af7b69..3c41cd5911e 100755 --- a/build_files/package_spec/build_archive.py +++ b/build_files/package_spec/build_archive.py @@ -10,8 +10,8 @@ import sys # get parameters if len(sys.argv) < 5: - sys.stderr.write('Excepted arguments: ./build_archive.py name extension install_dir output_dir') - sys.exit(1) + sys.stderr.write('Excepted arguments: ./build_archive.py name extension install_dir output_dir') + sys.exit(1) package_name = sys.argv[1] extension = sys.argv[2] @@ -23,47 +23,46 @@ package_dir = package_name # remove existing package with the same name try: - if os.path.exists(package_archive): - os.remove(package_archive) - if os.path.exists(package_dir): - shutil.rmtree(package_dir) + if os.path.exists(package_archive): + os.remove(package_archive) + if os.path.exists(package_dir): + shutil.rmtree(package_dir) except: - sys.stderr.write('Failed to clean up old package files: ' + sys.exc_info()[0] + '\n') - sys.exit(1) + sys.stderr.write('Failed to clean up old package files: ' + sys.exc_info()[0] + '\n') + sys.exit(1) # create temporary package dir try: - shutil.copytree(install_dir, package_dir) + shutil.copytree(install_dir, package_dir) - for f in os.listdir(package_dir): - if f.startswith('makes'): - os.remove(os.path.join(package_dir, f)) + for f in os.listdir(package_dir): + if f.startswith('makes'): + os.remove(os.path.join(package_dir, f)) except: - sys.stderr.write('Failed to copy install directory: ' + sys.exc_info()[0] + '\n') - sys.exit(1) + sys.stderr.write('Failed to copy install directory: ' + sys.exc_info()[0] + '\n') + sys.exit(1) # create archive try: - if not os.path.exists(output_dir): - os.mkdir(output_dir) + if not os.path.exists(output_dir): + os.mkdir(output_dir) - if extension == 'zip': - archive_cmd = ['zip', '-9', '-r', package_archive, package_dir] - elif extension == 'tar.bz2': - archive_cmd = ['tar', 'cjf', package_archive, package_dir] - else: - sys.stderr.write('Unknown archive extension: ' + extension) - sys.exit(-1) + if extension == 'zip': + archive_cmd = ['zip', '-9', '-r', package_archive, package_dir] + elif extension == 'tar.bz2': + archive_cmd = ['tar', 'cjf', package_archive, package_dir] + else: + sys.stderr.write('Unknown archive extension: ' + extension) + sys.exit(-1) - subprocess.call(archive_cmd) + subprocess.call(archive_cmd) except: - sys.stderr.write('Failed to create package archive: ' + sys.exc_info()[0] + '\n') - sys.exit(1) + sys.stderr.write('Failed to create package archive: ' + sys.exc_info()[0] + '\n') + sys.exit(1) # empty temporary package dir try: - shutil.rmtree(package_dir) + shutil.rmtree(package_dir) except: - sys.stderr.write('Failed to clean up package directory: ' + sys.exc_info()[0] + '\n') - sys.exit(1) - + sys.stderr.write('Failed to clean up package directory: ' + sys.exc_info()[0] + '\n') + sys.exit(1) diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index f1be2ae9a64..e9154b59ebf 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -488,7 +488,7 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C copy_v3_v3(p3d_prev, p3d_cur); copy_v3_v3(p3d_cur, p3d_next); - if (i < tot) { + if (i + 1 < tot) { gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next); } } From 74a996c8691d8c58efa3aac7c8997e7a2ec36ca2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Mar 2011 23:53:19 +0000 Subject: [PATCH 009/261] fix [#26385] operator edit_properties return error --- release/scripts/startup/bl_operators/wm.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 7e73fa7b647..0563cd409ca 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -731,7 +731,12 @@ class WM_OT_properties_edit(bpy.types.Operator): data_path = self.data_path value = self.value prop = self.property - prop_old = self._last_prop[0] + + prop_old = getattr(self, "_last_prop", [None])[0] + + if prop_old is None: + self.report({'ERROR'}, "Direct execution not supported") + return {'CANCELLED'} try: value_eval = eval(value) @@ -771,6 +776,10 @@ class WM_OT_properties_edit(bpy.types.Operator): def invoke(self, context, event): + if not self.data_path: + self.report({'ERROR'}, "Data path not set") + return {'CANCELLED'} + self._last_prop = [self.property] item = eval("context.%s" % self.data_path) From f3686b58856adc6929ef38d14c03197127bab017 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 01:38:26 +0000 Subject: [PATCH 010/261] py/api registration: move calls to the classes register/unregister function into register_class() / unregister_class() and add docs. also other minor changes: - remove face sorting keybinding, was Ctrl+Alt+F, this is quite and obscure feature and face order normally doesn't matter, so access from Face menu is enough. - add commented out call to mesh.validate() in addon template since its useful to correct incomplete meshes during development. --- release/scripts/modules/bpy/utils.py | 9 +---- release/scripts/templates/addon_add_object.py | 8 ++-- source/blender/editors/mesh/mesh_ops.c | 1 - source/blender/python/intern/bpy_rna.c | 39 +++++++++++++++++++ 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index f4f7d065259..28e6ee991de 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -426,21 +426,19 @@ def _bpy_module_classes(module, is_registered=False): def register_module(module, verbose=False): if verbose: print("bpy.utils.register_module(%r): ..." % module) + cls = None for cls in _bpy_module_classes(module, is_registered=False): if verbose: print(" %r" % cls) try: register_class(cls) - cls_func = getattr(cls, "register", None) - if cls_func is not None: - cls_func() except: print("bpy.utils.register_module(): failed to registering class %r" % cls) import traceback traceback.print_exc() if verbose: print("done.\n") - if "cls" not in locals(): + if cls is None: raise Exception("register_module(%r): defines no classes" % module) @@ -452,9 +450,6 @@ def unregister_module(module, verbose=False): print(" %r" % cls) try: unregister_class(cls) - cls_func = getattr(cls, "unregister", None) - if cls_func is not None: - cls_func() except: print("bpy.utils.unregister_module(): failed to unregistering class %r" % cls) import traceback diff --git a/release/scripts/templates/addon_add_object.py b/release/scripts/templates/addon_add_object.py index f4f1185e282..67e033271f4 100644 --- a/release/scripts/templates/addon_add_object.py +++ b/release/scripts/templates/addon_add_object.py @@ -31,8 +31,10 @@ def add_object(self, context): edges = [] faces = [[0, 1, 2, 3]] - mesh_data = bpy.data.meshes.new(name='New Object Mesh') - mesh_data.from_pydata(verts, edges, faces) + mesh = bpy.data.meshes.new(name='New Object Mesh') + mesh.from_pydata(verts, edges, faces) + # useful for development when the mesh may be invalid. + # mesh.validate(verbose=True) add_object_data(context, mesh_data, operator=self) @@ -55,7 +57,7 @@ class OBJECT_OT_add_object(bpy.types.Operator, AddObjectHelper): return {'FINISHED'} -#### REGISTER #### +# Registration def add_object_button(self, context): self.layout.operator( diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index fc174f3c59c..1c10128cee8 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -282,7 +282,6 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0); - WM_keymap_add_item(keymap, "MESH_OT_sort_faces", FKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "MESH_OT_edge_flip", FKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 0b244943541..6ae38d66781 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -95,11 +95,13 @@ int pyrna_prop_validity_check(BPy_PropertyRNA *self) return -1; } +#if defined(USE_PYRNA_INVALIDATE_GC) || defined(USE_PYRNA_INVALIDATE_WEAKREF) static void pyrna_invalidate(BPy_DummyPointerRNA *self) { self->ptr.type= NULL; /* this is checked for validity */ self->ptr.id.data= NULL; /* should not be needed but prevent bad pointer access, just incase */ } +#endif #ifdef USE_PYRNA_INVALIDATE_GC #define FROM_GC(g) ((PyObject *)(((PyGC_Head *)g)+1)) @@ -6106,6 +6108,8 @@ static char pyrna_register_class_doc[] = "\n" " Register a subclass of a blender type in (:class:`Panel`, :class:`Menu`, :class:`Header`, :class:`Operator`, :class:`KeyingSetInfo`, :class:`RenderEngine`).\n" "\n" +" If the class has a *register* class method it will be called before registration.\n" +"\n" " .. note:: :exc:`ValueError` exception is raised if the class is not a subclass of a registerable blender class.\n" "\n" ; @@ -6118,6 +6122,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class StructRNA *srna; StructRNA *srna_new; const char *identifier; + PyObject *py_cls_meth; if(PyDict_GetItemString(((PyTypeObject*)py_class)->tp_dict, "bl_rna")) { PyErr_SetString(PyExc_AttributeError, "register_class(...): already registered as a subclass"); @@ -6145,6 +6150,22 @@ 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(); @@ -6210,6 +6231,8 @@ static char pyrna_unregister_class_doc[] = ".. method:: unregister_class(cls)\n" "\n" " Unload the python class from blender.\n" +"\n" +" If the class has an *unregister* class method it will be called before unregistering.\n" ; PyMethodDef meth_bpy_unregister_class= {"unregister_class", pyrna_unregister_class, METH_O, pyrna_unregister_class_doc}; static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_class) @@ -6217,6 +6240,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla bContext *C= NULL; StructUnregisterFunc unreg; StructRNA *srna; + PyObject *py_cls_meth; /*if(PyDict_GetItemString(((PyTypeObject*)py_class)->tp_dict, "bl_rna")==NULL) { PWM_cursor_wait(0); @@ -6236,6 +6260,21 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla return NULL; } + /* call classed register function */ + py_cls_meth= PyObject_GetAttrString(py_class, "unregister"); + if(py_cls_meth == NULL) { + PyErr_Clear(); + } + else { + PyObject *ret= PyObject_CallObject(py_cls_meth, NULL); + if(ret) { + Py_DECREF(ret); + } + else { + return NULL; + } + } + /* should happen all the time but very slow */ if(G.f & G_DEBUG) { /* remove all properties using this class */ From a503713d6ca238119a57d0c86d79480aeccf5642 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Tue, 22 Mar 2011 01:40:22 +0000 Subject: [PATCH 011/261] Moving netrender to addons --- release/scripts/io/netrender/__init__.py | 73 -- release/scripts/io/netrender/balancing.py | 195 ---- release/scripts/io/netrender/client.py | 372 ------- release/scripts/io/netrender/master.py | 1079 ------------------- release/scripts/io/netrender/master_html.py | 315 ------ release/scripts/io/netrender/model.py | 360 ------- release/scripts/io/netrender/netrender.css | 88 -- release/scripts/io/netrender/netrender.js | 146 --- release/scripts/io/netrender/operators.py | 564 ---------- release/scripts/io/netrender/repath.py | 150 --- release/scripts/io/netrender/slave.py | 349 ------ release/scripts/io/netrender/thumbnail.py | 81 -- release/scripts/io/netrender/ui.py | 543 ---------- release/scripts/io/netrender/utils.py | 313 ------ release/scripts/io/netrender/versioning.py | 72 -- 15 files changed, 4700 deletions(-) delete mode 100644 release/scripts/io/netrender/__init__.py delete mode 100644 release/scripts/io/netrender/balancing.py delete mode 100644 release/scripts/io/netrender/client.py delete mode 100644 release/scripts/io/netrender/master.py delete mode 100644 release/scripts/io/netrender/master_html.py delete mode 100644 release/scripts/io/netrender/model.py delete mode 100644 release/scripts/io/netrender/netrender.css delete mode 100644 release/scripts/io/netrender/netrender.js delete mode 100644 release/scripts/io/netrender/operators.py delete mode 100644 release/scripts/io/netrender/repath.py delete mode 100644 release/scripts/io/netrender/slave.py delete mode 100644 release/scripts/io/netrender/thumbnail.py delete mode 100644 release/scripts/io/netrender/ui.py delete mode 100644 release/scripts/io/netrender/utils.py delete mode 100644 release/scripts/io/netrender/versioning.py diff --git a/release/scripts/io/netrender/__init__.py b/release/scripts/io/netrender/__init__.py deleted file mode 100644 index c77894d4751..00000000000 --- a/release/scripts/io/netrender/__init__.py +++ /dev/null @@ -1,73 +0,0 @@ -# ##### 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 ##### - -# This directory is a Python package. - -# To support reload properly, try to access a package var, if it's there, reload everything -if "init_data" in locals(): - import imp - imp.reload(model) - imp.reload(operators) - imp.reload(client) - imp.reload(slave) - imp.reload(master) - imp.reload(master_html) - imp.reload(utils) - imp.reload(balancing) - imp.reload(ui) - imp.reload(repath) - imp.reload(versioning) -else: - from . import model - from . import operators - from . import client - from . import slave - from . import master - from . import master_html - from . import utils - from . import balancing - from . import ui - from . import repath - from . import versioning - -jobs = [] -slaves = [] -blacklist = [] - -init_file = "" -valid_address = False -init_data = True - - -def register(): - ui.addProperties() - - import bpy - scene = bpy.context.scene - if scene: - netsettings = scene.network_render - ui.init_data(netsettings) - - bpy.utils.register_module(__name__) - - -def unregister(): - import bpy - del bpy.types.Scene.network_render - - bpy.utils.unregister_module(__name__) diff --git a/release/scripts/io/netrender/balancing.py b/release/scripts/io/netrender/balancing.py deleted file mode 100644 index dde3ad53084..00000000000 --- a/release/scripts/io/netrender/balancing.py +++ /dev/null @@ -1,195 +0,0 @@ -# ##### 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 ##### - -import time - -from netrender.utils import * -import netrender.model - -class RatingRule: - def __init__(self): - self.enabled = True - - def id(self): - return str(id(self)) - - def rate(self, job): - return 0 - -class ExclusionRule: - def __init__(self): - self.enabled = True - - def id(self): - return str(id(self)) - - def test(self, job): - return False - -class PriorityRule: - def __init__(self): - self.enabled = True - - def id(self): - return str(id(self)) - - def test(self, job): - return False - -class Balancer: - def __init__(self): - self.rules = [] - self.priorities = [] - self.exceptions = [] - - def ruleByID(self, rule_id): - for rule in self.rules: - if rule.id() == rule_id: - return rule - for rule in self.priorities: - if rule.id() == rule_id: - return rule - for rule in self.exceptions: - if rule.id() == rule_id: - return rule - - return None - - def addRule(self, rule): - self.rules.append(rule) - - def addPriority(self, priority): - self.priorities.append(priority) - - def addException(self, exception): - self.exceptions.append(exception) - - def applyRules(self, job): - return sum((rule.rate(job) for rule in self.rules if rule.enabled)) - - def applyPriorities(self, job): - for priority in self.priorities: - if priority.enabled and priority.test(job): - return True # priorities are first - - return False - - def applyExceptions(self, job): - for exception in self.exceptions: - if exception.enabled and exception.test(job): - return True # exceptions are last - - return False - - def sortKey(self, job): - return (1 if self.applyExceptions(job) else 0, # exceptions after - 0 if self.applyPriorities(job) else 1, # priorities first - self.applyRules(job)) - - def balance(self, jobs): - if jobs: - # use inline copy to make sure the list is still accessible while sorting - jobs[:] = sorted(jobs, key=self.sortKey) - return jobs[0] - else: - return None - -# ========================== - -class RatingUsage(RatingRule): - def __str__(self): - return "Usage per job" - - def rate(self, job): - # less usage is better - return job.usage / job.priority - -class RatingUsageByCategory(RatingRule): - def __init__(self, get_jobs): - super().__init__() - self.getJobs = get_jobs - - def __str__(self): - return "Usage per category" - - def rate(self, job): - total_category_usage = sum([j.usage for j in self.getJobs() if j.category == job.category]) - maximum_priority = max([j.priority for j in self.getJobs() if j.category == job.category]) - - # less usage is better - return total_category_usage / maximum_priority - -class NewJobPriority(PriorityRule): - def __init__(self, limit = 1): - super().__init__() - self.limit = limit - - def setLimit(self, value): - self.limit = int(value) - - def str_limit(self): - return "less than %i frame%s done" % (self.limit, "s" if self.limit > 1 else "") - - def __str__(self): - return "Priority to new jobs" - - def test(self, job): - return job.countFrames(status = DONE) < self.limit - -class MinimumTimeBetweenDispatchPriority(PriorityRule): - def __init__(self, limit = 10): - super().__init__() - self.limit = limit - - def setLimit(self, value): - self.limit = int(value) - - def str_limit(self): - return "more than %i minute%s since last" % (self.limit, "s" if self.limit > 1 else "") - - def __str__(self): - return "Priority to jobs that haven't been dispatched recently" - - def test(self, job): - return job.countFrames(status = DISPATCHED) == 0 and (time.time() - job.last_dispatched) / 60 > self.limit - -class ExcludeQueuedEmptyJob(ExclusionRule): - def __str__(self): - return "Exclude non queued or empty jobs" - - def test(self, job): - return job.status != JOB_QUEUED or job.countFrames(status = QUEUED) == 0 - -class ExcludeSlavesLimit(ExclusionRule): - def __init__(self, count_jobs, count_slaves, limit = 0.75): - super().__init__() - self.count_jobs = count_jobs - self.count_slaves = count_slaves - self.limit = limit - - def setLimit(self, value): - self.limit = float(value) - - def str_limit(self): - return "more than %.0f%% of all slaves" % (self.limit * 100) - - def __str__(self): - return "Exclude jobs that would use too many slaves" - - def test(self, job): - return not ( self.count_jobs() == 1 or self.count_slaves() <= 1 or float(job.countSlaves() + 1) / self.count_slaves() <= self.limit ) diff --git a/release/scripts/io/netrender/client.py b/release/scripts/io/netrender/client.py deleted file mode 100644 index bc43b8cfbb7..00000000000 --- a/release/scripts/io/netrender/client.py +++ /dev/null @@ -1,372 +0,0 @@ -# ##### 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 ##### - -import bpy -import sys, os, re -import http, http.client, http.server, urllib -import subprocess, shutil, time, hashlib -import json - -import netrender -import netrender.model -import netrender.slave as slave -import netrender.master as master -from netrender.utils import * - -def addFluidFiles(job, path): - if os.path.exists(path): - pattern = re.compile("fluidsurface_(final|preview)_([0-9]+)\.(bobj|bvel)\.gz") - - for fluid_file in sorted(os.listdir(path)): - match = pattern.match(fluid_file) - - if match: - # fluid frames starts at 0, which explains the +1 - # This is stupid - current_frame = int(match.groups()[1]) + 1 - job.addFile(path + fluid_file, current_frame, current_frame) - -def addPointCache(job, ob, point_cache, default_path): - if not point_cache.use_disk_cache: - return - - - name = point_cache.name - if name == "": - name = "".join(["%02X" % ord(c) for c in ob.name]) - - cache_path = bpy.path.abspath(point_cache.filepath) if point_cache.use_external else default_path - - index = "%02i" % point_cache.index - - if os.path.exists(cache_path): - pattern = re.compile(name + "_([0-9]+)_" + index + "\.bphys") - - cache_files = [] - - for cache_file in sorted(os.listdir(cache_path)): - match = pattern.match(cache_file) - - if match: - cache_frame = int(match.groups()[0]) - cache_files.append((cache_frame, cache_file)) - - cache_files.sort() - - if len(cache_files) == 1: - cache_frame, cache_file = cache_files[0] - job.addFile(cache_path + cache_file, cache_frame, cache_frame) - else: - for i in range(len(cache_files)): - current_item = cache_files[i] - next_item = cache_files[i+1] if i + 1 < len(cache_files) else None - previous_item = cache_files[i - 1] if i > 0 else None - - current_frame, current_file = current_item - - if not next_item and not previous_item: - job.addFile(cache_path + current_file, current_frame, current_frame) - elif next_item and not previous_item: - next_frame = next_item[0] - job.addFile(cache_path + current_file, current_frame, next_frame - 1) - elif not next_item and previous_item: - previous_frame = previous_item[0] - job.addFile(cache_path + current_file, previous_frame + 1, current_frame) - else: - next_frame = next_item[0] - previous_frame = previous_item[0] - job.addFile(cache_path + current_file, previous_frame + 1, next_frame - 1) - -def fillCommonJobSettings(job, job_name, netsettings): - job.name = job_name - job.category = netsettings.job_category - - for slave in netrender.blacklist: - job.blacklist.append(slave.id) - - job.chunks = netsettings.chunks - job.priority = netsettings.priority - - if netsettings.job_type == "JOB_BLENDER": - job.type = netrender.model.JOB_BLENDER - elif netsettings.job_type == "JOB_PROCESS": - job.type = netrender.model.JOB_PROCESS - elif netsettings.job_type == "JOB_VCS": - job.type = netrender.model.JOB_VCS - -def clientSendJob(conn, scene, anim = False): - netsettings = scene.network_render - if netsettings.job_type == "JOB_BLENDER": - return clientSendJobBlender(conn, scene, anim) - elif netsettings.job_type == "JOB_VCS": - return clientSendJobVCS(conn, scene, anim) - -def clientSendJobVCS(conn, scene, anim = False): - netsettings = scene.network_render - job = netrender.model.RenderJob() - - if anim: - for f in range(scene.frame_start, scene.frame_end + 1): - job.addFrame(f) - else: - job.addFrame(scene.frame_current) - - filename = bpy.data.filepath - - if not filename.startswith(netsettings.vcs_wpath): - # this is an error, need better way to handle this - return - - filename = filename[len(netsettings.vcs_wpath):] - - if filename[0] in (os.sep, os.altsep): - filename = filename[1:] - - print("CREATING VCS JOB", filename) - - job.addFile(filename, signed=False) - - job_name = netsettings.job_name - path, name = os.path.split(filename) - if job_name == "[default]": - job_name = name - - - fillCommonJobSettings(job, job_name, netsettings) - - # VCS Specific code - job.version_info = netrender.model.VersioningInfo() - job.version_info.system = netsettings.vcs_system - job.version_info.wpath = netsettings.vcs_wpath - job.version_info.rpath = netsettings.vcs_rpath - job.version_info.revision = netsettings.vcs_revision - - # try to send path first - conn.request("POST", "/job", json.dumps(job.serialize())) - response = conn.getresponse() - response.read() - - job_id = response.getheader("job-id") - - # a VCS job is always good right now, need error handling - - return job_id - -def clientSendJobBlender(conn, scene, anim = False): - netsettings = scene.network_render - job = netrender.model.RenderJob() - - if anim: - for f in range(scene.frame_start, scene.frame_end + 1): - job.addFrame(f) - else: - job.addFrame(scene.frame_current) - - filename = bpy.data.filepath - job.addFile(filename) - - job_name = netsettings.job_name - path, name = os.path.split(filename) - if job_name == "[default]": - job_name = name - - ########################### - # LIBRARIES - ########################### - for lib in bpy.data.libraries: - file_path = bpy.path.abspath(lib.filepath) - if os.path.exists(file_path): - job.addFile(file_path) - - ########################### - # IMAGES - ########################### - for image in bpy.data.images: - if image.source == "FILE" and not image.packed_file: - file_path = bpy.path.abspath(image.filepath) - if os.path.exists(file_path): - job.addFile(file_path) - - tex_path = os.path.splitext(file_path)[0] + ".tex" - if os.path.exists(tex_path): - job.addFile(tex_path) - - ########################### - # FLUID + POINT CACHE - ########################### - root, ext = os.path.splitext(name) - default_path = path + os.sep + "blendcache_" + root + os.sep # need an API call for that - - for object in bpy.data.objects: - for modifier in object.modifiers: - if modifier.type == 'FLUID_SIMULATION' and modifier.settings.type == "DOMAIN": - addFluidFiles(job, bpy.path.abspath(modifier.settings.filepath)) - elif modifier.type == "CLOTH": - addPointCache(job, object, modifier.point_cache, default_path) - elif modifier.type == "SOFT_BODY": - addPointCache(job, object, modifier.point_cache, default_path) - elif modifier.type == "SMOKE" and modifier.smoke_type == "TYPE_DOMAIN": - addPointCache(job, object, modifier.domain_settings.point_cache, default_path) - elif modifier.type == "MULTIRES" and modifier.is_external: - file_path = bpy.path.abspath(modifier.filepath) - job.addFile(file_path) - - # particles modifier are stupid and don't contain data - # we have to go through the object property - for psys in object.particle_systems: - addPointCache(job, object, psys.point_cache, default_path) - - #print(job.files) - - fillCommonJobSettings(job, job_name, netsettings) - - # try to send path first - conn.request("POST", "/job", json.dumps(job.serialize())) - response = conn.getresponse() - response.read() - - job_id = response.getheader("job-id") - - # if not ACCEPTED (but not processed), send files - if response.status == http.client.ACCEPTED: - for rfile in job.files: - f = open(rfile.filepath, "rb") - conn.request("PUT", fileURL(job_id, rfile.index), f) - f.close() - response = conn.getresponse() - response.read() - - # server will reply with ACCEPTED until all files are found - - return job_id - -def requestResult(conn, job_id, frame): - conn.request("GET", renderURL(job_id, frame)) - -class NetworkRenderEngine(bpy.types.RenderEngine): - bl_idname = 'NET_RENDER' - bl_label = "Network Render" - bl_use_postprocess = False - def render(self, scene): - if scene.network_render.mode == "RENDER_CLIENT": - self.render_client(scene) - elif scene.network_render.mode == "RENDER_SLAVE": - self.render_slave(scene) - elif scene.network_render.mode == "RENDER_MASTER": - self.render_master(scene) - else: - print("UNKNOWN OPERATION MODE") - - def render_master(self, scene): - netsettings = scene.network_render - - address = "" if netsettings.server_address == "[default]" else netsettings.server_address - - master.runMaster((address, netsettings.server_port), netsettings.use_master_broadcast, netsettings.use_master_clear, bpy.path.abspath(netsettings.path), self.update_stats, self.test_break) - - - def render_slave(self, scene): - slave.render_slave(self, scene.network_render, scene.render.threads) - - def render_client(self, scene): - netsettings = scene.network_render - self.update_stats("", "Network render client initiation") - - - conn = clientConnection(netsettings.server_address, netsettings.server_port) - - if conn: - # Sending file - - self.update_stats("", "Network render exporting") - - new_job = False - - job_id = netsettings.job_id - - # reading back result - - self.update_stats("", "Network render waiting for results") - - - requestResult(conn, job_id, scene.frame_current) - response = conn.getresponse() - buf = response.read() - - if response.status == http.client.NO_CONTENT: - new_job = True - netsettings.job_id = clientSendJob(conn, scene) - job_id = netsettings.job_id - - requestResult(conn, job_id, scene.frame_current) - response = conn.getresponse() - buf = response.read() - - while response.status == http.client.ACCEPTED and not self.test_break(): - time.sleep(1) - requestResult(conn, job_id, scene.frame_current) - response = conn.getresponse() - buf = response.read() - - # cancel new jobs (animate on network) on break - if self.test_break() and new_job: - conn.request("POST", cancelURL(job_id)) - response = conn.getresponse() - response.read() - print( response.status, response.reason ) - netsettings.job_id = 0 - - if response.status != http.client.OK: - conn.close() - return - - r = scene.render - x= int(r.resolution_x*r.resolution_percentage*0.01) - y= int(r.resolution_y*r.resolution_percentage*0.01) - - result_path = os.path.join(bpy.path.abspath(netsettings.path), "output.exr") - - folder = os.path.split(result_path)[0] - - if not os.path.exists(folder): - os.mkdir(folder) - - f = open(result_path, "wb") - - f.write(buf) - - f.close() - - result = self.begin_result(0, 0, x, y) - result.load_from_file(result_path) - self.end_result(result) - - conn.close() - -def compatible(module): - module = __import__(module) - for subclass in module.__dict__.values(): - try: subclass.COMPAT_ENGINES.add('NET_RENDER') - except: pass - del module - -compatible("properties_world") -compatible("properties_material") -compatible("properties_data_mesh") -compatible("properties_data_camera") -compatible("properties_texture") diff --git a/release/scripts/io/netrender/master.py b/release/scripts/io/netrender/master.py deleted file mode 100644 index 793e3bb51bf..00000000000 --- a/release/scripts/io/netrender/master.py +++ /dev/null @@ -1,1079 +0,0 @@ -# ##### 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 ##### - -import sys, os -import http, http.client, http.server, urllib, socket, socketserver, threading -import subprocess, shutil, time, hashlib -import pickle -import select # for select.error -import json - -from netrender.utils import * -import netrender.model -import netrender.balancing -import netrender.master_html -import netrender.thumbnail as thumbnail - -class MRenderFile(netrender.model.RenderFile): - def __init__(self, filepath, index, start, end, signature): - super().__init__(filepath, index, start, end, signature) - self.found = False - - def test(self): - self.found = os.path.exists(self.filepath) - if self.found and self.signature != None: - found_signature = hashFile(self.filepath) - self.found = self.signature == found_signature - - return self.found - - -class MRenderSlave(netrender.model.RenderSlave): - def __init__(self, name, address, stats): - super().__init__() - self.id = hashlib.md5(bytes(repr(name) + repr(address), encoding='utf8')).hexdigest() - self.name = name - self.address = address - self.stats = stats - self.last_seen = time.time() - - self.job = None - self.job_frames = [] - - netrender.model.RenderSlave._slave_map[self.id] = self - - def seen(self): - self.last_seen = time.time() - - def finishedFrame(self, frame_number): - self.job_frames.remove(frame_number) - if not self.job_frames: - self.job = None - -class MRenderJob(netrender.model.RenderJob): - def __init__(self, job_id, job_info): - super().__init__(job_info) - self.id = job_id - self.last_dispatched = time.time() - - # force one chunk for process jobs - if self.type == netrender.model.JOB_PROCESS: - self.chunks = 1 - - # Force WAITING status on creation - self.status = JOB_WAITING - - # special server properties - self.last_update = 0 - self.save_path = "" - self.files = [MRenderFile(rfile.filepath, rfile.index, rfile.start, rfile.end, rfile.signature) for rfile in job_info.files] - - def initInfo(self): - if not self.resolution: - self.resolution = tuple(getFileInfo(self.files[0].filepath, ["bpy.context.scene.render.resolution_x", "bpy.context.scene.render.resolution_y", "bpy.context.scene.render.resolution_percentage"])) - - def save(self): - if self.save_path: - f = open(os.path.join(self.save_path, "job.txt"), "w") - f.write(json.dumps(self.serialize())) - f.close() - - def edit(self, info_map): - if "status" in info_map: - self.status = info_map["status"] - - if "priority" in info_map: - self.priority = info_map["priority"] - - if "chunks" in info_map: - self.chunks = info_map["chunks"] - - def testStart(self): - # Don't test files for versionned jobs - if not self.version_info: - for f in self.files: - if not f.test(): - return False - - self.start() - self.initInfo() - return True - - def testFinished(self): - for f in self.frames: - if f.status == QUEUED or f.status == DISPATCHED: - break - else: - self.status = JOB_FINISHED - - def pause(self, status = None): - if self.status not in {JOB_PAUSED, JOB_QUEUED}: - return - - if status is None: - self.status = JOB_PAUSED if self.status == JOB_QUEUED else JOB_QUEUED - elif status: - self.status = JOB_QUEUED - else: - self.status = JOB_PAUSED - - def start(self): - self.status = JOB_QUEUED - - def addLog(self, frames): - log_name = "_".join(("%06d" % f for f in frames)) + ".log" - log_path = os.path.join(self.save_path, log_name) - - for number in frames: - frame = self[number] - if frame: - frame.log_path = log_path - - def addFrame(self, frame_number, command): - frame = MRenderFrame(frame_number, command) - self.frames.append(frame) - return frame - - def reset(self, all): - for f in self.frames: - f.reset(all) - - def getFrames(self): - frames = [] - for f in self.frames: - if f.status == QUEUED: - self.last_dispatched = time.time() - frames.append(f) - if len(frames) >= self.chunks: - break - - return frames - -class MRenderFrame(netrender.model.RenderFrame): - def __init__(self, frame, command): - super().__init__() - self.number = frame - self.slave = None - self.time = 0 - self.status = QUEUED - self.command = command - - self.log_path = None - - def reset(self, all): - if all or self.status == ERROR: - self.log_path = None - self.slave = None - self.time = 0 - self.status = QUEUED - - -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -file_pattern = re.compile("/file_([a-zA-Z0-9]+)_([0-9]+)") -render_pattern = re.compile("/render_([a-zA-Z0-9]+)_([0-9]+).exr") -thumb_pattern = re.compile("/thumb_([a-zA-Z0-9]+)_([0-9]+).jpg") -log_pattern = re.compile("/log_([a-zA-Z0-9]+)_([0-9]+).log") -reset_pattern = re.compile("/reset(all|)_([a-zA-Z0-9]+)_([0-9]+)") -cancel_pattern = re.compile("/cancel_([a-zA-Z0-9]+)") -pause_pattern = re.compile("/pause_([a-zA-Z0-9]+)") -edit_pattern = re.compile("/edit_([a-zA-Z0-9]+)") - -class RenderHandler(http.server.BaseHTTPRequestHandler): - def log_message(self, format, *args): - # override because the original calls self.address_string(), which - # is extremely slow due to some timeout.. - sys.stderr.write("[%s] %s\n" % (self.log_date_time_string(), format%args)) - - def getInfoMap(self): - length = int(self.headers['content-length']) - - if length > 0: - msg = str(self.rfile.read(length), encoding='utf8') - return json.loads(msg) - else: - return {} - - def send_head(self, code = http.client.OK, headers = {}, content = "application/octet-stream"): - self.send_response(code) - self.send_header("Content-type", content) - - for key, value in headers.items(): - self.send_header(key, value) - - self.end_headers() - - def do_HEAD(self): - - if self.path == "/status": - job_id = self.headers.get('job-id', "") - job_frame = int(self.headers.get('job-frame', -1)) - - job = self.server.getJobID(job_id) - if job: - frame = job[job_frame] - - - if frame: - self.send_head(http.client.OK) - else: - # no such frame - self.send_head(http.client.NO_CONTENT) - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - def do_GET(self): - - if self.path == "/version": - self.send_head() - self.server.stats("", "Version check") - self.wfile.write(VERSION) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path.startswith("/render"): - match = render_pattern.match(self.path) - - if match: - job_id = match.groups()[0] - frame_number = int(match.groups()[1]) - - job = self.server.getJobID(job_id) - - if job: - frame = job[frame_number] - - if frame: - if frame.status in (QUEUED, DISPATCHED): - self.send_head(http.client.ACCEPTED) - elif frame.status == DONE: - self.server.stats("", "Sending result to client") - - filename = os.path.join(job.save_path, "%06d.exr" % frame_number) - - f = open(filename, 'rb') - self.send_head(content = "image/x-exr") - shutil.copyfileobj(f, self.wfile) - f.close() - elif frame.status == ERROR: - self.send_head(http.client.PARTIAL_CONTENT) - else: - # no such frame - self.send_head(http.client.NO_CONTENT) - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - else: - # invalid url - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path.startswith("/thumb"): - match = thumb_pattern.match(self.path) - - if match: - job_id = match.groups()[0] - frame_number = int(match.groups()[1]) - - job = self.server.getJobID(job_id) - - if job: - frame = job[frame_number] - - if frame: - if frame.status in (QUEUED, DISPATCHED): - self.send_head(http.client.ACCEPTED) - elif frame.status == DONE: - filename = os.path.join(job.save_path, "%06d.exr" % frame_number) - - thumbname = thumbnail.generate(filename) - - if thumbname: - f = open(thumbname, 'rb') - self.send_head(content = "image/jpeg") - shutil.copyfileobj(f, self.wfile) - f.close() - else: # thumbnail couldn't be generated - self.send_head(http.client.PARTIAL_CONTENT) - return - elif frame.status == ERROR: - self.send_head(http.client.PARTIAL_CONTENT) - else: - # no such frame - self.send_head(http.client.NO_CONTENT) - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - else: - # invalid url - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path.startswith("/log"): - match = log_pattern.match(self.path) - - if match: - job_id = match.groups()[0] - frame_number = int(match.groups()[1]) - - job = self.server.getJobID(job_id) - - if job: - frame = job[frame_number] - - if frame: - if not frame.log_path or frame.status in (QUEUED, DISPATCHED): - self.send_head(http.client.PROCESSING) - else: - self.server.stats("", "Sending log to client") - f = open(frame.log_path, 'rb') - - self.send_head(content = "text/plain") - - shutil.copyfileobj(f, self.wfile) - - f.close() - else: - # no such frame - self.send_head(http.client.NO_CONTENT) - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - else: - # invalid URL - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/status": - job_id = self.headers.get('job-id', "") - job_frame = int(self.headers.get('job-frame', -1)) - - if job_id: - - job = self.server.getJobID(job_id) - if job: - if job_frame != -1: - frame = job[frame] - - if frame: - message = frame.serialize() - else: - # no such frame - self.send_heat(http.client.NO_CONTENT) - return - else: - message = job.serialize() - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - return - else: # status of all jobs - message = [] - - for job in self.server: - message.append(job.serialize()) - - - self.server.stats("", "Sending status") - self.send_head() - self.wfile.write(bytes(json.dumps(message), encoding='utf8')) - - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/job": - self.server.balance() - - slave_id = self.headers['slave-id'] - - slave = self.server.getSeenSlave(slave_id) - - if slave: # only if slave id is valid - job, frames = self.server.newDispatch(slave_id) - - if job and frames: - for f in frames: - print("dispatch", f.number) - f.status = DISPATCHED - f.slave = slave - - slave.job = job - slave.job_frames = [f.number for f in frames] - - self.send_head(headers={"job-id": job.id}) - - message = job.serialize(frames) - - self.wfile.write(bytes(json.dumps(message), encoding='utf8')) - - self.server.stats("", "Sending job to slave") - else: - # no job available, return error code - slave.job = None - slave.job_frames = [] - - self.send_head(http.client.ACCEPTED) - else: # invalid slave id - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path.startswith("/file"): - match = file_pattern.match(self.path) - - if match: - slave_id = self.headers['slave-id'] - slave = self.server.getSeenSlave(slave_id) - - if not slave: - # invalid slave id - print("invalid slave id") - - job_id = match.groups()[0] - file_index = int(match.groups()[1]) - - job = self.server.getJobID(job_id) - - if job: - render_file = job.files[file_index] - - if render_file: - self.server.stats("", "Sending file to slave") - f = open(render_file.filepath, 'rb') - - self.send_head() - shutil.copyfileobj(f, self.wfile) - - f.close() - else: - # no such file - self.send_head(http.client.NO_CONTENT) - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - else: # invalid url - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/slaves": - message = [] - - self.server.stats("", "Sending slaves status") - - for slave in self.server.slaves: - message.append(slave.serialize()) - - self.send_head() - - self.wfile.write(bytes(json.dumps(message), encoding='utf8')) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - else: - # hand over the rest to the html section - netrender.master_html.get(self) - - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - def do_POST(self): - - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - if self.path == "/job": - - length = int(self.headers['content-length']) - - job_info = netrender.model.RenderJob.materialize(json.loads(str(self.rfile.read(length), encoding='utf8'))) - - job_id = self.server.nextJobID() - - job = MRenderJob(job_id, job_info) - - for frame in job_info.frames: - frame = job.addFrame(frame.number, frame.command) - - self.server.addJob(job) - - headers={"job-id": job_id} - - if job.testStart(): - self.server.stats("", "New job, started") - self.send_head(headers=headers) - else: - self.server.stats("", "New job, missing files (%i total)" % len(job.files)) - self.send_head(http.client.ACCEPTED, headers=headers) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path.startswith("/edit"): - match = edit_pattern.match(self.path) - - if match: - job_id = match.groups()[0] - - job = self.server.getJobID(job_id) - - if job: - info_map = self.getInfoMap() - - job.edit(info_map) - self.send_head() - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - else: - # invalid url - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/balance_limit": - info_map = self.getInfoMap() - for rule_id, limit in info_map.items(): - try: - rule = self.server.balancer.ruleByID(rule_id) - if rule: - rule.setLimit(limit) - except: - pass # invalid type - - self.send_head() - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/balance_enable": - info_map = self.getInfoMap() - for rule_id, enabled in info_map.items(): - rule = self.server.balancer.ruleByID(rule_id) - if rule: - rule.enabled = enabled - - self.send_head() - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path.startswith("/cancel"): - match = cancel_pattern.match(self.path) - - if match: - info_map = self.getInfoMap() - clear = info_map.get("clear", False) - - job_id = match.groups()[0] - - job = self.server.getJobID(job_id) - - if job: - self.server.stats("", "Cancelling job") - self.server.removeJob(job, clear) - self.send_head() - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - else: - # invalid url - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path.startswith("/pause"): - match = pause_pattern.match(self.path) - - if match: - info_map = self.getInfoMap() - status = info_map.get("status", None) - - job_id = match.groups()[0] - - job = self.server.getJobID(job_id) - - if job: - self.server.stats("", "Pausing job") - job.pause(status) - self.send_head() - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - else: - # invalid url - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/clear": - # cancel all jobs - info_map = self.getInfoMap() - clear = info_map.get("clear", False) - - self.server.stats("", "Clearing jobs") - self.server.clear(clear) - - self.send_head() - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path.startswith("/reset"): - match = reset_pattern.match(self.path) - - if match: - all = match.groups()[0] == 'all' - job_id = match.groups()[1] - job_frame = int(match.groups()[2]) - - job = self.server.getJobID(job_id) - - if job: - if job_frame != 0: - - frame = job[job_frame] - if frame: - self.server.stats("", "Reset job frame") - frame.reset(all) - self.send_head() - else: - # no such frame - self.send_head(http.client.NO_CONTENT) - - else: - self.server.stats("", "Reset job") - job.reset(all) - self.send_head() - - else: # job not found - self.send_head(http.client.NO_CONTENT) - else: # invalid url - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/slave": - length = int(self.headers['content-length']) - job_frame_string = self.headers['job-frame'] - - self.server.stats("", "New slave connected") - - slave_info = netrender.model.RenderSlave.materialize(json.loads(str(self.rfile.read(length), encoding='utf8')), cache = False) - - slave_id = self.server.addSlave(slave_info.name, self.client_address, slave_info.stats) - - self.send_head(headers = {"slave-id": slave_id}) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/log": - length = int(self.headers['content-length']) - - log_info = netrender.model.LogFile.materialize(json.loads(str(self.rfile.read(length), encoding='utf8'))) - - slave_id = log_info.slave_id - - slave = self.server.getSeenSlave(slave_id) - - if slave: # only if slave id is valid - job = self.server.getJobID(log_info.job_id) - - if job: - self.server.stats("", "Log announcement") - job.addLog(log_info.frames) - self.send_head(http.client.OK) - else: - # no such job id - self.send_head(http.client.NO_CONTENT) - else: # invalid slave id - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - def do_PUT(self): - - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - if self.path.startswith("/file"): - match = file_pattern.match(self.path) - - if match: - self.server.stats("", "Receiving job") - - length = int(self.headers['content-length']) - job_id = match.groups()[0] - file_index = int(match.groups()[1]) - - job = self.server.getJobID(job_id) - - if job: - - render_file = job.files[file_index] - - if render_file: - main_file = job.files[0].filepath # filename of the first file - - main_path, main_name = os.path.split(main_file) - - if file_index > 0: - file_path = prefixPath(job.save_path, render_file.filepath, main_path) - else: - file_path = os.path.join(job.save_path, main_name) - - buf = self.rfile.read(length) - - # add same temp file + renames as slave - - f = open(file_path, "wb") - f.write(buf) - f.close() - del buf - - render_file.filepath = file_path # set the new path - - if job.testStart(): - self.server.stats("", "File upload, starting job") - self.send_head(http.client.OK) - else: - self.server.stats("", "File upload, file missings") - self.send_head(http.client.ACCEPTED) - else: # invalid file - print("file not found", job_id, file_index) - self.send_head(http.client.NO_CONTENT) - else: # job not found - print("job not found", job_id, file_index) - self.send_head(http.client.NO_CONTENT) - else: # invalid url - print("no match") - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/render": - self.server.stats("", "Receiving render result") - - # need some message content here or the slave doesn't like it - self.wfile.write(bytes("foo", encoding='utf8')) - - slave_id = self.headers['slave-id'] - - slave = self.server.getSeenSlave(slave_id) - - if slave: # only if slave id is valid - job_id = self.headers['job-id'] - - job = self.server.getJobID(job_id) - - if job: - job_frame = int(self.headers['job-frame']) - job_result = int(self.headers['job-result']) - job_time = float(self.headers['job-time']) - - frame = job[job_frame] - - if frame: - if job.hasRenderResult(): - if job_result == DONE: - length = int(self.headers['content-length']) - buf = self.rfile.read(length) - f = open(os.path.join(job.save_path, "%06d.exr" % job_frame), 'wb') - f.write(buf) - f.close() - - del buf - elif job_result == ERROR: - # blacklist slave on this job on error - # slaves might already be in blacklist if errors on the whole chunk - if not slave.id in job.blacklist: - job.blacklist.append(slave.id) - - slave.finishedFrame(job_frame) - - frame.status = job_result - frame.time = job_time - - job.testFinished() - - self.send_head() - else: # frame not found - self.send_head(http.client.NO_CONTENT) - else: # job not found - self.send_head(http.client.NO_CONTENT) - else: # invalid slave id - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path == "/thumb": - self.server.stats("", "Receiving thumbnail result") - - # need some message content here or the slave doesn't like it - self.wfile.write(bytes("foo", encoding='utf8')) - - slave_id = self.headers['slave-id'] - - slave = self.server.getSeenSlave(slave_id) - - if slave: # only if slave id is valid - job_id = self.headers['job-id'] - - job = self.server.getJobID(job_id) - - if job: - job_frame = int(self.headers['job-frame']) - - frame = job[job_frame] - - if frame: - if job.hasRenderResult(): - length = int(self.headers['content-length']) - buf = self.rfile.read(length) - f = open(os.path.join(job.save_path, "%06d.jpg" % job_frame), 'wb') - f.write(buf) - f.close() - - del buf - - else: # frame not found - self.send_head(http.client.NO_CONTENT) - else: # job not found - self.send_head(http.client.NO_CONTENT) - else: # invalid slave id - self.send_head(http.client.NO_CONTENT) - # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - elif self.path.startswith("/log"): - self.server.stats("", "Receiving log file") - - match = log_pattern.match(self.path) - - if match: - job_id = match.groups()[0] - - job = self.server.getJobID(job_id) - - if job: - job_frame = int(match.groups()[1]) - - frame = job[job_frame] - - if frame and frame.log_path: - length = int(self.headers['content-length']) - buf = self.rfile.read(length) - f = open(frame.log_path, 'ab') - f.write(buf) - f.close() - - del buf - - self.server.getSeenSlave(self.headers['slave-id']) - - self.send_head() - else: # frame not found - self.send_head(http.client.NO_CONTENT) - else: # job not found - self.send_head(http.client.NO_CONTENT) - else: # invalid url - self.send_head(http.client.NO_CONTENT) - -class RenderMasterServer(socketserver.ThreadingMixIn, http.server.HTTPServer): - def __init__(self, address, handler_class, path, subdir=True): - super().__init__(address, handler_class) - self.jobs = [] - self.jobs_map = {} - self.slaves = [] - self.slaves_map = {} - self.job_id = 0 - - if subdir: - self.path = os.path.join(path, "master_" + str(os.getpid())) - else: - self.path = path - - self.slave_timeout = 5 # 5 mins: need a parameter for that - - self.balancer = netrender.balancing.Balancer() - self.balancer.addRule(netrender.balancing.RatingUsageByCategory(self.getJobs)) - self.balancer.addRule(netrender.balancing.RatingUsage()) - self.balancer.addException(netrender.balancing.ExcludeQueuedEmptyJob()) - self.balancer.addException(netrender.balancing.ExcludeSlavesLimit(self.countJobs, self.countSlaves, limit = 0.9)) - self.balancer.addPriority(netrender.balancing.NewJobPriority()) - self.balancer.addPriority(netrender.balancing.MinimumTimeBetweenDispatchPriority(limit = 2)) - - if not os.path.exists(self.path): - os.mkdir(self.path) - - def restore(self, jobs, slaves, balancer = None): - self.jobs = jobs - self.jobs_map = {} - - for job in self.jobs: - self.jobs_map[job.id] = job - self.job_id = max(self.job_id, int(job.id)) - - self.slaves = slaves - for slave in self.slaves: - self.slaves_map[slave.id] = slave - - if balancer: - self.balancer = balancer - - - def nextJobID(self): - self.job_id += 1 - return str(self.job_id) - - def addSlave(self, name, address, stats): - slave = MRenderSlave(name, address, stats) - self.slaves.append(slave) - self.slaves_map[slave.id] = slave - - return slave.id - - def removeSlave(self, slave): - self.slaves.remove(slave) - self.slaves_map.pop(slave.id) - - def getSlave(self, slave_id): - return self.slaves_map.get(slave_id) - - def getSeenSlave(self, slave_id): - slave = self.getSlave(slave_id) - if slave: - slave.seen() - - return slave - - def timeoutSlaves(self): - removed = [] - - t = time.time() - - for slave in self.slaves: - if (t - slave.last_seen) / 60 > self.slave_timeout: - removed.append(slave) - - if slave.job: - for f in slave.job_frames: - slave.job[f].status = ERROR - - for slave in removed: - self.removeSlave(slave) - - def updateUsage(self): - blend = 0.5 - for job in self.jobs: - job.usage *= (1 - blend) - - if self.slaves: - slave_usage = blend / self.countSlaves() - - for slave in self.slaves: - if slave.job: - slave.job.usage += slave_usage - - - def clear(self, clear_files = False): - removed = self.jobs[:] - - for job in removed: - self.removeJob(job, clear_files) - - def balance(self): - self.balancer.balance(self.jobs) - - def getJobs(self): - return self.jobs - - def countJobs(self, status = JOB_QUEUED): - total = 0 - for j in self.jobs: - if j.status == status: - total += 1 - - return total - - def countSlaves(self): - return len(self.slaves) - - def removeJob(self, job, clear_files = False): - self.jobs.remove(job) - self.jobs_map.pop(job.id) - - if clear_files: - shutil.rmtree(job.save_path) - - for slave in self.slaves: - if slave.job == job: - slave.job = None - slave.job_frames = [] - - def addJob(self, job): - self.jobs.append(job) - self.jobs_map[job.id] = job - - # create job directory - job.save_path = os.path.join(self.path, "job_" + job.id) - if not os.path.exists(job.save_path): - os.mkdir(job.save_path) - - job.save() - - def getJobID(self, id): - return self.jobs_map.get(id) - - def __iter__(self): - for job in self.jobs: - yield job - - def newDispatch(self, slave_id): - if self.jobs: - for job in self.jobs: - if not self.balancer.applyExceptions(job) and slave_id not in job.blacklist: - return job, job.getFrames() - - return None, None - -def clearMaster(path): - shutil.rmtree(path) - -def createMaster(address, clear, path): - filepath = os.path.join(path, "blender_master.data") - - if not clear and os.path.exists(filepath): - print("loading saved master:", filepath) - with open(filepath, 'rb') as f: - path, jobs, slaves = pickle.load(f) - - httpd = RenderMasterServer(address, RenderHandler, path, subdir=False) - httpd.restore(jobs, slaves) - - return httpd - - return RenderMasterServer(address, RenderHandler, path) - -def saveMaster(path, httpd): - filepath = os.path.join(path, "blender_master.data") - - with open(filepath, 'wb') as f: - pickle.dump((httpd.path, httpd.jobs, httpd.slaves), f, pickle.HIGHEST_PROTOCOL) - -def runMaster(address, broadcast, clear, path, update_stats, test_break): - httpd = createMaster(address, clear, path) - httpd.timeout = 1 - httpd.stats = update_stats - - if broadcast: - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) - - start_time = time.time() - 2 - - while not test_break(): - try: - httpd.handle_request() - except select.error: - pass - - if time.time() - start_time >= 2: # need constant here - httpd.timeoutSlaves() - - httpd.updateUsage() - - if broadcast: - print("broadcasting address") - s.sendto(bytes("%i" % address[1], encoding='utf8'), 0, ('', 8000)) - start_time = time.time() - - httpd.server_close() - if clear: - clearMaster(httpd.path) - else: - saveMaster(path, httpd) - diff --git a/release/scripts/io/netrender/master_html.py b/release/scripts/io/netrender/master_html.py deleted file mode 100644 index 877273207a8..00000000000 --- a/release/scripts/io/netrender/master_html.py +++ /dev/null @@ -1,315 +0,0 @@ -# ##### 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 ##### - -import os -import re -import shutil -from netrender.utils import * -import netrender.model - -src_folder = os.path.split(__file__)[0] - -def get(handler): - def output(text): - handler.wfile.write(bytes(text, encoding='utf8')) - - def head(title, refresh = False): - output("") - if refresh: - output("") - output("") -# output("") - output("") - output(title) - output("") - output("") - - - def link(text, url, script=""): - return "%s" % (url, script, text) - - def tag(name, text, attr=""): - return "<%s %s>%s" % (name, attr, text, name) - - def startTable(border=1, class_style = None, caption = None): - output("") - - if caption: - output("" % caption) - - def headerTable(*headers): - output("") - - for c in headers: - output("") - - output("") - - def rowTable(*data, id = None, class_style = None, extra = None): - output("") - - for c in data: - output("") - - output("") - - def endTable(): - output("
%s
" + c + "
" + str(c) + "
") - - def checkbox(title, value, script=""): - return """""" % (title, "checked" if value else "", ("onclick=\"%s\"" % script) if script else "") - - if handler.path == "/html/netrender.js": - f = open(os.path.join(src_folder, "netrender.js"), 'rb') - - handler.send_head(content = "text/javascript") - shutil.copyfileobj(f, handler.wfile) - - f.close() - elif handler.path == "/html/netrender.css": - f = open(os.path.join(src_folder, "netrender.css"), 'rb') - - handler.send_head(content = "text/css") - shutil.copyfileobj(f, handler.wfile) - - f.close() - elif handler.path == "/html" or handler.path == "/": - handler.send_head(content = "text/html") - head("NetRender", refresh = True) - - output("

Jobs

") - - startTable() - headerTable( - " ", - "id", - "name", - "category", - "type", - "chunks", - "priority", - "usage", - "wait", - "status", - "length", - "done", - "dispatched", - "error", - "priority", - "exception" - ) - - handler.server.balance() - - for job in handler.server.jobs: - results = job.framesStatus() - rowTable( - """""" % job.id + - """""" % job.id + - """""" % job.id, - job.id, - link(job.name, "/html/job" + job.id), - job.category if job.category else "None", - netrender.model.JOB_TYPES[job.type], - str(job.chunks) + - """""" % (job.id, job.chunks + 1) + - """""" % (job.id, job.chunks - 1, "disabled=True" if job.chunks == 1 else ""), - str(job.priority) + - """""" % (job.id, job.priority + 1) + - """""" % (job.id, job.priority - 1, "disabled=True" if job.priority == 1 else ""), - "%0.1f%%" % (job.usage * 100), - "%is" % int(time.time() - job.last_dispatched), - job.statusText(), - len(job), - results[DONE], - results[DISPATCHED], - str(results[ERROR]) + - """""" % (job.id, "disabled=True" if not results[ERROR] else ""), - "yes" if handler.server.balancer.applyPriorities(job) else "no", - "yes" if handler.server.balancer.applyExceptions(job) else "no" - ) - - endTable() - - output("

Slaves

") - - startTable() - headerTable("name", "address", "last seen", "stats", "job") - - for slave in handler.server.slaves: - rowTable(slave.name, slave.address[0], time.ctime(slave.last_seen), slave.stats, link(slave.job.name, "/html/job" + slave.job.id) if slave.job else "None") - - endTable() - - output("

Configuration

") - - output("""""") - - startTable(caption = "Rules", class_style = "rules") - - headerTable("type", "enabled", "description", "limit") - - for rule in handler.server.balancer.rules: - rowTable( - "rating", - checkbox("", rule.enabled, "balance_enable('%s', '%s')" % (rule.id(), str(not rule.enabled).lower())), - rule, - rule.str_limit() + - """""" % (rule.id(), str(rule.limit)) if hasattr(rule, "limit") else " " - ) - - for rule in handler.server.balancer.priorities: - rowTable( - "priority", - checkbox("", rule.enabled, "balance_enable('%s', '%s')" % (rule.id(), str(not rule.enabled).lower())), - rule, - rule.str_limit() + - """""" % (rule.id(), str(rule.limit)) if hasattr(rule, "limit") else " " - ) - - for rule in handler.server.balancer.exceptions: - rowTable( - "exception", - checkbox("", rule.enabled, "balance_enable('%s', '%s')" % (rule.id(), str(not rule.enabled).lower())), - rule, - rule.str_limit() + - """""" % (rule.id(), str(rule.limit)) if hasattr(rule, "limit") else " " - ) - - endTable() - - output("") - - elif handler.path.startswith("/html/job"): - handler.send_head(content = "text/html") - job_id = handler.path[9:] - - head("NetRender") - - job = handler.server.getJobID(job_id) - - if job: - output("

Render Information

") - - job.initInfo() - - startTable() - - rowTable("resolution", "%ix%i at %i%%" % job.resolution) - - endTable() - - - if job.type == netrender.model.JOB_BLENDER: - output("

Files

") - - startTable() - headerTable("path") - - tot_cache = 0 - tot_fluid = 0 - - rowTable(job.files[0].filepath) - rowTable("Other Files", class_style = "toggle", extra = "onclick='toggleDisplay(".other", "none", "table-row")'") - - for file in job.files: - if file.filepath.endswith(".bphys"): - tot_cache += 1 - elif file.filepath.endswith(".bobj.gz") or file.filepath.endswith(".bvel.gz"): - tot_fluid += 1 - else: - if file != job.files[0]: - rowTable(file.filepath, class_style = "other") - - if tot_cache > 0: - rowTable("%i physic cache files" % tot_cache, class_style = "toggle", extra = "onclick='toggleDisplay(".cache", "none", "table-row")'") - for file in job.files: - if file.filepath.endswith(".bphys"): - rowTable(os.path.split(file.filepath)[1], class_style = "cache") - - if tot_fluid > 0: - rowTable("%i fluid bake files" % tot_fluid, class_style = "toggle", extra = "onclick='toggleDisplay(".fluid", "none", "table-row")'") - for file in job.files: - if file.filepath.endswith(".bobj.gz") or file.filepath.endswith(".bvel.gz"): - rowTable(os.path.split(file.filepath)[1], class_style = "fluid") - - endTable() - elif job.type == netrender.model.JOB_VCS: - output("

Versioning

") - - startTable() - - rowTable("System", job.version_info.system.name) - rowTable("Remote Path", job.version_info.rpath) - rowTable("Working Path", job.version_info.wpath) - rowTable("Revision", job.version_info.revision) - rowTable("Render File", job.files[0].filepath) - - endTable() - - if job.blacklist: - output("

Blacklist

") - - startTable() - headerTable("name", "address") - - for slave_id in job.blacklist: - slave = handler.server.slaves_map[slave_id] - rowTable(slave.name, slave.address[0]) - - endTable() - - output("

Frames

") - - startTable() - headerTable("no", "status", "render time", "slave", "log", "result", "") - - for frame in job.frames: - rowTable( - frame.number, - frame.statusText(), - "%.1fs" % frame.time, - frame.slave.name if frame.slave else " ", - link("view log", logURL(job_id, frame.number)) if frame.log_path else " ", - link("view result", renderURL(job_id, frame.number)) + " [" + - tag("span", "show", attr="class='thumb' onclick='showThumb(%s, %i)'" % (job.id, frame.number)) + "]" if frame.status == DONE else " ", - "" % (frame.number, job.id, frame.number) - ) - - endTable() - else: - output("no such job") - - output("") - diff --git a/release/scripts/io/netrender/model.py b/release/scripts/io/netrender/model.py deleted file mode 100644 index 5fc0bc2a0bb..00000000000 --- a/release/scripts/io/netrender/model.py +++ /dev/null @@ -1,360 +0,0 @@ -# ##### 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 ##### - -import sys, os -import http, http.client, http.server, urllib -import subprocess, shutil, time, hashlib - -import netrender.versioning as versioning -from netrender.utils import * - -class LogFile: - def __init__(self, job_id = 0, slave_id = 0, frames = []): - self.job_id = job_id - self.slave_id = slave_id - self.frames = frames - - def serialize(self): - return { - "job_id": self.job_id, - "slave_id": self.slave_id, - "frames": self.frames - } - - @staticmethod - def materialize(data): - if not data: - return None - - logfile = LogFile() - logfile.job_id = data["job_id"] - logfile.slave_id = data["slave_id"] - logfile.frames = data["frames"] - - return logfile - -class RenderSlave: - _slave_map = {} - - def __init__(self): - self.id = "" - self.name = "" - self.address = ("",0) - self.stats = "" - self.total_done = 0 - self.total_error = 0 - self.last_seen = 0.0 - - def serialize(self): - return { - "id": self.id, - "name": self.name, - "address": self.address, - "stats": self.stats, - "total_done": self.total_done, - "total_error": self.total_error, - "last_seen": self.last_seen - } - - @staticmethod - def materialize(data, cache = True): - if not data: - return None - - slave_id = data["id"] - - if cache and slave_id in RenderSlave._slave_map: - return RenderSlave._slave_map[slave_id] - - slave = RenderSlave() - slave.id = slave_id - slave.name = data["name"] - slave.address = data["address"] - slave.stats = data["stats"] - slave.total_done = data["total_done"] - slave.total_error = data["total_error"] - slave.last_seen = data["last_seen"] - - if cache: - RenderSlave._slave_map[slave_id] = slave - - return slave - -JOB_BLENDER = 1 -JOB_PROCESS = 2 -JOB_VCS = 3 - -JOB_TYPES = { - JOB_BLENDER: "Blender", - JOB_PROCESS: "Process", - JOB_VCS: "Versioned", - } - -class VersioningInfo: - def __init__(self, info = None): - self._system = None - self.wpath = "" - self.rpath = "" - self.revision = "" - - @property - def system(self): - return self._system - - @system.setter - def system(self, value): - self._system = versioning.SYSTEMS[value] - - def update(self): - self.system.update(self) - - def serialize(self): - return { - "wpath": self.wpath, - "rpath": self.rpath, - "revision": self.revision, - "system": self.system.name - } - - @staticmethod - def generate(system, path): - vs = VersioningInfo() - vs.wpath = path - vs.system = system - - vs.rpath = vs.system.path(path) - vs.revision = vs.system.revision(path) - - return vs - - - @staticmethod - def materialize(data): - if not data: - return None - - vs = VersioningInfo() - vs.wpath = data["wpath"] - vs.rpath = data["rpath"] - vs.revision = data["revision"] - vs.system = data["system"] - - return vs - - -class RenderFile: - def __init__(self, filepath = "", index = 0, start = -1, end = -1, signature=0): - self.filepath = filepath - self.original_path = filepath - self.signature = signature - self.index = index - self.start = start - self.end = end - - def serialize(self): - return { - "filepath": self.filepath, - "original_path": self.original_path, - "index": self.index, - "start": self.start, - "end": self.end, - "signature": self.signature - } - - @staticmethod - def materialize(data): - if not data: - return None - - rfile = RenderFile(data["filepath"], data["index"], data["start"], data["end"], data["signature"]) - rfile.original_path = data["original_path"] - - return rfile - -class RenderJob: - def __init__(self, job_info = None): - self.id = "" - self.type = JOB_BLENDER - self.name = "" - self.category = "None" - self.status = JOB_WAITING - self.files = [] - self.chunks = 0 - self.priority = 0 - self.blacklist = [] - - self.version_info = None - - self.resolution = None - - self.usage = 0.0 - self.last_dispatched = 0.0 - self.frames = [] - - if job_info: - self.type = job_info.type - self.name = job_info.name - self.category = job_info.category - self.status = job_info.status - self.files = job_info.files - self.chunks = job_info.chunks - self.priority = job_info.priority - self.blacklist = job_info.blacklist - self.version_info = job_info.version_info - - def hasRenderResult(self): - return self.type in (JOB_BLENDER, JOB_VCS) - - def rendersWithBlender(self): - return self.type in (JOB_BLENDER, JOB_VCS) - - def addFile(self, file_path, start=-1, end=-1, signed=True): - if signed: - signature = hashFile(file_path) - else: - signature = None - self.files.append(RenderFile(file_path, len(self.files), start, end, signature)) - - def addFrame(self, frame_number, command = ""): - frame = RenderFrame(frame_number, command) - self.frames.append(frame) - return frame - - def __len__(self): - return len(self.frames) - - def countFrames(self, status=QUEUED): - total = 0 - for f in self.frames: - if f.status == status: - total += 1 - - return total - - def countSlaves(self): - return len(set((frame.slave for frame in self.frames if frame.status == DISPATCHED))) - - def statusText(self): - return JOB_STATUS_TEXT[self.status] - - def framesStatus(self): - results = { - QUEUED: 0, - DISPATCHED: 0, - DONE: 0, - ERROR: 0 - } - - for frame in self.frames: - results[frame.status] += 1 - - return results - - def __contains__(self, frame_number): - for f in self.frames: - if f.number == frame_number: - return True - else: - return False - - def __getitem__(self, frame_number): - for f in self.frames: - if f.number == frame_number: - return f - else: - return None - - def serialize(self, frames = None): - min_frame = min((f.number for f in frames)) if frames else -1 - max_frame = max((f.number for f in frames)) if frames else -1 - return { - "id": self.id, - "type": self.type, - "name": self.name, - "category": self.category, - "status": self.status, - "files": [f.serialize() for f in self.files if f.start == -1 or not frames or (f.start <= max_frame and f.end >= min_frame)], - "frames": [f.serialize() for f in self.frames if not frames or f in frames], - "chunks": self.chunks, - "priority": self.priority, - "usage": self.usage, - "blacklist": self.blacklist, - "last_dispatched": self.last_dispatched, - "version_info": self.version_info.serialize() if self.version_info else None, - "resolution": self.resolution - } - - @staticmethod - def materialize(data): - if not data: - return None - - job = RenderJob() - job.id = data["id"] - job.type = data["type"] - job.name = data["name"] - job.category = data["category"] - job.status = data["status"] - job.files = [RenderFile.materialize(f) for f in data["files"]] - job.frames = [RenderFrame.materialize(f) for f in data["frames"]] - job.chunks = data["chunks"] - job.priority = data["priority"] - job.usage = data["usage"] - job.blacklist = data["blacklist"] - job.last_dispatched = data["last_dispatched"] - job.resolution = data["resolution"] - - version_info = data.get("version_info", None) - if version_info: - job.version_info = VersioningInfo.materialize(version_info) - - return job - -class RenderFrame: - def __init__(self, number = 0, command = ""): - self.number = number - self.time = 0 - self.status = QUEUED - self.slave = None - self.command = command - - def statusText(self): - return FRAME_STATUS_TEXT[self.status] - - def serialize(self): - return { - "number": self.number, - "time": self.time, - "status": self.status, - "slave": None if not self.slave else self.slave.serialize(), - "command": self.command - } - - @staticmethod - def materialize(data): - if not data: - return None - - frame = RenderFrame() - frame.number = data["number"] - frame.time = data["time"] - frame.status = data["status"] - frame.slave = RenderSlave.materialize(data["slave"]) - frame.command = data["command"] - - return frame diff --git a/release/scripts/io/netrender/netrender.css b/release/scripts/io/netrender/netrender.css deleted file mode 100644 index 0c54690e002..00000000000 --- a/release/scripts/io/netrender/netrender.css +++ /dev/null @@ -1,88 +0,0 @@ -body { - background-color:#eee; - font-size:12px; - font-family: "Lucida Sans","Lucida Sans Unicode","Lucida Grande",Lucida,sans-serif; - -} -a { - /*text-decoration:none;*/ - color:#666; -} -a:hover { - color:#000; -} -h2 { - background-color:#ddd; - font-size:120%; - padding:5px; -} - -h2 { - background-color:#ddd; - font-size:110%; - padding:5px; -} - -table { - text-align:center; - border:0; - background-color:#ddd; - padding: 0px; - margin: 0px; -} -thead{ - font-size:90%; - color:#555; - background-color:#ccc; -} -td { - border:0; - padding:2px; - padding-left:10px; - padding-right:10px; - margin-left:20px; - background-color:#ddd; -} -td:hover { - background-color:#ccc; -} -tr { - border:0; -} -button { - color: #111; - width: auto; - height: auto; -} - -.toggle { - text-decoration: underline; - cursor: pointer; -} - -.cache { - display: none; -} - -.fluid { - display: none; -} - -.other { - display: none; -} - -.rules { - width: 60em; - text-align: left; -} - -img.thumb { - display: none; - cursor: pointer; -} - -span.thumb { - text-decoration: underline; - cursor: pointer; -} diff --git a/release/scripts/io/netrender/netrender.js b/release/scripts/io/netrender/netrender.js deleted file mode 100644 index 1024a169571..00000000000 --- a/release/scripts/io/netrender/netrender.js +++ /dev/null @@ -1,146 +0,0 @@ -lastFrame = -1 -maxFrame = -1 -minFrame = -1 - -function request(url, data) -{ - xmlhttp = new XMLHttpRequest(); - xmlhttp.open("POST", url, false); - xmlhttp.send(data); - window.location.reload() -} - -function edit(id, info) -{ - request("/edit_" + id, info) -} - -function clear_jobs() -{ - var r=confirm("Also delete files on master?"); - - if (r==true) { - request('/clear', '{"clear":true}'); - } else { - request('/clear', '{"clear":false}'); - } -} - -function cancel_job(id) -{ - var r=confirm("Also delete files on master?"); - - if (r==true) { - request('/cancel_' + id, '{"clear":true}'); - } else { - request('/cancel_' + id, '{"clear":false}'); - } -} - -function balance_edit(id, old_value) -{ - var new_value = prompt("New limit", old_value); - if (new_value != null && new_value != "") { - request("/balance_limit", '{"' + id + '":"' + new_value + '"}'); - } -} - -function balance_enable(id, value) -{ - request("/balance_enable", '{"' + id + '":' + value + "}"); -} - -function showThumb(job, frame) -{ - if (lastFrame != -1) { - if (maxFrame != -1 && minFrame != -1) { - if (frame >= minFrame && frame <= maxFrame) { - for(i = minFrame; i <= maxFrame; i=i+1) { - toggleThumb(job, i); - } - minFrame = -1; - maxFrame = -1; - lastFrame = -1; - } else if (frame > maxFrame) { - for(i = maxFrame+1; i <= frame; i=i+1) { - toggleThumb(job, i); - } - maxFrame = frame; - lastFrame = frame; - } else { - for(i = frame; i <= minFrame-1; i=i+1) { - toggleThumb(job, i); - } - minFrame = frame; - lastFrame = frame; - } - } else if (frame == lastFrame) { - toggleThumb(job, frame); - } else if (frame < lastFrame) { - minFrame = frame; - maxFrame = lastFrame; - - for(i = minFrame; i <= maxFrame-1; i=i+1) { - toggleThumb(job, i); - } - lastFrame = frame; - } else { - minFrame = lastFrame; - maxFrame = frame; - - for(i = minFrame+1; i <= maxFrame; i=i+1) { - toggleThumb(job, i); - } - lastFrame = frame; - } - } else { - toggleThumb(job, frame); - } -} - -function toggleThumb(job, frame) -{ - img = document.images["thumb" + frame]; - url = "/thumb_" + job + "_" + frame + ".jpg" - - if (img.style.display == "block") { - img.style.display = "none"; - img.src = ""; - lastFrame = -1; - } else { - img.src = url; - img.style.display = "block"; - lastFrame = frame; - } -} - -function returnObjById( id ) -{ - if (document.getElementById) - var returnVar = document.getElementById(id); - else if (document.all) - var returnVar = document.all[id]; - else if (document.layers) - var returnVar = document.layers[id]; - return returnVar; -} - -function toggleDisplay( className, value1, value2 ) -{ - style = getStyle(className) - - if (style.style["display"] == value1) { - style.style["display"] = value2; - } else { - style.style["display"] = value1; - } -} - -function getStyle(className) { - var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules - for(var x=0;x 0): - netsettings.jobs.remove(0) - - netrender.jobs = [] - - for j in jobs: - netrender.jobs.append(j) - netsettings.jobs.add() - job = netsettings.jobs[-1] - - j.results = j.framesStatus() # cache frame status - - job.name = j.name - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) - -class RENDER_OT_netclientblacklistslave(bpy.types.Operator): - '''Operator documentation text, will be used for the operator tooltip and python docs.''' - bl_idname = "render.netclientblacklistslave" - bl_label = "Client Blacklist Slave" - - @classmethod - def poll(cls, context): - return True - - def execute(self, context): - netsettings = context.scene.network_render - - if netsettings.active_slave_index >= 0: - - # deal with data - slave = netrender.slaves.pop(netsettings.active_slave_index) - netrender.blacklist.append(slave) - - # deal with rna - netsettings.slaves_blacklist.add() - netsettings.slaves_blacklist[-1].name = slave.name - - netsettings.slaves.remove(netsettings.active_slave_index) - netsettings.active_slave_index = -1 - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) - -class RENDER_OT_netclientwhitelistslave(bpy.types.Operator): - '''Operator documentation text, will be used for the operator tooltip and python docs.''' - bl_idname = "render.netclientwhitelistslave" - bl_label = "Client Whitelist Slave" - - @classmethod - def poll(cls, context): - return True - - def execute(self, context): - netsettings = context.scene.network_render - - if netsettings.active_blacklisted_slave_index >= 0: - - # deal with data - slave = netrender.blacklist.pop(netsettings.active_blacklisted_slave_index) - netrender.slaves.append(slave) - - # deal with rna - netsettings.slaves.add() - netsettings.slaves[-1].name = slave.name - - netsettings.slaves_blacklist.remove(netsettings.active_blacklisted_slave_index) - netsettings.active_blacklisted_slave_index = -1 - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) - - -class RENDER_OT_netclientslaves(bpy.types.Operator): - '''Refresh status about available Render slaves''' - bl_idname = "render.netclientslaves" - bl_label = "Client Slaves" - - @classmethod - def poll(cls, context): - return True - - def execute(self, context): - netsettings = context.scene.network_render - conn = clientConnection(netsettings.server_address, netsettings.server_port, self.report) - - if conn: - conn.request("GET", "/slaves") - - response = conn.getresponse() - content = response.read() - print( response.status, response.reason ) - - slaves = (netrender.model.RenderSlave.materialize(s) for s in json.loads(str(content, encoding='utf8'))) - - while(len(netsettings.slaves) > 0): - netsettings.slaves.remove(0) - - netrender.slaves = [] - - for s in slaves: - for i in range(len(netrender.blacklist)): - slave = netrender.blacklist[i] - if slave.id == s.id: - netrender.blacklist[i] = s - netsettings.slaves_blacklist[i].name = s.name - break - else: - netrender.slaves.append(s) - - netsettings.slaves.add() - slave = netsettings.slaves[-1] - slave.name = s.name - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) - -class RENDER_OT_netclientcancel(bpy.types.Operator): - '''Cancel the selected network rendering job.''' - bl_idname = "render.netclientcancel" - bl_label = "Client Cancel" - - @classmethod - def poll(cls, context): - netsettings = context.scene.network_render - return netsettings.active_job_index >= 0 and len(netsettings.jobs) > 0 - - def execute(self, context): - netsettings = context.scene.network_render - conn = clientConnection(netsettings.server_address, netsettings.server_port, self.report) - - if conn: - job = netrender.jobs[netsettings.active_job_index] - - conn.request("POST", cancelURL(job.id), json.dumps({'clear':False})) - - response = conn.getresponse() - response.read() - print( response.status, response.reason ) - - netsettings.jobs.remove(netsettings.active_job_index) - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) - -class RENDER_OT_netclientcancelall(bpy.types.Operator): - '''Cancel all running network rendering jobs.''' - bl_idname = "render.netclientcancelall" - bl_label = "Client Cancel All" - - @classmethod - def poll(cls, context): - return True - - def execute(self, context): - netsettings = context.scene.network_render - conn = clientConnection(netsettings.server_address, netsettings.server_port, self.report) - - if conn: - conn.request("POST", "/clear", json.dumps({'clear':False})) - - response = conn.getresponse() - response.read() - print( response.status, response.reason ) - - while(len(netsettings.jobs) > 0): - netsettings.jobs.remove(0) - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) - -class netclientdownload(bpy.types.Operator): - '''Download render results from the network''' - bl_idname = "render.netclientdownload" - bl_label = "Client Download" - - @classmethod - def poll(cls, context): - netsettings = context.scene.network_render - return netsettings.active_job_index >= 0 and len(netsettings.jobs) > netsettings.active_job_index - - def execute(self, context): - netsettings = context.scene.network_render - rd = context.scene.render - - conn = clientConnection(netsettings.server_address, netsettings.server_port, self.report) - - if conn: - job_id = netrender.jobs[netsettings.active_job_index].id - - conn.request("GET", "/status", headers={"job-id":job_id}) - - response = conn.getresponse() - - if response.status != http.client.OK: - self.report('ERROR', "Job ID %i not defined on master" % job_id) - return {'ERROR'} - - content = response.read() - - job = netrender.model.RenderJob.materialize(json.loads(str(content, encoding='utf8'))) - - conn.close() - - finished_frames = [] - - nb_error = 0 - nb_missing = 0 - - for frame in job.frames: - if frame.status == DONE: - finished_frames.append(frame.number) - elif frame.status == ERROR: - nb_error += 1 - else: - nb_missing += 1 - - if not finished_frames: - return - - frame_ranges = [] - - first = None - last = None - - for i in range(len(finished_frames)): - current = finished_frames[i] - - if not first: - first = current - last = current - elif last + 1 == current: - last = current - - if last + 1 < current or i + 1 == len(finished_frames): - if first < last: - frame_ranges.append((first, last)) - else: - frame_ranges.append((first,)) - - first = current - last = current - - getResults(netsettings.server_address, netsettings.server_port, job_id, job.resolution[0], job.resolution[1], job.resolution[2], frame_ranges) - - if nb_error and nb_missing: - self.report('ERROR', "Results downloaded but skipped %i frames with errors and %i unfinished frames" % (nb_error, nb_missing)) - elif nb_error: - self.report('ERROR', "Results downloaded but skipped %i frames with errors" % nb_error) - elif nb_missing: - self.report('WARNING', "Results downloaded but skipped %i unfinished frames" % nb_missing) - else: - self.report('INFO', "All results downloaded") - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) - -class netclientscan(bpy.types.Operator): - '''Listen on network for master server broadcasting its address and port.''' - bl_idname = "render.netclientscan" - bl_label = "Client Scan" - - @classmethod - def poll(cls, context): - return True - - def execute(self, context): - address, port = clientScan(self.report) - - if address: - scene = context.scene - netsettings = scene.network_render - netsettings.server_address = address - netsettings.server_port = port - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) - -class netclientvcsguess(bpy.types.Operator): - '''Guess VCS setting for the current file''' - bl_idname = "render.netclientvcsguess" - bl_label = "VCS Guess" - - @classmethod - def poll(cls, context): - return True - - def execute(self, context): - netsettings = context.scene.network_render - - system = versioning.SYSTEMS.get(netsettings.vcs_system, None) - - if system: - wpath, name = os.path.split(os.path.abspath(bpy.data.filepath)) - - rpath = system.path(wpath) - revision = system.revision(wpath) - - netsettings.vcs_wpath = wpath - netsettings.vcs_rpath = rpath - netsettings.vcs_revision = revision - - - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) - - -class netclientweb(bpy.types.Operator): - '''Open new window with information about running rendering jobs''' - bl_idname = "render.netclientweb" - bl_label = "Open Master Monitor" - - @classmethod - def poll(cls, context): - netsettings = context.scene.network_render - return netsettings.server_address != "[default]" - - def execute(self, context): - netsettings = context.scene.network_render - - - # open connection to make sure server exists - conn = clientConnection(netsettings.server_address, netsettings.server_port, self.report) - - if conn: - conn.close() - - webbrowser.open("http://%s:%i" % (netsettings.server_address, netsettings.server_port)) - - return {'FINISHED'} - - def invoke(self, context, event): - return self.execute(context) diff --git a/release/scripts/io/netrender/repath.py b/release/scripts/io/netrender/repath.py deleted file mode 100644 index 3ac9636b628..00000000000 --- a/release/scripts/io/netrender/repath.py +++ /dev/null @@ -1,150 +0,0 @@ -# ##### 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 ##### - -import sys, os -import subprocess - -import bpy - -from netrender.utils import * -import netrender.model - -BLENDER_PATH = sys.argv[0] - -def reset(job): - main_file = job.files[0] - - job_full_path = main_file.filepath - - if os.path.exists(job_full_path + ".bak"): - os.remove(job_full_path) # repathed file - os.renames(job_full_path + ".bak", job_full_path) - -def update(job): - paths = [] - - main_file = job.files[0] - - job_full_path = main_file.filepath - - - path, ext = os.path.splitext(job_full_path) - - new_path = path + ".remap" + ext - - # Disable for now. Partial repath should work anyway - #all = main_file.filepath != main_file.original_path - all = False - - for rfile in job.files[1:]: - if all or rfile.original_path != rfile.filepath: - paths.append(rfile.original_path) - paths.append(rfile.filepath) - - # Only update if needed - if paths: - process = subprocess.Popen([BLENDER_PATH, "-b", "-noaudio", job_full_path, "-P", __file__, "--", new_path] + paths, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - process.wait() - - os.renames(job_full_path, job_full_path + ".bak") - os.renames(new_path, job_full_path) - -def process(paths): - def processPointCache(point_cache): - point_cache.use_external = False - - def processFluid(fluid): - new_path = path_map.get(fluid.filepath, None) - if new_path: - fluid.path = new_path - - path_map = {} - for i in range(0, len(paths), 2): - # special case for point cache - if paths[i].endswith(".bphys"): - pass # Don't need them in the map, they all use the default external path - # NOTE: This is probably not correct all the time, need to be fixed. - # special case for fluids - elif paths[i].endswith(".bobj.gz"): - path_map[os.path.split(paths[i])[0]] = os.path.split(paths[i+1])[0] - else: - path_map[os.path.split(paths[i])[1]] = paths[i+1] - - # TODO original paths aren't really the orignal path (they are the normalized path - # so we repath using the filenames only. - - ########################### - # LIBRARIES - ########################### - for lib in bpy.data.libraries: - file_path = bpy.path.abspath(lib.filepath) - new_path = path_map.get(os.path.split(file_path)[1], None) - if new_path: - lib.filepath = new_path - - ########################### - # IMAGES - ########################### - for image in bpy.data.images: - if image.source == "FILE" and not image.packed_file: - file_path = bpy.path.abspath(image.filepath) - new_path = path_map.get(os.path.split(file_path)[1], None) - if new_path: - image.filepath = new_path - - - ########################### - # FLUID + POINT CACHE - ########################### - for object in bpy.data.objects: - for modifier in object.modifiers: - if modifier.type == 'FLUID_SIMULATION' and modifier.settings.type == "DOMAIN": - processFluid(settings) - elif modifier.type == "CLOTH": - processPointCache(modifier.point_cache) - elif modifier.type == "SOFT_BODY": - processPointCache(modifier.point_cache) - elif modifier.type == "SMOKE" and modifier.smoke_type == "TYPE_DOMAIN": - processPointCache(modifier.domain_settings.point_cache_low) - if modifier.domain_settings.use_high_resolution: - processPointCache(modifier.domain_settings.point_cache_high) - elif modifier.type == "MULTIRES" and modifier.is_external: - file_path = bpy.path.abspath(modifier.filepath) - new_path = path_map.get(file_path, None) - if new_path: - modifier.filepath = new_path - - # particles modifier are stupid and don't contain data - # we have to go through the object property - for psys in object.particle_systems: - processPointCache(psys.point_cache) - - -if __name__ == "__main__": - try: - i = sys.argv.index("--") - except: - i = 0 - - if i: - new_path = sys.argv[i+1] - args = sys.argv[i+2:] - - process(args) - - bpy.ops.wm.save_as_mainfile(filepath=new_path, check_existing=False) diff --git a/release/scripts/io/netrender/slave.py b/release/scripts/io/netrender/slave.py deleted file mode 100644 index b05de0afeb9..00000000000 --- a/release/scripts/io/netrender/slave.py +++ /dev/null @@ -1,349 +0,0 @@ -# ##### 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 ##### - -import sys, os, platform, shutil -import http, http.client, http.server, urllib -import subprocess, time -import json - -import bpy - -from netrender.utils import * -import netrender.model -import netrender.repath -import netrender.thumbnail as thumbnail - -BLENDER_PATH = sys.argv[0] - -CANCEL_POLL_SPEED = 2 -MAX_TIMEOUT = 10 -INCREMENT_TIMEOUT = 1 -MAX_CONNECT_TRY = 10 -try: - system = platform.system() -except UnicodeDecodeError: - import sys - system = sys.platform - -if system in ('Windows', 'win32') and platform.version() >= '5': # Error mode is only available on Win2k or higher, that's version 5 - import ctypes - def SetErrorMode(): - val = ctypes.windll.kernel32.SetErrorMode(0x0002) - ctypes.windll.kernel32.SetErrorMode(val | 0x0002) - return val - - def RestoreErrorMode(val): - ctypes.windll.kernel32.SetErrorMode(val) -else: - def SetErrorMode(): - return 0 - - def RestoreErrorMode(val): - pass - -def clearSlave(path): - shutil.rmtree(path) - -def slave_Info(): - sysname, nodename, release, version, machine, processor = platform.uname() - slave = netrender.model.RenderSlave() - slave.name = nodename - slave.stats = sysname + " " + release + " " + machine + " " + processor - return slave - -def testCancel(conn, job_id, frame_number): - conn.request("HEAD", "/status", headers={"job-id":job_id, "job-frame": str(frame_number)}) - - # canceled if job isn't found anymore - if responseStatus(conn) == http.client.NO_CONTENT: - return True - else: - return False - -def testFile(conn, job_id, slave_id, rfile, JOB_PREFIX, main_path = None): - job_full_path = prefixPath(JOB_PREFIX, rfile.filepath, main_path) - - found = os.path.exists(job_full_path) - - if found and rfile.signature != None: - found_signature = hashFile(job_full_path) - found = found_signature == rfile.signature - - if not found: - print("Found file %s at %s but signature mismatch!" % (rfile.filepath, job_full_path)) - job_full_path = prefixPath(JOB_PREFIX, rfile.filepath, main_path, force = True) - - if not found: - # Force prefix path if not found - job_full_path = prefixPath(JOB_PREFIX, rfile.filepath, main_path, force = True) - temp_path = os.path.join(JOB_PREFIX, "slave.temp") - conn.request("GET", fileURL(job_id, rfile.index), headers={"slave-id":slave_id}) - response = conn.getresponse() - - if response.status != http.client.OK: - return None # file for job not returned by server, need to return an error code to server - - f = open(temp_path, "wb") - buf = response.read(1024) - - while buf: - f.write(buf) - buf = response.read(1024) - - f.close() - - os.renames(temp_path, job_full_path) - - rfile.filepath = job_full_path - - return job_full_path - -def breakable_timeout(timeout): - for i in range(timeout): - time.sleep(1) - if engine.test_break(): - break - -def render_slave(engine, netsettings, threads): - timeout = 1 - - bisleep = BreakableIncrementedSleep(INCREMENT_TIMEOUT, 1, MAX_TIMEOUT, engine.test_break) - - engine.update_stats("", "Network render node initiation") - - conn = clientConnection(netsettings.server_address, netsettings.server_port) - - if not conn: - timeout = 1 - print("Connection failed, will try connecting again at most %i times" % MAX_CONNECT_TRY) - bisleep.reset() - - for i in range(MAX_CONNECT_TRY): - bisleep.sleep() - - conn = clientConnection(netsettings.server_address, netsettings.server_port) - - if conn or engine.test_break(): - break - - print("Retry %i failed, waiting %is before retrying" % (i + 1, bisleep.current)) - - if conn: - conn.request("POST", "/slave", json.dumps(slave_Info().serialize())) - response = conn.getresponse() - response.read() - - slave_id = response.getheader("slave-id") - - NODE_PREFIX = os.path.join(bpy.path.abspath(netsettings.path), "slave_" + slave_id) - if not os.path.exists(NODE_PREFIX): - os.mkdir(NODE_PREFIX) - - engine.update_stats("", "Network render connected to master, waiting for jobs") - - while not engine.test_break(): - conn.request("GET", "/job", headers={"slave-id":slave_id}) - response = conn.getresponse() - - if response.status == http.client.OK: - bisleep.reset() - - job = netrender.model.RenderJob.materialize(json.loads(str(response.read(), encoding='utf8'))) - engine.update_stats("", "Network render processing job from master") - - JOB_PREFIX = os.path.join(NODE_PREFIX, "job_" + job.id) - if not os.path.exists(JOB_PREFIX): - os.mkdir(JOB_PREFIX) - - # set tempdir for fsaa temp files - # have to set environ var because render is done in a subprocess and that's the easiest way to propagate the setting - os.environ["TMP"] = JOB_PREFIX - - - if job.type == netrender.model.JOB_BLENDER: - job_path = job.files[0].filepath # path of main file - main_path, main_file = os.path.split(job_path) - - job_full_path = testFile(conn, job.id, slave_id, job.files[0], JOB_PREFIX) - print("Fullpath", job_full_path) - print("File:", main_file, "and %i other files" % (len(job.files) - 1,)) - - for rfile in job.files[1:]: - testFile(conn, job.id, slave_id, rfile, JOB_PREFIX, main_path) - print("\t", rfile.filepath) - - netrender.repath.update(job) - - engine.update_stats("", "Render File "+ main_file+ " for job "+ job.id) - elif job.type == netrender.model.JOB_VCS: - if not job.version_info: - # Need to return an error to server, incorrect job type - pass - - job_path = job.files[0].filepath # path of main file - main_path, main_file = os.path.split(job_path) - - job.version_info.update() - - # For VCS jobs, file path is relative to the working copy path - job_full_path = os.path.join(job.version_info.wpath, job_path) - - engine.update_stats("", "Render File "+ main_file+ " for job "+ job.id) - - # announce log to master - logfile = netrender.model.LogFile(job.id, slave_id, [frame.number for frame in job.frames]) - conn.request("POST", "/log", bytes(json.dumps(logfile.serialize()), encoding='utf8')) - response = conn.getresponse() - response.read() - - - first_frame = job.frames[0].number - - # start render - start_t = time.time() - - if job.rendersWithBlender(): - frame_args = [] - - for frame in job.frames: - print("frame", frame.number) - frame_args += ["-f", str(frame.number)] - - val = SetErrorMode() - process = subprocess.Popen([BLENDER_PATH, "-b", "-noaudio", job_full_path, "-t", str(threads), "-o", os.path.join(JOB_PREFIX, "######"), "-E", "BLENDER_RENDER", "-F", "MULTILAYER"] + frame_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - RestoreErrorMode(val) - elif job.type == netrender.model.JOB_PROCESS: - command = job.frames[0].command - val = SetErrorMode() - process = subprocess.Popen(command.split(" "), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - RestoreErrorMode(val) - - headers = {"slave-id":slave_id} - - cancelled = False - stdout = bytes() - run_t = time.time() - while not cancelled and process.poll() is None: - stdout += process.stdout.read(1024) - current_t = time.time() - cancelled = engine.test_break() - if current_t - run_t > CANCEL_POLL_SPEED: - - # update logs if needed - if stdout: - # (only need to update on one frame, they are linked - conn.request("PUT", logURL(job.id, first_frame), stdout, headers=headers) - response = conn.getresponse() - response.read() - - # Also output on console - if netsettings.use_slave_output_log: - print(str(stdout, encoding='utf8'), end="") - - stdout = bytes() - - run_t = current_t - if testCancel(conn, job.id, first_frame): - cancelled = True - - if job.type == netrender.model.JOB_BLENDER: - netrender.repath.reset(job) - - # read leftovers if needed - stdout += process.stdout.read() - - if cancelled: - # kill process if needed - if process.poll() is None: - try: - process.terminate() - except OSError: - pass - continue # to next frame - - # flush the rest of the logs - if stdout: - # Also output on console - if netsettings.use_slave_thumb: - print(str(stdout, encoding='utf8'), end="") - - # (only need to update on one frame, they are linked - conn.request("PUT", logURL(job.id, first_frame), stdout, headers=headers) - if responseStatus(conn) == http.client.NO_CONTENT: - continue - - total_t = time.time() - start_t - - avg_t = total_t / len(job.frames) - - status = process.returncode - - print("status", status) - - headers = {"job-id":job.id, "slave-id":slave_id, "job-time":str(avg_t)} - - - if status == 0: # non zero status is error - headers["job-result"] = str(DONE) - for frame in job.frames: - headers["job-frame"] = str(frame.number) - if job.hasRenderResult(): - # send image back to server - - filename = os.path.join(JOB_PREFIX, "%06d.exr" % frame.number) - - # thumbnail first - if netsettings.use_slave_thumb: - thumbname = thumbnail.generate(filename) - - if thumbname: - f = open(thumbname, 'rb') - conn.request("PUT", "/thumb", f, headers=headers) - f.close() - responseStatus(conn) - - f = open(filename, 'rb') - conn.request("PUT", "/render", f, headers=headers) - f.close() - if responseStatus(conn) == http.client.NO_CONTENT: - continue - - elif job.type == netrender.model.JOB_PROCESS: - conn.request("PUT", "/render", headers=headers) - if responseStatus(conn) == http.client.NO_CONTENT: - continue - else: - headers["job-result"] = str(ERROR) - for frame in job.frames: - headers["job-frame"] = str(frame.number) - # send error result back to server - conn.request("PUT", "/render", headers=headers) - if responseStatus(conn) == http.client.NO_CONTENT: - continue - - engine.update_stats("", "Network render connected to master, waiting for jobs") - else: - bisleep.sleep() - - conn.close() - - if netsettings.use_slave_clear: - clearSlave(NODE_PREFIX) - -if __name__ == "__main__": - pass diff --git a/release/scripts/io/netrender/thumbnail.py b/release/scripts/io/netrender/thumbnail.py deleted file mode 100644 index 2ead6e82745..00000000000 --- a/release/scripts/io/netrender/thumbnail.py +++ /dev/null @@ -1,81 +0,0 @@ -# ##### 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 ##### - -import sys, os -import subprocess - -import bpy - -def generate(filename, external=True): - if external: - process = subprocess.Popen([sys.argv[0], "-b", "-noaudio", "-P", __file__, "--", filename], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - while process.poll() is None: - process.stdout.read(1024) # empty buffer to be sure - process.stdout.read() - - return _thumbname(filename) - else: - return _internal(filename) - -def _thumbname(filename): - root = os.path.splitext(filename)[0] - return root + ".jpg" - -def _internal(filename): - imagename = os.path.split(filename)[1] - thumbname = _thumbname(filename) - - if os.path.exists(thumbname): - return thumbname - - if bpy: - scene = bpy.data.scenes[0] # FIXME, this is dodgy! - scene.render.file_format = "JPEG" - scene.render.file_quality = 90 - - # remove existing image, if there's a leftover (otherwise open changes the name) - if imagename in bpy.data.images: - img = bpy.data.images[imagename] - bpy.data.images.remove(img) - - bpy.ops.image.open(filepath=filename) - img = bpy.data.images[imagename] - - img.save_render(thumbname, scene=scene) - - img.user_clear() - bpy.data.images.remove(img) - - try: - process = subprocess.Popen(["convert", thumbname, "-resize", "300x300", thumbname]) - process.wait() - return thumbname - except Exception as exp: - print("Error while generating thumbnail") - print(exp) - - return None - -if __name__ == "__main__": - import bpy - try: - start = sys.argv.index("--") + 1 - except ValueError: - start = 0 - for filename in sys.argv[start:]: - generate(filename, external=False) diff --git a/release/scripts/io/netrender/ui.py b/release/scripts/io/netrender/ui.py deleted file mode 100644 index ebc7b5807e8..00000000000 --- a/release/scripts/io/netrender/ui.py +++ /dev/null @@ -1,543 +0,0 @@ -# ##### 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 ##### - -import bpy -import sys, os -import http, http.client, http.server, urllib -import subprocess, shutil, time, hashlib - -import netrender -import netrender.slave as slave -import netrender.master as master - -from netrender.utils import * - -VERSION = b"0.3" - -PATH_PREFIX = "/tmp/" - -QUEUED = 0 -DISPATCHED = 1 -DONE = 2 -ERROR = 3 - -LAST_ADDRESS_TEST = 0 - -def base_poll(cls, context): - rd = context.scene.render - return (rd.use_game_engine==False) and (rd.engine in cls.COMPAT_ENGINES) - - -def init_file(): - if netrender.init_file != bpy.data.filepath: - netrender.init_file = bpy.data.filepath - netrender.init_data = True - netrender.valid_address = False - -def init_data(netsettings): - init_file() - - if netrender.init_data: - netrender.init_data = False - - netsettings.active_slave_index = 0 - while(len(netsettings.slaves) > 0): - netsettings.slaves.remove(0) - - netsettings.active_blacklisted_slave_index = 0 - while(len(netsettings.slaves_blacklist) > 0): - netsettings.slaves_blacklist.remove(0) - - netsettings.active_job_index = 0 - while(len(netsettings.jobs) > 0): - netsettings.jobs.remove(0) - -def verify_address(netsettings): - global LAST_ADDRESS_TEST - init_file() - - if LAST_ADDRESS_TEST + 30 < time.time(): - LAST_ADDRESS_TEST = time.time() - - try: - conn = clientConnection(netsettings.server_address, netsettings.server_port, scan = False, timeout = 1) - except: - conn = None - - if conn: - netrender.valid_address = True - conn.close() - else: - netrender.valid_address = False - - return netrender.valid_address - -class NeedValidAddress(): - @classmethod - def poll(cls, context): - return super().poll(context) and verify_address(context.scene.network_render) - -class NetRenderButtonsPanel(): - bl_space_type = "PROPERTIES" - bl_region_type = "WINDOW" - bl_context = "render" - # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here - - @classmethod - def poll(cls, context): - rd = context.scene.render - return rd.engine == 'NET_RENDER' and rd.use_game_engine == False - -# Setting panel, use in the scene for now. -class RENDER_PT_network_settings(NetRenderButtonsPanel, bpy.types.Panel): - bl_label = "Network Settings" - COMPAT_ENGINES = {'NET_RENDER'} - - @classmethod - def poll(cls, context): - return super().poll(context) - - def draw(self, context): - layout = self.layout - - netsettings = context.scene.network_render - - verify_address(netsettings) - - layout.prop(netsettings, "mode", expand=True) - - if netsettings.mode in ("RENDER_MASTER", "RENDER_SLAVE"): - layout.operator("render.netclientstart", icon='PLAY') - - layout.prop(netsettings, "path") - - split = layout.split(percentage=0.7) - - col = split.column() - col.label(text="Server Address:") - col.prop(netsettings, "server_address", text="") - - col = split.column() - col.label(text="Port:") - col.prop(netsettings, "server_port", text="") - - if netsettings.mode != "RENDER_MASTER": - layout.operator("render.netclientscan", icon='FILE_REFRESH', text="") - - if not netrender.valid_address: - layout.label(text="No master at specified address") - - layout.operator("render.netclientweb", icon='QUESTION') - -class RENDER_PT_network_slave_settings(NetRenderButtonsPanel, bpy.types.Panel): - bl_label = "Slave Settings" - COMPAT_ENGINES = {'NET_RENDER'} - - @classmethod - def poll(cls, context): - scene = context.scene - return super().poll(context) and scene.network_render.mode == "RENDER_SLAVE" - - def draw(self, context): - layout = self.layout - - rd = context.scene.render - netsettings = context.scene.network_render - - layout.prop(netsettings, "use_slave_clear") - layout.prop(netsettings, "use_slave_thumb") - layout.prop(netsettings, "use_slave_output_log") - layout.label(text="Threads:") - layout.prop(rd, "threads_mode", expand=True) - - col = layout.column() - col.enabled = rd.threads_mode == 'FIXED' - col.prop(rd, "threads") - -class RENDER_PT_network_master_settings(NetRenderButtonsPanel, bpy.types.Panel): - bl_label = "Master Settings" - COMPAT_ENGINES = {'NET_RENDER'} - - @classmethod - def poll(cls, context): - scene = context.scene - return super().poll(context) and scene.network_render.mode == "RENDER_MASTER" - - def draw(self, context): - layout = self.layout - - netsettings = context.scene.network_render - - layout.prop(netsettings, "use_master_broadcast") - layout.prop(netsettings, "use_master_clear") - -class RENDER_PT_network_job(NetRenderButtonsPanel, bpy.types.Panel): - bl_label = "Job Settings" - COMPAT_ENGINES = {'NET_RENDER'} - - @classmethod - def poll(cls, context): - scene = context.scene - return super().poll(context) and scene.network_render.mode == "RENDER_CLIENT" - - def draw(self, context): - layout = self.layout - - netsettings = context.scene.network_render - - verify_address(netsettings) - - if netsettings.server_address != "[default]": - layout.operator("render.netclientanim", icon='RENDER_ANIMATION') - layout.operator("render.netclientsend", icon='FILE_BLEND') - layout.operator("render.netclientsendframe", icon='RENDER_STILL') - if netsettings.job_id: - row = layout.row() - row.operator("render.render", text="Get Image", icon='RENDER_STILL') - row.operator("render.render", text="Get Animation", icon='RENDER_ANIMATION').animation = True - - split = layout.split(percentage=0.3) - - col = split.column() - col.label(text="Type:") - col.label(text="Name:") - col.label(text="Category:") - - col = split.column() - col.prop(netsettings, "job_type", text="") - col.prop(netsettings, "job_name", text="") - col.prop(netsettings, "job_category", text="") - - row = layout.row() - row.prop(netsettings, "priority") - row.prop(netsettings, "chunks") - -class RENDER_PT_network_job_vcs(NetRenderButtonsPanel, bpy.types.Panel): - bl_label = "VCS Job Settings" - COMPAT_ENGINES = {'NET_RENDER'} - - @classmethod - def poll(cls, context): - scene = context.scene - return (super().poll(context) - and scene.network_render.mode == "RENDER_CLIENT" - and scene.network_render.job_type == "JOB_VCS") - - def draw(self, context): - layout = self.layout - - netsettings = context.scene.network_render - - layout.operator("render.netclientvcsguess", icon='FILE_REFRESH', text="") - - layout.prop(netsettings, "vcs_system") - layout.prop(netsettings, "vcs_revision") - layout.prop(netsettings, "vcs_rpath") - layout.prop(netsettings, "vcs_wpath") - -class RENDER_PT_network_slaves(NeedValidAddress, NetRenderButtonsPanel, bpy.types.Panel): - bl_label = "Slaves Status" - COMPAT_ENGINES = {'NET_RENDER'} - - @classmethod - def poll(cls, context): - netsettings = context.scene.network_render - return super().poll(context) and netsettings.mode == "RENDER_CLIENT" - - def draw(self, context): - layout = self.layout - - netsettings = context.scene.network_render - - row = layout.row() - row.template_list(netsettings, "slaves", netsettings, "active_slave_index", rows=2) - - sub = row.column(align=True) - sub.operator("render.netclientslaves", icon='FILE_REFRESH', text="") - sub.operator("render.netclientblacklistslave", icon='ZOOMOUT', text="") - - if len(netrender.slaves) > netsettings.active_slave_index >= 0: - layout.separator() - - slave = netrender.slaves[netsettings.active_slave_index] - - layout.label(text="Name: " + slave.name) - layout.label(text="Address: " + slave.address[0]) - layout.label(text="Seen: " + time.ctime(slave.last_seen)) - layout.label(text="Stats: " + slave.stats) - -class RENDER_PT_network_slaves_blacklist(NeedValidAddress, NetRenderButtonsPanel, bpy.types.Panel): - bl_label = "Slaves Blacklist" - COMPAT_ENGINES = {'NET_RENDER'} - - @classmethod - def poll(cls, context): - netsettings = context.scene.network_render - return super().poll(context) and netsettings.mode == "RENDER_CLIENT" - - def draw(self, context): - layout = self.layout - - netsettings = context.scene.network_render - - row = layout.row() - row.template_list(netsettings, "slaves_blacklist", netsettings, "active_blacklisted_slave_index", rows=2) - - sub = row.column(align=True) - sub.operator("render.netclientwhitelistslave", icon='ZOOMOUT', text="") - - if len(netrender.blacklist) > netsettings.active_blacklisted_slave_index >= 0: - layout.separator() - - slave = netrender.blacklist[netsettings.active_blacklisted_slave_index] - - layout.label(text="Name: " + slave.name) - layout.label(text="Address: " + slave.address[0]) - layout.label(text="Seen: " + time.ctime(slave.last_seen)) - layout.label(text="Stats: " + slave.stats) - -class RENDER_PT_network_jobs(NeedValidAddress, NetRenderButtonsPanel, bpy.types.Panel): - bl_label = "Jobs" - COMPAT_ENGINES = {'NET_RENDER'} - - @classmethod - def poll(cls, context): - netsettings = context.scene.network_render - return super().poll(context) and netsettings.mode == "RENDER_CLIENT" - - def draw(self, context): - layout = self.layout - - netsettings = context.scene.network_render - - row = layout.row() - row.template_list(netsettings, "jobs", netsettings, "active_job_index", rows=2) - - sub = row.column(align=True) - sub.operator("render.netclientstatus", icon='FILE_REFRESH', text="") - sub.operator("render.netclientcancel", icon='ZOOMOUT', text="") - sub.operator("render.netclientcancelall", icon='PANEL_CLOSE', text="") - sub.operator("render.netclientdownload", icon='RENDER_ANIMATION', text="") - - if len(netrender.jobs) > netsettings.active_job_index >= 0: - layout.separator() - - job = netrender.jobs[netsettings.active_job_index] - - layout.label(text="Name: %s" % job.name) - layout.label(text="Length: %04i" % len(job)) - layout.label(text="Done: %04i" % job.results[DONE]) - layout.label(text="Error: %04i" % job.results[ERROR]) - -import properties_render -class RENDER_PT_network_output(NeedValidAddress, NetRenderButtonsPanel, bpy.types.Panel): - bl_label = "Output" - COMPAT_ENGINES = {'NET_RENDER'} - - @classmethod - def poll(cls, context): - netsettings = context.scene.network_render - return super().poll(context) and netsettings.mode == "RENDER_CLIENT" - - draw = properties_render.RENDER_PT_output.draw - - -def addProperties(): - class NetRenderSettings(bpy.types.PropertyGroup): - pass - - class NetRenderSlave(bpy.types.PropertyGroup): - pass - - class NetRenderJob(bpy.types.PropertyGroup): - pass - - bpy.utils.register_class(NetRenderSettings) - bpy.utils.register_class(NetRenderSlave) - bpy.utils.register_class(NetRenderJob) - - from bpy.props import PointerProperty, StringProperty, BoolProperty, EnumProperty, IntProperty, CollectionProperty - bpy.types.Scene.network_render = PointerProperty(type=NetRenderSettings, name="Network Render", description="Network Render Settings") - - NetRenderSettings.server_address = StringProperty( - name="Server address", - description="IP or name of the master render server", - maxlen = 128, - default = "[default]") - - NetRenderSettings.server_port = IntProperty( - name="Server port", - description="port of the master render server", - default = 8000, - min=1, - max=65535) - - NetRenderSettings.use_master_broadcast = BoolProperty( - name="Broadcast", - description="broadcast master server address on local network", - default = True) - - NetRenderSettings.use_slave_clear = BoolProperty( - name="Clear on exit", - description="delete downloaded files on exit", - default = True) - - NetRenderSettings.use_slave_thumb = BoolProperty( - name="Generate thumbnails", - description="Generate thumbnails on slaves instead of master", - default = False) - - NetRenderSettings.use_slave_output_log = BoolProperty( - name="Output render log on console", - description="Output render text log to console as well as sending it to the master", - default = True) - - NetRenderSettings.use_master_clear = BoolProperty( - name="Clear on exit", - description="delete saved files on exit", - default = False) - - default_path = os.environ.get("TEMP") - - if not default_path: - if os.name == 'nt': - default_path = "c:/tmp/" - else: - default_path = "/tmp/" - elif not default_path.endswith(os.sep): - default_path += os.sep - - NetRenderSettings.path = StringProperty( - name="Path", - description="Path for temporary files", - maxlen = 128, - default = default_path, - subtype='FILE_PATH') - - NetRenderSettings.job_type = EnumProperty( - items=( - ("JOB_BLENDER", "Blender", "Standard Blender Job"), - ("JOB_PROCESS", "Process", "Custom Process Job"), - ("JOB_VCS", "VCS", "Version Control System Managed Job"), - ), - name="Job Type", - description="Type of render job", - default="JOB_BLENDER") - - NetRenderSettings.job_name = StringProperty( - name="Job name", - description="Name of the job", - maxlen = 128, - default = "[default]") - - NetRenderSettings.job_category = StringProperty( - name="Job category", - description="Category of the job", - maxlen = 128, - default = "") - - NetRenderSettings.chunks = IntProperty( - name="Chunks", - description="Number of frame to dispatch to each slave in one chunk", - default = 5, - min=1, - max=65535) - - NetRenderSettings.priority = IntProperty( - name="Priority", - description="Priority of the job", - default = 1, - min=1, - max=10) - - NetRenderSettings.vcs_wpath = StringProperty( - name="Working Copy", - description="Path of the local working copy", - maxlen = 1024, - default = "") - - NetRenderSettings.vcs_rpath = StringProperty( - name="Remote Path", - description="Path of the server copy (protocol specific)", - maxlen = 1024, - default = "") - - NetRenderSettings.vcs_revision = StringProperty( - name="Revision", - description="Revision for this job", - maxlen = 256, - default = "") - - NetRenderSettings.vcs_system = StringProperty( - name="VCS", - description="Version Control System", - maxlen = 64, - default = "Subversion") - - NetRenderSettings.job_id = StringProperty( - name="Network job id", - description="id of the last sent render job", - maxlen = 64, - default = "") - - NetRenderSettings.active_slave_index = IntProperty( - name="Index of the active slave", - description="", - default = -1, - min= -1, - max=65535) - - NetRenderSettings.active_blacklisted_slave_index = IntProperty( - name="Index of the active slave", - description="", - default = -1, - min= -1, - max=65535) - - NetRenderSettings.active_job_index = IntProperty( - name="Index of the active job", - description="", - default = -1, - min= -1, - max=65535) - - NetRenderSettings.mode = EnumProperty( - items=( - ("RENDER_CLIENT", "Client", "Act as render client"), - ("RENDER_MASTER", "Master", "Act as render master"), - ("RENDER_SLAVE", "Slave", "Act as render slave"), - ), - name="Network mode", - description="Mode of operation of this instance", - default="RENDER_CLIENT") - - NetRenderSettings.slaves = CollectionProperty(type=NetRenderSlave, name="Slaves", description="") - NetRenderSettings.slaves_blacklist = CollectionProperty(type=NetRenderSlave, name="Slaves Blacklist", description="") - NetRenderSettings.jobs = CollectionProperty(type=NetRenderJob, name="Job List", description="") - - NetRenderSlave.name = StringProperty( - name="Name of the slave", - description="", - maxlen = 64, - default = "") - - NetRenderJob.name = StringProperty( - name="Name of the job", - description="", - maxlen = 128, - default = "") diff --git a/release/scripts/io/netrender/utils.py b/release/scripts/io/netrender/utils.py deleted file mode 100644 index ed9fb2de812..00000000000 --- a/release/scripts/io/netrender/utils.py +++ /dev/null @@ -1,313 +0,0 @@ -# ##### 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 ##### - -import sys, os -import re -import http, http.client, http.server, urllib, socket -import subprocess, shutil, time, hashlib, zlib - -import netrender.model - -try: - import bpy -except: - bpy = None - -VERSION = bytes("1.3", encoding='utf8') - -# Jobs status -JOB_WAITING = 0 # before all data has been entered -JOB_PAUSED = 1 # paused by user -JOB_FINISHED = 2 # finished rendering -JOB_QUEUED = 3 # ready to be dispatched - -JOB_STATUS_TEXT = { - JOB_WAITING: "Waiting", - JOB_PAUSED: "Paused", - JOB_FINISHED: "Finished", - JOB_QUEUED: "Queued" - } - - -# Frames status -QUEUED = 0 -DISPATCHED = 1 -DONE = 2 -ERROR = 3 - -FRAME_STATUS_TEXT = { - QUEUED: "Queued", - DISPATCHED: "Dispatched", - DONE: "Done", - ERROR: "Error" - } - -class DirectoryContext: - def __init__(self, path): - self.path = path - - def __enter__(self): - self.curdir = os.path.abspath(os.curdir) - os.chdir(self.path) - - def __exit__(self, exc_type, exc_value, traceback): - os.chdir(self.curdir) - -class BreakableIncrementedSleep: - def __init__(self, increment, default_timeout, max_timeout, break_fct): - self.increment = increment - self.default = default_timeout - self.max = max_timeout - self.current = self.default - self.break_fct = break_fct - - def reset(self): - self.current = self.default - - def increase(self): - self.current = min(self.current + self.increment, self.max) - - def sleep(self): - for i in range(self.current): - time.sleep(1) - if self.break_fct(): - break - - self.increase() - -def responseStatus(conn): - response = conn.getresponse() - response.read() - return response.status - -def reporting(report, message, errorType = None): - if errorType: - t = 'ERROR' - else: - t = 'INFO' - - if report: - report(t, message) - return None - elif errorType: - raise errorType(message) - else: - return None - -def clientScan(report = None): - try: - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) - s.settimeout(30) - - s.bind(('', 8000)) - - buf, address = s.recvfrom(64) - - address = address[0] - port = int(str(buf, encoding='utf8')) - - reporting(report, "Master server found") - - return (address, port) - except socket.timeout: - reporting(report, "No master server on network", IOError) - - return ("", 8000) # return default values - -def clientConnection(address, port, report = None, scan = True, timeout = 5): - if address == "[default]": -# calling operator from python is fucked, scene isn't in context -# if bpy: -# bpy.ops.render.netclientscan() -# else: - if not scan: - return None - - address, port = clientScan() - if address == "": - return None - - try: - conn = http.client.HTTPConnection(address, port, timeout = timeout) - - if conn: - if clientVerifyVersion(conn): - return conn - else: - conn.close() - reporting(report, "Incorrect master version", ValueError) - except BaseException as err: - if report: - report('ERROR', str(err)) - return None - else: - print(err) - return None - -def clientVerifyVersion(conn): - conn.request("GET", "/version") - response = conn.getresponse() - - if response.status != http.client.OK: - conn.close() - return False - - server_version = response.read() - - if server_version != VERSION: - print("Incorrect server version!") - print("expected", str(VERSION, encoding='utf8'), "received", str(server_version, encoding='utf8')) - return False - - return True - -def fileURL(job_id, file_index): - return "/file_%s_%i" % (job_id, file_index) - -def logURL(job_id, frame_number): - return "/log_%s_%i.log" % (job_id, frame_number) - -def renderURL(job_id, frame_number): - return "/render_%s_%i.exr" % (job_id, frame_number) - -def cancelURL(job_id): - return "/cancel_%s" % (job_id) - -def hashFile(path): - f = open(path, "rb") - value = hashData(f.read()) - f.close() - return value - -def hashData(data): - m = hashlib.md5() - m.update(data) - return m.hexdigest() - - -def prefixPath(prefix_directory, file_path, prefix_path, force = False): - if (os.path.isabs(file_path) or - len(file_path) >= 3 and (file_path[1:3] == ":/" or file_path[1:3] == ":\\") or # Windows absolute path don't count as absolute on unix, have to handle them myself - file_path[0] == "/" or file_path[0] == "\\"): # and vice versa - - # if an absolute path, make sure path exists, if it doesn't, use relative local path - full_path = file_path - if force or not os.path.exists(full_path): - p, n = os.path.split(os.path.normpath(full_path)) - - if prefix_path and p.startswith(prefix_path): - if len(prefix_path) < len(p): - directory = os.path.join(prefix_directory, p[len(prefix_path)+1:]) # +1 to remove separator - if not os.path.exists(directory): - os.mkdir(directory) - else: - directory = prefix_directory - full_path = os.path.join(directory, n) - else: - full_path = os.path.join(prefix_directory, n) - else: - full_path = os.path.join(prefix_directory, file_path) - - return full_path - -def getResults(server_address, server_port, job_id, resolution_x, resolution_y, resolution_percentage, frame_ranges): - if bpy.app.debug: - print("=============================================") - print("============= FETCHING RESULTS ==============") - - frame_arguments = [] - for r in frame_ranges: - if len(r) == 2: - frame_arguments.extend(["-s", str(r[0]), "-e", str(r[1]), "-a"]) - else: - frame_arguments.extend(["-f", str(r[0])]) - - filepath = os.path.join(bpy.app.tempdir, "netrender_temp.blend") - bpy.ops.wm.save_as_mainfile(filepath=filepath, copy=True, check_existing=False) - - arguments = [sys.argv[0], "-b", "-noaudio", filepath, "-o", bpy.path.abspath(bpy.context.scene.render.filepath), "-P", __file__] + frame_arguments + ["--", "GetResults", server_address, str(server_port), job_id, str(resolution_x), str(resolution_y), str(resolution_percentage)] - if bpy.app.debug: - print("Starting subprocess:") - print(" ".join(arguments)) - - process = subprocess.Popen(arguments, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - while process.poll() is None: - stdout = process.stdout.read(1024) - if bpy.app.debug: - print(str(stdout, encoding='utf-8'), end="") - - - # read leftovers if needed - stdout = process.stdout.read() - if bpy.app.debug: - print(str(stdout, encoding='utf-8')) - - os.remove(filepath) - - if bpy.app.debug: - print("=============================================") - return - -def _getResults(server_address, server_port, job_id, resolution_x, resolution_y, resolution_percentage): - render = bpy.context.scene.render - - netsettings = bpy.context.scene.network_render - - netsettings.server_address = server_address - netsettings.server_port = int(server_port) - netsettings.job_id = job_id - - render.engine = 'NET_RENDER' - render.resolution_x = int(resolution_x) - render.resolution_y = int(resolution_y) - render.resolution_percentage = int(resolution_percentage) - - render.use_full_sample = False - render.use_compositing = False - render.use_border = False - - -def getFileInfo(filepath, infos): - process = subprocess.Popen([sys.argv[0], "-b", "-noaudio", filepath, "-P", __file__, "--", "FileInfo"] + infos, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - stdout = bytes() - while process.poll() is None: - stdout += process.stdout.read(1024) - - # read leftovers if needed - stdout += process.stdout.read() - - stdout = str(stdout, encoding="utf8") - - values = [eval(v[1:].strip()) for v in stdout.split("\n") if v.startswith("$")] - - return values - - -if __name__ == "__main__": - try: - start = sys.argv.index("--") + 1 - except ValueError: - start = 0 - action, *args = sys.argv[start:] - - if action == "FileInfo": - for info in args: - print("$", eval(info)) - elif action == "GetResults": - _getResults(args[0], args[1], args[2], args[3], args[4], args[5]) diff --git a/release/scripts/io/netrender/versioning.py b/release/scripts/io/netrender/versioning.py deleted file mode 100644 index d4f8522cce8..00000000000 --- a/release/scripts/io/netrender/versioning.py +++ /dev/null @@ -1,72 +0,0 @@ -import sys, os -import re -import subprocess - -from netrender.utils import * - -class AbstractVCS: - name = "ABSTRACT VCS" - def __init__(self): - pass - - def update(self, info): - """update(info) - Update a working copy to the specified revision. - If working copy doesn't exist, do a full get from server to create it. - [info] model.VersioningInfo instance, specifies the working path, remote path and version number.""" - pass - - def revision(self, path): - """revision(path) - return the current revision of the specified working copy path""" - pass - - def path(self, path): - """path(path) - return the remote path of the specified working copy path""" - pass - -class Subversion(AbstractVCS): - name = "Subversion" - def __init__(self): - super().__init__() - self.version_exp = re.compile("([0-9]*)") - self.path_exp = re.compile("URL: (.*)") - - def update(self, info): - if not os.path.exists(info.wpath): - base, folder = os.path.split(info.wpath) - - with DirectoryContext(base): - subprocess.call(["svn", "co", "%s@%s" % (info.rpath, str(info.revision)), folder]) - else: - with DirectoryContext(info.wpath): - subprocess.call(["svn", "up", "--accept", "theirs-full", "-r", str(info.revision)]) - - def revision(self, path): - if not os.path.exists(path): - return - - with DirectoryContext(path): - stdout = subprocess.check_output(["svnversion"]) - - match = self.version_exp.match(str(stdout, encoding="utf-8")) - - if match: - return match.group(1) - - def path(self, path): - if not os.path.exists(path): - return - - with DirectoryContext(path): - stdout = subprocess.check_output(["svn", "info"]) - - match = self.path_exp.search(str(stdout, encoding="utf-8")) - - if match: - return match.group(1) - -SYSTEMS = { - Subversion.name: Subversion() - } From 2299d674f43e6ce9a872f30517fa6dfdeef75cc1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 02:38:39 +0000 Subject: [PATCH 012/261] operators called from python were not getting their reports back into python errors. eg: - console calls operator - operator calls report - report went into header rather them back into the console as an error. --- source/blender/makesdna/DNA_windowmanager_types.h | 3 ++- source/blender/python/intern/bpy_operator.c | 2 +- source/blender/windowmanager/intern/wm_event_system.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 958c9cffc84..3072c2c3430 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -85,7 +85,8 @@ typedef enum ReportType { enum ReportListFlags { RPT_PRINT = 1, RPT_STORE = 2, - RPT_FREE = 4 + RPT_FREE = 4, + RPT_OP_HOLD = 8 /* dont move them into the operator global list (caller will use) */ }; # # diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index a116aa0e9c0..ebe6e05ee43 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -195,7 +195,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) ReportList *reports; reports= MEM_mallocN(sizeof(ReportList), "wmOperatorReportList"); - BKE_reports_init(reports, RPT_STORE); + BKE_reports_init(reports, RPT_STORE | RPT_OP_HOLD); /* own so these dont move into global reports */ operator_ret= WM_operator_call_py(C, ot, context, &ptr, reports); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 20f9a4b7a51..15964b8c1e5 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -453,7 +453,8 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int pop } } - if (op->reports->list.first) { + /* if the caller owns them them handle this */ + if (op->reports->list.first && (op->reports->flag & RPT_OP_HOLD) == 0) { wmWindowManager *wm = CTX_wm_manager(C); ReportList *wm_reports= CTX_wm_reports(C); From 3384679aecfe93ae72bd34eb9b17095db2603eb2 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Tue, 22 Mar 2011 02:39:08 +0000 Subject: [PATCH 013/261] BGE Dynamic Loading: * Adding keyword arguments to LibLoad - load_actions (Default: False) Ensures that all actions are loaded. Otherwise, just actions used by objects in the scene are loaded. - verbose (Default: False) Turns on extra prints (eg SceneName: MyScene). * Also making error reporting better for when an invalid group/idcode is given. --- .../Converter/KX_BlenderSceneConverter.cpp | 50 ++++++++++++++++--- .../Converter/KX_BlenderSceneConverter.h | 13 +++-- source/gameengine/Ketsji/KX_PythonInit.cpp | 22 ++++++-- 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 411844841de..99cd30c76ed 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -932,23 +932,23 @@ Main* KX_BlenderSceneConverter::GetMainDynamicPath(const char *path) return NULL; } -bool KX_BlenderSceneConverter::LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str) +bool KX_BlenderSceneConverter::LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options) { BlendHandle *bpy_openlib = BLO_blendhandle_from_memory(data, length); // Error checking is done in LinkBlendFile - return LinkBlendFile(bpy_openlib, path, group, scene_merge, err_str); + return LinkBlendFile(bpy_openlib, path, group, scene_merge, err_str, options); } -bool KX_BlenderSceneConverter::LinkBlendFilePath(const char *path, char *group, KX_Scene *scene_merge, char **err_str) +bool KX_BlenderSceneConverter::LinkBlendFilePath(const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options) { BlendHandle *bpy_openlib = BLO_blendhandle_from_file((char *)path, NULL); // Error checking is done in LinkBlendFile - return LinkBlendFile(bpy_openlib, path, group, scene_merge, err_str); + return LinkBlendFile(bpy_openlib, path, group, scene_merge, err_str, options); } -bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str) +bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options) { bContext *C; Main *main_newlib; /* stored as a dynamic 'main' until we free it */ @@ -962,6 +962,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha /* only scene and mesh supported right now */ if(idcode!=ID_SCE && idcode!=ID_ME &&idcode!=ID_AC) { snprintf(err_local, sizeof(err_local), "invalid ID type given \"%s\"\n", group); + *err_str= err_local; BLO_blendhandle_close(bpy_openlib); return false; } @@ -1000,6 +1001,26 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha BLI_linklist_free(names, free); /* free linklist *and* each node's data */ BLO_library_append_end(C, main_tmp, &bpy_openlib, idcode, flag); + + /* now do another round of linking for Scenes so all actions are properly loaded */ + if (idcode==ID_SCE && options & LIB_LOAD_LOAD_ACTIONS) { + main_tmp = BLO_library_append_begin(C, &bpy_openlib, (char *)path); + + int totnames_dummy; + names = BLO_blendhandle_get_datablock_names( bpy_openlib, ID_AC, &totnames_dummy); + + int i=0; + LinkNode *n= names; + while(n) { + BLO_library_append_named_part(C, main_tmp, &bpy_openlib, (char *)n->link, ID_AC, 0); + n= (LinkNode *)n->next; + i++; + } + BLI_linklist_free(names, free); /* free linklist *and* each node's data */ + + BLO_library_append_end(C, main_tmp, &bpy_openlib, ID_AC, flag); + } + BLO_blendhandle_close(bpy_openlib); CTX_free(C); @@ -1016,6 +1037,8 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha ID* mesh; for(mesh= (ID *)main_newlib->mesh.first; mesh; mesh= (ID *)mesh->next ) { + if (options & LIB_LOAD_VERBOSE) + printf("MeshName: %s\n", mesh->name+2); RAS_MeshObject *meshobj = BL_ConvertMesh((Mesh *)mesh, NULL, scene_merge, this); scene_merge->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj); } @@ -1025,7 +1048,8 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha ID *action; for(action= (ID *)main_newlib->action.first; action; action= (ID *)action->next) { - printf("ActionName: %s\n", action->name); + if (options & LIB_LOAD_VERBOSE) + printf("ActionName: %s\n", action->name+2); scene_merge->GetLogicManager()->RegisterActionName(action->name+2, action); } } @@ -1033,7 +1057,8 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha /* Merge all new linked in scene into the existing one */ ID *scene; for(scene= (ID *)main_newlib->scene.first; scene; scene= (ID *)scene->next ) { - printf("SceneName: %s\n", scene->name); + if (options & LIB_LOAD_VERBOSE) + printf("SceneName: %s\n", scene->name+2); /* merge into the base scene */ KX_Scene* other= m_ketsjiEngine->CreateScene((Scene *)scene); @@ -1042,6 +1067,17 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha // RemoveScene(other); // Dont run this, it frees the entire scene converter data, just delete the scene delete other; } + + /* Now handle all the actions */ + if (options & LIB_LOAD_LOAD_ACTIONS) { + ID *action; + + for(action= (ID *)main_newlib->action.first; action; action= (ID *)action->next) { + if (options & LIB_LOAD_VERBOSE) + printf("ActionName: %s\n", action->name+2); + scene_merge->GetLogicManager()->RegisterActionName(action->name+2, action); + } + } } return true; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index f99ed3aa412..741b3ea8757 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -147,9 +147,9 @@ public: struct Main* GetMainDynamicPath(const char *path); vector &GetMainDynamic(); - bool LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str); - bool LinkBlendFilePath(const char *path, char *group, KX_Scene *scene_merge, char **err_str); - bool LinkBlendFile(struct BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str); + bool LinkBlendFileMemory(void *data, int length, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options); + bool LinkBlendFilePath(const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options); + bool LinkBlendFile(struct BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options); bool MergeScene(KX_Scene *to, KX_Scene *from); RAS_MeshObject *ConvertMeshSpecial(KX_Scene* kx_scene, Main *maggie, const char *name); bool FreeBlendFile(struct Main *maggie); @@ -176,6 +176,13 @@ public: #endif // /printf("\t m_ketsjiEngine->m_scenes: %d\n", m_ketsjiEngine->CurrentScenes()->size()); } + + /* LibLoad Options */ + enum + { + LIB_LOAD_LOAD_ACTIONS = 1, + LIB_LOAD_VERBOSE = 2, + }; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 95831b38bfa..ad3f4b06323 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -638,7 +638,7 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) Py_RETURN_NONE; } -static PyObject *gLibLoad(PyObject*, PyObject* args) +static PyObject *gLibLoad(PyObject*, PyObject* args, PyObject* kwds) { KX_Scene *kx_scene= gp_KetsjiScene; char *path; @@ -646,10 +646,22 @@ static PyObject *gLibLoad(PyObject*, PyObject* args) Py_buffer py_buffer; py_buffer.buf = NULL; char *err_str= NULL; + + short options=0; + int load_actions=0, verbose=0; + + static const char *kwlist[] = {"path", "group", "buffer", "load_actions", "verbose", NULL}; - if (!PyArg_ParseTuple(args,"ss|y*:LibLoad",&path, &group, &py_buffer)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|y*ii:LibLoad", const_cast(kwlist), + &path, &group, &py_buffer, &load_actions, &verbose)) return NULL; + /* setup options */ + if (load_actions != 0) + options |= KX_BlenderSceneConverter::LIB_LOAD_LOAD_ACTIONS; + if (verbose != 0) + options |= KX_BlenderSceneConverter::LIB_LOAD_VERBOSE; + if (!py_buffer.buf) { char abs_path[FILE_MAX]; @@ -657,14 +669,14 @@ static PyObject *gLibLoad(PyObject*, PyObject* args) BLI_strncpy(abs_path, path, sizeof(abs_path)); BLI_path_abs(abs_path, gp_GamePythonPath); - if(kx_scene->GetSceneConverter()->LinkBlendFilePath(abs_path, group, kx_scene, &err_str)) { + if(kx_scene->GetSceneConverter()->LinkBlendFilePath(abs_path, group, kx_scene, &err_str, options)) { Py_RETURN_TRUE; } } else { - if(kx_scene->GetSceneConverter()->LinkBlendFileMemory(py_buffer.buf, py_buffer.len, path, group, kx_scene, &err_str)) { + if(kx_scene->GetSceneConverter()->LinkBlendFileMemory(py_buffer.buf, py_buffer.len, path, group, kx_scene, &err_str, options)) { PyBuffer_Release(&py_buffer); Py_RETURN_TRUE; } @@ -798,7 +810,7 @@ static struct PyMethodDef game_methods[] = { {"PrintMemInfo", (PyCFunction)pyPrintStats, METH_NOARGS, (const char *)"Print engine stastics"}, /* library functions */ - {"LibLoad", (PyCFunction)gLibLoad, METH_VARARGS, (const char *)""}, + {"LibLoad", (PyCFunction)gLibLoad, METH_VARARGS|METH_KEYWORDS, (const char *)""}, {"LibNew", (PyCFunction)gLibNew, METH_VARARGS, (const char *)""}, {"LibFree", (PyCFunction)gLibFree, METH_VARARGS, (const char *)""}, {"LibList", (PyCFunction)gLibList, METH_VARARGS, (const char *)""}, From 1b80538fea5b42f5b3111066f617d94a4ffc180c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 04:28:51 +0000 Subject: [PATCH 014/261] fix [#25688] undocumted functions in pyapi expose collection function docs. --- doc/python_api/sphinx_doc_gen.py | 75 ++++++++++++------- release/scripts/modules/rna_info.py | 6 +- .../editors/transform/transform_manipulator.c | 9 +-- source/blender/python/intern/bpy_rna.c | 42 ++++++++++- 4 files changed, 94 insertions(+), 38 deletions(-) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index e51ea516158..bc190231e36 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -36,7 +36,7 @@ For HTML generation sphinx-build doc/python_api/sphinx-in doc/python_api/sphinx-out - assuming that you have sphinx 0.6.7 installed + assuming that you have sphinx 1.0.7 installed For PDF generation ------------------ @@ -61,7 +61,7 @@ else: "bpy.app", "bpy.path", "bpy.data", - #"bpy.props", + "bpy.props", "bpy.utils", "bpy.context", # "bpy.types", # supports filtering @@ -102,8 +102,13 @@ EXAMPLE_SET = set() EXAMPLE_SET_USED = set() _BPY_STRUCT_FAKE = "bpy_struct" +_BPY_PROP_COLLECTION_FAKE = "bpy_prop_collection" _BPY_FULL_REBUILD = False +if _BPY_PROP_COLLECTION_FAKE: + _BPY_PROP_COLLECTION_ID = ":class:`%s`" % _BPY_PROP_COLLECTION_FAKE +else: + _BPY_PROP_COLLECTION_ID = "collection" def undocumented_message(module_name, type_name, identifier): if str(type_name).startswith('ptr, "constraint_axis", constraint_axis); WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, op->ptr); - //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL); + //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL, FALSE); } else if (drawflags & MAN_SCALE_C) { switch(drawflags) { @@ -1654,11 +1653,11 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) } RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); WM_operator_name_call(C, "TRANSFORM_OT_resize", WM_OP_INVOKE_DEFAULT, op->ptr); - //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_resize", 0), event, op->ptr, NULL); + //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_resize", 0), event, op->ptr, NULL, FALSE); } else if (drawflags == MAN_ROT_T) { /* trackball need special case, init is different */ - //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_trackball", 0), event, op->ptr, NULL); WM_operator_name_call(C, "TRANSFORM_OT_trackball", WM_OP_INVOKE_DEFAULT, op->ptr); + //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_trackball", 0), event, op->ptr, NULL, FALSE); } else if (drawflags & MAN_ROT_C) { switch(drawflags) { @@ -1674,7 +1673,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) } RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); WM_operator_name_call(C, "TRANSFORM_OT_rotate", WM_OP_INVOKE_DEFAULT, op->ptr); - //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_rotate", 0), event, op->ptr, NULL); + //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_rotate", 0), event, op->ptr, NULL, FALSE); } } /* after transform, restore drawflags */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 6ae38d66781..0dfc98de487 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3294,6 +3294,14 @@ static PyGetSetDef pyrna_struct_getseters[]= { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; +static char pyrna_prop_collection_keys_doc[] = +".. method:: keys()\n" +"\n" +" Return the identifiers of collection members (matching pythons dict.keys() functionality).\n" +"\n" +" :return: the identifiers for each member of this collection.\n" +" :rtype: list of stings\n" +; static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self) { PyObject *ret= PyList_New(0); @@ -3319,6 +3327,14 @@ static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self) return ret; } +static char pyrna_prop_collection_items_doc[] = +".. method:: items()\n" +"\n" +" Return the identifiers of collection members (matching pythons dict.items() functionality).\n" +"\n" +" :return: (key, value) pairs for each member of this collection.\n" +" :rtype: list of tuples\n" +; static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self) { PyObject *ret= PyList_New(0); @@ -3352,6 +3368,14 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self) return ret; } +static char pyrna_prop_collection_values_doc[] = +".. method:: values()\n" +"\n" +" Return the values of collection (matching pythons dict.values() functionality).\n" +"\n" +" :return: the members of this collection.\n" +" :rtype: list\n" +; static PyObject *pyrna_prop_collection_values(BPy_PropertyRNA *self) { /* re-use slice*/ @@ -3414,6 +3438,16 @@ static PyObject *pyrna_struct_as_pointer(BPy_StructRNA *self) return PyLong_FromVoidPtr(self->ptr.data); } +static char pyrna_prop_collection_get_doc[] = +".. method:: get(key, default=None)\n" +"\n" +" Returns the value of the item assigned to key or default when not found (matches pythons dictionary function of the same name).\n" +"\n" +" :arg key: The identifier for the collection member.\n" +" :type key: string\n" +" :arg default: Optional argument for the value to return if *key* is not found.\n" +" :type default: Undefined\n" +; static PyObject *pyrna_prop_collection_get(BPy_PropertyRNA *self, PyObject *args) { PointerRNA newptr; @@ -3804,11 +3838,11 @@ static struct PyMethodDef pyrna_prop_collection_methods[]= { {"foreach_get", (PyCFunction)pyrna_prop_collection_foreach_get, METH_VARARGS, pyrna_prop_collection_foreach_get_doc}, {"foreach_set", (PyCFunction)pyrna_prop_collection_foreach_set, METH_VARARGS, pyrna_prop_collection_foreach_set_doc}, - {"keys", (PyCFunction)pyrna_prop_collection_keys, METH_NOARGS, NULL}, - {"items", (PyCFunction)pyrna_prop_collection_items, METH_NOARGS, NULL}, - {"values", (PyCFunction)pyrna_prop_collection_values, METH_NOARGS, NULL}, + {"keys", (PyCFunction)pyrna_prop_collection_keys, METH_NOARGS, pyrna_prop_collection_keys_doc}, + {"items", (PyCFunction)pyrna_prop_collection_items, METH_NOARGS, pyrna_prop_collection_items_doc}, + {"values", (PyCFunction)pyrna_prop_collection_values, METH_NOARGS, pyrna_prop_collection_values_doc}, - {"get", (PyCFunction)pyrna_prop_collection_get, METH_VARARGS, NULL}, + {"get", (PyCFunction)pyrna_prop_collection_get, METH_VARARGS, pyrna_prop_collection_get_doc}, {NULL, NULL, 0, NULL} }; From a5867232b1e91db7f7d1d2071de341297e86cf22 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 08:21:16 +0000 Subject: [PATCH 015/261] poll functions were for keymap operators were still raising errors in some cases. remove unused script dirs. --- release/scripts/startup/bl_ui/space_userpref_keymap.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index 4b3ff36abe9..e401a895a23 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -710,7 +710,8 @@ class WM_OT_keyitem_restore(bpy.types.Operator): @classmethod def poll(cls, context): - return hasattr(context, "keymap") and context.keymap.is_user_defined + keymap = getattr(context, "keymap", None) + return keymap and keymap.is_user_defined def execute(self, context): km = context.keymap @@ -772,7 +773,8 @@ class WM_OT_keyconfig_remove(bpy.types.Operator): @classmethod def poll(cls, context): wm = context.window_manager - return wm.keyconfigs.active.is_user_defined + keyconf = wm.keyconfigs.active + return keyconf and keyconf.is_user_defined def execute(self, context): wm = context.window_manager From 91e4a1bdf8c1b7cee7ac5c508775bcd3180b94b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 08:30:07 +0000 Subject: [PATCH 016/261] fix for crashes moving armature layers and applying loc/scale/rot in armature editmode. --- source/blender/editors/armature/poseobject.c | 32 +++++++++++-------- .../blender/editors/object/object_transform.c | 6 ++-- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 6baf76192a6..23253c0b4cf 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -1707,20 +1707,23 @@ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev static int pose_armature_layers_exec (bContext *C, wmOperator *op) { Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); - bArmature *arm= (ob)? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - + + if(ob==NULL || ob->data==NULL) { + return OPERATOR_CANCELLED; + } + /* get the values set in the operator properties */ RNA_boolean_get_array(op->ptr, "layers", layers); - + /* get pointer for armature, and write data there... */ - RNA_id_pointer_create((ID *)arm, &ptr); + RNA_id_pointer_create((ID *)ob->data, &ptr); RNA_boolean_set_array(&ptr, "layers", layers); - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -1794,25 +1797,28 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) static int pose_bone_layers_exec (bContext *C, wmOperator *op) { Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); - bArmature *arm= (ob)? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - + + if(ob==NULL || ob->data==NULL) { + return OPERATOR_CANCELLED; + } + /* get the values set in the operator properties */ RNA_boolean_get_array(op->ptr, "layers", layers); - + /* set layers of pchans based on the values set in the operator props */ - CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones) + CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones) { /* get pointer for pchan, and write flags this way */ - RNA_pointer_create((ID *)arm, &RNA_Bone, pchan->bone, &ptr); + RNA_pointer_create((ID *)ob->data, &RNA_Bone, pchan->bone, &ptr); RNA_boolean_set_array(&ptr, "layers", layers); } CTX_DATA_END; - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); - + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index c373f30a6ac..c41a1bf9a75 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -607,7 +607,7 @@ void OBJECT_OT_location_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= location_apply_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* editmode will crash */ /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -627,7 +627,7 @@ void OBJECT_OT_scale_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= scale_apply_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -647,7 +647,7 @@ void OBJECT_OT_rotation_apply(wmOperatorType *ot) /* api callbacks */ ot->exec= rotation_apply_exec; - ot->poll= ED_operator_scene_editable; + ot->poll= ED_operator_objectmode; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; From 481b4842cf1f1feae8b0c777eb56275400047074 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Tue, 22 Mar 2011 08:35:56 +0000 Subject: [PATCH 017/261] Blenderplayer: Fixing import issues. Using PyImport_ExtendInittab() for the Blender modules allows them to be imported in the Blenderplayer. --- source/gameengine/Ketsji/KX_PythonInit.cpp | 36 +++++++--------------- source/gameengine/Ketsji/KX_PythonInit.h | 4 --- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index ad3f4b06323..d274b3e4eac 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1917,6 +1917,15 @@ static void restorePySysObjects(void) // PyObject_Print(sys_path, stderr, 0); } +// Copied from bpy_interface.c +static struct _inittab bpy_internal_modules[]= { + {"mathutils", BPyInit_mathutils}, + {"bgl", BPyInit_bgl}, + {"blf", BPyInit_blf}, + {"aud", AUD_initPython}, + {NULL, NULL} +}; + /** * Python is not initialised. */ @@ -1957,6 +1966,8 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur bpy_import_main_set(maggie); initPySysObjects(maggie); + + PyImport_ExtendInittab(bpy_internal_modules); first_time = false; @@ -2045,11 +2056,6 @@ void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main * initGameKeys(); initPythonConstraintBinding(); - initMathutils(); - initGeometry(); - initBGL(); - initBLF(); - AUD_initPython(); initVideoTexture(); /* could be done a lot more nicely, but for now a quick way to get bge.* working */ @@ -2358,26 +2364,6 @@ PyObject* initGameKeys() return d; } -PyObject* initMathutils() -{ - return BPyInit_mathutils(); -} - -PyObject* initGeometry() -{ - return BPyInit_mathutils_geometry(); -} - -PyObject* initBGL() -{ - return BPyInit_bgl(); -} - -PyObject* initBLF() -{ - return BPyInit_blf(); -} - // utility function for loading and saving the globalDict int saveGamePythonConfig( char **marshal_buffer) { diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index f062aa2d661..1b172c35eff 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -49,10 +49,6 @@ PyObject* initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene* ketsjisce PyObject* initGameKeys(); PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas); PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level, struct Main *maggie, int argc, char** argv); -PyObject* initMathutils(); -PyObject* initGeometry(); -PyObject* initBGL(); -PyObject* initBLF(); PyObject* initVideoTexture(void); void exitGamePlayerPythonScripting(); PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, struct Main *maggie); From a1567aa7c081ce6a3c7b24b7a772323940faa437 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 22 Mar 2011 08:58:49 +0000 Subject: [PATCH 018/261] Printing error message would fail on exception. --- build_files/package_spec/build_archive.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build_files/package_spec/build_archive.py b/build_files/package_spec/build_archive.py index 3c41cd5911e..2496c2295eb 100755 --- a/build_files/package_spec/build_archive.py +++ b/build_files/package_spec/build_archive.py @@ -27,8 +27,8 @@ try: os.remove(package_archive) if os.path.exists(package_dir): shutil.rmtree(package_dir) -except: - sys.stderr.write('Failed to clean up old package files: ' + sys.exc_info()[0] + '\n') +except Exception, ex: + sys.stderr.write('Failed to clean up old package files: ' + str(ex) + '\n') sys.exit(1) # create temporary package dir @@ -38,8 +38,8 @@ try: for f in os.listdir(package_dir): if f.startswith('makes'): os.remove(os.path.join(package_dir, f)) -except: - sys.stderr.write('Failed to copy install directory: ' + sys.exc_info()[0] + '\n') +except Exception, ex: + sys.stderr.write('Failed to copy install directory: ' + str(ex) + '\n') sys.exit(1) # create archive @@ -56,13 +56,13 @@ try: sys.exit(-1) subprocess.call(archive_cmd) -except: - sys.stderr.write('Failed to create package archive: ' + sys.exc_info()[0] + '\n') +except Exception, ex: + sys.stderr.write('Failed to create package archive: ' + str(ex) + '\n') sys.exit(1) # empty temporary package dir try: shutil.rmtree(package_dir) -except: - sys.stderr.write('Failed to clean up package directory: ' + sys.exc_info()[0] + '\n') +except Exception, ex: + sys.stderr.write('Failed to clean up package directory: ' + str(ex) + '\n') sys.exit(1) From cfc904f3f1a00556032e12bb72395e261574669b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 09:14:27 +0000 Subject: [PATCH 019/261] - support transform operators running in backgruond mode (was crashing) - fix for crash getting the extrude mode enum value when a non-mesh edit object was active. --- source/blender/editors/mesh/editmesh_tools.c | 6 +++--- source/blender/editors/screen/area.c | 6 +++++- source/blender/editors/transform/transform.c | 2 +- source/blender/editors/transform/transform_generics.c | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index e22dab2f3c8..b4378829456 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -761,7 +761,7 @@ static EnumPropertyItem extrude_items[] = { {0, NULL, 0, NULL, NULL}}; -static EnumPropertyItem *extrude_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) +static EnumPropertyItem *mesh_extrude_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) { EnumPropertyItem *item= NULL; Object *obedit= CTX_data_edit_object(C); @@ -769,7 +769,7 @@ static EnumPropertyItem *extrude_itemf(bContext *C, PointerRNA *UNUSED(ptr), int int totitem= 0; - if(!obedit) + if(obedit==NULL || obedit->type != OB_MESH) return extrude_items; em = BKE_mesh_get_editmesh(obedit->data); @@ -849,7 +849,7 @@ void MESH_OT_extrude(wmOperatorType *ot) /* properties */ prop= RNA_def_enum(ot->srna, "type", extrude_items, 0, "Type", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - RNA_def_enum_funcs(prop, extrude_itemf); + RNA_def_enum_funcs(prop, mesh_extrude_itemf); ot->prop= prop; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 7af5064218e..4a54b0ab0e4 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -431,7 +431,11 @@ void ED_area_tag_refresh(ScrArea *sa) void ED_area_headerprint(ScrArea *sa, const char *str) { ARegion *ar; - + + /* happens when running transform operators in backround mode */ + if(sa == NULL) + return; + for(ar= sa->regionbase.first; ar; ar= ar->next) { if(ar->regiontype==RGN_TYPE_HEADER) { if(str) { diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e342ce6769a..0a055358902 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4298,7 +4298,7 @@ static int createSlideVerts(TransInfo *t) int uvlay_tot= CustomData_number_of_layers(&em->fdata, CD_MTFACE); int uvlay_idx; TransDataSlideUv *slideuvs=NULL, *suv=NULL, *suv_last=NULL; - RegionView3D *v3d = t->ar->regiondata; + RegionView3D *v3d = t->ar ? t->ar->regiondata : NULL; /* background mode support */ float projectMat[4][4]; float start[3] = {0.0f, 0.0f, 0.0f}, end[3] = {0.0f, 0.0f, 0.0f}; float vec[3]; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 1fb57f2820d..7358811a79c 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -964,7 +964,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) t->options |= CTX_EDGE; } - t->spacetype = sa->spacetype; + t->spacetype = sa ? sa->spacetype : SPACE_EMPTY; /* background mode */ if(t->spacetype == SPACE_VIEW3D) { View3D *v3d = sa->spacedata.first; From d485a54b599610de09e35e97d3844df3b9695575 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 10:13:42 +0000 Subject: [PATCH 020/261] crash fix for Normalize All VGroups on a lattice without vgroups (probably other tools too - bug was in ED_vgroup_give_parray). Also fix for crashes running operators in bg mode by using setting poll functions: WM_OT_search_menu, MESH_OT_extrude_repeat, SCREEN_OT_new --- source/blender/editors/mesh/editmesh_tools.c | 2 +- source/blender/editors/object/object_vgroup.c | 17 +++++++++++------ source/blender/editors/screen/screen_ops.c | 1 + .../blender/windowmanager/intern/wm_operators.c | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index b4378829456..68a76f5363d 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -944,7 +944,7 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot) /* api callbacks */ ot->exec= extrude_repeat_mesh; - ot->poll= ED_operator_editmesh; + ot->poll= ED_operator_editmesh_region_view3d; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index af18a709198..f1692c1150b 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -208,14 +208,19 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to Lattice *lt= (Lattice *)id; lt= (lt->editlatt)? lt->editlatt->latt: lt; - *dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw; - *dvert_arr= MEM_mallocN(sizeof(void*)*(*dvert_tot), "vgroup parray from me"); + if(lt->dvert) { + *dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw; + *dvert_arr= MEM_mallocN(sizeof(void*)*(*dvert_tot), "vgroup parray from me"); - for (i=0; i<*dvert_tot; i++) { - (*dvert_arr)[i] = lt->dvert + i; + for (i=0; i<*dvert_tot; i++) { + (*dvert_arr)[i] = lt->dvert + i; + } + + return 1; + } + else { + return 0; } - - return 1; } } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 72cc4a48105..5236d67fa55 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3111,6 +3111,7 @@ static void SCREEN_OT_new(wmOperatorType *ot) /* api callbacks */ ot->exec= screen_new_exec; + ot->poll= WM_operator_winactive; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 74c20457e1a..8aa89f6707d 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1320,6 +1320,7 @@ static void WM_OT_call_menu(wmOperatorType *ot) ot->idname= "WM_OT_call_menu"; ot->exec= wm_call_menu_exec; + ot->poll= WM_operator_winactive; RNA_def_string(ot->srna, "name", "", BKE_ST_MAXNAME, "Name", "Name of the menu"); } From d2a721cfd5d88efb4ea09fb557bf4737c959ff83 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 22 Mar 2011 10:26:53 +0000 Subject: [PATCH 021/261] Add buildslave target for builder.blender.org integration --- SConstruct | 7 +++ build_files/scons/tools/btools.py | 71 ++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 49c5ae98249..583cc0b144b 100644 --- a/SConstruct +++ b/SConstruct @@ -669,7 +669,14 @@ if 'blenderlite' in B.targets: Depends(nsiscmd, allinstall) +buildslave_action = env.Action(btools.buildslave, btools.buildslave_print) +buildslave_cmd = env.Command('buildslave_exec', None, buildslave_action) +buildslave_alias = env.Alias('buildslave', buildslave_cmd) + +Depends(buildslave_cmd, allinstall) + Default(B.program_list) if not env['WITHOUT_BF_INSTALL']: Default(installtarget) + diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 4554cad055d..3e1f497bec0 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -56,10 +56,16 @@ def get_version(): raise Exception("%s: missing version string" % fname) +def get_revision(): + build_rev = os.popen('svnversion').read()[:-1] # remove \n + if build_rev == '' or build_rev==None: + build_rev = 'UNKNOWN' + + return 'r' + build_rev # This is used in creating the local config directories VERSION, VERSION_DISPLAY = get_version() - +REVISION = get_revision() def print_arguments(args, bc): if len(args): @@ -175,7 +181,7 @@ def print_targets(targs, bc): def validate_targets(targs, bc): valid_list = ['.', 'blender', 'blenderstatic', 'blenderplayer', 'webplugin', 'blendernogame', 'blenderstaticnogame', 'blenderlite', 'release', - 'everything', 'clean', 'install-bin', 'install', 'nsis'] + 'everything', 'clean', 'install-bin', 'install', 'nsis','buildslave'] oklist = [] for t in targs: if t in valid_list: @@ -496,6 +502,67 @@ def read_opts(env, cfg, args): return localopts +def buildbot_zip(src, dest, package_name, extension): + import zipfile + ln = len(src)+1 # one extra to remove leading os.sep when cleaning root for package_root + flist = list() + + # create list of tuples containing file and archive name + for root, dirs, files in os.walk(src): + package_root = os.path.join(package_name, root[ln:]) + flist.extend([(os.path.join(root, file), os.path.join(package_root, file)) for file in files]) + + if extension == '.zip': + package = zipfile.ZipFile(dest, 'w', zipfile.ZIP_DEFLATED) + package.comment = package_name + ' is a zip-file containing the Blender software. Visit http://www.blender.org for more information.' + for entry in flist: + package.write(entry[0], entry[1]) + package.close() + else: + import tarfile + package = tarfile.open(dest, 'w:bz2') + for entry in flist: + package.add(entry[0], entry[1], recursive=False) + package.close() + bb_zip_name = os.path.normpath(src + os.sep + '..' + os.sep + 'buildbot_upload.zip') + print("creating %s" % (bb_zip_name)) + bb_zip = zipfile.ZipFile(bb_zip_name, 'w', zipfile.ZIP_DEFLATED) + print("writing %s to %s" % (dest, bb_zip_name)) + bb_zip.write(dest, os.path.split(dest)[1]) + bb_zip.close() + print("done.") + +def buildslave_print(target, source, env): + return "Running buildslave target" + +def buildslave(target=None, source=None, env=None): + """ + Builder for buildbot integration. Used by buildslaves of http://builder.blender.org only. + """ + + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'): + extension = '.zip' + else: + extension = '.tar.bz2' + + outdir = os.path.abspath(env['BF_INSTALLDIR']) + package_name = 'blender-' + env['OURPLATFORM'].split('-')[0] + '-'+VERSION+'-'+REVISION + 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) + + try: + if os.path.exists(package_archive): + os.remove(package_archive) + if os.path.exists(package_dir): + shutil.rmtree(package_dir) + except Exception, ex: + sys.stderr.write('Failed to clean up old package files: ' + str(ex) + '\n') + return 1 + + buildbot_zip(outdir, package_archive, package_name, extension) + + return 0 + def NSIS_print(target, source, env): return "Creating NSIS installer for Blender" From 82d13ad99996c5e7432e3aa15c547b2231bea2f7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 11:19:02 +0000 Subject: [PATCH 022/261] add missing mem-free on vertex group sorting & dont crash when calling fullscreen in bg mode. --- source/blender/editors/object/object_vgroup.c | 1 + source/blender/windowmanager/intern/wm_window.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index f1692c1150b..3b0c1ff62b0 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2055,6 +2055,7 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) } else { BKE_report(op->reports, RPT_ERROR, "Editmode lattice isnt supported yet."); + MEM_freeN(sort_map_update); return OPERATOR_CANCELLED; } } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index be33264cafd..a02ce3fe554 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -528,7 +528,12 @@ int wm_window_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { wmWindow *window= CTX_wm_window(C); - GHOST_TWindowState state = GHOST_GetWindowState(window->ghostwin); + GHOST_TWindowState state; + + if(G.background) + return OPERATOR_CANCELLED; + + state= GHOST_GetWindowState(window->ghostwin); if(state!=GHOST_kWindowStateFullScreen) GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen); else From a2acecc9d2624e3ae1b7a78b600caa0fa8a2d059 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 11:44:46 +0000 Subject: [PATCH 023/261] allow system info operator in background mode. --- release/scripts/modules/sys_info.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py index 16dfbf1bb3d..1272d81872d 100644 --- a/release/scripts/modules/sys_info.py +++ b/release/scripts/modules/sys_info.py @@ -51,8 +51,8 @@ def textWrap(text, length=70): def write_sysinfo(op): output_filename = "system-info.txt" - if output_filename in bpy.data.texts.keys(): - output = bpy.data.texts[output_filename] + output = bpy.data.texts.get(output_filename) + if output: output.clear() else: output = bpy.data.texts.new(name=output_filename) @@ -94,16 +94,19 @@ def write_sysinfo(op): output.write('autosave: {}\n'.format(bpy.utils.user_resource('AUTOSAVE'))) output.write('tempdir: {}\n'.format(bpy.app.tempdir)) - output.write('\nOpenGL\n') - output.write(lilies) - output.write('renderer:\t{}\n'.format(bgl.glGetString(bgl.GL_RENDERER))) - output.write('vendor:\t\t{}\n'.format(bgl.glGetString(bgl.GL_VENDOR))) - output.write('version:\t{}\n'.format(bgl.glGetString(bgl.GL_VERSION))) - output.write('extensions:\n') + if bpy.app.background: + output.write('\nOpenGL: missing, background mode\n') + else: + output.write('\nOpenGL\n') + output.write(lilies) + output.write('renderer:\t{}\n'.format(bgl.glGetString(bgl.GL_RENDERER))) + output.write('vendor:\t\t{}\n'.format(bgl.glGetString(bgl.GL_VENDOR))) + output.write('version:\t{}\n'.format(bgl.glGetString(bgl.GL_VERSION))) + output.write('extensions:\n') - glext = bgl.glGetString(bgl.GL_EXTENSIONS) - glext = textWrap(glext, 70) - for l in glext: - output.write('\t\t{}\n'.format(l)) + glext = bgl.glGetString(bgl.GL_EXTENSIONS) + glext = textWrap(glext, 70) + for l in glext: + output.write('\t\t{}\n'.format(l)) op.report({'INFO'}, "System information generated in 'system-info.txt'") From 4c3899ca09fd6b8d8acb70aa28148cf348794003 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 22 Mar 2011 12:53:18 +0000 Subject: [PATCH 024/261] Fixing the particle emitter interpolation (#25385 & #26493) further * The interpolation should only be done if the dynamics were calculated, since otherwise animation keys can't be set after parenting. --- .../blenkernel/intern/particle_system.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 9e57ad24648..088ab78ce47 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1577,7 +1577,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, part=psys->part; /* get precise emitter matrix if particle is born */ - if(part->type!=PART_HAIR && pa->time < cfra && pa->time >= sim->psys->cfra) { + if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) { /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ while(ob) { BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM); @@ -4334,17 +4334,19 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) } } + if(psys->cfra < cfra) { + /* make sure emitter is left at correct time (particle emission can change this) */ + while(ob) { + BKE_animsys_evaluate_animdata(&ob->id, ob->adt, cfra, ADT_RECALC_ANIM); + ob = ob->parent; + } + ob = sim.ob; + where_is_object_time(scene, ob, cfra); + } + psys->cfra = cfra; psys->recalc = 0; - /* make sure emitter is left at correct time (particle emission can change this) */ - while(ob) { - BKE_animsys_evaluate_animdata(&ob->id, ob->adt, cfra, ADT_RECALC_ANIM); - ob = ob->parent; - } - ob = sim.ob; - where_is_object_time(scene, ob, cfra); - /* save matrix for duplicators, at rendertime the actual dupliobject's matrix is used so don't update! */ if(psys->renderdata==0) invert_m4_m4(psys->imat, ob->obmat); From a79820d2849a6366353c7045e4fd5f161f6a70fa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 12:53:36 +0000 Subject: [PATCH 025/261] properties were being used with wrong type functions, this resulted in bad memory access when getting int from an enum. --- .../startup/bl_operators/vertexpaint_dirt.py | 4 +-- .../blender/editors/armature/armature_ops.c | 4 +-- source/blender/editors/curve/curve_ops.c | 2 +- source/blender/editors/curve/editcurve.c | 4 +-- source/blender/editors/metaball/mball_edit.c | 2 +- source/blender/editors/metaball/mball_ops.c | 2 +- source/blender/editors/physics/physics_ops.c | 2 +- .../blender/editors/space_action/action_ops.c | 2 +- .../blender/editors/space_graph/graph_ops.c | 2 +- source/blender/editors/space_nla/nla_edit.c | 2 +- .../editors/space_sequencer/sequencer_edit.c | 2 +- .../editors/space_sequencer/sequencer_ops.c | 2 +- .../blender/editors/transform/transform_ops.c | 26 +++++++++---------- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py b/release/scripts/startup/bl_operators/vertexpaint_dirt.py index ca8a3dedd0d..672db71e361 100644 --- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py +++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py @@ -162,8 +162,8 @@ class VertexPaintDirt(bpy.types.Operator): obj = context.object if not obj or obj.type != 'MESH': - print('Error, no active mesh object, aborting') - return('CANCELLED',) + self.report({'ERROR'}, "Error, no active mesh object, aborting") + return {'CANCELLED'} mesh = obj.data diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 254174dc090..34942a2edc1 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -180,7 +180,7 @@ void ED_operatormacros_armature(void) ot= WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", OPTYPE_UNDO|OPTYPE_REGISTER); if(ot) { otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); - RNA_enum_set(otmacro->ptr, "forked", 0); + RNA_boolean_set(otmacro->ptr, "forked", 0); otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); } @@ -190,7 +190,7 @@ void ED_operatormacros_armature(void) ot= WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", OPTYPE_UNDO|OPTYPE_REGISTER); if(ot) { otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); - RNA_enum_set(otmacro->ptr, "forked", 1); + RNA_boolean_set(otmacro->ptr, "forked", 1); otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); } diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index b1d499162eb..c8aabdfe033 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -231,7 +231,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CURVE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, 0, 0); - RNA_enum_set(WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index d4b96762ab8..a14a75fc545 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4731,7 +4731,7 @@ static int extrude_exec(bContext *C, wmOperator *UNUSED(op)) static int extrude_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if(extrude_exec(C, op) == OPERATOR_FINISHED) { - RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); + RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; @@ -5608,7 +5608,7 @@ static int duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { duplicate_exec(C, op); - RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); + RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 28c2a74f5b2..43871285ee5 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -302,7 +302,7 @@ static int duplicate_metaelems_invoke(bContext *C, wmOperator *op, wmEvent *UNUS int retv= duplicate_metaelems_exec(C, op); if (retv == OPERATOR_FINISHED) { - RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); + RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); } diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 615dc37016a..1b50cc6523a 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -65,7 +65,7 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MBALL_OT_reveal_metaelems", HKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "MBALL_OT_hide_metaelems", HKEY, KM_PRESS, 0, 0); - RNA_enum_set(WM_keymap_add_item(keymap, "MBALL_OT_hide_metaelems", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "MBALL_OT_hide_metaelems", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", DELKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 889ee2c9740..02b2fad7a00 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -108,7 +108,7 @@ static void keymap_particle(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PARTICLE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, 0, 0); - RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 38d221858b3..e07efcadb65 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -98,7 +98,7 @@ void ED_operatormacros_action(void) if (ot) { WM_operatortype_macro_define(ot, "ACTION_OT_duplicate"); otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); - RNA_int_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); + RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); } } diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index e2550bcf477..674d2809188 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -279,7 +279,7 @@ void ED_operatormacros_graph(void) if (ot) { WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate"); otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); - RNA_int_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); + RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); } } diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 300d38732ec..d9cd11b751f 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -656,7 +656,7 @@ static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED { nlaedit_duplicate_exec(C, op); - RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); + RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index b14904672d0..7a94ed2e6b6 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1656,7 +1656,7 @@ static int sequencer_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent * { sequencer_add_duplicate_exec(C, op); - RNA_int_set(op->ptr, "mode", TFM_TRANSLATION); + RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index f476f911ab6..f5c26cb17d3 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -180,7 +180,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) int i; for (i = 1; i <= 10; i++) { - RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut_multicam", keys[i-1], KM_PRESS, 0, 0)->ptr, "camera", i); + RNA_int_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut_multicam", keys[i-1], KM_PRESS, 0, 0)->ptr, "camera", i); } } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index a97d9e861ba..963fe2ffa8b 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -882,19 +882,19 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac break; case SPACE_ACTION: km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_TRANSLATE); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_TRANSLATE); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND); + RNA_enum_set(km->ptr, "mode", TFM_TIME_EXTEND); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_SCALE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_SCALE); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", TKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_SLIDE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_SLIDE); break; case SPACE_IPO: WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0); @@ -902,7 +902,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND); + RNA_enum_set(km->ptr, "mode", TFM_TIME_EXTEND); WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0); @@ -910,24 +910,24 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac break; case SPACE_NLA: km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TRANSLATION); + RNA_enum_set(km->ptr, "mode", TFM_TRANSLATION); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TRANSLATION); + RNA_enum_set(km->ptr, "mode", TFM_TRANSLATION); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND); + RNA_enum_set(km->ptr, "mode", TFM_TIME_EXTEND); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_SCALE); + RNA_enum_set(km->ptr, "mode", TFM_TIME_SCALE); break; case SPACE_NODE: WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0); km= WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_A, KM_ANY, 0, 0); - RNA_enum_set(km->ptr, "release_confirm", 1); + RNA_boolean_set(km->ptr, "release_confirm", 1); km= WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0); - RNA_enum_set(km->ptr, "release_confirm", 1); + RNA_boolean_set(km->ptr, "release_confirm", 1); WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0); @@ -939,7 +939,7 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac WM_keymap_add_item(keymap, OP_SEQ_SLIDE, EVT_TWEAK_S, KM_ANY, 0, 0); km= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0); - RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND); + RNA_enum_set(km->ptr, "mode", TFM_TIME_EXTEND); break; case SPACE_IMAGE: WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0); From e8dc841199aaabea86fa2d924e637ba56f312336 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 22 Mar 2011 12:54:13 +0000 Subject: [PATCH 026/261] Version and platform name were in wrong order. --- build_files/scons/tools/btools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 3e1f497bec0..17ee80e6dbd 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -546,7 +546,7 @@ def buildslave(target=None, source=None, env=None): extension = '.tar.bz2' outdir = os.path.abspath(env['BF_INSTALLDIR']) - package_name = 'blender-' + env['OURPLATFORM'].split('-')[0] + '-'+VERSION+'-'+REVISION + package_name = 'blender-' + VERSION+'-'+REVISION + '-' + env['OURPLATFORM'].split('-')[0] 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) From 5528781f793f0878a85f046c03f88b66adb4dd02 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 12:56:57 +0000 Subject: [PATCH 027/261] add BLI_assert() type checks for RNA property get/set functions, since there ended up being quite a lot of these in blenders source. These wont be compiled into release builds, and will only print errors by default (unless WITH_ASSERT_ABORT is enabled at compile time). --- source/blender/makesrna/intern/rna_access.c | 108 ++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 17dc775787e..0f14c1d85a2 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1331,6 +1331,8 @@ int RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop) BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN); + if((idprop=rna_idproperty_check(&prop, ptr))) return IDP_Int(idprop); else if(bprop->get) @@ -1344,6 +1346,8 @@ void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, int value) BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN); + /* just incase other values are passed */ if(value) value= 1; @@ -1368,6 +1372,8 @@ void RNA_property_boolean_get_array(PointerRNA *ptr, PropertyRNA *prop, int *val BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN); + if((idprop=rna_idproperty_check(&prop, ptr))) { if(prop->arraydimension == 0) values[0]= RNA_property_boolean_get(ptr, prop); @@ -1389,6 +1395,8 @@ int RNA_property_boolean_get_index(PointerRNA *ptr, PropertyRNA *prop, int index int tmp[RNA_MAX_ARRAY_LENGTH]; int len= rna_ensure_property_array_length(ptr, prop); + BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN); + if(len <= RNA_MAX_ARRAY_LENGTH) { RNA_property_boolean_get_array(ptr, prop, tmp); return tmp[index]; @@ -1410,6 +1418,8 @@ void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const in BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN); + if((idprop=rna_idproperty_check(&prop, ptr))) { if(prop->arraydimension == 0) IDP_Int(idprop)= values[0]; @@ -1441,6 +1451,8 @@ void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int inde int tmp[RNA_MAX_ARRAY_LENGTH]; int len= rna_ensure_property_array_length(ptr, prop); + BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN); + if(len <= RNA_MAX_ARRAY_LENGTH) { RNA_property_boolean_get_array(ptr, prop, tmp); tmp[index]= value; @@ -1460,6 +1472,9 @@ void RNA_property_boolean_set_index(PointerRNA *ptr, PropertyRNA *prop, int inde int RNA_property_boolean_get_default(PointerRNA *ptr, PropertyRNA *prop) { BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop; + + BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN); + return bprop->defaultvalue; } @@ -1467,6 +1482,8 @@ void RNA_property_boolean_get_default_array(PointerRNA *ptr, PropertyRNA *prop, { BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop; + BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN); + if(prop->arraydimension == 0) values[0]= bprop->defaultvalue; else if(bprop->defaultarray) @@ -1480,6 +1497,8 @@ int RNA_property_boolean_get_default_index(PointerRNA *ptr, PropertyRNA *prop, i int tmp[RNA_MAX_ARRAY_LENGTH]; int len= rna_ensure_property_array_length(ptr, prop); + BLI_assert(RNA_property_type(prop) == PROP_BOOLEAN); + if(len <= RNA_MAX_ARRAY_LENGTH) { RNA_property_boolean_get_default_array(ptr, prop, tmp); return tmp[index]; @@ -1501,6 +1520,8 @@ int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop) IntPropertyRNA *iprop= (IntPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_INT); + if((idprop=rna_idproperty_check(&prop, ptr))) return IDP_Int(idprop); else if(iprop->get) @@ -1514,6 +1535,8 @@ void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value) IntPropertyRNA *iprop= (IntPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_INT); + if((idprop=rna_idproperty_check(&prop, ptr))) IDP_Int(idprop)= value; else if(iprop->set) @@ -1535,6 +1558,8 @@ void RNA_property_int_get_array(PointerRNA *ptr, PropertyRNA *prop, int *values) IntPropertyRNA *iprop= (IntPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_INT); + if((idprop=rna_idproperty_check(&prop, ptr))) { if(prop->arraydimension == 0) values[0]= RNA_property_int_get(ptr, prop); @@ -1556,6 +1581,8 @@ int RNA_property_int_get_index(PointerRNA *ptr, PropertyRNA *prop, int index) int tmp[RNA_MAX_ARRAY_LENGTH]; int len= rna_ensure_property_array_length(ptr, prop); + BLI_assert(RNA_property_type(prop) == PROP_INT); + if(len <= RNA_MAX_ARRAY_LENGTH) { RNA_property_int_get_array(ptr, prop, tmp); return tmp[index]; @@ -1577,6 +1604,8 @@ void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *v IntPropertyRNA *iprop= (IntPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_INT); + if((idprop=rna_idproperty_check(&prop, ptr))) { if(prop->arraydimension == 0) IDP_Int(idprop)= values[0]; @@ -1608,6 +1637,8 @@ void RNA_property_int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, i int tmp[RNA_MAX_ARRAY_LENGTH]; int len= rna_ensure_property_array_length(ptr, prop); + BLI_assert(RNA_property_type(prop) == PROP_INT); + if(len <= RNA_MAX_ARRAY_LENGTH) { RNA_property_int_get_array(ptr, prop, tmp); tmp[index]= value; @@ -1634,6 +1665,8 @@ void RNA_property_int_get_default_array(PointerRNA *ptr, PropertyRNA *prop, int { IntPropertyRNA *iprop= (IntPropertyRNA*)prop; + BLI_assert(RNA_property_type(prop) == PROP_INT); + if(prop->arraydimension == 0) values[0]= iprop->defaultvalue; else if(iprop->defaultarray) @@ -1668,6 +1701,8 @@ float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop) FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_FLOAT); + if((idprop=rna_idproperty_check(&prop, ptr))) { if(idprop->type == IDP_FLOAT) return IDP_Float(idprop); @@ -1685,6 +1720,8 @@ void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value) FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_FLOAT); + if((idprop=rna_idproperty_check(&prop, ptr))) { if(idprop->type == IDP_FLOAT) IDP_Float(idprop)= value; @@ -1712,6 +1749,8 @@ void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *val IDProperty *idprop; int i; + BLI_assert(RNA_property_type(prop) == PROP_FLOAT); + if((idprop=rna_idproperty_check(&prop, ptr))) { if(prop->arraydimension == 0) values[0]= RNA_property_float_get(ptr, prop); @@ -1738,6 +1777,8 @@ float RNA_property_float_get_index(PointerRNA *ptr, PropertyRNA *prop, int index float tmp[RNA_MAX_ARRAY_LENGTH]; int len= rna_ensure_property_array_length(ptr, prop); + BLI_assert(RNA_property_type(prop) == PROP_FLOAT); + if(len <= RNA_MAX_ARRAY_LENGTH) { RNA_property_float_get_array(ptr, prop, tmp); return tmp[index]; @@ -1761,6 +1802,8 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const floa IDProperty *idprop; int i; + BLI_assert(RNA_property_type(prop) == PROP_FLOAT); + if((idprop=rna_idproperty_check(&prop, ptr))) { if(prop->arraydimension == 0) { if(idprop->type == IDP_FLOAT) @@ -1802,6 +1845,8 @@ void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float tmp[RNA_MAX_ARRAY_LENGTH]; int len= rna_ensure_property_array_length(ptr, prop); + BLI_assert(RNA_property_type(prop) == PROP_FLOAT); + if(len <= RNA_MAX_ARRAY_LENGTH) { RNA_property_float_get_array(ptr, prop, tmp); tmp[index]= value; @@ -1821,6 +1866,9 @@ void RNA_property_float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, float RNA_property_float_get_default(PointerRNA *ptr, PropertyRNA *prop) { FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; + + BLI_assert(RNA_property_type(prop) == PROP_FLOAT); + return fprop->defaultvalue; } @@ -1828,6 +1876,8 @@ void RNA_property_float_get_default_array(PointerRNA *ptr, PropertyRNA *prop, fl { FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; + BLI_assert(RNA_property_type(prop) == PROP_FLOAT); + if(prop->arraydimension == 0) values[0]= fprop->defaultvalue; else if(fprop->defaultarray) @@ -1841,6 +1891,8 @@ float RNA_property_float_get_default_index(PointerRNA *ptr, PropertyRNA *prop, i float tmp[RNA_MAX_ARRAY_LENGTH]; int len= rna_ensure_property_array_length(ptr, prop); + BLI_assert(RNA_property_type(prop) == PROP_FLOAT); + if(len <= RNA_MAX_ARRAY_LENGTH) { RNA_property_float_get_default_array(ptr, prop, tmp); return tmp[index]; @@ -1862,6 +1914,8 @@ void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value) StringPropertyRNA *sprop= (StringPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_STRING); + if((idprop=rna_idproperty_check(&prop, ptr))) strcpy(value, IDP_String(idprop)); else if(sprop->get) @@ -1875,6 +1929,8 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fi char *buf; int length; + BLI_assert(RNA_property_type(prop) == PROP_STRING); + length= RNA_property_string_length(ptr, prop); if(length+1 < fixedlen) @@ -1893,6 +1949,8 @@ int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop) StringPropertyRNA *sprop= (StringPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_STRING); + if((idprop=rna_idproperty_check(&prop, ptr))) return strlen(IDP_String(idprop)); else if(sprop->length) @@ -1906,6 +1964,8 @@ void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *val StringPropertyRNA *sprop= (StringPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_STRING); + if((idprop=rna_idproperty_check(&prop, ptr))) IDP_AssignString(idprop, (char*)value, RNA_property_string_maxlength(prop) - 1); else if(sprop->set) @@ -1922,6 +1982,9 @@ void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *val void RNA_property_string_get_default(PointerRNA *ptr, PropertyRNA *prop, char *value) { StringPropertyRNA *sprop= (StringPropertyRNA*)prop; + + BLI_assert(RNA_property_type(prop) == PROP_STRING); + strcpy(value, sprop->defaultvalue); } @@ -1930,6 +1993,8 @@ char *RNA_property_string_get_default_alloc(PointerRNA *ptr, PropertyRNA *prop, char *buf; int length; + BLI_assert(RNA_property_type(prop) == PROP_STRING); + length= RNA_property_string_default_length(ptr, prop); if(length+1 < fixedlen) @@ -1946,6 +2011,9 @@ char *RNA_property_string_get_default_alloc(PointerRNA *ptr, PropertyRNA *prop, int RNA_property_string_default_length(PointerRNA *ptr, PropertyRNA *prop) { StringPropertyRNA *sprop= (StringPropertyRNA*)prop; + + BLI_assert(RNA_property_type(prop) == PROP_STRING); + return strlen(sprop->defaultvalue); } @@ -1954,6 +2022,8 @@ int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop) EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_ENUM); + if((idprop=rna_idproperty_check(&prop, ptr))) return IDP_Int(idprop); else if(eprop->get) @@ -1967,6 +2037,8 @@ void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value) EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_ENUM); + if((idprop=rna_idproperty_check(&prop, ptr))) IDP_Int(idprop)= value; else if(eprop->set) { @@ -1987,6 +2059,9 @@ void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value) int RNA_property_enum_get_default(PointerRNA *ptr, PropertyRNA *prop) { EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop; + + BLI_assert(RNA_property_type(prop) == PROP_ENUM); + return eprop->defaultvalue; } @@ -1996,6 +2071,8 @@ PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop) PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_POINTER); + if((idprop=rna_idproperty_check(&prop, ptr))) { pprop= (PointerPropertyRNA*)prop; @@ -2020,6 +2097,8 @@ void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr { /*IDProperty *idprop;*/ + BLI_assert(RNA_property_type(prop) == PROP_POINTER); + if((/*idprop=*/ rna_idproperty_check(&prop, ptr))) { /* not supported */ } @@ -2038,6 +2117,9 @@ void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr PointerRNA RNA_property_pointer_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop)) { //PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop; + + // BLI_assert(RNA_property_type(prop) == PROP_POINTER); + return PointerRNA_NULL; // FIXME: there has to be a way... } @@ -2045,6 +2127,8 @@ void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop) { /*IDProperty *idprop;*/ + BLI_assert(RNA_property_type(prop) == PROP_POINTER); + if((/*idprop=*/rna_idproperty_check(&prop, ptr))) { /* already exists */ } @@ -2066,6 +2150,8 @@ void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop) { IDProperty *idprop, *group; + BLI_assert(RNA_property_type(prop) == PROP_POINTER); + if((idprop=rna_idproperty_check(&prop, ptr))) { group= RNA_struct_idprops(ptr, 0); @@ -2092,6 +2178,8 @@ void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, Collectio { IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + memset(iter, 0, sizeof(*iter)); if((idprop=rna_idproperty_check(&prop, ptr)) || (prop->flag & PROP_IDPROPERTY)) { @@ -2143,6 +2231,8 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop) CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + if((idprop=rna_idproperty_check(&prop, ptr))) { return idprop->len; } @@ -2167,6 +2257,8 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA IDProperty *idprop; // CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + if((idprop=rna_idproperty_check(&prop, ptr))) { IDPropertyTemplate val = {0}; IDProperty *item; @@ -2224,6 +2316,8 @@ int RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) IDProperty *idprop; // CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + if((idprop=rna_idproperty_check(&prop, ptr))) { IDProperty tmp, *array; int len; @@ -2269,6 +2363,8 @@ int RNA_property_collection_move(PointerRNA *ptr, PropertyRNA *prop, int key, in { IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + if((idprop=rna_idproperty_check(&prop, ptr))) { IDProperty tmp, *array; int len; @@ -2297,6 +2393,8 @@ void RNA_property_collection_clear(PointerRNA *ptr, PropertyRNA *prop) { IDProperty *idprop; + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + if((idprop=rna_idproperty_check(&prop, ptr))) IDP_ResizeIDPArray(idprop, 0); } @@ -2306,6 +2404,8 @@ int RNA_property_collection_lookup_index(PointerRNA *ptr, PropertyRNA *prop, Poi CollectionPropertyIterator iter; int index= 0; + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + RNA_property_collection_begin(ptr, prop, &iter); for(index=0; iter.valid; RNA_property_collection_next(&iter), index++) { if (iter.ptr.data == t_ptr->data) @@ -2324,6 +2424,8 @@ int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int k { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)rna_ensure_property(prop); + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + if(cprop->lookupint) { /* we have a callback defined, use it */ return cprop->lookupint(ptr, key, r_ptr); @@ -2353,6 +2455,8 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)rna_ensure_property(prop); + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + if(cprop->lookupstring) { /* we have a callback defined, use it */ return cprop->lookupstring(ptr, key, r_ptr); @@ -2394,6 +2498,8 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co int RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr) { + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + *r_ptr= *ptr; return ((r_ptr->type = prop->srna) ? 1:0); } @@ -2404,6 +2510,8 @@ int RNA_property_collection_raw_array(PointerRNA *ptr, PropertyRNA *prop, Proper ArrayIterator *internal; char *arrayp; + BLI_assert(RNA_property_type(prop) == PROP_COLLECTION); + if(!(prop->flag & PROP_RAW_ARRAY) || !(itemprop->flag & PROP_RAW_ACCESS)) return 0; From 04a63cb3933dcf7d9a76805b9bf147c1c9dc6687 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 22 Mar 2011 13:05:05 +0000 Subject: [PATCH 028/261] Buildbot updates: working windows scons build, and run slave_*.py scripts to compile/test/package directly from svn, easier to make changes this way. --- build_files/buildbot/master.cfg | 109 ++++++++++---------------- build_files/buildbot/master_unpack.py | 99 ++++++++++++----------- build_files/buildbot/slave_compile.py | 58 ++++++++++++++ build_files/buildbot/slave_pack.py | 29 ++++--- build_files/buildbot/slave_test.py | 40 ++++++++++ 5 files changed, 203 insertions(+), 132 deletions(-) create mode 100644 build_files/buildbot/slave_compile.py create mode 100644 build_files/buildbot/slave_test.py diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg index c4c8d8108e1..aee6f1175eb 100644 --- a/build_files/buildbot/master.cfg +++ b/build_files/buildbot/master.cfg @@ -36,7 +36,7 @@ c['change_source'] = SVNPoller( # only take place on one slave. from buildbot.process.factory import BuildFactory -from buildbot.steps.source import SVN +from buildbot.steps.source import SVN from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import Compile from buildbot.steps.shell import Test @@ -50,102 +50,76 @@ from buildbot.config import BuilderConfig c['builders'] = [] buildernames = [] - -def add_builder(c, name, factory): +def add_builder(c, name, libdir, factory): slavenames = [] for slave in master_private.slaves: if name in slave['builders']: slavenames.append(slave['name']) - f = factory(name) - c['builders'].append(BuilderConfig(name=name, slavenames=slavenames, factory=f, category='blender')) - buildernames.append(name) + if len(slavenames) > 0: + f = factory(name, libdir) + c['builders'].append(BuilderConfig(name=name, slavenames=slavenames, factory=f, category='blender')) + buildernames.append(name) # common steps - def svn_step(): return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/blender', mode='update', defaultBranch='trunk', workdir='blender') - def lib_svn_step(dir): return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir) - -def cmake_compile_step(): - return Compile(command=['make'], workdir='blender') - - -def cmake_test_step(): - return Test(workdir='blender') # make test - - def scons_compile_step(): return Compile(command=['python', 'scons/scons.py'], workdir='blender') - -class SlavePack(ShellCommand): - pack_script = 'slave_pack.py' - - def start(self): - if self.getProperty('buildername').find('scons') >= 0: - self.setCommand(['python', pack_script, 'scons']) - else: - self.setCommand(['python', pack_script, 'cmake']) - ShellCommand.start(self) - - -def file_upload(f, id): +def scons_file_upload(f, id): filename = 'buildbot_upload_' + id + '.zip' - pack_script = 'slave_pack.py' unpack_script = 'master_unpack.py' - f.addStep(FileDownload(name='download', mastersrc=pack_script, slavedest=pack_script)) - f.addStep(ShellCommand(name='package', command=['python', pack_script], description='packaging', descriptionDone='packaged')) - f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100 * 1024 * 1024)) + f.addStep(Compile(name='package', command=['python', 'scons/scons.py', 'BF_QUICK=slnt', 'buildslave'], description='packaging', descriptionDone='packaged', workdir='blender')) + f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024, workdir='install')) f.addStep(MasterShellCommand(name='unpack', command=['python', unpack_script, filename], description='unpacking', descriptionDone='unpacked')) -# linux cmake +# generic +def generic_builder(id, libdir=''): + filename = 'buildbot_upload_' + id + '.zip' + compile_script = '../blender/build_files/buildbot/slave_compile.py' + test_script = '../blender/build_files/buildbot/slave_test.py' + pack_script = '../blender/build_files/buildbot/slave_pack.py' + unpack_script = 'master_unpack.py' -def linux_cmake(id): f = BuildFactory() f.addStep(svn_step()) - f.addStep(cmake_compile_step()) - f.addStep(cmake_test_step()) - file_upload(f, id) + if libdir != '': + f.addStep(lib_svn_step(libdir)) + + f.addStep(Compile(command=['python', compile_script, id])) + f.addStep(Test(command=['python', test_script, id])) + f.addStep(ShellCommand(name='package', command=['python', pack_script, id], description='packaging', descriptionDone='packaged')) + f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024)) + f.addStep(MasterShellCommand(name='unpack', command=['python', unpack_script, filename], description='unpacking', descriptionDone='unpacked')) return f -add_builder(c, 'linux_x86_64_cmake', linux_cmake) - -# mac cmake - - -def mac_cmake(id): - f = BuildFactory() - f.addStep(svn_step()) - f.addStep(lib_svn_step('darwin-9.x.universal')) - f.addStep(cmake_compile_step()) - f.addStep(cmake_test_step()) - file_upload(f, id) - return f - -add_builder(c, 'mac_x86_64_cmake', mac_cmake) +add_builder(c, 'mac_x86_64_cmake', 'darwin-9.x.universal', generic_builder) +add_builder(c, 'mac_i386_cmake', 'darwin-9.x.universal', generic_builder) +add_builder(c, 'mac_ppc_cmake', 'darwin-9.x.universal', generic_builder) +add_builder(c, 'linux_x86_64_cmake', '', generic_builder) +add_builder(c, 'linux_x86_64_scons', '', generic_builder) # win32 scons - # TODO: add scons test target -def win32_scons(id): +def win32_scons(id, libdir): f = BuildFactory() f.addStep(svn_step()) - f.addStep(lib_svn_step('windows')) + f.addStep(lib_svn_step(libdir)) f.addStep(scons_compile_step()) - file_upload(f, id) + scons_file_upload(f, id) return f -add_builder(c, 'win32_scons', win32_scons) +add_builder(c, 'win32_scons', 'windows', win32_scons) # SCHEDULERS # @@ -178,16 +152,16 @@ c['status'] = [] from buildbot.status import html from buildbot.status.web import auth, authz -authz_cfg = authz.Authz( +authz_cfg=authz.Authz( # change any of these to True to enable; see the manual for more # options - gracefulShutdown=False, - forceBuild=True, # use this to test your slave once it is set up - forceAllBuilds=False, - pingBuilder=False, - stopBuild=False, - stopAllBuilds=False, - cancelPendingBuild=False, + gracefulShutdown = False, + forceBuild = True, # use this to test your slave once it is set up + forceAllBuilds = False, + pingBuilder = False, + stopBuild = False, + stopAllBuilds = False, + cancelPendingBuild = False, ) c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) @@ -212,3 +186,4 @@ c['buildbotURL'] = "http://builder.blender.org/" # installations. c['db_url'] = "sqlite:///state.sqlite" + diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index 8580fd3d6d6..2c2bc1898b2 100644 --- a/build_files/buildbot/master_unpack.py +++ b/build_files/buildbot/master_unpack.py @@ -18,69 +18,67 @@ # Runs on Buildbot master, to unpack incoming unload.zip into latest # builds directory and remove older builds. - + import os import shutil import sys import zipfile - # extension stripping def strip_extension(filename): - extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] + extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] - for ext in extensions: - if filename.endswith(ext): - filename = filename[:-len(ext)] - - return filename + for ext in extensions: + if filename.endswith(ext): + filename = filename[:-len(ext)] + return filename # extract platform from package name def get_platform(filename): - # name is blender-version-platform.extension. we want to get the - # platform out, but there may be some variations, so we fiddle a - # bit to handle current and hopefully future names - filename = strip_extension(filename) - filename = strip_extension(filename) + # name is blender-version-platform.extension. we want to get the + # platform out, but there may be some variations, so we fiddle a + # bit to handle current and hopefully future names + filename = strip_extension(filename) + filename = strip_extension(filename) - tokens = filename.split("-") - platforms = ['osx', 'mac', 'bsd', 'windows', 'linux', 'source', 'irix', 'solaris'] - platform_tokens = [] - found = False + tokens = filename.split("-") + platforms = ['osx', 'mac', 'bsd', 'win', 'linux', 'source', 'irix', 'solaris'] + platform_tokens = [] + found = False - for i, token in enumerate(tokens): - if not found: - for platform in platforms: - if token.lower().find(platform) != -1: - found = True + for i, token in enumerate(tokens): + if not found: + for platform in platforms: + if token.lower().find(platform) != -1: + found = True - if found: - platform_tokens += [token] + if found: + platform_tokens += [token] - return '-'.join(platform_tokens) + return '-'.join(platform_tokens) # get filename if len(sys.argv) < 2: - sys.stderr.write("Not enough arguments, expecting file to unpack\n") - sys.exit(1) + sys.stderr.write("Not enough arguments, expecting file to unpack\n") + sys.exit(1) filename = sys.argv[1] # open zip file if not os.path.exists(filename): - sys.stderr.write("File " + filename + " not found.\n") - sys.exit(1) + sys.stderr.write("File " + filename + " not found.\n") + sys.exit(1) try: - z = zipfile.ZipFile(filename, "r") + z = zipfile.ZipFile(filename, "r") except Exception, ex: - sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') + sys.exit(1) if len(z.namelist()) != 1: - sys.stderr.write("Expected on file in " + filename + ".") - sys.exit(1) + sys.stderr.write("Expected on file in " + filename + ".") + sys.exit(1) package = z.namelist()[0] packagename = os.path.basename(package) @@ -89,30 +87,31 @@ packagename = os.path.basename(package) platform = get_platform(packagename) if platform == '': - sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') - sys.exit(1) + sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') + sys.exit(1) # extract -dir = 'public_html/latest_builds' +dir = 'public_html/download' try: - zf = z.open(package) - f = file(os.path.join(dir, packagename), "wb") + zf = z.open(package) + f = file(os.path.join(dir, packagename), "wb") - shutil.copyfileobj(zf, f) + shutil.copyfileobj(zf, f) - zf.close() - z.close() + zf.close() + z.close() except Exception, ex: - sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') + sys.exit(1) # remove other files from the same platform try: - for f in os.listdir(dir): - if f.lower().find(platform.lower()) != -1: - if f != packagename: - os.remove(os.path.join(dir, f)) + for f in os.listdir(dir): + if f.lower().find(platform.lower()) != -1: + if f != packagename: + os.remove(os.path.join(dir, f)) except Exception, ex: - sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') + sys.exit(1) + diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py new file mode 100644 index 00000000000..4892865bcea --- /dev/null +++ b/build_files/buildbot/slave_compile.py @@ -0,0 +1,58 @@ +# ##### 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 ##### + +import os +import subprocess +import sys + +# get builder name +if len(sys.argv) < 2: + sys.stderr.write("Not enough arguments, expecting builder name\n") + sys.exit(1) + +builder = sys.argv[1] + +# we run from build/ directory +blender_dir = '../blender' + +if builder.find('cmake') != -1: + # cmake + + # set build options + cmake_options = ['-DCMAKE_BUILD_TYPE:STRING=Release'] + + if builder == 'mac_x86_64_cmake': + cmake_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64') + elif builder == 'mac_i386_cmake': + cmake_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=i386') + elif builder == 'mac_ppc_cmake': + cmake_options.append('-DCMAKE_OSX_ARCHITECTURES:STRING=ppc') + + # configure and make + retcode = subprocess.call(['cmake', blender_dir] + cmake_options) + if retcode != 0: + sys.exit(retcode) + retcode = subprocess.call(['make', '-s', '-j4', 'install']) + sys.exit(retcode) +else: + # scons + os.chdir(blender_dir) + + retcode = subprocess.call(['python', 'scons/scons.py']) + sys.exit(retcode) + diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py index 6710591d0d7..12171cf4003 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -25,38 +25,36 @@ import subprocess import sys import zipfile +# get builder name +if len(sys.argv) < 2: + sys.stderr.write("Not enough arguments, expecting builder name\n") + sys.exit(1) -# find release directory -def find_release_directory(): - for d in os.listdir('.'): - if os.path.isdir(d): - rd = os.path.join(d, 'release') - if os.path.exists(rd): - return rd +builder = sys.argv[1] - return None +# 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) # clean release directory if it already exists -dir = find_release_directory() +dir = 'release' -if dir: +if os.path.exists(dir): for f in os.listdir(dir): if os.path.isfile(os.path.join(dir, f)): os.remove(os.path.join(dir, f)) # create release package try: - os.chdir('../blender') subprocess.call(['make', 'package_archive']) - os.chdir('../build') except Exception, ex: sys.stderr.write('Make package release failed' + str(ex) + '\n') sys.exit(1) # find release directory, must exist this time -dir = find_release_directory() - -if not dir: +if not os.path.exists(dir): sys.stderr.write("Failed to find release directory.\n") sys.exit(1) @@ -85,3 +83,4 @@ try: except Exception, ex: sys.stderr.write('Create buildbot_upload.zip failed' + str(ex) + '\n') sys.exit(1) + diff --git a/build_files/buildbot/slave_test.py b/build_files/buildbot/slave_test.py new file mode 100644 index 00000000000..7e78f1ab5cd --- /dev/null +++ b/build_files/buildbot/slave_test.py @@ -0,0 +1,40 @@ +# ##### 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 ##### + +import os +import subprocess +import sys + +# get builder name +if len(sys.argv) < 2: + sys.stderr.write("Not enough arguments, expecting builder name\n") + sys.exit(1) + +builder = sys.argv[1] + +# we run from build/ directory +blender_dir = '../blender' + +if builder.find('cmake') != -1: + # cmake + retcode = subprocess.call(['ctest', '.' '--output-on-failure']) + sys.exit(retcode) +else: + # scons + pass + From ddb9893ca924d3dab195a30049e574d042e1773b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 13:30:20 +0000 Subject: [PATCH 029/261] some more corrections to incorrect rna get/set types. --- source/blender/editors/mesh/editmesh_tools.c | 2 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_relations.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 68a76f5363d..0dc4314d589 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -744,7 +744,7 @@ static int mesh_extrude_exec(bContext *C, wmOperator *op) Object *obedit= CTX_data_edit_object(C); EditMesh *em= BKE_mesh_get_editmesh(obedit->data); - extrude_mesh(obedit, em, op, RNA_int_get(op->ptr, "type")); + extrude_mesh(obedit, em, op, RNA_enum_get(op->ptr, "type")); DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index c3fb3ca5ddd..2463e17d49f 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -417,7 +417,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) /* for object add operator */ static int effector_add_exec(bContext *C, wmOperator *op) { - if(effector_add_type(C, op, RNA_int_get(op->ptr, "type")) == NULL) + if(effector_add_type(C, op, RNA_enum_get(op->ptr, "type")) == NULL) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 8d378d25937..7938096c2a6 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1254,7 +1254,7 @@ static int allow_make_links_data(int ev, Object *ob, Object *obt) static int make_links_data_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); - int event = RNA_int_get(op->ptr, "type"); + int event = RNA_enum_get(op->ptr, "type"); Object *ob; ID *id; int a; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 8aa89f6707d..1622159efcb 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2945,7 +2945,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) { ARegion *ar= CTX_wm_region(C); double stime= PIL_check_seconds_timer(); - int type = RNA_int_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); int iter = RNA_int_get(op->ptr, "iterations"); int a; float time; From a69524358bc3fdd2018ad64f79cba9e92f5e0e07 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 22 Mar 2011 13:30:50 +0000 Subject: [PATCH 030/261] Bug fix: Fluidsim crashed after clicking "bake" multiple times * Fluid baking didn't check if there was already an ongoing job before starting a new job. --- source/blender/editors/physics/physics_fluid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index f4d31ee5bb5..b2f62f21cf1 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -1081,9 +1081,11 @@ static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object static int fluid_bake_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + /* only one bake job at a time */ + if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) + return 0; - if(!fluidsimBake(C, op->reports, ob)) + if(!fluidsimBake(C, op->reports, CTX_data_active_object(C))) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; From fc7c3c663ef6d908e3c165515a144bdbfddee867 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 14:04:47 +0000 Subject: [PATCH 031/261] - weight paint poll would crash if no area was found. - don't print a line for each operator run when in background mode. - extrude was using an invalid type for RNA access. --- source/blender/editors/mesh/editmesh_tools.c | 2 +- .../editors/sculpt_paint/paint_vertex.c | 19 +++++++++++-------- .../windowmanager/intern/wm_event_system.c | 10 ++++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 0dc4314d589..5525a486438 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -728,7 +728,7 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even Object *obedit= CTX_data_edit_object(C); EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data); - extrude_mesh(obedit, em, op, RNA_int_get(op->ptr, "type")); + extrude_mesh(obedit, em, op, RNA_enum_get(op->ptr, "type")); BKE_mesh_end_editmesh(obedit->data, em); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index b0979817c88..6859fd333bc 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -127,15 +127,18 @@ int weight_paint_mode_poll(bContext *C) int weight_paint_poll(bContext *C) { - Object *ob = CTX_data_active_object(C); + Object *ob= CTX_data_active_object(C); + ScrArea *sa; - if(ob && ob->mode & OB_MODE_WEIGHT_PAINT && - paint_brush(&CTX_data_tool_settings(C)->wpaint->paint)) { - ScrArea *sa= CTX_wm_area(C); - if(sa->spacetype==SPACE_VIEW3D) { - ARegion *ar= CTX_wm_region(C); - if(ar->regiontype==RGN_TYPE_WINDOW) - return 1; + if( (ob != NULL) && + (ob->mode & OB_MODE_WEIGHT_PAINT) && + (paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) && + (sa= CTX_wm_area(C)) && + (sa->spacetype == SPACE_VIEW3D) + ) { + ARegion *ar= CTX_wm_region(C); + if(ar->regiontype==RGN_TYPE_WINDOW) { + return 1; } } return 0; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 15964b8c1e5..8dcd3fa34d1 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -446,10 +446,12 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int pop wm_operator_print(C, op); /* todo - this print may double up, might want to check more flags then the FINISHED */ if (op->type->flag & OPTYPE_REGISTER) { - /* Report the python string representation of the operator */ - char *buf = WM_operator_pystring(C, op->type, op->ptr, 1); - BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); - MEM_freeN(buf); + if(G.background == 0) { /* ends up printing these in the terminal, gets annoying */ + /* Report the python string representation of the operator */ + char *buf = WM_operator_pystring(C, op->type, op->ptr, 1); + BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); + MEM_freeN(buf); + } } } From f40d33f24b85a1c1e0e8d8cb0e42146ebcdef5a9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 14:09:07 +0000 Subject: [PATCH 032/261] Added CTest to run most operators in background mode under various conditions to see if any crash. used this to find quite a many errors already. --- source/tests/CMakeLists.txt | 5 + source/tests/bl_run_operators.py | 186 +++++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 source/tests/bl_run_operators.py diff --git a/source/tests/CMakeLists.txt b/source/tests/CMakeLists.txt index e9837dd354f..0430b49181e 100644 --- a/source/tests/CMakeLists.txt +++ b/source/tests/CMakeLists.txt @@ -55,6 +55,11 @@ add_test(script_load_modules ${TEST_BLENDER_EXE} --python ${CMAKE_CURRENT_LIST_DIR}/bl_load_py_modules.py ) +# test running operators doesn't segfault under various conditions +add_test(script_run_operators ${TEST_BLENDER_EXE} + --python ${CMAKE_CURRENT_LIST_DIR}/bl_run_operators.py +) + # ------------------------------------------------------------------------------ # IO TESTS diff --git a/source/tests/bl_run_operators.py b/source/tests/bl_run_operators.py new file mode 100644 index 00000000000..703adafad91 --- /dev/null +++ b/source/tests/bl_run_operators.py @@ -0,0 +1,186 @@ +# ##### 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 ##### + +# + +# semi-useful script, runs all operators in a number of different +# contexts, cheap way to find misc small bugs but is in no way a complete test. +# +# only error checked for here is a segfault. + +import bpy +import sys + +op_blacklist = ( + "script.reload", + "script.reload", + "export*.*", + "import*.*", + "*.save_*", + "*.read_*", + "*.open_*", + "*.link_append", + "render.render", + "*.*_export", + "*.*_import", + "wm.url_open", + "wm.doc_view", + "wm.path_open", + "help.operator_cheat_sheet", + ) + + +def filter_op_list(operators): + from fnmatch import fnmatchcase + + def is_op_ok(op): + for op_match in op_blacklist: + if fnmatchcase(op, op_match): + print(" skipping: %s (%s)" % (op, op_match)) + return False + return True + + operators[:] = [op for op in operators if is_op_ok(op[0])] + + +def run_ops(operators, setup_func=None): + print("\ncontext:", setup_func.__name__) + # first invoke + for op_id, op in operators: + if op.poll(): + print(" operator:", op_id) + sys.stdout.flush() # incase of crash + + # disable will get blender in a bad state and crash easy! + bpy.ops.wm.read_factory_settings() + + setup_func() + continue + for mode in ('EXEC_DEFAULT', 'INVOKE_DEFAULT'): + try: + op(mode) + #print(" - pass") + except: + #print(" - fail") + #import traceback + #traceback.print_exc() + pass + + +# contexts +def ctx_clear_scene(): # copied from batch_import.py + unique_obs = set() + for scene in bpy.data.scenes: + for obj in scene.objects[:]: + scene.objects.unlink(obj) + unique_obs.add(obj) + + # remove obdata, for now only worry about the startup scene + for bpy_data_iter in (bpy.data.objects, bpy.data.meshes, bpy.data.lamps, bpy.data.cameras): + for id_data in bpy_data_iter: + bpy_data_iter.remove(id_data) + + +def ctx_editmode_mesh(): + bpy.ops.object.mode_set(mode='EDIT') + bpy.ops.object.vertex_group_add() + + +def ctx_editmode_curves(): + bpy.ops.curve.primitive_nurbs_circle_add() + bpy.ops.object.mode_set(mode='EDIT') + + +def ctx_editmode_surface(): + bpy.ops.surface.primitive_nurbs_surface_torus_add() + 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_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') + + +def ctx_editmode_armature(): + bpy.ops.object.armature_add() + bpy.ops.object.mode_set(mode='EDIT') + bpy.ops.armature.select_all(action='TOGGLE') + bpy.ops.armature.delete() + + +def ctx_editmode_lattice(): + bpy.ops.object.add(type='LATTICE') + bpy.ops.object.mode_set(mode='EDIT') + # bpy.ops.object.vertex_group_add() + + +def ctx_object_empty(): + bpy.ops.object.add(type='EMPTY') + + +def ctx_weightpaint(): + bpy.ops.object.mode_set(mode='WEIGHT_PAINT') + + +def main(): + # bpy.ops.wm.read_factory_settings() + import bpy + operators = [] + for mod_name in dir(bpy.ops): + mod = getattr(bpy.ops, mod_name) + for submod_name in dir(mod): + op = getattr(mod, submod_name) + operators.append(("%s.%s" % (mod_name, submod_name), op)) + + operators.sort(key=lambda op: op[0]) + + filter_op_list(operators) + + # for testing, mix the list up. + #operators.reverse() + + #import random + #random.shuffle(operators) + + # Run the operator tests in different contexts + run_ops(operators, setup_func=lambda: None) + run_ops(operators, setup_func=ctx_editmode_surface) + run_ops(operators, setup_func=ctx_object_empty) + run_ops(operators, setup_func=ctx_editmode_armature) + run_ops(operators, setup_func=ctx_editmode_mesh) + run_ops(operators, setup_func=ctx_clear_scene) + run_ops(operators, setup_func=ctx_editmode_curves) + run_ops(operators, setup_func=ctx_editmode_mball) + run_ops(operators, setup_func=ctx_editmode_text) + run_ops(operators, setup_func=ctx_weightpaint) + run_ops(operators, setup_func=ctx_editmode_lattice) + + print("finished") + +if __name__ == "__main__": + main() From 287a185e909bf833414e14a50864e8cd0f80f0b8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Mar 2011 14:37:45 +0000 Subject: [PATCH 033/261] found text editor X/Y selections coords were booleans and corrections to operator calling script from last commit. --- source/blender/editors/space_text/text_ops.c | 4 ++-- source/tests/bl_run_operators.py | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 0065c3317b8..5325bed15fd 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2683,8 +2683,8 @@ void TEXT_OT_cursor_set(wmOperatorType *ot) ot->poll= text_region_edit_poll; /* properties */ - RNA_def_boolean(ot->srna, "x", 0, "X", "X-coordinate to set cursor to."); - RNA_def_boolean(ot->srna, "y", 0, "Y", "X-coordinate to set cursor to."); + RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); + RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); } /******************* line number operator **********************/ diff --git a/source/tests/bl_run_operators.py b/source/tests/bl_run_operators.py index 703adafad91..f1f21d3bd71 100644 --- a/source/tests/bl_run_operators.py +++ b/source/tests/bl_run_operators.py @@ -27,7 +27,6 @@ import bpy import sys op_blacklist = ( - "script.reload", "script.reload", "export*.*", "import*.*", @@ -70,13 +69,11 @@ def run_ops(operators, setup_func=None): bpy.ops.wm.read_factory_settings() setup_func() - continue + for mode in ('EXEC_DEFAULT', 'INVOKE_DEFAULT'): try: op(mode) - #print(" - pass") except: - #print(" - fail") #import traceback #traceback.print_exc() pass @@ -129,8 +126,6 @@ def ctx_editmode_text(): def ctx_editmode_armature(): bpy.ops.object.armature_add() bpy.ops.object.mode_set(mode='EDIT') - bpy.ops.armature.select_all(action='TOGGLE') - bpy.ops.armature.delete() def ctx_editmode_lattice(): From 636ceed094635ab80867d062377d9a8e6ddacfcb Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 22 Mar 2011 15:20:25 +0000 Subject: [PATCH 034/261] Bugfix #26562 Keymap fix for UV/Image editor: the modal zoom/pan functions were checking for hardcoded events to end. Now it uses the key from keymap. --- source/blender/editors/space_image/image_ops.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 93e5465cd64..3aa509ab998 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -176,6 +176,7 @@ int space_image_main_area_poll(bContext *C) typedef struct ViewPanData { float x, y; float xof, yof; + int event_type; } ViewPanData; static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event) @@ -190,6 +191,7 @@ static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event) vpd->y= event->y; vpd->xof= sima->xof; vpd->yof= sima->yof; + vpd->event_type= event->type; WM_event_add_modal_handler(C, op); } @@ -266,9 +268,8 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) RNA_float_set_array(op->ptr, "offset", offset); view_pan_exec(C, op); break; - case MIDDLEMOUSE: - case LEFTMOUSE: - if(event->val==KM_RELEASE) { + default: + if(event->type==vpd->event_type && event->val==KM_RELEASE) { view_pan_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -310,6 +311,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot) typedef struct ViewZoomData { float x, y; float zoom; + int event_type; } ViewZoomData; static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) @@ -323,7 +325,8 @@ static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) vpd->x= event->x; vpd->y= event->y; vpd->zoom= sima->zoom; - + vpd->event_type= event->type; + WM_event_add_modal_handler(C, op); } @@ -396,9 +399,8 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) sima_zoom_set(sima, ar, vpd->zoom*factor); ED_region_tag_redraw(CTX_wm_region(C)); break; - case MIDDLEMOUSE: - case LEFTMOUSE: - if(event->val==KM_RELEASE) { + default: + if(event->type==vpd->event_type && event->val==KM_RELEASE) { view_zoom_exit(C, op, 0); return OPERATOR_FINISHED; } From e5eed21a6bf9d8ab36f72d51c3d9f6fad02e795e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 22 Mar 2011 15:25:18 +0000 Subject: [PATCH 035/261] Buildbot master tweaks: use generic builder for scons win32, unpack fixes. --- build_files/buildbot/master.cfg | 34 +++------- build_files/buildbot/master_unpack.py | 94 ++++++++++++++------------- build_files/buildbot/slave_compile.py | 3 +- 3 files changed, 58 insertions(+), 73 deletions(-) diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg index aee6f1175eb..f6aa6390e8c 100644 --- a/build_files/buildbot/master.cfg +++ b/build_files/buildbot/master.cfg @@ -70,18 +70,7 @@ def svn_step(): def lib_svn_step(dir): return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir) -def scons_compile_step(): - return Compile(command=['python', 'scons/scons.py'], workdir='blender') - -def scons_file_upload(f, id): - filename = 'buildbot_upload_' + id + '.zip' - unpack_script = 'master_unpack.py' - - f.addStep(Compile(name='package', command=['python', 'scons/scons.py', 'BF_QUICK=slnt', 'buildslave'], description='packaging', descriptionDone='packaged', workdir='blender')) - f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024, workdir='install')) - f.addStep(MasterShellCommand(name='unpack', command=['python', unpack_script, filename], description='unpacking', descriptionDone='unpacked')) - -# generic +# generic builder def generic_builder(id, libdir=''): filename = 'buildbot_upload_' + id + '.zip' @@ -98,28 +87,21 @@ def generic_builder(id, libdir=''): f.addStep(Compile(command=['python', compile_script, id])) f.addStep(Test(command=['python', test_script, id])) f.addStep(ShellCommand(name='package', command=['python', pack_script, id], description='packaging', descriptionDone='packaged')) - f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024)) + if id.find('cmake') != -1: + f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024)) + else: + f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024, workdir='install')) f.addStep(MasterShellCommand(name='unpack', command=['python', unpack_script, filename], description='unpacking', descriptionDone='unpacked')) return f +# builders + add_builder(c, 'mac_x86_64_cmake', 'darwin-9.x.universal', generic_builder) add_builder(c, 'mac_i386_cmake', 'darwin-9.x.universal', generic_builder) add_builder(c, 'mac_ppc_cmake', 'darwin-9.x.universal', generic_builder) add_builder(c, 'linux_x86_64_cmake', '', generic_builder) add_builder(c, 'linux_x86_64_scons', '', generic_builder) - -# win32 scons - -# TODO: add scons test target -def win32_scons(id, libdir): - f = BuildFactory() - f.addStep(svn_step()) - f.addStep(lib_svn_step(libdir)) - f.addStep(scons_compile_step()) - scons_file_upload(f, id) - return f - -add_builder(c, 'win32_scons', 'windows', win32_scons) +add_builder(c, 'win32_scons', 'windows', generic_builder) # SCHEDULERS # diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index 2c2bc1898b2..70c8b4c3b0b 100644 --- a/build_files/buildbot/master_unpack.py +++ b/build_files/buildbot/master_unpack.py @@ -26,59 +26,59 @@ import zipfile # extension stripping def strip_extension(filename): - extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] + extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] - for ext in extensions: - if filename.endswith(ext): - filename = filename[:-len(ext)] + for ext in extensions: + if filename.endswith(ext): + filename = filename[:-len(ext)] - return filename + return filename # extract platform from package name def get_platform(filename): - # name is blender-version-platform.extension. we want to get the - # platform out, but there may be some variations, so we fiddle a - # bit to handle current and hopefully future names - filename = strip_extension(filename) - filename = strip_extension(filename) + # name is blender-version-platform.extension. we want to get the + # platform out, but there may be some variations, so we fiddle a + # bit to handle current and hopefully future names + filename = strip_extension(filename) + filename = strip_extension(filename) - tokens = filename.split("-") - platforms = ['osx', 'mac', 'bsd', 'win', 'linux', 'source', 'irix', 'solaris'] - platform_tokens = [] - found = False + tokens = filename.split("-") + platforms = ['osx', 'mac', 'bsd', 'win', 'linux', 'source', 'irix', 'solaris'] + platform_tokens = [] + found = False - for i, token in enumerate(tokens): - if not found: - for platform in platforms: - if token.lower().find(platform) != -1: - found = True + for i, token in enumerate(tokens): + if not found: + for platform in platforms: + if token.lower().find(platform) != -1: + found = True - if found: - platform_tokens += [token] + if found: + platform_tokens += [token] - return '-'.join(platform_tokens) + return '-'.join(platform_tokens) # get filename if len(sys.argv) < 2: - sys.stderr.write("Not enough arguments, expecting file to unpack\n") - sys.exit(1) + sys.stderr.write("Not enough arguments, expecting file to unpack\n") + sys.exit(1) filename = sys.argv[1] # open zip file if not os.path.exists(filename): - sys.stderr.write("File " + filename + " not found.\n") - sys.exit(1) + sys.stderr.write("File " + filename + " not found.\n") + sys.exit(1) try: - z = zipfile.ZipFile(filename, "r") + z = zipfile.ZipFile(filename, "r") except Exception, ex: - sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') + sys.exit(1) if len(z.namelist()) != 1: - sys.stderr.write("Expected on file in " + filename + ".") - sys.exit(1) + sys.stderr.write("Expected on file in " + filename + ".") + sys.exit(1) package = z.namelist()[0] packagename = os.path.basename(package) @@ -87,31 +87,33 @@ packagename = os.path.basename(package) platform = get_platform(packagename) if platform == '': - sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') - sys.exit(1) + sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') + sys.exit(1) # extract dir = 'public_html/download' try: - zf = z.open(package) - f = file(os.path.join(dir, packagename), "wb") + zf = z.open(package) + f = file(os.path.join(dir, packagename), "wb") - shutil.copyfileobj(zf, f) + shutil.copyfileobj(zf, f) - zf.close() - z.close() + zf.close() + z.close() + + os.remove(filename) except Exception, ex: - sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') + sys.exit(1) # remove other files from the same platform try: - for f in os.listdir(dir): - if f.lower().find(platform.lower()) != -1: - if f != packagename: - os.remove(os.path.join(dir, f)) + for f in os.listdir(dir): + if f.lower().find(platform.lower()) != -1: + if f != packagename: + os.remove(os.path.join(dir, f)) except Exception, ex: - sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') - sys.exit(1) + sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') + sys.exit(1) diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index 4892865bcea..708c2951272 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -52,7 +52,8 @@ if builder.find('cmake') != -1: else: # scons os.chdir(blender_dir) + scons_options = [] - retcode = subprocess.call(['python', 'scons/scons.py']) + retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) sys.exit(retcode) From f78e11dc3888f6d0e3c4b3ea86ca29c9f142e3bf Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 22 Mar 2011 15:28:56 +0000 Subject: [PATCH 036/261] [#26476] and missing from Colada reported by Juan Linietsky Export for and shaders, was already being written for these. shader doesn't have . Right now we write when blender spec is phong, when blender spec is blinn. When spec is any other shader, and diffuse shader set to lambert, we export as . Any other combination defaults right now to . This will change when Blender specific profiles have been created for the shader combinations in Blender. --- source/blender/collada/EffectExporter.cpp | 43 ++++++++++++++++++----- source/blender/collada/EffectExporter.h | 4 +++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 323b90fe1cc..085ee7356ab 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -89,6 +89,34 @@ void EffectsExporter::exportEffects(Scene *sce) } } +void EffectsExporter::writeBlinn(COLLADASW::EffectProfile &ep, Material *ma) +{ + COLLADASW::ColorOrTexture cot; + ep.setShaderType(COLLADASW::EffectProfile::BLINN); + // shininess + ep.setShininess(ma->har); + // specular + cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); + ep.setSpecular(cot); +} + +void EffectsExporter::writeLambert(COLLADASW::EffectProfile &ep, Material *ma) +{ + COLLADASW::ColorOrTexture cot; + ep.setShaderType(COLLADASW::EffectProfile::LAMBERT); +} + +void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma) +{ + COLLADASW::ColorOrTexture cot; + ep.setShaderType(COLLADASW::EffectProfile::PHONG); + // shininess + ep.setShininess(ma->har); + // specular + cot = getcol(ma->specr, ma->specg, ma->specb, 1.0f); + ep.setSpecular(cot); +} + void EffectsExporter::operator()(Material *ma, Object *ob) { // create a list of indices to textures of type TEX_IMAGE @@ -102,18 +130,17 @@ void EffectsExporter::operator()(Material *ma, Object *ob) ep.openProfile(); // set shader type - one of three blinn, phong or lambert if (ma->spec_shader == MA_SPEC_BLINN) { - ep.setShaderType(COLLADASW::EffectProfile::BLINN); - // shininess - ep.setShininess(ma->har); + writeBlinn(ep, ma); } else if (ma->spec_shader == MA_SPEC_PHONG) { - ep.setShaderType(COLLADASW::EffectProfile::PHONG); - // shininess - ep.setShininess(ma->har); + writePhong(ep, ma); + } + else if(ma->diff_shader == MA_DIFF_LAMBERT) { + writeLambert(ep, ma); } else { - // XXX write warning "Current shader type is not supported" - ep.setShaderType(COLLADASW::EffectProfile::LAMBERT); + // \todo figure out handling of all spec+diff shader combos blender has, for now write phong + writePhong(ep, ma); } // index of refraction if (ma->mode & MA_RAYTRANSP) { diff --git a/source/blender/collada/EffectExporter.h b/source/blender/collada/EffectExporter.h index 8fe7ef31da4..2b25d1b889f 100644 --- a/source/blender/collada/EffectExporter.h +++ b/source/blender/collada/EffectExporter.h @@ -61,6 +61,10 @@ private: /** Fills the array of mtex indices which have image. Used for exporting images. */ void createTextureIndices(Material *ma, std::vector &indices); + void writeBlinn(COLLADASW::EffectProfile &ep, Material *ma); + void writeLambert(COLLADASW::EffectProfile &ep, Material *ma); + void writePhong(COLLADASW::EffectProfile &ep, Material *ma); + bool hasEffects(Scene *sce); }; From c7f37b84d8dff7091ae7952f6fc4336027c5befa Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 22 Mar 2011 16:30:46 +0000 Subject: [PATCH 037/261] remove constructors, they cause compile errors under Fedora --- extern/bullet2/src/BulletSoftBody/btSoftBody.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/extern/bullet2/src/BulletSoftBody/btSoftBody.h b/extern/bullet2/src/BulletSoftBody/btSoftBody.h index 87247c3c1c0..ad8678f28b2 100644 --- a/extern/bullet2/src/BulletSoftBody/btSoftBody.h +++ b/extern/bullet2/src/BulletSoftBody/btSoftBody.h @@ -205,14 +205,12 @@ public: btScalar m_kAST; // Area/Angular stiffness coefficient [0,1] btScalar m_kVST; // Volume stiffness coefficient [0,1] int m_flags; // Flags - Material() : Element() {} }; /* Feature */ struct Feature : Element { Material* m_material; // Material - Feature() : Element() {} }; /* Node */ struct Node : Feature @@ -226,7 +224,6 @@ public: btScalar m_area; // Area btDbvtNode* m_leaf; // Leaf data int m_battach:1; // Attached - Node() : Feature() {} }; /* Link */ struct Link : Feature @@ -238,7 +235,6 @@ public: btScalar m_c1; // rl^2 btScalar m_c2; // |gradient|^2/c0 btVector3 m_c3; // gradient - Link() : Feature() {} }; /* Face */ struct Face : Feature @@ -247,7 +243,6 @@ public: btVector3 m_normal; // Normal btScalar m_ra; // Rest area btDbvtNode* m_leaf; // Leaf data - Face() : Feature() {} }; /* Tetra */ struct Tetra : Feature @@ -258,7 +253,6 @@ public: btVector3 m_c0[4]; // gradients btScalar m_c1; // (4*kVST)/(im0+im1+im2+im3) btScalar m_c2; // m_c1/sum(|g0..3|^2) - Tetra() : Feature() {} }; /* RContact */ struct RContact @@ -300,7 +294,6 @@ public: int m_rank; // Rank Node* m_nodes[4]; // Nodes btScalar m_coords[4]; // Coordinates - Note() : Element() {} }; /* Pose */ struct Pose From a4e2ece786398b1b7d97a54980d89273be0f8ce9 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 22 Mar 2011 19:39:53 +0000 Subject: [PATCH 038/261] Logic rna: actuator --> renaming Motion Actuator to 'MOTION' and tooltip fix internally it's still called Object Actuator, but for the user at least it's better motion. --- source/blender/makesrna/intern/rna_actuator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 38c8d6da5cc..bec879d6ae3 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -53,7 +53,7 @@ EnumPropertyItem actuator_type_items[] ={ {ACT_2DFILTER, "FILTER_2D", 0, "Filter 2D", ""}, {ACT_GAME, "GAME", 0, "Game", ""}, {ACT_MESSAGE, "MESSAGE", 0, "Message", ""}, - {ACT_OBJECT, "OBJECT", 0, "Motion", ""}, + {ACT_OBJECT, "MOTION", 0, "Motion", ""}, {ACT_PARENT, "PARENT", 0, "Parent", ""}, {ACT_PROPERTY, "PROPERTY", 0, "Property", ""}, {ACT_RANDOM, "RANDOM", 0, "Random", ""}, @@ -1173,7 +1173,7 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_distance_get", "rna_ConstraintActuator_distance_set", NULL); RNA_def_property_ui_range(prop, -2000.f, 2000.f, 1, 2); - RNA_def_property_ui_text(prop, "Distance", "Set the maximum length of ray"); + RNA_def_property_ui_text(prop, "Distance", "Keep this distance to target"); RNA_def_property_update(prop, NC_LOGIC, NULL); //XXX to use a pointer or add a material lookup @@ -1235,7 +1235,7 @@ static void rna_def_constraint_actuator(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Distance", "Height of the force field area"); RNA_def_property_update(prop, NC_LOGIC, NULL); - prop= RNA_def_property(srna, "fh_force", PROP_FLOAT, PROP_PERCENTAGE); + prop= RNA_def_property(srna, "fh_force", PROP_FLOAT, PROP_NONE); RNA_def_property_float_funcs(prop, "rna_ConstraintActuator_spring_get", "rna_ConstraintActuator_spring_set", NULL); RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2); RNA_def_property_ui_text(prop, "Force", "Spring force within the force field area"); From 60b94886c8e24c5da9bf5a70469a2abcf198a014 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 22 Mar 2011 22:00:26 +0000 Subject: [PATCH 039/261] Small tweak to material export: only export as when spec intensity is 0.0 and diffuse shader is set to Lambert. Other cases will be handled in due time, until then phong. --- source/blender/collada/EffectExporter.cpp | 26 ++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 085ee7356ab..d41323004cc 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -129,19 +129,25 @@ void EffectsExporter::operator()(Material *ma, Object *ob) ep.setProfileType(COLLADASW::EffectProfile::COMMON); ep.openProfile(); // set shader type - one of three blinn, phong or lambert - if (ma->spec_shader == MA_SPEC_BLINN) { - writeBlinn(ep, ma); - } - else if (ma->spec_shader == MA_SPEC_PHONG) { - writePhong(ep, ma); - } - else if(ma->diff_shader == MA_DIFF_LAMBERT) { - writeLambert(ep, ma); - } - else { + if(ma->spec>0.0f) { + if (ma->spec_shader == MA_SPEC_BLINN) { + writeBlinn(ep, ma); + } + else { + // \todo figure out handling of all spec+diff shader combos blender has, for now write phong + // for now set phong in case spec shader is not blinn + writePhong(ep, ma); + } + } else { + if(ma->diff_shader == MA_DIFF_LAMBERT) { + writeLambert(ep, ma); + } + else { // \todo figure out handling of all spec+diff shader combos blender has, for now write phong writePhong(ep, ma); + } } + // index of refraction if (ma->mode & MA_RAYTRANSP) { ep.setIndexOfRefraction(ma->ang); From de89e78589f1a4aba0f212ceb83c809bdb19474a Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 22 Mar 2011 22:51:02 +0000 Subject: [PATCH 040/261] Fix [#26475] wrong in COLLADA export. reported by Juan Linietsky fix by Imran Syed (freakabcd) Use material index suffixed to material name to create symbolic name. --- source/blender/collada/GeometryExporter.cpp | 6 +++++- source/blender/collada/InstanceWriter.cpp | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 9edfbe14a71..332df0318e9 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -28,6 +28,8 @@ */ +#include + #include "COLLADASWPrimitves.h" #include "COLLADASWSource.h" #include "COLLADASWVertices.h" @@ -167,7 +169,9 @@ void GeometryExporter::createPolylist(int material_index, // sets material name if (ma) { - polylist.setMaterial(translate_id(id_name(ma))); + std::ostringstream ostr; + ostr << translate_id(id_name(ma)) << material_index+1; + polylist.setMaterial(ostr.str()); } COLLADASW::InputList &til = polylist.getInputList(); diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp index f822db0f39b..a069e72fbbd 100644 --- a/source/blender/collada/InstanceWriter.cpp +++ b/source/blender/collada/InstanceWriter.cpp @@ -29,6 +29,7 @@ #include +#include #include "COLLADASWInstanceMaterial.h" @@ -52,7 +53,9 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia if (ma) { std::string matid(get_material_id(ma)); matid = translate_id(matid); - COLLADASW::InstanceMaterial im(matid, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid)); + std::ostringstream ostr; + ostr << translate_id(id_name(ma)) << a+1; + COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid)); // create for each uv layer Mesh *me = (Mesh*)ob->data; From ee99cf5aa57d7772a98e4e727638fba548cab204 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 23 Mar 2011 00:03:52 +0000 Subject: [PATCH 041/261] Wrong extension tag: show_double_sided -> double_sided --- source/blender/collada/EffectExporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index d41323004cc..ff714533199 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -319,7 +319,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) twoSided = true; } if (twoSided) - ep.addExtraTechniqueParameter("GOOGLEEARTH", "show_double_sided", 1); + ep.addExtraTechniqueParameter("GOOGLEEARTH", "double_sided", 1); ep.addExtraTechniques(mSW); ep.closeProfile(); From 4470783264f49b4081e41d80f5b3349fb4a1be35 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 23 Mar 2011 00:19:38 +0000 Subject: [PATCH 042/261] Fix [#26474] double_sided wrong in COLLADA Export reported by Juan Linietsky The export was not really wrong, but Maya expects their profile to be present inside . Added this for mesh with ME_TWOSIDED flag set. Ideally this will change in the future to be controllable through options to the exporter (like current Google Earth and 3DS Max extensions for ). --- source/blender/collada/GeometryExporter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 332df0318e9..5df5ab99b91 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -116,6 +116,11 @@ void GeometryExporter::operator()(Object *ob) } closeMesh(); + + if (me->flag & ME_TWOSIDED) { + mSW->appendTextBlock("1"); + } + closeGeometry(); #if 0 From 95173a4ae83ad47c40ca0f5acca95873d5ec6496 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Mar 2011 01:08:10 +0000 Subject: [PATCH 043/261] minor changes to master unpack script. --- build_files/buildbot/master_unpack.py | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index 70c8b4c3b0b..5e0c6beb962 100644 --- a/build_files/buildbot/master_unpack.py +++ b/build_files/buildbot/master_unpack.py @@ -18,21 +18,22 @@ # Runs on Buildbot master, to unpack incoming unload.zip into latest # builds directory and remove older builds. - + import os import shutil import sys import zipfile + # extension stripping def strip_extension(filename): - extensions = ['.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe'] + extensions = '.zip', '.tar', '.bz2', '.gz', '.tgz', '.tbz', '.exe' + filename_noext, ext = os.path.splitext(filename) + if ext in extensions: + return strip_extension(filename_noext) # may have .tar.bz2 + else: + return filename - for ext in extensions: - if filename.endswith(ext): - filename = filename[:-len(ext)] - - return filename # extract platform from package name def get_platform(filename): @@ -40,18 +41,18 @@ def get_platform(filename): # platform out, but there may be some variations, so we fiddle a # bit to handle current and hopefully future names filename = strip_extension(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 for i, token in enumerate(tokens): if not found: for platform in platforms: - if token.lower().find(platform) != -1: + if platform in token.lower(): found = True + break if found: platform_tokens += [token] @@ -67,17 +68,17 @@ filename = sys.argv[1] # open zip file if not os.path.exists(filename): - sys.stderr.write("File " + filename + " not found.\n") + sys.stderr.write("File %r not found.\n" % filename) sys.exit(1) try: z = zipfile.ZipFile(filename, "r") except Exception, ex: - sys.stderr.write('Failed to open zip file: ' + str(ex) + '\n') + sys.stderr.write('Failed to open zip file: %s\n' % str(ex)) sys.exit(1) if len(z.namelist()) != 1: - sys.stderr.write("Expected on file in " + filename + ".") + sys.stderr.write("Expected one file in %r." % filename) sys.exit(1) package = z.namelist()[0] @@ -87,7 +88,7 @@ packagename = os.path.basename(package) platform = get_platform(packagename) if platform == '': - sys.stderr.write('Failed to detect platform from package: ' + packagename + '\n') + sys.stderr.write('Failed to detect platform from package: %r\n' % packagename) sys.exit(1) # extract @@ -101,19 +102,18 @@ try: zf.close() z.close() - + os.remove(filename) except Exception, ex: - sys.stderr.write('Failed to unzip package: ' + str(ex) + '\n') + sys.stderr.write('Failed to unzip package: %s\n' % str(ex)) sys.exit(1) # remove other files from the same platform try: for f in os.listdir(dir): - if f.lower().find(platform.lower()) != -1: + if platform.lower() in f.lower(): if f != packagename: os.remove(os.path.join(dir, f)) except Exception, ex: - sys.stderr.write('Failed to remove old packages: ' + str(ex) + '\n') + sys.stderr.write('Failed to remove old packages: %s\n' % str(ex)) sys.exit(1) - From 6984924b96f1dc7c2bb43b0e0330ed8cd13d5159 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Mar 2011 01:50:14 +0000 Subject: [PATCH 044/261] fix implicit declaration --- source/blender/editors/physics/physics_fluid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index b2f62f21cf1..4ac794ed620 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -87,6 +87,7 @@ #include "ED_fluidsim.h" #include "WM_types.h" +#include "WM_api.h" #include "physics_intern.h" // own include From 55b631516642d3269197fd36495844677a102630 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 23 Mar 2011 08:52:53 +0000 Subject: [PATCH 045/261] Fix for [#26580] Rekey deselects active verts * Just a missing flag after rekeying. --- source/blender/editors/physics/particle_edit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index d3e61e785e1..697f016f2d4 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1970,6 +1970,7 @@ static void rekey_particle(PEData *data, int pa_index) for(k=0, key=pa->hair; ktotkey; k++, key++, ekey++) { ekey->co= key->co; ekey->time= &key->time; + ekey->flag |= PEK_SELECT; if(!(psys->flag & PSYS_GLOBAL_HAIR)) ekey->flag |= PEK_USE_WCO; } From 82f99a0db0a2ebe2589a0260d869f18bbf4ee196 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 23 Mar 2011 09:18:09 +0000 Subject: [PATCH 046/261] Adding header for offsetof() --- source/blender/collada/AnimationImporter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 85fc6e3cbeb..a166324bde7 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -26,6 +26,7 @@ * \ingroup collada */ +#include /* COLLADABU_ASSERT, may be able to remove later */ #include "COLLADABUPlatform.h" From 9b1ee158e59211d77089563fc8cbf8f3b6ce065f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 23 Mar 2011 09:22:28 +0000 Subject: [PATCH 047/261] Bugfix: NLA Header was broken by recent Py UI-script changes --- release/scripts/startup/bl_ui/space_nla.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py index 83d84647acb..4f2988f6b4b 100644 --- a/release/scripts/startup/bl_ui/space_nla.py +++ b/release/scripts/startup/bl_ui/space_nla.py @@ -25,7 +25,7 @@ class NLA_HT_header(bpy.types.Header): bl_space_type = 'NLA_EDITOR' def draw(self, context): - from space_dopesheet import dopesheet_filter + from bl_ui.space_dopesheet import dopesheet_filter layout = self.layout From f64f979a10c5c5007a0b14c2f134970023cb7e15 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 23 Mar 2011 10:33:06 +0000 Subject: [PATCH 048/261] Fix wrong CINE_SCOPE_24FPS RNA enum identifier. --- source/blender/makesrna/intern/rna_scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 3ac1f929203..bfaa81f631e 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2034,7 +2034,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {1, "CINE_24FPS", 0, "Cinema 24fps 2048x1080", ""}, {2, "CINE_48FPS", 0, "Cinema 48fps 2048x1080", ""}, {3, "CINE_24FPS_4K", 0, "Cinema 24fps 4096x2160", ""}, - {4, "CINE_SCOPE_48FPS", 0, "Cine-Scope 24fps 2048x858", ""}, + {4, "CINE_SCOPE_24FPS", 0, "Cine-Scope 24fps 2048x858", ""}, {5, "CINE_SCOPE_48FPS", 0, "Cine-Scope 48fps 2048x858", ""}, {6, "CINE_FLAT_24FPS", 0, "Cine-Flat 24fps 1998x1080", ""}, {7, "CINE_FLAT_48FPS", 0, "Cine-Flat 48fps 1998x1080", ""}, From f35c3966766ad62a90a00b4473c79766be9b2139 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 23 Mar 2011 10:57:45 +0000 Subject: [PATCH 049/261] Fix for 1. in [#26212] ParticleSystem.particles issues * Exposed dynamic hair data in rna to allow exporting hair dynamics. --- source/blender/makesrna/intern/rna_particle.c | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 73030b00328..f48a575951f 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -37,6 +37,7 @@ #include "rna_internal.h" #include "DNA_material_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_cloth_types.h" #include "DNA_particle_types.h" @@ -121,6 +122,8 @@ EnumPropertyItem part_hair_ren_as_items[] = { #include "BKE_cloth.h" #include "BKE_deform.h" #include "BKE_depsgraph.h" +#include "BKE_DerivedMesh.h" +#include "BKE_cdderivedmesh.h" #include "BKE_effect.h" #include "BKE_modifier.h" #include "BKE_particle.h" @@ -213,6 +216,58 @@ static void rna_ParticleHairKey_location_object_set(PointerRNA *ptr, const float } } +static void rna_ParticleHairKey_dynamic_location_object_get(PointerRNA *ptr, float *values) +{ + HairKey *hkey= (HairKey *)ptr->data; + Object *ob = (Object *)ptr->id.data; + ParticleSystemModifierData *psmd; + ParticleData *pa; + + rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa); + + if(pa) { + ParticleSystem *psys = psmd->psys; + DerivedMesh *hairdm = (psys->flag & PSYS_HAIR_DYNAMICS) ? psys->hair_out_dm : NULL; + + if(hairdm) { + MVert *mvert = CDDM_get_vert(hairdm, pa->hair_index + (hkey - pa->hair)); + copy_v3_v3(values, mvert->co); + } + else { + rna_ParticleHairKey_dynamic_location_object_get(ptr, values); + } + } + else { + zero_v3(values); + } +} + +static void rna_ParticleHairKey_dynamic_location_object_set(PointerRNA *ptr, const float *values) +{ + HairKey *hkey= (HairKey *)ptr->data; + Object *ob = (Object *)ptr->id.data; + ParticleSystemModifierData *psmd; + ParticleData *pa; + + rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa); + + if(pa) { + ParticleSystem *psys = psmd->psys; + DerivedMesh *hairdm = (psys->flag & PSYS_HAIR_DYNAMICS) ? psys->hair_out_dm : NULL; + + if(hairdm) { + MVert *mvert = CDDM_get_vert(hairdm, pa->hair_index + (hkey - pa->hair)); + copy_v3_v3(mvert->co, values); + } + else { + rna_ParticleHairKey_dynamic_location_object_set(ptr, values); + } + } + else { + zero_v3(hkey->co); + } +} + /* property update functions */ static void particle_recalc(Main *bmain, Scene *scene, PointerRNA *ptr, short flag) { @@ -886,6 +941,11 @@ static void rna_def_particle_hair_key(BlenderRNA *brna) prop= RNA_def_property(srna, "co_hair_space", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "co"); RNA_def_property_ui_text(prop, "Location", "Location of the hair key in its internal coordinate system, relative to the emitting face"); + + prop= RNA_def_property(srna, "co_dynamic", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Location (Dynamic)", "Location of the hair key for the current frame with hair dynamics applied"); + RNA_def_property_float_funcs(prop, "rna_ParticleHairKey_dynamic_location_object_get", "rna_ParticleHairKey_dynamic_location_object_set", NULL); } static void rna_def_particle_key(BlenderRNA *brna) From f87b37b3ef679dad8f492e223f20fecc7e9fa5da Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Mar 2011 12:44:22 +0000 Subject: [PATCH 050/261] allow unregistered rna classes to have rna properties assigned before registration. this is useful for the register() class method which is called before the class gets structRNA assigned. eg: class MyClass(bpy.types.PropertyGroup): @classmethod def register(cls): cls.name = StringProperty() # assigned but registration is delayed. --- source/blender/python/intern/bpy_rna.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 0dfc98de487..a8c504e775b 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -2993,11 +2993,13 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb } if(srna == NULL) { + /* allow setting on unregistered classes which can be registered later on */ + /* if(value && is_deferred_prop) { PyErr_Format(PyExc_AttributeError, "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'", ((PyTypeObject *)cls)->tp_name); return -1; } - + */ /* srna_from_self may set an error */ PyErr_Clear(); return PyType_Type.tp_setattro(cls, attr, value); From 72fe34efb2a9787598fe10c3aefae3f523bd036f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Mar 2011 13:04:35 +0000 Subject: [PATCH 051/261] tweaks not to load webbrowser or math modules on startup. --- .../startup/bl_operators/uvcalc_lightmap.py | 4 +- release/scripts/startup/bl_operators/wm.py | 64 +++++++++++++++++++ source/blender/makesrna/intern/rna_particle.c | 4 +- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index fedc8b15161..3893612437a 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -21,8 +21,6 @@ import bpy import mathutils -from math import sqrt, pi - class prettyface(object): __slots__ = "uv", "width", "height", "children", "xoff", "yoff", "has_parent", "rot" @@ -104,6 +102,7 @@ class prettyface(object): pf.spin() def place(self, xoff, yoff, xfac, yfac, margin_w, margin_h): + from math import pi xoff += self.xoff yoff += self.yoff @@ -196,6 +195,7 @@ def lightmap_uvpack(meshes, and a higher value will have more clumpy boxes but more waisted space ''' import time + from math import sqrt if not meshes: return diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 0563cd409ca..5d222168046 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -552,6 +552,7 @@ class WM_OT_url_open(bpy.types.Operator): def execute(self, context): import webbrowser + _webbrowser_bug_fix() webbrowser.open(self.url) return {'FINISHED'} @@ -625,6 +626,7 @@ class WM_OT_doc_view(bpy.types.Operator): return {'PASS_THROUGH'} import webbrowser + _webbrowser_bug_fix() webbrowser.open(url) return {'FINISHED'} @@ -855,3 +857,65 @@ class WM_OT_sysinfo(bpy.types.Operator): import sys_info sys_info.write_sysinfo(self) return {'FINISHED'} + + +def _webbrowser_bug_fix(): + # test for X11 + import os + + if os.environ.get("DISPLAY"): + + # BSD licenced code copied from python, temp fix for bug + # http://bugs.python.org/issue11432, XXX == added code + def _invoke(self, args, remote, autoraise): + # XXX, added imports + import io + import subprocess + import time + + raise_opt = [] + if remote and self.raise_opts: + # use autoraise argument only for remote invocation + autoraise = int(autoraise) + opt = self.raise_opts[autoraise] + if opt: + raise_opt = [opt] + + cmdline = [self.name] + raise_opt + args + + if remote or self.background: + inout = io.open(os.devnull, "r+") + else: + # for TTY browsers, we need stdin/out + inout = None + # if possible, put browser in separate process group, so + # keyboard interrupts don't affect browser as well as Python + setsid = getattr(os, 'setsid', None) + if not setsid: + setsid = getattr(os, 'setpgrp', None) + + p = subprocess.Popen(cmdline, close_fds=True, # XXX, stdin=inout, + stdout=(self.redirect_stdout and inout or None), + stderr=inout, preexec_fn=setsid) + if remote: + # wait five secons. If the subprocess is not finished, the + # remote invocation has (hopefully) started a new instance. + time.sleep(1) + rc = p.poll() + if rc is None: + time.sleep(4) + rc = p.poll() + if rc is None: + return True + # if remote call failed, open() will try direct invocation + return not rc + elif self.background: + if p.poll() is None: + return True + else: + return False + else: + return not p.wait() + + import webbrowser + webbrowser.UnixBrowser._invoke = _invoke \ No newline at end of file diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index f48a575951f..55882f0acee 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -219,7 +219,7 @@ static void rna_ParticleHairKey_location_object_set(PointerRNA *ptr, const float static void rna_ParticleHairKey_dynamic_location_object_get(PointerRNA *ptr, float *values) { HairKey *hkey= (HairKey *)ptr->data; - Object *ob = (Object *)ptr->id.data; + // Object *ob = (Object *)ptr->id.data; ParticleSystemModifierData *psmd; ParticleData *pa; @@ -245,7 +245,7 @@ static void rna_ParticleHairKey_dynamic_location_object_get(PointerRNA *ptr, flo static void rna_ParticleHairKey_dynamic_location_object_set(PointerRNA *ptr, const float *values) { HairKey *hkey= (HairKey *)ptr->data; - Object *ob = (Object *)ptr->id.data; + // Object *ob = (Object *)ptr->id.data; ParticleSystemModifierData *psmd; ParticleData *pa; From edc5cf1f96f0f0a0eff65a4aa574dfae9c2fc606 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 23 Mar 2011 14:06:44 +0000 Subject: [PATCH 052/261] Fix #26573, #26574 and #26551: objects on layers not visible on load or undo restore, would not get their dependencies updated when they became visible. It happend with a shrinkwrap modifier in these reports, but could happen with other modifiers too. Now we keep track of which layers have ever been updated since load, and tag objects on them to be recalculated when they become visible. --- source/blender/blenkernel/BKE_depsgraph.h | 2 +- source/blender/blenkernel/intern/blender.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 5 +++-- source/blender/blenloader/intern/readfile.c | 1 + source/blender/makesdna/DNA_scene_types.h | 2 +- source/blender/makesrna/intern/rna_scene.c | 8 +++++++- source/blender/makesrna/intern/rna_space.c | 7 ++++++- source/blender/windowmanager/intern/wm_files.c | 4 ++-- source/creator/creator.c | 4 ++-- 9 files changed, 24 insertions(+), 11 deletions(-) diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index f78a957cbab..14251fb1762 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -112,7 +112,7 @@ void DAG_scene_update_flags(struct Main *bmain, struct Scene *sce, unsigned int /* flushes all recalc flags in objects down the dependency tree */ void DAG_scene_flush_update(struct Main *bmain, struct Scene *sce, unsigned int lay, const short do_time); /* tag objects for update on file load */ -void DAG_on_load_update(struct Main *bmain, const short do_time); +void DAG_on_visible_update(struct Main *bmain, const short do_time); /* when setting manual RECALC flags, call this afterwards */ void DAG_ids_flush_update(struct Main *bmain, int time); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 9fb36d8f6b7..d1a181046a6 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -466,7 +466,7 @@ static int read_undosave(bContext *C, UndoElem *uel) if(success) { /* important not to update time here, else non keyed tranforms are lost */ - DAG_on_load_update(G.main, FALSE); + DAG_on_visible_update(G.main, FALSE); } return success; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index ec75bfb1818..ff49c64ebf4 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2270,7 +2270,7 @@ void DAG_ids_flush_update(Main *bmain, int time) DAG_scene_flush_update(bmain, sce, lay, time); } -void DAG_on_load_update(Main *bmain, const short do_time) +void DAG_on_visible_update(Main *bmain, const short do_time) { Scene *scene; Base *base; @@ -2295,7 +2295,7 @@ void DAG_on_load_update(Main *bmain, const short do_time) node= (sce_iter->theDag)? dag_get_node(sce_iter->theDag, ob): NULL; oblay= (node)? node->lay: ob->lay; - if(oblay & lay) { + if((oblay & lay) & ~scene->lay_updated) { if(ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) ob->recalc |= OB_RECALC_DATA; if(ob->dup_group) @@ -2318,6 +2318,7 @@ void DAG_on_load_update(Main *bmain, const short do_time) /* now tag update flags, to ensure deformers get calculated on redraw */ DAG_scene_update_flags(bmain, scene, lay, do_time); + scene->lay_updated |= lay; } } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 98a83e22ee5..22ce3bd590a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4470,6 +4470,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->stats= NULL; sce->fps_info= NULL; sce->customdata_mask_modal= 0; + sce->lay_updated = 0; sound_create_scene(sce); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index cc35658b63f..bd2cce041dd 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -783,9 +783,9 @@ typedef struct Scene { unsigned int lay; /* bitflags for layer visibility */ int layact; /* active layer */ + unsigned int lay_updated; /* runtime flag, has layer ever been updated since load? */ unsigned int customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ unsigned int customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ - unsigned int pad4; short flag; /* various settings */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index bfaa81f631e..812e991831b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -319,6 +319,12 @@ static void rna_Scene_view3d_update(Main *bmain, Scene *unused, PointerRNA *ptr) BKE_screen_view3d_main_sync(&bmain->screen, scene); } +static void rna_Scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + rna_Scene_view3d_update(bmain, scene, ptr); + DAG_on_visible_update(bmain, FALSE); +} + static void rna_Scene_framelen_update(Main *bmain, Scene *scene, PointerRNA *ptr) { scene->r.framelen= (float)scene->r.framapto/(float)scene->r.images; @@ -3177,7 +3183,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_array(prop, 20); RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_layer_set"); RNA_def_property_ui_text(prop, "Layers", "Layers visible when rendering the scene"); - RNA_def_property_update(prop, NC_SCENE|ND_LAYER, "rna_Scene_view3d_update"); + RNA_def_property_update(prop, NC_SCENE|ND_LAYER, "rna_Scene_layer_update"); /* Frame Range Stuff */ prop= RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 6b0ae7eec80..54b2dc1dd0f 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -314,6 +314,11 @@ static void rna_SpaceView3D_layer_set(PointerRNA *ptr, const int *values) v3d->lay= ED_view3d_scene_layer_set(v3d->lay, values, &v3d->layact); } +static void rna_SpaceView3D_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + DAG_on_visible_update(bmain, FALSE); +} + static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr) { View3D *v3d= (View3D*)(ptr->data); @@ -1275,7 +1280,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_array(prop, 20); RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_layer_set"); RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible in this 3D View"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_SpaceView3D_layer_update"); prop= RNA_def_property(srna, "layers_used", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "lay_used", 1); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ebf3e856241..35bb874ff71 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -329,7 +329,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); ED_editors_init(C); - DAG_on_load_update(CTX_data_main(C), TRUE); + DAG_on_visible_update(CTX_data_main(C), TRUE); #ifdef WITH_PYTHON /* run any texts that were loaded in and flagged as modules */ @@ -433,7 +433,7 @@ int WM_read_homefile(bContext *C, ReportList *reports, short from_memory) BKE_write_undo(C, "original"); /* save current state */ ED_editors_init(C); - DAG_on_load_update(CTX_data_main(C), TRUE); + DAG_on_visible_update(CTX_data_main(C), TRUE); #ifdef WITH_PYTHON if(CTX_py_init_get(C)) { diff --git a/source/creator/creator.c b/source/creator/creator.c index 6c2ba5bc674..2480f8b544b 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -72,7 +72,7 @@ #include "BKE_utildefines.h" #include "BKE_blender.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" // for DAG_on_load_update +#include "BKE_depsgraph.h" // for DAG_on_visible_update #include "BKE_font.h" #include "BKE_global.h" #include "BKE_main.h" @@ -993,7 +993,7 @@ static int load_file(int UNUSED(argc), const char **argv, void *data) G.relbase_valid = 1; if (CTX_wm_manager(C) == NULL) CTX_wm_manager_set(C, wm); /* reset wm */ - DAG_on_load_update(CTX_data_main(C), TRUE); + DAG_on_visible_update(CTX_data_main(C), TRUE); } /* WM_read_file() runs normally but since we're in background mode do here */ From 392829c6ea2350078f1018a216190cea8acf6e4f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Mar 2011 14:24:13 +0000 Subject: [PATCH 053/261] fix [#26588] In render view, Blender crashes when collapsing an opened split render pane if you have the histogram tab open in the pane your collapsing. --- source/blender/editors/space_image/space_image.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 1b5cae2ab05..1d643ba1a89 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -460,7 +460,9 @@ static SpaceLink *image_duplicate(SpaceLink *sl) /* clear or remove stuff from old */ if(simagen->cumap) simagen->cumap= curvemapping_copy(simagen->cumap); - + + scopes_new(&simagen->scopes); + return (SpaceLink *)simagen; } From 3c45a2d2984723caba3846f143d90b3f0c69aede Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 23 Mar 2011 14:25:35 +0000 Subject: [PATCH 054/261] COLLADA: supporting barebone class for support (incomplete). --- source/blender/collada/CMakeLists.txt | 3 + source/blender/collada/DocumentImporter.cpp | 10 ++- source/blender/collada/ExtraHandler.cpp | 67 ++++++++++++++++++++ source/blender/collada/ExtraHandler.h | 69 +++++++++++++++++++++ source/blender/collada/SConscript | 2 +- 5 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 source/blender/collada/ExtraHandler.cpp create mode 100644 source/blender/collada/ExtraHandler.h diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt index 73e81025226..830e22f70d7 100644 --- a/source/blender/collada/CMakeLists.txt +++ b/source/blender/collada/CMakeLists.txt @@ -51,6 +51,7 @@ else() ${OPENCOLLADA_INC}/COLLADABaseUtils/include ${OPENCOLLADA_INC}/COLLADAFramework/include ${OPENCOLLADA_INC}/COLLADASaxFrameworkLoader/include + ${OPENCOLLADA_INC}/GeneratedSaxParser/include ) endif() @@ -62,6 +63,7 @@ set(SRC DocumentExporter.cpp DocumentImporter.cpp EffectExporter.cpp + ExtraHandler.cpp GeometryExporter.cpp ImageExporter.cpp InstanceWriter.cpp @@ -82,6 +84,7 @@ set(SRC DocumentExporter.h DocumentImporter.h EffectExporter.h + ExtraHandler.h GeometryExporter.h ImageExporter.h InstanceWriter.h diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 91652957234..49992a6989f 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -49,6 +49,7 @@ #include "COLLADAFWLight.h" #include "COLLADASaxFWLLoader.h" +#include "COLLADASaxFWLIExtraDataCallbackHandler.h" #include "BLI_listbase.h" #include "BLI_math.h" @@ -74,10 +75,11 @@ #include "MEM_guardedalloc.h" +#include "ExtraHandler.h" #include "DocumentImporter.h" #include "TransformReader.h" -#include "collada_internal.h" +#include "collada_internal.h" #include "collada_utils.h" @@ -143,6 +145,10 @@ private: /** TODO Add error handler (implement COLLADASaxFWL::IErrorHandler */ COLLADASaxFWL::Loader loader; COLLADAFW::Root root(&loader, this); + ExtraHandler *ehandler = new ExtraHandler(); + + loader.registerExtraDataCallbackHandler(ehandler); + if (!root.loadDocument(mFilename)) return false; @@ -157,6 +163,8 @@ private: if (!root2.loadDocument(mFilename)) return false; + + delete ehandler; return true; } diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp new file mode 100644 index 00000000000..8aafccd3734 --- /dev/null +++ b/source/blender/collada/ExtraHandler.cpp @@ -0,0 +1,67 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Nathan Letwory. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/collada/ExtraHandler.cpp + * \ingroup collada + */ + +#include "BLI_string.h" + +#include "ExtraHandler.h" + +ExtraHandler::ExtraHandler(){} + +ExtraHandler::~ExtraHandler(){} + +bool ExtraHandler::elementBegin( const char* elementName, const char** attributes) +{ + printf("begin: %s\n", elementName); + return true; +} + +bool ExtraHandler::elementEnd(const char* elementName ) +{ + printf("end: %s\n", elementName); + return true; +} + +bool ExtraHandler::textData(const char* text, size_t textLength) +{ + char buf[1024] = {0}; + _snprintf(buf, textLength, "%s", text); + printf("data: %s\n", buf); + return true; +} + +bool ExtraHandler::parseElement ( + const char* profileName, + const unsigned long& elementHash, + const COLLADAFW::UniqueId& uniqueId ) { + if(BLI_strcaseeq(profileName, "blender")) { + printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); + return true; + } + printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); + return false; +} diff --git a/source/blender/collada/ExtraHandler.h b/source/blender/collada/ExtraHandler.h new file mode 100644 index 00000000000..463633d744c --- /dev/null +++ b/source/blender/collada/ExtraHandler.h @@ -0,0 +1,69 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Nathan Letwory. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/collada/ExtraHandler.h + * \ingroup collada + */ + +#include +#include +#include +#include // sort() + +#include "COLLADASaxFWLIExtraDataCallbackHandler.h" + + +/** \brief Handler class for data, through which different + * profiles can be handled + */ +class ExtraHandler : public COLLADASaxFWL::IExtraDataCallbackHandler +{ +public: + /** Constructor. */ + ExtraHandler(); + + /** Destructor. */ + virtual ~ExtraHandler(); + + /** Handle the beginning of an element. */ + bool elementBegin( const char* elementName, const char** attributes); + + /** Handle the end of an element. */ + bool elementEnd(const char* elementName ); + + /** Receive the data in text format. */ + bool textData(const char* text, size_t textLength); + + /** Method to ask, if the current callback handler want to read the data of the given extra element. */ + bool parseElement ( + const char* profileName, + const unsigned long& elementHash, + const COLLADAFW::UniqueId& uniqueId ); +private: + /** Disable default copy constructor. */ + ExtraHandler( const ExtraHandler& pre ); + /** Disable default assignment operator. */ + const ExtraHandler& operator= ( const ExtraHandler& pre ); +}; + diff --git a/source/blender/collada/SConscript b/source/blender/collada/SConscript index 10c3fcaeb96..b2a25e81dd5 100644 --- a/source/blender/collada/SConscript +++ b/source/blender/collada/SConscript @@ -35,7 +35,7 @@ defs = [] if env['OURPLATFORM']=='darwin': incs = '../blenlib ../blenkernel ../windowmanager ../blenloader ../makesdna ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter [OPENCOLLADA]/COLLADABaseUtils [OPENCOLLADA]/COLLADAFramework [OPENCOLLADA]/COLLADASaxFrameworkLoader '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) else: - incs = '../blenlib ../blenkernel ../windowmanager ../makesdna ../blenloader ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter/include [OPENCOLLADA]/COLLADABaseUtils/include [OPENCOLLADA]/COLLADAFramework/include [OPENCOLLADA]/COLLADASaxFrameworkLoader/include '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) + incs = '../blenlib ../blenkernel ../windowmanager ../makesdna ../blenloader ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter/include [OPENCOLLADA]/COLLADABaseUtils/include [OPENCOLLADA]/COLLADAFramework/include [OPENCOLLADA]/COLLADASaxFrameworkLoader/include [OPENCOLLADA]/GeneratedSaxParser/include '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) if env['BF_BUILDINFO']: defs.append('NAN_BUILDINFO') From 66670b8f7ff77cd91db61ab69b1ac3c13c8ffb01 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Mar 2011 15:07:30 +0000 Subject: [PATCH 055/261] fix for building collada on linux --- source/blender/collada/ExtraHandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp index 8aafccd3734..deec22fac04 100644 --- a/source/blender/collada/ExtraHandler.cpp +++ b/source/blender/collada/ExtraHandler.cpp @@ -26,6 +26,8 @@ * \ingroup collada */ +#include + #include "BLI_string.h" #include "ExtraHandler.h" @@ -49,7 +51,7 @@ bool ExtraHandler::elementEnd(const char* elementName ) bool ExtraHandler::textData(const char* text, size_t textLength) { char buf[1024] = {0}; - _snprintf(buf, textLength, "%s", text); + BLI_snprintf(buf, textLength, "%s", text); printf("data: %s\n", buf); return true; } From 2c4999eccb707041e2c97380c505b5ccb302b496 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Mar 2011 15:14:21 +0000 Subject: [PATCH 056/261] missed committing this before --- release/scripts/modules/bpy/__init__.py | 60 ------------------------- 1 file changed, 60 deletions(-) diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index efb1cf5c435..ed7b4baa806 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -53,65 +53,5 @@ def _main(): else: utils.load_scripts() - import os - - # test for X11 - if os.environ.get("DISPLAY"): - - # BSD licenced code copied from python, temp fix for bug - # http://bugs.python.org/issue11432, XXX == added code - def _invoke(self, args, remote, autoraise): - # XXX, added imports - import io - import subprocess - import time - - raise_opt = [] - if remote and self.raise_opts: - # use autoraise argument only for remote invocation - autoraise = int(autoraise) - opt = self.raise_opts[autoraise] - if opt: - raise_opt = [opt] - - cmdline = [self.name] + raise_opt + args - - if remote or self.background: - inout = io.open(os.devnull, "r+") - else: - # for TTY browsers, we need stdin/out - inout = None - # if possible, put browser in separate process group, so - # keyboard interrupts don't affect browser as well as Python - setsid = getattr(os, 'setsid', None) - if not setsid: - setsid = getattr(os, 'setpgrp', None) - - p = subprocess.Popen(cmdline, close_fds=True, # XXX, stdin=inout, - stdout=(self.redirect_stdout and inout or None), - stderr=inout, preexec_fn=setsid) - if remote: - # wait five secons. If the subprocess is not finished, the - # remote invocation has (hopefully) started a new instance. - time.sleep(1) - rc = p.poll() - if rc is None: - time.sleep(4) - rc = p.poll() - if rc is None: - return True - # if remote call failed, open() will try direct invocation - return not rc - elif self.background: - if p.poll() is None: - return True - else: - return False - else: - return not p.wait() - - import webbrowser - webbrowser.UnixBrowser._invoke = _invoke - _main() From 9019d3b1f2ae10e88a0a0f430bdca3b7f2f83fb7 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 23 Mar 2011 15:15:42 +0000 Subject: [PATCH 057/261] Additonal fix for r35724 (bugfix #26573, #26574 and #26551) Layer visibility code for hotkeys uses different code still, added same new DAG_on_visible_update() in this operator. --- source/blender/editors/space_view3d/view3d_header.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 9d7f0313256..3b6b7257c9c 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -152,8 +152,6 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); ScrArea *sa= CTX_wm_area(C); View3D *v3d= sa->spacedata.first; - Base *base; - int oldlay= v3d->lay; int nr= RNA_int_get(op->ptr, "nr"); int toggle= RNA_boolean_get(op->ptr, "toggle"); @@ -211,12 +209,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) if(v3d->scenelock) handle_view3d_lock(C); - /* XXX new layers might need updates, there is no provision yet to detect if that's needed */ - oldlay= ~oldlay & v3d->lay; - for (base= scene->base.first; base; base= base->next) { - if(base->lay & oldlay) - base->object->recalc= OB_RECALC_OB|OB_RECALC_DATA; - } + DAG_on_visible_update(CTX_data_main(C), FALSE); ED_area_tag_redraw(sa); From a94e9c5955876e7dc3e1fb6c1aef6568b5b1f1e7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Mar 2011 16:05:35 +0000 Subject: [PATCH 058/261] fix [#26456] weightpaint mode with armature modifier, armature mode disable bone selection in weightpaint mode when the armature is not in pose mode. --- source/blender/editors/space_view3d/drawarmature.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 701e9f8af0d..a69ad1c7050 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2460,12 +2460,16 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in /* drawing posemode selection indices or colors only in these cases */ if(!(base->flag & OB_FROMDUPLI)) { if(G.f & G_PICKSEL) { +#if 0 /* nifty but actually confusing to allow bone selection out of posemode */ if(OBACT && (OBACT->mode & OB_MODE_WEIGHT_PAINT)) { if(ob==modifiers_isDeformedByArmature(OBACT)) arm->flag |= ARM_POSEMODE; } - else if(ob->mode & OB_MODE_POSE) + else +#endif + if(ob->mode & OB_MODE_POSE) { arm->flag |= ARM_POSEMODE; + } } else if(ob->mode & OB_MODE_POSE) { if (arm->ghosttype == ARM_GHOST_RANGE) { From 7cef4ea008b10a879c0731b39e431594602af41d Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 23 Mar 2011 16:36:41 +0000 Subject: [PATCH 059/261] IRC bugreport: Splitting/joining editors (areas) was possible in full-screen mode. That's not possible, crashes on going back to previous. --- source/blender/editors/screen/screen_ops.c | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 5236d67fa55..b52937aa309 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -108,6 +108,17 @@ int ED_operator_screenactive(bContext *C) return 1; } +static int screen_active_editable(bContext *C) +{ + if(ED_operator_screenactive(C)) { + /* no full window splitting allowed */ + if(CTX_wm_screen(C)->full != SCREENNORMAL) + return 0; + return 1; + } + return 0; +} + /* when mouse is over area-edge */ int ED_operator_screen_mainwinactive(bContext *C) { @@ -1263,6 +1274,10 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) sAreaSplitData *sd; int dir; + /* no full window splitting allowed */ + if(CTX_wm_screen(C)->full != SCREENNORMAL) + return OPERATOR_CANCELLED; + if(event->type==EVT_ACTIONZONE_AREA) { sActionzoneData *sad= event->customdata; @@ -1270,7 +1285,6 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_PASS_THROUGH; } - /* verify *sad itself */ if(sad==NULL || sad->sa1==NULL || sad->az==NULL) return OPERATOR_PASS_THROUGH; @@ -1299,10 +1313,6 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) ScrEdge *actedge; int x, y; - /* no full window splitting allowed */ - if(CTX_wm_area(C) && CTX_wm_area(C)->full) - return OPERATOR_CANCELLED; - /* retrieve initial mouse coord, so we can find the active edge */ if(RNA_property_is_set(op->ptr, "mouse_x")) x= RNA_int_get(op->ptr, "mouse_x"); @@ -1471,7 +1481,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot) ot->invoke= area_split_invoke; ot->modal= area_split_modal; - ot->poll= ED_operator_screenactive; + ot->poll= screen_active_editable; ot->flag= OPTYPE_BLOCKING; /* rna */ @@ -2210,7 +2220,7 @@ static void SCREEN_OT_area_join(wmOperatorType *ot) ot->exec= area_join_exec; ot->invoke= area_join_invoke; ot->modal= area_join_modal; - ot->poll= ED_operator_screenactive; + ot->poll= screen_active_editable; ot->flag= OPTYPE_BLOCKING; From 26dd18e7ceba689bd784eb50e9af9a0294fdcbe1 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Wed, 23 Mar 2011 18:51:31 +0000 Subject: [PATCH 060/261] fix [#26591] File browser: select multiple files for Library append/link broken * added check for valid files a bit too eagerly in Rev.35654. Solved now by setting correct type for .blend file contents. Objects are now tagged as regular files, while the list (Mesh, Material, ...) (no idcode given) is tagged as directory. --- source/blender/editors/space_file/filelist.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index da8226de516..a32cfe29970 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -1057,8 +1057,11 @@ void filelist_from_library(struct FileList* filelist) char *blockname= l->link; filelist->filelist[i + 1].relname= BLI_strdup(blockname); - if (!idcode) + if (idcode) { + filelist->filelist[i + 1].type |= S_IFREG; + } else { filelist->filelist[i + 1].type |= S_IFDIR; + } } if(previews) { @@ -1194,7 +1197,7 @@ void filelist_from_main(struct FileList *filelist) files->relname= MEM_mallocN(FILE_MAXDIR+FILE_MAXFILE+32, "filename for lib"); sprintf(files->relname, "%s | %s", id->lib->name, id->name+2); } - /* files->type |= S_IFDIR; */ + files->type |= S_IFREG; #if 0 // XXXXX TODO show the selection status of the objects if(!filelist->has_func) { /* F4 DATA BROWSE */ if(idcode==ID_OB) { From 261f74115daf8d1622c60a85ec1e0f3faef641fc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 23 Mar 2011 23:07:09 +0000 Subject: [PATCH 061/261] Fix #26571: slow approximate AO with zero area faces. --- source/blender/render/intern/source/occlusion.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index cb6a8a102d0..8f070421890 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -613,7 +613,8 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i /* compute maximum distance from center */ node->dco= 0.0f; - occ_build_dco(tree, node, node->co, &node->dco); + if(node->area > 0.0f) + occ_build_dco(tree, node, node->co, &node->dco); } static void occ_build_sh_normalize(OccNode *node) From c210b3991a074f27af80178c85d0658c4041480b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Mar 2011 00:14:49 +0000 Subject: [PATCH 062/261] support for blender as a module on win32. --- CMakeLists.txt | 7 +++++++ build_files/cmake/macros.cmake | 4 ++-- source/creator/CMakeLists.txt | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d860d525289..afb3d71a0ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1016,6 +1016,13 @@ if(WITH_OPENMP) mark_as_advanced(OpenMP_CXX_FLAGS) endif() +#----------------------------------------------------------------------------- +# Configure Python. + +if(WITH_PYTHON_MODULE) + add_definitions(-DPy_ENABLE_SHARED) +endif() + #----------------------------------------------------------------------------- # Extra compile flags diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 2297cac8bb9..073147266bb 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -66,7 +66,7 @@ macro(SETUP_LIBDIRS) link_directories(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH}) - if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE) + if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs link_directories(${PYTHON_LIBPATH}) endif() if(WITH_INTERNATIONAL) @@ -127,7 +127,7 @@ macro(setup_liblinks target_link_libraries(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${LLIBS}) # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions - if(WITH_PYTHON AND NOT WITH_PYTHON_MODULE) + if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs target_link_libraries(${target} ${PYTHON_LINKFLAGS}) if(WIN32 AND NOT UNIX) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index f13f3f7770f..99c7dba9305 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -169,7 +169,18 @@ if(WITH_PYTHON_MODULE) PREFIX "" OUTPUT_NAME bpy LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ # only needed on windows ) + + if(WIN32) + # python modules use this + set_target_properties( + blender + PROPERTIES + SUFFIX ".pyd" + ) + endif() + else() add_executable(blender ${EXETYPE} ${SRC}) endif() From eef811a0954ad67a4667592c85cd95822d15e17c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 24 Mar 2011 03:02:34 +0000 Subject: [PATCH 063/261] Animation Tool: Propagate Pose This tool automates the process of copying a pose to successive keyframes, making it easier for animators to go back and change the pose for some controls which remain "static" for periods of time. Previously, animators would need to do a "{Ctrl-Pageup Ctrl-V} * number_of_static_keyframes" dance for each set of controls that this happened on, which is not too good ergonomically speaking. There are two modes exposed via the menu (Pose->Propagate): - "Pose Propagate" - also known as the 'WHILE_HELD' mode, which propagates to all keyframes that are holding the same value - "To Next Keyframe" - which only propagates the pose to the closest keyframe in the occurring after (but not including) the current frame Additionally, there are a few other modes that can be used, though they are less useful for direct use from the UI, though they can be used via the PyAPI as need be. --- Also, I did some cleanups in the "Pose" menu to bring it more into line with the Object mode one. There are some more tweaks that could still be done here, such as bringing the keyframing operator entries under a submenu too (as in the Object mode version) to get the length of this under control. --- release/scripts/startup/bl_ui/space_view3d.py | 60 ++- .../editors/animation/keyframes_draw.c | 19 +- .../editors/armature/armature_intern.h | 2 + .../blender/editors/armature/armature_ops.c | 2 + source/blender/editors/armature/poseSlide.c | 347 +++++++++++++++++- source/blender/editors/armature/poseobject.c | 3 +- .../editors/include/ED_keyframes_draw.h | 3 + 7 files changed, 411 insertions(+), 25 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 31704173258..bbeb76d2cb1 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -177,10 +177,6 @@ class VIEW3D_MT_transform(bpy.types.Menu): layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY' layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR' - if context.mode == 'OBJECT': - layout.operator("object.align") - layout.operator("object.randomize_transform") - class VIEW3D_MT_mirror(bpy.types.Menu): bl_label = "Mirror" @@ -254,14 +250,6 @@ class VIEW3D_MT_uv_map(bpy.types.Menu): layout.operator("uv.reset") - layout.separator() - - # python scripts - layout.operator_context = 'INVOKE_REGION_WIN' - layout.operator("uv.smart_project") - layout.operator("uv.lightmap_pack") - layout.operator("uv.follow_active_quads") - # ********** View menus ********** @@ -1172,23 +1160,23 @@ class VIEW3D_MT_pose(bpy.types.Menu): layout.separator() layout.menu("VIEW3D_MT_transform") - layout.menu("VIEW3D_MT_snap") layout.menu("VIEW3D_MT_pose_transform") + layout.menu("VIEW3D_MT_pose_apply") + + layout.menu("VIEW3D_MT_snap") layout.separator() + # TODO: make this an "Animation" menu like we have for object? layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...") layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...") layout.operator("anim.keying_set_active_set", text="Change Keying Set...") layout.separator() - layout.operator("pose.relax") - - layout.separator() - - layout.menu("VIEW3D_MT_pose_apply") + layout.menu("VIEW3D_MT_pose_slide") + layout.menu("VIEW3D_MT_pose_propagate") layout.separator() @@ -1198,7 +1186,7 @@ class VIEW3D_MT_pose(bpy.types.Menu): layout.separator() - layout.menu("VIEW3D_MT_pose_pose") + layout.menu("VIEW3D_MT_pose_library") layout.menu("VIEW3D_MT_pose_motion") layout.menu("VIEW3D_MT_pose_group") @@ -1246,7 +1234,28 @@ class VIEW3D_MT_pose_transform(bpy.types.Menu): layout.label(text="Origin") -class VIEW3D_MT_pose_pose(bpy.types.Menu): +class VIEW3D_MT_pose_slide(bpy.types.Menu): + bl_label = "In-Betweens" + + def draw(self, context): + layout = self.layout + + layout.operator("pose.push") + layout.operator("pose.relax") + layout.operator("pose.breakdown") + + +class VIEW3D_MT_pose_propagate(bpy.types.Menu): + bl_label = "Propagate" + + def draw(self, context): + layout = self.layout + + layout.operator("pose.propagate") + layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY' + + +class VIEW3D_MT_pose_library(bpy.types.Menu): bl_label = "Pose Library" def draw(self, context): @@ -2313,3 +2322,14 @@ class VIEW3D_PT_context_properties(bpy.types.Panel): if member: # Draw with no edit button rna_prop_ui.draw(self.layout, context, member, object, False) + + +def register(): + bpy.utils.register_module(__name__) + + +def unregister(): + bpy.utils.unregister_module(__name__) + +if __name__ == "__main__": + register() diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index aab38790687..3f8f8dc1e84 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -80,7 +80,7 @@ /* ActKeyColumns (Keyframe Columns) ------------------------------------------ */ /* Comparator callback used for ActKeyColumns and cframe float-value pointer */ -// NOTE: this is exported to other modules that use the ActKeyColumns for finding keyframes +/* NOTE: this is exported to other modules that use the ActKeyColumns for finding keyframes */ short compare_ak_cfraPtr (void *node, void *data) { ActKeyColumn *ak= (ActKeyColumn *)node; @@ -311,6 +311,23 @@ static BezTriple *abk_get_bezt_with_value (ActBeztColumn *abk, float value) /* ActKeyBlocks (Long Keyframes) ------------------------------------------ */ +/* Comparator callback used for ActKeyBlock and cframe float-value pointer */ +/* NOTE: this is exported to other modules that use the ActKeyBlocks for finding long-keyframes */ +short compare_ab_cfraPtr (void *node, void *data) +{ + ActKeyBlock *ab= (ActKeyBlock *)node; + float *cframe= data; + + if (*cframe < ab->start) + return -1; + else if (*cframe > ab->start) + return 1; + else + return 0; +} + +/* --------------- */ + /* Create a ActKeyColumn for a pair of BezTriples */ static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn) { diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index b72cf75d9c7..7a6141540bd 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -200,6 +200,8 @@ void POSE_OT_push(struct wmOperatorType *ot); void POSE_OT_relax(struct wmOperatorType *ot); void POSE_OT_breakdown(struct wmOperatorType *ot); +void POSE_OT_propagate(struct wmOperatorType *ot); + /* ******************************************************* */ /* editarmature.c */ diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 34942a2edc1..545cff82483 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -146,6 +146,8 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_armature_layers); WM_operatortype_append(POSE_OT_bone_layers); + WM_operatortype_append(POSE_OT_propagate); + /* POSELIB */ WM_operatortype_append(POSELIB_OT_browse_interactive); WM_operatortype_append(POSELIB_OT_apply_pose); diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 39d65a4526f..680cd4b6430 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -61,8 +61,6 @@ #include "WM_api.h" #include "WM_types.h" - - #include "ED_armature.h" #include "ED_keyframes_draw.h" #include "ED_screen.h" @@ -77,7 +75,13 @@ * for interactively controlling the spacing of poses, but also * for 'pushing' and/or 'relaxing' extremes as they see fit. * - * B) Pose Sculpting + * B) Propagate + * This tool copies elements of the selected pose to successive + * keyframes, allowing the animator to go back and modify the poses + * for some "static" pose controls, without having to repeatedly + * doing a "next paste" dance. + * + * C) Pose Sculpting * This is yet to be implemented, but the idea here is to use * sculpting techniques to make it easier to pose rigs by allowing * rigs to be manipulated using a familiar paint-based interface. @@ -854,3 +858,340 @@ void POSE_OT_breakdown (wmOperatorType *ot) } /* **************************************************** */ +/* B) Pose Propagate */ + +/* "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 next keyframe */ + POSE_PROPAGATE_NEXT_KEY, + /* stop after the specified frame */ + POSE_PROPAGATE_BEFORE_FRAME, + /* stop after */ + POSE_PROPAGATE_SMART_HOLDS +} ePosePropagate_Termination; + +/* --------------------------------- */ + +/* helper for pose_propagate_get_boneHoldEndFrame() + * Checks if ActKeyBlock should exist... + */ +// TODO: move to keyframes drawing API... +static short actkeyblock_is_valid (ActKeyBlock *ab, DLRBT_Tree *keys) +{ + ActKeyColumn *ak; + short startCurves, endCurves, totCurves; + + /* check that block is valid */ + if (ab == NULL) + return 0; + + /* find out how many curves occur at each keyframe */ + ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start); + startCurves = (ak)? ak->totcurve: 0; + + ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end); + endCurves = (ak)? ak->totcurve: 0; + + /* only draw keyblock if it appears in at all of the keyframes at lowest end */ + if (!startCurves && !endCurves) + return 0; + + totCurves = (startCurves>endCurves)? endCurves: startCurves; + return (ab->totcurve >= totCurves); +} + +/* get frame on which the "hold" for the bone ends + * XXX: this may not really work that well if a bone moves on some channels and not others + * if this happens to be a major issue, scrap this, and just make this happen + * independently per F-Curve + */ +static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink *pfl, float startFrame) +{ + DLRBT_Tree keys, blocks; + ActKeyBlock *ab; + + AnimData *adt= ob->adt; + LinkData *ld; + float endFrame = startFrame; + + /* set up optimised data-structures for searching for relevant keyframes + holds */ + BLI_dlrbTree_init(&keys); + BLI_dlrbTree_init(&blocks); + + for (ld = pfl->fcurves.first; ld; ld = ld->next) { + FCurve *fcu = (FCurve *)ld->data; + fcurve_to_keylist(adt, fcu, &keys, &blocks); + } + + BLI_dlrbTree_linkedlist_sync(&keys); + BLI_dlrbTree_linkedlist_sync(&blocks); + + /* find the long keyframe (i.e. hold), and hence obtain the endFrame value + * - the best case would be one that starts on the frame itself + */ + ab = (ActKeyBlock *)BLI_dlrbTree_search_exact(&blocks, compare_ab_cfraPtr, &startFrame); + + if (actkeyblock_is_valid(ab, &keys) == 0) { + /* There are only two cases for no-exact match: + * 1) the current frame is just before another key but not on a key itself + * 2) the current frame is on a key, but that key doesn't link to the next + * + * If we've got the first case, then we can search for another block, + * otherwise forget it, as we'd be overwriting some valid data. + */ + if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &startFrame) == NULL) { + /* we've got case 1, so try the one after */ + ab = (ActKeyBlock *)BLI_dlrbTree_search_next(&blocks, compare_ab_cfraPtr, &startFrame); + + if (actkeyblock_is_valid(ab, &keys) == 0) { + /* try the block before this frame then as last resort */ + ab = (ActKeyBlock *)BLI_dlrbTree_search_prev(&blocks, compare_ab_cfraPtr, &startFrame); + + /* whatever happens, stop searching now... */ + if (actkeyblock_is_valid(ab, &keys) == 0) { + /* restrict range to just the frame itself + * i.e. everything is in motion, so no holds to safely overwrite + */ + ab = NULL; + } + } + } + else { + /* we've got case 2 - set ab to NULL just in case, since we shouldn't do anything in this case */ + ab = NULL; + } + } + + /* check if we can go any further than we've already gone */ + if (ab) { + /* go to next if it is also valid and meets "extension" criteria */ + while (ab->next) { + ActKeyBlock *abn = (ActKeyBlock *)ab->next; + + /* must be valid */ + if (actkeyblock_is_valid(abn, &keys) == 0) + break; + /* should start on the same frame that the last ended on */ + if (ab->end != abn->start) + break; + /* should have the same number of curves */ + if (ab->totcurve != abn->totcurve) + break; + /* should have the same value + * XXX: this may be a bit fuzzy on larger data sets, so be careful + */ + if (ab->val != abn->val) + break; + + /* we can extend the bounds to the end of this "next" block now */ + ab = abn; + } + + /* end frame can now take the value of the end of the block */ + endFrame = ab->end; + } + + /* free temp memory */ + BLI_dlrbTree_free(&keys); + BLI_dlrbTree_free(&blocks); + + /* return the end frame we've found */ + return endFrame; +} + +/* get reference value from F-Curve using RNA */ +static float pose_propagate_get_refVal (Object *ob, FCurve *fcu) +{ + PointerRNA id_ptr, ptr; + PropertyRNA *prop; + float value; + + /* base pointer is always the object -> id_ptr */ + RNA_id_pointer_create(&ob->id, &id_ptr); + + /* resolve the property... */ + if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) { + if (RNA_property_array_check(&ptr, prop)) { + /* array */ + if (fcu->array_index < RNA_property_array_length(&ptr, prop)) { + switch (RNA_property_type(prop)) { + case PROP_BOOLEAN: + value= (float)RNA_property_boolean_get_index(&ptr, prop, fcu->array_index); + break; + case PROP_INT: + value= (float)RNA_property_int_get_index(&ptr, prop, fcu->array_index); + break; + case PROP_FLOAT: + value= RNA_property_float_get_index(&ptr, prop, fcu->array_index); + break; + default: + break; + } + } + } + else { + /* not an array */ + switch (RNA_property_type(prop)) { + case PROP_BOOLEAN: + value= (float)RNA_property_boolean_get(&ptr, prop); + break; + case PROP_INT: + value= (float)RNA_property_int_get(&ptr, prop); + break; + case PROP_ENUM: + value= (float)RNA_property_enum_get(&ptr, prop); + break; + case PROP_FLOAT: + value= RNA_property_float_get(&ptr, prop); + break; + default: + break; + } + } + } + + return value; +} + +/* propagate just works along each F-Curve in turn */ +static void pose_propagate_fcurve (wmOperator *op, Object *ob, tPChanFCurveLink *pfl, FCurve *fcu, float startFrame, float endFrame) +{ + const int mode = RNA_enum_get(op->ptr, "mode"); + + BezTriple *bezt; + float refVal = 0.0f; + short keyExists; + int i, match; + short first=1; + + /* skip if no keyframes to edit */ + if ((fcu->bezt == NULL) || (fcu->totvert < 2)) + return; + + /* find the reference value from bones directly, which means that the user + * doesn't need to firstly keyframe the pose (though this doesn't mean that + * they can't either) + */ + refVal = pose_propagate_get_refVal(ob, fcu); + + /* find the first keyframe to start propagating from + * - if there's a keyframe on the current frame, we probably want to save this value there too + * since it may be as of yet unkeyed + * - if starting before the starting frame, don't touch the key, as it may have had some valid + * values + */ + match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists); + + if (fcu->bezt[match].vec[1][0] < startFrame) + i = match + 1; + else + i = match; + + for (bezt = &fcu->bezt[i]; i < fcu->totvert; i++, bezt++) { + /* 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; + } + else if (mode == POSE_PROPAGATE_NEXT_KEY) { + /* stop after the first keyframe has been processed */ + if (first == 0) + break; + } + + /* 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)? + bezt->vec[0][1] = bezt->vec[1][1] = bezt->vec[2][1] = refVal; + + /* select keyframe to indicate that it's been changed */ + bezt->f2 |= SELECT; + first = 0; + } +} + +/* --------------------------------- */ + +static int pose_propagate_exec (bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); + bAction *act= (ob && ob->adt)? ob->adt->action : NULL; + + ListBase pflinks = {NULL, NULL}; + tPChanFCurveLink *pfl; + + float endFrame = RNA_float_get(op->ptr, "end_frame"); + const int mode = RNA_enum_get(op->ptr, "mode"); + + /* sanity checks */ + if (ob == NULL) { + BKE_report(op->reports, RPT_ERROR, "No object to propagate poses for"); + return OPERATOR_CANCELLED; + } + if (act == NULL) { + BKE_report(op->reports, RPT_ERROR, "No keyframed poses to propagate to"); + return OPERATOR_CANCELLED; + } + + /* isolate F-Curves related to the selected bones */ + poseAnim_mapping_get(C, &pflinks, ob, act); + + /* for each bone, perform the copying required */ + for (pfl = pflinks.first; pfl; pfl = pfl->next) { + LinkData *ld; + + /* mode-specific data preprocessing (requiring access to all curves) */ + if (mode == POSE_PROPAGATE_SMART_HOLDS) { + /* 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); + } + + /* 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); + } + + /* free temp data */ + poseAnim_mapping_free(&pflinks); + + /* updates + notifiers */ + poseAnim_mapping_refresh(C, scene, ob); + + return OPERATOR_FINISHED; +} + +/* --------------------------------- */ + +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)"}, + {0, NULL, 0, NULL, NULL}}; + + /* identifiers */ + ot->name= "Propagate Pose"; + ot->idname= "POSE_OT_propagate"; + ot->description= "Copy selected aspects of the current pose to subsequent poses already keyframed"; + + /* callbacks */ + ot->exec= pose_propagate_exec; + ot->poll= ED_operator_posemode; // XXX: needs selected bones! + + /* flag */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* 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); +} + +/* **************************************************** */ diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 23253c0b4cf..e9892c62a68 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -57,6 +57,7 @@ #include "BKE_constraint.h" #include "BKE_deform.h" #include "BKE_depsgraph.h" +#include "BKE_fcurve.h" #include "BKE_modifier.h" #include "BKE_report.h" @@ -1600,7 +1601,7 @@ static int pose_autoside_names_exec (bContext *C, wmOperator *op) void POSE_OT_autoside_names (wmOperatorType *ot) { static EnumPropertyItem axis_items[]= { - {0, "XAXIS", 0, "X-Axis", "Left/Right"}, + {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index c697f8cc435..544c5c4a1ef 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -146,5 +146,8 @@ void gpl_to_keylist(struct bDopeSheet *ads, struct bGPDlayer *gpl, struct DLRBT_ /* Comparator callback used for ActKeyColumns and cframe float-value pointer */ short compare_ak_cfraPtr(void *node, void *data); +/* Comparator callback used for ActKeyBlocks and cframe float-value pointer */ +short compare_ab_cfraPtr(void *node, void *data); + #endif /* ED_KEYFRAMES_DRAW_H */ From 3b0a42f898bc862cbb4e6ad04200b64dcf83e611 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 24 Mar 2011 03:19:30 +0000 Subject: [PATCH 064/261] Reshuffled utility function to keyframe drawing API, removing some duplicate code --- .../editors/animation/keyframes_draw.c | 44 ++++++++++++------- source/blender/editors/armature/poseSlide.c | 28 ------------ .../editors/include/ED_keyframes_draw.h | 3 ++ 3 files changed, 31 insertions(+), 44 deletions(-) diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 3f8f8dc1e84..662f038fd6e 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -457,6 +457,33 @@ static void set_touched_actkeyblock (ActKeyBlock *ab) set_touched_actkeyblock(ab->right); } +/* --------- */ + +/* Checks if ActKeyBlock should exist... */ +short actkeyblock_is_valid (ActKeyBlock *ab, DLRBT_Tree *keys) +{ + ActKeyColumn *ak; + short startCurves, endCurves, totCurves; + + /* check that block is valid */ + if (ab == NULL) + return 0; + + /* find out how many curves occur at each keyframe */ + ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start); + startCurves = (ak)? ak->totcurve: 0; + + ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end); + endCurves = (ak)? ak->totcurve: 0; + + /* only draw keyblock if it appears in at all of the keyframes at lowest end */ + if (!startCurves && !endCurves) + return 0; + + totCurves = (startCurves>endCurves)? endCurves: startCurves; + return (ab->totcurve >= totCurves); +} + /* *************************** Keyframe Drawing *************************** */ /* coordinates for diamond shape */ @@ -576,22 +603,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa /* draw keyblocks */ if (blocks) { for (ab= blocks->first; ab; ab= ab->next) { - short startCurves, endCurves, totCurves; - - /* find out how many curves occur at each keyframe */ - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start); - startCurves = (ak)? ak->totcurve: 0; - - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end); - endCurves = (ak)? ak->totcurve: 0; - - /* only draw keyblock if it appears in at all of the keyframes at lowest end */ - if (!startCurves && !endCurves) - continue; - else - totCurves = (startCurves>endCurves)? endCurves: startCurves; - - if (ab->totcurve >= totCurves) { + if (actkeyblock_is_valid(ab, keys)) { /* draw block */ if (ab->sel) UI_ThemeColor4(TH_STRIP_SELECT); diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 680cd4b6430..6fdcb1039f1 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -874,34 +874,6 @@ typedef enum ePosePropagate_Termination { /* --------------------------------- */ -/* helper for pose_propagate_get_boneHoldEndFrame() - * Checks if ActKeyBlock should exist... - */ -// TODO: move to keyframes drawing API... -static short actkeyblock_is_valid (ActKeyBlock *ab, DLRBT_Tree *keys) -{ - ActKeyColumn *ak; - short startCurves, endCurves, totCurves; - - /* check that block is valid */ - if (ab == NULL) - return 0; - - /* find out how many curves occur at each keyframe */ - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start); - startCurves = (ak)? ak->totcurve: 0; - - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end); - endCurves = (ak)? ak->totcurve: 0; - - /* only draw keyblock if it appears in at all of the keyframes at lowest end */ - if (!startCurves && !endCurves) - return 0; - - totCurves = (startCurves>endCurves)? endCurves: startCurves; - return (ab->totcurve >= totCurves); -} - /* get frame on which the "hold" for the bone ends * XXX: this may not really work that well if a bone moves on some channels and not others * if this happens to be a major issue, scrap this, and just make this happen diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index 544c5c4a1ef..3c1bb814c82 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -149,5 +149,8 @@ short compare_ak_cfraPtr(void *node, void *data); /* Comparator callback used for ActKeyBlocks and cframe float-value pointer */ short compare_ab_cfraPtr(void *node, void *data); +/* Checks if ActKeyBlock can be used (i.e. drawn/used to detect "holds") */ +short actkeyblock_is_valid(ActKeyBlock *ab, struct DLRBT_Tree *keys); + #endif /* ED_KEYFRAMES_DRAW_H */ From d2614c62eb3b645443667b57231caa4bdd821099 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 24 Mar 2011 03:23:30 +0000 Subject: [PATCH 065/261] Pose Menu Tweak: Moved keyframe management items into sub-menu like in Object menu --- release/scripts/startup/bl_ui/space_view3d.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index bbeb76d2cb1..a2ba0948669 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -716,7 +716,6 @@ class VIEW3D_MT_object(bpy.types.Menu): class VIEW3D_MT_object_animation(bpy.types.Menu): - bl_context = "objectmode" bl_label = "Animation" def draw(self, context): @@ -1168,10 +1167,7 @@ class VIEW3D_MT_pose(bpy.types.Menu): layout.separator() - # TODO: make this an "Animation" menu like we have for object? - layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...") - layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...") - layout.operator("anim.keying_set_active_set", text="Change Keying Set...") + layout.menu("VIEW3D_MT_object_animation") layout.separator() From b07f94d87bbb033d1f5f01d13c25856b73afca19 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Mar 2011 03:28:18 +0000 Subject: [PATCH 066/261] tag variable as unused. --- source/blender/editors/armature/poseSlide.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 6fdcb1039f1..e47ec0029a0 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -1028,7 +1028,7 @@ 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 *pfl, FCurve *fcu, float startFrame, float endFrame) +static void pose_propagate_fcurve (wmOperator *op, Object *ob, tPChanFCurveLink *UNUSED(pfl), FCurve *fcu, float startFrame, float endFrame) { const int mode = RNA_enum_get(op->ptr, "mode"); From 0c9488b2f3b14a84b462f5f666c1dc992efca883 Mon Sep 17 00:00:00 2001 From: "M.G. Kishalmi" Date: Thu, 24 Mar 2011 08:33:42 +0000 Subject: [PATCH 067/261] the script is now creating 2 project files: Blender.creator Blender_Python.creator .glsl files have been added to the former latter contains everything .py --- build_files/cmake/cmake_qtcreator_project.py | 55 ++++++++++++++++---- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index a6d6906d26d..5bd1f114770 100644 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -17,15 +17,18 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -# Contributor(s): Campbell Barton +# Contributor(s): Campbell Barton, M.G. Kishalmi # # ***** END GPL LICENSE BLOCK ***** # """ -Exampel Win32 usage: +Example Win32 usage: c:\Python32\python.exe c:\blender_dev\blender\build_files\cmake\cmake_qtcreator_project.py c:\blender_dev\cmake_build + +example linux usage + python .~/blenderSVN/blender/build_files/cmake/cmake_qtcreator_project.py ~/blenderSVN/cmake """ import os @@ -62,6 +65,14 @@ def is_c_header(filename): return (ext in (".h", ".hpp", ".hxx")) +def is_py(filename): + ext = splitext(filename)[1] + return (ext == ".py") + +def is_glsl(filename): + ext = splitext(filename)[1] + return (ext == ".glsl") + def is_c(filename): ext = splitext(filename)[1] return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc")) @@ -78,7 +89,7 @@ def is_svn_file(filename): def is_project_file(filename): - return (is_c_any(filename) or is_cmake(filename)) # and is_svn_file(filename) + return (is_c_any(filename) or is_cmake(filename) or is_glsl(filename)) # and is_svn_file(filename) def cmake_advanced_info(): @@ -105,7 +116,7 @@ def cmake_advanced_info(): if not os.path.exists(os.path.join(cmake_dir, "CMakeCache.txt")): cmake_dir = os.getcwd() if not os.path.exists(os.path.join(cmake_dir, "CMakeCache.txt")): - print("CMakeCache.txt not found in %r or %r\n Pass CMake build dir as an argument, or run from that dir, abording" % (cmake_dir, os.getcwd())) + print("CMakeCache.txt not found in %r or %r\n Pass CMake build dir as an argument, or run from that dir, aborting" % (cmake_dir, os.getcwd())) sys.exit(1) create_eclipse_project(cmake_dir) @@ -154,15 +165,14 @@ def cmake_advanced_info(): return includes, defines - -def main(): +def create_qtc_project_main(): files = list(source_list(base, filename_check=is_project_file)) files_rel = [relpath(f, start=base) for f in files] files_rel.sort() - # --- qtcreator spesific, simple format + # --- qtcreator specific, simple format if SIMPLE_PROJECTFILE: - # --- qtcreator spesific, simple format + # --- qtcreator specific, simple format PROJECT_NAME = "Blender" f = open(join(base, "%s.files" % PROJECT_NAME), 'w') f.write("\n".join(files_rel)) @@ -201,8 +211,35 @@ def main(): f.write("// ADD PREDEFINED MACROS HERE!\n") f.write("\n".join([("#define %s %s" % item) for item in defines])) - print("Project file written to: %s" % qtc_prj) + print("Main Blender project file written to: %s" % qtc_prj) # --- end +def create_qtc_project_python(): + files = list(source_list(base, filename_check=is_py)) + files_rel = [relpath(f, start=base) for f in files] + files_rel.sort() + + # --- qtcreator specific, simple format + PROJECT_NAME = "Blender_Python" + f = open(join(base, "%s.files" % PROJECT_NAME), 'w') + f.write("\n".join(files_rel)) + + qtc_prj = join(base, "%s.creator" % PROJECT_NAME) + f = open(qtc_prj, 'w') + f.write("[General]\n") + + qtc_cfg = join(base, "%s.config" % PROJECT_NAME) + if not exists(qtc_cfg): + f = open(qtc_cfg, 'w') + f.write("// ADD PREDEFINED MACROS HERE!\n") + + print("Blender python project file written to: %s" % qtc_prj) + + +def main(): + create_qtc_project_main() + create_qtc_project_python() + + if __name__ == "__main__": main() From b3d70cbcbab018d1f6e7806fca44ac4524e60e7c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Mar 2011 09:27:41 +0000 Subject: [PATCH 068/261] RNA & interface functions for checking if RNA in a button uses valid rna property (not currently used). --- source/blender/editors/interface/interface.c | 11 ++++++++++ .../editors/interface/interface_intern.h | 1 + source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_access.c | 22 +++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 1fd4b376aff..00b2d922ffc 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1211,6 +1211,17 @@ int ui_is_but_unit(uiBut *but) return 1; } +int ui_is_but_rna_valid(uiBut *but) +{ + if (but->rnaprop==NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) { + return TRUE; + } + else { + printf("property removed %s: %p\n", but->drawstr, but->rnaprop); + return FALSE; + } +} + double ui_get_but_val(uiBut *but) { PropertyRNA *prop; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index a2b876f0412..6cca689d115 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -376,6 +376,7 @@ extern void ui_set_but_soft_range(uiBut *but, double value); extern void ui_check_but(uiBut *but); extern int ui_is_but_float(uiBut *but); extern int ui_is_but_unit(uiBut *but); +extern int ui_is_but_rna_valid(uiBut *but); extern void ui_bounds_block(uiBlock *block); extern void ui_block_translate(uiBlock *block, int x, int y); diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 946bbfece92..076aa199766 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -621,6 +621,7 @@ int RNA_struct_idprops_register_check(StructRNA *type); PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier); +int RNA_struct_contains_property(PointerRNA *ptr, PropertyRNA *prop_test); /* lower level functions for access to type properties */ const struct ListBase *RNA_struct_type_properties(StructRNA *srna); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 0f14c1d85a2..cd243d49fde 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -574,6 +574,28 @@ PropertyRNA *RNA_struct_find_nested(PointerRNA *ptr, StructRNA *srna) return prop; } +int RNA_struct_contains_property(PointerRNA *ptr, PropertyRNA *prop_test) +{ + /* note, prop_test could be freed memory, only use for comparison */ + + /* validate the RNA is ok */ + PropertyRNA *iterprop; + int found= FALSE; + + iterprop= RNA_struct_iterator_property(ptr->type); + + RNA_PROP_BEGIN(ptr, itemptr, iterprop) { + /* PropertyRNA *prop= itemptr.data; */ + if(prop_test == (PropertyRNA *)itemptr.data) { + found= TRUE; + break; + } + } + RNA_PROP_END; + + return found; +} + /* low level direct access to type->properties, note this ignores parent classes so should be used with care */ const struct ListBase *RNA_struct_type_properties(StructRNA *srna) { From 2fcc3628d23acd9179656c4b786b435525f7d00e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 24 Mar 2011 09:53:39 +0000 Subject: [PATCH 069/261] ZanQdo Bugfix: Envelope FModifier data points were getting saved in a non-portable way. Apparently this broke when trying to read files with this data on PPC machines if the files were saved using Intel machines. --- source/blender/blenloader/intern/writefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index a32d6038f7e..50968cb2a54 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -468,7 +468,7 @@ static void write_fmodifiers(WriteData *wd, ListBase *fmodifiers) /* write envelope data */ if (data->data) - writedata(wd, DATA, sizeof(FCM_EnvelopeData)*(data->totvert), data->data); + writestruct(wd, DATA, "FCM_EnvelopeData", data->totvert, data->data); } break; case FMODIFIER_TYPE_PYTHON: From 3ebb9676c11b6d0c7855936bc7765dd8e561228d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Mar 2011 09:59:02 +0000 Subject: [PATCH 070/261] fix for incorrect array use when freeing fcurve modifier envelope points, array also wasnt NULL'd on freeing which gave memory errors later on. --- source/blender/editors/animation/fmodifier_ui.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 390b9f840cb..d14ebc2c7bb 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -443,9 +443,9 @@ static void fmod_envelope_deletepoint_cb (bContext *UNUSED(C), void *fcm_dv, voi if (env->totvert > 1) { /* allocate a new smaller array */ fedn= MEM_callocN(sizeof(FCM_EnvelopeData)*(env->totvert-1), "FCM_EnvelopeData"); - - memcpy(fedn, &env->data, sizeof(FCM_EnvelopeData)*(index)); - memcpy(&fedn[index], &env->data[index+1], sizeof(FCM_EnvelopeData)*(env->totvert-index-1)); + + memcpy(fedn, env->data, sizeof(FCM_EnvelopeData)*(index)); + memcpy(fedn + index, env->data + (index + 1), sizeof(FCM_EnvelopeData)*((env->totvert - index)-1)); /* free old array, and set the new */ MEM_freeN(env->data); @@ -454,8 +454,10 @@ static void fmod_envelope_deletepoint_cb (bContext *UNUSED(C), void *fcm_dv, voi } else { /* just free array, since the only vert was deleted */ - if (env->data) + if (env->data) { MEM_freeN(env->data); + env->data= NULL; + } env->totvert= 0; } } From 19819dcbc776b8cc17ade1654a8dba396094cf1e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Mar 2011 10:54:42 +0000 Subject: [PATCH 071/261] write project files into the build dir. --- build_files/cmake/cmake_qtcreator_project.py | 79 ++++++++++++-------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index 5bd1f114770..a8687e34be1 100644 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -26,11 +26,12 @@ """ Example Win32 usage: c:\Python32\python.exe c:\blender_dev\blender\build_files\cmake\cmake_qtcreator_project.py c:\blender_dev\cmake_build - + example linux usage python .~/blenderSVN/blender/build_files/cmake/cmake_qtcreator_project.py ~/blenderSVN/cmake """ +import sys import os from os.path import join, dirname, normpath, abspath, splitext, relpath, exists @@ -40,6 +41,20 @@ base = abspath(base) SIMPLE_PROJECTFILE = False +# get cmake path +CMAKE_DIR = sys.argv[-1] + +if not os.path.exists(os.path.join(CMAKE_DIR, "CMakeCache.txt")): + CMAKE_DIR = os.getcwd() +if not os.path.exists(os.path.join(CMAKE_DIR, "CMakeCache.txt")): + print("CMakeCache.txt not found in %r or %r\n Pass CMake build dir as an argument, or run from that dir, aborting" % (CMAKE_DIR, os.getcwd())) + sys.exit(1) + + +# could be either. +# PROJECT_DIR = base +PROJECT_DIR = CMAKE_DIR + def source_list(path, filename_check=None): for dirpath, dirnames, filenames in os.walk(path): @@ -69,10 +84,12 @@ def is_py(filename): ext = splitext(filename)[1] return (ext == ".py") + def is_glsl(filename): ext = splitext(filename)[1] return (ext == ".glsl") - + + def is_c(filename): ext = splitext(filename)[1] return (ext in (".c", ".cpp", ".cxx", ".m", ".mm", ".rc")) @@ -96,12 +113,12 @@ def cmake_advanced_info(): """ Extracr includes and defines from cmake. """ - def create_eclipse_project(cmake_dir): + def create_eclipse_project(CMAKE_DIR): import sys if sys.platform == "win32": - cmd = 'cmake %r -G"Eclipse CDT4 - MinGW Makefiles"' % cmake_dir + cmd = 'cmake %r -G"Eclipse CDT4 - MinGW Makefiles"' % CMAKE_DIR else: - cmd = 'cmake %r -G"Eclipse CDT4 - Unix Makefiles"' % cmake_dir + cmd = 'cmake %r -G"Eclipse CDT4 - Unix Makefiles"' % CMAKE_DIR os.system(cmd) @@ -111,18 +128,10 @@ def cmake_advanced_info(): import os import sys - cmake_dir = sys.argv[-1] - - if not os.path.exists(os.path.join(cmake_dir, "CMakeCache.txt")): - cmake_dir = os.getcwd() - if not os.path.exists(os.path.join(cmake_dir, "CMakeCache.txt")): - print("CMakeCache.txt not found in %r or %r\n Pass CMake build dir as an argument, or run from that dir, aborting" % (cmake_dir, os.getcwd())) - sys.exit(1) - - create_eclipse_project(cmake_dir) + create_eclipse_project(CMAKE_DIR) from xml.dom.minidom import parse - tree = parse(os.path.join(cmake_dir, ".cproject")) + tree = parse(os.path.join(CMAKE_DIR, ".cproject")) ''' f = open(".cproject_pretty", 'w') f.write(tree.toprettyxml(indent=" ", newl="")) @@ -165,26 +174,27 @@ def cmake_advanced_info(): return includes, defines + def create_qtc_project_main(): files = list(source_list(base, filename_check=is_project_file)) - files_rel = [relpath(f, start=base) for f in files] + files_rel = [relpath(f, start=PROJECT_DIR) for f in files] files_rel.sort() # --- qtcreator specific, simple format if SIMPLE_PROJECTFILE: # --- qtcreator specific, simple format PROJECT_NAME = "Blender" - f = open(join(base, "%s.files" % PROJECT_NAME), 'w') + f = open(join(PROJECT_DIR, "%s.files" % PROJECT_NAME), 'w') f.write("\n".join(files_rel)) - f = open(join(base, "%s.includes" % PROJECT_NAME), 'w') + f = open(join(PROJECT_DIR, "%s.includes" % PROJECT_NAME), 'w') f.write("\n".join(sorted(list(set(dirname(f) for f in files_rel if is_c_header(f)))))) - qtc_prj = join(base, "%s.creator" % PROJECT_NAME) + qtc_prj = join(PROJECT_DIR, "%s.creator" % PROJECT_NAME) f = open(qtc_prj, 'w') f.write("[General]\n") - qtc_cfg = join(base, "%s.config" % PROJECT_NAME) + qtc_cfg = join(PROJECT_DIR, "%s.config" % PROJECT_NAME) if not exists(qtc_cfg): f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") @@ -196,44 +206,47 @@ def create_qtc_project_main(): includes.sort() PROJECT_NAME = "Blender" - f = open(join(base, "%s.files" % PROJECT_NAME), 'w') + FILE_NAME = PROJECT_NAME.lower() + f = open(join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w') f.write("\n".join(files_rel)) - f = open(join(base, "%s.includes" % PROJECT_NAME), 'w') + f = open(join(PROJECT_DIR, "%s.includes" % FILE_NAME), 'w') f.write("\n".join(sorted(includes))) - qtc_prj = join(base, "%s.creator" % PROJECT_NAME) + qtc_prj = join(PROJECT_DIR, "%s.creator" % FILE_NAME) f = open(qtc_prj, 'w') f.write("[General]\n") - qtc_cfg = join(base, "%s.config" % PROJECT_NAME) + qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME) f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") f.write("\n".join([("#define %s %s" % item) for item in defines])) - print("Main Blender project file written to: %s" % qtc_prj) + print("Blender project file written to: %s" % qtc_prj) # --- end + def create_qtc_project_python(): files = list(source_list(base, filename_check=is_py)) - files_rel = [relpath(f, start=base) for f in files] + files_rel = [relpath(f, start=PROJECT_DIR) for f in files] files_rel.sort() # --- qtcreator specific, simple format PROJECT_NAME = "Blender_Python" - f = open(join(base, "%s.files" % PROJECT_NAME), 'w') + FILE_NAME = PROJECT_NAME.lower() + f = open(join(PROJECT_DIR, "%s.files" % FILE_NAME), 'w') f.write("\n".join(files_rel)) - - qtc_prj = join(base, "%s.creator" % PROJECT_NAME) + + qtc_prj = join(PROJECT_DIR, "%s.creator" % FILE_NAME) f = open(qtc_prj, 'w') f.write("[General]\n") - - qtc_cfg = join(base, "%s.config" % PROJECT_NAME) + + qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME) if not exists(qtc_cfg): f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") - - print("Blender python project file written to: %s" % qtc_prj) + + print("Python project file written to: %s" % qtc_prj) def main(): From 7735eccc54970262696f9603f6a88ce6d77eee50 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Mar 2011 11:38:20 +0000 Subject: [PATCH 072/261] fix [#26545] Crash when changing values for properties after changing max-min tried doing this smarter by validating the property exists in UI code before access but this ended up making it too complicated and also hard to account for possible access without checking every time. for now just redraw all areas when a user property is changed. --- release/scripts/startup/bl_operators/wm.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 5d222168046..df51af25b02 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -772,7 +772,10 @@ class WM_OT_properties_edit(bpy.types.Operator): # otherwise existing buttons which reference freed # memory may crash blender [#26510] - context.area.tag_redraw() + # context.area.tag_redraw() + for win in context.window_manager.windows: + for area in win.screen.areas: + area.tag_redraw() return {'FINISHED'} @@ -918,4 +921,4 @@ def _webbrowser_bug_fix(): return not p.wait() import webbrowser - webbrowser.UnixBrowser._invoke = _invoke \ No newline at end of file + webbrowser.UnixBrowser._invoke = _invoke From c2ee06a4b2bf5618930d38b646c82ae91abb4b65 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 24 Mar 2011 12:12:54 +0000 Subject: [PATCH 073/261] Particle charge effector wasn't working properly. * Probably just forgot this code somewhere a long time ago. --- source/blender/blenkernel/intern/effect.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index f07dd0bc5f4..216dffc1e4a 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -361,12 +361,18 @@ void pdEndEffectors(ListBase **effectors) void pd_point_from_particle(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, EffectedPoint *point) { + ParticleSettings *part = sim->psys->part; point->loc = state->co; point->vel = state->vel; point->index = pa - sim->psys->particles; point->size = pa->size; - /* TODO: point->charge */ - point->charge = 1.0f; + point->charge = 0.0f; + + if(part->pd && part->pd->forcefield == PFIELD_CHARGE) + point->charge += part->pd->f_strength; + + if(part->pd2 && part->pd2->forcefield == PFIELD_CHARGE) + point->charge += part->pd2->f_strength; point->vel_to_sec = 1.0f; point->vel_to_frame = psys_get_timestep(sim); From da4023b6554b237fe04debf05000bba37408ad3e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Mar 2011 12:17:24 +0000 Subject: [PATCH 074/261] fix [#26598] zoom view and scaling odd vertices circle --- source/blender/editors/transform/transform_input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index be2e1404730..e8d82fb211c 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -92,8 +92,9 @@ static void InputSpringFlip(TransInfo *t, MouseInput *mi, short mval[2], float o InputSpring(t, mi, mval, output); /* flip scale */ - if ((mi->center[0] - mval[0]) * (mi->center[0] - mi->imval[0]) + - (mi->center[1] - mval[1]) * (mi->center[1] - mi->imval[1]) < 0) + /* values can become really big when zoomed in so use longs [#26598] */ + if ((long long int)(mi->center[0] - mval[0]) * (long long int)(mi->center[0] - mi->imval[0]) + + (long long int)(mi->center[1] - mval[1]) * (long long int)(mi->center[1] - mi->imval[1]) < 0) { output[0] *= -1.0f; } From 422f1674bb84e8f96629e8c70e90339696af68fb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 24 Mar 2011 12:36:12 +0000 Subject: [PATCH 075/261] fix for using uiItemIntO for an enum, added uiItemEnumO_value function. --- source/blender/editors/animation/keyingsets.c | 2 +- source/blender/editors/include/UI_interface.h | 1 + .../editors/interface/interface_layout.c | 27 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 324e9e39fc4..04565b4c236 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -795,7 +795,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op for (ks= builtin_keyingsets.first; ks; ks= ks->next) { /* only show KeyingSet if context is suitable */ if (ANIM_keyingset_context_ok_poll(C, ks)) - uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i--); + uiItemEnumO_value(layout, ks->name, ICON_NONE, op_name, "type", i--); } uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index e938192c5aa..e0f34410673 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -720,6 +720,7 @@ void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr /* items */ void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname); void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value); +void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value); void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname); void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 1e94824a9f9..c94c3a7813a 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -781,6 +781,33 @@ void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) } /* for use in cases where we have */ +void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) +{ + PointerRNA ptr; + + /* for getting the enum */ + PropertyRNA *prop; + + WM_operator_properties_create(&ptr, opname); + + /* enum lookup */ + if((prop= RNA_struct_find_property(&ptr, propname))) { + /* pass */ + } + else { + printf("uiItemEnumO_value: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname); + return; + } + + RNA_property_enum_set(&ptr, prop, value); + + /* same as uiItemEnumO */ + if(!name) + name= ui_menu_enumpropname(layout, opname, propname, value); + + uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); +} + void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value_str) { PointerRNA ptr; From d5e839d2abc830e2a2dd237b82bbb84873df3d88 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 24 Mar 2011 14:19:12 +0000 Subject: [PATCH 076/261] Bug fix: Fluidsim didn't take parent objects into account when calculating the inflow velocity in local coordinates. * The object rotation was based on ob->rot (which only includes object's own rotation) instead of ob->obmat, which includes parent rotations as well. --- source/blender/editors/physics/physics_fluid.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 4ac794ed620..210b2480d85 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -449,8 +449,9 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid continue; /* init euler rotation values and convert to elbeem format */ - BKE_rotMode_change_values(ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, ROT_MODE_EUL); - mul_v3_v3fl(rot_d, ob->rot, 180.f/M_PI); + /* get the rotation from ob->obmat rather than ob->rot to account for parent animations */ + mat4_to_eul(rot_d, ob->obmat); + mul_v3_fl(rot_d, 180.f/M_PI); sub_v3_v3v3(rot_d, rot_360, rot_d); set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC); From db421408ce3eb21be3e04cae3e1c987e9b747311 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 24 Mar 2011 14:31:58 +0000 Subject: [PATCH 077/261] Bugfix #26584 - Colormanagement code was gamma correcting non-RGBA buffers in composite. (Like vector buffers). - Crash on using "use Color Management" button during composites, because it was freeing all node images. Added code to stop first jobs before freeing. It sends notifier for recomposites after free anyway. --- source/blender/makesrna/intern/rna_scene.c | 4 ++++ source/blender/nodes/intern/CMP_nodes/CMP_image.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 812e991831b..e00ceeafd99 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -54,6 +54,7 @@ #include #endif +#include "WM_api.h" #include "WM_types.h" #include "BLI_threads.h" @@ -754,6 +755,9 @@ static void rna_RenderSettings_color_management_update(Main *bmain, Scene *unuse bNode *node; if(ntree && scene->use_nodes) { + /* XXX images are freed here, stop render and preview threads, until Image is threadsafe */ + WM_jobs_stop_all(bmain->wm.first); + for (node=ntree->nodes.first; node; node=node->next) { if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_IMAGE)) { ED_node_changed_update(&scene->id, node); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_image.c b/source/blender/nodes/intern/CMP_nodes/CMP_image.c index a7be5ac6f8a..1ea3cf96ad0 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_image.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_image.c @@ -80,9 +80,9 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i IMB_float_from_rect(ibuf); } - /* now we need a float buffer from the image - * with matching color management */ - if(ibuf->channels == 4) { + /* now we need a float buffer from the image with matching color management */ + /* XXX weak code, multilayer is excluded from this */ + if(ibuf->channels == 4 && ima->rr==NULL) { if(rd->color_mgt_flag & R_COLOR_MANAGEMENT) { if(ibuf->profile != IB_PROFILE_NONE) { rect= ibuf->rect_float; From 3e9293f1a1821336cd1f8e784793d021b52145b7 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 24 Mar 2011 17:15:43 +0000 Subject: [PATCH 078/261] Further fix for parented fluidsim objects * The rotation values determined from ob->obmat have to be continuous as fluidsim interpolates between these values internally. --- .../blender/editors/physics/physics_fluid.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 210b2480d85..67d2184dc69 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -349,6 +349,16 @@ static void free_all_fluidobject_channels(ListBase *fobjects) } } +static void continuous_rotation(float *rot, const float *old_rot) +{ + *rot += (int)(*old_rot/360.f)*360.f; + + if(*old_rot - *rot > 180.f) + *rot += 360.f; + else if(*old_rot - *rot < -180.f) + *rot -= 360.f; +} + static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), FluidsimSettings *domainSettings, FluidAnimChannels *channels, ListBase *fobjects) { Scene *scene = CTX_data_scene(C); @@ -451,8 +461,14 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid /* init euler rotation values and convert to elbeem format */ /* get the rotation from ob->obmat rather than ob->rot to account for parent animations */ mat4_to_eul(rot_d, ob->obmat); - mul_v3_fl(rot_d, 180.f/M_PI); - sub_v3_v3v3(rot_d, rot_360, rot_d); + mul_v3_fl(rot_d, -180.f/M_PI); + if(i) { + /* the rotation values have to be continuous, so compare with previous rotation and adjust accordingly */ + /* note: the unfortunate side effect of this is that it filters out rotations of over 180 degrees/frame */ + continuous_rotation(rot_d, fobj->Rotation + 4*(i-1)); + continuous_rotation(rot_d+1, fobj->Rotation + 4*(i-1)+1); + continuous_rotation(rot_d+2, fobj->Rotation + 4*(i-1)+2); + } set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC); set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC); From dee8ba8ba18766b15d427c0daa8e50097d3c26e9 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 24 Mar 2011 17:17:44 +0000 Subject: [PATCH 079/261] UI clarification: "local coordinates" option for fluid inflow objects doesn't have any effect when "export animated mesh" is selected * Grayed out the "local coordinates" option in this case to avoid confusion. --- release/scripts/startup/bl_ui/properties_physics_fluid.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index 53eb67e1340..dac8fe9195f 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -123,7 +123,9 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, bpy.types.Panel): col.label(text="Volume Initialization:") col.prop(fluid, "volume_initialization", text="") col.prop(fluid, "use_animated_mesh") - col.prop(fluid, "use_local_coords") + row = col.row() + row.active = not fluid.use_animated_mesh + row.prop(fluid, "use_local_coords") col = split.column() col.label(text="Inflow Velocity:") From 22ea604c6f877f36747b9e07b0459ee20cf6b0e5 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 24 Mar 2011 18:39:54 +0000 Subject: [PATCH 080/261] Bugfix 26578 "Warp" texture map option didnt work for new bump methods yet. Also fixed to not grey out bump menu for this mapping option. --- release/scripts/startup/bl_ui/properties_texture.py | 2 +- .../blender/render/intern/source/render_texture.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 7e289f1ecce..f6fa86d64aa 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -1015,7 +1015,7 @@ class TEXTURE_PT_influence(TextureSlotPanel, bpy.types.Panel): # only show bump settings if activated but not for normalmap images row = layout.row() - row.active = tex.use_map_normal and not (tex.texture.type == 'IMAGE' and tex.texture.use_normal_map) + row.active = (tex.use_map_normal or tex.use_map_warp) and not (tex.texture.type == 'IMAGE' and tex.texture.use_normal_map) row.prop(tex, "bump_method", text="Method") diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index acc69680487..2b98e7a3f96 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -2339,9 +2339,16 @@ void do_material_tex(ShadeInput *shi) } // warping, local space if(mtex->mapto & MAP_WARP) { - warpvec[0]= mtex->warpfac*texres.nor[0]; - warpvec[1]= mtex->warpfac*texres.nor[1]; - warpvec[2]= mtex->warpfac*texres.nor[2]; + float *warpnor= texres.nor, warpnor_[3]; + + if(use_ntap_bump) { + VECCOPY(warpnor_, texres.nor); + warpnor= warpnor_; + normalize_v3(warpnor_); + } + warpvec[0]= mtex->warpfac*warpnor[0]; + warpvec[1]= mtex->warpfac*warpnor[1]; + warpvec[2]= mtex->warpfac*warpnor[2]; warpdone= 1; } #if 0 From 70d7884792e883f8d7093b6c74e9d9936084884f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 24 Mar 2011 21:07:54 +0000 Subject: [PATCH 081/261] Logic Editor UI: sensor frequency active only when one of the triggers is on. Removing text "Action" from Action and Shape Action Actuators. I still would love to see a change in the action actuators (Action, Shape and FCurve) even if only a rename or unifying them in a single actuator (I do have some patch for that). Anyways --- source/blender/editors/space_logic/logic_window.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index ae4303f91a4..8cbe56c852f 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3228,7 +3228,7 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) { - uiLayout *box, *split, *row; + uiLayout *box, *split, *subrow, *row; box= uiLayoutBox(layout); split = uiLayoutSplit(box, 0.45, 0); @@ -3236,7 +3236,11 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) row= uiLayoutRow(split, 1); uiItemR(row, ptr, "use_pulse_true_level", 0, "", ICON_DOTSUP); uiItemR(row, ptr, "use_pulse_false_level", 0, "", ICON_DOTSDOWN); - uiItemR(row, ptr, "frequency", 0, "Freq", ICON_NONE); + + subrow=uiLayoutRow(row, 0); + uiLayoutSetActive(subrow, (RNA_boolean_get(ptr, "use_pulse_true_level") + || RNA_boolean_get(ptr, "use_pulse_false_level"))); + uiItemR(subrow, ptr, "frequency", 0, "Freq", ICON_NONE); row= uiLayoutRow(split, 1); uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -3683,7 +3687,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "play_mode", 0, "", ICON_NONE); - uiItemR(row, ptr, "action", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "action", 0, "", ICON_NONE); uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); row= uiLayoutRow(layout, 0); @@ -4275,7 +4279,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "mode", 0, "", ICON_NONE); - uiItemR(row, ptr, "action", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "action", 0, "", ICON_NONE); uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); row= uiLayoutRow(layout, 0); From 561b6e34f05d6714d2ed294040a6c4947d943da3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 24 Mar 2011 23:34:43 +0000 Subject: [PATCH 082/261] Bugfix: [#25725] Transform bone constraint & 'local with parent' as owners space [#26014] ChildOf Bone Constrain (influence) works in wrong workspace Moved the influence calculation stuff outside of the space conversions (i.e. so that it is done in worldspace only) fixes these problems, which seem to arise when a constraint doesn't work in worldspace AND doesn't need to apply inverse correct for this space conversion when it's done, hence resulting in mismatch between spaces for old and new matrices resulting in all the weird behaviour. Patch to fix this from Jahka. Cheers! --- source/blender/blenkernel/intern/constraint.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index ba5b7e3ae4a..9f646a93b6a 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4465,9 +4465,11 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) */ enf = con->enforce; + /* make copy of worldspace matrix pre-constraint for use with blending later */ + copy_m4_m4(oldmat, cob->matrix); + /* move owner matrix into right space */ constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, CONSTRAINT_SPACE_WORLD, con->ownspace); - copy_m4_m4(oldmat, cob->matrix); /* prepare targets for constraint solving */ if (cti->get_constraint_targets) { @@ -4503,16 +4505,20 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) cti->flush_constraint_targets(con, &targets, 1); } - /* Interpolate the enforcement, to blend result of constraint into final owner transform */ + /* move owner back into worldspace for next constraint/other business */ + if ((con->flag & CONSTRAINT_SPACEONCE) == 0) + constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD); + + /* Interpolate the enforcement, to blend result of constraint into final owner transform + * - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]), + * since some constraints may not convert the solution back to the input space before blending + * but all are guaranteed to end up in good "worldspace" result + */ /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */ if (enf < 1.0) { float solution[4][4]; copy_m4_m4(solution, cob->matrix); blend_m4_m4m4(cob->matrix, oldmat, solution, enf); } - - /* move owner back into worldspace for next constraint/other business */ - if ((con->flag & CONSTRAINT_SPACEONCE) == 0) - constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD); } } From 737ca9ad5fa11ce188c8c3f6508e6f33180b0d16 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 00:23:02 +0000 Subject: [PATCH 083/261] BGE player was using un-initialized variables for initializing the canvas color. --- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 597cec17c61..0c47b0d01bf 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -124,16 +124,16 @@ bool RAS_OpenGLRasterizer::Init() glFrontFace(GL_CCW); m_last_frontface = true; - glClearColor(m_redback,m_greenback,m_blueback,m_alphaback); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - m_redback = 0.4375; m_greenback = 0.4375; m_blueback = 0.4375; m_alphaback = 0.0; + glClearColor(m_redback,m_greenback,m_blueback,m_alphaback); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glShadeModel(GL_SMOOTH); return true; From fcc5b5c48c127b0b4567434e8ce5c30dc91ae1e3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 00:34:28 +0000 Subject: [PATCH 084/261] fix for blenderplayer using un-initialized mathutils types. --- source/gameengine/Ketsji/KX_PythonInit.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index d274b3e4eac..0be0fa3c7dc 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1918,7 +1918,7 @@ static void restorePySysObjects(void) } // Copied from bpy_interface.c -static struct _inittab bpy_internal_modules[]= { +static struct _inittab bge_internal_modules[]= { {"mathutils", BPyInit_mathutils}, {"bgl", BPyInit_bgl}, {"blf", BPyInit_blf}, @@ -1945,6 +1945,10 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur #endif Py_NoSiteFlag=1; Py_FrozenFlag=1; + + /* must run before python initializes */ + PyImport_ExtendInittab(bge_internal_modules); + Py_Initialize(); if(argv && first_time) { /* browser plugins dont currently set this */ @@ -1961,13 +1965,18 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur } setSandbox(level); + + /* mathutils types are used by the BGE even if we dont import them */ + { + PyObject *mod= PyImport_ImportModuleLevel((char *)"mathutils", NULL, NULL, NULL, 0); + Py_DECREF(mod); + } + initPyTypes(); bpy_import_main_set(maggie); initPySysObjects(maggie); - - PyImport_ExtendInittab(bpy_internal_modules); first_time = false; From b5100196021d12129c0d7e80be7e202c319ea120 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 01:55:00 +0000 Subject: [PATCH 085/261] fix for incorrect prints with RNA errors (own fault, CONTAINER_RNA_ID was incorrect) & close keymap file after running. --- release/scripts/modules/bpy/utils.py | 4 +++- source/blender/makesrna/intern/rna_internal_types.h | 2 +- source/blender/python/intern/bpy_interface.c | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 28e6ee991de..a8f5925f467 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -352,7 +352,9 @@ def keyconfig_set(filepath): keyconfigs_old = keyconfigs[:] try: - exec(compile(open(filepath).read(), filepath, 'exec'), {"__file__": filepath}) + file = open(filepath) + exec(compile(file.read(), filepath, 'exec'), {"__file__": filepath}) + file.close() except: import traceback traceback.print_exc() diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index ce7ee030906..eb1beb90567 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -346,6 +346,6 @@ struct BlenderRNA { ListBase structs; }; -#define CONTAINER_RNA_ID(cont) (const char *)(((ContainerRNA *)(cont))+1) +#define CONTAINER_RNA_ID(cont) (*(const char **)(((ContainerRNA *)(cont))+1)) #endif /* RNA_INTERNAL_TYPES_H */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index fb598c1ac30..8833079d742 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -235,7 +235,7 @@ void BPY_python_start(int argc, const char **argv) utf8towchar(bprogname_wchar, bprogname); Py_SetProgramName(bprogname_wchar); - /* builtin modules */ + /* must run before python initializes */ PyImport_ExtendInittab(bpy_internal_modules); bpy_python_start_path(); /* allow to use our own included python */ @@ -264,7 +264,8 @@ void BPY_python_start(int argc, const char **argv) #else (void)argc; (void)argv; - + + /* must run before python initializes */ PyImport_ExtendInittab(bpy_internal_modules); #endif From 0c03fa78c10f04283512f2a5a4557d86c72d6f29 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 02:12:44 +0000 Subject: [PATCH 086/261] fix [#26601] Python error when use of autocomplete Was a naming collision with 'keys' python method, reserve keys/items/values/get for python. Updated animsys_update.py for shapekey data paths. renamed: Particle.hair --> hair_keys Particle.keys --> particle_keys Key.keys --> key_blocks EnumProperty.items --> enum_items KeyMap.items --> keymap_items noted: http://wiki.blender.org/index.php/Dev:2.5/Py/API/Updates#Since_2.56a --- release/scripts/modules/rna_info.py | 2 +- release/scripts/presets/keyconfig/maya.py | 434 +++++++++--------- .../startup/bl_operators/animsys_update.py | 1 + .../scripts/startup/bl_operators/object.py | 8 +- .../startup/bl_ui/properties_data_mesh.py | 4 +- .../startup/bl_ui/properties_physics_cloth.py | 2 +- release/scripts/startup/bl_ui/space_info.py | 2 +- .../startup/bl_ui/space_userpref_keymap.py | 34 +- source/blender/makesrna/intern/rna_define.c | 15 + source/blender/makesrna/intern/rna_key.c | 12 +- source/blender/makesrna/intern/rna_particle.c | 4 +- source/blender/makesrna/intern/rna_rna.c | 2 +- source/blender/makesrna/intern/rna_wm.c | 3 +- 13 files changed, 270 insertions(+), 253 deletions(-) diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index 74df544b679..93a344f4b09 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -207,7 +207,7 @@ class InfoPropertyRNA: self.fixed_type = None if self.type == "enum": - self.enum_items[:] = rna_prop.items.keys() + self.enum_items[:] = rna_prop.enum_items.keys() self.is_enum_flag = rna_prop.is_enum_flag else: self.is_enum_flag = False diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index 120597cdd2a..4014920698d 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -7,372 +7,372 @@ kc = wm.keyconfigs.new('maya') # Map 3D View km = kc.keymaps.new('3D View', space_type='VIEW_3D', region_type='WINDOW', modal=False) -kmi = km.items.new('view3d.manipulator', 'LEFTMOUSE', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.manipulator', 'LEFTMOUSE', 'PRESS', any=True) kmi.properties.release_confirm = True -kmi = km.items.new('view3d.cursor3d', 'ACTIONMOUSE', 'PRESS') -kmi = km.items.new('view3d.rotate', 'LEFTMOUSE', 'PRESS', alt=True) -kmi = km.items.new('view3d.move', 'MIDDLEMOUSE', 'PRESS', alt=True) -kmi = km.items.new('view3d.zoom', 'RIGHTMOUSE', 'PRESS', alt=True) -kmi = km.items.new('view3d.view_selected', 'NUMPAD_PERIOD', 'PRESS') -kmi = km.items.new('view3d.view_center_cursor', 'NUMPAD_PERIOD', 'PRESS', ctrl=True) -kmi = km.items.new('view3d.fly', 'F', 'PRESS', shift=True) -kmi = km.items.new('view3d.smoothview', 'TIMER1', 'ANY', any=True) -kmi = km.items.new('view3d.rotate', 'TRACKPADPAN', 'ANY', alt=True) -kmi = km.items.new('view3d.rotate', 'MOUSEROTATE', 'ANY') -kmi = km.items.new('view3d.move', 'TRACKPADPAN', 'ANY') -kmi = km.items.new('view3d.zoom', 'TRACKPADZOOM', 'ANY') -kmi = km.items.new('view3d.zoom', 'NUMPAD_PLUS', 'PRESS') +kmi = km.keymap_items.new('view3d.cursor3d', 'ACTIONMOUSE', 'PRESS') +kmi = km.keymap_items.new('view3d.rotate', 'LEFTMOUSE', 'PRESS', alt=True) +kmi = km.keymap_items.new('view3d.move', 'MIDDLEMOUSE', 'PRESS', alt=True) +kmi = km.keymap_items.new('view3d.zoom', 'RIGHTMOUSE', 'PRESS', alt=True) +kmi = km.keymap_items.new('view3d.view_selected', 'NUMPAD_PERIOD', 'PRESS') +kmi = km.keymap_items.new('view3d.view_center_cursor', 'NUMPAD_PERIOD', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.fly', 'F', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.smoothview', 'TIMER1', 'ANY', any=True) +kmi = km.keymap_items.new('view3d.rotate', 'TRACKPADPAN', 'ANY', alt=True) +kmi = km.keymap_items.new('view3d.rotate', 'MOUSEROTATE', 'ANY') +kmi = km.keymap_items.new('view3d.move', 'TRACKPADPAN', 'ANY') +kmi = km.keymap_items.new('view3d.zoom', 'TRACKPADZOOM', 'ANY') +kmi = km.keymap_items.new('view3d.zoom', 'NUMPAD_PLUS', 'PRESS') kmi.properties.delta = 1 -kmi = km.items.new('view3d.zoom', 'NUMPAD_MINUS', 'PRESS') +kmi = km.keymap_items.new('view3d.zoom', 'NUMPAD_MINUS', 'PRESS') kmi.properties.delta = -1 -kmi = km.items.new('view3d.zoom', 'EQUAL', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.zoom', 'EQUAL', 'PRESS', ctrl=True) kmi.properties.delta = 1 -kmi = km.items.new('view3d.zoom', 'MINUS', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.zoom', 'MINUS', 'PRESS', ctrl=True) kmi.properties.delta = -1 -kmi = km.items.new('view3d.zoom', 'WHEELINMOUSE', 'PRESS') +kmi = km.keymap_items.new('view3d.zoom', 'WHEELINMOUSE', 'PRESS') kmi.properties.delta = 1 -kmi = km.items.new('view3d.zoom', 'WHEELOUTMOUSE', 'PRESS') +kmi = km.keymap_items.new('view3d.zoom', 'WHEELOUTMOUSE', 'PRESS') kmi.properties.delta = -1 -kmi = km.items.new('view3d.view_all', 'HOME', 'PRESS') +kmi = km.keymap_items.new('view3d.view_all', 'HOME', 'PRESS') kmi.properties.center = False -kmi = km.items.new('view3d.view_all', 'C', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.view_all', 'C', 'PRESS', shift=True) kmi.properties.center = True -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_0', 'PRESS') +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_0', 'PRESS') kmi.properties.type = 'CAMERA' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS') +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS') kmi.properties.type = 'FRONT' -kmi = km.items.new('view3d.view_orbit', 'NUMPAD_2', 'PRESS') +kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_2', 'PRESS') kmi.properties.type = 'ORBITDOWN' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS') +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS') kmi.properties.type = 'RIGHT' -kmi = km.items.new('view3d.view_orbit', 'NUMPAD_4', 'PRESS') +kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_4', 'PRESS') kmi.properties.type = 'ORBITLEFT' -kmi = km.items.new('view3d.view_persportho', 'NUMPAD_5', 'PRESS') -kmi = km.items.new('view3d.view_orbit', 'NUMPAD_6', 'PRESS') +kmi = km.keymap_items.new('view3d.view_persportho', 'NUMPAD_5', 'PRESS') +kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_6', 'PRESS') kmi.properties.type = 'ORBITRIGHT' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS') +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS') kmi.properties.type = 'TOP' -kmi = km.items.new('view3d.view_orbit', 'NUMPAD_8', 'PRESS') +kmi = km.keymap_items.new('view3d.view_orbit', 'NUMPAD_8', 'PRESS') kmi.properties.type = 'ORBITUP' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', ctrl=True) kmi.properties.type = 'BACK' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', ctrl=True) kmi.properties.type = 'LEFT' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', ctrl=True) kmi.properties.type = 'BOTTOM' -kmi = km.items.new('view3d.view_pan', 'NUMPAD_2', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_2', 'PRESS', ctrl=True) kmi.properties.type = 'PANDOWN' -kmi = km.items.new('view3d.view_pan', 'NUMPAD_4', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_4', 'PRESS', ctrl=True) kmi.properties.type = 'PANLEFT' -kmi = km.items.new('view3d.view_pan', 'NUMPAD_6', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_6', 'PRESS', ctrl=True) kmi.properties.type = 'PANRIGHT' -kmi = km.items.new('view3d.view_pan', 'NUMPAD_8', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.view_pan', 'NUMPAD_8', 'PRESS', ctrl=True) kmi.properties.type = 'PANUP' -kmi = km.items.new('view3d.view_pan', 'WHEELUPMOUSE', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.view_pan', 'WHEELUPMOUSE', 'PRESS', ctrl=True) kmi.properties.type = 'PANRIGHT' -kmi = km.items.new('view3d.view_pan', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.view_pan', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True) kmi.properties.type = 'PANLEFT' -kmi = km.items.new('view3d.view_pan', 'WHEELUPMOUSE', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.view_pan', 'WHEELUPMOUSE', 'PRESS', shift=True) kmi.properties.type = 'PANUP' -kmi = km.items.new('view3d.view_pan', 'WHEELDOWNMOUSE', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.view_pan', 'WHEELDOWNMOUSE', 'PRESS', shift=True) kmi.properties.type = 'PANDOWN' -kmi = km.items.new('view3d.view_orbit', 'WHEELUPMOUSE', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELUPMOUSE', 'PRESS', ctrl=True, alt=True) kmi.properties.type = 'ORBITLEFT' -kmi = km.items.new('view3d.view_orbit', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELDOWNMOUSE', 'PRESS', ctrl=True, alt=True) kmi.properties.type = 'ORBITRIGHT' -kmi = km.items.new('view3d.view_orbit', 'WHEELUPMOUSE', 'PRESS', shift=True, alt=True) +kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELUPMOUSE', 'PRESS', shift=True, alt=True) kmi.properties.type = 'ORBITUP' -kmi = km.items.new('view3d.view_orbit', 'WHEELDOWNMOUSE', 'PRESS', shift=True, alt=True) +kmi = km.keymap_items.new('view3d.view_orbit', 'WHEELDOWNMOUSE', 'PRESS', shift=True, alt=True) kmi.properties.type = 'ORBITDOWN' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', shift=True) kmi.properties.align_active = True kmi.properties.type = 'FRONT' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', shift=True) kmi.properties.align_active = True kmi.properties.type = 'RIGHT' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', shift=True) kmi.properties.align_active = True kmi.properties.type = 'TOP' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_1', 'PRESS', shift=True, ctrl=True) kmi.properties.align_active = True kmi.properties.type = 'BACK' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_3', 'PRESS', shift=True, ctrl=True) kmi.properties.align_active = True kmi.properties.type = 'LEFT' -kmi = km.items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.viewnumpad', 'NUMPAD_7', 'PRESS', shift=True, ctrl=True) kmi.properties.align_active = True kmi.properties.type = 'BOTTOM' -kmi = km.items.new('view3d.localview', 'NUMPAD_SLASH', 'PRESS') -kmi = km.items.new('view3d.layers', 'ACCENT_GRAVE', 'PRESS') +kmi = km.keymap_items.new('view3d.localview', 'NUMPAD_SLASH', 'PRESS') +kmi = km.keymap_items.new('view3d.layers', 'ACCENT_GRAVE', 'PRESS') kmi.properties.nr = 0 -kmi = km.items.new('view3d.layers', 'ONE', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'ONE', 'PRESS', any=True) kmi.properties.nr = 1 -kmi = km.items.new('view3d.layers', 'TWO', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'TWO', 'PRESS', any=True) kmi.properties.nr = 2 -kmi = km.items.new('view3d.layers', 'THREE', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'THREE', 'PRESS', any=True) kmi.properties.nr = 3 -kmi = km.items.new('view3d.layers', 'FOUR', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'FOUR', 'PRESS', any=True) kmi.properties.nr = 4 -kmi = km.items.new('view3d.layers', 'FIVE', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'FIVE', 'PRESS', any=True) kmi.properties.nr = 5 -kmi = km.items.new('view3d.layers', 'SIX', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'SIX', 'PRESS', any=True) kmi.properties.nr = 6 -kmi = km.items.new('view3d.layers', 'SEVEN', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'SEVEN', 'PRESS', any=True) kmi.properties.nr = 7 -kmi = km.items.new('view3d.layers', 'EIGHT', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'EIGHT', 'PRESS', any=True) kmi.properties.nr = 8 -kmi = km.items.new('view3d.layers', 'NINE', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'NINE', 'PRESS', any=True) kmi.properties.nr = 9 -kmi = km.items.new('view3d.layers', 'ZERO', 'PRESS', any=True) +kmi = km.keymap_items.new('view3d.layers', 'ZERO', 'PRESS', any=True) kmi.properties.nr = 10 -kmi = km.items.new('wm.context_toggle_enum', 'Z', 'PRESS') +kmi = km.keymap_items.new('wm.context_toggle_enum', 'Z', 'PRESS') kmi.properties.data_path = 'space_data.viewport_shade' kmi.properties.value_1 = 'SOLID' kmi.properties.value_2 = 'WIREFRAME' -kmi = km.items.new('wm.context_toggle_enum', 'Z', 'PRESS', alt=True) +kmi = km.keymap_items.new('wm.context_toggle_enum', 'Z', 'PRESS', alt=True) kmi.properties.data_path = 'space_data.viewport_shade' kmi.properties.value_1 = 'TEXTURED' kmi.properties.value_2 = 'SOLID' -kmi = km.items.new('view3d.select', 'SELECTMOUSE', 'PRESS') -kmi = km.items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS') +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True) kmi.properties.extend = True -kmi = km.items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True) kmi.properties.center = True -kmi = km.items.new('view3d.select', 'SELECTMOUSE', 'PRESS', alt=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', alt=True) kmi.properties.enumerate = True -kmi = km.items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True) kmi.properties.center = True kmi.properties.extend = True -kmi = km.items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) kmi.properties.center = True kmi.properties.enumerate = True -kmi = km.items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) kmi.properties.enumerate = True kmi.properties.extend = True -kmi = km.items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) +kmi = km.keymap_items.new('view3d.select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) kmi.properties.center = True kmi.properties.enumerate = True kmi.properties.extend = True -kmi = km.items.new('view3d.select_border', 'EVT_TWEAK_S', 'ANY') +kmi = km.keymap_items.new('view3d.select_border', 'EVT_TWEAK_S', 'ANY') kmi.properties.extend = False -kmi = km.items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) -kmi = km.items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', ctrl=True) +kmi = km.keymap_items.new('view3d.select_lasso', 'EVT_TWEAK_A', 'ANY', shift=True, ctrl=True) kmi.properties.deselect = True -kmi = km.items.new('view3d.select_circle', 'C', 'PRESS') -kmi = km.items.new('view3d.clip_border', 'B', 'PRESS', alt=True) -kmi = km.items.new('view3d.zoom_border', 'B', 'PRESS', shift=True) -kmi = km.items.new('view3d.render_border', 'B', 'PRESS', shift=True) -kmi = km.items.new('view3d.camera_to_view', 'NUMPAD_0', 'PRESS', ctrl=True, alt=True) -kmi = km.items.new('view3d.object_as_camera', 'NUMPAD_0', 'PRESS', ctrl=True) -kmi = km.items.new('wm.call_menu', 'S', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.select_circle', 'C', 'PRESS') +kmi = km.keymap_items.new('view3d.clip_border', 'B', 'PRESS', alt=True) +kmi = km.keymap_items.new('view3d.zoom_border', 'B', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.render_border', 'B', 'PRESS', shift=True) +kmi = km.keymap_items.new('view3d.camera_to_view', 'NUMPAD_0', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('view3d.object_as_camera', 'NUMPAD_0', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.call_menu', 'S', 'PRESS', shift=True) kmi.properties.name = 'VIEW3D_MT_snap' -kmi = km.items.new('wm.context_set_enum', 'COMMA', 'PRESS') +kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS') kmi.properties.data_path = 'space_data.pivot_point' kmi.properties.value = 'BOUNDING_BOX_CENTER' -kmi = km.items.new('wm.context_set_enum', 'COMMA', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.context_set_enum', 'COMMA', 'PRESS', ctrl=True) kmi.properties.data_path = 'space_data.pivot_point' kmi.properties.value = 'MEDIAN_POINT' -kmi = km.items.new('wm.context_toggle', 'COMMA', 'PRESS', alt=True) +kmi = km.keymap_items.new('wm.context_toggle', 'COMMA', 'PRESS', alt=True) kmi.properties.data_path = 'space_data.use_pivot_point' -kmi = km.items.new('wm.context_toggle', 'Q', 'PRESS') +kmi = km.keymap_items.new('wm.context_toggle', 'Q', 'PRESS') kmi.properties.data_path = 'space_data.show_manipulator' -kmi = km.items.new('wm.context_set_enum', 'PERIOD', 'PRESS') +kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS') kmi.properties.data_path = 'space_data.pivot_point' kmi.properties.value = 'CURSOR' -kmi = km.items.new('wm.context_set_enum', 'PERIOD', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', ctrl=True) kmi.properties.data_path = 'space_data.pivot_point' kmi.properties.value = 'INDIVIDUAL_ORIGINS' -kmi = km.items.new('wm.context_set_enum', 'PERIOD', 'PRESS', alt=True) +kmi = km.keymap_items.new('wm.context_set_enum', 'PERIOD', 'PRESS', alt=True) kmi.properties.data_path = 'space_data.pivot_point' kmi.properties.value = 'ACTIVE_ELEMENT' -kmi = km.items.new('transform.translate', 'G', 'PRESS', shift=True) -kmi = km.items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') -kmi = km.items.new('transform.rotate', 'R', 'PRESS', shift=True) -kmi = km.items.new('transform.resize', 'S', 'PRESS', shift=True) -kmi = km.items.new('transform.warp', 'W', 'PRESS', shift=True) -kmi = km.items.new('transform.tosphere', 'S', 'PRESS', shift=True, alt=True) -kmi = km.items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.items.new('transform.select_orientation', 'SPACE', 'PRESS', alt=True) -kmi = km.items.new('transform.create_orientation', 'SPACE', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('transform.translate', 'G', 'PRESS', shift=True) +kmi = km.keymap_items.new('transform.translate', 'EVT_TWEAK_S', 'ANY') +kmi = km.keymap_items.new('transform.rotate', 'R', 'PRESS', shift=True) +kmi = km.keymap_items.new('transform.resize', 'S', 'PRESS', shift=True) +kmi = km.keymap_items.new('transform.warp', 'W', 'PRESS', shift=True) +kmi = km.keymap_items.new('transform.tosphere', 'S', 'PRESS', shift=True, alt=True) +kmi = km.keymap_items.new('transform.shear', 'S', 'PRESS', shift=True, ctrl=True, alt=True) +kmi = km.keymap_items.new('transform.select_orientation', 'SPACE', 'PRESS', alt=True) +kmi = km.keymap_items.new('transform.create_orientation', 'SPACE', 'PRESS', ctrl=True, alt=True) kmi.properties.use = True -kmi = km.items.new('transform.mirror', 'M', 'PRESS', ctrl=True) -kmi = km.items.new('wm.context_toggle', 'TAB', 'PRESS', shift=True) +kmi = km.keymap_items.new('transform.mirror', 'M', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.context_toggle', 'TAB', 'PRESS', shift=True) kmi.properties.data_path = 'tool_settings.use_snap' -kmi = km.items.new('transform.snap_type', 'TAB', 'PRESS', shift=True, ctrl=True) -kmi = km.items.new('view3d.enable_manipulator', 'W', 'PRESS') +kmi = km.keymap_items.new('transform.snap_type', 'TAB', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('view3d.enable_manipulator', 'W', 'PRESS') kmi.properties.translate = True -kmi = km.items.new('view3d.enable_manipulator', 'E', 'PRESS') +kmi = km.keymap_items.new('view3d.enable_manipulator', 'E', 'PRESS') kmi.properties.rotate = True -kmi = km.items.new('view3d.enable_manipulator', 'R', 'PRESS') +kmi = km.keymap_items.new('view3d.enable_manipulator', 'R', 'PRESS') kmi.properties.scale = True -kmi = km.items.new('view3d.select_border', 'EVT_TWEAK_S', 'ANY', shift=True) +kmi = km.keymap_items.new('view3d.select_border', 'EVT_TWEAK_S', 'ANY', shift=True) kmi.properties.extend = True # Map Object Mode km = kc.keymaps.new('Object Mode', space_type='EMPTY', region_type='WINDOW', modal=False) -kmi = km.items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) +kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) kmi.properties.data_path = 'tool_settings.proportional_edit_falloff' -kmi = km.items.new('wm.context_toggle_enum', 'O', 'PRESS') +kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS') kmi.properties.data_path = 'tool_settings.proportional_edit' kmi.properties.value_1 = 'DISABLED' kmi.properties.value_2 = 'ENABLED' -kmi = km.items.new('view3d.game_start', 'P', 'PRESS') -kmi = km.items.new('object.select_all', 'A', 'PRESS') -kmi = km.items.new('object.select_inverse', 'I', 'PRESS', ctrl=True) -kmi = km.items.new('object.select_linked', 'L', 'PRESS', shift=True) -kmi = km.items.new('object.select_grouped', 'G', 'PRESS', shift=True) -kmi = km.items.new('object.select_mirror', 'M', 'PRESS', shift=True, ctrl=True) -kmi = km.items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS') +kmi = km.keymap_items.new('view3d.game_start', 'P', 'PRESS') +kmi = km.keymap_items.new('object.select_all', 'A', 'PRESS') +kmi = km.keymap_items.new('object.select_inverse', 'I', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.select_linked', 'L', 'PRESS', shift=True) +kmi = km.keymap_items.new('object.select_grouped', 'G', 'PRESS', shift=True) +kmi = km.keymap_items.new('object.select_mirror', 'M', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS') kmi.properties.direction = 'PARENT' -kmi = km.items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS', shift=True) +kmi = km.keymap_items.new('object.select_hierarchy', 'LEFT_BRACKET', 'PRESS', shift=True) kmi.properties.direction = 'PARENT' kmi.properties.extend = True -kmi = km.items.new('object.select_hierarchy', 'RIGHT_BRACKET', 'PRESS') +kmi = km.keymap_items.new('object.select_hierarchy', 'RIGHT_BRACKET', 'PRESS') kmi.properties.direction = 'CHILD' -kmi = km.items.new('object.select_hierarchy', 'RIGHT_BRACKET', 'PRESS', shift=True) +kmi = km.keymap_items.new('object.select_hierarchy', 'RIGHT_BRACKET', 'PRESS', shift=True) kmi.properties.direction = 'CHILD' kmi.properties.extend = True -kmi = km.items.new('object.parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.items.new('object.parent_no_inverse_set', 'P', 'PRESS', shift=True, ctrl=True) -kmi = km.items.new('object.parent_clear', 'P', 'PRESS', alt=True) -kmi = km.items.new('object.track_set', 'T', 'PRESS', ctrl=True) -kmi = km.items.new('object.track_clear', 'T', 'PRESS', alt=True) -kmi = km.items.new('object.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True) -kmi = km.items.new('object.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True) -kmi = km.items.new('object.location_clear', 'G', 'PRESS', alt=True) -kmi = km.items.new('object.rotation_clear', 'R', 'PRESS', alt=True) -kmi = km.items.new('object.scale_clear', 'S', 'PRESS', alt=True) -kmi = km.items.new('object.origin_clear', 'O', 'PRESS', alt=True) -kmi = km.items.new('object.hide_view_clear', 'H', 'PRESS', alt=True) -kmi = km.items.new('object.hide_view_set', 'H', 'PRESS') -kmi = km.items.new('object.hide_view_set', 'H', 'PRESS', shift=True) +kmi = km.keymap_items.new('object.parent_set', 'P', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.parent_no_inverse_set', 'P', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('object.parent_clear', 'P', 'PRESS', alt=True) +kmi = km.keymap_items.new('object.track_set', 'T', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.track_clear', 'T', 'PRESS', alt=True) +kmi = km.keymap_items.new('object.constraint_add_with_targets', 'C', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('object.constraints_clear', 'C', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('object.location_clear', 'G', 'PRESS', alt=True) +kmi = km.keymap_items.new('object.rotation_clear', 'R', 'PRESS', alt=True) +kmi = km.keymap_items.new('object.scale_clear', 'S', 'PRESS', alt=True) +kmi = km.keymap_items.new('object.origin_clear', 'O', 'PRESS', alt=True) +kmi = km.keymap_items.new('object.hide_view_clear', 'H', 'PRESS', alt=True) +kmi = km.keymap_items.new('object.hide_view_set', 'H', 'PRESS') +kmi = km.keymap_items.new('object.hide_view_set', 'H', 'PRESS', shift=True) kmi.properties.unselected = True -kmi = km.items.new('object.move_to_layer', 'M', 'PRESS') -kmi = km.items.new('object.delete', 'X', 'PRESS') -kmi = km.items.new('object.delete', 'DEL', 'PRESS') -kmi = km.items.new('wm.call_menu', 'A', 'PRESS', shift=True) +kmi = km.keymap_items.new('object.move_to_layer', 'M', 'PRESS') +kmi = km.keymap_items.new('object.delete', 'X', 'PRESS') +kmi = km.keymap_items.new('object.delete', 'DEL', 'PRESS') +kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) kmi.properties.name = 'INFO_MT_add' -kmi = km.items.new('object.duplicates_make_real', 'A', 'PRESS', shift=True, ctrl=True) -kmi = km.items.new('wm.call_menu', 'A', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.duplicates_make_real', 'A', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_object_apply' -kmi = km.items.new('wm.call_menu', 'U', 'PRESS') +kmi = km.keymap_items.new('wm.call_menu', 'U', 'PRESS') kmi.properties.name = 'VIEW3D_MT_make_single_user' -kmi = km.items.new('wm.call_menu', 'L', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.call_menu', 'L', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_make_links' -kmi = km.items.new('object.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.items.new('object.duplicate_move_linked', 'D', 'PRESS', alt=True) -kmi = km.items.new('object.join', 'J', 'PRESS', ctrl=True) -kmi = km.items.new('object.convert', 'C', 'PRESS', alt=True) -kmi = km.items.new('object.proxy_make', 'P', 'PRESS', ctrl=True, alt=True) -kmi = km.items.new('object.make_local', 'L', 'PRESS') -kmi = km.items.new('anim.keyframe_insert_menu', 'I', 'PRESS') -kmi = km.items.new('anim.keyframe_delete_v3d', 'I', 'PRESS', alt=True) -kmi = km.items.new('anim.keying_set_active_set', 'I', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.items.new('group.create', 'G', 'PRESS', ctrl=True) -kmi = km.items.new('group.objects_remove', 'G', 'PRESS', ctrl=True, alt=True) -kmi = km.items.new('group.objects_add_active', 'G', 'PRESS', shift=True, ctrl=True) -kmi = km.items.new('group.objects_remove_active', 'G', 'PRESS', shift=True, alt=True) -kmi = km.items.new('wm.call_menu', 'W', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.duplicate_move', 'D', 'PRESS', shift=True) +kmi = km.keymap_items.new('object.duplicate_move_linked', 'D', 'PRESS', alt=True) +kmi = km.keymap_items.new('object.join', 'J', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.convert', 'C', 'PRESS', alt=True) +kmi = km.keymap_items.new('object.proxy_make', 'P', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('object.make_local', 'L', 'PRESS') +kmi = km.keymap_items.new('anim.keyframe_insert_menu', 'I', 'PRESS') +kmi = km.keymap_items.new('anim.keyframe_delete_v3d', 'I', 'PRESS', alt=True) +kmi = km.keymap_items.new('anim.keying_set_active_set', 'I', 'PRESS', shift=True, ctrl=True, alt=True) +kmi = km.keymap_items.new('group.create', 'G', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('group.objects_remove', 'G', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('group.objects_add_active', 'G', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('group.objects_remove_active', 'G', 'PRESS', shift=True, alt=True) +kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_object_specials' -kmi = km.items.new('object.subdivision_set', 'ZERO', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.subdivision_set', 'ZERO', 'PRESS', ctrl=True) kmi.properties.level = 0 -kmi = km.items.new('object.subdivision_set', 'ONE', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.subdivision_set', 'ONE', 'PRESS', ctrl=True) kmi.properties.level = 1 -kmi = km.items.new('object.subdivision_set', 'TWO', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.subdivision_set', 'TWO', 'PRESS', ctrl=True) kmi.properties.level = 2 -kmi = km.items.new('object.subdivision_set', 'THREE', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.subdivision_set', 'THREE', 'PRESS', ctrl=True) kmi.properties.level = 3 -kmi = km.items.new('object.subdivision_set', 'FOUR', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.subdivision_set', 'FOUR', 'PRESS', ctrl=True) kmi.properties.level = 4 -kmi = km.items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.subdivision_set', 'FIVE', 'PRESS', ctrl=True) kmi.properties.level = 5 -kmi = km.items.new('object.select_all', 'SELECTMOUSE', 'CLICK') +kmi = km.keymap_items.new('object.select_all', 'SELECTMOUSE', 'CLICK') kmi.properties.action = 'DESELECT' # Map Mesh km = kc.keymaps.new('Mesh', space_type='EMPTY', region_type='WINDOW', modal=False) -kmi = km.items.new('mesh.loopcut_slide', 'R', 'PRESS', ctrl=True) -kmi = km.items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi = km.items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) +kmi = km.keymap_items.new('mesh.loopcut_slide', 'R', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('mesh.loop_select', 'SELECTMOUSE', 'PRESS', shift=True, alt=True) kmi.properties.extend = True -kmi = km.items.new('mesh.edgering_select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) -kmi = km.items.new('mesh.edgering_select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) +kmi = km.keymap_items.new('mesh.edgering_select', 'SELECTMOUSE', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('mesh.edgering_select', 'SELECTMOUSE', 'PRESS', shift=True, ctrl=True, alt=True) kmi.properties.extend = True -kmi = km.items.new('mesh.select_shortest_path', 'SELECTMOUSE', 'PRESS', ctrl=True) -kmi = km.items.new('mesh.select_all', 'A', 'PRESS') -kmi = km.items.new('mesh.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) -kmi = km.items.new('mesh.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) -kmi = km.items.new('mesh.select_inverse', 'I', 'PRESS', ctrl=True) -kmi = km.items.new('mesh.select_non_manifold', 'M', 'PRESS', shift=True, ctrl=True, alt=True) -kmi = km.items.new('mesh.select_linked', 'L', 'PRESS', ctrl=True) -kmi = km.items.new('mesh.select_linked_pick', 'L', 'PRESS') -kmi = km.items.new('mesh.select_linked_pick', 'L', 'PRESS', shift=True) +kmi = km.keymap_items.new('mesh.select_shortest_path', 'SELECTMOUSE', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('mesh.select_all', 'A', 'PRESS') +kmi = km.keymap_items.new('mesh.select_more', 'NUMPAD_PLUS', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('mesh.select_less', 'NUMPAD_MINUS', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('mesh.select_inverse', 'I', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('mesh.select_non_manifold', 'M', 'PRESS', shift=True, ctrl=True, alt=True) +kmi = km.keymap_items.new('mesh.select_linked', 'L', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('mesh.select_linked_pick', 'L', 'PRESS') +kmi = km.keymap_items.new('mesh.select_linked_pick', 'L', 'PRESS', shift=True) kmi.properties.deselect = True -kmi = km.items.new('mesh.faces_select_linked_flat', 'F', 'PRESS', shift=True, ctrl=True, alt=True) +kmi = km.keymap_items.new('mesh.faces_select_linked_flat', 'F', 'PRESS', shift=True, ctrl=True, alt=True) kmi.properties.sharpness = 135.0 -kmi = km.items.new('mesh.select_similar', 'G', 'PRESS', shift=True) -kmi = km.items.new('wm.call_menu', 'TAB', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('mesh.select_similar', 'G', 'PRESS', shift=True) +kmi = km.keymap_items.new('wm.call_menu', 'TAB', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_edit_mesh_select_mode' -kmi = km.items.new('mesh.hide', 'H', 'PRESS') -kmi = km.items.new('mesh.hide', 'H', 'PRESS', shift=True) +kmi = km.keymap_items.new('mesh.hide', 'H', 'PRESS') +kmi = km.keymap_items.new('mesh.hide', 'H', 'PRESS', shift=True) kmi.properties.unselected = True -kmi = km.items.new('mesh.reveal', 'H', 'PRESS', alt=True) -kmi = km.items.new('mesh.normals_make_consistent', 'N', 'PRESS', ctrl=True) -kmi = km.items.new('mesh.normals_make_consistent', 'N', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('mesh.reveal', 'H', 'PRESS', alt=True) +kmi = km.keymap_items.new('mesh.normals_make_consistent', 'N', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('mesh.normals_make_consistent', 'N', 'PRESS', shift=True, ctrl=True) kmi.properties.inside = True -kmi = km.items.new('view3d.edit_mesh_extrude_move_normal', 'E', 'PRESS', ctrl=True) -kmi = km.items.new('view3d.edit_mesh_extrude_individual_move', 'E', 'PRESS', shift=True) -kmi = km.items.new('wm.call_menu', 'E', 'PRESS', alt=True) +kmi = km.keymap_items.new('view3d.edit_mesh_extrude_move_normal', 'E', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('view3d.edit_mesh_extrude_individual_move', 'E', 'PRESS', shift=True) +kmi = km.keymap_items.new('wm.call_menu', 'E', 'PRESS', alt=True) kmi.properties.name = 'VIEW3D_MT_edit_mesh_extrude' -kmi = km.items.new('mesh.spin', 'R', 'PRESS', alt=True) -kmi = km.items.new('mesh.fill', 'F', 'PRESS', alt=True) -kmi = km.items.new('mesh.beautify_fill', 'F', 'PRESS', shift=True, alt=True) -kmi = km.items.new('mesh.quads_convert_to_tris', 'T', 'PRESS', ctrl=True) -kmi = km.items.new('mesh.tris_convert_to_quads', 'J', 'PRESS', alt=True) -kmi = km.items.new('mesh.edge_flip', 'F', 'PRESS', shift=True, ctrl=True) -kmi = km.items.new('mesh.rip_move', 'V', 'PRESS') -kmi = km.items.new('mesh.merge', 'M', 'PRESS', alt=True) -kmi = km.items.new('transform.shrink_fatten', 'S', 'PRESS', ctrl=True, alt=True) -kmi = km.items.new('mesh.edge_face_add', 'F', 'PRESS') -kmi = km.items.new('mesh.duplicate_move', 'D', 'PRESS', shift=True) -kmi = km.items.new('wm.call_menu', 'A', 'PRESS', shift=True) +kmi = km.keymap_items.new('mesh.spin', 'R', 'PRESS', alt=True) +kmi = km.keymap_items.new('mesh.fill', 'F', 'PRESS', alt=True) +kmi = km.keymap_items.new('mesh.beautify_fill', 'F', 'PRESS', shift=True, alt=True) +kmi = km.keymap_items.new('mesh.quads_convert_to_tris', 'T', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('mesh.tris_convert_to_quads', 'J', 'PRESS', alt=True) +kmi = km.keymap_items.new('mesh.edge_flip', 'F', 'PRESS', shift=True, ctrl=True) +kmi = km.keymap_items.new('mesh.rip_move', 'V', 'PRESS') +kmi = km.keymap_items.new('mesh.merge', 'M', 'PRESS', alt=True) +kmi = km.keymap_items.new('transform.shrink_fatten', 'S', 'PRESS', ctrl=True, alt=True) +kmi = km.keymap_items.new('mesh.edge_face_add', 'F', 'PRESS') +kmi = km.keymap_items.new('mesh.duplicate_move', 'D', 'PRESS', shift=True) +kmi = km.keymap_items.new('wm.call_menu', 'A', 'PRESS', shift=True) kmi.properties.name = 'INFO_MT_mesh_add' -kmi = km.items.new('mesh.separate', 'P', 'PRESS') -kmi = km.items.new('mesh.split', 'Y', 'PRESS') -kmi = km.items.new('mesh.dupli_extrude_cursor', 'ACTIONMOUSE', 'CLICK', ctrl=True) -kmi = km.items.new('mesh.delete', 'X', 'PRESS') -kmi = km.items.new('mesh.delete', 'DEL', 'PRESS') -kmi = km.items.new('mesh.knife_cut', 'LEFTMOUSE', 'PRESS', key_modifier='K') -kmi = km.items.new('mesh.knife_cut', 'LEFTMOUSE', 'PRESS', shift=True, key_modifier='K') +kmi = km.keymap_items.new('mesh.separate', 'P', 'PRESS') +kmi = km.keymap_items.new('mesh.split', 'Y', 'PRESS') +kmi = km.keymap_items.new('mesh.dupli_extrude_cursor', 'ACTIONMOUSE', 'CLICK', ctrl=True) +kmi = km.keymap_items.new('mesh.delete', 'X', 'PRESS') +kmi = km.keymap_items.new('mesh.delete', 'DEL', 'PRESS') +kmi = km.keymap_items.new('mesh.knife_cut', 'LEFTMOUSE', 'PRESS', key_modifier='K') +kmi = km.keymap_items.new('mesh.knife_cut', 'LEFTMOUSE', 'PRESS', shift=True, key_modifier='K') kmi.properties.type = 'MIDPOINTS' -kmi = km.items.new('object.vertex_parent_set', 'P', 'PRESS', ctrl=True) -kmi = km.items.new('wm.call_menu', 'W', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('object.vertex_parent_set', 'P', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.call_menu', 'W', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_edit_mesh_specials' -kmi = km.items.new('wm.call_menu', 'F', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.call_menu', 'F', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_edit_mesh_faces' -kmi = km.items.new('wm.call_menu', 'E', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.call_menu', 'E', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_edit_mesh_edges' -kmi = km.items.new('wm.call_menu', 'V', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.call_menu', 'V', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_edit_mesh_vertices' -kmi = km.items.new('wm.call_menu', 'H', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.call_menu', 'H', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_hook' -kmi = km.items.new('wm.call_menu', 'U', 'PRESS') +kmi = km.keymap_items.new('wm.call_menu', 'U', 'PRESS') kmi.properties.name = 'VIEW3D_MT_uv_map' -kmi = km.items.new('wm.call_menu', 'G', 'PRESS', ctrl=True) +kmi = km.keymap_items.new('wm.call_menu', 'G', 'PRESS', ctrl=True) kmi.properties.name = 'VIEW3D_MT_vertex_group' -kmi = km.items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) +kmi = km.keymap_items.new('wm.context_cycle_enum', 'O', 'PRESS', shift=True) kmi.properties.data_path = 'tool_settings.proportional_edit_falloff' -kmi = km.items.new('wm.context_toggle_enum', 'O', 'PRESS') +kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS') kmi.properties.data_path = 'tool_settings.proportional_edit' kmi.properties.value_1 = 'DISABLED' kmi.properties.value_2 = 'ENABLED' -kmi = km.items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True) +kmi = km.keymap_items.new('wm.context_toggle_enum', 'O', 'PRESS', alt=True) kmi.properties.data_path = 'tool_settings.proportional_edit' kmi.properties.value_1 = 'DISABLED' kmi.properties.value_2 = 'CONNECTED' -kmi = km.items.new('mesh.select_all', 'SELECTMOUSE', 'CLICK') +kmi = km.keymap_items.new('mesh.select_all', 'SELECTMOUSE', 'CLICK') kmi.properties.action = 'DESELECT' wm.keyconfigs.active = kc diff --git a/release/scripts/startup/bl_operators/animsys_update.py b/release/scripts/startup/bl_operators/animsys_update.py index eb14ab7eb72..8fd3ff9bc74 100644 --- a/release/scripts/startup/bl_operators/animsys_update.py +++ b/release/scripts/startup/bl_operators/animsys_update.py @@ -679,6 +679,7 @@ data_path_update = [ ("SpeedControlSequence", "global_speed", "multiply_speed"), ("SpeedControlSequence", "use_curve_velocity", "use_as_speed"), ("SpeedControlSequence", "use_curve_compress_y", "scale_to_length"), + ("Key", "keys", "key_blocks"), ] diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index db5eaccfc8f..d19de50ea6a 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -250,11 +250,11 @@ class ShapeTransfer(bpy.types.Operator): def ob_add_shape(ob, name): me = ob.data key = ob.shape_key_add(from_mix=False) - if len(me.shape_keys.keys) == 1: + if len(me.shape_keys.key_blocks) == 1: key.name = "Basis" key = ob.shape_key_add(from_mix=False) # we need a rest key.name = name - ob.active_shape_key_index = len(me.shape_keys.keys) - 1 + ob.active_shape_key_index = len(me.shape_keys.key_blocks) - 1 ob.show_only_shape_key = True from mathutils.geometry import barycentric_transform @@ -270,7 +270,7 @@ class ShapeTransfer(bpy.types.Operator): orig_normals = me_nos(me.vertices) # orig_coords = me_cos(me.vertices) # the actual mverts location isnt as relyable as the base shape :S - orig_coords = me_cos(me.shape_keys.keys[0].data) + orig_coords = me_cos(me.shape_keys.key_blocks[0].data) for ob_other in objects: me_other = ob_other.data @@ -280,7 +280,7 @@ class ShapeTransfer(bpy.types.Operator): target_normals = me_nos(me_other.vertices) if me_other.shape_keys: - target_coords = me_cos(me_other.shape_keys.keys[0].data) + target_coords = me_cos(me_other.shape_keys.key_blocks[0].data) else: target_coords = me_cos(me_other.vertices) diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index d6557fda8a2..62e60cd7a16 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -188,7 +188,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, bpy.types.Panel): rows = 2 if kb: rows = 5 - row.template_list(key, "keys", ob, "active_shape_key_index", rows=rows) + row.template_list(key, "key_blocks", ob, "active_shape_key_index", rows=rows) col = row.column() @@ -243,7 +243,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, bpy.types.Panel): col.active = enable_edit_value col.label(text="Blend:") col.prop_search(kb, "vertex_group", ob, "vertex_groups", text="") - col.prop_search(kb, "relative_key", key, "keys", text="") + col.prop_search(kb, "relative_key", key, "key_blocks", text="") else: row = layout.row() diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py index 9bc3075a021..25797f3da8f 100644 --- a/release/scripts/startup/bl_ui/properties_physics_cloth.py +++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py @@ -114,7 +114,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, bpy.types.Panel): if key: col.label(text="Rest Shape Key:") - col.prop_search(cloth, "rest_shape_key", key, "keys", text="") + col.prop_search(cloth, "rest_shape_key", key, "key_blocks", text="") class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, bpy.types.Panel): diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index be76cf7c4f8..b6265903890 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -368,7 +368,7 @@ class INFO_MT_help(bpy.types.Menu): if sys.platform[:3] == "win": layout.operator("wm.toggle_console", icon='CONSOLE') layout.separator() - layout.operator("anim.update_data_paths", text="FCurve/Driver 2.54 fix", icon='HELP') + layout.operator("anim.update_data_paths", text="FCurve/Driver Version fix", icon='HELP') layout.separator() layout.operator("wm.splash", icon='BLENDER') diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index e401a895a23..3f1a625e800 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -206,7 +206,7 @@ class InputKeyMapPanel(bpy.types.Panel): # Key Map items if km.show_expanded_items: - for kmi in km.items: + for kmi in km.keymap_items: self.draw_kmi(display_keymaps, kc, km, kmi, col, level + 1) # "Add New" at end of keymap item list @@ -339,7 +339,7 @@ class InputKeyMapPanel(bpy.types.Panel): km = km.active() layout.context_pointer_set("keymap", km) - filtered_items = [kmi for kmi in km.items if filter_text in kmi.name.lower()] + filtered_items = [kmi for kmi in km.keymap_items if filter_text in kmi.name.lower()] if len(filtered_items) != 0: col = layout.column() @@ -433,9 +433,9 @@ class WM_OT_keyconfig_test(bpy.types.Operator): def kmistr(kmi): if km.is_modal: - s = ["kmi = km.items.new_modal(\'%s\', \'%s\', \'%s\'" % (kmi.propvalue, kmi.type, kmi.value)] + s = ["kmi = km.keymap_items.new_modal(\'%s\', \'%s\', \'%s\'" % (kmi.propvalue, kmi.type, kmi.value)] else: - s = ["kmi = km.items.new(\'%s\', \'%s\', \'%s\'" % (kmi.idname, kmi.type, kmi.value)] + s = ["kmi = km.keymap_items.new(\'%s\', \'%s\', \'%s\'" % (kmi.idname, kmi.type, kmi.value)] if kmi.any: s.append(", any=True") @@ -468,7 +468,7 @@ class WM_OT_keyconfig_test(bpy.types.Operator): km = km.active() if src: - for item in km.items: + for item in km.keymap_items: if src.compare(item): print("===========") print(parent.name) @@ -481,15 +481,15 @@ class WM_OT_keyconfig_test(bpy.types.Operator): if self.testEntry(kc, child, src, parent): result = True else: - for i in range(len(km.items)): - src = km.items[i] + for i in range(len(km.keymap_items)): + src = km.keymap_items[i] for child in children: if self.testEntry(kc, child, src, km): result = True - for j in range(len(km.items) - i - 1): - item = km.items[j + i + 1] + for j in range(len(km.keymap_items) - i - 1): + item = km.keymap_items[j + i + 1] if src.compare(item): print("===========") print(km.name) @@ -633,11 +633,11 @@ class WM_OT_keyconfig_export(bpy.types.Operator): f.write("# Map %s\n" % km.name) f.write("km = kc.keymaps.new('%s', space_type='%s', region_type='%s', modal=%s)\n\n" % (km.name, km.space_type, km.region_type, km.is_modal)) - for kmi in km.items: + for kmi in km.keymap_items: if km.is_modal: - f.write("kmi = km.items.new_modal('%s', '%s', '%s'" % (kmi.propvalue, kmi.type, kmi.value)) + f.write("kmi = km.keymap_items.new_modal('%s', '%s', '%s'" % (kmi.propvalue, kmi.type, kmi.value)) else: - f.write("kmi = km.items.new('%s', '%s', '%s'" % (kmi.idname, kmi.type, kmi.value)) + f.write("kmi = km.keymap_items.new('%s', '%s', '%s'" % (kmi.idname, kmi.type, kmi.value)) if kmi.any: f.write(", any=True") else: @@ -715,7 +715,7 @@ class WM_OT_keyitem_restore(bpy.types.Operator): def execute(self, context): km = context.keymap - kmi = km.items.from_id(self.item_id) + kmi = km.keymap_items.from_id(self.item_id) if not kmi.is_user_defined: km.restore_item_to_default(kmi) @@ -734,9 +734,9 @@ class WM_OT_keyitem_add(bpy.types.Operator): kc = wm.keyconfigs.default if km.is_modal: - km.items.new_modal("", 'A', 'PRESS') # kmi + km.keymap_items.new_modal("", 'A', 'PRESS') # kmi else: - km.items.new("none", 'A', 'PRESS') # kmi + km.keymap_items.new("none", 'A', 'PRESS') # kmi # clear filter and expand keymap so we can see the newly added item if context.space_data.filter_text != "": @@ -760,8 +760,8 @@ class WM_OT_keyitem_remove(bpy.types.Operator): def execute(self, context): km = context.keymap - kmi = km.items.from_id(self.item_id) - km.items.remove(kmi) + kmi = km.keymap_items.from_id(self.item_id) + km.keymap_items.remove(kmi) return {'FINISHED'} diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 4a14b2286f9..12f15911bda 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -411,6 +411,21 @@ static int rna_validate_identifier(const char *identifier, char *error, int prop return 0; } } + + if(property) { + static const char *kwlist_prop[] = { + /* not keywords but reserved all the same because py uses */ + "keys", "values", "items", "get", + NULL + }; + + for(a=0; kwlist_prop[a]; a++) { + if (strcmp(identifier, kwlist_prop[a]) == 0) { + strcpy(error, "this keyword is reserved by python"); + return 0; + } + } + } return 1; } diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 0edd46c089a..48cab3b13d1 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -85,7 +85,7 @@ void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value) } /* fix all the animation data which may link to this */ - BKE_all_animdata_fix_paths_rename("keys", oldname, kb->name); + BKE_all_animdata_fix_paths_rename("key_blocks", oldname, kb->name); } static void rna_ShapeKey_value_set(PointerRNA *ptr, float value) @@ -350,7 +350,7 @@ static char *rna_ShapeKey_path(PointerRNA *ptr) if ((id) && (GS(id->name) != ID_KE)) return BLI_sprintfN("shape_keys.keys[\"%s\"]", kb->name); else - return BLI_sprintfN("keys[\"%s\"]", kb->name); + return BLI_sprintfN("key_blocks[\"%s\"]", kb->name); } static void rna_Key_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -434,9 +434,9 @@ static char *rna_ShapeKeyPoint_path(PointerRNA *ptr) int index = rna_ShapeKeyPoint_get_index(key, kb, point); if (GS(id->name) == ID_KE) - return BLI_sprintfN("keys[\"%s\"].data[%d]", kb->name, index); + return BLI_sprintfN("key_blocks[\"%s\"].data[%d]", kb->name, index); else - return BLI_sprintfN("shape_keys.keys[\"%s\"].data[%d]", kb->name, index); + return BLI_sprintfN("shape_keys.key_blocks[\"%s\"].data[%d]", kb->name, index); } else return NULL; // XXX: there's really no way to resolve this... @@ -599,10 +599,10 @@ static void rna_def_key(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "refkey"); RNA_def_property_ui_text(prop, "Reference Key", ""); - prop= RNA_def_property(srna, "keys", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "key_blocks", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "block", NULL); RNA_def_property_struct_type(prop, "ShapeKey"); - RNA_def_property_ui_text(prop, "Keys", "Shape keys"); + RNA_def_property_ui_text(prop, "Key Blocks", "Shape keys"); rna_def_animdata_common(srna); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 55882f0acee..1531b6a9dc0 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -1045,12 +1045,12 @@ static void rna_def_particle(BlenderRNA *brna) /* Hair & Keyed Keys */ - prop= RNA_def_property(srna, "hair", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "hair_keys", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "hair", "totkey"); RNA_def_property_struct_type(prop, "ParticleHairKey"); RNA_def_property_ui_text(prop, "Hair", ""); - prop= RNA_def_property(srna, "keys", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "particle_keys", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "keys", "totkey"); RNA_def_property_struct_type(prop, "ParticleKey"); RNA_def_property_ui_text(prop, "Keyed States", ""); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 203a399ea6c..ca3852c0fd0 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -1233,7 +1233,7 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna) RNA_def_property_enum_funcs(prop, "rna_EnumProperty_default_get", NULL, "rna_EnumProperty_default_itemf"); RNA_def_property_ui_text(prop, "Default", "Default value for this enum"); - prop= RNA_def_property(srna, "items", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "enum_items", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "EnumPropertyItem"); RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 2a51d8b682b..0d1463428bb 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1664,7 +1664,8 @@ static void rna_def_keyconfig(BlenderRNA *brna) RNA_def_property_enum_items(prop, region_type_items); RNA_def_property_ui_text(prop, "Region Type", "Optional region type keymap is associated with"); - prop= RNA_def_property(srna, "items", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "keymap_items", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "items", NULL); RNA_def_property_struct_type(prop, "KeyMapItem"); RNA_def_property_ui_text(prop, "Items", "Items in the keymap, linking an operator to an input event"); rna_def_keymap_items(brna, prop); From 16e736b7db3ef3597e22f55e7b26416ee562a418 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 25 Mar 2011 03:58:21 +0000 Subject: [PATCH 087/261] Graph Editor: Euler Filter ported from Py to C Ported joeedh's Euler Filter code from Python to C so that this is more in line with the other Graph Editor tools - i.e. joeedh's version only worked on the active bone's curves, while standard tools could work with multiple bones/objects at the same time. To use this new version of this operator: 1) Select all the F-Curves for all 3 of the components (XYZ) for the euler rotations you wish to clean up. In the Graph Editor, they must be one after the other (i.e. you can't have "RotX, RotY, something else, RotZ") 2) Activate the operator from the Key menu in the Graph Editor In an old test file I have floating around, this method did not appear to be good enough to fix a very clear discontinuity in the middle of the action, so I'll test some additional methods too --- .../scripts/startup/bl_operators/__init__.py | 1 - .../bl_operators/fcurve_euler_filter.py | 78 ----------- .../blender/editors/space_graph/graph_edit.c | 123 +++++++++++++++--- .../editors/space_graph/graph_intern.h | 1 + .../blender/editors/space_graph/graph_ops.c | 1 + 5 files changed, 108 insertions(+), 96 deletions(-) delete mode 100644 release/scripts/startup/bl_operators/fcurve_euler_filter.py diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py index 599cd6c1889..2a42cfbacb8 100644 --- a/release/scripts/startup/bl_operators/__init__.py +++ b/release/scripts/startup/bl_operators/__init__.py @@ -25,7 +25,6 @@ if "bpy" in locals(): _modules = ( "add_mesh_torus", "animsys_update", - "fcurve_euler_filter", "image", "mesh", "nla", diff --git a/release/scripts/startup/bl_operators/fcurve_euler_filter.py b/release/scripts/startup/bl_operators/fcurve_euler_filter.py deleted file mode 100644 index c7b249a1d0c..00000000000 --- a/release/scripts/startup/bl_operators/fcurve_euler_filter.py +++ /dev/null @@ -1,78 +0,0 @@ -# ##### 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 ##### - -# - -import bpy - - -def main(context): - from math import pi - - def cleanupEulCurve(fcv): - keys = [] - - for k in fcv.keyframe_points: - keys.append([k.handle_left.copy(), k.co.copy(), k.handle_right.copy()]) - - for i in range(len(keys)): - cur = keys[i] - prev = keys[i - 1] if i > 0 else None - next = keys[i + 1] if i < len(keys) - 1 else None - - if prev is None: - continue - - th = pi - if abs(prev[1][1] - cur[1][1]) >= th: # more than 180 degree jump - fac = pi * 2.0 - if prev[1][1] > cur[1][1]: - while abs(cur[1][1] - prev[1][1]) >= th: # < prev[1][1]: - cur[0][1] += fac - cur[1][1] += fac - cur[2][1] += fac - elif prev[1][1] < cur[1][1]: - while abs(cur[1][1] - prev[1][1]) >= th: - cur[0][1] -= fac - cur[1][1] -= fac - cur[2][1] -= fac - - for i in range(len(keys)): - for x in range(2): - fcv.keyframe_points[i].handle_left[x] = keys[i][0][x] - fcv.keyframe_points[i].co[x] = keys[i][1][x] - fcv.keyframe_points[i].handle_right[x] = keys[i][2][x] - - flist = bpy.context.active_object.animation_data.action.fcurves - for f in flist: - if f.select and f.data_path.endswith("rotation_euler"): - cleanupEulCurve(f) - - -class DiscontFilterOp(bpy.types.Operator): - """Fixes the most common causes of gimbal lock in the fcurves of the active bone""" - bl_idname = "graph.euler_filter" - bl_label = "Filter out discontinuities in the active fcurves" - - @classmethod - def poll(cls, context): - return context.active_object != None - - def execute(self, context): - main(context) - return {'FINISHED'} diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index fdd43aa0566..deffc60019e 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1501,12 +1501,13 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) * of values to -180 degrees to 180 degrees. */ -#if 0 // XXX this is not ready for the primetime yet - /* set of three euler-rotation F-Curves */ typedef struct tEulerFilter { + struct tEulerFilter *next, *prev; + ID *id; /* ID-block which owns the channels */ - FCurve (*fcurves)[3]; /* 3 Pointers to F-Curves */ + FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */ + char *rna_path; /* Pointer to one of the RNA Path's used by one of the F-Curves */ } tEulerFilter; static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) @@ -1518,7 +1519,8 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) int filter; ListBase eulers = {NULL, NULL}; - tEulerFilter *euf= NULL; + tEulerFilter *euf= NULL; + int groups=0, failed=0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1528,7 +1530,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) * 1) Sets of three related rotation curves are identified from the selected channels, * and are stored as a single 'operation unit' for the next step * 2) Each set of three F-Curves is processed for each keyframe, with the values being - * processed according to one of several ways. + * processed as necessary */ /* step 1: extract only the rotation f-curves */ @@ -1542,45 +1544,134 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) * - only rotation curves * - for pchan curves, make sure we're only using the euler curves */ - if (strstr(fcu->rna_path, "rotation_euler") == 0) + if (strstr(fcu->rna_path, "rotation_euler") == NULL) continue; + else if (ELEM3(fcu->array_index, 0, 1, 2) == 0) { + BKE_reportf(op->reports, RPT_WARNING, + "Euler Rotation F-Curve has invalid index (ID='%s', Path='%s', Index=%d)", + (ale->id)? ale->id->name:"", fcu->rna_path, fcu->array_index); + continue; + } - /* check if current set of 3-curves is suitable to add this curve to - * - things like whether the current set of curves is 'full' should be checked later only - * - first check if id-blocks are compatible + /* optimisation: assume that xyz curves will always be stored consecutively, + * so if the paths or the ID's don't match up, then a curve needs to be added + * to a new group */ - if ((euf) && (ale->id != euf->id)) { - /* if the paths match, add this curve to the set of curves */ - // NOTE: simple string compare for now... could be a bit more fancy... - + if ((euf) && (euf->id == ale->id) && (strcmp(euf->rna_path, fcu->rna_path)==0)) { + /* this should be fine to add to the existing group then */ + euf->fcurves[fcu->array_index]= fcu; } else { /* just add to a new block */ euf= MEM_callocN(sizeof(tEulerFilter), "tEulerFilter"); BLI_addtail(&eulers, euf); + groups++; euf->id= ale->id; + euf->rna_path = fcu->rna_path; /* this should be safe, since we're only using it for a short time */ euf->fcurves[fcu->array_index]= fcu; } } BLI_freelistN(&anim_data); + if (groups == 0) { + BKE_report(op->reports, RPT_WARNING, "No Euler Rotation F-Curves to fix up"); + return OPERATOR_CANCELLED; + } + /* step 2: go through each set of curves, processing the values at each keyframe * - it is assumed that there must be a full set of keyframes at each keyframe position */ for (euf= eulers.first; euf; euf= euf->next) { + int f; + /* sanity check: ensure that there are enough F-Curves to work on in this group */ + // TODO: also enforce assumption that there be a full set of keyframes at each position by ensuring that totvert counts are same? + if (ELEM3(NULL, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) { + /* report which components are missing */ + BKE_reportf(op->reports, RPT_WARNING, + "Missing %s%s%s component(s) of euler rotation for ID='%s' and RNA-Path='%s'", + (euf->fcurves[0]==NULL)? "X":"", + (euf->fcurves[1]==NULL)? "Y":"", + (euf->fcurves[2]==NULL)? "Z":"", + euf->id->name, euf->rna_path); + + /* keep track of number of failed sets, and carry on to next group */ + failed++; + continue; + } + + /* simple method: just treat any difference between keys of greater than 180 degrees as being a flip */ + // FIXME: there are more complicated methods that will be needed to fix more cases than just some + for (f = 0; f < 3; f++) { + FCurve *fcu = euf->fcurves[f]; + BezTriple *bezt, *prev=NULL; + unsigned int i; + + /* skip if not enough vets to do a decent analysis of... */ + if (fcu->totvert <= 2) + continue; + + /* prev follows bezt, bezt = "current" point to be fixed */ + for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, prev=bezt, bezt++) { + /* our method depends on determining a "difference" from the previous vert */ + if (prev == NULL) + continue; + + /* > 180 degree flip? */ + if (fabs(prev->vec[1][1] - bezt->vec[1][1]) >= M_PI) { + /* 360 degrees to add/subtract frame value until difference is acceptably small that there's no more flip */ + const double fac = 2.0 * M_PI; + + if (prev->vec[1][1] > bezt->vec[1][1]) { + while (fabs(bezt->vec[1][1] - prev->vec[1][1]) >= M_PI) { + bezt->vec[0][1] += fac; + bezt->vec[1][1] += fac; + bezt->vec[2][1] += fac; + } + } + else /* if (prev->vec[1][1] < bezt->vec[1][1]) */ { + while (fabs(bezt->vec[1][1] - prev->vec[1][1]) >= M_PI) { + bezt->vec[0][1] -= fac; + bezt->vec[1][1] -= fac; + bezt->vec[2][1] -= fac; + } + } + } + } + } } BLI_freelistN(&eulers); - return OPERATOR_FINISHED; + /* updates + finishing warnings */ + if (failed == groups) { + BKE_report(op->reports, RPT_ERROR, + "No Euler Rotations could be corrected. Ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected."); + return OPERATOR_CANCELLED; + } + else { + if (failed) { + BKE_report(op->reports, RPT_ERROR, + "Some Euler Rotations couldn't be corrected due to missing/unselected/out-of-order F-Curves. Ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected."); + } + + /* validate keyframes after editing */ + ANIM_editkeyframes_refresh(&ac); + + /* set notifier that keyframes have changed */ + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + + /* done at last */ + return OPERATOR_FINISHED; + } } void GRAPH_OT_euler_filter (wmOperatorType *ot) { /* identifiers */ - ot->name= "Euler Filter"; + ot->name= "Euler Discontinuity Filter"; ot->idname= "GRAPH_OT_euler_filter"; + ot->description= "Fixes the most common causes of gimbal lock in the selected Euler Rotation F-Curves"; /* api callbacks */ ot->exec= graphkeys_euler_filter_exec; @@ -1590,8 +1681,6 @@ void GRAPH_OT_euler_filter (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -#endif // XXX this is not ready for the primetime yet - /* ***************** Jump to Selected Frames Operator *********************** */ /* snap current-frame indicator to 'average time' of selected keyframe */ diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index feb17827db7..2aefb7c64dd 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -111,6 +111,7 @@ void GRAPH_OT_sample(struct wmOperatorType *ot); void GRAPH_OT_bake(struct wmOperatorType *ot); void GRAPH_OT_sound_bake(struct wmOperatorType *ot); void GRAPH_OT_smooth(struct wmOperatorType *ot); +void GRAPH_OT_euler_filter(struct wmOperatorType *ot); void GRAPH_OT_handle_type(struct wmOperatorType *ot); void GRAPH_OT_interpolation_type(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 674d2809188..e75fbeb8efc 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -255,6 +255,7 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_sound_bake); WM_operatortype_append(GRAPH_OT_smooth); WM_operatortype_append(GRAPH_OT_clean); + WM_operatortype_append(GRAPH_OT_euler_filter); WM_operatortype_append(GRAPH_OT_delete); WM_operatortype_append(GRAPH_OT_duplicate); From a21f46b6d43c3743b96515e9733faf78d70c36ed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 04:36:10 +0000 Subject: [PATCH 088/261] new function RNA_warning(), replaces printf with function which may be called via python. Now this gives the line number of the scripts thats running, eg: uiItemFullO: unknown operator 'some.operator' /c/bin/2.56/scripts/startup/bl_ui/space_view3d_toolbar.py:73 --- source/blender/editors/interface/interface.c | 2 +- .../editors/interface/interface_layout.c | 45 +++++++++++-------- .../editors/interface/interface_templates.c | 45 +++++++++++-------- source/blender/makesrna/RNA_access.h | 6 +++ source/blender/makesrna/intern/rna_access.c | 16 +++++++ source/blender/python/generic/py_capi_utils.c | 9 ++++ source/blender/python/generic/py_capi_utils.h | 1 + 7 files changed, 86 insertions(+), 38 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 00b2d922ffc..b4b96f46173 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2546,7 +2546,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s } } else { - printf("ui_def_but_rna: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("ui_def_but_rna: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); str= propname; } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index c94c3a7813a..a208eee1649 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -609,15 +609,16 @@ static void ui_item_disabled(uiLayout *layout, const char *name) } /* operator items */ -PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, IDProperty *properties, int context, int flag) +PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, int context, int flag) { uiBlock *block= layout->root->block; - wmOperatorType *ot= WM_operatortype_find(idname, 0); + wmOperatorType *ot= WM_operatortype_find(opname, 1); uiBut *but; int w; if(!ot) { - ui_item_disabled(layout, idname); + ui_item_disabled(layout, opname); + RNA_warning("uiItemFullO: unknown operator '%s'\n", opname); return PointerRNA_NULL; } @@ -713,7 +714,7 @@ void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int ico void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, IDProperty *properties, int context, int flag) { - wmOperatorType *ot= WM_operatortype_find(opname, 0); + wmOperatorType *ot= WM_operatortype_find(opname, 1); PointerRNA ptr; PropertyRNA *prop; uiBut *bt; @@ -721,6 +722,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname if(!ot || !ot->srna) { ui_item_disabled(layout, opname); + RNA_warning("uiItemsFullEnumO: %s '%s'\n", ot ? "unknown operator" : "operator missing srna", opname); return; } @@ -795,7 +797,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char /* pass */ } else { - printf("uiItemEnumO_value: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname); + RNA_warning("uiItemEnumO_value: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname); return; } @@ -824,7 +826,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free); if(item==NULL || RNA_enum_value_from_id(item, value_str, &value)==0) { if(free) MEM_freeN(item); - printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str); + RNA_warning("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str); return; } @@ -832,7 +834,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char MEM_freeN(item); } else { - printf("uiItemEnumO_string: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname); + RNA_warning("uiItemEnumO_string: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname); return; } @@ -1038,7 +1040,7 @@ void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag, if(!prop) { ui_item_disabled(layout, propname); - printf("uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } @@ -1051,7 +1053,7 @@ void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA if(!prop || RNA_property_type(prop) != PROP_ENUM) { ui_item_disabled(layout, propname); - printf("uiItemEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiItemEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } @@ -1066,7 +1068,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr if(!prop || RNA_property_type(prop) != PROP_ENUM) { ui_item_disabled(layout, propname); - printf("uiItemEnumR_string: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiItemEnumR_string: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } @@ -1075,7 +1077,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr if(!RNA_enum_value_from_id(item, value, &ivalue)) { if(free) MEM_freeN(item); ui_item_disabled(layout, propname); - printf("uiItemEnumR: enum property value not found: %s\n", value); + RNA_warning("uiItemEnumR: enum property value not found: %s\n", value); return; } @@ -1100,10 +1102,15 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname if(!prop) { ui_item_disabled(layout, propname); + RNA_warning("uiItemsEnumR: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) == PROP_ENUM) { + if(RNA_property_type(prop) != PROP_ENUM) { + RNA_warning("uiItemsEnumR: not an enum property: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + return; + } + else { EnumPropertyItem *item; int totitem, i, free; uiLayout *split= uiLayoutSplit(layout, 0, 0); @@ -1288,13 +1295,13 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna prop= RNA_struct_find_property(ptr, propname); if(!prop) { - printf("uiItemPointerR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiItemPointerR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } type= RNA_property_type(prop); if(!ELEM(type, PROP_POINTER, PROP_STRING)) { - printf("uiItemPointerR: property %s must be a pointer or string.\n", propname); + RNA_warning("uiItemPointerR: property %s must be a pointer or string.\n", propname); return; } @@ -1302,11 +1309,11 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna if(!searchprop) { - printf("uiItemPointerR: search collection property not found: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname); + RNA_warning("uiItemPointerR: search collection property not found: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname); return; } else if (RNA_property_type(searchprop) != PROP_COLLECTION) { - printf("uiItemPointerR: search collection property is not a collection type: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname); + RNA_warning("uiItemPointerR: search collection property is not a collection type: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname); return; } @@ -1391,7 +1398,7 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const mt= WM_menutype_find(menuname, FALSE); if(mt==NULL) { - printf("uiItemM: not found %s\n", menuname); + RNA_warning("uiItemM: not found %s\n", menuname); return; } @@ -1504,11 +1511,12 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon) { - wmOperatorType *ot= WM_operatortype_find(opname, 0); + wmOperatorType *ot= WM_operatortype_find(opname, 1); MenuItemLevel *lvl; if(!ot || !ot->srna) { ui_item_disabled(layout, opname); + RNA_warning("uiItemMenuEnumO: %s '%s'\n", ot ? "unknown operator" : "operator missing srna", name); return; } @@ -1541,6 +1549,7 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn prop= RNA_struct_find_property(ptr, propname); if(!prop) { ui_item_disabled(layout, propname); + RNA_warning("uiItemMenuEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 5944d1606e1..d13de5cf0c6 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -240,7 +240,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) switch(event) { case UI_ID_BROWSE: case UI_ID_PIN: - printf("warning, id event %d shouldnt come here\n", event); + RNA_warning("warning, id event %d shouldnt come here\n", event); break; case UI_ID_OPEN: case UI_ID_ADD_NEW: @@ -484,7 +484,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const prop= RNA_struct_find_property(ptr, propname); if(!prop || RNA_property_type(prop) != PROP_POINTER) { - printf("uiTemplateID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiTemplateID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } @@ -545,11 +545,11 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co propType= RNA_struct_find_property(ptr, proptypename); if (!propID || RNA_property_type(propID) != PROP_POINTER) { - printf("uiTemplateAnyID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiTemplateAnyID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } if (!propType || RNA_property_type(propType) != PROP_ENUM) { - printf("uiTemplateAnyID: pointer-type property not found: %s.%s\n", RNA_struct_identifier(ptr->type), proptypename); + RNA_warning("uiTemplateAnyID: pointer-type property not found: %s.%s\n", RNA_struct_identifier(ptr->type), proptypename); return; } @@ -588,7 +588,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna /* check that properties are valid */ propPath= RNA_struct_find_property(ptr, propname); if (!propPath || RNA_property_type(propPath) != PROP_STRING) { - printf("uiTemplatePathBuilder: path property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiTemplatePathBuilder: path property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } @@ -830,7 +830,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) /* verify we have valid data */ if(!RNA_struct_is_a(ptr->type, &RNA_Modifier)) { - printf("uiTemplateModifier: expected modifier on object.\n"); + RNA_warning("uiTemplateModifier: expected modifier on object.\n"); return NULL; } @@ -838,7 +838,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) md= ptr->data; if(!ob || !(GS(ob->id.name) == ID_OB)) { - printf("uiTemplateModifier: expected modifier on object.\n"); + RNA_warning("uiTemplateModifier: expected modifier on object.\n"); return NULL; } @@ -1062,7 +1062,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) /* verify we have valid data */ if(!RNA_struct_is_a(ptr->type, &RNA_Constraint)) { - printf("uiTemplateConstraint: expected constraint on object.\n"); + RNA_warning("uiTemplateConstraint: expected constraint on object.\n"); return NULL; } @@ -1070,7 +1070,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) con= ptr->data; if(!ob || !(GS(ob->id.name) == ID_OB)) { - printf("uiTemplateConstraint: expected constraint on object.\n"); + RNA_warning("uiTemplateConstraint: expected constraint on object.\n"); return NULL; } @@ -1116,7 +1116,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M PointerRNA texture_ptr; if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) { - printf("uiTemplatePreview: expected ID of type material, texture, lamp or world.\n"); + RNA_warning("uiTemplatePreview: expected ID of type material, texture, lamp or world.\n"); return; } @@ -1818,8 +1818,15 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn PropertyRNA *prop= RNA_struct_find_property(ptr, propname); PointerRNA cptr; - if(!prop || RNA_property_type(prop) != PROP_POINTER) + if(!prop) { + RNA_warning("uiTemplateCurveMapping: curve property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; + } + + if(RNA_property_type(prop) != PROP_POINTER) { + RNA_warning("uiTemplateCurveMapping: curve is not a pointer: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + return; + } cptr= RNA_property_pointer_get(ptr, prop); if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping)) @@ -1847,7 +1854,7 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam float softmin, softmax, step, precision; if (!prop) { - printf("uiTemplateColorWheel: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiTemplateColorWheel: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } @@ -1917,7 +1924,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, prop= RNA_struct_find_property(ptr, propname); if (!prop) { - printf("uiTemplateLayer: layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiTemplateLayer: layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } @@ -1934,7 +1941,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, if(used_ptr && used_propname) { used_prop= RNA_struct_find_property(used_ptr, used_propname); if (!used_prop) { - printf("uiTemplateLayer: used layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), used_propname); + RNA_warning("uiTemplateLayer: used layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), used_propname); return; } @@ -2115,7 +2122,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * pa= block->panel; if(!pa) { - printf("uiTemplateList: only works inside a panel.\n"); + RNA_warning("uiTemplateList: only works inside a panel.\n"); return; } @@ -2125,28 +2132,28 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * if(ptr->data) { prop= RNA_struct_find_property(ptr, propname); if(!prop) { - printf("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); return; } } activeprop= RNA_struct_find_property(activeptr, activepropname); if(!activeprop) { - printf("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), activepropname); + RNA_warning("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), activepropname); return; } if(prop) { type= RNA_property_type(prop); if(type != PROP_COLLECTION) { - printf("uiTemplateList: expected collection property.\n"); + RNA_warning("uiTemplateList: expected collection property.\n"); return; } } activetype= RNA_property_type(activeprop); if(activetype != PROP_INT) { - printf("uiTemplateList: expected integer property.\n"); + RNA_warning("uiTemplateList: expected integer property.\n"); return; } diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 076aa199766..e67728def11 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -955,6 +955,12 @@ int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *re short RNA_type_to_ID_code(StructRNA *type); StructRNA *ID_code_to_RNA_type(short idcode); +void RNA_warning(const char *format, ...) +#ifdef __GNUC__ +__attribute__ ((format (printf, 1, 2))) +#endif +; + #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index cd243d49fde..cbd02d885dc 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -62,6 +62,22 @@ #include "rna_internal.h" +void RNA_warning(const char *format, ...) +{ + va_list args; + + va_start(args, format); + vprintf(format, args); + va_end(args); + +#if WITH_PYTHON + { + extern void PyC_LineSpit(void); + PyC_LineSpit(); + } +#endif +} + const PointerRNA PointerRNA_NULL= {{NULL}}; /* Init/Exit */ diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index fd44e09003e..7182d5f75d0 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -30,6 +30,8 @@ #include "py_capi_utils.h" +#define PYC_INTERPRETER_ACTIVE (((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL) + /* for debugging */ void PyC_ObSpit(const char *name, PyObject *var) { fprintf(stderr, "<%s> : ", name); @@ -51,9 +53,16 @@ void PyC_ObSpit(const char *name, PyObject *var) { } void PyC_LineSpit(void) { + const char *filename; int lineno; + /* Note, allow calling from outside python (RNA) */ + if(!PYC_INTERPRETER_ACTIVE) { + fprintf(stderr, "python line lookup failed, interpreter inactive\n"); + return; + } + PyErr_Clear(); PyC_FileAndNum(&filename, &lineno); diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index c78e78b5a0b..0b821759bec 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -47,4 +47,5 @@ void PyC_RunQuicky(const char *filepath, int n, ...); void PyC_MainModule_Backup(PyObject **main_mod); void PyC_MainModule_Restore(PyObject *main_mod); + #endif // PY_CAPI_UTILS_H From 2c04bab116c5e5e0d93e78a7c196a59c6c3a2944 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 04:37:59 +0000 Subject: [PATCH 089/261] SpaceImage.curves --> curve for consistency. --- .../editors/space_image/image_buttons.c | 2 +- source/blender/makesrna/intern/rna_access.c | 32 +++++++++---------- source/blender/makesrna/intern/rna_space.c | 4 +-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 8b3ceecc7da..6a50de566ac 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -346,7 +346,7 @@ static void image_panel_curves(const bContext *C, Panel *pa) levels= (ibuf->channels==4); RNA_pointer_create(&sc->id, &RNA_SpaceImageEditor, sima, &simaptr); - uiTemplateCurveMapping(pa->layout, &simaptr, "curves", 'c', levels, 0); + uiTemplateCurveMapping(pa->layout, &simaptr, "curve", 'c', levels, 0); } ED_space_image_release_buffer(sima, lock); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index cbd02d885dc..4d2e205d1a9 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -62,22 +62,6 @@ #include "rna_internal.h" -void RNA_warning(const char *format, ...) -{ - va_list args; - - va_start(args, format); - vprintf(format, args); - va_end(args); - -#if WITH_PYTHON - { - extern void PyC_LineSpit(void); - PyC_LineSpit(); - } -#endif -} - const PointerRNA PointerRNA_NULL= {{NULL}}; /* Init/Exit */ @@ -5093,3 +5077,19 @@ int RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, i return 0; } + +void RNA_warning(const char *format, ...) +{ + va_list args; + + va_start(args, format); + vprintf(format, args); + va_end(args); + +#ifdef WITH_PYTHON + { + extern void PyC_LineSpit(void); + PyC_LineSpit(); + } +#endif +} diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 54b2dc1dd0f..5d39537970b 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1450,9 +1450,9 @@ static void rna_def_space_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Image User", "Parameters defining which layer, pass and frame of the image is displayed"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); - prop= RNA_def_property(srna, "curves", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "cumap"); - RNA_def_property_ui_text(prop, "Curves", "Color curve mapping to use for displaying the image"); + RNA_def_property_ui_text(prop, "Curve", "Color curve mapping to use for displaying the image"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_SpaceImageEditor_curves_update"); prop= RNA_def_property(srna, "scopes", PROP_POINTER, PROP_NONE); From 5f8fa29755a062a3dff4a574c904f5e24cc48cca Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 04:56:48 +0000 Subject: [PATCH 090/261] add cmake option to build without xinput (tablet support) --- CMakeLists.txt | 10 +++++++++- intern/ghost/CMakeLists.txt | 5 +++++ intern/ghost/SConscript | 3 ++- intern/ghost/intern/GHOST_WindowX11.cpp | 13 ++++++++++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index afb3d71a0ec..73437c63635 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,10 @@ else() option(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF) endif() +if(UNIX AND NOT APPLE) + option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support)" ON) +endif() + # Modifiers option(WITH_MOD_FLUID "Enable Elbeem Modifier (Fluid Simulation)" ON) option(WITH_MOD_DECIMATE "Enable Decimate Modifier" ON) @@ -384,7 +388,11 @@ if(UNIX AND NOT APPLE) mark_as_advanced(X11_XF86keysym_INCLUDE_PATH) # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed - set(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB} ${X11_Xinput_LIB}") + set(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB}") + + if(WITH_X11_XINPUT) + list(APPEND LLIBS ${X11_Xinput_LIB}) + endif() if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(NOT WITH_PYTHON_MODULE) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 33185a63d5b..d629b44a106 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -118,6 +118,11 @@ if(APPLE) endif() elseif(UNIX) + + if(WITH_X11_XINPUT) + add_definitions(-DWITH_X11_XINPUT) + endif() + list(APPEND INC ${X11_X11_INCLUDE_PATH}) list(APPEND SRC diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript index 7aedc08ce96..b67545f216a 100644 --- a/intern/ghost/SConscript +++ b/intern/ghost/SConscript @@ -21,7 +21,8 @@ if window_system in ('linux2', 'openbsd3', 'sunos5', 'freebsd7', 'freebsd8', 'fr sources.remove('intern' + os.sep + f + 'Carbon.cpp') except ValueError: pass - defs += ['PREFIX=\\"/usr/local/\\"'] + defs += ['PREFIX=\\"/usr/local/\\"'] # XXX, make an option + defs += ['WITH_X11_XINPUT'] # XXX, make an option elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-vc'): for f in pf: diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 890c40f6f11..3578ae8619f 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -439,7 +439,9 @@ GHOST_WindowX11( setTitle(title); +#ifdef WITH_X11_XINPUT initXInputDevices(); +#endif // now set up the rendering context. if (installDrawingContext(type) == GHOST_kSuccess) { @@ -493,6 +495,8 @@ static bool match_token(const char *haystack, const char *needle) return FALSE; } +#ifdef WITH_X11_XINPUT + /* Determining if an X device is a Tablet style device is an imperfect science. ** We rely on common conventions around device names as well as the type reported ** by Wacom tablets. This code will likely need to be expanded for alternate tablet types @@ -652,8 +656,9 @@ void GHOST_WindowX11::initXInputDevices() } XFree(version); } -} +} +#endif /* WITH_X11_XINPUT */ Window GHOST_WindowX11:: @@ -1275,14 +1280,16 @@ GHOST_WindowX11:: if (m_custom_cursor) { XFreeCursor(m_display, m_custom_cursor); } - + +#ifdef WITH_X11_XINPUT /* close tablet devices */ if(m_xtablet.StylusDevice) XCloseDevice(m_display, m_xtablet.StylusDevice); if(m_xtablet.EraserDevice) XCloseDevice(m_display, m_xtablet.EraserDevice); - +#endif /* WITH_X11_XINPUT */ + if (m_context != s_firstContext) { glXDestroyContext(m_display, m_context); } From 06b04fa8862eee030ea4024f020992664c3457fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 05:23:58 +0000 Subject: [PATCH 091/261] dont return a system path if cmake's 'WITH_INSTALL_PORTABLE' is enabled. this way portable builds wont find scripts in /usr/share. --- CMakeLists.txt | 6 +----- intern/ghost/CMakeLists.txt | 4 +++- intern/ghost/intern/GHOST_SystemPathsX11.cpp | 10 +++++----- intern/ghost/intern/GHOST_SystemX11.cpp | 4 ---- intern/ghost/intern/GHOST_WindowX11.cpp | 2 +- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73437c63635..81263095bf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,11 +111,7 @@ endif() # 3D format support # disable opencollada on non-apple unix because opencollada has no package for debian -if(UNIX AND NOT APPLE) - option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" OFF) -else() - option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" OFF) -endif() +option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" OFF) # Sound output option(WITH_SDL "Enable SDL for sound and joystick support" ON) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index d629b44a106..6c86cf82f0e 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -137,7 +137,9 @@ elseif(UNIX) intern/GHOST_WindowX11.h ) - add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}") + if(NOT WITH_INSTALL_PORTABLE) + add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}") + endif() if(X11_XF86keysym_INCLUDE_PATH) add_definitions(-DWITH_XF86KEYSYM) diff --git a/intern/ghost/intern/GHOST_SystemPathsX11.cpp b/intern/ghost/intern/GHOST_SystemPathsX11.cpp index 30c45de47bc..dd8935732c5 100644 --- a/intern/ghost/intern/GHOST_SystemPathsX11.cpp +++ b/intern/ghost/intern/GHOST_SystemPathsX11.cpp @@ -43,11 +43,6 @@ #include // for fprintf only #include // for exit -#ifndef PREFIX -# define PREFIX "/usr/local" -#endif - - using namespace std; GHOST_SystemPathsX11::GHOST_SystemPathsX11() @@ -60,7 +55,12 @@ GHOST_SystemPathsX11::~GHOST_SystemPathsX11() const GHOST_TUns8* GHOST_SystemPathsX11::getSystemDir() const { + /* no prefix assumes a portable build which only uses bundled scripts */ +#ifdef PREFIX return (GHOST_TUns8*) PREFIX "/share"; +#else + return NULL; +#endif } const GHOST_TUns8* GHOST_SystemPathsX11::getUserDir() const diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 36748b9f295..e2ee7044392 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -76,10 +76,6 @@ #include // for fprintf only #include // for exit -#ifndef PREFIX -#error "PREFIX not defined" -#endif - typedef struct NDOFPlatformInfo { Display *display; Window window; diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 3578ae8619f..aea5b5156d9 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -455,6 +455,7 @@ GHOST_WindowX11( XFlush(m_display); } +#ifdef WITH_X11_XINPUT /* Dummy function to get around IO Handler exiting if device invalid Basically it will not crash blender now if you have a X device that @@ -495,7 +496,6 @@ static bool match_token(const char *haystack, const char *needle) return FALSE; } -#ifdef WITH_X11_XINPUT /* Determining if an X device is a Tablet style device is an imperfect science. ** We rely on common conventions around device names as well as the type reported From d8e6dd705fbf7d98043e8a210bb49d6903792872 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 07:34:44 +0000 Subject: [PATCH 092/261] fix [#26607] blender won't duplicate or assign new drivers on duplication --- source/blender/blenkernel/BKE_animsys.h | 3 +++ source/blender/blenkernel/intern/anim_sys.c | 26 +++++++++++++++++++ source/blender/editors/object/object_add.c | 4 +++ .../blender/editors/object/object_relations.c | 5 +++- source/blender/makesdna/DNA_anim_types.h | 2 +- 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index a469d05ee26..348b967f9c4 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -72,6 +72,9 @@ void BKE_copy_animdata_id_action(struct ID *id); /* Make Local */ void BKE_animdata_make_local(struct AnimData *adt); +/* Re-Assign ID's */ +void BKE_relink_animdata(struct AnimData *adt); + /* ************************************* */ /* KeyingSets API */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 16269c3f66f..b4adaa0ab07 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -282,6 +282,32 @@ void BKE_animdata_make_local(AnimData *adt) make_local_strips(&nlt->strips); } +void BKE_relink_animdata(struct AnimData *adt) +{ + /* 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) { + dtar->id= dtar->id->newid; + } + } + DRIVER_TARGETS_LOOPER_END + } + } + } +} + /* Sub-ID Regrouping ------------------------------------------- */ /* helper heuristic for determining if a path is compatible with the basepath diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 2463e17d49f..289a66a1484 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -868,6 +868,10 @@ static void copy_object_set_idnew(bContext *C, int dupflag) } } modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL); + + if(ob->adt) + BKE_relink_animdata(ob->adt); + ID_NEW(ob->parent); ID_NEW(ob->proxy); ID_NEW(ob->proxy_group); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 7938096c2a6..eccc826f01f 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1412,7 +1412,10 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) } } modifiers_foreachObjectLink(base->object, single_object_users__forwardModifierLinks, NULL); - + + if(ob->adt) + BKE_relink_animdata(ob->adt); + ID_NEW(ob->parent); } } diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 31e02ff1877..4b649031f97 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -261,7 +261,7 @@ typedef enum eFMod_Stepped_Flags { * Defines how to access a dependency needed for a driver variable. */ typedef struct DriverTarget { - ID *id; /* ID-block which owns the target */ + ID *id; /* ID-block which owns the target, no user count */ char *rna_path; /* RNA path defining the setting to use (for DVAR_TYPE_SINGLE_PROP) */ From 8b6b5341a55541110684e5272f8856559b89337f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 08:43:41 +0000 Subject: [PATCH 093/261] move object re-linking into a function. --- source/blender/blenkernel/BKE_object.h | 2 ++ source/blender/blenkernel/intern/object.c | 29 +++++++++++++++++++ source/blender/editors/object/object_add.c | 23 +-------------- .../blender/editors/object/object_relations.c | 22 +------------- 4 files changed, 33 insertions(+), 43 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 065810089f1..cacfa702f7f 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -143,6 +143,8 @@ void object_camera_matrix( float winmat[][4], struct rctf *viewplane, float *clipsta, float *clipend, float *lens, float *ycor, float *viewdx, float *viewdy); +void object_relink(struct Object *ob); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 9f2de5be84a..0348d188a7d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3082,3 +3082,32 @@ int object_is_modified(Scene *scene, Object *ob) return flag; } + +static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), ID **idpoin) +{ + /* this is copied from ID_NEW; it might be better to have a macro */ + if(*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid; +} + +void object_relink(Object *ob) +{ + if(ob->id.lib) + return; + + relink_constraints(&ob->constraints); + if (ob->pose){ + bPoseChannel *chan; + for (chan = ob->pose->chanbase.first; chan; chan=chan->next){ + relink_constraints(&chan->constraints); + } + } + modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL); + + if(ob->adt) + BKE_relink_animdata(ob->adt); + + ID_NEW(ob->parent); + + ID_NEW(ob->proxy); + ID_NEW(ob->proxy_group); +} diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 289a66a1484..f630b05d8f2 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -843,13 +843,6 @@ void OBJECT_OT_delete(wmOperatorType *ot) /**************************** Copy Utilities ******************************/ -static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), - ID **idpoin) -{ - /* this is copied from ID_NEW; it might be better to have a macro */ - if(*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid; -} - /* after copying objects, copied data should get new pointers */ static void copy_object_set_idnew(bContext *C, int dupflag) { @@ -860,21 +853,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) /* XXX check object pointers */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - relink_constraints(&ob->constraints); - if (ob->pose){ - bPoseChannel *chan; - for (chan = ob->pose->chanbase.first; chan; chan=chan->next){ - relink_constraints(&chan->constraints); - } - } - modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL); - - if(ob->adt) - BKE_relink_animdata(ob->adt); - - ID_NEW(ob->parent); - ID_NEW(ob->proxy); - ID_NEW(ob->proxy_group); + object_relink(ob); } CTX_DATA_END; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index eccc826f01f..1aa6de18bad 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1366,11 +1366,6 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot) /**************************** Make Single User ********************************/ -static void single_object_users__forwardModifierLinks(void *UNUSED(userData), Object *UNUSED(ob), Object **obpoin) -{ - ID_NEW(*obpoin); -} - static void single_object_users(Scene *scene, View3D *v3d, int flag) { Base *base; @@ -1402,22 +1397,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) /* object pointers */ for(base= FIRSTBASE; base; base= base->next) { - ob= base->object; - if(ob->id.lib==NULL) { - relink_constraints(&base->object->constraints); - if (base->object->pose){ - bPoseChannel *chan; - for (chan = base->object->pose->chanbase.first; chan; chan=chan->next){ - relink_constraints(&chan->constraints); - } - } - modifiers_foreachObjectLink(base->object, single_object_users__forwardModifierLinks, NULL); - - if(ob->adt) - BKE_relink_animdata(ob->adt); - - ID_NEW(ob->parent); - } + object_relink(base->object); } set_sca_new_poins(); From 5f5d091554141ae886a6f5b25422f1b8d8a0fc95 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 25 Mar 2011 08:47:41 +0000 Subject: [PATCH 094/261] Switched the fluid fix from yesterday into using the existing compatible eulers function rather than a custom function. Thanks for the tip Campbell! --- .../blender/editors/physics/physics_fluid.c | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 67d2184dc69..c4c30df87ed 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -349,16 +349,6 @@ static void free_all_fluidobject_channels(ListBase *fobjects) } } -static void continuous_rotation(float *rot, const float *old_rot) -{ - *rot += (int)(*old_rot/360.f)*360.f; - - if(*old_rot - *rot > 180.f) - *rot += 360.f; - else if(*old_rot - *rot < -180.f) - *rot -= 360.f; -} - static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), FluidsimSettings *domainSettings, FluidAnimChannels *channels, ListBase *fobjects) { Scene *scene = CTX_data_scene(C); @@ -453,22 +443,20 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); float active= (float)(fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE); - float rot_d[3], rot_360[3] = {360.f, 360.f, 360.f}; + float rot_d[3], old_rot[3] = {0.f, 0.f, 0.f}; if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) continue; /* init euler rotation values and convert to elbeem format */ /* get the rotation from ob->obmat rather than ob->rot to account for parent animations */ - mat4_to_eul(rot_d, ob->obmat); - mul_v3_fl(rot_d, -180.f/M_PI); if(i) { - /* the rotation values have to be continuous, so compare with previous rotation and adjust accordingly */ - /* note: the unfortunate side effect of this is that it filters out rotations of over 180 degrees/frame */ - continuous_rotation(rot_d, fobj->Rotation + 4*(i-1)); - continuous_rotation(rot_d+1, fobj->Rotation + 4*(i-1)+1); - continuous_rotation(rot_d+2, fobj->Rotation + 4*(i-1)+2); + copy_v3_v3(old_rot, fobj->Rotation + 4*(i-1)); + mul_v3_fl(old_rot, -M_PI/180.f); } + + mat4_to_compatible_eulO(rot_d, old_rot, 0, ob->obmat); + mul_v3_fl(rot_d, -180.f/M_PI); set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC); set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC); From c5c4b31d6b51b3a51855bc9adcde91564aa1a8c7 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Fri, 25 Mar 2011 09:52:36 +0000 Subject: [PATCH 095/261] Mostly formatting commit, small elaboration in extra handling API (take pointer to importer). --- source/blender/collada/DocumentImporter.cpp | 1691 +++++++++---------- source/blender/collada/DocumentImporter.h | 47 +- source/blender/collada/ExtraHandler.cpp | 10 +- source/blender/collada/ExtraHandler.h | 8 +- 4 files changed, 867 insertions(+), 889 deletions(-) diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 49992a6989f..77c2fc971ac 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -92,617 +92,579 @@ // creates empties for each imported bone on layer 2, for debugging // #define ARMATURE_TEST -/** Class that needs to be implemented by a writer. - IMPORTANT: The write functions are called in arbitrary order.*/ -/* -private: - std::string mFilename; +DocumentImporter::DocumentImporter(bContext *C, const char *filename) : + mImportStage(General), + mFilename(filename), + mContext(C), + armature_importer(&unit_converter, &mesh_importer, &anim_importer, CTX_data_scene(C)), + mesh_importer(&unit_converter, &armature_importer, CTX_data_scene(C)), + anim_importer(&unit_converter, &armature_importer, CTX_data_scene(C)) +{} + +DocumentImporter::~DocumentImporter() {} + +bool DocumentImporter::import() +{ + /** TODO Add error handler (implement COLLADASaxFWL::IErrorHandler */ + COLLADASaxFWL::Loader loader; + COLLADAFW::Root root(&loader, this); + ExtraHandler *ehandler = new ExtraHandler(this); - bContext *mContext; - - UnitConverter unit_converter; - ArmatureImporter armature_importer; - MeshImporter mesh_importer; - AnimationImporter anim_importer; - - 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 material_texture_mapping_map; - std::map object_map; - std::map node_map; - std::vector vscenes; - std::vector libnode_ob; - - std::map root_map; - */ - // find root joint by child joint uid, for bone tree evaluation during resampling - - // animation - // std::map > uid_fcurve_map; - // Nodes don't share AnimationLists (Arystan) - // std::map uid_animated_map; // AnimationList->uniqueId to AnimatedObject map - -//public: - - /** Constructor. */ - DocumentImporter::DocumentImporter(bContext *C, const char *filename) : - mImportStage(General), - mFilename(filename), - mContext(C), - armature_importer(&unit_converter, &mesh_importer, &anim_importer, CTX_data_scene(C)), - mesh_importer(&unit_converter, &armature_importer, CTX_data_scene(C)), - anim_importer(&unit_converter, &armature_importer, CTX_data_scene(C)) - {} - - /** Destructor. */ - DocumentImporter::~DocumentImporter() {} - - bool DocumentImporter::import() - { - /** TODO Add error handler (implement COLLADASaxFWL::IErrorHandler */ - COLLADASaxFWL::Loader loader; - COLLADAFW::Root root(&loader, this); - ExtraHandler *ehandler = new ExtraHandler(); - - loader.registerExtraDataCallbackHandler(ehandler); - - - if (!root.loadDocument(mFilename)) - return false; - - /** TODO set up scene graph and such here */ - - mImportStage = Controller; - - COLLADASaxFWL::Loader loader2; - COLLADAFW::Root root2(&loader2, this); - - if (!root2.loadDocument(mFilename)) - return false; - - - delete ehandler; - - return true; - } + loader.registerExtraDataCallbackHandler(ehandler); - void DocumentImporter::cancel(const COLLADAFW::String& errorMessage) - { - // TODO: if possible show error info - // - // Should we get rid of invisible Meshes that were created so far - // or maybe create objects at coordinate space origin? - // - // The latter sounds better. - } - void DocumentImporter::start(){} + if (!root.loadDocument(mFilename)) + return false; + + /** TODO set up scene graph and such here */ + + mImportStage = Controller; + + COLLADASaxFWL::Loader loader2; + COLLADAFW::Root root2(&loader2, this); + + if (!root2.loadDocument(mFilename)) + return false; + + + delete ehandler; - /** This method is called after the last write* method. No other methods will be called after this.*/ - void DocumentImporter::finish() - { - if(mImportStage!=General) - return; - - /** TODO Break up and put into 2-pass parsing of DAE */ - std::vector::iterator it; - for (it = vscenes.begin(); it != vscenes.end(); it++) { - PointerRNA sceneptr, unit_settings; - PropertyRNA *system, *scale; - // TODO: create a new scene except the selected - use current blender scene for it - Scene *sce = CTX_data_scene(mContext); - - // for scene unit settings: system, scale_length - RNA_id_pointer_create(&sce->id, &sceneptr); - unit_settings = RNA_pointer_get(&sceneptr, "unit_settings"); - system = RNA_struct_find_property(&unit_settings, "system"); - scale = RNA_struct_find_property(&unit_settings, "scale_length"); - - switch(unit_converter.isMetricSystem()) { - case UnitConverter::Metric: - RNA_property_enum_set(&unit_settings, system, USER_UNIT_METRIC); - break; - case UnitConverter::Imperial: - RNA_property_enum_set(&unit_settings, system, USER_UNIT_IMPERIAL); - break; - default: - RNA_property_enum_set(&unit_settings, system, USER_UNIT_NONE); - break; - } - RNA_property_float_set(&unit_settings, scale, unit_converter.getLinearMeter()); - - const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes(); + return true; +} - for (unsigned int i = 0; i < roots.getCount(); i++) { - write_node(roots[i], NULL, sce, NULL, false); - } +void DocumentImporter::cancel(const COLLADAFW::String& errorMessage) +{ + // TODO: if possible show error info + // + // Should we get rid of invisible Meshes that were created so far + // or maybe create objects at coordinate space origin? + // + // The latter sounds better. +} + +void DocumentImporter::start(){} + +void DocumentImporter::finish() +{ + if(mImportStage!=General) + return; + + /** TODO Break up and put into 2-pass parsing of DAE */ + std::vector::iterator it; + for (it = vscenes.begin(); it != vscenes.end(); it++) { + PointerRNA sceneptr, unit_settings; + PropertyRNA *system, *scale; + // TODO: create a new scene except the selected - use current blender scene for it + Scene *sce = CTX_data_scene(mContext); + + // for scene unit settings: system, scale_length + RNA_id_pointer_create(&sce->id, &sceneptr); + unit_settings = RNA_pointer_get(&sceneptr, "unit_settings"); + system = RNA_struct_find_property(&unit_settings, "system"); + scale = RNA_struct_find_property(&unit_settings, "scale_length"); + + switch(unit_converter.isMetricSystem()) { + case UnitConverter::Metric: + RNA_property_enum_set(&unit_settings, system, USER_UNIT_METRIC); + break; + case UnitConverter::Imperial: + RNA_property_enum_set(&unit_settings, system, USER_UNIT_IMPERIAL); + break; + default: + RNA_property_enum_set(&unit_settings, system, USER_UNIT_NONE); + break; } + RNA_property_float_set(&unit_settings, scale, unit_converter.getLinearMeter()); + + const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes(); - armature_importer.make_armatures(mContext); + for (unsigned int i = 0; i < roots.getCount(); i++) { + write_node(roots[i], NULL, sce, NULL, false); + } + } + + armature_importer.make_armatures(mContext); #if 0 - armature_importer.fix_animation(); + armature_importer.fix_animation(); #endif - for (std::vector::iterator it = vscenes.begin(); it != vscenes.end(); it++) { - const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes(); + for (std::vector::iterator it = vscenes.begin(); it != vscenes.end(); it++) { + const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes(); - for (unsigned int i = 0; i < roots.getCount(); i++) - translate_anim_recursive(roots[i],NULL,NULL); - } - - if (libnode_ob.size()) { - Scene *sce = CTX_data_scene(mContext); - - fprintf(stderr, "got %d library nodes to free\n", (int)libnode_ob.size()); - // free all library_nodes - std::vector::iterator it; - for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) { - Object *ob = *it; - - Base *base = object_in_scene(ob, sce); - if (base) { - BLI_remlink(&sce->base, base); - free_libblock_us(&G.main->object, base->object); - if (sce->basact==base) - sce->basact= NULL; - MEM_freeN(base); - } - } - libnode_ob.clear(); - - DAG_scene_sort(CTX_data_main(mContext), sce); - DAG_ids_flush_update(CTX_data_main(mContext), 0); - } + for (unsigned int i = 0; i < roots.getCount(); i++) + translate_anim_recursive(roots[i],NULL,NULL); } + if (libnode_ob.size()) { + Scene *sce = CTX_data_scene(mContext); - void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW::Node *par = NULL, Object *parob = NULL) - { - if (par && par->getType() == COLLADAFW::Node::JOINT) { - // par is root if there's no corresp. key in root_map - if (root_map.find(par->getUniqueId()) == root_map.end()) - root_map[node->getUniqueId()] = par; - else - root_map[node->getUniqueId()] = root_map[par->getUniqueId()]; - } + fprintf(stderr, "got %d library nodes to free\n", (int)libnode_ob.size()); + // free all library_nodes + std::vector::iterator it; + for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) { + Object *ob = *it; - COLLADAFW::Transformation::TransformationType types[] = { - COLLADAFW::Transformation::ROTATE, - COLLADAFW::Transformation::SCALE, - COLLADAFW::Transformation::TRANSLATE, - COLLADAFW::Transformation::MATRIX - }; - - unsigned int i; - Object *ob; - - for (i = 0; i < 4; i++) - ob = anim_importer.translate_animation(node, object_map, root_map, types[i]); - - COLLADAFW::NodePointerArray &children = node->getChildNodes(); - for (i = 0; i < children.getCount(); i++) { - translate_anim_recursive(children[i], node, ob); - } - } - - /** When this method is called, the writer must write the global document asset. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeGlobalAsset ( const COLLADAFW::FileInfo* asset ) - { - unit_converter.read_asset(asset); - - return true; - } - - /** When this method is called, the writer must write the scene. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeScene ( const COLLADAFW::Scene* scene ) - { - // XXX could store the scene id, but do nothing for now - return true; - } - Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce) - { - const COLLADAFW::UniqueId& cam_uid = camera->getInstanciatedObjectId(); - if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) { - fprintf(stderr, "Couldn't find camera by UID.\n"); - return NULL; - } - Object *ob = add_object(sce, OB_CAMERA); - Camera *cam = uid_camera_map[cam_uid]; - Camera *old_cam = (Camera*)ob->data; - ob->data = cam; - old_cam->id.us--; - if (old_cam->id.us == 0) - free_libblock(&G.main->camera, old_cam); - return ob; - } - - Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce) - { - const COLLADAFW::UniqueId& lamp_uid = lamp->getInstanciatedObjectId(); - if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) { - fprintf(stderr, "Couldn't find lamp by UID. \n"); - return NULL; - } - Object *ob = add_object(sce, OB_LAMP); - Lamp *la = uid_lamp_map[lamp_uid]; - Lamp *old_lamp = (Lamp*)ob->data; - ob->data = la; - old_lamp->id.us--; - if (old_lamp->id.us == 0) - free_libblock(&G.main->lamp, old_lamp); - return ob; - } - - Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, bool is_library_node) - { - Object *obn = copy_object(source_ob); - obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - scene_add_base(sce, obn); - - if (instance_node) { - anim_importer.read_node_transform(instance_node, obn); - // if we also have a source_node (always ;), take its - // transformation matrix and apply it to the newly instantiated - // object to account for node hierarchy transforms in - // .dae - if(source_node) { - COLLADABU::Math::Matrix4 mat4 = source_node->getTransformationMatrix(); - COLLADABU::Math::Matrix4 bmat4 = mat4.transpose(); // transpose to get blender row-major order - float mat[4][4]; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - mat[i][j] = bmat4[i][j]; - } - } - // calc new matrix and apply - mul_m4_m4m4(obn->obmat, mat, obn->obmat); - object_apply_mat4(obn, obn->obmat, 0, 0); + Base *base = object_in_scene(ob, sce); + if (base) { + BLI_remlink(&sce->base, base); + free_libblock_us(&G.main->object, base->object); + if (sce->basact==base) + sce->basact= NULL; + MEM_freeN(base); } } - else { - anim_importer.read_node_transform(source_node, obn); - } + libnode_ob.clear(); DAG_scene_sort(CTX_data_main(mContext), sce); DAG_ids_flush_update(CTX_data_main(mContext), 0); - - COLLADAFW::NodePointerArray &children = source_node->getChildNodes(); - if (children.getCount()) { - for (unsigned int i = 0; i < children.getCount(); i++) { - COLLADAFW::Node *child_node = children[i]; - const COLLADAFW::UniqueId& child_id = child_node->getUniqueId(); - if (object_map.find(child_id) == object_map.end()) - continue; - COLLADAFW::InstanceNodePointerArray &inodes = child_node->getInstanceNodes(); - Object *new_child = NULL; - if (inodes.getCount()) { // \todo loop through instance nodes - const COLLADAFW::UniqueId& id = inodes[0]->getInstanciatedObjectId(); - new_child = create_instance_node(object_map[id], node_map[id], child_node, sce, is_library_node); - } - else { - new_child = create_instance_node(object_map[child_id], child_node, NULL, sce, is_library_node); - } - bc_set_parent(new_child, obn, mContext, true); - - if (is_library_node) - libnode_ob.push_back(new_child); - } - } - - // when we have an instance_node, don't return the object, because otherwise - // its correct location gets overwritten in write_node(). Fixes bug #26012. - if(instance_node) return NULL; - else return obn; } - - void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node) - { - Object *ob = NULL; - bool is_joint = node->getType() == COLLADAFW::Node::JOINT; +} - if (is_joint) { - armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par); + +void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW::Node *par = NULL, Object *parob = NULL) +{ + if (par && par->getType() == COLLADAFW::Node::JOINT) { + // par is root if there's no corresp. key in root_map + if (root_map.find(par->getUniqueId()) == root_map.end()) + root_map[node->getUniqueId()] = par; + else + root_map[node->getUniqueId()] = root_map[par->getUniqueId()]; + } + + COLLADAFW::Transformation::TransformationType types[] = { + COLLADAFW::Transformation::ROTATE, + COLLADAFW::Transformation::SCALE, + COLLADAFW::Transformation::TRANSLATE, + COLLADAFW::Transformation::MATRIX + }; + + unsigned int i; + Object *ob; + + for (i = 0; i < 4; i++) + ob = anim_importer.translate_animation(node, object_map, root_map, types[i]); + + COLLADAFW::NodePointerArray &children = node->getChildNodes(); + for (i = 0; i < children.getCount(); i++) { + translate_anim_recursive(children[i], node, ob); + } +} + +/** When this method is called, the writer must write the global document asset. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeGlobalAsset ( const COLLADAFW::FileInfo* asset ) +{ + unit_converter.read_asset(asset); + + return true; +} + +/** When this method is called, the writer must write the scene. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeScene ( const COLLADAFW::Scene* scene ) +{ + // XXX could store the scene id, but do nothing for now + return true; +} +Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce) +{ + const COLLADAFW::UniqueId& cam_uid = camera->getInstanciatedObjectId(); + if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) { + fprintf(stderr, "Couldn't find camera by UID.\n"); + return NULL; + } + Object *ob = add_object(sce, OB_CAMERA); + Camera *cam = uid_camera_map[cam_uid]; + Camera *old_cam = (Camera*)ob->data; + ob->data = cam; + old_cam->id.us--; + if (old_cam->id.us == 0) + free_libblock(&G.main->camera, old_cam); + return ob; +} + +Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce) +{ + const COLLADAFW::UniqueId& lamp_uid = lamp->getInstanciatedObjectId(); + if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) { + fprintf(stderr, "Couldn't find lamp by UID. \n"); + return NULL; + } + Object *ob = add_object(sce, OB_LAMP); + Lamp *la = uid_lamp_map[lamp_uid]; + Lamp *old_lamp = (Lamp*)ob->data; + ob->data = la; + old_lamp->id.us--; + if (old_lamp->id.us == 0) + free_libblock(&G.main->lamp, old_lamp); + return ob; +} + +Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, bool is_library_node) +{ + Object *obn = copy_object(source_ob); + obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + scene_add_base(sce, obn); + + if (instance_node) { + anim_importer.read_node_transform(instance_node, obn); + // if we also have a source_node (always ;), take its + // transformation matrix and apply it to the newly instantiated + // object to account for node hierarchy transforms in + // .dae + if(source_node) { + COLLADABU::Math::Matrix4 mat4 = source_node->getTransformationMatrix(); + COLLADABU::Math::Matrix4 bmat4 = mat4.transpose(); // transpose to get blender row-major order + float mat[4][4]; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + mat[i][j] = bmat4[i][j]; + } + } + // calc new matrix and apply + mul_m4_m4m4(obn->obmat, mat, obn->obmat); + object_apply_mat4(obn, obn->obmat, 0, 0); } - else { - COLLADAFW::InstanceGeometryPointerArray &geom = node->getInstanceGeometries(); - COLLADAFW::InstanceCameraPointerArray &camera = node->getInstanceCameras(); - COLLADAFW::InstanceLightPointerArray &lamp = node->getInstanceLights(); - COLLADAFW::InstanceControllerPointerArray &controller = node->getInstanceControllers(); - COLLADAFW::InstanceNodePointerArray &inst_node = node->getInstanceNodes(); - int geom_done = 0; - int camera_done = 0; - int lamp_done = 0; - int controller_done = 0; - int inst_done = 0; + } + else { + anim_importer.read_node_transform(source_node, obn); + } - // XXX linking object with the first , though a node may have more of them... - // maybe join multiple meshes into 1, and link object with it? not sure... - // - while (geom_done < geom.getCount()) { - ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map, - material_texture_mapping_map); - ++geom_done; - } - while (camera_done < camera.getCount()) { - ob = create_camera_object(camera[camera_done], sce); - ++camera_done; - } - while (lamp_done < lamp.getCount()) { - ob = create_lamp_object(lamp[lamp_done], sce); - ++lamp_done; - } - while (controller_done < controller.getCount()) { - COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry*)controller[controller_done]; - ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map); - ++controller_done; - } - // XXX instance_node is not supported yet - while (inst_done < inst_node.getCount()) { - const COLLADAFW::UniqueId& node_id = inst_node[inst_done]->getInstanciatedObjectId(); - if (object_map.find(node_id) == object_map.end()) { - fprintf(stderr, "Cannot find node to instanciate.\n"); - ob = NULL; - } - else { - Object *source_ob = object_map[node_id]; - COLLADAFW::Node *source_node = node_map[node_id]; + DAG_scene_sort(CTX_data_main(mContext), sce); + DAG_ids_flush_update(CTX_data_main(mContext), 0); - ob = create_instance_node(source_ob, source_node, node, sce, is_library_node); - } - ++inst_done; + COLLADAFW::NodePointerArray &children = source_node->getChildNodes(); + if (children.getCount()) { + for (unsigned int i = 0; i < children.getCount(); i++) { + COLLADAFW::Node *child_node = children[i]; + const COLLADAFW::UniqueId& child_id = child_node->getUniqueId(); + if (object_map.find(child_id) == object_map.end()) + continue; + COLLADAFW::InstanceNodePointerArray &inodes = child_node->getInstanceNodes(); + Object *new_child = NULL; + if (inodes.getCount()) { // \todo loop through instance nodes + const COLLADAFW::UniqueId& id = inodes[0]->getInstanciatedObjectId(); + new_child = create_instance_node(object_map[id], node_map[id], child_node, sce, is_library_node); } - // if node is empty - create empty object - // XXX empty node may not mean it is empty object, not sure about this - if ( (geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) { - ob = add_object(sce, OB_EMPTY); + else { + new_child = create_instance_node(object_map[child_id], child_node, NULL, sce, is_library_node); } - - // check if object is not NULL - if (!ob) return; - - rename_id(&ob->id, (char*)node->getOriginalId().c_str()); - - object_map[node->getUniqueId()] = ob; - node_map[node->getUniqueId()] = node; + bc_set_parent(new_child, obn, mContext, true); if (is_library_node) - libnode_ob.push_back(ob); - } - - anim_importer.read_node_transform(node, ob); // overwrites location set earlier - - if (!is_joint) { - // if par was given make this object child of the previous - if (par && ob) - bc_set_parent(ob, par, mContext); - } - - // if node has child nodes write them - COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes(); - for (unsigned int i = 0; i < child_nodes.getCount(); i++) { - write_node(child_nodes[i], node, sce, ob, is_library_node); + libnode_ob.push_back(new_child); } } - /** When this method is called, the writer must write the entire visual scene. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* visualScene ) - { - if(mImportStage!=General) - return true; - - // this method called on post process after writeGeometry, writeMaterial, etc. + // when we have an instance_node, don't return the object, because otherwise + // its correct location gets overwritten in write_node(). Fixes bug #26012. + if(instance_node) return NULL; + else return obn; +} - // for each in : - // create an Object - // if Mesh (previously created in writeGeometry) to which corresponds exists, link Object with that mesh +void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node) +{ + Object *ob = NULL; + bool is_joint = node->getType() == COLLADAFW::Node::JOINT; - // update: since we cannot link a Mesh with Object in - // writeGeometry because does not reference , - // we link Objects with Meshes here + if (is_joint) { + armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par); + } + else { + COLLADAFW::InstanceGeometryPointerArray &geom = node->getInstanceGeometries(); + COLLADAFW::InstanceCameraPointerArray &camera = node->getInstanceCameras(); + COLLADAFW::InstanceLightPointerArray &lamp = node->getInstanceLights(); + COLLADAFW::InstanceControllerPointerArray &controller = node->getInstanceControllers(); + COLLADAFW::InstanceNodePointerArray &inst_node = node->getInstanceNodes(); + int geom_done = 0; + int camera_done = 0; + int lamp_done = 0; + int controller_done = 0; + int inst_done = 0; - vscenes.push_back(visualScene); + // XXX linking object with the first , though a node may have more of them... + // maybe join multiple meshes into 1, and link object with it? not sure... + // + while (geom_done < geom.getCount()) { + ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map, + material_texture_mapping_map); + ++geom_done; + } + while (camera_done < camera.getCount()) { + ob = create_camera_object(camera[camera_done], sce); + ++camera_done; + } + while (lamp_done < lamp.getCount()) { + ob = create_lamp_object(lamp[lamp_done], sce); + ++lamp_done; + } + while (controller_done < controller.getCount()) { + COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry*)controller[controller_done]; + ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map); + ++controller_done; + } + // XXX instance_node is not supported yet + while (inst_done < inst_node.getCount()) { + const COLLADAFW::UniqueId& node_id = inst_node[inst_done]->getInstanciatedObjectId(); + if (object_map.find(node_id) == object_map.end()) { + fprintf(stderr, "Cannot find node to instanciate.\n"); + ob = NULL; + } + else { + Object *source_ob = object_map[node_id]; + COLLADAFW::Node *source_node = node_map[node_id]; + + ob = create_instance_node(source_ob, source_node, node, sce, is_library_node); + } + ++inst_done; + } + // if node is empty - create empty object + // XXX empty node may not mean it is empty object, not sure about this + if ( (geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) { + ob = add_object(sce, OB_EMPTY); + } - return true; - } - - /** When this method is called, the writer must handle all nodes contained in the - library nodes. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeLibraryNodes ( const COLLADAFW::LibraryNodes* libraryNodes ) - { - if(mImportStage!=General) - return true; - - Scene *sce = CTX_data_scene(mContext); - - const COLLADAFW::NodePointerArray& nodes = libraryNodes->getNodes(); - - for (unsigned int i = 0; i < nodes.getCount(); i++) { - write_node(nodes[i], NULL, sce, NULL, true); - } - - return true; - } - - /** When this method is called, the writer must write the geometry. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeGeometry ( const COLLADAFW::Geometry* geom ) - { - if(mImportStage!=General) - return true; - - return mesh_importer.write_geometry(geom); - } - - /** When this method is called, the writer must write the material. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat ) - { - if(mImportStage!=General) - return true; - - const std::string& str_mat_id = cmat->getOriginalId(); - Material *ma = add_material((char*)str_mat_id.c_str()); - - this->uid_effect_map[cmat->getInstantiatedEffect()] = ma; - this->uid_material_map[cmat->getUniqueId()] = ma; + // check if object is not NULL + if (!ob) return; + rename_id(&ob->id, (char*)node->getOriginalId().c_str()); + + object_map[node->getUniqueId()] = ob; + node_map[node->getUniqueId()] = node; + + if (is_library_node) + libnode_ob.push_back(ob); + } + + anim_importer.read_node_transform(node, ob); // overwrites location set earlier + + if (!is_joint) { + // if par was given make this object child of the previous + if (par && ob) + bc_set_parent(ob, par, mContext); + } + + // if node has child nodes write them + COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes(); + for (unsigned int i = 0; i < child_nodes.getCount(); i++) { + write_node(child_nodes[i], node, sce, ob, is_library_node); + } +} + +/** When this method is called, the writer must write the entire visual scene. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* visualScene ) +{ + if(mImportStage!=General) return true; + + // this method called on post process after writeGeometry, writeMaterial, etc. + + // for each in : + // create an Object + // if Mesh (previously created in writeGeometry) to which corresponds exists, link Object with that mesh + + // update: since we cannot link a Mesh with Object in + // writeGeometry because does not reference , + // we link Objects with Meshes here + + vscenes.push_back(visualScene); + + return true; +} + +/** When this method is called, the writer must handle all nodes contained in the + library nodes. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeLibraryNodes ( const COLLADAFW::LibraryNodes* libraryNodes ) +{ + if(mImportStage!=General) + return true; + + Scene *sce = CTX_data_scene(mContext); + + const COLLADAFW::NodePointerArray& nodes = libraryNodes->getNodes(); + + for (unsigned int i = 0; i < nodes.getCount(); i++) { + write_node(nodes[i], NULL, sce, NULL, true); + } + + return true; +} + +/** When this method is called, the writer must write the geometry. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeGeometry ( const COLLADAFW::Geometry* geom ) +{ + if(mImportStage!=General) + return true; + + return mesh_importer.write_geometry(geom); +} + +/** When this method is called, the writer must write the material. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat ) +{ + if(mImportStage!=General) + return true; + + const std::string& str_mat_id = cmat->getOriginalId(); + Material *ma = add_material((char*)str_mat_id.c_str()); + + this->uid_effect_map[cmat->getInstantiatedEffect()] = ma; + this->uid_material_map[cmat->getUniqueId()] = ma; + + return true; +} + +// create mtex, create texture, set texture image +MTex* DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::Texture &ctex, Material *ma, + int i, TexIndexTextureArrayMap &texindex_texarray_map) +{ + COLLADAFW::SamplerPointerArray& samp_array = ef->getSamplerPointerArray(); + COLLADAFW::Sampler *sampler = samp_array[ctex.getSamplerId()]; + + const COLLADAFW::UniqueId& ima_uid = sampler->getSourceImage(); + + if (uid_image_map.find(ima_uid) == uid_image_map.end()) { + fprintf(stderr, "Couldn't find an image by UID.\n"); + return NULL; } - // create mtex, create texture, set texture image - MTex* DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::Texture &ctex, Material *ma, - int i, TexIndexTextureArrayMap &texindex_texarray_map) - { - COLLADAFW::SamplerPointerArray& samp_array = ef->getSamplerPointerArray(); - COLLADAFW::Sampler *sampler = samp_array[ctex.getSamplerId()]; - - const COLLADAFW::UniqueId& ima_uid = sampler->getSourceImage(); - - if (uid_image_map.find(ima_uid) == uid_image_map.end()) { - fprintf(stderr, "Couldn't find an image by UID.\n"); - return NULL; - } - - ma->mtex[i] = add_mtex(); - ma->mtex[i]->texco = TEXCO_UV; - ma->mtex[i]->tex = add_texture("Texture"); - ma->mtex[i]->tex->type = TEX_IMAGE; - ma->mtex[i]->tex->imaflag &= ~TEX_USEALPHA; - ma->mtex[i]->tex->ima = uid_image_map[ima_uid]; - - texindex_texarray_map[ctex.getTextureMapId()].push_back(ma->mtex[i]); - - return ma->mtex[i]; - } + ma->mtex[i] = add_mtex(); + ma->mtex[i]->texco = TEXCO_UV; + ma->mtex[i]->tex = add_texture("Texture"); + ma->mtex[i]->tex->type = TEX_IMAGE; + ma->mtex[i]->tex->imaflag &= ~TEX_USEALPHA; + ma->mtex[i]->tex->ima = uid_image_map[ima_uid]; - void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Material *ma) - { - COLLADAFW::EffectCommon::ShaderType shader = ef->getShaderType(); - - // blinn - if (shader == COLLADAFW::EffectCommon::SHADER_BLINN) { - ma->spec_shader = MA_SPEC_BLINN; - ma->spec = ef->getShininess().getFloatValue(); + texindex_texarray_map[ctex.getTextureMapId()].push_back(ma->mtex[i]); + + return ma->mtex[i]; +} + +void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Material *ma) +{ + COLLADAFW::EffectCommon::ShaderType shader = ef->getShaderType(); + + // blinn + if (shader == COLLADAFW::EffectCommon::SHADER_BLINN) { + ma->spec_shader = MA_SPEC_BLINN; + ma->spec = ef->getShininess().getFloatValue(); + } + // phong + else if (shader == COLLADAFW::EffectCommon::SHADER_PHONG) { + ma->spec_shader = MA_SPEC_PHONG; + ma->har = ef->getShininess().getFloatValue(); + } + // lambert + else if (shader == COLLADAFW::EffectCommon::SHADER_LAMBERT) { + ma->diff_shader = MA_DIFF_LAMBERT; + } + // default - lambert + else { + ma->diff_shader = MA_DIFF_LAMBERT; + fprintf(stderr, "Current shader type is not supported, default to lambert.\n"); + } + // reflectivity + ma->ray_mirror = ef->getReflectivity().getFloatValue(); + // index of refraction + ma->ang = ef->getIndexOfRefraction().getFloatValue(); + + int i = 0; + COLLADAFW::Color col; + MTex *mtex = NULL; + TexIndexTextureArrayMap texindex_texarray_map; + + // DIFFUSE + // color + if (ef->getDiffuse().isColor()) { + col = ef->getDiffuse().getColor(); + ma->r = col.getRed(); + ma->g = col.getGreen(); + ma->b = col.getBlue(); + } + // texture + else if (ef->getDiffuse().isTexture()) { + COLLADAFW::Texture ctex = ef->getDiffuse().getTexture(); + mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); + if (mtex != NULL) { + mtex->mapto = MAP_COL; + ma->texact = (int)i; + i++; } - // phong - else if (shader == COLLADAFW::EffectCommon::SHADER_PHONG) { - ma->spec_shader = MA_SPEC_PHONG; - ma->har = ef->getShininess().getFloatValue(); + } + // AMBIENT + // color + if (ef->getAmbient().isColor()) { + col = ef->getAmbient().getColor(); + ma->ambr = col.getRed(); + ma->ambg = col.getGreen(); + ma->ambb = col.getBlue(); + } + // texture + else if (ef->getAmbient().isTexture()) { + COLLADAFW::Texture ctex = ef->getAmbient().getTexture(); + mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); + if (mtex != NULL) { + mtex->mapto = MAP_AMB; + i++; } - // lambert - else if (shader == COLLADAFW::EffectCommon::SHADER_LAMBERT) { - ma->diff_shader = MA_DIFF_LAMBERT; + } + // SPECULAR + // color + if (ef->getSpecular().isColor()) { + col = ef->getSpecular().getColor(); + ma->specr = col.getRed(); + ma->specg = col.getGreen(); + ma->specb = col.getBlue(); + } + // texture + else if (ef->getSpecular().isTexture()) { + COLLADAFW::Texture ctex = ef->getSpecular().getTexture(); + mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); + if (mtex != NULL) { + mtex->mapto = MAP_SPEC; + i++; } - // default - lambert - else { - ma->diff_shader = MA_DIFF_LAMBERT; - fprintf(stderr, "Current shader type is not supported, default to lambert.\n"); + } + // REFLECTIVE + // color + if (ef->getReflective().isColor()) { + col = ef->getReflective().getColor(); + ma->mirr = col.getRed(); + ma->mirg = col.getGreen(); + ma->mirb = col.getBlue(); + } + // texture + else if (ef->getReflective().isTexture()) { + COLLADAFW::Texture ctex = ef->getReflective().getTexture(); + mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); + if (mtex != NULL) { + mtex->mapto = MAP_REF; + i++; } - // reflectivity - ma->ray_mirror = ef->getReflectivity().getFloatValue(); - // index of refraction - ma->ang = ef->getIndexOfRefraction().getFloatValue(); - - int i = 0; - COLLADAFW::Color col; - MTex *mtex = NULL; - TexIndexTextureArrayMap texindex_texarray_map; - - // DIFFUSE - // color - if (ef->getDiffuse().isColor()) { - col = ef->getDiffuse().getColor(); - ma->r = col.getRed(); - ma->g = col.getGreen(); - ma->b = col.getBlue(); + } + // EMISSION + // color + if (ef->getEmission().isColor()) { + // XXX there is no emission color in blender + // but I am not sure + } + // texture + else if (ef->getEmission().isTexture()) { + COLLADAFW::Texture ctex = ef->getEmission().getTexture(); + mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); + if (mtex != NULL) { + mtex->mapto = MAP_EMIT; + i++; } - // texture - else if (ef->getDiffuse().isTexture()) { - COLLADAFW::Texture ctex = ef->getDiffuse().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_COL; - ma->texact = (int)i; - i++; - } - } - // AMBIENT - // color - if (ef->getAmbient().isColor()) { - col = ef->getAmbient().getColor(); - ma->ambr = col.getRed(); - ma->ambg = col.getGreen(); - ma->ambb = col.getBlue(); - } - // texture - else if (ef->getAmbient().isTexture()) { - COLLADAFW::Texture ctex = ef->getAmbient().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_AMB; - i++; - } - } - // SPECULAR - // color - if (ef->getSpecular().isColor()) { - col = ef->getSpecular().getColor(); - ma->specr = col.getRed(); - ma->specg = col.getGreen(); - ma->specb = col.getBlue(); - } - // texture - else if (ef->getSpecular().isTexture()) { - COLLADAFW::Texture ctex = ef->getSpecular().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_SPEC; - i++; - } - } - // REFLECTIVE - // color - if (ef->getReflective().isColor()) { - col = ef->getReflective().getColor(); - ma->mirr = col.getRed(); - ma->mirg = col.getGreen(); - ma->mirb = col.getBlue(); - } - // texture - else if (ef->getReflective().isTexture()) { - COLLADAFW::Texture ctex = ef->getReflective().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_REF; - i++; - } - } - // EMISSION - // color - if (ef->getEmission().isColor()) { - // XXX there is no emission color in blender - // but I am not sure - } - // texture - else if (ef->getEmission().isTexture()) { - COLLADAFW::Texture ctex = ef->getEmission().getTexture(); - mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); - if (mtex != NULL) { - mtex->mapto = MAP_EMIT; - i++; - } - } - // TRANSPARENT - // color - // if (ef->getOpacity().isColor()) { + } + // TRANSPARENT + // color +// if (ef->getOpacity().isColor()) { // // XXX don't know what to do here // } // // texture @@ -714,326 +676,329 @@ private: // if (mtex != NULL) mtex->mapto = MAP_ALPHA; // } // } - material_texture_mapping_map[ma] = texindex_texarray_map; - } + material_texture_mapping_map[ma] = texindex_texarray_map; +} + +/** When this method is called, the writer must write the effect. + @return The writer should return true, if writing succeeded, false otherwise.*/ + +bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect ) +{ + if(mImportStage!=General) + return true; - /** When this method is called, the writer must write the effect. - @return The writer should return true, if writing succeeded, false otherwise.*/ - - bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect ) - { - if(mImportStage!=General) - return true; - - const COLLADAFW::UniqueId& uid = effect->getUniqueId(); - if (uid_effect_map.find(uid) == uid_effect_map.end()) { - fprintf(stderr, "Couldn't find a material by UID.\n"); - return true; - } - - Material *ma = uid_effect_map[uid]; - - COLLADAFW::CommonEffectPointerArray common_efs = effect->getCommonEffects(); - if (common_efs.getCount() < 1) { - fprintf(stderr, "Couldn't find .\n"); - return true; - } - // XXX TODO: Take all s - // Currently only first is supported - COLLADAFW::EffectCommon *ef = common_efs[0]; - write_profile_COMMON(ef, ma); - + const COLLADAFW::UniqueId& uid = effect->getUniqueId(); + if (uid_effect_map.find(uid) == uid_effect_map.end()) { + fprintf(stderr, "Couldn't find a material by UID.\n"); return true; } + Material *ma = uid_effect_map[uid]; - /** When this method is called, the writer must write the camera. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) - { - if(mImportStage!=General) - return true; - - Camera *cam = NULL; - std::string cam_id, cam_name; + COLLADAFW::CommonEffectPointerArray common_efs = effect->getCommonEffects(); + if (common_efs.getCount() < 1) { + fprintf(stderr, "Couldn't find .\n"); + return true; + } + // XXX TODO: Take all s + // Currently only first is supported + COLLADAFW::EffectCommon *ef = common_efs[0]; + write_profile_COMMON(ef, ma); + + return true; +} + + +/** When this method is called, the writer must write the camera. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) +{ + if(mImportStage!=General) + return true; - cam_id = camera->getOriginalId(); - cam_name = camera->getName(); - if (cam_name.size()) cam = (Camera*)add_camera((char*)cam_name.c_str()); - else cam = (Camera*)add_camera((char*)cam_id.c_str()); - - if (!cam) { - fprintf(stderr, "Cannot create camera. \n"); - return true; + Camera *cam = NULL; + std::string cam_id, cam_name; + + cam_id = camera->getOriginalId(); + cam_name = camera->getName(); + if (cam_name.size()) cam = (Camera*)add_camera((char*)cam_name.c_str()); + else cam = (Camera*)add_camera((char*)cam_id.c_str()); + + if (!cam) { + fprintf(stderr, "Cannot create camera. \n"); + return true; + } + cam->clipsta = camera->getNearClippingPlane().getValue(); + cam->clipend = camera->getFarClippingPlane().getValue(); + + COLLADAFW::Camera::CameraType type = camera->getCameraType(); + switch(type) { + case COLLADAFW::Camera::ORTHOGRAPHIC: + { + cam->type = CAM_ORTHO; } - cam->clipsta = camera->getNearClippingPlane().getValue(); - cam->clipend = camera->getFarClippingPlane().getValue(); - - COLLADAFW::Camera::CameraType type = camera->getCameraType(); - switch(type) { - case COLLADAFW::Camera::ORTHOGRAPHIC: - { - cam->type = CAM_ORTHO; - } - break; - case COLLADAFW::Camera::PERSPECTIVE: - { - cam->type = CAM_PERSP; - } - break; - case COLLADAFW::Camera::UNDEFINED_CAMERATYPE: - { - fprintf(stderr, "Current camera type is not supported. \n"); - cam->type = CAM_PERSP; - } - break; + break; + case COLLADAFW::Camera::PERSPECTIVE: + { + cam->type = CAM_PERSP; } - - switch(camera->getDescriptionType()) { - case COLLADAFW::Camera::ASPECTRATIO_AND_Y: - { - switch(cam->type) { - case CAM_ORTHO: - { - double ymag = camera->getYMag().getValue(); - double aspect = camera->getAspectRatio().getValue(); - double xmag = aspect*ymag; - cam->ortho_scale = (float)xmag; - } - break; - case CAM_PERSP: - default: - { - double yfov = camera->getYFov().getValue(); - double aspect = camera->getAspectRatio().getValue(); - double xfov = aspect*yfov; - // xfov is in degrees, cam->lens is in millimiters - cam->lens = angle_to_lens((float)xfov*(M_PI/180.0f)); - } - break; - } - } - break; - /* XXX correct way to do following four is probably to get also render - size and determine proper settings from that somehow */ - case COLLADAFW::Camera::ASPECTRATIO_AND_X: - case COLLADAFW::Camera::SINGLE_X: - case COLLADAFW::Camera::X_AND_Y: - { - switch(cam->type) { - case CAM_ORTHO: - cam->ortho_scale = (float)camera->getXMag().getValue(); - break; - case CAM_PERSP: - default: - { - double x = camera->getXFov().getValue(); - // x is in degrees, cam->lens is in millimiters - cam->lens = angle_to_lens((float)x*(M_PI/180.0f)); - } - break; - } - } - break; - case COLLADAFW::Camera::SINGLE_Y: - { - switch(cam->type) { - case CAM_ORTHO: - cam->ortho_scale = (float)camera->getYMag().getValue(); - break; - case CAM_PERSP: - default: - { + break; + case COLLADAFW::Camera::UNDEFINED_CAMERATYPE: + { + fprintf(stderr, "Current camera type is not supported. \n"); + cam->type = CAM_PERSP; + } + break; + } + + switch(camera->getDescriptionType()) { + case COLLADAFW::Camera::ASPECTRATIO_AND_Y: + { + switch(cam->type) { + case CAM_ORTHO: + { + double ymag = camera->getYMag().getValue(); + double aspect = camera->getAspectRatio().getValue(); + double xmag = aspect*ymag; + cam->ortho_scale = (float)xmag; + } + break; + case CAM_PERSP: + default: + { double yfov = camera->getYFov().getValue(); - // yfov is in degrees, cam->lens is in millimiters - cam->lens = angle_to_lens((float)yfov*(M_PI/180.0f)); - } - break; - } + double aspect = camera->getAspectRatio().getValue(); + double xfov = aspect*yfov; + // xfov is in degrees, cam->lens is in millimiters + cam->lens = angle_to_lens((float)xfov*(M_PI/180.0f)); + } + break; } - break; - case COLLADAFW::Camera::UNDEFINED: - // read nothing, use blender defaults. - break; } - - this->uid_camera_map[camera->getUniqueId()] = cam; - // XXX import camera options - return true; - } - - /** When this method is called, the writer must write the image. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeImage( const COLLADAFW::Image* image ) - { - if(mImportStage!=General) - return true; - - // XXX maybe it is necessary to check if the path is absolute or relative - const std::string& filepath = image->getImageURI().toNativePath(); - const char *filename = (const char*)mFilename.c_str(); - char dir[FILE_MAX]; - char full_path[FILE_MAX]; - - BLI_split_dirfile(filename, dir, NULL); - BLI_join_dirfile(full_path, sizeof(full_path), dir, filepath.c_str()); - Image *ima = BKE_add_image_file(full_path); - if (!ima) { - fprintf(stderr, "Cannot create image. \n"); - return true; - } - this->uid_image_map[image->getUniqueId()] = ima; - - return true; - } - - /** When this method is called, the writer must write the light. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) - { - if(mImportStage!=General) - return true; - - Lamp *lamp = NULL; - std::string la_id, la_name; - - 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(); - } - 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; + break; + /* XXX correct way to do following four is probably to get also render + size and determine proper settings from that somehow */ + case COLLADAFW::Camera::ASPECTRATIO_AND_X: + case COLLADAFW::Camera::SINGLE_X: + case COLLADAFW::Camera::X_AND_Y: + { + switch(cam->type) { + case CAM_ORTHO: + cam->ortho_scale = (float)camera->getXMag().getValue(); + break; + case CAM_PERSP: + default: + { + double x = camera->getXFov().getValue(); + // x is in degrees, cam->lens is in millimiters + cam->lens = angle_to_lens((float)x*(M_PI/180.0f)); + } + break; } - 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->energy = 1.0; - 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; + break; + case COLLADAFW::Camera::SINGLE_Y: + { + switch(cam->type) { + case CAM_ORTHO: + cam->ortho_scale = (float)camera->getYMag().getValue(); + break; + case CAM_PERSP: + default: + { + double yfov = camera->getYFov().getValue(); + // yfov is in degrees, cam->lens is in millimiters + cam->lens = angle_to_lens((float)yfov*(M_PI/180.0f)); + } + break; + } + } + break; + case COLLADAFW::Camera::UNDEFINED: + // read nothing, use blender defaults. + break; } - // this function is called only for animations that pass COLLADAFW::validate - bool DocumentImporter::writeAnimation( const COLLADAFW::Animation* anim ) - { - if(mImportStage!=General) - return true; - - // return true; - return anim_importer.write_animation(anim); - } - - // called on post-process stage after writeVisualScenes - bool DocumentImporter::writeAnimationList( const COLLADAFW::AnimationList* animationList ) - { - if(mImportStage!=General) - return true; - - // return true; - return anim_importer.write_animation_list(animationList); - } - - /** When this method is called, the writer must write the skin controller data. - @return The writer should return true, if writing succeeded, false otherwise.*/ - bool DocumentImporter::writeSkinControllerData( const COLLADAFW::SkinControllerData* skin ) - { - return armature_importer.write_skin_controller_data(skin); - } + this->uid_camera_map[camera->getUniqueId()] = cam; + // XXX import camera options + return true; +} - // this is called on postprocess, before writeVisualScenes - bool DocumentImporter::writeController( const COLLADAFW::Controller* controller ) - { - if(mImportStage!=General) - return true; - - return armature_importer.write_controller(controller); - } - - bool DocumentImporter::writeFormulas( const COLLADAFW::Formulas* formulas ) - { +/** When this method is called, the writer must write the image. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeImage( const COLLADAFW::Image* image ) +{ + if(mImportStage!=General) + return true; + + // XXX maybe it is necessary to check if the path is absolute or relative + const std::string& filepath = image->getImageURI().toNativePath(); + const char *filename = (const char*)mFilename.c_str(); + char dir[FILE_MAX]; + char full_path[FILE_MAX]; + + BLI_split_dirfile(filename, dir, NULL); + BLI_join_dirfile(full_path, sizeof(full_path), dir, filepath.c_str()); + Image *ima = BKE_add_image_file(full_path); + if (!ima) { + fprintf(stderr, "Cannot create image. \n"); return true; } + this->uid_image_map[image->getUniqueId()] = ima; + + return true; +} - bool DocumentImporter::writeKinematicsScene( const COLLADAFW::KinematicsScene* kinematicsScene ) - { +/** When this method is called, the writer must write the light. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) +{ + if(mImportStage!=General) + return true; + + Lamp *lamp = NULL; + std::string la_id, la_name; + + 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(); + } + 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; + } + 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->energy = 1.0; + 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; +} +// this function is called only for animations that pass COLLADAFW::validate +bool DocumentImporter::writeAnimation( const COLLADAFW::Animation* anim ) +{ + if(mImportStage!=General) + return true; + + // return true; + return anim_importer.write_animation(anim); +} +// called on post-process stage after writeVisualScenes +bool DocumentImporter::writeAnimationList( const COLLADAFW::AnimationList* animationList ) +{ + if(mImportStage!=General) + return true; + + // return true; + return anim_importer.write_animation_list(animationList); +} + +/** When this method is called, the writer must write the skin controller data. + @return The writer should return true, if writing succeeded, false otherwise.*/ +bool DocumentImporter::writeSkinControllerData( const COLLADAFW::SkinControllerData* skin ) +{ + return armature_importer.write_skin_controller_data(skin); +} + +// this is called on postprocess, before writeVisualScenes +bool DocumentImporter::writeController( const COLLADAFW::Controller* controller ) +{ + if(mImportStage!=General) + return true; + + return armature_importer.write_controller(controller); +} + +bool DocumentImporter::writeFormulas( const COLLADAFW::Formulas* formulas ) +{ + return true; +} + +bool DocumentImporter::writeKinematicsScene( const COLLADAFW::KinematicsScene* kinematicsScene ) +{ + return true; +} + +bool DocumentImporter::addElementData( const COLLADAFW::UniqueId &uid) +{ + return true; +} diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h index e312268c458..949185471f4 100644 --- a/source/blender/collada/DocumentImporter.h +++ b/source/blender/collada/DocumentImporter.h @@ -53,7 +53,7 @@ struct bContext; /** Importer class. */ class DocumentImporter : COLLADAFW::IWriter { - public: +public: //! Enumeration to denote the stage of import enum ImportStage { General, //!< First pass to collect all data except controller @@ -78,8 +78,8 @@ class DocumentImporter : COLLADAFW::IWriter void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*); /** This method will be called if an error in the loading process occurred and the loader cannot - continue to load. The writer should undo all operations that have been performed. - @param errorMessage A message containing informations about the error that occurred. + continue to load. The writer should undo all operations that have been performed. + @param errorMessage A message containing informations about the error that occurred. */ void cancel(const COLLADAFW::String& errorMessage); @@ -88,7 +88,7 @@ class DocumentImporter : COLLADAFW::IWriter /** This method is called after the last write* method. No other methods will be called after this.*/ void finish(); - + bool writeGlobalAsset(const COLLADAFW::FileInfo*); bool writeScene(const COLLADAFW::Scene*); @@ -121,31 +121,34 @@ class DocumentImporter : COLLADAFW::IWriter bool writeKinematicsScene(const COLLADAFW::KinematicsScene*); - private: - + /** Add element and data for UniqueId */ + bool addElementData(const COLLADAFW::UniqueId &uid); + +private: + /** Current import stage we're in. */ ImportStage mImportStage; std::string mFilename; - bContext *mContext; + bContext *mContext; - UnitConverter unit_converter; - ArmatureImporter armature_importer; - MeshImporter mesh_importer; - AnimationImporter anim_importer; + UnitConverter unit_converter; + ArmatureImporter armature_importer; + MeshImporter mesh_importer; + AnimationImporter anim_importer; - 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 material_texture_mapping_map; - std::map object_map; - std::map node_map; - std::vector vscenes; - std::vector libnode_ob; + 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 material_texture_mapping_map; + std::map object_map; + std::map node_map; + std::vector vscenes; + std::vector libnode_ob; - std::map root_map; // find root joint by child joint uid, for bone tree evaluation during resampling + std::map root_map; // find root joint by child joint uid, for bone tree evaluation during resampling }; diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp index deec22fac04..3ab34e70c8c 100644 --- a/source/blender/collada/ExtraHandler.cpp +++ b/source/blender/collada/ExtraHandler.cpp @@ -27,14 +27,16 @@ */ #include - #include "BLI_string.h" #include "ExtraHandler.h" -ExtraHandler::ExtraHandler(){} +ExtraHandler::ExtraHandler(DocumentImporter *dimp) +{ + this->dimp = dimp; +} -ExtraHandler::~ExtraHandler(){} +ExtraHandler::~ExtraHandler() {} bool ExtraHandler::elementBegin( const char* elementName, const char** attributes) { @@ -45,6 +47,7 @@ bool ExtraHandler::elementBegin( const char* elementName, const char** attribute bool ExtraHandler::elementEnd(const char* elementName ) { printf("end: %s\n", elementName); + currentUid = COLLADAFW::UniqueId(); return true; } @@ -62,6 +65,7 @@ bool ExtraHandler::parseElement ( const COLLADAFW::UniqueId& uniqueId ) { if(BLI_strcaseeq(profileName, "blender")) { printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); + currentUid = uniqueId; return true; } printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); diff --git a/source/blender/collada/ExtraHandler.h b/source/blender/collada/ExtraHandler.h index 463633d744c..df26310d696 100644 --- a/source/blender/collada/ExtraHandler.h +++ b/source/blender/collada/ExtraHandler.h @@ -33,6 +33,7 @@ #include "COLLADASaxFWLIExtraDataCallbackHandler.h" +#include "DocumentImporter.h" /** \brief Handler class for data, through which different * profiles can be handled @@ -41,7 +42,7 @@ class ExtraHandler : public COLLADASaxFWL::IExtraDataCallbackHandler { public: /** Constructor. */ - ExtraHandler(); + ExtraHandler(DocumentImporter *dimp); /** Destructor. */ virtual ~ExtraHandler(); @@ -65,5 +66,10 @@ private: ExtraHandler( const ExtraHandler& pre ); /** Disable default assignment operator. */ const ExtraHandler& operator= ( const ExtraHandler& pre ); + + /** Handle to DocumentImporter for interface to extra element data saving. */ + DocumentImporter* dimp; + /** Holds Id of element for which XML elements are handled. */ + COLLADAFW::UniqueId currentUid; }; From 6d0859768883c96f303fa5be5c44e81f60d262a4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 10:41:53 +0000 Subject: [PATCH 096/261] fix [#26610] Pressing the ENTER key while editing a Text Object crashes Blender. --- source/blender/editors/curve/editfont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 2f6bd0abcef..34fe2d68cc7 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1095,7 +1095,7 @@ static int line_break_exec(bContext *C, wmOperator *op) Object *obedit= CTX_data_edit_object(C); Curve *cu= obedit->data; EditFont *ef= cu->editfont; - int ctrl= RNA_enum_get(op->ptr, "ctrl"); + const int ctrl= RNA_boolean_get(op->ptr, "ctrl"); if(ctrl) { insert_into_textbuf(obedit, 1); From 32abf5eca87795f4bf6fca1357a4e66a4403b17c Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Fri, 25 Mar 2011 11:07:57 +0000 Subject: [PATCH 097/261] Add ExtraTags class for handling tags inside an extra block. --- source/blender/collada/CMakeLists.txt | 2 + source/blender/collada/DocumentImporter.cpp | 21 +++++++- source/blender/collada/DocumentImporter.h | 6 ++- source/blender/collada/ExtraHandler.cpp | 27 ++++++++--- source/blender/collada/ExtraHandler.h | 2 + source/blender/collada/ExtraTags.cpp | 50 +++++++++++++++++++ source/blender/collada/ExtraTags.h | 54 +++++++++++++++++++++ 7 files changed, 151 insertions(+), 11 deletions(-) create mode 100644 source/blender/collada/ExtraTags.cpp create mode 100644 source/blender/collada/ExtraTags.h diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt index 830e22f70d7..13c33e63869 100644 --- a/source/blender/collada/CMakeLists.txt +++ b/source/blender/collada/CMakeLists.txt @@ -64,6 +64,7 @@ set(SRC DocumentImporter.cpp EffectExporter.cpp ExtraHandler.cpp + ExtraTags.cpp GeometryExporter.cpp ImageExporter.cpp InstanceWriter.cpp @@ -85,6 +86,7 @@ set(SRC DocumentImporter.h EffectExporter.h ExtraHandler.h + ExtraTags.h GeometryExporter.h ImageExporter.h InstanceWriter.h diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 77c2fc971ac..b0bbe49a182 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -101,7 +101,15 @@ DocumentImporter::DocumentImporter(bContext *C, const char *filename) : anim_importer(&unit_converter, &armature_importer, CTX_data_scene(C)) {} -DocumentImporter::~DocumentImporter() {} +DocumentImporter::~DocumentImporter() +{ + std::map::iterator etit; + etit = uid_tags_map.begin(); + while(etit!=uid_tags_map.end()) { + delete etit->second; + etit++; + } +} bool DocumentImporter::import() { @@ -997,8 +1005,17 @@ bool DocumentImporter::writeKinematicsScene( const COLLADAFW::KinematicsScene* k return true; } -bool DocumentImporter::addElementData( const COLLADAFW::UniqueId &uid) +ExtraTags* DocumentImporter::getExtraTags(const COLLADAFW::UniqueId &uid) { + if(uid_tags_map.find(uid)==uid_tags_map.end()) { + return NULL; + } + return uid_tags_map[uid]; +} + +bool DocumentImporter::addExtraTags( const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags) +{ + uid_tags_map[uid] = extra_tags; return true; } diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h index 949185471f4..1905dfe6a3e 100644 --- a/source/blender/collada/DocumentImporter.h +++ b/source/blender/collada/DocumentImporter.h @@ -45,6 +45,7 @@ #include "AnimationImporter.h" #include "ArmatureImporter.h" #include "MeshImporter.h" +#include "ExtraTags.h" struct Main; @@ -122,7 +123,9 @@ public: bool writeKinematicsScene(const COLLADAFW::KinematicsScene*); /** Add element and data for UniqueId */ - bool addElementData(const COLLADAFW::UniqueId &uid); + bool addExtraTags(const COLLADAFW::UniqueId &uid, ExtraTags *extra_tags); + /** Get an extisting ExtraTags for uid */ + ExtraTags* getExtraTags(const COLLADAFW::UniqueId &uid); private: @@ -142,6 +145,7 @@ private: 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 3ab34e70c8c..9dc5f4e4ee6 100644 --- a/source/blender/collada/ExtraHandler.cpp +++ b/source/blender/collada/ExtraHandler.cpp @@ -31,7 +31,7 @@ #include "ExtraHandler.h" -ExtraHandler::ExtraHandler(DocumentImporter *dimp) +ExtraHandler::ExtraHandler(DocumentImporter *dimp) : currentExtraTags(0) { this->dimp = dimp; } @@ -40,22 +40,27 @@ ExtraHandler::~ExtraHandler() {} bool ExtraHandler::elementBegin( const char* elementName, const char** attributes) { - printf("begin: %s\n", elementName); + // \todo attribute handling for profile tags + currentElement = std::string(elementName); return true; } bool ExtraHandler::elementEnd(const char* elementName ) { - printf("end: %s\n", elementName); currentUid = COLLADAFW::UniqueId(); + currentExtraTags = 0; + currentElement.clear(); return true; } bool ExtraHandler::textData(const char* text, size_t textLength) { - char buf[1024] = {0}; - BLI_snprintf(buf, textLength, "%s", text); - printf("data: %s\n", buf); + char buf[1024]; + + if(currentElement.length() == 0) return false; + + BLI_snprintf(buf, textLength+1, "%s", text); + currentExtraTags->addTag(std::string(currentElement), std::string(buf)); return true; } @@ -64,10 +69,16 @@ bool ExtraHandler::parseElement ( const unsigned long& elementHash, const COLLADAFW::UniqueId& uniqueId ) { if(BLI_strcaseeq(profileName, "blender")) { - printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); + //printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); currentUid = uniqueId; + ExtraTags *et = dimp->getExtraTags(uniqueId); + if(!et) { + et = new ExtraTags(std::string(profileName)); + dimp->addExtraTags(uniqueId, et); + } + currentExtraTags = et; return true; } - printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); + //printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); return false; } diff --git a/source/blender/collada/ExtraHandler.h b/source/blender/collada/ExtraHandler.h index df26310d696..de3b063290d 100644 --- a/source/blender/collada/ExtraHandler.h +++ b/source/blender/collada/ExtraHandler.h @@ -71,5 +71,7 @@ private: DocumentImporter* dimp; /** Holds Id of element for which XML elements are handled. */ COLLADAFW::UniqueId currentUid; + ExtraTags* currentExtraTags; + std::string currentElement; }; diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp new file mode 100644 index 00000000000..4fce2768cee --- /dev/null +++ b/source/blender/collada/ExtraTags.cpp @@ -0,0 +1,50 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Nathan Letwory. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/collada/ExtraTags.cpp + * \ingroup collada + */ + +#include +#include "BLI_string.h" + +#include + +#include "ExtraTags.h" + +ExtraTags::ExtraTags(const std::string profile) +{ + this->profile = profile; +} + +ExtraTags::~ExtraTags() +{ +} + +bool ExtraTags::addTag(const std::string tag, const std::string data) +{ + //std::cout << "ready to add " << tag << ": " << data << "." << std::endl; + + return true; +} \ No newline at end of file diff --git a/source/blender/collada/ExtraTags.h b/source/blender/collada/ExtraTags.h new file mode 100644 index 00000000000..09a86741481 --- /dev/null +++ b/source/blender/collada/ExtraTags.h @@ -0,0 +1,54 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Nathan Letwory. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/collada/ExtraTags.h + * \ingroup collada + */ + +#include +#include +#include + +/** \brief Class for saving tags for a specific UniqueId. + */ +class ExtraTags +{ +public: + /** Constructor. */ + ExtraTags(const std::string profile); + + /** Destructor. */ + virtual ~ExtraTags(); + + /** Handle the beginning of an element. */ + bool addTag( const std::string tag, const std::string data); + +private: + /** Disable default copy constructor. */ + ExtraTags( const ExtraTags& pre ); + /** Disable default assignment operator. */ + const ExtraTags& operator= ( const ExtraTags& pre ); + + std::string profile; +}; From 3d5898f3dcc5e19b5961112477b2e9c00be9734c Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 25 Mar 2011 11:45:55 +0000 Subject: [PATCH 098/261] Fix for [#25932] Video Sequencer: F-curve insertion failure after un-meta * Copying/pasting sequence strips didn't properly check for unique names between the copied/pasted strips, so the rna paths of copypasted strips couldn't always be checked properly. --- .../editors/space_sequencer/sequencer_edit.c | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 7a94ed2e6b6..dd64c17b703 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2613,6 +2613,8 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; + ListBase nseqbase= {NULL, NULL}; + seq_free_clipboard(); if(seqbase_isolated_sel_check(ed->seqbasep)==FALSE) { @@ -2620,7 +2622,28 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - seqbase_dupli_recursive(scene, NULL, &seqbase_clipboard, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME); + seqbase_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_UNIQUE_NAME); + + /* To make sure the copied strips have unique names between each other add + * them temporarily to the end of the original seqbase. (bug 25932) + */ + if(nseqbase.first) { + Sequence *seq, *first_seq = nseqbase.first; + BLI_movelisttolist(ed->seqbasep, &nseqbase); + + for(seq=first_seq; seq; seq=seq->next) + seq_recursive_apply(seq, apply_unique_name_cb, scene); + + seqbase_clipboard.first = first_seq; + seqbase_clipboard.last = ed->seqbasep->last; + + if(first_seq->prev) { + first_seq->prev->next = NULL; + ed->seqbasep->last = first_seq->prev; + first_seq->prev = NULL; + } + } + seqbase_clipboard_frame= scene->r.cfra; /* Need to remove anything that references the current scene */ @@ -2690,8 +2713,14 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) } } + iseq = nseqbase.first; + BLI_movelisttolist(ed->seqbasep, &nseqbase); + /* make sure the pasted strips have unique names between them */ + for(; iseq; iseq=iseq->next) + seq_recursive_apply(iseq, apply_unique_name_cb, scene); + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; From f08a227f931e869eaead63476b71a5e1acfdd274 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 12:42:33 +0000 Subject: [PATCH 099/261] include gcc builtin defines in qtcreator project file (__VERSION__, __x86_64__, __linux__ etc) --- build_files/cmake/cmake_qtcreator_project.py | 38 +++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index a8687e34be1..cf1da2f666f 100644 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -175,6 +175,40 @@ def cmake_advanced_info(): return includes, defines +def cmake_cache_var(var): + cache_file = open(os.path.join(CMAKE_DIR, "CMakeCache.txt")) + lines = [l_strip for l in cache_file for l_strip in (l.strip(),) if l_strip if not l_strip.startswith("//") if not l_strip.startswith("#")] + cache_file.close() + + for l in lines: + if l.split(":")[0] == var: + return l.split("=", 1)[-1] + return None + + +def cmake_compiler_defines(): + compiler = cmake_cache_var("CMAKE_C_COMPILER") # could do CXX too + + if compiler is None: + print("Couldn't find the compiler, os defines will be omitted...") + return + + import tempfile + temp_c = tempfile.mkstemp(suffix=".c")[1] + temp_def = tempfile.mkstemp(suffix=".def")[1] + + os.system("%s -dM -E %s > %s" % (compiler, temp_c, temp_def)) + + temp_def_file = open(temp_def) + lines = [l.strip() for l in temp_def_file if l.strip()] + temp_def_file.close() + + os.remove(temp_c) + os.remove(temp_def) + + return lines + + def create_qtc_project_main(): files = list(source_list(base, filename_check=is_project_file)) files_rel = [relpath(f, start=PROJECT_DIR) for f in files] @@ -220,7 +254,9 @@ def create_qtc_project_main(): qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME) f = open(qtc_cfg, 'w') f.write("// ADD PREDEFINED MACROS HERE!\n") - f.write("\n".join([("#define %s %s" % item) for item in defines])) + defines_final = [("#define %s %s" % item) for item in defines] + defines_final += cmake_compiler_defines() # defines from the compiler + f.write("\n".join(defines_final)) print("Blender project file written to: %s" % qtc_prj) # --- end From 21e0eff89712435708d4c8d931e988777a9f865a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 13:37:50 +0000 Subject: [PATCH 100/261] fix [#26600] TexturedSolid + Curve: Specular affecting other materials --- source/blender/editors/space_view3d/drawmesh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 6c5f093d6f1..d062ca8e25f 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -328,6 +328,7 @@ static int set_draw_settings_cached(int clearcache, int textured, MTFace *texfac glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, CLAMPIS(ma->har, 0, 128)); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); } From 77a1a2f14e969176133d53a1504dc0f0b92e8b00 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Mar 2011 13:40:44 +0000 Subject: [PATCH 101/261] use size_t rather then int for passing lengths to string functions since this is what guarded-malloc uses as well as stdlib.h. --- source/blender/blenlib/BLI_string.h | 8 ++++---- source/blender/blenlib/intern/string.c | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 4694f4c413f..635c38e1d13 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -58,7 +58,7 @@ char *BLI_strdup(const char *str); * @param len The number of bytes to duplicate * @retval Returns the duplicated string */ -char *BLI_strdupn(const char *str, int len); +char *BLI_strdupn(const char *str, const size_t len); /** * Appends the two strings, and returns new mallocN'ed string @@ -78,7 +78,7 @@ char *BLI_strdupcat(const char *str1, const char *str2); * the size of dst) * @retval Returns dst */ -char *BLI_strncpy(char *dst, const char *src, const int maxncpy); +char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy); /* Makes a copy of the text within the "" that appear after some text 'blahblah' * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples" @@ -106,7 +106,7 @@ char *BLI_replacestr(char *str, const char *oldText, const char *newText); /* * Replacement for snprintf */ -int BLI_snprintf(char *buffer, size_t count, const char *format, ...) +size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...) #ifdef __GNUC__ __attribute__ ((format (printf, 3, 4))) #endif @@ -138,7 +138,7 @@ int BLI_strcaseeq(const char *a, const char *b); char *BLI_strcasestr(const char *s, const char *find); int BLI_strcasecmp(const char *s1, const char *s2); -int BLI_strncasecmp(const char *s1, const char *s2, int n); +int BLI_strncasecmp(const char *s1, const char *s2, size_t len); int BLI_natstrcmp(const char *s1, const char *s2); size_t BLI_strnlen(const char *str, size_t maxlen); diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 259c12781f2..d626ca4bf09 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -47,7 +47,7 @@ #include "BLI_dynstr.h" #include "BLI_string.h" -char *BLI_strdupn(const char *str, int len) { +char *BLI_strdupn(const char *str, const size_t len) { char *n= MEM_mallocN(len+1, "strdup"); memcpy(n, str, len); n[len]= '\0'; @@ -60,7 +60,7 @@ char *BLI_strdup(const char *str) { char *BLI_strdupcat(const char *str1, const char *str2) { - int len; + size_t len; char *n; len= strlen(str1)+strlen(str2); @@ -71,9 +71,9 @@ char *BLI_strdupcat(const char *str1, const char *str2) return n; } -char *BLI_strncpy(char *dst, const char *src, const int maxncpy) { - int srclen= strlen(src); - int cpylen= (srclen>(maxncpy-1))?(maxncpy-1):srclen; +char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy) { + size_t srclen= strlen(src); + size_t cpylen= (srclen>(maxncpy-1))?(maxncpy-1):srclen; memcpy(dst, src, cpylen); dst[cpylen]= '\0'; @@ -81,9 +81,9 @@ char *BLI_strncpy(char *dst, const char *src, const int maxncpy) { return dst; } -int BLI_snprintf(char *buffer, size_t count, const char *format, ...) +size_t BLI_snprintf(char *buffer, size_t count, const char *format, ...) { - int n; + size_t n; va_list arg; va_start(arg, format); @@ -128,7 +128,7 @@ char *BLI_sprintfN(const char *format, ...) */ char *BLI_getQuotedStr (const char *str, const char *prefix) { - int prefixLen = strlen(prefix); + size_t prefixLen = strlen(prefix); char *startMatch, *endMatch; /* get the starting point (i.e. where prefix starts, and add prefixLen+1 to it to get be after the first " */ @@ -138,7 +138,7 @@ char *BLI_getQuotedStr (const char *str, const char *prefix) endMatch= strchr(startMatch, '"'); // " NOTE: this comment here is just so that my text editor still shows the functions ok... /* return the slice indicated */ - return BLI_strdupn(startMatch, (int)(endMatch-startMatch)); + return BLI_strdupn(startMatch, (size_t)(endMatch-startMatch)); } /* Replaces all occurances of oldText with newText in str, returning a new string that doesn't @@ -149,7 +149,7 @@ char *BLI_getQuotedStr (const char *str, const char *prefix) char *BLI_replacestr(char *str, const char *oldText, const char *newText) { DynStr *ds= NULL; - int lenOld= strlen(oldText); + size_t lenOld= strlen(oldText); char *match; /* sanity checks */ @@ -263,10 +263,10 @@ int BLI_strcasecmp(const char *s1, const char *s2) { return 0; } -int BLI_strncasecmp(const char *s1, const char *s2, int n) { +int BLI_strncasecmp(const char *s1, const char *s2, size_t len) { int i; - for (i=0; i Date: Fri, 25 Mar 2011 14:32:47 +0000 Subject: [PATCH 102/261] incorrect rna type for the BGE ui. --- source/blender/editors/space_logic/logic_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 8cbe56c852f..66e19cf0400 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3303,7 +3303,7 @@ static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr, bContext *C uiItemR(row, ptr, "use_pulse", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_material", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - switch (RNA_enum_get(ptr, "use_material")) { + switch (RNA_boolean_get(ptr, "use_material")) { case SENS_COLLISION_PROPERTY: uiItemR(split, ptr, "property", 0, NULL, ICON_NONE); break; From fb2fd884637f912a56302d331f4514ddd7b18374 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Fri, 25 Mar 2011 16:53:07 +0000 Subject: [PATCH 103/261] Moved temporary drag operator link drawing from node tree to node space function. Otherwise these links are redrawn for each node group. Changed selection flag used for the selected_nodes context property from SELECT to NODE_SELECT. These are just incidentally the same, but NODE_SELECT should be used for nodes. --- source/blender/editors/space_node/node_draw.c | 18 +++++++++--------- source/blender/editors/space_node/space_node.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 920e670573d..0c9f12966ef 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -995,7 +995,6 @@ static void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, { bNode *node; bNodeLink *link; - bNodeLinkDrag *nldrag; int a; if(ntree==NULL) return; /* groups... */ @@ -1030,14 +1029,6 @@ static void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, node_draw_basis(C, ar, snode, ntree, node); } } - - /* temporary links */ - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); - for(nldrag= snode->linkdrag.first; nldrag; nldrag= nldrag->next) - node_draw_link(&ar->v2d, snode, nldrag->link); - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); } static void group_verify_cb(bContext *UNUSED(C), void *UNUSED(snode_v), void *ngroup_v) @@ -1213,6 +1204,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) SpaceNode *snode= CTX_wm_space_node(C); Scene *scene= CTX_data_scene(C); int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; + bNodeLinkDrag *nldrag; UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); @@ -1268,6 +1260,14 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) } } + /* temporary links */ + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); + for(nldrag= snode->linkdrag.first; nldrag; nldrag= nldrag->next) + node_draw_link(&ar->v2d, snode, nldrag->link); + glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); + /* draw grease-pencil ('canvas' strokes) */ if (/*(snode->flag & SNODE_DISPGP) &&*/ (snode->nodetree)) draw_gpencil_view2d((bContext*)C, 1); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 5d9cb183e60..c0e9e8e22e1 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -431,7 +431,7 @@ static int node_context(const bContext *C, const char *member, bContextDataResul bNode *node; for(next_node(snode->edittree); (node=next_node(NULL));) { - if(node->flag & SELECT) { + if(node->flag & NODE_SELECT) { CTX_data_list_add(result, &snode->edittree->id, &RNA_Node, node); } } From 11920f7880062c1efb68a4e141162b7ec060ca29 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 25 Mar 2011 17:11:32 +0000 Subject: [PATCH 104/261] Bugfix #26195 When rendering, during processing scene data, drawing in 3d window is now locked. Can get extended to more areas in UI easily. At least this solves all crashes with conflicting memory access in render && 3d drawing. Deleting objects via operators or delete modifiers isn't locked yet. Also fixed: crash on quitting a renderwindow when it was rendering. --- source/blender/blenkernel/BKE_screen.h | 5 ++++- source/blender/blenkernel/intern/screen.c | 21 ++++++++++++++++++ .../blender/editors/render/render_internal.c | 9 ++++++++ source/blender/editors/screen/area.c | 4 ++++ .../editors/space_view3d/space_view3d.c | 1 + .../render/extern/include/RE_pipeline.h | 1 + .../render/intern/include/render_types.h | 2 ++ .../blender/render/intern/source/pipeline.c | 22 +++++++++++++++---- .../blender/windowmanager/intern/wm_window.c | 14 +++++++----- 9 files changed, 68 insertions(+), 11 deletions(-) diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 0a7d9780a6b..56b0cd63e01 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -112,7 +112,7 @@ typedef struct SpaceType { typedef struct ARegionType { struct ARegionType *next, *prev; - int regionid; /* unique identifier within this space */ + int regionid; /* unique identifier within this space, defines RGN_TYPE_xxxx */ /* add handlers, stuff you only do once or on area/region type/size changes */ void (*init)(struct wmWindowManager *, struct ARegion *); @@ -152,6 +152,8 @@ typedef struct ARegionType { int prefsizex, prefsizey; /* default keymaps to add */ int keymapflag; + /* return without drawing. lock is set by region definition, and copied to do_lock by render. can become flag */ + short do_lock, lock; } ARegionType; /* panel types */ @@ -231,6 +233,7 @@ void BKE_spacetypes_free(void); /* only for quitting blender */ /* spacedata */ void BKE_spacedata_freelist(ListBase *lb); void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2); +void BKE_spacedata_draw_locks(int set); /* area/regions */ struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar); diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index d8219b61816..63e35408381 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -236,6 +236,26 @@ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2) } } +/* facility to set locks for drawing to survive (render) threads accessing drawing data */ +/* lock can become bitflag too */ +/* should be replaced in future by better local data handling for threads */ +void BKE_spacedata_draw_locks(int set) +{ + SpaceType *st; + + for(st= spacetypes.first; st; st= st->next) { + ARegionType *art; + + for(art= st->regiontypes.first; art; art= art->next) { + if(set) + art->do_lock= art->lock; + else + art->do_lock= 0; + } + } +} + + /* not region itself */ void BKE_area_region_free(SpaceType *st, ARegion *ar) { @@ -395,3 +415,4 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene) BKE_screen_view3d_sync((View3D*)sl, scene); } } + diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 75c98464601..a2d88cb2222 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -53,6 +53,7 @@ #include "BKE_multires.h" #include "BKE_report.h" #include "BKE_sequencer.h" +#include "BKE_screen.h" #include "WM_api.h" #include "WM_types.h" @@ -636,6 +637,13 @@ static int render_breakjob(void *rjv) return 0; } +/* runs in thread, no cursor setting here works. careful with notifiers too (malloc conflicts) */ +/* maybe need a way to get job send notifer? */ +static void render_drawlock(void *UNUSED(rjv), int lock) +{ + BKE_spacedata_draw_locks(lock); +} + /* catch esc */ static int screen_render_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { @@ -769,6 +777,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) /* setup new render */ re= RE_NewRender(scene->id.name); RE_test_break_cb(re, rj, render_breakjob); + RE_draw_lock_cb(re, rj, render_drawlock); RE_display_draw_cb(re, rj, image_rect_update); RE_stats_draw_cb(re, rj, image_renderinfo_cb); RE_progress_cb(re, rj, render_progress_update); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 4a54b0ab0e4..f272352c183 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -314,6 +314,10 @@ void ED_region_do_draw(bContext *C, ARegion *ar) ARegionType *at= ar->type; rcti winrct; + /* see BKE_spacedata_draw_locks() */ + if(at->do_lock) + return; + /* checks other overlapping regions */ region_scissor_winrct(ar, &winrct); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 86b15a922a8..5d75d645695 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1087,6 +1087,7 @@ void ED_spacetype_view3d(void) art->duplicate= view3d_main_area_duplicate; art->listener= view3d_main_area_listener; art->cursor= view3d_main_area_cursor; + art->lock= 1; /* can become flag, see BKE_spacedata_draw_locks */ BLI_addhead(&st->regiontypes, art); /* regions: listview/buttons */ diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index b64538cb452..4cc3207a05e 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -239,6 +239,7 @@ void RE_display_clear_cb(struct Render *re, void *handle, void (*f)(void *handle void RE_display_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr, volatile struct rcti *rect)); void RE_stats_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderStats *rs)); void RE_progress_cb (struct Render *re, void *handle, void (*f)(void *handle, float)); +void RE_draw_lock_cb (struct Render *re, void *handle, void (*f)(void *handle, int)); void RE_test_break_cb (struct Render *re, void *handle, int (*f)(void *handle)); void RE_error_cb (struct Render *re, void *handle, void (*f)(void *handle, const char *str)); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 7a1d7190b83..672b5080fbf 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -246,6 +246,8 @@ struct Render void (*progress)(void *handle, float i); void *prh; + void (*draw_lock)(void *handle, int i); + void *dlh; int (*test_break)(void *handle); void *tbh; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 9511392116f..68ed956781d 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -46,18 +46,18 @@ #include "MEM_guardedalloc.h" -#include "BKE_utildefines.h" +#include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */ #include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" #include "BKE_node.h" #include "BKE_object.h" +#include "BKE_pointcache.h" #include "BKE_report.h" #include "BKE_scene.h" -#include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */ #include "BKE_sequencer.h" -#include "BKE_pointcache.h" -#include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */ +#include "BKE_utildefines.h" +#include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */ #include "BLI_math.h" #include "BLI_blenlib.h" @@ -1404,6 +1404,12 @@ void RE_progress_cb(Render *re, void *handle, void (*f)(void *handle, float)) re->prh= handle; } +void RE_draw_lock_cb(Render *re, void *handle, void (*f)(void *handle, int i)) +{ + re->draw_lock= f; + re->tbh= handle; +} + void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle)) { re->test_break= f; @@ -1790,12 +1796,20 @@ static void do_render_3d(Render *re) // re->cfra= cfra; /* <- unused! */ re->scene->r.subframe = re->mblur_offs + re->field_offs; + /* lock drawing in UI during data phase */ + if(re->draw_lock) + re->draw_lock(re->dlh, 1); + /* make render verts/faces/halos/lamps */ if(render_scene_needs_vector(re)) RE_Database_FromScene_Vectors(re, re->main, re->scene, re->lay); else RE_Database_FromScene(re, re->main, re->scene, re->lay, 1); + /* clear UI drawing locks */ + if(re->draw_lock) + re->draw_lock(re->dlh, 0); + threaded_tile_processor(re); /* do left-over 3d post effects (flares) */ diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index a02ce3fe554..5cf2f8932f5 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -238,6 +238,8 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig) /* this is event from ghost, or exit-blender op */ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) { + bScreen *screen= win->screen; + BLI_remlink(&wm->windows, win); wm_draw_window_clear(win); @@ -246,14 +248,14 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) WM_event_remove_handlers(C, &win->modalhandlers); ED_screen_exit(C, win, win->screen); - /* if temp screen, delete it */ - if(win->screen->temp) { - Main *bmain= CTX_data_main(C); - free_libblock(&bmain->screen, win->screen); - } - wm_window_free(C, wm, win); + /* if temp screen, delete it after window free (it stops jobs that can access it) */ + if(screen->temp) { + Main *bmain= CTX_data_main(C); + free_libblock(&bmain->screen, screen); + } + /* check remaining windows */ if(wm->windows.first) { for(win= wm->windows.first; win; win= win->next) From 6bc3b99016adc70990094cab9d7f9cfea87fdf21 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 25 Mar 2011 17:16:22 +0000 Subject: [PATCH 105/261] Forgot to add to log of previous commit: The purpose was to set a wait-cursor draw on 3d windows. I tried for but it keeps failing... inside threads you can't do UI stuff. Needs further thinking, probably something via jobs system. --- source/blender/editors/render/render_internal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index a2d88cb2222..956618eb1bb 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -642,6 +642,7 @@ static int render_breakjob(void *rjv) static void render_drawlock(void *UNUSED(rjv), int lock) { BKE_spacedata_draw_locks(lock); + } /* catch esc */ From bc88e61efa3fdf9b0f2dc2d3790567d0c2c26a82 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 25 Mar 2011 22:02:50 +0000 Subject: [PATCH 106/261] "Fill Deformed" option for curves isn't dependent from bevel object, so it shouldn't be grayed out even if bevel object is set. --- release/scripts/startup/bl_ui/properties_data_curve.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index 8f117cd0335..58047db63d6 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -106,12 +106,12 @@ class DATA_PT_shape_curve(CurveButtonsPanel, bpy.types.Panel): sub.prop(curve, "render_resolution_v", text="Render V") if (is_curve or is_text): + col.label(text="Fill:") sub = col.column() sub.active = (curve.bevel_object is None) - sub.label(text="Fill:") sub.prop(curve, "use_fill_front") sub.prop(curve, "use_fill_back") - sub.prop(curve, "use_fill_deform", text="Fill Deformed") + col.prop(curve, "use_fill_deform", text="Fill Deformed") col.label(text="Textures:") col.prop(curve, "use_uv_as_generated") From 04e32be958bb90be2824c083eba8f983d9133f76 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Mar 2011 03:42:59 +0000 Subject: [PATCH 107/261] optparse module is deprecated, use new argparse module in background job template. correction to example in doc too. --- doc/python_api/examples/bpy.data.py | 4 ++-- release/scripts/templates/background_job.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/python_api/examples/bpy.data.py b/doc/python_api/examples/bpy.data.py index 555b421ddac..7d6bf94532b 100644 --- a/doc/python_api/examples/bpy.data.py +++ b/doc/python_api/examples/bpy.data.py @@ -14,7 +14,7 @@ print(bpy.data.scenes.keys()) if "Cube" in bpy.data.meshes: mesh = bpy.data.meshes["Cube"] print("removing mesh", mesh) - bpy.data.meshes.unlink(mesh) + bpy.data.meshes.remove(mesh) # write images into a file next to the blend @@ -22,6 +22,6 @@ import os file = open(os.path.splitext(bpy.data.filepath)[0] + ".txt", 'w') for image in bpy.data.images: - file.write("%s %dx%d\n" % (image.filepath, image.size[0], image.size[1])) + file.write("%s %d x %d\n" % (image.filepath, image.size[0], image.size[1])) file.close() diff --git a/release/scripts/templates/background_job.py b/release/scripts/templates/background_job.py index 0337f8f4922..90ddba8a91d 100644 --- a/release/scripts/templates/background_job.py +++ b/release/scripts/templates/background_job.py @@ -66,7 +66,7 @@ def example_function(body_text, save_path, render_path): import sys # to get command line args -import optparse # to parse options for us and print a nice help message +import argparse # to parse options for us and print a nice help message def main(): @@ -84,16 +84,18 @@ def main(): usage_text = "Run blender in background mode with this script:" usage_text += " blender --background --python " + __file__ + " -- [options]" - parser = optparse.OptionParser(usage=usage_text) + print(usage_text) + + parser = argparse.ArgumentParser(description=usage_text) # Example background utility, add some text and renders or saves it (with options) # Possible types are: string, int, long, choice, float and complex. - parser.add_option("-t", "--text", dest="body_text", help="This text will be used to render an image", type="string") + parser.add_argument("-t", "--text", dest="body_text", help="This text will be used to render an image", type=str, required=True) - parser.add_option("-s", "--save", dest="save_path", help="Save the generated file to the specified path", metavar='FILE') - parser.add_option("-r", "--render", dest="render_path", help="Render an image to the specified path", metavar='FILE') + parser.add_argument("-s", "--save", dest="save_path", help="Save the generated file to the specified path", metavar='FILE') + parser.add_argument("-r", "--render", dest="render_path", help="Render an image to the specified path", metavar='FILE') - options, args = parser.parse_args(argv) # In this example we wont use the args + options = parser.parse_args(argv) # In this example we wont use the args if not argv: parser.print_help() From cae59a78d84b1d61974d942538b4707a9565bb67 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Mar 2011 04:50:59 +0000 Subject: [PATCH 108/261] print guarded-alloc memory leaks on blenderplayer exit. --- release/scripts/templates/background_job.py | 2 -- .../gameengine/GamePlayer/ghost/GPG_ghost.cpp | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/release/scripts/templates/background_job.py b/release/scripts/templates/background_job.py index 90ddba8a91d..5cc2e04db0b 100644 --- a/release/scripts/templates/background_job.py +++ b/release/scripts/templates/background_job.py @@ -84,8 +84,6 @@ def main(): usage_text = "Run blender in background mode with this script:" usage_text += " blender --background --python " + __file__ + " -- [options]" - print(usage_text) - parser = argparse.ArgumentParser(description=usage_text) # Example background utility, add some text and renders or saves it (with options) diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 767ccff4259..65a68f1bac3 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -115,6 +115,12 @@ const int kMinWindowHeight = 100; char bprogname[FILE_MAX]; +static void mem_error_cb(const char *errorStr) +{ + fprintf(stderr, "%s", errorStr); + fflush(stderr); +} + #ifdef WIN32 typedef enum { @@ -834,9 +840,10 @@ int main(int argc, char** argv) // GPG_Application app (system, maggie, startscenename); app.SetGameEngineData(maggie, scene, argc, argv); /* this argc cant be argc_py_clamped, since python uses it */ - BLI_strncpy(pathname, maggie->name, sizeof(pathname)); - BLI_strncpy(G.main->name, maggie->name, sizeof(G.main->name)); + if(G.main != maggie) { + BLI_strncpy(G.main->name, maggie->name, sizeof(G.main->name)); + } #ifdef WITH_PYTHON setGamePythonPath(G.main->name); #endif @@ -956,6 +963,13 @@ int main(int argc, char** argv) SYS_DeleteSystem(syshandle); + int totblock= MEM_get_memory_blocks_in_use(); + if(totblock!=0) { + printf("Error Totblock: %d\n",totblock); + MEM_set_error_callback(mem_error_cb); + MEM_printmemlist(); + } + return error ? -1 : 0; } From d53a0cd48f5e9293a9e08252d261c830c34f532c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 26 Mar 2011 05:52:18 +0000 Subject: [PATCH 109/261] Bugfix: Recent renaming of Key.keys to Key.key_blocks broke converter for old files. Campbell Alert: However, more seriously, it has broken many current rigs, especially those with heavy usage of (driven) Shape Keys --- source/blender/blenkernel/intern/ipo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 92098d59e0e..08e0ad4f3ff 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -331,7 +331,7 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) if (adrcode == 0) sprintf(buf, "speed"); else - sprintf(buf, "keys[%d].value", adrcode); + sprintf(buf, "key_blocks[%d].value", adrcode); return buf; } From 02a7063a0922c6c59a9f71ea2627e4f211a79899 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Mar 2011 08:13:42 +0000 Subject: [PATCH 110/261] fix for blenderplayer crashing on exit. the event consumer was being freed twice, once when going out of C++ scope, another when freeing the system. --- intern/ghost/GHOST_C-api.h | 11 ++++++++++- intern/ghost/GHOST_ISystem.h | 9 ++++++++- intern/ghost/intern/GHOST_C-api.cpp | 7 +++++++ intern/ghost/intern/GHOST_System.cpp | 11 +++++++++++ intern/ghost/intern/GHOST_System.h | 7 ++++++- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 4 ++++ 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index e1464542ed3..be8dc138797 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -262,7 +262,16 @@ extern int GHOST_DispatchEvents(GHOST_SystemHandle systemhandle); */ extern GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle); - + +/** + * Remove the given event consumer to our list. + * @param systemhandle The handle to the system + * @param consumerhandle The event consumer to remove. + * @return Indication of success. + */ +extern GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle, + GHOST_EventConsumerHandle consumerhandle); + /*************************************************************************************** ** Progress bar functionality ***************************************************************************************/ diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 7e1300d780a..38c732153d7 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -290,7 +290,14 @@ public: * @return Indication of success. */ virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer) = 0; - + + /** + * Removes the given event consumer to our list. + * @param consumer The event consumer to remove. + * @return Indication of success. + */ + virtual GHOST_TSuccess removeEventConsumer(GHOST_IEventConsumer* consumer) = 0; + /*************************************************************************************** ** N-degree of freedom device management functionality ***************************************************************************************/ diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index 20caa057be0..28058c60499 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -253,6 +253,13 @@ GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_Eve return system->addEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle); } +GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle) +{ + GHOST_ISystem* system = (GHOST_ISystem*) systemhandle; + + return system->removeEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle); +} + GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle,float progress) { GHOST_IWindow* window = (GHOST_IWindow*) windowhandle; diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index ce492c2903b..559fb65277d 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -226,6 +226,17 @@ GHOST_TSuccess GHOST_System::addEventConsumer(GHOST_IEventConsumer* consumer) return success; } +GHOST_TSuccess GHOST_System::removeEventConsumer(GHOST_IEventConsumer* consumer) +{ + GHOST_TSuccess success; + if (m_eventManager) { + success = m_eventManager->removeConsumer(consumer); + } + else { + success = GHOST_kFailure; + } + return success; +} GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent* event) { diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 1f2199855fa..b5c64bfceb6 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -183,7 +183,12 @@ public: */ virtual GHOST_TSuccess addEventConsumer(GHOST_IEventConsumer* consumer); - + /** + * Remove the given event consumer to our list. + * @param consumer The event consumer to remove. + * @return Indication of success. + */ + virtual GHOST_TSuccess removeEventConsumer(GHOST_IEventConsumer* consumer); /*************************************************************************************** ** N-degree of freedom devcice management functionality diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 65a68f1bac3..968d6caeb1c 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -939,6 +939,10 @@ int main(int argc, char** argv) } app.StopGameEngine(); + /* 'app' is freed automatic when out of scope. + * removal is needed else the system will free an already freed value */ + system->removeEventConsumer(&app); + BLO_blendfiledata_free(bfd); } } while (exitcode == KX_EXIT_REQUEST_RESTART_GAME || exitcode == KX_EXIT_REQUEST_START_OTHER_GAME); From 63e40dbe0e4fcee2f96eb0f16bc511e019e0d509 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 26 Mar 2011 08:28:24 +0000 Subject: [PATCH 111/261] Fix #26582, #26586, #26613: recent normal calculation changes didn't take into account that some tools use normals for things other than display. Now we properly initialize vertex normals at flat faces too. Also fixed a normal refresh issue, and deduplicated CDDM/mesh normal calculation code. --- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenkernel/BKE_mesh.h | 2 +- .../blender/blenkernel/intern/cdderivedmesh.c | 61 ++----------------- source/blender/blenkernel/intern/mesh.c | 55 ++++++++++++----- source/blender/blenlib/BLI_editVert.h | 1 + source/blender/blenloader/intern/readfile.c | 2 +- source/blender/editors/mesh/editmesh_lib.c | 41 +++++++++---- source/blender/editors/mesh/editmesh_tools.c | 2 + 8 files changed, 79 insertions(+), 87 deletions(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 2bba079d605..6f8e9bbe8df 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -44,7 +44,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather then defining with quotes */ #define BLENDER_VERSION 256 -#define BLENDER_SUBVERSION 4 +#define BLENDER_SUBVERSION 5 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 4a7e14f7d7d..ae7ac0dabee 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -100,7 +100,7 @@ void mesh_strip_loose_edges(struct Mesh *me); /* Calculate vertex and face normals, face normals are returned in *faceNors_r if non-NULL * and vertex normals are stored in actual mverts. */ -void mesh_calc_normals(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float **faceNors_r); +void mesh_calc_normals(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float (*faceNors_r)[3]); /* Return a newly MEM_malloc'd array of all the mesh vertex locations * (_numVerts_r_ may be NULL) */ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index b7034a7db8a..fc0d5d90687 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1789,26 +1789,15 @@ void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3]) VECCOPY(vert->no, vertNormals[i]); } -/* adapted from mesh_calc_normals */ void CDDM_calc_normals(DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*)dm; - float (*temp_nors)[3]; float (*face_nors)[3]; - int i; - int numVerts = dm->numVertData; - int numFaces = dm->numFaceData; - MFace *mfaces; - MVert *mv; - if(numVerts == 0) return; - - temp_nors = MEM_callocN(numVerts * sizeof(*temp_nors), - "CDDM_calc_normals temp_nors"); + if(dm->numVertData == 0) return; /* we don't want to overwrite any referenced layers */ - mv = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT); - cddm->mvert = mv; + cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT); /* make a face normal layer if not present */ face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL); @@ -1816,50 +1805,8 @@ void CDDM_calc_normals(DerivedMesh *dm) face_nors = CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_CALLOC, NULL, dm->numFaceData); - /* calculate face normals and add to vertex normals */ - mfaces = CDDM_get_faces(dm); - for(i = 0; i < numFaces; i++) { - MFace * mf = &mfaces[i]; - float *f_no = face_nors[i]; - - if(mf->v4) - normal_quad_v3(f_no, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co); - else - normal_tri_v3(f_no, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co); - - if((mf->flag&ME_SMOOTH)!=0) { - float *n4 = (mf->v4)? temp_nors[mf->v4]: NULL; - float *c4 = (mf->v4)? mv[mf->v4].co: NULL; - - accumulate_vertex_normals(temp_nors[mf->v1], temp_nors[mf->v2], temp_nors[mf->v3], n4, - f_no, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, c4); - } - } - - for(i = 0; i < numFaces; i++) { - MFace * mf = &mfaces[i]; - - if((mf->flag&ME_SMOOTH)==0) { - float *f_no = face_nors[i]; - - if(is_zero_v3(temp_nors[mf->v1])) copy_v3_v3(temp_nors[mf->v1], f_no); - if(is_zero_v3(temp_nors[mf->v2])) copy_v3_v3(temp_nors[mf->v2], f_no); - if(is_zero_v3(temp_nors[mf->v3])) copy_v3_v3(temp_nors[mf->v3], f_no); - if(mf->v4 && is_zero_v3(temp_nors[mf->v4])) copy_v3_v3(temp_nors[mf->v4], f_no); - } - } - - /* normalize vertex normals and assign */ - for(i = 0; i < numVerts; i++, mv++) { - float *no = temp_nors[i]; - - if(normalize_v3(no) == 0.0f) - normalize_v3_v3(no, mv->co); - - normal_float_to_short_v3(mv->no, no); - } - - MEM_freeN(temp_nors); + /* calculate face normals */ + mesh_calc_normals(cddm->mvert, dm->numVertData, CDDM_get_faces(dm), dm->numFaceData, face_nors); } void CDDM_calc_edges(DerivedMesh *dm) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 1e29f5c9d3f..365817265f4 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1270,42 +1270,69 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) mf->flag &= ~ME_SMOOTH; } } + + mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); } -void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float **faceNors_r) +void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3]) { float (*tnorms)[3]= MEM_callocN(numVerts*sizeof(*tnorms), "tnorms"); - float *fnors= MEM_callocN(sizeof(*fnors)*3*numFaces, "meshnormals"); + float (*fnors)[3]= (faceNors_r)? faceNors_r: MEM_callocN(sizeof(*fnors)*numFaces, "meshnormals"); int i; + int found_flat=0; for(i=0; iv4) normal_quad_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co); else normal_tri_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co); - if((mf->flag&ME_SMOOTH)!=0) { + if(mf->flag & ME_SMOOTH) { float *n4 = (mf->v4)? tnorms[mf->v4]: NULL; float *c4 = (mf->v4)? mverts[mf->v4].co: NULL; accumulate_vertex_normals(tnorms[mf->v1], tnorms[mf->v2], tnorms[mf->v3], n4, f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, c4); } + else { + found_flat=1; + } } - for(i=0; iflag&ME_SMOOTH)==0) { - float *f_no= &fnors[i*3]; - if(is_zero_v3(tnorms[mf->v1])) copy_v3_v3(tnorms[mf->v1], f_no); - if(is_zero_v3(tnorms[mf->v2])) copy_v3_v3(tnorms[mf->v2], f_no); - if(is_zero_v3(tnorms[mf->v3])) copy_v3_v3(tnorms[mf->v3], f_no); - if(mf->v4 && is_zero_v3(tnorms[mf->v4])) copy_v3_v3(tnorms[mf->v4], f_no); + for(i=0; iflag & ME_SMOOTH)) { + if(is_zero_v3(tnorms[mf->v1])) bit_array[mf->v1>>nr_bits]|=(1<<(mf->v1&(nr_bits-1))); + if(is_zero_v3(tnorms[mf->v2])) bit_array[mf->v2>>nr_bits]|=(1<<(mf->v2&(nr_bits-1))); + if(is_zero_v3(tnorms[mf->v3])) bit_array[mf->v3>>nr_bits]|=(1<<(mf->v3&(nr_bits-1))); + if(mf->v4 && is_zero_v3(tnorms[mf->v4])) bit_array[mf->v4>>nr_bits]|=(1<<(mf->v4&(nr_bits-1))); + } } + + for(i=0; iflag&ME_SMOOTH)==0) { + float *f_no= fnors[i]; + + if(bit_array[mf->v1>>nr_bits]&(1<<(mf->v1&(nr_bits-1)))) add_v3_v3(tnorms[mf->v1], f_no); + if(bit_array[mf->v2>>nr_bits]&(1<<(mf->v2&(nr_bits-1)))) add_v3_v3(tnorms[mf->v2], f_no); + if(bit_array[mf->v3>>nr_bits]&(1<<(mf->v3&(nr_bits-1)))) add_v3_v3(tnorms[mf->v3], f_no); + if(mf->v4 && bit_array[mf->v4>>nr_bits]&(1<<(mf->v4&(nr_bits-1)))) add_v3_v3(tnorms[mf->v4], f_no); + } + } + + MEM_freeN(bit_array); } /* following Mesh convention; we use vertex coordinate itself for normal in this case */ @@ -1321,9 +1348,7 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, MEM_freeN(tnorms); - if(faceNors_r) - *faceNors_r = fnors; - else + if(fnors != faceNors_r) MEM_freeN(fnors); } diff --git a/source/blender/blenlib/BLI_editVert.h b/source/blender/blenlib/BLI_editVert.h index b422b79b165..ba745af5a0b 100644 --- a/source/blender/blenlib/BLI_editVert.h +++ b/source/blender/blenlib/BLI_editVert.h @@ -60,6 +60,7 @@ typedef struct EditVert void *p; intptr_t l; float fp; + int t; } tmp; float no[3]; /*vertex normal */ float co[3]; /*vertex location */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 22ce3bd590a..647352ec727 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11552,7 +11552,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile <4)){ + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 5)){ Mesh *me; for(me= main->mesh.first; me; me= me->id.next) diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index 384b311437b..db990e033df 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -2001,36 +2001,53 @@ void recalc_editnormals(EditMesh *em) { EditFace *efa; EditVert *eve; + int found_flat= 0; - for(eve= em->verts.first; eve; eve=eve->next) { - eve->no[0] = eve->no[1] = eve->no[2] = 0.0; - } + for(eve= em->verts.first; eve; eve=eve->next) + zero_v3(eve->no); for(efa= em->faces.first; efa; efa=efa->next) { if(efa->v4) { - normal_quad_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); + normal_quad_v3(efa->n, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); cent_quad_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); } else { - normal_tri_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co); + normal_tri_v3(efa->n, efa->v1->co, efa->v2->co, efa->v3->co); cent_tri_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co); } - if((efa->flag&ME_SMOOTH)!=0) { + if(efa->flag & ME_SMOOTH) { float *n4= (efa->v4)? efa->v4->no: NULL; float *c4= (efa->v4)? efa->v4->co: NULL; accumulate_vertex_normals(efa->v1->no, efa->v2->no, efa->v3->no, n4, efa->n, efa->v1->co, efa->v2->co, efa->v3->co, c4); } + else + found_flat= 1; } - for(efa= em->faces.first; efa; efa=efa->next) { - if((efa->flag&ME_SMOOTH)==0) { - if(is_zero_v3(efa->v1->no)) copy_v3_v3(efa->v1->no, efa->n); - if(is_zero_v3(efa->v2->no)) copy_v3_v3(efa->v2->no, efa->n); - if(is_zero_v3(efa->v3->no)) copy_v3_v3(efa->v3->no, efa->n); - if(efa->v4 && is_zero_v3(efa->v4->no)) copy_v3_v3(efa->v4->no, efa->n); + /* build smooth normals for uninitialized normals at faces set to flat */ + if(found_flat!=0) { + for(efa= em->faces.first; efa; efa=efa->next) { + efa->v1->tmp.t= 0; + efa->v2->tmp.t= 0; + efa->v3->tmp.t= 0; + if(efa->v4) efa->v4->tmp.t= 0; + + if(!(efa->flag & ME_SMOOTH)) { + if(is_zero_v3(efa->v1->no)) efa->v1->tmp.t= 1; + if(is_zero_v3(efa->v2->no)) efa->v2->tmp.t= 1; + if(is_zero_v3(efa->v3->no)) efa->v3->tmp.t= 1; + if(efa->v4 && is_zero_v3(efa->v4->no)) efa->v4->tmp.t= 1; + } + } + + for(efa= em->faces.first; efa; efa=efa->next) { + if(efa->v1->tmp.t) add_v3_v3(efa->v1->no, efa->n); + if(efa->v2->tmp.t) add_v3_v3(efa->v2->no, efa->n); + if(efa->v3->tmp.t) add_v3_v3(efa->v3->no, efa->n); + if(efa->v4 && efa->v4->tmp.t) add_v3_v3(efa->v4->no, efa->n); } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 5525a486438..40387b82205 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -7451,6 +7451,8 @@ static void mesh_set_smooth_faces(EditMesh *em, short smooth) else efa->flag &= ~ME_SMOOTH; } } + + recalc_editnormals(em); } static int mesh_faces_shade_smooth_exec(bContext *C, wmOperator *UNUSED(op)) From 76fd7a90ad3ef898706742fb7d68eabcdfd80413 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 26 Mar 2011 08:41:21 +0000 Subject: [PATCH 112/261] Fix for Mac addon install, unzipping could create __MACOSX folder which we don't need, just remove it if it gets created. --- release/scripts/startup/bl_ui/space_userpref.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index c79caf78b4b..67174db1d3d 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1100,6 +1100,12 @@ class WM_OT_addon_install(bpy.types.Operator): try: # extract the file to "addons" file_to_extract.extractall(path_addons) + + # zip files can create this dir with metadata, don't need it + macosx_dir = os.path.join(path_addons, '__MACOSX') + if os.path.isdir(macosx_dir): + shutil.rmtree(macosx_dir) + except: traceback.print_exc() return {'CANCELLED'} From ac2d935a32db96925beb86350b99212260e798f5 Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Sat, 26 Mar 2011 09:09:00 +0000 Subject: [PATCH 113/261] Update cmake & scons scripts to use new Collada includes for building with latest blender collada updates --- source/blender/collada/CMakeLists.txt | 3 ++- source/blender/collada/SConscript | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt index 13c33e63869..fa7bfee8ee5 100644 --- a/source/blender/collada/CMakeLists.txt +++ b/source/blender/collada/CMakeLists.txt @@ -43,7 +43,8 @@ if(APPLE) ${OPENCOLLADA_INC}/COLLADAStreamWriter ${OPENCOLLADA_INC}/COLLADABaseUtils ${OPENCOLLADA_INC}/COLLADAFramework - ${OPENCOLLADA_INC}/COLLADASaxFrameworkLoader + ${OPENCOLLADA_INC}/COLLADASaxFrameworkLoader + ${OPENCOLLADA_INC}/GeneratedSaxParser ) else() list(APPEND INC diff --git a/source/blender/collada/SConscript b/source/blender/collada/SConscript index b2a25e81dd5..3dd6160c445 100644 --- a/source/blender/collada/SConscript +++ b/source/blender/collada/SConscript @@ -33,7 +33,7 @@ defs = [] # TODO sanitize inc path building # relative paths to include dirs, space-separated, string if env['OURPLATFORM']=='darwin': - incs = '../blenlib ../blenkernel ../windowmanager ../blenloader ../makesdna ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter [OPENCOLLADA]/COLLADABaseUtils [OPENCOLLADA]/COLLADAFramework [OPENCOLLADA]/COLLADASaxFrameworkLoader '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) + incs = '../blenlib ../blenkernel ../windowmanager ../blenloader ../makesdna ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter [OPENCOLLADA]/COLLADABaseUtils [OPENCOLLADA]/COLLADAFramework [OPENCOLLADA]/COLLADASaxFrameworkLoader [OPENCOLLADA]/GeneratedSaxParser '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) else: incs = '../blenlib ../blenkernel ../windowmanager ../makesdna ../blenloader ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter/include [OPENCOLLADA]/COLLADABaseUtils/include [OPENCOLLADA]/COLLADAFramework/include [OPENCOLLADA]/COLLADASaxFrameworkLoader/include [OPENCOLLADA]/GeneratedSaxParser/include '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) From f141c81b5b0ad58e59f4a311dd1ff7844fb8fa4c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Mar 2011 09:36:45 +0000 Subject: [PATCH 114/261] - fix for editfont using an enum func on boolean property. - updated FBX export test hash. --- source/blender/editors/curve/editfont.c | 8 +++----- source/tests/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 34fe2d68cc7..88842f36efd 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -616,7 +616,7 @@ static EnumPropertyItem style_items[]= { {CU_CHINFO_SMALLCAPS, "SMALL_CAPS", 0, "Small Caps", ""}, {0, NULL, 0, NULL, NULL}}; -static int set_style(bContext *C, int style, int clear) +static int set_style(bContext *C, const int style, const int clear) { Object *obedit= CTX_data_edit_object(C); Curve *cu= obedit->data; @@ -641,10 +641,8 @@ static int set_style(bContext *C, int style, int clear) static int set_style_exec(bContext *C, wmOperator *op) { - int style, clear; - - style= RNA_enum_get(op->ptr, "style"); - clear= RNA_enum_get(op->ptr, "clear"); + const int style= RNA_enum_get(op->ptr, "style"); + const int clear= RNA_boolean_get(op->ptr, "clear"); return set_style(C, style, clear); } diff --git a/source/tests/CMakeLists.txt b/source/tests/CMakeLists.txt index 0430b49181e..7bfebf3a123 100644 --- a/source/tests/CMakeLists.txt +++ b/source/tests/CMakeLists.txt @@ -276,5 +276,5 @@ add_test(export_fbx_all_objects ${TEST_BLENDER_EXE} --python ${CMAKE_CURRENT_LIST_DIR}/bl_test.py -- --run={'FINISHED'}&bpy.ops.export_scene.fbx\(filepath='${TEST_OUT_DIR}/export_fbx_all_objects.fbx',use_selection=False,use_metadata=False\) --md5_source=${TEST_OUT_DIR}/export_fbx_all_objects.fbx - --md5=be69cf0baf51dcf43f579183310cb383 --md5_method=FILE + --md5=fdcd9021da2aaa9b5a32e6ef91ec1799 --md5_method=FILE ) From 5aec085da0526362f2a7cb6c880417fc5ec46c61 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 26 Mar 2011 09:48:03 +0000 Subject: [PATCH 115/261] Fixed memory access in mesh_calc_normals(). Now it uses much less memory. --- source/blender/blenkernel/intern/mesh.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 365817265f4..946f02a97b8 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1306,16 +1306,16 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, if(found_flat!=0) { const int nr_bits= sizeof(int)*8; const int nr_words= (numVerts+(nr_bits-1))/nr_bits; - int *bit_array= (int*)MEM_callocN(sizeof(int)*numVerts*nr_words, "temp buffer"); + int *bit_array= (int*)MEM_callocN(sizeof(int)*MAX2(nr_words, 1), "temp buffer"); for(i=0; iflag & ME_SMOOTH)) { - if(is_zero_v3(tnorms[mf->v1])) bit_array[mf->v1>>nr_bits]|=(1<<(mf->v1&(nr_bits-1))); - if(is_zero_v3(tnorms[mf->v2])) bit_array[mf->v2>>nr_bits]|=(1<<(mf->v2&(nr_bits-1))); - if(is_zero_v3(tnorms[mf->v3])) bit_array[mf->v3>>nr_bits]|=(1<<(mf->v3&(nr_bits-1))); - if(mf->v4 && is_zero_v3(tnorms[mf->v4])) bit_array[mf->v4>>nr_bits]|=(1<<(mf->v4&(nr_bits-1))); + if(is_zero_v3(tnorms[mf->v1])) bit_array[mf->v1/nr_bits]|=(1<<(mf->v1&(nr_bits-1))); + if(is_zero_v3(tnorms[mf->v2])) bit_array[mf->v2/nr_bits]|=(1<<(mf->v2&(nr_bits-1))); + if(is_zero_v3(tnorms[mf->v3])) bit_array[mf->v3/nr_bits]|=(1<<(mf->v3&(nr_bits-1))); + if(mf->v4 && is_zero_v3(tnorms[mf->v4])) bit_array[mf->v4/nr_bits]|=(1<<(mf->v4&(nr_bits-1))); } } @@ -1325,10 +1325,10 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, if((mf->flag&ME_SMOOTH)==0) { float *f_no= fnors[i]; - if(bit_array[mf->v1>>nr_bits]&(1<<(mf->v1&(nr_bits-1)))) add_v3_v3(tnorms[mf->v1], f_no); - if(bit_array[mf->v2>>nr_bits]&(1<<(mf->v2&(nr_bits-1)))) add_v3_v3(tnorms[mf->v2], f_no); - if(bit_array[mf->v3>>nr_bits]&(1<<(mf->v3&(nr_bits-1)))) add_v3_v3(tnorms[mf->v3], f_no); - if(mf->v4 && bit_array[mf->v4>>nr_bits]&(1<<(mf->v4&(nr_bits-1)))) add_v3_v3(tnorms[mf->v4], f_no); + if(bit_array[mf->v1/nr_bits]&(1<<(mf->v1&(nr_bits-1)))) add_v3_v3(tnorms[mf->v1], f_no); + if(bit_array[mf->v2/nr_bits]&(1<<(mf->v2&(nr_bits-1)))) add_v3_v3(tnorms[mf->v2], f_no); + if(bit_array[mf->v3/nr_bits]&(1<<(mf->v3&(nr_bits-1)))) add_v3_v3(tnorms[mf->v3], f_no); + if(mf->v4 && bit_array[mf->v4/nr_bits]&(1<<(mf->v4&(nr_bits-1)))) add_v3_v3(tnorms[mf->v4], f_no); } } From 1fa04dce8cc32c96670d1f458e02dc86207fe550 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Mar 2011 15:24:59 +0000 Subject: [PATCH 116/261] fix for transform using the wrong RNA type --- source/blender/editors/transform/transform_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 963fe2ffa8b..c31722d97cb 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -303,7 +303,7 @@ static int transformops_data(bContext *C, wmOperator *op, wmEvent *event) if (mode == -1) { - mode = RNA_int_get(op->ptr, "mode"); + mode = RNA_enum_get(op->ptr, "mode"); } retval = initTransform(C, t, op, event, mode); From 121075ec15cff682a010dee75d77432b16fe7172 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 26 Mar 2011 17:43:07 +0000 Subject: [PATCH 117/261] One more fix for recent normals re-calculation change --- source/blender/blenkernel/intern/mesh.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 946f02a97b8..bc3e6b4c4dd 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1321,15 +1321,12 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, for(i=0; iflag&ME_SMOOTH)==0) { - float *f_no= fnors[i]; - - if(bit_array[mf->v1/nr_bits]&(1<<(mf->v1&(nr_bits-1)))) add_v3_v3(tnorms[mf->v1], f_no); - if(bit_array[mf->v2/nr_bits]&(1<<(mf->v2&(nr_bits-1)))) add_v3_v3(tnorms[mf->v2], f_no); - if(bit_array[mf->v3/nr_bits]&(1<<(mf->v3&(nr_bits-1)))) add_v3_v3(tnorms[mf->v3], f_no); - if(mf->v4 && bit_array[mf->v4/nr_bits]&(1<<(mf->v4&(nr_bits-1)))) add_v3_v3(tnorms[mf->v4], f_no); - } + if(bit_array[mf->v1/nr_bits]&(1<<(mf->v1&(nr_bits-1)))) add_v3_v3(tnorms[mf->v1], f_no); + if(bit_array[mf->v2/nr_bits]&(1<<(mf->v2&(nr_bits-1)))) add_v3_v3(tnorms[mf->v2], f_no); + if(bit_array[mf->v3/nr_bits]&(1<<(mf->v3&(nr_bits-1)))) add_v3_v3(tnorms[mf->v3], f_no); + if(mf->v4 && bit_array[mf->v4/nr_bits]&(1<<(mf->v4&(nr_bits-1)))) add_v3_v3(tnorms[mf->v4], f_no); } MEM_freeN(bit_array); From 7beca3d142853a0d24ab878d5f3b40d62e75f76d Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 26 Mar 2011 23:42:51 +0000 Subject: [PATCH 118/261] Bugfixes due to recent RNA renaming: * Driver F-Curves were not getting fixed by the "FCurve/Driver Version Fix" tool. This was causing problems such as shapekey drivers from older (2.56 compatible rigs) failing to run. As well as renaming the paths for these Driver F-Curves, the "disabled" flags also get cleared from these drivers so that they can be run again * "Revive Disabled F-Curves" operator in Animation Editors can now be used to revive disabled drivers too. --- release/scripts/modules/animsys_refactor.py | 9 +++++++++ source/blender/editors/animation/anim_channels_edit.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py index 464df870e87..7a83a1434c5 100644 --- a/release/scripts/modules/animsys_refactor.py +++ b/release/scripts/modules/animsys_refactor.py @@ -170,6 +170,15 @@ def update_data_paths(rna_update): continue for fcurve in anim_data.drivers: + data_path = fcurve.data_path + data_path_new = find_path_new(anim_data_base, data_path, rna_update_dict, rna_update_from_map) + # print(data_path_new) + if data_path_new != data_path: + if not IS_TESTING: + fcurve.data_path = data_path_new + fcurve.driver.is_valid = True; # reset to allow this to work again + print("driver-fcurve (%s): %s -> %s" % (id_data.name, data_path, data_path_new)) + for var in fcurve.driver.variables: if var.type == 'SINGLE_PROP': for tar in var.targets: diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index ad88ece1154..0845014c99e 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1687,7 +1687,16 @@ static int animchannels_enable_exec (bContext *C, wmOperator *UNUSED(op)) /* loop through filtered data and clean curves */ for (ale= anim_data.first; ale; ale= ale->next) { FCurve *fcu = (FCurve *)ale->data; + + /* remove disabled flags from F-Curves */ fcu->flag &= ~FCURVE_DISABLED; + + /* for drivers, let's do the same too */ + if (fcu->driver) + fcu->driver->flag &= ~DRIVER_FLAG_INVALID; + + /* tag everything for updates - in particular, this is needed to get drivers working again */ + ANIM_list_elem_update(ac.scene, ale); } /* free temp data */ From 4b5819a5af816ef76409d2c7e228e3027ca21841 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Sat, 26 Mar 2011 23:55:54 +0000 Subject: [PATCH 119/261] SVN maintenance. --- source/blender/collada/ExtraTags.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index 4fce2768cee..2ea11c46509 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -47,4 +47,4 @@ bool ExtraTags::addTag(const std::string tag, const std::string data) //std::cout << "ready to add " << tag << ": " << data << "." << std::endl; return true; -} \ No newline at end of file +} From 7ccfec1ff3ea0ee0ebdbdb91e3e44ab03ab81d6f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 03:14:14 +0000 Subject: [PATCH 120/261] fix (own bug) [#26628] "FCurve/Driver Version Fix" Incorrectly Clobbers Array Indexing also escape strings properly now. --- release/scripts/modules/animsys_refactor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py index 7a83a1434c5..9f2acc5e268 100644 --- a/release/scripts/modules/animsys_refactor.py +++ b/release/scripts/modules/animsys_refactor.py @@ -27,6 +27,10 @@ The main function to use is: update_data_paths(...) IS_TESTING = False +def drepr(string): + # is there a less crappy way to do this in python?, re.escape also escapes + # single quotes strings so cant use it. + return '"%s"' % repr(string)[1:-1].replace("\"", "\\\"").replace("\\'","'") class DataPathBuilder(object): __slots__ = ("data_path", ) @@ -40,7 +44,12 @@ class DataPathBuilder(object): return DataPathBuilder(self.data_path + (str_value, )) def __getitem__(self, key): - str_value = '["%s"]' % key + if type(key) is int: + str_value = '[%d]' % key + elif type(key) is str: + str_value = '[%s]' % drepr(key) + else: + raise Exception("unsupported accessor %r of type %r (internal error)" % (key, type(key))) return DataPathBuilder(self.data_path + (str_value, )) def resolve(self, real_base, rna_update_from_map=None): From 50a06eccff48a2029fa085dc8459246ff8c6394e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 05:23:14 +0000 Subject: [PATCH 121/261] pep8 cleanup --- build_files/buildbot/master.cfg | 37 +++++++++++-------- build_files/buildbot/master_unpack.py | 2 + build_files/buildbot/slave_compile.py | 3 +- build_files/buildbot/slave_pack.py | 3 +- build_files/buildbot/slave_test.py | 4 +- build_files/cmake/cmake_qtcreator_project.py | 1 - build_files/package_spec/build_archive.py | 2 + doc/python_api/sphinx_doc_gen.py | 1 + release/scripts/modules/animsys_refactor.py | 6 ++- release/scripts/modules/bpyml.py | 12 +++--- .../startup/bl_ui/properties_data_armature.py | 2 + release/scripts/startup/bl_ui/space_view3d.py | 4 +- source/tests/pep8.py | 2 +- 13 files changed, 47 insertions(+), 32 deletions(-) diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg index f6aa6390e8c..6913ed2dab0 100644 --- a/build_files/buildbot/master.cfg +++ b/build_files/buildbot/master.cfg @@ -1,6 +1,8 @@ # -*- python -*- # ex: set syntax=python: +# + # Dictionary that the buildmaster pays attention to. c = BuildmasterConfig = {} @@ -36,12 +38,12 @@ c['change_source'] = SVNPoller( # only take place on one slave. from buildbot.process.factory import BuildFactory -from buildbot.steps.source import SVN +from buildbot.steps.source import SVN from buildbot.steps.shell import ShellCommand from buildbot.steps.shell import Compile from buildbot.steps.shell import Test from buildbot.steps.transfer import FileUpload -from buildbot.steps.transfer import FileDownload +# from buildbot.steps.transfer import FileDownload from buildbot.steps.master import MasterShellCommand from buildbot.config import BuilderConfig @@ -50,6 +52,7 @@ from buildbot.config import BuilderConfig c['builders'] = [] buildernames = [] + def add_builder(c, name, libdir, factory): slavenames = [] @@ -64,15 +67,18 @@ def add_builder(c, name, libdir, factory): # common steps + def svn_step(): return SVN(baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/blender', mode='update', defaultBranch='trunk', workdir='blender') + def lib_svn_step(dir): return SVN(name='lib svn', baseURL='https://svn.blender.org/svnroot/bf-blender/%%BRANCH%%/lib/' + dir, mode='update', defaultBranch='trunk', workdir='lib/' + dir) # generic builder -def generic_builder(id, libdir=''): + +def generic_builder(id, libdir=""): filename = 'buildbot_upload_' + id + '.zip' compile_script = '../blender/build_files/buildbot/slave_compile.py' test_script = '../blender/build_files/buildbot/slave_test.py' @@ -88,9 +94,9 @@ def generic_builder(id, libdir=''): f.addStep(Test(command=['python', test_script, id])) f.addStep(ShellCommand(name='package', command=['python', pack_script, id], description='packaging', descriptionDone='packaged')) if id.find('cmake') != -1: - f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024)) + f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100 * 1024 * 1024)) else: - f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100*1024*1024, workdir='install')) + f.addStep(FileUpload(name='upload', slavesrc='buildbot_upload.zip', masterdest=filename, maxsize=100 * 1024 * 1024, workdir='install')) f.addStep(MasterShellCommand(name='unpack', command=['python', unpack_script, filename], description='unpacking', descriptionDone='unpacked')) return f @@ -107,7 +113,7 @@ add_builder(c, 'win32_scons', 'windows', generic_builder) # # Decide how to react to incoming changes. -from buildbot.scheduler import Scheduler +# from buildbot.scheduler import Scheduler from buildbot.schedulers import timed c['schedulers'] = [] @@ -132,18 +138,18 @@ c['schedulers'].append(timed.Nightly(name='nightly', c['status'] = [] from buildbot.status import html -from buildbot.status.web import auth, authz +from buildbot.status.web import authz -authz_cfg=authz.Authz( +authz_cfg = authz.Authz( # change any of these to True to enable; see the manual for more # options - gracefulShutdown = False, - forceBuild = True, # use this to test your slave once it is set up - forceAllBuilds = False, - pingBuilder = False, - stopBuild = False, - stopAllBuilds = False, - cancelPendingBuild = False, + gracefulShutdown=False, + forceBuild=True, # use this to test your slave once it is set up + forceAllBuilds=False, + pingBuilder=False, + stopBuild=False, + stopAllBuilds=False, + cancelPendingBuild=False, ) c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg)) @@ -168,4 +174,3 @@ c['buildbotURL'] = "http://builder.blender.org/" # installations. c['db_url'] = "sqlite:///state.sqlite" - diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index 5e0c6beb962..f97e53384b0 100644 --- a/build_files/buildbot/master_unpack.py +++ b/build_files/buildbot/master_unpack.py @@ -19,6 +19,8 @@ # Runs on Buildbot master, to unpack incoming unload.zip into latest # builds directory and remove older builds. +# + import os import shutil import sys diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index 708c2951272..54150a93e61 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -16,6 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### +# + import os import subprocess import sys @@ -56,4 +58,3 @@ 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 12171cf4003..74d00bf9249 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -16,6 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### +# + # Runs on buildbot slave, creating a release package using the build # system and zipping it into buildbot_upload.zip. This is then uploaded # to the master in the next buildbot step. @@ -83,4 +85,3 @@ try: except Exception, ex: sys.stderr.write('Create buildbot_upload.zip failed' + str(ex) + '\n') sys.exit(1) - diff --git a/build_files/buildbot/slave_test.py b/build_files/buildbot/slave_test.py index 7e78f1ab5cd..f79ef7cf5c6 100644 --- a/build_files/buildbot/slave_test.py +++ b/build_files/buildbot/slave_test.py @@ -16,7 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### -import os +# + import subprocess import sys @@ -37,4 +38,3 @@ if builder.find('cmake') != -1: else: # scons pass - diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index cf1da2f666f..1bad1835434 100644 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -126,7 +126,6 @@ def cmake_advanced_info(): defines = [] import os - import sys create_eclipse_project(CMAKE_DIR) diff --git a/build_files/package_spec/build_archive.py b/build_files/package_spec/build_archive.py index 2496c2295eb..0329d16b1ec 100755 --- a/build_files/package_spec/build_archive.py +++ b/build_files/package_spec/build_archive.py @@ -1,5 +1,7 @@ #!/usr/bin/python +# + import os import shutil import subprocess diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index bc190231e36..b479b19c297 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -110,6 +110,7 @@ if _BPY_PROP_COLLECTION_FAKE: else: _BPY_PROP_COLLECTION_ID = "collection" + def undocumented_message(module_name, type_name, identifier): if str(type_name).startswith(' %s" % (id_data.name, data_path, data_path_new)) for var in fcurve.driver.variables: diff --git a/release/scripts/modules/bpyml.py b/release/scripts/modules/bpyml.py index f1f72d50fd2..fdf5172a0b3 100644 --- a/release/scripts/modules/bpyml.py +++ b/release/scripts/modules/bpyml.py @@ -160,9 +160,9 @@ if __name__ == "__main__": from bpyml_test import * draw = [ - ui() [ - split() [ - column() [ + ui()[ + split()[ + column()[ prop(data='context.scene.render', property='use_stamp_time', text='Time'), prop(data='context.scene.render', property='use_stamp_date', text='Date'), prop(data='context.scene.render', property='use_stamp_render_time', text='RenderTime'), @@ -173,7 +173,7 @@ if __name__ == "__main__": prop(data='context.scene.render', property='use_stamp_marker', text='Marker'), prop(data='context.scene.render', property='use_stamp_sequencer_strip', text='Seq. Strip') ], - column() [ + column()[ active(expr='context.scene.render.use_stamp'), prop(data='context.scene.render', property='stamp_foreground', slider=True), prop(data='context.scene.render', property='stamp_background', slider=True), @@ -181,9 +181,9 @@ if __name__ == "__main__": prop(data='context.scene.render', property='stamp_font_size', text='Font Size') ] ], - split(percentage=0.2) [ + split(percentage=0.2)[ prop(data='context.scene.render', property='use_stamp_note', text='Note'), - row() [ + row()[ active(expr='context.scene.render.use_stamp_note'), prop(data='context.scene.render', property='stamp_note_text', text='') ] diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 7aa1dee2721..4823d365633 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -20,6 +20,7 @@ import bpy from rna_prop_ui import PropertyPanel + class ArmatureButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' @@ -264,6 +265,7 @@ from bl_ui.properties_animviz import ( OnionSkinButtonsPanel, ) + class DATA_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel): #bl_label = "Bones Motion Paths" bl_context = "data" diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index a2ba0948669..22d630643c9 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1161,8 +1161,8 @@ class VIEW3D_MT_pose(bpy.types.Menu): layout.menu("VIEW3D_MT_transform") layout.menu("VIEW3D_MT_pose_transform") - layout.menu("VIEW3D_MT_pose_apply") - + layout.menu("VIEW3D_MT_pose_apply") + layout.menu("VIEW3D_MT_snap") layout.separator() diff --git a/source/tests/pep8.py b/source/tests/pep8.py index 3872d169a9a..67ef12261d0 100644 --- a/source/tests/pep8.py +++ b/source/tests/pep8.py @@ -42,7 +42,7 @@ SKIP_PREFIX = "./tools", "./config", "./scons", "./extern" def file_list_py(path): for dirpath, dirnames, filenames in os.walk(path): for filename in filenames: - if filename.endswith(".py"): + if filename.endswith(".py") or filename.endswith(".cfg"): yield os.path.join(dirpath, filename) From 9b19c564ef9e41f8892b0174196cb0e41e9d2d30 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 06:15:55 +0000 Subject: [PATCH 122/261] fix for 'View Docs' with inherited properties, eg: "Object.name", is inherited and needs to open the URL of "ID.name". --- release/scripts/startup/bl_operators/wm.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index df51af25b02..bb5f3a3a2a9 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -617,6 +617,15 @@ class WM_OT_doc_view(bpy.types.Operator): url = '%s/bpy.ops.%s.html#bpy.ops.%s.%s' % \ (self._prefix, class_name, class_name, class_prop) else: + + # detect if this is a inherited member and use that name instead + rna_parent = getattr(bpy.types, class_name).bl_rna + rna_prop = rna_parent.properties[class_prop] + rna_parent = rna_parent.base + while rna_parent and rna_prop == rna_parent.properties.get(class_prop): + class_name = rna_parent.identifier + rna_parent = rna_parent.base + # It so happens that epydoc nests these, not sphinx # class_name_full = self._nested_class_string(class_name) url = '%s/bpy.types.%s.html#bpy.types.%s.%s' % \ From 587bbc4213078fab34ebb631c7eb3cdabe61bc3b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 06:56:37 +0000 Subject: [PATCH 123/261] fix [#26616] Line of code make Blender crash --- source/blender/python/intern/bpy_rna.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index a8c504e775b..ecf66ca4700 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3861,11 +3861,11 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * { if(PyTuple_GET_SIZE(args) == 1) { BPy_StructRNA *base= (BPy_StructRNA *)PyTuple_GET_ITEM(args, 0); - if (type == Py_TYPE(base)) { + if (Py_TYPE(base) == type) { Py_INCREF(base); return (PyObject *)base; } - else if (PyType_IsSubtype(type, &pyrna_struct_Type)) { + else if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) { /* this almost never runs, only when using user defined subclasses of built-in object. * this isnt common since its NOT related to registerable subclasses. eg: From b11f29c8ac136888bbdef6d5cc2d481a5692d6ba Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 07:56:29 +0000 Subject: [PATCH 124/261] clear some c++ warnings. --- intern/itasc/Scene.cpp | 4 ++-- source/blender/ikplugin/intern/itasc_plugin.cpp | 2 -- source/gameengine/Ketsji/KX_PyConstraintBinding.cpp | 1 + source/gameengine/Ketsji/KX_PythonInit.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/intern/itasc/Scene.cpp b/intern/itasc/Scene.cpp index d46e4da7900..0c5e00ec56f 100644 --- a/intern/itasc/Scene.cpp +++ b/intern/itasc/Scene.cpp @@ -292,7 +292,7 @@ bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, b return true; } - double maxqdot; + // double maxqdot; // UNUSED e_scalar nlcoef; SceneLock lockCallback(this); Frame external_pose; @@ -454,7 +454,7 @@ bool Scene::update(double timestamp, double timestep, unsigned int numsubstep, b // We will pass the joint velocity to each object and they will recommend a maximum timestep timesubstep = timeleft; // get armature max joint velocity to estimate the maximum duration of integration - maxqdot = m_qdot.cwise().abs().maxCoeff(); + // maxqdot = m_qdot.cwise().abs().maxCoeff(); // UNUSED double maxsubstep = nlcoef*m_maxstep; if (maxsubstep < m_minstep) maxsubstep = m_minstep; diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index dbd7c7dbf14..a456e18498b 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -860,13 +860,11 @@ static int convert_channels(IK_Scene *ikscene, PoseTree *tree) { IK_Channel *ikchan; bPoseChannel *pchan; - Bone *bone; int a, flag, njoint; njoint = 0; for(a=0, ikchan = ikscene->channels; anumchan; ++a, ++ikchan) { pchan= tree->pchan[a]; - bone= pchan->bone; ikchan->pchan = pchan; ikchan->parent = (a>0) ? tree->parent[a] : -1; ikchan->owner = ikscene->blArmature; diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 8776bf6fe88..bf288e1f1ad 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -405,6 +405,7 @@ static PyObject* gPyCreateConstraint(PyObject* self, PyObject* args, PyObject* kwds) { + /* FIXME - physicsid is an int being cast to a pointer, should at least use PyCapsule */ int physicsid=0,physicsid2 = 0,constrainttype=0,extrainfo=0; int len = PyTuple_Size(args); int success = 1; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 0be0fa3c7dc..4226399f192 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1919,10 +1919,10 @@ static void restorePySysObjects(void) // Copied from bpy_interface.c static struct _inittab bge_internal_modules[]= { - {"mathutils", BPyInit_mathutils}, - {"bgl", BPyInit_bgl}, - {"blf", BPyInit_blf}, - {"aud", AUD_initPython}, + {(char *)"mathutils", BPyInit_mathutils}, + {(char *)"bgl", BPyInit_bgl}, + {(char *)"blf", BPyInit_blf}, + {(char *)"aud", AUD_initPython}, {NULL, NULL} }; From 4ec9d47de3797ab88e022682f2b9bc2a24bcee45 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 08:31:10 +0000 Subject: [PATCH 125/261] option not to restore the original frame when canceling the animation, use in demo mode. --- source/blender/editors/screen/screen_ops.c | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index b52937aa309..d4b547154ed 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2938,20 +2938,23 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot) RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate"); } -static int screen_animation_cancel_exec(bContext *C, wmOperator *UNUSED(op)) +static int screen_animation_cancel_exec(bContext *C, wmOperator *op) { bScreen *screen= CTX_wm_screen(C); - + if (screen->animtimer) { - ScreenAnimData *sad= screen->animtimer->customdata; - Scene *scene= CTX_data_scene(C); - - /* reset current frame before stopping, and just send a notifier to deal with the rest - * (since playback still needs to be stopped) - */ - scene->r.cfra= sad->sfra; - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); - + if(RNA_boolean_get(op->ptr, "restore_frame")) { + ScreenAnimData *sad= screen->animtimer->customdata; + Scene *scene= CTX_data_scene(C); + + /* reset current frame before stopping, and just send a notifier to deal with the rest + * (since playback still needs to be stopped) + */ + scene->r.cfra= sad->sfra; + + WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + } + /* call the other "toggling" operator to clean up now */ ED_screen_animation_play(C, 0, 0); } @@ -2970,6 +2973,8 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot) ot->exec= screen_animation_cancel_exec; ot->poll= ED_operator_screenactive; + + RNA_def_boolean(ot->srna, "restore_frame", TRUE, "Restore Frame", "Restore the frame when animation was initialized."); } /* ************** border select operator (template) ***************************** */ From 3cb6f52eec3beae54adcec64e1213995dfac0423 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 27 Mar 2011 09:46:20 +0000 Subject: [PATCH 126/261] Add blender light profile. --- source/blender/collada/ExtraTags.cpp | 2 +- source/blender/collada/LightExporter.cpp | 43 ++++++++++++++++++++++-- source/blender/collada/LightExporter.h | 3 ++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index 2ea11c46509..772c20c6c4f 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -44,7 +44,7 @@ ExtraTags::~ExtraTags() bool ExtraTags::addTag(const std::string tag, const std::string data) { - //std::cout << "ready to add " << tag << ": " << data << "." << std::endl; + std::cout << "ready to add " << tag << ": " << data << "." << std::endl; return true; } diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index ab72d2113bb..b4afaa4cc26 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -27,14 +27,11 @@ * \ingroup collada */ - #include #include "COLLADASWColor.h" #include "COLLADASWLight.h" -#include "DNA_lamp_types.h" - #include "BLI_math.h" #include "LightExporter.h" @@ -102,6 +99,7 @@ void LightsExporter::operator()(Object *ob) COLLADASW::DirectionalLight cla(mSW, la_id, la_name, e); cla.setColor(col); cla.setConstantAttenuation(constatt); + exportBlenderProfile(cla, la); addLight(cla); } // hemi @@ -109,6 +107,7 @@ void LightsExporter::operator()(Object *ob) COLLADASW::AmbientLight cla(mSW, la_id, la_name, e); cla.setColor(col); cla.setConstantAttenuation(constatt); + exportBlenderProfile(cla, la); addLight(cla); } // spot @@ -120,6 +119,7 @@ void LightsExporter::operator()(Object *ob) cla.setConstantAttenuation(constatt); cla.setLinearAttenuation(linatt); cla.setQuadraticAttenuation(quadatt); + exportBlenderProfile(cla, la); addLight(cla); } // lamp @@ -129,6 +129,7 @@ void LightsExporter::operator()(Object *ob) cla.setConstantAttenuation(constatt); cla.setLinearAttenuation(linatt); cla.setQuadraticAttenuation(quadatt); + exportBlenderProfile(cla, la); addLight(cla); } // area lamp is not supported @@ -139,6 +140,42 @@ void LightsExporter::operator()(Object *ob) cla.setConstantAttenuation(constatt); cla.setLinearAttenuation(linatt); cla.setQuadraticAttenuation(quadatt); + exportBlenderProfile(cla, la); addLight(cla); } + +} + +bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la) +{ + cla.addExtraTechniqueParameter("blender", "type", la->type); + cla.addExtraTechniqueParameter("blender", "flag", la->flag); + cla.addExtraTechniqueParameter("blender", "mode", la->mode); + cla.addExtraTechniqueParameter("blender", "gamma", la->k); + cla.addExtraTechniqueParameter("blender", "shadow_r", la->shdwr); + cla.addExtraTechniqueParameter("blender", "shadow_g", la->shdwg); + cla.addExtraTechniqueParameter("blender", "shadow_b", la->shdwb); + cla.addExtraTechniqueParameter("blender", "energy", la->energy); + cla.addExtraTechniqueParameter("blender", "dist", la->dist); + cla.addExtraTechniqueParameter("blender", "spotsize", la->spotsize); + cla.addExtraTechniqueParameter("blender", "spotblend", la->spotblend); + cla.addExtraTechniqueParameter("blender", "halo_intensity", la->haint); + cla.addExtraTechniqueParameter("blender", "att1", la->att1); + cla.addExtraTechniqueParameter("blender", "att2", la->att2); + // \todo figure out how we can have falloff curve supported here + cla.addExtraTechniqueParameter("blender", "falloff_type", la->falloff_type); + cla.addExtraTechniqueParameter("blender", "clipsta", la->clipsta); + cla.addExtraTechniqueParameter("blender", "clipend", la->clipend); + cla.addExtraTechniqueParameter("blender", "shadspotsize", la->shadspotsize); + cla.addExtraTechniqueParameter("blender", "bias", la->bias); + cla.addExtraTechniqueParameter("blender", "soft", la->soft); + cla.addExtraTechniqueParameter("blender", "compressthresh", la->compressthresh); + cla.addExtraTechniqueParameter("blender", "bufsize", la->bufsize); + cla.addExtraTechniqueParameter("blender", "samp", la->samp); + cla.addExtraTechniqueParameter("blender", "buffers", la->buffers); + cla.addExtraTechniqueParameter("blender", "filtertype", la->filtertype); + cla.addExtraTechniqueParameter("blender", "bufflag", la->bufflag); + cla.addExtraTechniqueParameter("blender", "buftype", la->buftype); + + return true; } diff --git a/source/blender/collada/LightExporter.h b/source/blender/collada/LightExporter.h index 685a50ff17e..3706582e52c 100644 --- a/source/blender/collada/LightExporter.h +++ b/source/blender/collada/LightExporter.h @@ -33,6 +33,7 @@ #include "COLLADASWStreamWriter.h" #include "COLLADASWLibraryLights.h" +#include "DNA_lamp_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -42,6 +43,8 @@ public: LightsExporter(COLLADASW::StreamWriter *sw); void exportLights(Scene *sce); void operator()(Object *ob); +private: + bool exportBlenderProfile(COLLADASW::Light &cla, Lamp *la); }; #endif From 9997c3c8951fb253fa5e37b624b81005202ceb6d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 13:49:53 +0000 Subject: [PATCH 127/261] modifiers: floats were being implicitly promoted to doubles, adjust to use floats. --- source/blender/modifiers/intern/MOD_build.c | 2 +- source/blender/modifiers/intern/MOD_cast.c | 16 ++++++++-------- source/blender/modifiers/intern/MOD_edgesplit.c | 4 ++-- source/blender/modifiers/intern/MOD_hook.c | 4 ++-- source/blender/modifiers/intern/MOD_meshdeform.c | 2 +- .../modifiers/intern/MOD_particleinstance.c | 2 +- .../modifiers/intern/MOD_particlesystem.c | 2 +- source/blender/modifiers/intern/MOD_screw.c | 2 +- .../blender/modifiers/intern/MOD_simpledeform.c | 10 +++++----- source/blender/modifiers/intern/MOD_smooth.c | 4 +--- source/blender/modifiers/intern/MOD_uvproject.c | 2 +- source/blender/modifiers/intern/MOD_wave.c | 12 ++++++------ 12 files changed, 30 insertions(+), 32 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 0d04476c618..1cf67ac8cae 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -114,7 +114,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } else { frac = BKE_curframe(md->scene) - bmd->start / bmd->length; } - CLAMP(frac, 0.0, 1.0); + CLAMP(frac, 0.0f, 1.0f); numFaces = dm->getNumFaces(dm) * frac; numEdges = dm->getNumEdges(dm) * frac; diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 91d89aaa5d1..5cb352ef482 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -427,9 +427,9 @@ static void cuboid_do( } if (has_radius) { - if (fabs(tmp_co[0]) > cmd->radius || - fabs(tmp_co[1]) > cmd->radius || - fabs(tmp_co[2]) > cmd->radius) continue; + if (fabsf(tmp_co[0]) > cmd->radius || + fabsf(tmp_co[1]) > cmd->radius || + fabsf(tmp_co[2]) > cmd->radius) continue; } for (j = 0; j < dvert[i].totweight; ++j) { @@ -479,7 +479,7 @@ static void cuboid_do( /* ok, now we know which coordinate of the vertex to use */ - if (fabs(tmp_co[coord]) < FLT_EPSILON) /* avoid division by zero */ + if (fabsf(tmp_co[coord]) < FLT_EPSILON) /* avoid division by zero */ continue; /* finally, this is the factor we wanted, to project the vertex @@ -523,9 +523,9 @@ static void cuboid_do( } if (has_radius) { - if (fabs(tmp_co[0]) > cmd->radius || - fabs(tmp_co[1]) > cmd->radius || - fabs(tmp_co[2]) > cmd->radius) continue; + if (fabsf(tmp_co[0]) > cmd->radius || + fabsf(tmp_co[1]) > cmd->radius || + fabsf(tmp_co[2]) > cmd->radius) continue; } octant = 0; @@ -550,7 +550,7 @@ static void cuboid_do( coord = 2; } - if (fabs(tmp_co[coord]) < FLT_EPSILON) + if (fabsf(tmp_co[coord]) < FLT_EPSILON) continue; fbb = apex[coord] / tmp_co[coord]; diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 1de95b67cad..09e29d9ed8e 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -1052,7 +1052,7 @@ static void tag_and_count_extra_edges(SmoothMesh *mesh, float split_angle, /* if normal1 dot normal2 < threshold, angle is greater, so split */ /* FIXME not sure if this always works */ /* 0.00001 added for floating-point rounding */ - float threshold = cos((split_angle + 0.00001) * M_PI / 180.0); + float threshold = cos((split_angle + 0.00001f) * (float)M_PI / 180.0f); int i; *extra_edges = 0; @@ -1113,7 +1113,7 @@ static void split_sharp_edges(SmoothMesh *mesh, float split_angle, int flags) /* if normal1 dot normal2 < threshold, angle is greater, so split */ /* FIXME not sure if this always works */ /* 0.00001 added for floating-point rounding */ - mesh->threshold = cos((split_angle + 0.00001) * M_PI / 180.0); + mesh->threshold = cosf((split_angle + 0.00001f) * (float)M_PI / 180.0f); mesh->flags = flags; /* loop through edges, splitting sharp ones */ diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 4dbe781ca13..082c199b16f 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -136,8 +136,8 @@ static float hook_falloff(float *co_1, float *co_2, const float falloff_squared, if(len_squared > falloff_squared) { return 0.0f; } - else if(len_squared > 0.0) { - return fac * (1.0 - (len_squared / falloff_squared)); + else if(len_squared > 0.0f) { + return fac * (1.0f - (len_squared / falloff_squared)); } } diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index fa9976b1ad6..ba73f3fa0d1 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -377,7 +377,7 @@ static void deformVertsEM(ModifierData *md, Object *ob, dm->release(dm); } -#define MESHDEFORM_MIN_INFLUENCE 0.00001 +#define MESHDEFORM_MIN_INFLUENCE 0.00001f void modifier_mdef_compact_influences(ModifierData *md) { diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index 4b6e4bd0241..46d53e0db15 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -236,7 +236,7 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, normalize_v3(state.vel); /* TODO: incremental rotations somehow */ - if(state.vel[axis] < -0.9999 || state.vel[axis] > 0.9999) { + if(state.vel[axis] < -0.9999f || state.vel[axis] > 0.9999f) { state.rot[0] = 1; state.rot[1] = state.rot[2] = state.rot[3] = 0.0f; } diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index 7e94a76598b..533bfd203b5 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -101,7 +101,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) dataMask |= CD_MASK_MTFACE; } - if(psmd->psys->part->tanfac!=0.0) + if(psmd->psys->part->tanfac != 0.0f) dataMask |= CD_MASK_MTFACE; /* ask for vertexgroups if we need them */ diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 076c09cc51a..17e350482f0 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -272,7 +272,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* will the screw be closed? * Note! smaller then FLT_EPSILON*100 gives problems with float precision so its never closed. */ - if (fabs(screw_ofs) <= (FLT_EPSILON*100) && fabs(fabs(angle) - (M_PI * 2)) <= (FLT_EPSILON*100)) { + if (fabsf(screw_ofs) <= (FLT_EPSILON*100.0f) && fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON*100.0f)) { close= 1; step_tot--; if(step_tot < 2) step_tot= 2; diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index fc13eafa866..2e6d9350148 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -89,11 +89,11 @@ static void simpleDeform_stretch(const float factor, const float dcut[3], float float x = co[0], y = co[1], z = co[2]; float scale; - scale = (z*z*factor-factor + 1.0); + scale = (z*z*factor-factor + 1.0f); co[0] = x*scale; co[1] = y*scale; - co[2] = z*(1.0+factor); + co[2] = z*(1.0f+factor); if(dcut) @@ -134,7 +134,7 @@ static void simpleDeform_bend(const float factor, const float dcut[3], float *co sint = sin(theta); cost = cos(theta); - if(fabs(factor) > 1e-7f) + if(fabsf(factor) > 1e-7f) { co[0] = -(y-1.0f/factor)*sint; co[1] = (y-1.0f/factor)*cost + 1.0f/factor; @@ -168,8 +168,8 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object //Safe-check if(smd->origin == ob) smd->origin = NULL; //No self references - if(smd->limit[0] < 0.0) smd->limit[0] = 0.0f; - if(smd->limit[0] > 1.0) smd->limit[0] = 1.0f; + if(smd->limit[0] < 0.0f) smd->limit[0] = 0.0f; + if(smd->limit[0] > 1.0f) smd->limit[0] = 1.0f; smd->limit[0] = MIN2(smd->limit[0], smd->limit[1]); //Upper limit >= than lower limit diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index 8aca9ec82c3..5f76fad14b1 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -142,9 +142,7 @@ static void smoothModifier_do( v1 = vertexCos[idx1]; v2 = vertexCos[idx2]; - fvec[0] = (v1[0] + v2[0]) / 2.0; - fvec[1] = (v1[1] + v2[1]) / 2.0; - fvec[2] = (v1[2] + v2[2]) / 2.0; + mid_v3_v3v3(fvec, v1, v2); v1 = &ftmp[idx1*3]; v2 = &ftmp[idx2*3]; diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index abe87458038..b054a5b0a6e 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -194,7 +194,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, free_uci= 1; } else { - float scale= (cam->type == CAM_PERSP) ? cam->clipsta * 32.0 / cam->lens : cam->ortho_scale; + float scale= (cam->type == CAM_PERSP) ? cam->clipsta * 32.0f / cam->lens : cam->ortho_scale; float xmax, xmin, ymax, ymin; if(aspect > 1.0f) { diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index b4e94157e9a..6d547867ed8 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -286,7 +286,7 @@ static void waveModifier_do(WaveModifierData *md, if(wmd->damp == 0) wmd->damp = 10.0f; - if(wmd->lifetime != 0.0) { + if(wmd->lifetime != 0.0f) { float x = ctime - wmd->timeoffs; if(x > wmd->lifetime) { @@ -294,7 +294,7 @@ static void waveModifier_do(WaveModifierData *md, if(lifefac > wmd->damp) lifefac = 0.0; else lifefac = - (float)(wmd->height * (1.0 - sqrt(lifefac / wmd->damp))); + (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp))); } } @@ -304,9 +304,9 @@ static void waveModifier_do(WaveModifierData *md, wavemod_get_texture_coords(wmd, ob, dm, vertexCos, tex_co, numVerts); } - if(lifefac != 0.0) { + if(lifefac != 0.0f) { /* avoid divide by zero checks within the loop */ - float falloff_inv= wmd->falloff ? 1.0f / wmd->falloff : 1.0; + float falloff_inv= wmd->falloff ? 1.0f / wmd->falloff : 1.0f; int i; for(i = 0; i < numVerts; i++) { @@ -364,14 +364,14 @@ static void waveModifier_do(WaveModifierData *md, amplit -= (ctime - wmd->timeoffs) * wmd->speed; if(wmd->flag & MOD_WAVE_CYCL) { - amplit = (float)fmod(amplit - wmd->width, 2.0 * wmd->width) + amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width) + wmd->width; } /* GAUSSIAN */ if(amplit > -wmd->width && amplit < wmd->width) { amplit = amplit * wmd->narrow; - amplit = (float)(1.0 / exp(amplit * amplit) - minfac); + amplit = (float)(1.0f / expf(amplit * amplit) - minfac); /*apply texture*/ if(wmd->texture) From 0b9f67061ce34e6147a013cc7025bb194c4e693e Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sun, 27 Mar 2011 13:49:56 +0000 Subject: [PATCH 128/261] Fix for [26631] relative blur decimal value from 2.49 is not correctly converted to percentage value in 2.5 This will not work for file saved between the blur node patch and subversion 2, those will still have to be update manually. --- source/blender/blenloader/intern/readfile.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 647352ec727..b6c0688ee5a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11559,6 +11559,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main) mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); } + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)){ + /* update blur area sizes from 0..1 range to 0..100 percentage */ + Scene *scene; + bNode *node; + for (scene=main->scene.first; scene; scene=scene->id.next) + if (scene->nodetree) + for (node=scene->nodetree->nodes.first; node; node=node->next) + if (node->type==CMP_NODE_BLUR) { + NodeBlurData *nbd= node->storage; + nbd->percentx *= 100.0f; + nbd->percenty *= 100.0f; + } + } + /* put compatibility code here until next subversion bump */ { From 8d7c3f8a7e6de7625b3631cd91242fbefa98cf3a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 14:52:16 +0000 Subject: [PATCH 129/261] interface: floats were being implicitly promoted to doubles, adjust to use floats (in most cases) otherwise cast to double. --- source/blender/blenlib/BLI_math_rotation.h | 4 + source/blender/blenlib/BLI_utildefines.h | 1 + source/blender/editors/include/ED_sequencer.h | 2 +- source/blender/editors/interface/interface.c | 98 +++++++++---------- .../editors/interface/interface_draw.c | 80 +++++++-------- .../editors/interface/interface_handlers.c | 84 ++++++++-------- .../editors/interface/interface_panel.c | 10 +- .../editors/interface/interface_regions.c | 8 +- .../editors/interface/interface_templates.c | 2 +- .../editors/interface/interface_widgets.c | 44 ++++----- source/blender/editors/interface/resources.c | 67 +++++++------ source/blender/editors/interface/view2d.c | 12 +-- source/blender/editors/interface/view2d_ops.c | 12 +-- source/blender/makesdna/DNA_scene_types.h | 6 +- 14 files changed, 217 insertions(+), 213 deletions(-) diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index 11849e0be6d..0385ad5846f 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -39,6 +39,10 @@ extern "C" { #define RAD2DEG(_rad) ((_rad)*(180.0/M_PI)) #define DEG2RAD(_deg) ((_deg)*(M_PI/180.0)) + +#define RAD2DEGF(_rad) ((_rad)*(float)(180.0/M_PI)) +#define DEG2RADF(_deg) ((_deg)*(float)(M_PI/180.0)) + /******************************** Quaternions ********************************/ /* stored in (w, x, y, z) order */ diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 55f227f0284..bee5c031fc9 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -125,6 +125,7 @@ #define CLAMPTEST(a, b, c) if((b)<(c)) {CLAMP(a, b, c);} else {CLAMP(a, c, b);} #define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1) +#define IS_EQF(a,b) ((fabsf((float)(a)-(b)) >= (float) FLT_EPSILON) ? 0 : 1) #define IS_EQT(a, b, c) ((a > b)? (((a-b) <= c)? 1:0) : ((((b-a) <= c)? 1:0))) #define IN_RANGE(a, b, c) ((b < c)? ((b 0)? (szoom) : (szoom == 0)? (1.0) : (-1.0/szoom) +#define SEQ_ZOOM_FAC(szoom) ((szoom) > 0.0f)? (szoom) : ((szoom) == 0.0f)? (1.0f) : (-1.0f/(szoom)) /* in space_sequencer.c, for rna update function */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index b4b96f46173..93537928c92 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -120,8 +120,8 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y gy += block->panel->ofsy; } - *x= ((float)sx) + ((float)getsizex)*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0])); - *y= ((float)sy) + ((float)getsizey)*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1])); + *x= ((float)sx) + ((float)getsizex)*(0.5f+ 0.5f*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0])); + *y= ((float)sy) + ((float)getsizey)*(0.5f+ 0.5f*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1])); } void ui_block_to_window(const ARegion *ar, uiBlock *block, int *x, int *y) @@ -161,13 +161,13 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y sx= ar->winrct.xmin; sy= ar->winrct.ymin; - a= .5*((float)getsizex)*block->winmat[0][0]; - b= .5*((float)getsizex)*block->winmat[1][0]; - c= .5*((float)getsizex)*(1.0+block->winmat[3][0]); + a= 0.5f*((float)getsizex)*block->winmat[0][0]; + b= 0.5f*((float)getsizex)*block->winmat[1][0]; + c= 0.5f*((float)getsizex)*(1.0f+block->winmat[3][0]); - d= .5*((float)getsizey)*block->winmat[0][1]; - e= .5*((float)getsizey)*block->winmat[1][1]; - f= .5*((float)getsizey)*(1.0+block->winmat[3][1]); + d= 0.5f*((float)getsizey)*block->winmat[0][1]; + e= 0.5f*((float)getsizey)*block->winmat[1][1]; + f= 0.5f*((float)getsizey)*(1.0f+block->winmat[3][1]); px= *x - sx; py= *y - sy; @@ -455,10 +455,10 @@ static void ui_draw_linkline(uiLinkLine *line) if(line->from==NULL || line->to==NULL) return; - rect.xmin= (line->from->x1+line->from->x2)/2.0; - rect.ymin= (line->from->y1+line->from->y2)/2.0; - rect.xmax= (line->to->x1+line->to->x2)/2.0; - rect.ymax= (line->to->y1+line->to->y2)/2.0; + rect.xmin= (line->from->x1+line->from->x2)/2.0f; + rect.ymin= (line->from->y1+line->from->y2)/2.0f; + rect.xmax= (line->to->x1+line->to->x2)/2.0f; + rect.ymax= (line->to->y1+line->to->y2)/2.0f; if(line->flag & UI_SELECT) glColor3ub(100,100,100); @@ -800,7 +800,7 @@ void uiEndBlock(const bContext *C, uiBlock *block) else if(block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block); else if(block->dobounds) ui_popup_bounds_block(C, block, block->dobounds); - if(block->minx==0.0 && block->maxx==0.0) uiBoundsBlock(block, 0); + if(block->minx==0.0f && block->maxx==0.0f) uiBoundsBlock(block, 0); if(block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); block->endblock= 1; @@ -817,10 +817,10 @@ void ui_fontscale(short *points, float aspect) aspect= sqrt(aspect); pointsf /= aspect; - if(aspect > 1.0) - *points= ceil(pointsf); + if(aspect > 1.0f) + *points= ceilf(pointsf); else - *points= floor(pointsf); + *points= floorf(pointsf); } } @@ -836,14 +836,14 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u gx= (but?but->x1:block->minx) + (block->panel?block->panel->ofsx:0.0f); gy= (but?but->y1:block->miny) + (block->panel?block->panel->ofsy:0.0f); - rect->xmin= floor(getsizex*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); - rect->ymin= floor(getsizey*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); + rect->xmin= floorf(getsizex*(0.5f+ 0.5f*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); + rect->ymin= floorf(getsizey*(0.5f+ 0.5f*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); gx= (but?but->x2:block->maxx) + (block->panel?block->panel->ofsx:0.0f); gy= (but?but->y2:block->maxy) + (block->panel?block->panel->ofsy:0.0f); - rect->xmax= floor(getsizex*(0.5+ 0.5*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); - rect->ymax= floor(getsizey*(0.5+ 0.5*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); + rect->xmax= floorf(getsizex*(0.5f+ 0.5f*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]))); + rect->ymax= floorf(getsizey*(0.5f+ 0.5f*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]))); } @@ -943,7 +943,7 @@ static void ui_is_but_sel(uiBut *but) case ICONTOG: case OPTION: value= ui_get_but_val(but); - if(value!=but->hardmin) push= 1; + if(value != (double)but->hardmin) push= 1; break; case ICONTOGN: case TOGN: @@ -959,7 +959,7 @@ static void ui_is_but_sel(uiBut *but) if((int)value & (int)but->hardmax) push= 1; } else { - if(value == but->hardmax) push= 1; + if(value == (double)but->hardmax) push= 1; } break; case COL: @@ -1125,9 +1125,9 @@ void ui_get_but_vectorf(uiBut *but, float *vec) } else if(but->pointype == CHA) { char *cp= (char *)but->poin; - vec[0]= ((float)cp[0])/255.0; - vec[1]= ((float)cp[1])/255.0; - vec[2]= ((float)cp[2])/255.0; + vec[0]= ((float)cp[0])/255.0f; + vec[1]= ((float)cp[1])/255.0f; + vec[2]= ((float)cp[2])/255.0f; } else if(but->pointype == FLO) { float *fp= (float *)but->poin; @@ -1164,9 +1164,9 @@ void ui_set_but_vectorf(uiBut *but, float *vec) } else if(but->pointype == CHA) { char *cp= (char *)but->poin; - cp[0]= (char)(0.5 +vec[0]*255.0); - cp[1]= (char)(0.5 +vec[1]*255.0); - cp[2]= (char)(0.5 +vec[2]*255.0); + cp[0]= (char)(0.5f + vec[0]*255.0f); + cp[1]= (char)(0.5f + vec[1]*255.0f); + cp[2]= (char)(0.5f + vec[2]*255.0f); } else if(but->pointype == FLO) { float *fp= (float *)but->poin; @@ -1401,7 +1401,7 @@ static double ui_get_but_scale_unit(uiBut *but, double value) int unit_type= uiButGetUnitType(but); if(unit_type == PROP_UNIT_LENGTH) { - return value * scene->unit.scale_length; + return value * (double)scene->unit.scale_length; } else if(unit_type == PROP_UNIT_AREA) { return value * pow(scene->unit.scale_length, 2); @@ -1441,7 +1441,7 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va int unit_type= uiButGetUnitType(but); int precision= but->a2; - if(scene->unit.scale_length<0.0001) scene->unit.scale_length= 1.0; // XXX do_versions + if(scene->unit.scale_length<0.0001f) scene->unit.scale_length= 1.0f; // XXX do_versions /* Sanity checks */ if(precision>7) precision= 7; @@ -1458,8 +1458,8 @@ static float ui_get_but_step_unit(uiBut *but, float step_default) step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), scene->unit.system, unit_type); - if(step > 0.0) { /* -1 is an error value */ - return (step/ui_get_but_scale_unit(but, 1.0))*100; + if(step > 0.0f) { /* -1 is an error value */ + return (float)((double)step/ui_get_but_scale_unit(but, 1.0))*100.0f; } else { return step_default; @@ -1633,8 +1633,8 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) if(but->type==NUMABS) value= fabs(value); /* not that we use hard limits here */ - if(valuehardmin) value= but->hardmin; - if(value>but->hardmax) value= but->hardmax; + if(value < (double)but->hardmin) value= but->hardmin; + if(value > (double)but->hardmax) value= but->hardmax; ui_set_but_val(but, value); return 1; @@ -1705,8 +1705,8 @@ void ui_set_but_soft_range(uiBut *but, double value) float fmin, fmax, fstep, fprecision; RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision); - softmin= (fmin == -FLT_MAX)? -1e4: fmin; - softmax= (fmax == FLT_MAX)? 1e4: fmax; + softmin= (fmin == -FLT_MAX)? (float)-1e4: fmin; + softmax= (fmax == FLT_MAX)? (float)1e4: fmax; /*step= fstep;*/ /*UNUSED*/ /*precision= fprecision;*/ /*UNUSED*/ } @@ -1720,8 +1720,8 @@ void ui_set_but_soft_range(uiBut *but, double value) else softmin= soft_range_round_down(value, softmin); - if(softmin < but->hardmin) - softmin= but->hardmin; + if(softmin < (double)but->hardmin) + softmin= (double)but->hardmin; } else if(value-1e-10 > softmax) { if(value < 0.0) @@ -1729,7 +1729,7 @@ void ui_set_but_soft_range(uiBut *but, double value) else softmax= soft_range_round_up(value, softmax); - if(softmax > but->hardmax) + if(softmax > (double)but->hardmax) softmax= but->hardmax; } @@ -1932,14 +1932,14 @@ void ui_check_but(uiBut *but) case NUMSLI: case HSVSLI: value= ui_get_but_val(but); - if(value < but->hardmin) ui_set_but_val(but, but->hardmin); - else if(value > but->hardmax) ui_set_but_val(but, but->hardmax); + if(value < (double)but->hardmin) ui_set_but_val(but, but->hardmin); + else if(value > (double)but->hardmax) ui_set_but_val(but, but->hardmax); break; case NUMABS: value= fabs( ui_get_but_val(but) ); - if(value < but->hardmin) ui_set_but_val(but, but->hardmin); - else if(value > but->hardmax) ui_set_but_val(but, but->hardmax); + if(value < (double)but->hardmin) ui_set_but_val(but, but->hardmin); + else if(value > (double)but->hardmax) ui_set_but_val(but, but->hardmax); break; case ICONTOG: @@ -2008,7 +2008,7 @@ void ui_check_but(uiBut *but) else sprintf(but->drawstr, "%s%.4f", but->str, value); } else { - if(but->hardmax<10.001) sprintf(but->drawstr, "%s%.3f", but->str, value); + if(but->hardmax<10.001f) sprintf(but->drawstr, "%s%.3f", but->str, value); else sprintf(but->drawstr, "%s%.2f", but->str, value); } } @@ -2248,23 +2248,23 @@ static void ui_block_do_align_but(uiBut *first, int nr) if(prev) { // simple cases if(rows==0) { - but->x1= (prev->x2+but->x1)/2.0; + but->x1= (prev->x2+but->x1)/2.0f; prev->x2= but->x1; } else if(cols==0) { - but->y2= (prev->y1+but->y2)/2.0; + but->y2= (prev->y1+but->y2)/2.0f; prev->y1= but->y2; } else { if(buts_are_horiz(prev, but)) { - but->x1= (prev->x2+but->x1)/2.0; + but->x1= (prev->x2+but->x1)/2.0f; prev->x2= but->x1; /* copy height too */ but->y2= prev->y2; } else if(prev->prev && buts_are_horiz(prev->prev, prev)==0) { /* the previous button is a single one in its row */ - but->y2= (prev->y1+but->y2)/2.0; + but->y2= (prev->y1+but->y2)/2.0f; prev->y1= but->y2; but->x1= prev->x1; @@ -3046,7 +3046,7 @@ void uiBlockFlipOrder(uiBlock *block) if(but->y2 > maxy) maxy= but->y2; } /* mirror trick */ - centy= (miny+maxy)/2.0; + centy= (miny+maxy)/2.0f; for(but= block->buttons.first; but; but= but->next) { but->y1 = centy-(but->y1-centy); but->y2 = centy-(but->y2-centy); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 659bb41eec0..f8ce278814f 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -144,9 +144,9 @@ static void round_box_shade_col(float *col1, float *col2, float fac) { float col[3]; - col[0]= (fac*col1[0] + (1.0-fac)*col2[0]); - col[1]= (fac*col1[1] + (1.0-fac)*col2[1]); - col[2]= (fac*col1[2] + (1.0-fac)*col2[2]); + col[0]= (fac*col1[0] + (1.0f-fac)*col2[0]); + col[1]= (fac*col1[1] + (1.0f-fac)*col2[1]); + col[2]= (fac*col1[2] + (1.0f-fac)*col2[2]); glColor3fv(col); } @@ -170,12 +170,12 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl glGetFloatv(GL_CURRENT_COLOR, color); /* 'shade' defines strength of shading */ - coltop[0]= color[0]+shadetop; if(coltop[0]>1.0) coltop[0]= 1.0; - coltop[1]= color[1]+shadetop; if(coltop[1]>1.0) coltop[1]= 1.0; - coltop[2]= color[2]+shadetop; if(coltop[2]>1.0) coltop[2]= 1.0; - coldown[0]= color[0]+shadedown; if(coldown[0]<0.0) coldown[0]= 0.0; - coldown[1]= color[1]+shadedown; if(coldown[1]<0.0) coldown[1]= 0.0; - coldown[2]= color[2]+shadedown; if(coldown[2]<0.0) coldown[2]= 0.0; + coltop[0]= color[0]+shadetop; if(coltop[0]>1.0f) coltop[0]= 1.0f; + coltop[1]= color[1]+shadetop; if(coltop[1]>1.0f) coltop[1]= 1.0f; + coltop[2]= color[2]+shadetop; if(coltop[2]>1.0f) coltop[2]= 1.0f; + coldown[0]= color[0]+shadedown; if(coldown[0]<0.0f) coldown[0]= 0.0f; + coldown[1]= color[1]+shadedown; if(coldown[1]<0.0f) coldown[1]= 0.0f; + coldown[2]= color[2]+shadedown; if(coldown[2]<0.0f) coldown[2]= 0.0f; glShadeModel(GL_SMOOTH); glBegin(mode); @@ -277,12 +277,12 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float glGetFloatv(GL_CURRENT_COLOR, color); /* 'shade' defines strength of shading */ - colLeft[0]= color[0]+shadeLeft; if(colLeft[0]>1.0) colLeft[0]= 1.0; - colLeft[1]= color[1]+shadeLeft; if(colLeft[1]>1.0) colLeft[1]= 1.0; - colLeft[2]= color[2]+shadeLeft; if(colLeft[2]>1.0) colLeft[2]= 1.0; - colRight[0]= color[0]+shadeRight; if(colRight[0]<0.0) colRight[0]= 0.0; - colRight[1]= color[1]+shadeRight; if(colRight[1]<0.0) colRight[1]= 0.0; - colRight[2]= color[2]+shadeRight; if(colRight[2]<0.0) colRight[2]= 0.0; + colLeft[0]= color[0]+shadeLeft; if(colLeft[0]>1.0f) colLeft[0]= 1.0f; + colLeft[1]= color[1]+shadeLeft; if(colLeft[1]>1.0f) colLeft[1]= 1.0f; + colLeft[2]= color[2]+shadeLeft; if(colLeft[2]>1.0f) colLeft[2]= 1.0f; + colRight[0]= color[0]+shadeRight; if(colRight[0]<0.0f) colRight[0]= 0.0f; + colRight[1]= color[1]+shadeRight; if(colRight[1]<0.0f) colRight[1]= 0.0f; + colRight[2]= color[2]+shadeRight; if(colRight[2]<0.0f) colRight[2]= 0.0f; glShadeModel(GL_SMOOTH); glBegin(mode); @@ -951,9 +951,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), /* min max */ for (c=0; c<3; c++) { if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) - glColor3f(colors[c][0]*0.75, colors[c][1]*0.75, colors[c][2]*0.75); + glColor3f(colors[c][0]*0.75f, colors[c][1]*0.75f, colors[c][2]*0.75f); else - glColor3f(colorsycc[c][0]*0.75, colorsycc[c][1]*0.75, colorsycc[c][2]*0.75); + glColor3f(colorsycc[c][0]*0.75f, colorsycc[c][1]*0.75f, colorsycc[c][2]*0.75f); min= yofs+scopes->minmax[c][0]*h; max= yofs+scopes->minmax[c][1]*h; CLAMP(min, rect.ymin, rect.ymax); @@ -986,15 +986,15 @@ static void vectorscope_draw_target(float centerx, float centery, float diam, fl rgb_to_yuv(r,g,b, &y, &u, &v); if (u>0 && v>=0) tangle=atanf(v/u); - else if (u>0 && v<0) tangle=atanf(v/u)+2*M_PI; - else if (u<0) tangle=atanf(v/u)+M_PI; - else if (u==0 && v>0) tangle=M_PI/2.0f; - else if (u==0 && v<0) tangle=-M_PI/2.0f; + else if (u>0 && v<0) tangle= atanf(v/u) + 2.0f * (float)M_PI; + else if (u<0) tangle=atanf(v/u) + (float)M_PI; + else if (u==0 && v > 0.0f) tangle= (float)M_PI/2.0f; + else if (u==0 && v < 0.0f) tangle=-(float)M_PI/2.0f; tampli= sqrtf(u*u+v*v); /* small target vary by 2.5 degree and 2.5 IRE unit */ glColor4f(1.0f, 1.0f, 1.0, 0.12f); - dangle= 2.5*M_PI/180.0f; + dangle= 2.5f*(float)M_PI/180.0f; dampli= 2.5f/200.0f; glBegin(GL_LINE_STRIP); glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle)); @@ -1005,9 +1005,9 @@ static void vectorscope_draw_target(float centerx, float centery, float diam, fl glEnd(); /* big target vary by 10 degree and 20% amplitude */ glColor4f(1.0f, 1.0f, 1.0, 0.12f); - dangle= 10*M_PI/180.0f; - dampli= 0.2*tampli; - dangle2= 5.0f*M_PI/180.0f; + dangle= 10.0f*(float)M_PI/180.0f; + dampli= 0.2f*tampli; + dangle2= 5.0f*(float)M_PI/180.0f; dampli2= 0.5f*dampli; glBegin(GL_LINE_STRIP); glVertex2f(polar_to_x(centerx,diam,tampli+dampli-dampli2,tangle+dangle), polar_to_y(centery,diam,tampli+dampli-dampli2,tangle+dangle)); @@ -1131,13 +1131,13 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) sizey= rect->ymax-y1; /* first background, to show tranparency */ - dx= sizex/12.0; + dx= sizex/12.0f; v1[0]= x1; for(a=0; a<12; a++) { if(a & 1) glColor3f(0.3, 0.3, 0.3); else glColor3f(0.8, 0.8, 0.8); - glRectf(v1[0], y1, v1[0]+dx, y1+0.5*sizey); + glRectf(v1[0], y1, v1[0]+dx, y1+0.5f*sizey); if(a & 1) glColor3f(0.8, 0.8, 0.8); else glColor3f(0.3, 0.3, 0.3); - glRectf(v1[0], y1+0.5*sizey, v1[0]+dx, y1+sizey); + glRectf(v1[0], y1+0.5f*sizey, v1[0]+dx, y1+sizey); v1[0]+= dx; } @@ -1178,9 +1178,9 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) /* help lines */ v1[0]= v2[0]=v3[0]= x1; v1[1]= y1; - v1a[1]= y1+0.25*sizey; - v2[1]= y1+0.5*sizey; - v2a[1]= y1+0.75*sizey; + v1a[1]= y1+0.25f*sizey; + v2[1]= y1+0.5f*sizey; + v2a[1]= y1+0.75f*sizey; v3[1]= y1+sizey; @@ -1330,7 +1330,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o glBegin(GL_LINES); dx= step*zoomx; fx= rect->xmin + zoomx*(-offsx); - if(fx > rect->xmin) fx -= dx*( floor(fx-rect->xmin)); + if(fx > rect->xmin) fx -= dx*(floorf(fx-rect->xmin)); while(fx < rect->xmax) { glVertex2f(fx, rect->ymin); glVertex2f(fx, rect->ymax); @@ -1339,7 +1339,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o dy= step*zoomy; fy= rect->ymin + zoomy*(-offsy); - if(fy > rect->ymin) fy -= dy*( floor(fy-rect->ymin)); + if(fy > rect->ymin) fy -= dy*(floorf(fy-rect->ymin)); while(fy < rect->ymax) { glVertex2f(rect->xmin, fy); glVertex2f(rect->xmax, fy); @@ -1379,8 +1379,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax-scissor_new.xmin, scissor_new.ymax-scissor_new.ymin); /* calculate offset and zoom */ - zoomx= (rect->xmax-rect->xmin-2.0*but->aspect)/(cumap->curr.xmax - cumap->curr.xmin); - zoomy= (rect->ymax-rect->ymin-2.0*but->aspect)/(cumap->curr.ymax - cumap->curr.ymin); + zoomx= (rect->xmax-rect->xmin-2.0f*but->aspect)/(cumap->curr.xmax - cumap->curr.xmin); + zoomy= (rect->ymax-rect->ymin-2.0f*but->aspect)/(cumap->curr.ymax - cumap->curr.ymin); offsx= cumap->curr.xmin-but->aspect/zoomx; offsy= cumap->curr.ymin-but->aspect/zoomy; @@ -1540,9 +1540,9 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s glBegin(GL_POLYGON); glColor4ub(0, 0, 0, alpha); glVertex2f(maxx, miny); - glVertex2f(maxx, maxy-0.3*shadsize); + glVertex2f(maxx, maxy-0.3f*shadsize); glColor4ub(0, 0, 0, 0); - glVertex2f(maxx+shadsize, maxy-0.75*shadsize); + glVertex2f(maxx+shadsize, maxy-0.75f*shadsize); glVertex2f(maxx+shadsize, miny); glEnd(); @@ -1552,18 +1552,18 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s glVertex2f(maxx, miny); glColor4ub(0, 0, 0, 0); glVertex2f(maxx+shadsize, miny); - glVertex2f(maxx+0.7*shadsize, miny-0.7*shadsize); + glVertex2f(maxx+0.7f*shadsize, miny-0.7f*shadsize); glVertex2f(maxx, miny-shadsize); glEnd(); /* bottom quad */ glBegin(GL_POLYGON); glColor4ub(0, 0, 0, alpha); - glVertex2f(minx+0.3*shadsize, miny); + glVertex2f(minx+0.3f*shadsize, miny); glVertex2f(maxx, miny); glColor4ub(0, 0, 0, 0); glVertex2f(maxx, miny-shadsize); - glVertex2f(minx+0.5*shadsize, miny-shadsize); + glVertex2f(minx+0.5f*shadsize, miny-shadsize); glEnd(); glDisable(GL_BLEND); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 91380d20f41..648eee07ca0 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1296,7 +1296,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho while (i > 0) { i--; - if (BLF_width(fstyle->uifont_id, origstr+i) > (startx - x)*0.25) break; // 0.25 == scale factor for less sensitivity + if (BLF_width(fstyle->uifont_id, origstr+i) > (startx - x)*0.25f) break; // 0.25 == scale factor for less sensitivity } but->ofs = i; but->pos = but->ofs; @@ -1968,7 +1968,7 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) softmax= but->softmax; softrange= softmax - softmin; - data->dragfstart= (softrange == 0.0)? 0.0: (data->value - softmin)/softrange; + data->dragfstart= (softrange == 0.0f)? 0.0f: ((float)data->value - softmin)/softrange; data->dragf= data->dragfstart; } @@ -2318,13 +2318,13 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa } if(snap==1) { - if(softrange < 2.10) tempf= 0.1*floor(10*tempf); - else if(softrange < 21.0) tempf= floor(tempf); - else tempf= 10.0*floor(tempf/10.0); + if(softrange < 2.10f) tempf= 0.1f*floorf(10.0f*tempf); + else if(softrange < 21.0f) tempf= floorf(tempf); + else tempf= 10.0f*floorf(tempf/10.0f); } else if(snap==2) { - if(softrange < 2.10) tempf= 0.01*floor(100.0*tempf); - else if(softrange < 21.0) tempf= 0.1*floor(10.0*tempf); + if(softrange < 2.10f) tempf= 0.01f*floorf(100.0f*tempf); + else if(softrange < 21.0f) tempf= 0.1f*floorf(10.0f*tempf); else tempf= floor(tempf); } @@ -2380,8 +2380,8 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i /* Mouse location isn't screen clamped to the screen so use a linear mapping * 2px == 1-int, or 1px == 1-ClickStep */ if(ui_is_but_float(but)) { - fac *= 0.01*but->a1; - tempf = data->startvalue + ((mx - data->dragstartx) * fac); + fac *= 0.01f*but->a1; + tempf = (float)data->startvalue + ((float)(mx - data->dragstartx) * fac); tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap); #if 1 /* fake moving the click start, nicer for dragging back after passing the limit */ @@ -2396,7 +2396,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i CLAMP(tempf, softmin, softmax); #endif - if(tempf != data->value) { + if(tempf != (float)data->value) { data->dragchange= 1; data->value= tempf; changed= 1; @@ -2407,7 +2407,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i else if(softrange > 32) fac= 1.0/2.0; /* 2px == 1 */ else fac= 1.0/16.0; /* 16px == 1? */ - temp= data->startvalue + ((mx - data->dragstartx) * fac); + temp= data->startvalue + (((double)mx - data->dragstartx) * (double)fac); temp= ui_numedit_apply_snap(temp, softmin, softmax, snap); #if 1 /* fake moving the click start, nicer for dragging back after passing the limit */ @@ -2445,22 +2445,22 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i if(softrange > 11) { /* non linear change in mouse input- good for high precicsion */ - data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.002); + data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.002f); } else if (softrange > 129) { /* only scale large int buttons */ /* non linear change in mouse input- good for high precicsionm ints need less fine tuning */ - data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabs(data->dragstartx-mx)*0.004); + data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.004f); } else { /*no scaling */ data->dragf+= ((float)(mx-data->draglastx))/deler ; } - CLAMP(data->dragf, 0.0, 1.0); + CLAMP(data->dragf, 0.0f, 1.0f); data->draglastx= mx; tempf= (softmin + data->dragf*softrange); if(!ui_is_but_float(but)) { - temp= floor(tempf+.5); + temp= floorf(tempf + 0.5f); temp= ui_numedit_apply_snap(temp, softmin, softmax, snap); @@ -2479,7 +2479,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i CLAMP(tempf, softmin, softmax); - if(tempf != data->value) { + if(tempf != (float)data->value) { data->dragchange= 1; data->value= tempf; changed= 1; @@ -2609,7 +2609,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton if(mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - tempf= data->value - 0.01*but->a1; + tempf= (float)data->value - 0.01f * but->a1; if (tempf < softmin) tempf = softmin; data->value= tempf; @@ -2618,7 +2618,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton else if(mx > but->x1 + (2*((but->x2 - but->x1)/3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - tempf= data->value + 0.01*but->a1; + tempf= (float)data->value + 0.01f * but->a1; if (tempf > softmax) tempf = softmax; data->value= tempf; @@ -2643,23 +2643,23 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i softmax= but->softmax; softrange= softmax - softmin; - if(but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0*but->aspect); - else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2 - 5.0*but->aspect); + if(but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0f*but->aspect); + else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2.0f - 5.0f*but->aspect); else if(but->type==SCROLL) { int horizontal= (but->x2 - but->x1 > but->y2 - but->y1); float size= (horizontal)? (but->x2-but->x1): -(but->y2-but->y1); deler= size*(but->softmax - but->softmin)/(but->softmax - but->softmin + but->a1); } - else deler= (but->x2-but->x1- 5.0*but->aspect); + else deler= (but->x2-but->x1- 5.0f*but->aspect); f= (float)(mx-data->dragstartx)/deler + data->dragfstart; if(shift) - f= (f-data->dragfstart)/10.0 + data->dragfstart; + f= (f-data->dragfstart)/10.0f + data->dragfstart; - CLAMP(f, 0.0, 1.0); + CLAMP(f, 0.0f, 1.0f); tempf= softmin + f*softrange; - temp= floor(tempf+.5); + temp= floorf(tempf+0.5f); if(ctrl) { if(tempf==softmin || tempf==softmax); @@ -2667,14 +2667,14 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i if(shift) { if(tempf==softmin || tempf==softmax); - else if(softmax-softmin < 2.10) tempf= 0.01*floor(100.0*tempf); - else if(softmax-softmin < 21.0) tempf= 0.1*floor(10.0*tempf); - else tempf= floor(tempf); + else if(softmax-softmin < 2.10f) tempf= 0.01f * floorf(100.0f*tempf); + else if(softmax-softmin < 21.0f) tempf= 0.1f * floorf(10.0f*tempf); + else tempf= floorf(tempf); } else { - if(softmax-softmin < 2.10) tempf= 0.1*floor(10*tempf); - else if(softmax-softmin < 21.0) tempf= floor(tempf); - else tempf= 10.0*floor(tempf/10.0); + if(softmax-softmin < 2.10f) tempf= 0.1f * floorf(10.0f*tempf); + else if(softmax-softmin < 21.0f) tempf= floorf(tempf); + else tempf= 10.0f*floorf(tempf/10.0f); } } else { @@ -2697,7 +2697,7 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i else { CLAMP(tempf, softmin, softmax); - if(tempf != data->value) { + if(tempf != (float)data->value) { data->value= tempf; data->dragchange= 1; changed= 1; @@ -2814,8 +2814,8 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton data->cancel= 1; } else { - if(f=softmin && tempf<=softmax) data->value= tempf; @@ -2983,7 +2983,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i mdy= (rad*fp[1]); } else if(fp[2]> -1.0f) { - mrad= rad/sqrt(fp[0]*fp[0] + fp[1]*fp[1]); + mrad= rad/sqrtf(fp[0]*fp[0] + fp[1]*fp[1]); mdx= 2.0f*mrad*fp[0] - (rad*fp[0]); mdy= 2.0f*mrad*fp[1] - (rad*fp[1]); @@ -3002,7 +3002,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i } else { /* outer circle */ - mrad= rad/sqrt(mrad); // veclen + mrad= rad/sqrtf(mrad); // veclen dx*= (2.0f*mrad - 1.0f); dy*= (2.0f*mrad - 1.0f); @@ -3081,8 +3081,8 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, /* relative position within box */ x= ((float)mx-but->x1)/(but->x2-but->x1); y= ((float)my-but->y1)/(but->y2-but->y1); - CLAMP(x, 0.0, 1.0); - CLAMP(y, 0.0, 1.0); + CLAMP(x, 0.0f, 1.0f); + CLAMP(y, 0.0f, 1.0f); switch((int)but->a1) { case UI_GRAD_SV: @@ -3226,7 +3226,7 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx } if(U.uiflag & USER_CONTINUOUS_MOUSE) { - float fac= shift ? 0.05 : 1.0f; + float fac= shift ? 0.05f : 1.0f; /* slow down the mouse, this is fairly picky */ mx = (data->dragstartx*(1.0f-fac) + mx*fac); my = (data->dragstarty*(1.0f-fac) + my*fac); @@ -3374,7 +3374,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx dx= ((float)(mx - data->draglastx))/(but->x2-but->x1); data->dragcbd->pos += dx; - CLAMP(data->dragcbd->pos, 0.0, 1.0); + CLAMP(data->dragcbd->pos, 0.0f, 1.0f); ui_colorband_update(data->coba); data->dragcbd= data->coba->data + data->coba->cur; /* because qsort */ @@ -3479,8 +3479,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, cmp[a].x+= fx; cmp[a].y+= fy; if(snap) { - cmp[a].x= 0.125f*floor(0.5f + 8.0f*cmp[a].x); - cmp[a].y= 0.125f*floor(0.5f + 8.0f*cmp[a].y); + cmp[a].x= 0.125f*floorf(0.5f + 8.0f*cmp[a].x); + cmp[a].y= 0.125f*floorf(0.5f + 8.0f*cmp[a].y); } if(cmp[a].x!=origx || cmp[a].y!=origy) moved_point= 1; @@ -3687,7 +3687,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx hist->height = (but->y2 - but->y1) + (data->dragstarty - my); } else { /* scale histogram values */ - yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5; + yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5f; hist->ymax += dy * yfac; CLAMP(hist->ymax, 1.f, 100.f); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index f3d1dd25c2f..25dbcf81c26 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -377,7 +377,7 @@ static void ui_draw_anti_x(float x1, float y1, float x2, float y2) static void ui_draw_x_icon(float x, float y) { - ui_draw_anti_x(x, y, x+9.375, y+9.375); + ui_draw_anti_x(x, y, x+9.375f, y+9.375f); } @@ -737,8 +737,8 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) for(a=0; apa->flag & PNL_SELECT)==0) { if((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { - ps->orig->ofsx= floor(0.5 + fac*ps->pa->ofsx + (1.0-fac)*ps->orig->ofsx); - ps->orig->ofsy= floor(0.5 + fac*ps->pa->ofsy + (1.0-fac)*ps->orig->ofsy); + ps->orig->ofsx= floorf(0.5f + fac*(float)ps->pa->ofsx + (1.0f-fac)*(float)ps->orig->ofsx); + ps->orig->ofsy= floorf(0.5f + fac*(float)ps->pa->ofsy + (1.0f-fac)*(float)ps->orig->ofsy); done= 1; } } @@ -886,9 +886,9 @@ static void check_panel_overlap(ARegion *ar, Panel *panel) else if(panel->flag & PNL_CLOSEDY) safey= 0.05; if(pa->ofsx > panel->ofsx- safex*panel->sizex) - if(pa->ofsx+pa->sizex < panel->ofsx+ (1.0+safex)*panel->sizex) + if(pa->ofsx+pa->sizex < panel->ofsx+ (1.0f+safex)*panel->sizex) if(pa->ofsy > panel->ofsy- safey*panel->sizey) - if(pa->ofsy+pa->sizey < panel->ofsy+ (1.0+safey)*panel->sizey) + if(pa->ofsy+pa->sizey < panel->ofsy+ (1.0f+safey)*panel->sizey) pa->flag |= PNL_OVERLAP; } } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index d2b1a4d8db8..4a0584bca7b 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1185,9 +1185,9 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, if(block->direction & UI_CENTER) center= ysize/2; else center= 0; - if( butrct.xmin-xsize > 0.0) left= 1; + if( butrct.xmin-xsize > 0.0f) left= 1; if( butrct.xmax+xsize < winx) right= 1; - if( butrct.ymin-ysize+center > 0.0) down= 1; + if( butrct.ymin-ysize+center > 0.0f) down= 1; if( butrct.ymax+ysize-center < winy) top= 1; dir1= block->direction & UI_DIRECTION; @@ -1300,8 +1300,8 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, /* safety calculus */ if(but) { - float midx= (butrct.xmin+butrct.xmax)/2.0; - float midy= (butrct.ymin+butrct.ymax)/2.0; + float midx= (butrct.xmin+butrct.xmax)/2.0f; + float midy= (butrct.ymin+butrct.ymax)/2.0f; /* when you are outside parent button, safety there should be smaller */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index d13de5cf0c6..2f442d930de 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2423,7 +2423,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) rti= (ReportTimerInfo *)reports->reporttimer->customdata; - if (!rti || rti->widthfac==0.0 || !report) return; + if (!rti || rti->widthfac==0.0f || !report) return; ui_abs= uiLayoutAbsolute(layout, 0); block= uiLayoutGetBlock(ui_abs); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 50d0359883b..b57d8fda712 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -173,7 +173,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y /* for each AA step */ for(j=0; j<8; j++) { - glTranslatef(1.0*jit[j][0], 1.0*jit[j][1], 0.0f); + glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); glBegin(GL_POLYGON); glVertex2f(x1, y1); @@ -181,7 +181,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y glVertex2f(x3, y3); glEnd(); - glTranslatef(-1.0*jit[j][0], -1.0*jit[j][1], 0.0f); + glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); } glDisable(GL_BLEND); @@ -696,7 +696,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) /* for each AA step */ if(wtb->outline) { for(j=0; j<8; j++) { - glTranslatef(1.0*jit[j][0], 1.0*jit[j][1], 0.0f); + glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); /* outline */ glColor4ub(wcol->outline[0], wcol->outline[1], wcol->outline[2], 32); @@ -720,7 +720,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glEnd(); } - glTranslatef(-1.0*jit[j][0], -1.0*jit[j][1], 0.0f); + glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); } } @@ -728,7 +728,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) if(wtb->tria1.tot || wtb->tria2.tot) { /* for each AA step */ for(j=0; j<8; j++) { - glTranslatef(1.0*jit[j][0], 1.0*jit[j][1], 0.0f); + glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); if(wtb->tria1.tot) { glColor4ub(wcol->item[0], wcol->item[1], wcol->item[2], 32); @@ -739,7 +739,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) widget_trias_draw(&wtb->tria2); } - glTranslatef(-1.0*jit[j][0], -1.0*jit[j][1], 0.0f); + glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); } } @@ -1700,7 +1700,7 @@ void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float else *valdist= 1.0f; - *valrad= atan2(mx, my)/(2.0f*M_PI) + 0.5f; + *valrad= atan2f(mx, my)/(2.0f*(float)M_PI) + 0.5f; } static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) @@ -1715,7 +1715,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) color_profile = BLI_PR_NONE; - radstep= 2.0f*M_PI/(float)tot; + radstep= 2.0f*(float)M_PI/(float)tot; centx= (float)(rect->xmin + rect->xmax)/2; centy= (float)(rect->ymin + rect->ymax)/2; @@ -1773,14 +1773,14 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) glPopMatrix(); /* cursor */ - ang= 2.0f*M_PI*hsvo[0] + 0.5f*M_PI; + ang= 2.0f*(float)M_PI*hsvo[0] + 0.5f*(float)M_PI; if(but->flag & UI_BUT_COLOR_CUBIC) - radius= (1.0f - pow(1.0f - hsvo[1], 3.0f)) *radius; + radius= (1.0f - powf(1.0f - hsvo[1], 3.0f)) *radius; else radius= hsvo[1] * radius; - ui_hsv_cursor(centx + cos(-ang)*radius, centy + sin(-ang)*radius); + ui_hsv_cursor(centx + cosf(-ang)*radius, centy + sinf(-ang)*radius); } @@ -1845,7 +1845,7 @@ void ui_draw_gradient(rcti *rect, float *hsv, int type, float alpha) /* old below */ - for(dx=0.0; dx<1.0; dx+= 0.05) { + for(dx=0.0f; dx<1.0f; dx+= 0.05f) { // previous color VECCOPY(col0[0], col1[0]); VECCOPY(col0[1], col1[1]); @@ -1894,7 +1894,7 @@ void ui_draw_gradient(rcti *rect, float *hsv, int type, float alpha) // rect sx1= rect->xmin + dx*(rect->xmax-rect->xmin); - sx2= rect->xmin + (dx+0.05)*(rect->xmax-rect->xmin); + sx2= rect->xmin + (dx+0.05f)*(rect->xmax-rect->xmin); sy= rect->ymin; dy= (rect->ymax-rect->ymin)/3.0; @@ -1959,8 +1959,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) /* cursor */ x= rect->xmin + x*(rect->xmax-rect->xmin); y= rect->ymin + y*(rect->ymax-rect->ymin); - CLAMP(x, rect->xmin+3.0, rect->xmax-3.0); - CLAMP(y, rect->ymin+3.0, rect->ymax-3.0); + CLAMP(x, rect->xmin+3.0f, rect->xmax-3.0f); + CLAMP(y, rect->ymin+3.0f, rect->ymax-3.0f); ui_hsv_cursor(x, y); @@ -2009,7 +2009,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) /* cursor */ x= rect->xmin + 0.5f * (rect->xmax-rect->xmin); y= rect->ymin + v * (rect->ymax-rect->ymin); - CLAMP(y, rect->ymin+3.0, rect->ymax-3.0); + CLAMP(y, rect->ymin+3.0f, rect->ymax-3.0f); ui_hsv_cursor(x, y); @@ -2039,7 +2039,7 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round { uiWidgetBase wtb; float rad= 0.5f*(rect->ymax - rect->ymin); - float textofs = rad*0.75; + float textofs = rad*0.75f; if(state & UI_SELECT) SWAP(short, wcol->shadetop, wcol->shadedown); @@ -2210,8 +2210,8 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat if(horizontal) { fac= (rect->xmax - rect->xmin)/(size); - rect1.xmin= rect1.xmin + ceil(fac*(value - but->softmin)); - rect1.xmax= rect1.xmin + ceil(fac*(but->a1 - but->softmin)); + rect1.xmin= rect1.xmin + ceilf(fac*((float)value - but->softmin)); + rect1.xmax= rect1.xmin + ceilf(fac*(but->a1 - but->softmin)); /* ensure minimium size */ min= rect->ymax - rect->ymin; @@ -2227,8 +2227,8 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat } else { fac= (rect->ymax - rect->ymin)/(size); - rect1.ymax= rect1.ymax - ceil(fac*(value - but->softmin)); - rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin)); + rect1.ymax= rect1.ymax - ceilf(fac*((float)value - but->softmin)); + rect1.ymin= rect1.ymax - ceilf(fac*(but->a1 - but->softmin)); /* ensure minimium size */ min= rect->xmax - rect->xmin; @@ -2325,7 +2325,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s rect1= *rect; value= ui_get_but_val(but); - fac= (value-but->softmin)*(rect1.xmax - rect1.xmin - offs)/(but->softmax - but->softmin); + fac= ((float)value-but->softmin)*(rect1.xmax - rect1.xmin - offs)/(but->softmax - but->softmin); /* left part of slider, always rounded */ rect1.xmax= rect1.xmin + ceil(offs+1.0f); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 81e093c07ff..d272b03fc22 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -784,10 +784,10 @@ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac) cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= floor((1.0-fac)*cp1[2] + fac*cp2[2]); + CLAMP(fac, 0.0f, 1.0f); + r= floorf((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= floorf((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= floorf((1.0f-fac)*cp1[2] + fac*cp2[2]); glColor3ub(r, g, b); } @@ -801,10 +801,10 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset) cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); + CLAMP(fac, 0.0f, 1.0f); + r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]); CLAMP(r, 0, 255); CLAMP(g, 0, 255); @@ -822,11 +822,11 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); - a= alphaoffset+floor((1.0-fac)*cp1[3] + fac*cp2[3]); + CLAMP(fac, 0.0f, 1.0f); + r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]); + a= alphaoffset + floorf((1.0f-fac)*cp1[3] + fac*cp2[3]); CLAMP(r, 0, 255); CLAMP(g, 0, 255); @@ -864,9 +864,9 @@ void UI_GetThemeColor3fv(int colorid, float *col) const unsigned char *cp; cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); - col[0]= ((float)cp[0])/255.0; - col[1]= ((float)cp[1])/255.0; - col[2]= ((float)cp[2])/255.0; + col[0]= ((float)cp[0])/255.0f; + col[1]= ((float)cp[1])/255.0f; + col[2]= ((float)cp[2])/255.0f; } // get the color, range 0.0-1.0, complete with shading offset @@ -884,9 +884,9 @@ void UI_GetThemeColorShade3fv(int colorid, int offset, float *col) b= offset + (int) cp[2]; CLAMP(b, 0, 255); - col[0]= ((float)r)/255.0; - col[1]= ((float)g)/255.0; - col[2]= ((float)b)/255.0; + col[0]= ((float)r)/255.0f; + col[1]= ((float)g)/255.0f; + col[2]= ((float)b)/255.0f; } // get the color, in char pointer @@ -927,11 +927,10 @@ void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4]) void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset) { int r, g, b; - - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); + CLAMP(fac, 0.0f, 1.0f); + r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]); r= r<0?0:(r>255?255:r); g= g<0?0:(g>255?255:g); @@ -944,16 +943,16 @@ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char c void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset) { int r, g, b; - - if(fac<0.0) fac=0.0; else if(fac>1.0) fac= 1.0; - r= offset+floor((1.0-fac)*cp1[0] + fac*cp2[0]); - g= offset+floor((1.0-fac)*cp1[1] + fac*cp2[1]); - b= offset+floor((1.0-fac)*cp1[2] + fac*cp2[2]); - - r= r<0?0:(r>255?255:r); - g= g<0?0:(g>255?255:g); - b= b<0?0:(b>255?255:b); - + + CLAMP(fac, 0.0f, 1.0f); + r= offset+floor((1.0f-fac)*cp1[0] + fac*cp2[0]); + g= offset+floor((1.0f-fac)*cp1[1] + fac*cp2[1]); + b= offset+floor((1.0f-fac)*cp1[2] + fac*cp2[2]); + + CLAMP(r, 0, 255); + CLAMP(g, 0, 255); + CLAMP(b, 0, 255); + col[0] = r; col[1] = g; col[2] = b; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 8c397d9c14f..32301dd6423 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -996,12 +996,12 @@ void UI_view2d_view_ortho(View2D *v2d) /* XXX ton: this flag set by outliner, for icons */ if(v2d->flag & V2D_PIXELOFS_X) { - curmasked.xmin= floor(curmasked.xmin) - 0.001f; - curmasked.xmax= floor(curmasked.xmax) - 0.001f; + curmasked.xmin= floorf(curmasked.xmin) - 0.001f; + curmasked.xmax= floorf(curmasked.xmax) - 0.001f; } if(v2d->flag & V2D_PIXELOFS_Y) { - curmasked.ymin= floor(curmasked.ymin) - 0.001f; - curmasked.ymax= floor(curmasked.ymax) - 0.001f; + curmasked.ymin= floorf(curmasked.ymin) - 0.001f; + curmasked.ymax= floorf(curmasked.ymax) - 0.001f; } /* set matrix on all appropriate axes */ @@ -1815,8 +1815,8 @@ void UI_view2d_listview_view_to_cell(View2D *v2d, short columnwidth, short rowhe float viewx, float viewy, int *column, int *row) { /* adjust view coordinates to be all positive ints, corrected for the start offset */ - const int x= (int)(floor(fabs(viewx) + 0.5f) - startx); - const int y= (int)(floor(fabs(viewy) + 0.5f) - starty); + const int x= (int)(floorf(fabsf(viewx) + 0.5f) - startx); + const int y= (int)(floorf(fabsf(viewy) + 0.5f) - starty); /* sizes must not be negative */ if ( (v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0)) ) { diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 10aac4ce0a6..123f9e2044f 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -607,7 +607,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax-v2d->cur.xmin); - float mval_faci = 1.0 - mval_fac; + float mval_faci = 1.0f - mval_fac; float ofs= (mval_fac * dx) - (mval_faci * dx); v2d->cur.xmin += ofs + dx; @@ -632,7 +632,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax-v2d->cur.ymin); - float mval_faci = 1.0 - mval_fac; + float mval_faci = 1.0f - mval_fac; float ofs= (mval_fac * dy) - (mval_faci * dy); v2d->cur.ymin += ofs + dy; @@ -817,7 +817,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax-v2d->cur.xmin); - float mval_faci = 1.0 - mval_fac; + float mval_faci = 1.0f - mval_fac; float ofs= (mval_fac * dx) - (mval_faci * dx); v2d->cur.xmin += ofs + dx; @@ -836,7 +836,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) else { if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax-v2d->cur.ymin); - float mval_faci = 1.0 - mval_fac; + float mval_faci = 1.0f - mval_fac; float ofs= (mval_fac * dy) - (mval_faci * dy); v2d->cur.ymin += ofs + dy; @@ -1448,9 +1448,9 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event) /* single-click was in empty space outside bubble, so scroll by 1 'page' */ if (ELEM(vsm->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) { if (vsm->zone == SCROLLHANDLE_MIN_OUTSIDE) - vsm->delta = -vsm->scrollbarwidth * 0.8; + vsm->delta = -vsm->scrollbarwidth * 0.8f; else if (vsm->zone == SCROLLHANDLE_MAX_OUTSIDE) - vsm->delta = vsm->scrollbarwidth * 0.8; + vsm->delta = vsm->scrollbarwidth * 0.8f; scroller_activate_apply(C, op); scroller_activate_exit(C, op); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index bd2cce041dd..b1586068220 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1063,9 +1063,9 @@ typedef struct Scene { #define PRVRANGEON (scene->r.flag & SCER_PRV_RANGE) #define PSFRA ((PRVRANGEON)? (scene->r.psfra): (scene->r.sfra)) #define PEFRA ((PRVRANGEON)? (scene->r.pefra): (scene->r.efra)) -#define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (a)) / scene->r.frs_sec) -#define TIME2FRA(a) ((((double) scene->r.frs_sec) * (a)) / scene->r.frs_sec_base) -#define FPS (((double) scene->r.frs_sec) / scene->r.frs_sec_base) +#define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (double)(a)) / (double)scene->r.frs_sec) +#define TIME2FRA(a) ((((double) scene->r.frs_sec) * (double)(a)) / (double)scene->r.frs_sec_base) +#define FPS (((double) scene->r.frs_sec) / (double)scene->r.frs_sec_base) #define RAD_PHASE_PATCHES 1 #define RAD_PHASE_FACES 2 From 617e6a83bc89ca36e18bd06d851a31c010e11db2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 14:59:55 +0000 Subject: [PATCH 130/261] object/paint/misc-files: floats were being implicitly promoted to doubles, adjust to use floats. - also UV angle stretching was using radians->deg which wasn't needed. --- source/blender/blenkernel/intern/constraint.c | 37 +++--- .../blender/blenlib/intern/math_base_inline.c | 8 +- .../blenlib/intern/math_vector_inline.c | 14 +-- source/blender/editors/animation/keyframing.c | 10 +- source/blender/editors/armature/poselib.c | 2 +- source/blender/editors/curve/editcurve.c | 56 ++++----- source/blender/editors/gpencil/drawgpencil.c | 6 +- source/blender/editors/metaball/mball_edit.c | 2 +- source/blender/editors/object/object_edit.c | 2 +- .../blender/editors/object/object_transform.c | 4 +- source/blender/editors/object/object_vgroup.c | 6 +- source/blender/editors/screen/glutil.c | 22 ++-- source/blender/editors/screen/screen_ops.c | 2 +- .../editors/sculpt_paint/paint_image.c | 2 +- .../blender/editors/sculpt_paint/paint_ops.c | 2 +- .../editors/sculpt_paint/paint_stroke.c | 28 ++--- .../editors/sculpt_paint/paint_utils.c | 2 +- .../editors/sculpt_paint/paint_vertex.c | 30 ++--- source/blender/editors/sculpt_paint/sculpt.c | 4 +- .../blender/editors/space_image/image_draw.c | 14 +-- .../blender/editors/space_image/image_ops.c | 10 +- .../editors/space_sequencer/sequencer_edit.c | 8 +- .../blender/editors/space_time/space_time.c | 4 +- .../editors/space_view3d/drawarmature.c | 6 +- source/blender/editors/uvedit/uvedit_draw.c | 114 +++++++++--------- 25 files changed, 196 insertions(+), 199 deletions(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 9f646a93b6a..d2e48edc7ce 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -621,7 +621,7 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *sub * PoseChannel by the Armature Object's Matrix to get a worldspace * matrix. */ - if (headtail < 0.000001) { + if (headtail < 0.000001f) { /* skip length interpolation if set to head */ mul_m4_m4m4(mat, pchan->pose_mat, ob->obmat); } @@ -994,10 +994,10 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh float neg = -1; int right_index; - if (normalize_v3_v3(n, vec) == 0.0) { - n[0] = 0.0; - n[1] = 0.0; - n[2] = 1.0; + if (normalize_v3_v3(n, vec) == 0.0f) { + n[0] = 0.0f; + n[1] = 0.0f; + n[2] = 1.0f; } if (axis > 2) axis -= 3; else negate_v3(n); @@ -1019,10 +1019,10 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh sub_v3_v3v3(proj, u, proj); /* then onto the plane */ /* proj specifies the transformation of the up axis */ - if (normalize_v3(proj) == 0.0) { /* degenerate projection */ - proj[0] = 0.0; - proj[1] = 1.0; - proj[2] = 0.0; + if (normalize_v3(proj) == 0.0f) { /* degenerate projection */ + proj[0] = 0.0f; + proj[1] = 1.0f; + proj[2] = 0.0f; } /* Normalized cross product of n and proj specifies transformation of the right axis */ @@ -1278,7 +1278,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr * factor, which then gets clamped to lie within 0.0 - 1.0 range */ curvetime /= cu->pathlen; - CLAMP(curvetime, 0.0, 1.0); + CLAMP(curvetime, 0.0f, 1.0f); } else { /* fixed position along curve */ @@ -1925,7 +1925,7 @@ static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob, ListBase /* calculate normalising scale factor for non-essential values */ if (obsize[data->flag] != 0) - fac = sqrt(volume / obsize[data->flag]) / obsize[data->flag]; + fac = sqrtf(volume / obsize[data->flag]) / obsize[data->flag]; /* apply scaling factor to the channels not being kept */ switch (data->flag) { @@ -2176,9 +2176,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint if (data->type < 10) { /* extract rotation (is in whatever space target should be in) */ mat4_to_eul(vec, tempmat); - vec[0] *= (float)(180.0/M_PI); - vec[1] *= (float)(180.0/M_PI); - vec[2] *= (float)(180.0/M_PI); + mul_v3_fl(vec, (float)(180.0/M_PI)); /* rad -> deg */ axis= data->type; } else if (data->type < 20) { @@ -2669,7 +2667,7 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * else if (data->flag & LIMITDIST_USESOFT) { // FIXME: there's a problem with "jumping" when this kicks in if (dist >= (data->dist - data->soft)) { - sfac = (float)( data->soft*(1.0 - exp(-(dist - data->dist)/data->soft)) + data->dist ); + sfac = (float)( data->soft*(1.0f - expf(-(dist - data->dist)/data->soft)) + data->dist ); sfac /= dist; clamp_surf= 1; @@ -2677,7 +2675,7 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * } } else { - if (IS_EQ(dist, data->dist)==0) { + if (IS_EQF(dist, data->dist)==0) { clamp_surf= 1; sfac= data->dist / dist; } @@ -3336,8 +3334,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * break; case 1: /* rotation (convert to degrees first) */ mat4_to_eulO(dvec, cob->rotOrder, ct->matrix); - for (i=0; i<3; i++) - dvec[i] = (float)(dvec[i] / M_PI * 180); + mul_v3_fl(dvec, (float)(180.0/M_PI)); /* rad -> deg */ break; default: /* location */ copy_v3_v3(dvec, ct->matrix[3]); @@ -3387,7 +3384,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * eul[i]= tmin + (sval[(int)data->map[i]] * (tmax - tmin)); /* now convert final value back to radians */ - eul[i] = (float)(eul[i] / 180 * M_PI); + eul[i] = DEG2RADF(eul[i]); } break; default: /* location */ @@ -4515,7 +4512,7 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) * but all are guaranteed to end up in good "worldspace" result */ /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */ - if (enf < 1.0) { + if (enf < 1.0f) { float solution[4][4]; copy_m4_m4(solution, cob->matrix); blend_m4_m4m4(cob->matrix, oldmat, solution, enf); diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index db1683efc98..d37f1d6c5f0 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -45,7 +45,7 @@ MINLINE float sqrt3f(float f) { - if(f==0.0) return 0; + if(f==0.0f) return 0.0f; if(f<0) return (float)(-exp(log(-f)/3)); else return (float)(exp(log(f)/3)); } @@ -73,7 +73,7 @@ MINLINE float saasin(float fac) MINLINE float sasqrt(float fac) { - if(fac<=0.0) return 0.0; + if(fac<=0.0f) return 0.0f; return (float)sqrt(fac); } @@ -93,7 +93,7 @@ MINLINE float saasinf(float fac) MINLINE float sasqrtf(float fac) { - if(fac<=0.0) return 0.0; + if(fac<=0.0f) return 0.0f; return (float)sqrtf(fac); } @@ -108,7 +108,7 @@ MINLINE float interpf(float target, float origin, float fac) * the distance gets very high, 180d would be inf, but this case isn't valid */ MINLINE float shell_angle_to_dist(const float angle) { - return (angle < SMALL_NUMBER) ? 1.0f : fabsf(1.0f / cosf(angle)); + return (angle < (float)SMALL_NUMBER) ? 1.0f : fabsf(1.0f / cosf(angle)); } /* used for zoom values*/ diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 185b108ffe1..9a36f000624 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -472,9 +472,9 @@ MINLINE int equals_v4v4(const float *v1, const float *v2) MINLINE int compare_v3v3(const float *v1, const float *v2, const float limit) { - if(fabs(v1[0]-v2[0])vec[1][1]; /* keyframe to be added at point where there are already two similar points? */ - if (IS_EQ(prevPosi, cFrame) && IS_EQ(beztPosi, cFrame) && IS_EQ(beztPosi, prevPosi)) { + if (IS_EQF(prevPosi, cFrame) && IS_EQF(beztPosi, cFrame) && IS_EQF(beztPosi, prevPosi)) { return KEYNEEDED_DONTADD; } /* keyframe between prev+current points ? */ if ((prevPosi <= cFrame) && (cFrame <= beztPosi)) { /* is the value of keyframe to be added the same as keyframes on either side ? */ - if (IS_EQ(prevVal, nValue) && IS_EQ(beztVal, nValue) && IS_EQ(prevVal, beztVal)) { + if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal)) { return KEYNEEDED_DONTADD; } else { @@ -420,7 +420,7 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) realVal= evaluate_fcurve(fcu, cFrame); /* compare whether it's the same as proposed */ - if (IS_EQ(realVal, nValue)) + if (IS_EQF(realVal, nValue)) return KEYNEEDED_DONTADD; else return KEYNEEDED_JUSTADD; @@ -433,7 +433,7 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) * stays around or not depends on whether the values of previous/current * beztriples and new keyframe are the same. */ - if (IS_EQ(prevVal, nValue) && IS_EQ(beztVal, nValue) && IS_EQ(prevVal, beztVal)) + if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal)) return KEYNEEDED_DELNEXT; else return KEYNEEDED_JUSTADD; @@ -471,7 +471,7 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) else valB= bezt->vec[1][1] + 1.0f; - if (IS_EQ(valA, nValue) && IS_EQ(valA, valB)) + if (IS_EQF(valA, nValue) && IS_EQF(valA, valB)) return KEYNEEDED_DELPREV; else return KEYNEEDED_JUSTADD; diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 5fc872d070d..5897da97f85 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -298,7 +298,7 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* check if any pose matches this */ // TODO: don't go looking through the list like this every time... for (marker= act->markers.first; marker; marker= marker->next) { - if (IS_EQ(marker->frame, ak->cfra)) { + if (IS_EQ(marker->frame, (double)ak->cfra)) { marker->flag = -1; break; } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index a14a75fc545..12d1327da68 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2167,8 +2167,8 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) if(bezt->f2 & SELECT) { for(i=0; i<3; i++) { val = bezt->vec[1][i]; - newval = ((beztOrig+(a-1))->vec[1][i] * 0.5) + ((beztOrig+(a+1))->vec[1][i] * 0.5); - offset = (val*((1.0/6.0)*5)) + (newval*(1.0/6.0)) - val; + newval = ((beztOrig+(a-1))->vec[1][i] * 0.5f) + ((beztOrig+(a+1))->vec[1][i] * 0.5f); + offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val; /* offset handles */ bezt->vec[1][i] += offset; bezt->vec[0][i] += offset; @@ -2187,8 +2187,8 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) if(bp->f1 & SELECT) { for(i=0; i<3; i++) { val = bp->vec[i]; - newval = ((bpOrig+(a-1))->vec[i] * 0.5) + ((bpOrig+(a+1))->vec[i] * 0.5); - offset = (val*((1.0/6.0)*5)) + (newval*(1.0/6.0)) - val; + newval = ((bpOrig+(a-1))->vec[i] * 0.5f) + ((bpOrig+(a+1))->vec[i] * 0.5f); + offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val; bp->vec[i] += offset; } @@ -2272,9 +2272,9 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_sel>0) start_rad = (nu->bezt+start_sel-1)->radius; if (end_sel!=-1 && end_sel < nu->pntsu) end_rad = (nu->bezt+start_sel+1)->radius; - if (start_rad >= 0.0 && end_rad >= 0.0) (nu->bezt+start_sel)->radius = (start_rad + end_rad)/2; - else if (start_rad >= 0.0) (nu->bezt+start_sel)->radius = start_rad; - else if (end_rad >= 0.0) (nu->bezt+start_sel)->radius = end_rad; + if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bezt+start_sel)->radius = (start_rad + end_rad)/2; + else if (start_rad >= 0.0f) (nu->bezt+start_sel)->radius = start_rad; + else if (end_rad >= 0.0f) (nu->bezt+start_sel)->radius = end_rad; } else { /* if endpoints selected, then use them */ if (start_sel==0) { @@ -2294,7 +2294,7 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) range = (float)(end_sel - start_sel) + 2.0f; for(bezt=nu->bezt+start_sel, a=start_sel; a<=end_sel; a++, bezt++) { fac = (float)(1+a-start_sel) / range; - bezt->radius = start_rad*(1.0-fac) + end_rad*fac; + bezt->radius = start_rad*(1.0f-fac) + end_rad*fac; } } } @@ -2334,9 +2334,9 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_sel>0) start_rad = (nu->bp+start_sel-1)->radius; if (end_sel!=-1 && end_sel < nu->pntsu) end_rad = (nu->bp+start_sel+1)->radius; - if (start_rad >= 0.0 && end_rad >= 0.0) (nu->bp+start_sel)->radius = (start_rad + end_rad)/2; - else if (start_rad >= 0.0) (nu->bp+start_sel)->radius = start_rad; - else if (end_rad >= 0.0) (nu->bp+start_sel)->radius = end_rad; + if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bp+start_sel)->radius = (start_rad + end_rad)/2; + else if (start_rad >= 0.0f) (nu->bp+start_sel)->radius = start_rad; + else if (end_rad >= 0.0f) (nu->bp+start_sel)->radius = end_rad; } else { /* if endpoints selected, then use them */ if (start_sel==0) { @@ -2356,7 +2356,7 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) range = (float)(end_sel - start_sel) + 2.0f; for(bp=nu->bp+start_sel, a=start_sel; a<=end_sel; a++, bp++) { fac = (float)(1+a-start_sel) / range; - bp->radius = start_rad*(1.0-fac) + end_rad*fac; + bp->radius = start_rad*(1.0f-fac) + end_rad*fac; } } } @@ -3751,7 +3751,7 @@ static void make_selection_list_nurb(ListBase *editnurb) add_v3_v3(nus->vec, bp->vec); bp++; } - mul_v3_fl(nus->vec, 1.0/(float)nu->pntsu); + mul_v3_fl(nus->vec, 1.0f/(float)nu->pntsu); } @@ -4107,7 +4107,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) nu1->knotsu= fp; - offset= nu1->knotsu[a-1] +1.0; + offset= nu1->knotsu[a-1] + 1.0f; fp= nu1->knotsu+a; for(a=0; apntsu; a++, fp++) { if(nu2->knotsu) @@ -4292,8 +4292,8 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen mul_m3_m3m3(scalemat1,imat,tmat); unit_m3(scalemat2); - scalemat2[0][0]/= M_SQRT2; - scalemat2[1][1]/= M_SQRT2; + scalemat2[0][0]/= (float)M_SQRT2; + scalemat2[1][1]/= (float)M_SQRT2; mul_m3_m3m3(tmat,persmat,bmat); mul_m3_m3m3(cmat,scalemat2,tmat); @@ -6218,10 +6218,10 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) bezt->radius = 1.0; bezt->vec[1][0]+= -grid; - bezt->vec[0][0]+= -1.5*grid; - bezt->vec[0][1]+= -0.5*grid; - bezt->vec[2][0]+= -0.5*grid; - bezt->vec[2][1]+= 0.5*grid; + bezt->vec[0][0]+= -1.5f*grid; + bezt->vec[0][1]+= -0.5f*grid; + bezt->vec[2][0]+= -0.5f*grid; + bezt->vec[2][1]+= 0.5f*grid; for(a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); bezt++; @@ -6254,7 +6254,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) } bp= nu->bp; - bp->vec[0]+= -1.5*grid; + bp->vec[0]+= -1.5f*grid; bp++; bp->vec[0]+= -grid; bp->vec[1]+= grid; @@ -6262,7 +6262,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) bp->vec[0]+= grid; bp->vec[1]+= grid; bp++; - bp->vec[0]+= 1.5*grid; + bp->vec[0]+= 1.5f*grid; bp= nu->bp; for(a=0;a<4;a++, bp++) mul_m4_v3(mat,bp->vec); @@ -6290,13 +6290,13 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) } bp= nu->bp; - bp->vec[0]+= -2.0*grid; + bp->vec[0]+= -2.0f*grid; bp++; bp->vec[0]+= -grid; bp++; bp++; bp->vec[0]+= grid; bp++; - bp->vec[0]+= 2.0*grid; + bp->vec[0]+= 2.0f*grid; bp= nu->bp; for(a=0;a<5;a++, bp++) mul_m4_v3(mat,bp->vec); @@ -6361,8 +6361,8 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) bp->vec[1]+= nurbcircle[a][1]*grid; } else { - bp->vec[0]+= 0.25*nurbcircle[a][0]*grid-.75*grid; - bp->vec[2]+= 0.25*nurbcircle[a][1]*grid; + bp->vec[0]+= 0.25f*nurbcircle[a][0]*grid-0.75f*grid; + bp->vec[2]+= 0.25f*nurbcircle[a][1]*grid; } if(a & 1) bp->vec[3]= 0.25*M_SQRT2; else bp->vec[3]= 1.0; @@ -6391,9 +6391,9 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) for(a=0; a<4; a++) { for(b=0; b<4; b++) { bp->f1= SELECT; - fac= (float)a -1.5; + fac= (float)a -1.5f; bp->vec[0]+= fac*grid; - fac= (float)b -1.5; + fac= (float)b -1.5f; bp->vec[1]+= fac*grid; if(a==1 || a==2) if(b==1 || b==2) { bp->vec[2]+= grid; diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index ffaedf6a5bc..8d41ed5fec1 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -123,7 +123,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick /* if there was a significant pressure change, stop the curve, change the thickness of the stroke, * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP) */ - if (fabs(pt->pressure - oldpressure) > 0.2f) { + if (fabsf(pt->pressure - oldpressure) > 0.2f) { glEnd(); glLineWidth(pt->pressure * thickness); glBegin(GL_LINE_STRIP); @@ -217,7 +217,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* if there was a significant pressure change, stop the curve, change the thickness of the stroke, * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP) */ - if (fabs(pt->pressure - oldpressure) > 0.2f) { + if (fabsf(pt->pressure - oldpressure) > 0.2f) { glEnd(); glLineWidth(pt->pressure * thickness); glBegin(GL_LINE_STRIP); @@ -384,7 +384,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s mt[1]= mb[1] * pthick; athick= len_v2(mt); dfac= pthick - (athick * 2); - if ( ((athick * 2) < pthick) && (IS_EQ(athick, pthick)==0) ) + if ( ((athick * 2.0f) < pthick) && (IS_EQ(athick, pthick)==0) ) { mt[0] += (mb[0] * dfac); mt[1] += (mb[1] * dfac); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 43871285ee5..1cbd7e82b95 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -230,7 +230,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op) MetaElem *ml; float percent= RNA_float_get(op->ptr, "percent"); - if(percent == 0.0) + if(percent == 0.0f) return OPERATOR_CANCELLED; ml= mb->editelems->first; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index a8d0b93fa60..eb04a2743e3 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1863,7 +1863,7 @@ static void rand_timeoffs(Scene *scene, View3D *v3d) for(base= FIRSTBASE; base; base= base->next) { if(TESTBASELIB(v3d, base)) { - base->object->sf += (BLI_drand()-0.5) * rand_ofs; + base->object->sf += ((float)BLI_drand()-0.5f) * rand_ofs; if (base->object->sf < -MAXFRAMEF) base->object->sf = -MAXFRAMEF; else if (base->object->sf > MAXFRAMEF) base->object->sf = MAXFRAMEF; } diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index c41a1bf9a75..e6bb65b1a84 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -101,9 +101,9 @@ static void object_clear_rot(Object *ob) ob->rotAxis[2]= ob->drotAxis[2]= 0.0f; /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */ - if (IS_EQ(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQ(ob->rotAxis[1], ob->rotAxis[2])) + if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2])) ob->rotAxis[1] = 1.0f; - if (IS_EQ(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQ(ob->drotAxis[1], ob->drotAxis[2])) + if (IS_EQF(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQF(ob->drotAxis[1], ob->drotAxis[2])) ob->drotAxis[1]= 1.0f; } else if (ob->rotmode == ROT_MODE_QUAT) { diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 3b0c1ff62b0..a724e5850ec 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -421,15 +421,15 @@ static void ED_vgroup_nr_vert_add(Object *ob, int def_nr, int vertnum, float wei break; case WEIGHT_ADD: dv->dw[i].weight+=weight; - if(dv->dw[i].weight >= 1.0) - dv->dw[i].weight = 1.0; + if(dv->dw[i].weight >= 1.0f) + dv->dw[i].weight = 1.0f; break; case WEIGHT_SUBTRACT: dv->dw[i].weight-=weight; /* if the weight is zero or less then * remove the vert from the deform group */ - if(dv->dw[i].weight <= 0.0) + if(dv->dw[i].weight <= 0.0f) ED_vgroup_nr_vert_remove(ob, def_nr, vertnum); break; } diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index d541550c2a7..2918c98c84a 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -346,7 +346,7 @@ void glutil_draw_filled_arc(float start, float angle, float radius, int nsegment float t= (float) i/(nsegments-1); float cur= start + t*angle; - glVertex2f(cos(cur)*radius, sin(cur)*radius); + glVertex2f(cosf(cur)*radius, sinf(cur)*radius); } glEnd(); } @@ -359,7 +359,7 @@ void glutil_draw_lined_arc(float start, float angle, float radius, int nsegments float t= (float) i/(nsegments-1); float cur= start + t*angle; - glVertex2f(cos(cur)*radius, sin(cur)*radius); + glVertex2f(cosf(cur)*radius, sinf(cur)*radius); } glEnd(); } @@ -761,9 +761,9 @@ void bglBegin(int mode) if(mode==GL_POINTS) { float value[4]; glGetFloatv(GL_POINT_SIZE_RANGE, value); - if(value[1]<2.0) { + if(value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); - pointhack= floor(value[0]+0.5); + pointhack= floor(value[0] + 0.5f); if(pointhack>4) pointhack= 4; } else glBegin(mode); @@ -774,9 +774,9 @@ int bglPointHack(void) { float value[4]; int pointhack_px; glGetFloatv(GL_POINT_SIZE_RANGE, value); - if(value[1]<2.0) { + if(value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); - pointhack_px= floor(value[0]+0.5); + pointhack_px= floorf(value[0]+0.5f); if(pointhack_px>4) pointhack_px= 4; return pointhack_px; } @@ -789,7 +789,7 @@ void bglVertex3fv(float *vec) case GL_POINTS: if(pointhack) { glRasterPos3fv(vec); - glBitmap(pointhack, pointhack, (float)pointhack/2.0, (float)pointhack/2.0, 0.0, 0.0, Squaredot); + glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); } else glVertex3fv(vec); break; @@ -802,7 +802,7 @@ void bglVertex3f(float x, float y, float z) case GL_POINTS: if(pointhack) { glRasterPos3f(x, y, z); - glBitmap(pointhack, pointhack, (float)pointhack/2.0, (float)pointhack/2.0, 0.0, 0.0, Squaredot); + glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); } else glVertex3f(x, y, z); break; @@ -860,7 +860,7 @@ void bglPolygonOffset(float viewdist, float dist) { static float winmat[16], offset=0.0; - if(dist!=0.0) { + if(dist != 0.0f) { float offs; // glEnable(GL_POLYGON_OFFSET_FILL); @@ -872,8 +872,8 @@ void bglPolygonOffset(float viewdist, float dist) /* dist is from camera to center point */ - if(winmat[15]>0.5) offs= 0.00001*dist*viewdist; // ortho tweaking - else offs= 0.0005*dist; // should be clipping value or so... + if(winmat[15]>0.5f) offs= 0.00001f*dist*viewdist; // ortho tweaking + else offs= 0.0005f*dist; // should be clipping value or so... winmat[14]-= offs; offset+= offs; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index d4b547154ed..d07cc61e680 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2776,7 +2776,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e scene->r.cfra -= step; else scene->r.cfra += step; - wt->duration -= ((float)step)/FPS; + wt->duration -= ((double)step)/FPS; } else { /* one frame +/- */ diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 83f3661ac31..27fc13a0a0a 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -866,7 +866,7 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve x_diff= fabsf(p1[0]-p2[0]); /* yuck, horizontal line, we cant do much here */ - if (x_diff < 0.000001) { /* yuck, vertical line, we cant do much here */ + if (x_diff < 0.000001f) { /* yuck, vertical line, we cant do much here */ *y_isect = (p1[0]+p2[0]) * 0.5f; return ISECT_TRUE; } diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e3b92975383..eb9fbea22f4 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -111,7 +111,7 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op) { float unprojected_radius= scalar*brush_unprojected_radius(brush); - if (unprojected_radius < 0.001) // XXX magic number + if (unprojected_radius < 0.001f) // XXX magic number unprojected_radius= 0.001f; brush_set_unprojected_radius(brush, unprojected_radius); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 1e3aa4fca1b..b63c2973758 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -265,11 +265,11 @@ static int load_tex(Sculpt *sd, Brush* br, ViewContext* vc) /* it is probably worth optimizing for those cases where the texture is not rotated by skipping the calls to atan2, sqrtf, sin, and cos. */ - if (br->mtex.tex && (rotation > 0.001 || rotation < -0.001)) { - const float angle = atan2(y, x) + rotation; + if (br->mtex.tex && (rotation > 0.001f || rotation < -0.001f)) { + const float angle = atan2f(y, x) + rotation; - x = len * cos(angle); - y = len * sin(angle); + x = len * cosf(angle); + y = len * sinf(angle); } x *= br->mtex.size[0]; @@ -337,20 +337,20 @@ static int project_brush_radius(RegionView3D* rv3d, float radius, float location // create a vector that is not orthogonal to view - if (fabsf(view[0]) < 0.1) { - nonortho[0] = view[0] + 1; + if (fabsf(view[0]) < 0.1f) { + nonortho[0] = view[0] + 1.0f; nonortho[1] = view[1]; nonortho[2] = view[2]; } - else if (fabsf(view[1]) < 0.1) { + else if (fabsf(view[1]) < 0.1f) { nonortho[0] = view[0]; - nonortho[1] = view[1] + 1; + nonortho[1] = view[1] + 1.0f; nonortho[2] = view[2]; } else { nonortho[0] = view[0]; nonortho[1] = view[1]; - nonortho[2] = view[2] + 1; + nonortho[2] = view[2] + 1.0f; } // get a vector in the plane of the view @@ -446,10 +446,10 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, if(brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { /* brush rotation */ - glTranslatef(0.5f, 0.5f, 0); - glRotatef(((brush->flag & BRUSH_RAKE) ? - sd->last_angle : sd->special_rotation) * (180.0f/M_PI), - 0, 0, 1); + glTranslatef(0.5, 0.5, 0); + glRotatef((double)((brush->flag & BRUSH_RAKE) ? + sd->last_angle : sd->special_rotation) * (180.0/M_PI), + 0.0, 0.0, 1.0); glTranslatef(-0.5f, -0.5f, 0); /* scale based on tablet pressure */ @@ -730,7 +730,7 @@ static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *ev !(stroke->brush->flag & BRUSH_ANCHORED) && !(stroke->brush->flag & BRUSH_RESTORE_MESH)) { - float u = stroke->brush->smooth_stroke_factor, v = 1.0 - u; + float u = stroke->brush->smooth_stroke_factor, v = 1.0f - u; float dx = stroke->last_mouse_position[0] - event->x, dy = stroke->last_mouse_position[1] - event->y; /* If the mouse is moving within the radius of the last move, diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 73b6d170a92..ad85a4bf29b 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -84,7 +84,7 @@ float paint_get_tex_pixel(Brush* br, float u, float v) hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 0, &texres); if (hasrgb & TEX_RGB) - texres.tin = (0.35*texres.tr + 0.45*texres.tg + 0.2*texres.tb)*texres.ta; + texres.tin = (0.35f*texres.tr + 0.45f*texres.tg + 0.2f*texres.tb)*texres.ta; return texres.tin; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 6859fd333bc..7d8c3c70708 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -171,13 +171,13 @@ static unsigned int rgba_to_mcol(float r, float g, float b, float a) unsigned int col; char *cp; - ir= floor(255.0*r); + ir= floor(255.0f * r); if(ir<0) ir= 0; else if(ir>255) ir= 255; - ig= floor(255.0*g); + ig= floor(255.0f * g); if(ig<0) ig= 0; else if(ig>255) ig= 255; - ib= floor(255.0*b); + ib= floor(255.0f * b); if(ib<0) ib= 0; else if(ib>255) ib= 255; - ia= floor(255.0*a); + ia= floor(255.0f * a); if(ia<0) ia= 0; else if(ia>255) ia= 255; cp= (char *)&col; @@ -667,7 +667,7 @@ static void vpaint_blend(VPaint *vp, unsigned int *col, unsigned int *colorig, u unsigned int testcol=0, a; char *cp, *ct, *co; - alpha= (int)(255.0*brush_alpha(brush)); + alpha= (int)(255.0f*brush_alpha(brush)); if(brush->vertexpaint_tool==VP_MIX || brush->vertexpaint_tool==VP_BLUR) testcol= mcol_blend( *colorig, paintcol, alpha); else if(brush->vertexpaint_tool==VP_ADD) testcol= mcol_add( *colorig, paintcol, alpha); @@ -762,7 +762,7 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], fl /* transpose ! */ fac= vpimat[2][0]*no[0]+vpimat[2][1]*no[1]+vpimat[2][2]*no[2]; - if(fac>0.0) { + if(fac > 0.0f) { dx= vpimat[0][0]*no[0]+vpimat[0][1]*no[1]+vpimat[0][2]*no[2]; dy= vpimat[1][0]*no[0]+vpimat[1][1]*no[1]+vpimat[1][2]*no[2]; @@ -797,20 +797,20 @@ static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float } if(tool==VP_MIX || tool==VP_BLUR) - dw->weight = paintval*alpha + dw->weight*(1.0-alpha); + dw->weight = paintval*alpha + dw->weight*(1.0f-alpha); else if(tool==VP_ADD) dw->weight += paintval*alpha; else if(tool==VP_SUB) dw->weight -= paintval*alpha; else if(tool==VP_MUL) /* first mul, then blend the fac */ - dw->weight = ((1.0-alpha) + alpha*paintval)*dw->weight; + dw->weight = ((1.0f-alpha) + alpha*paintval)*dw->weight; else if(tool==VP_LIGHTEN) { if (dw->weight < paintval) - dw->weight = paintval*alpha + dw->weight*(1.0-alpha); + dw->weight = paintval*alpha + dw->weight*(1.0f-alpha); } else if(tool==VP_DARKEN) { if (dw->weight > paintval) - dw->weight = paintval*alpha + dw->weight*(1.0-alpha); + dw->weight = paintval*alpha + dw->weight*(1.0f-alpha); } CLAMP(dw->weight, 0.0f, 1.0f); @@ -820,22 +820,22 @@ static void wpaint_blend(VPaint *wp, MDeformWeight *dw, MDeformWeight *uw, float alpha= brush_alpha(brush); if(tool==VP_MIX || tool==VP_BLUR) - testw = paintval*alpha + uw->weight*(1.0-alpha); + testw = paintval*alpha + uw->weight*(1.0f-alpha); else if(tool==VP_ADD) testw = uw->weight + paintval*alpha; else if(tool==VP_SUB) testw = uw->weight - paintval*alpha; else if(tool==VP_MUL) /* first mul, then blend the fac */ - testw = ((1.0-alpha) + alpha*paintval)*uw->weight; + testw = ((1.0f-alpha) + alpha*paintval)*uw->weight; else if(tool==VP_LIGHTEN) { if (uw->weight < paintval) - testw = paintval*alpha + uw->weight*(1.0-alpha); + testw = paintval*alpha + uw->weight*(1.0f-alpha); else testw = uw->weight; } else if(tool==VP_DARKEN) { if (uw->weight > paintval) - testw = paintval*alpha + uw->weight*(1.0-alpha); + testw = paintval*alpha + uw->weight*(1.0f-alpha); else testw = uw->weight; } @@ -1858,7 +1858,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int index for(i = 0; i < (mface->v4 ? 4 : 3); ++i) { alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*(&mface->v1)[i], mval, pressure); if(alpha) - vpaint_blend(vp, mcol+i, mcolorig+i, vpd->paintcol, (int)(alpha*255.0)); + vpaint_blend(vp, mcol+i, mcolorig+i, vpd->paintcol, (int)(alpha*255.0f)); } } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index c82b7ffdafa..1428a9a9075 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3153,8 +3153,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st float halfway[2]; float out[3]; - halfway[0] = dx*0.5 + cache->initial_mouse[0]; - halfway[1] = dy*0.5 + cache->initial_mouse[1]; + halfway[0] = (float)dx * 0.5f + cache->initial_mouse[0]; + halfway[1] = (float)dy * 0.5f + cache->initial_mouse[1]; if (sculpt_stroke_get_location(C, stroke, out, halfway)) { copy_v3_v3(sd->anchored_location, out); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index aa748745cd2..3e028607172 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -151,7 +151,7 @@ void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *f } if(zp) - ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| Z: %.4f ", 0.5+0.5*(((float)*zp)/(float)0x7fffffff)); + ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| Z: %.4f ", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); if(zpf) ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| Z: %.3f ", *zpf); (void)ofs; @@ -193,21 +193,21 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) if(gridsize<1.0f) { while(gridsize<1.0f) { - gridsize*= 4.0; - gridstep*= 4.0; + gridsize*= 4.0f; + gridstep*= 4.0f; } } else { while(gridsize>=4.0f) { - gridsize/= 4.0; - gridstep/= 4.0; + gridsize/= 4.0f; + gridstep/= 4.0f; } } /* the fine resolution level */ - blendfac= 0.25*gridsize - floor(0.25*gridsize); + blendfac= 0.25*gridsize - floor(0.25f*gridsize); CLAMP(blendfac, 0.0, 1.0); - UI_ThemeColorShade(TH_BACK, (int)(20.0*(1.0-blendfac))); + UI_ThemeColorShade(TH_BACK, (int)(20.0f*(1.0f-blendfac))); fac= 0.0f; glBegin(GL_LINES); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 3aa509ab998..56b5ed10c56 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -394,7 +394,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) switch(event->type) { case MOUSEMOVE: - factor= 1.0 + (vpd->x-event->x+vpd->y-event->y)/300.0f; + factor= 1.0f + (vpd->x-event->x+vpd->y-event->y)/300.0f; RNA_float_set(op->ptr, "factor", factor); sima_zoom_set(sima, ar, vpd->zoom*factor); ED_region_tag_redraw(CTX_wm_region(C)); @@ -522,10 +522,10 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op)) d[0]= max[0] - min[0]; d[1]= max[1] - min[1]; - size= 0.5*MAX2(d[0], d[1])*MAX2(width, height)/256.0f; + size= 0.5f*MAX2(d[0], d[1])*MAX2(width, height)/256.0f; - if(size<=0.01) size= 0.01; - sima_zoom_set(sima, ar, 0.7/size); + if(size<=0.01f) size= 0.01f; + sima_zoom_set(sima, ar, 0.7f/size); ED_region_tag_redraw(CTX_wm_region(C)); @@ -1655,7 +1655,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) my= event->y - ar->winrct.ymin; UI_view2d_region_to_view(&ar->v2d, mx, my, &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) { float *fp; char *cp; int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index dd64c17b703..a86f16ee10f 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2815,10 +2815,10 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op) rect.xmax /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin)); rect.ymax /= (float)(ABS(v2d->tot.ymax - v2d->tot.ymin)); - rect.xmin+=0.5; - rect.xmax+=0.5; - rect.ymin+=0.5; - rect.ymax+=0.5; + rect.xmin+=0.5f; + rect.xmax+=0.5f; + rect.ymin+=0.5f; + rect.ymax+=0.5f; CLAMP(rect.xmin, 0.0f, 1.0f); CLAMP(rect.ymin, 0.0f, 1.0f); diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index b3c51953d59..ca9d786c4de 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -192,9 +192,9 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) glRectf((float)sta, 0.0, (float)end, 1.0); - col[3] = 0.4; + col[3] = 0.4f; if (pid->cache->flag & PTCACHE_BAKED) { - col[0] -= 0.4; col[1] -= 0.4; col[2] -= 0.4; + col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; } glColor4fv(col); diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index a69ad1c7050..e68e1657096 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1515,7 +1515,7 @@ static void draw_pose_dofs(Object *ob) /* arcs */ if (pchan->ikflag & BONE_IK_ZLIMIT) { /* OpenGL requires rotations in degrees; so we're taking the average angle here */ - theta= 0.5f*(pchan->limitmin[2]+pchan->limitmax[2]) * (float)(180.0f/M_PI); + theta= RAD2DEGF(0.5f * (pchan->limitmin[2]+pchan->limitmax[2])); glRotatef(theta, 0.0f, 0.0f, 1.0f); glColor3ub(50, 50, 255); // blue, Z axis limit @@ -1538,7 +1538,7 @@ static void draw_pose_dofs(Object *ob) if (pchan->ikflag & BONE_IK_XLIMIT) { /* OpenGL requires rotations in degrees; so we're taking the average angle here */ - theta= 0.5f*(pchan->limitmin[0] + pchan->limitmax[0]) * (float)(180.0f/M_PI); + theta= RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0])); glRotatef(theta, 1.0f, 0.0f, 0.0f); glColor3ub(255, 50, 50); // Red, X axis limit @@ -1596,7 +1596,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* hacky... prevent outline select from drawing dashed helplines */ glGetFloatv(GL_LINE_WIDTH, &tmp); - if (tmp > 1.1) do_dashed &= ~1; + if (tmp > 1.1f) do_dashed &= ~1; if (v3d->flag & V3D_HIDE_HELPLINES) do_dashed &= ~2; /* precalc inverse matrix for drawing screen aligned */ diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 38df9a48fd0..b2a76681bff 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -72,35 +72,35 @@ static void drawcursor_sima(SpaceImage *sima, ARegion *ar) h= zoomy*height/256.0f; cpack(0xFFFFFF); - glTranslatef(sima->cursor[0], sima->cursor[1], 0.0f); - fdrawline(-0.05/w, 0, 0, 0.05/h); - fdrawline(0, 0.05/h, 0.05/w, 0); - fdrawline(0.05/w, 0, 0, -0.05/h); - fdrawline(0, -0.05/h, -0.05/w, 0); - + glTranslatef(sima->cursor[0], sima->cursor[1], 0.0); + fdrawline(-0.05f/w, 0, 0, 0.05f/h); + fdrawline(0, 0.05f/h, 0.05f/w, 0.0f); + fdrawline(0.05f/w, 0.0f, 0.0f, -0.05f/h); + fdrawline(0.0f, -0.05f/h, -0.05f/w, 0.0f); + setlinestyle(4); cpack(0xFF); - fdrawline(-0.05/w, 0, 0, 0.05/h); - fdrawline(0, 0.05/h, 0.05/w, 0); - fdrawline(0.05/w, 0, 0, -0.05/h); - fdrawline(0, -0.05/h, -0.05/w, 0); - - - setlinestyle(0); + fdrawline(-0.05f/w, 0.0f, 0.0f, 0.05f/h); + fdrawline(0.0f, 0.05f/h, 0.05f/w, 0.0f); + fdrawline(0.05f/w, 0.0f, 0.0f, -0.05f/h); + fdrawline(0.0f, -0.05f/h, -0.05f/w, 0.0f); + + + setlinestyle(0.0f); cpack(0x0); - fdrawline(-0.020/w, 0, -0.1/w, 0); - fdrawline(0.1/w, 0, .020/w, 0); - fdrawline(0, -0.020/h, 0, -0.1/h); - fdrawline(0, 0.1/h, 0, 0.020/h); - + fdrawline(-0.020f/w, 0.0f, -0.1f/w, 0.0f); + fdrawline(0.1f/w, 0.0f, 0.020f/w, 0.0f); + fdrawline(0.0f, -0.020f/h, 0.0f, -0.1f/h); + fdrawline(0.0f, 0.1f/h, 0.0f, 0.020f/h); + setlinestyle(1); cpack(0xFFFFFF); - fdrawline(-0.020/w, 0, -0.1/w, 0); - fdrawline(0.1/w, 0, .020/w, 0); - fdrawline(0, -0.020/h, 0, -0.1/h); - fdrawline(0, 0.1/h, 0, 0.020/h); - - glTranslatef(-sima->cursor[0], -sima->cursor[1], 0.0f); + fdrawline(-0.020f/w, 0.0f, -0.1f/w, 0.0f); + fdrawline(0.1f/w, 0.0f, 0.020f/w, 0.0f); + fdrawline(0.0f, -0.020f/h, 0.0f, -0.1f/h); + fdrawline(0.0f, 0.1f/h, 0.0f, 0.020f/h); + + glTranslatef(-sima->cursor[0], -sima->cursor[1], 0.0); setlinestyle(0); } @@ -215,11 +215,11 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac uvarea = uv_area(tf_uv, efa->v4 != NULL) / totuvarea; if(area < FLT_EPSILON || uvarea < FLT_EPSILON) - areadiff = 1.0; + areadiff = 1.0f; else if(area>uvarea) - areadiff = 1.0-(uvarea/area); + areadiff = 1.0f-(uvarea/area); else - areadiff = 1.0-(area/uvarea); + areadiff = 1.0f-(area/uvarea); weight_to_rgb(areadiff, col, col+1, col+2); glColor3fv(col); @@ -276,10 +276,10 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac /* This is the correct angle however we are only comparing angles * uvang1 = 90-((angle_normalized_v2v2(av1, av2) * 180.0/M_PI)-90);*/ - uvang1 = angle_normalized_v2v2(av1, av2)*180.0/M_PI; - uvang2 = angle_normalized_v2v2(av2, av3)*180.0/M_PI; - uvang3 = angle_normalized_v2v2(av3, av4)*180.0/M_PI; - uvang4 = angle_normalized_v2v2(av4, av1)*180.0/M_PI; + uvang1 = angle_normalized_v2v2(av1, av2); + uvang2 = angle_normalized_v2v2(av2, av3); + uvang3 = angle_normalized_v2v2(av3, av4); + uvang4 = angle_normalized_v2v2(av4, av1); /* 3d angles */ VECSUB(av1, efa->v4->co, efa->v1->co); normalize_v3(av1); @@ -289,30 +289,30 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac /* This is the correct angle however we are only comparing angles * ang1 = 90-((angle_normalized_v3v3(av1, av2) * 180.0/M_PI)-90);*/ - ang1 = angle_normalized_v3v3(av1, av2)*180.0/M_PI; - ang2 = angle_normalized_v3v3(av2, av3)*180.0/M_PI; - ang3 = angle_normalized_v3v3(av3, av4)*180.0/M_PI; - ang4 = angle_normalized_v3v3(av4, av1)*180.0/M_PI; + ang1 = angle_normalized_v3v3(av1, av2); + ang2 = angle_normalized_v3v3(av2, av3); + ang3 = angle_normalized_v3v3(av3, av4); + ang4 = angle_normalized_v3v3(av4, av1); glBegin(GL_QUADS); /* This simple makes the angles display worse then they really are ;) - * 1.0-pow((1.0-a), 2) */ + * 1.0-powf((1.0-a), 2) */ - a = fabs(uvang1-ang1)/180.0; - weight_to_rgb(1.0-pow((1.0-a), 2), col, col+1, col+2); + a = fabsf(uvang1-ang1)/(float)M_PI; + weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); glColor3fv(col); glVertex2fv(tf->uv[0]); - a = fabs(uvang2-ang2)/180.0; - weight_to_rgb(1.0-pow((1.0-a), 2), col, col+1, col+2); + a = fabsf(uvang2-ang2)/(float)M_PI; + weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); glColor3fv(col); glVertex2fv(tf->uv[1]); - a = fabs(uvang3-ang3)/180.0; - weight_to_rgb(1.0-pow((1.0-a), 2), col, col+1, col+2); + a = fabsf(uvang3-ang3)/(float)M_PI; + weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); glColor3fv(col); glVertex2fv(tf->uv[2]); - a = fabs(uvang4-ang4)/180.0; - weight_to_rgb(1.0-pow((1.0-a), 2), col, col+1, col+2); + a = fabsf(uvang4-ang4)/(float)M_PI; + weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); glColor3fv(col); glVertex2fv(tf->uv[3]); @@ -336,9 +336,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac /* This is the correct angle however we are only comparing angles * uvang1 = 90-((angle_normalized_v2v2(av1, av2) * 180.0/M_PI)-90); */ - uvang1 = angle_normalized_v2v2(av1, av2)*180.0/M_PI; - uvang2 = angle_normalized_v2v2(av2, av3)*180.0/M_PI; - uvang3 = angle_normalized_v2v2(av3, av1)*180.0/M_PI; + uvang1 = angle_normalized_v2v2(av1, av2); + uvang2 = angle_normalized_v2v2(av2, av3); + uvang3 = angle_normalized_v2v2(av3, av1); /* 3d angles */ VECSUB(av1, efa->v3->co, efa->v1->co); normalize_v3(av1); @@ -346,24 +346,24 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac VECSUB(av3, efa->v2->co, efa->v3->co); normalize_v3(av3); /* This is the correct angle however we are only comparing angles * ang1 = 90-((angle_normalized_v3v3(av1, av2) * 180.0/M_PI)-90); */ - ang1 = angle_normalized_v3v3(av1, av2)*180.0/M_PI; - ang2 = angle_normalized_v3v3(av2, av3)*180.0/M_PI; - ang3 = angle_normalized_v3v3(av3, av1)*180.0/M_PI; + ang1 = angle_normalized_v3v3(av1, av2); + ang2 = angle_normalized_v3v3(av2, av3); + ang3 = angle_normalized_v3v3(av3, av1); /* This simple makes the angles display worse then they really are ;) - * 1.0-pow((1.0-a), 2) */ + * 1.0f-powf((1.0-a), 2) */ glBegin(GL_TRIANGLES); - a = fabs(uvang1-ang1)/180.0; - weight_to_rgb(1.0-pow((1.0-a), 2), col, col+1, col+2); + a = fabsf(uvang1-ang1)/(float)M_PI; + weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); glColor3fv(col); glVertex2fv(tf->uv[0]); - a = fabs(uvang2-ang2)/180.0; - weight_to_rgb(1.0-pow((1.0-a), 2), col, col+1, col+2); + a = fabsf(uvang2-ang2)/(float)M_PI; + weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); glColor3fv(col); glVertex2fv(tf->uv[1]); - a = fabs(uvang3-ang3)/180.0; - weight_to_rgb(1.0-pow((1.0-a), 2), col, col+1, col+2); + a = fabsf(uvang3-ang3)/(float)M_PI; + weight_to_rgb(1.0f-powf((1.0f-a), 2.0f), col, col+1, col+2); glColor3fv(col); glVertex2fv(tf->uv[2]); } From 59cdbfd8849315984e280b92968d6cf1d9d44c4b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 15:54:20 +0000 Subject: [PATCH 131/261] math lib and UV project: floats were being implicitly promoted to doubles, adjust to use floats. --- source/blender/blenlib/intern/math_color.c | 20 ++-- source/blender/blenlib/intern/math_geom.c | 97 +++++++++---------- source/blender/blenlib/intern/math_matrix.c | 26 ++--- source/blender/blenlib/intern/math_rotation.c | 56 +++++------ source/blender/blenlib/intern/math_vector.c | 14 +-- source/blender/blenlib/intern/uvproject.c | 18 ++-- 6 files changed, 115 insertions(+), 116 deletions(-) diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 8699c3664a6..85636d23f6f 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -45,9 +45,9 @@ void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b) *b = v; } else { - h= (h - floor(h))*6.0f; + h= (h - floorf(h))*6.0f; - i = (int)floor(h); + i = (int)floorf(h); f = h - i; p = v*(1.0f-s); q = v*(1.0f-(s*f)); @@ -308,11 +308,11 @@ unsigned int rgb_to_cpack(float r, float g, float b) { int ir, ig, ib; - ir= (int)floor(255.0*r); + ir= (int)floor(255.0f*r); if(ir<0) ir= 0; else if(ir>255) ir= 255; - ig= (int)floor(255.0*g); + ig= (int)floor(255.0f*g); if(ig<0) ig= 0; else if(ig>255) ig= 255; - ib= (int)floor(255.0*b); + ib= (int)floor(255.0f*b); if(ib<0) ib= 0; else if(ib>255) ib= 255; return (ir+ (ig*256) + (ib*256*256)); @@ -342,9 +342,9 @@ void rgb_float_to_byte(const float *in, unsigned char *out) { int r, g, b; - r= (int)(in[0] * 255.0); - g= (int)(in[1] * 255.0); - b= (int)(in[2] * 255.0); + r= (int)(in[0] * 255.0f); + g= (int)(in[1] * 255.0f); + b= (int)(in[2] * 255.0f); out[0]= (char)((r <= 0)? 0 : (r >= 255)? 255 : r); out[1]= (char)((g <= 0)? 0 : (g >= 255)? 255 : g); @@ -509,8 +509,8 @@ void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset) rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); hsv[0]+= hue_offset; - 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_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); } diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index b0709c30494..9fa5775c6a1 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -94,12 +94,12 @@ float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const flo float area_tri_v2(const float v1[2], const float v2[2], const float v3[2]) { - return (float)(0.5f*fabs((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0]))); + return 0.5f * fabsf((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0])); } float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]) { - return (float)(0.5f*((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0]))); + return 0.5f * ((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0])); } float area_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]) /* only convex Quadrilaterals */ @@ -158,7 +158,7 @@ float area_poly_v3(int nr, float verts[][3], float *normal) cur= verts[a+1]; } - return (float)fabs(0.5*area/max); + return fabsf(0.5f * area / max); } /********************************* Distance **********************************/ @@ -174,7 +174,7 @@ float dist_to_line_v2(float *v1, float *v2, float *v3) deler= (float)sqrt(a[0]*a[0]+a[1]*a[1]); if(deler== 0.0f) return 0; - return (float)(fabs((v1[0]-v2[0])*a[0]+(v1[1]-v2[1])*a[1])/deler); + return fabsf((v1[0]-v2[0])*a[0]+(v1[1]-v2[1])*a[1])/deler; } @@ -186,18 +186,18 @@ float dist_to_line_segment_v2(float *v1, float *v2, float *v3) rc[0]= v3[0]-v2[0]; rc[1]= v3[1]-v2[1]; len= rc[0]*rc[0]+ rc[1]*rc[1]; - if(len==0.0) { + if(len==0.0f) { rc[0]= v1[0]-v2[0]; rc[1]= v1[1]-v2[1]; return (float)(sqrt(rc[0]*rc[0]+ rc[1]*rc[1])); } labda= (rc[0]*(v1[0]-v2[0]) + rc[1]*(v1[1]-v2[1]))/len; - if(labda<=0.0) { + if(labda <= 0.0f) { pt[0]= v2[0]; pt[1]= v2[1]; } - else if(labda>=1.0) { + else if(labda >= 1.0f) { pt[0]= v3[0]; pt[1]= v3[1]; } @@ -263,14 +263,14 @@ int isect_line_line_v2(const float *v1, const float *v2, const float *v3, const float div, labda, mu; div= (v2[0]-v1[0])*(v4[1]-v3[1])-(v2[1]-v1[1])*(v4[0]-v3[0]); - if(div==0.0) return ISECT_LINE_LINE_COLINEAR; + if(div==0.0f) return ISECT_LINE_LINE_COLINEAR; labda= ((float)(v1[1]-v3[1])*(v4[0]-v3[0])-(v1[0]-v3[0])*(v4[1]-v3[1]))/div; mu= ((float)(v1[1]-v3[1])*(v2[0]-v1[0])-(v1[0]-v3[0])*(v2[1]-v1[1]))/div; - 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 ISECT_LINE_LINE_EXACT; + 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 ISECT_LINE_LINE_EXACT; return ISECT_LINE_LINE_CROSS; } return ISECT_LINE_LINE_NONE; @@ -407,15 +407,15 @@ static short IsectLLPt2Df(float x0,float y0,float x1,float y1, int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2]) { - if (line_point_side_v2(v1,v2,pt)>=0.0) { - if (line_point_side_v2(v2,v3,pt)>=0.0) { - if (line_point_side_v2(v3,v1,pt)>=0.0) { + if (line_point_side_v2(v1,v2,pt)>=0.0f) { + if (line_point_side_v2(v2,v3,pt)>=0.0f) { + if (line_point_side_v2(v3,v1,pt)>=0.0f) { return 1; } } } else { - if (! (line_point_side_v2(v2,v3,pt)>=0.0)) { - if (! (line_point_side_v2(v3,v1,pt)>=0.0)) { + if (! (line_point_side_v2(v2,v3,pt)>=0.0f)) { + if (! (line_point_side_v2(v3,v1,pt)>=0.0f)) { return -1; } } @@ -426,18 +426,18 @@ int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2]) /* point in quad - only convex quads */ int isect_point_quad_v2(float pt[2], float v1[2], float v2[2], float v3[2], float v4[2]) { - if (line_point_side_v2(v1,v2,pt)>=0.0) { - if (line_point_side_v2(v2,v3,pt)>=0.0) { - if (line_point_side_v2(v3,v4,pt)>=0.0) { - if (line_point_side_v2(v4,v1,pt)>=0.0) { + if (line_point_side_v2(v1,v2,pt)>=0.0f) { + if (line_point_side_v2(v2,v3,pt)>=0.0f) { + if (line_point_side_v2(v3,v4,pt)>=0.0f) { + if (line_point_side_v2(v4,v1,pt)>=0.0f) { return 1; } } } } else { - if (! (line_point_side_v2(v2,v3,pt)>=0.0)) { - if (! (line_point_side_v2(v3,v4,pt)>=0.0)) { - if (! (line_point_side_v2(v4,v1,pt)>=0.0)) { + if (! (line_point_side_v2(v2,v3,pt)>=0.0f)) { + if (! (line_point_side_v2(v3,v4,pt)>=0.0f)) { + if (! (line_point_side_v2(v4,v1,pt)>=0.0f)) { return -1; } } @@ -463,21 +463,21 @@ int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float cross_v3_v3v3(p, d, e2); a = dot_v3v3(e1, p); - if ((a > -0.000001) && (a < 0.000001)) return 0; + if ((a > -0.000001f) && (a < 0.000001f)) return 0; f = 1.0f/a; sub_v3_v3v3(s, p1, v0); u = f * dot_v3v3(s, p); - if ((u < 0.0)||(u > 1.0)) return 0; + if ((u < 0.0f)||(u > 1.0f)) return 0; cross_v3_v3v3(q, s, e1); v = f * dot_v3v3(d, q); - if ((v < 0.0)||((u + v) > 1.0)) return 0; + if ((v < 0.0f)||((u + v) > 1.0f)) return 0; *lambda = f * dot_v3v3(e2, q); - if ((*lambda < 0.0)||(*lambda > 1.0)) return 0; + if ((*lambda < 0.0f)||(*lambda > 1.0f)) return 0; if(uv) { uv[0]= u; @@ -503,21 +503,21 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2 a = dot_v3v3(e1, p); /* note: these values were 0.000001 in 2.4x but for projection snapping on * a human head (1BU==1m), subsurf level 2, this gave many errors - campbell */ - if ((a > -0.00000001) && (a < 0.00000001)) return 0; + if ((a > -0.00000001f) && (a < 0.00000001f)) return 0; f = 1.0f/a; sub_v3_v3v3(s, p1, v0); u = f * dot_v3v3(s, p); - if ((u < 0.0)||(u > 1.0)) return 0; - + if ((u < 0.0f)||(u > 1.0f)) return 0; + cross_v3_v3v3(q, s, e1); v = f * dot_v3v3(d, q); - if ((v < 0.0)||((u + v) > 1.0)) return 0; + if ((v < 0.0f)||((u + v) > 1.0f)) return 0; *lambda = f * dot_v3v3(e2, q); - if ((*lambda < 0.0)) return 0; + if ((*lambda < 0.0f)) return 0; if(uv) { uv[0]= u; @@ -572,14 +572,14 @@ int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3] cross_v3_v3v3(p, d, e2); a = dot_v3v3(e1, p); - if ((a > -0.000001) && (a < 0.000001)) return 0; + if ((a > -0.000001f) && (a < 0.000001f)) return 0; f = 1.0f/a; sub_v3_v3v3(s, p1, v0); cross_v3_v3v3(q, s, e1); *lambda = f * dot_v3v3(e2, q); - if ((*lambda < 0.0)) return 0; + if ((*lambda < 0.0f)) return 0; u = f * dot_v3v3(s, p); v = f * dot_v3v3(d, q); @@ -673,10 +673,9 @@ int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v a=dot_v3v3(p1,nor)-dot_v3v3(v0,nor); nordotv=dot_v3v3(nor,vel); - if (fabs(nordotv) < 0.000001) + if (fabsf(nordotv) < 0.000001f) { - if(fabs(a)>=radius) - { + if(fabsf(a) >= radius) { return 0; } } @@ -870,25 +869,25 @@ int isect_axial_line_tri_v3(int axis, float p1[3], float p2[3], float v0[3], flo sub_v3_v3v3(p,v0,p1); f= (e2[a1]*e1[a2]-e2[a2]*e1[a1]); - if ((f > -0.000001) && (f < 0.000001)) return 0; + if ((f > -0.000001f) && (f < 0.000001f)) return 0; v= (p[a2]*e1[a1]-p[a1]*e1[a2])/f; - if ((v < 0.0)||(v > 1.0)) return 0; + if ((v < 0.0f)||(v > 1.0f)) return 0; f= e1[a1]; - if((f > -0.000001) && (f < 0.000001)){ + if((f > -0.000001f) && (f < 0.000001f)){ f= e1[a2]; - if((f > -0.000001) && (f < 0.000001)) return 0; + if((f > -0.000001f) && (f < 0.000001f)) return 0; u= (-p[a2]-v*e2[a2])/f; } else u= (-p[a1]-v*e2[a1])/f; - if ((u < 0.0)||((u + v) > 1.0)) return 0; + if ((u < 0.0f) || ((u + v) > 1.0f)) return 0; *lambda = (p[a0]+u*e1[a0]+v*e2[a0])/(p2[a0]-p1[a0]); - if ((*lambda < 0.0)||(*lambda > 1.0)) return 0; + if ((*lambda < 0.0f) || (*lambda > 1.0f)) return 0; return 1; } @@ -1455,7 +1454,7 @@ static int barycentric_weights(float *v1, float *v2, float *v3, float *co, float asum= a1 + a2 + a3; - if (fabs(asum) < FLT_EPSILON) { + if (fabsf(asum) < FLT_EPSILON) { /* zero area triangle */ w[0]= w[1]= w[2]= 1.0f/3.0f; return 1; @@ -1750,7 +1749,7 @@ void orthographic_m4(float matrix[][4],float left, float right, float bottom, fl Xdelta = right - left; Ydelta = top - bottom; Zdelta = farClip - nearClip; - if (Xdelta == 0.0 || Ydelta == 0.0 || Zdelta == 0.0) { + if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) { return; } unit_m4(matrix); @@ -1770,7 +1769,7 @@ void perspective_m4(float mat[][4],float left, float right, float bottom, float Ydelta = top - bottom; Zdelta = farClip - nearClip; - if (Xdelta == 0.0 || Ydelta == 0.0 || Zdelta == 0.0) { + if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) { return; } mat[0][0] = nearClip * 2.0f/Xdelta; @@ -1857,7 +1856,7 @@ void lookat_m4(float mat[][4],float vx, float vy, float vz, float px, float py, hyp1 = (float)sqrt(dy*dy + hyp); hyp = (float)sqrt(hyp); /* the real hyp */ - if (hyp1 != 0.0) { /* rotate X */ + if (hyp1 != 0.0f) { /* rotate X */ sine = -dy / hyp1; cosine = hyp /hyp1; } else { @@ -1971,7 +1970,7 @@ void map_to_sphere(float *u, float *v,float x, float y, float z) len= (float)sqrt(x*x+y*y+z*z); if(len > 0.0f) { if(x==0.0f && y==0.0f) *u= 0.0f; /* othwise domain error */ - else *u = (float)((1.0 - (float)atan2(x,y) / M_PI) / 2.0); + else *u = (1.0f - atan2f(x,y) / (float)M_PI) / 2.0f; z/=len; *v = 1.0f - (float)saacos(z)/(float)M_PI; @@ -2040,7 +2039,7 @@ void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, float *tang, /* find a tangent with connected uvs */ for(vt= *vtang; vt; vt=vt->next) { - if(fabs(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabs(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT) { + if(fabsf(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT) { add_v3_v3(vt->tang, tang); return; } @@ -2063,7 +2062,7 @@ float *find_vertex_tangent(VertexTangent *vtang, float *uv) static float nulltang[3] = {0.0f, 0.0f, 0.0f}; for(vt= vtang; vt; vt=vt->next) - if(fabs(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabs(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT) + if(fabsf(uv[0]-vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1]-vt->uv[1]) < STD_UV_CONNECT_LIMIT) return vt->tang; return nulltang; /* shouldn't happen, except for nan or so */ diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 289d279c9a1..9fde87d734f 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -535,7 +535,7 @@ int invert_m4_m4(float inverse[4][4], float mat[4][4]) max = fabs(tempmat[i][i]); maxj = i; for(j = i + 1; j < 4; j++) { - if(fabs(tempmat[j][i]) > max) { + if(fabsf(tempmat[j][i]) > max) { max = fabs(tempmat[j][i]); maxj = j; } @@ -760,13 +760,13 @@ void orthogonalize_m4(float mat[][4], int axis) int is_orthogonal_m3(float mat[][3]) { - if (fabs(dot_v3v3(mat[0], mat[1])) > 1.5 * FLT_EPSILON) + if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON) return 0; - if (fabs(dot_v3v3(mat[1], mat[2])) > 1.5 * FLT_EPSILON) + if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON) return 0; - if (fabs(dot_v3v3(mat[0], mat[2])) > 1.5 * FLT_EPSILON) + if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON) return 0; return 1; @@ -774,13 +774,13 @@ int is_orthogonal_m3(float mat[][3]) int is_orthogonal_m4(float mat[][4]) { - if (fabs(dot_v3v3(mat[0], mat[1])) > 1.5 * FLT_EPSILON) + if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON) return 0; - if (fabs(dot_v3v3(mat[1], mat[2])) > 1.5 * FLT_EPSILON) + if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON) return 0; - if (fabs(dot_v3v3(mat[0], mat[2])) > 1.5 * FLT_EPSILON) + if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON) return 0; return 1; @@ -806,11 +806,11 @@ void normalize_m4(float mat[][4]) float len; len= normalize_v3(mat[0]); - if(len!=0.0) mat[0][3]/= len; + if(len!=0.0f) mat[0][3]/= len; len= normalize_v3(mat[1]); - if(len!=0.0) mat[1][3]/= len; + if(len!=0.0f) mat[1][3]/= len; len= normalize_v3(mat[2]); - if(len!=0.0) mat[2][3]/= len; + if(len!=0.0f) mat[2][3]/= len; } void normalize_m4_m4(float rmat[][4], float mat[][4]) @@ -818,11 +818,11 @@ void normalize_m4_m4(float rmat[][4], float mat[][4]) float len; len= normalize_v3_v3(rmat[0], mat[0]); - if(len!=0.0) rmat[0][3]= mat[0][3] / len; + if(len!=0.0f) rmat[0][3]= mat[0][3] / len; len= normalize_v3_v3(rmat[1], mat[1]); - if(len!=0.0) rmat[1][3]= mat[1][3] / len; + if(len!=0.0f) rmat[1][3]= mat[1][3] / len; len= normalize_v3_v3(rmat[2], mat[2]); - if(len!=0.0) rmat[2][3]= mat[2][3] / len;; + if(len!=0.0f) rmat[2][3]= mat[2][3] / len;; } void adjoint_m3_m3(float m1[][3], float m[][3]) diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index d9afd9f3cd4..4e37de93ded 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -167,10 +167,10 @@ static void quat_to_mat3_no_error(float m[][3], const float q[4]) { double q0, q1, q2, q3, qda,qdb,qdc,qaa,qab,qac,qbb,qbc,qcc; - q0= M_SQRT2 * q[0]; - q1= M_SQRT2 * q[1]; - q2= M_SQRT2 * q[2]; - q3= M_SQRT2 * q[3]; + q0= M_SQRT2 * (double)q[0]; + q1= M_SQRT2 * (double)q[1]; + q2= M_SQRT2 * (double)q[2]; + q3= M_SQRT2 * (double)q[3]; qda= q0*q1; qdb= q0*q2; @@ -200,7 +200,7 @@ void quat_to_mat3(float m[][3], const float q[4]) { #ifdef DEBUG float f; - if(!((f=dot_qtqt(q, q))==0.0 || (fabs(f-1.0) < QUAT_EPSILON))) { + if(!((f=dot_qtqt(q, q))==0.0f || (fabsf(f-1.0f) < (float)QUAT_EPSILON))) { fprintf(stderr, "Warning! quat_to_mat3() called with non-normalized: size %.8f *** report a bug ***\n", f); } #endif @@ -213,15 +213,15 @@ void quat_to_mat4(float m[][4], const float q[4]) double q0, q1, q2, q3, qda,qdb,qdc,qaa,qab,qac,qbb,qbc,qcc; #ifdef DEBUG - if(!((q0=dot_qtqt(q, q))==0.0 || (fabs(q0-1.0) < QUAT_EPSILON))) { + if(!((q0=dot_qtqt(q, q))==0.0f || (fabsf(q0-1.0f) < (float)QUAT_EPSILON))) { fprintf(stderr, "Warning! quat_to_mat4() called with non-normalized: size %.8f *** report a bug ***\n", (float)q0); } #endif - q0= M_SQRT2 * q[0]; - q1= M_SQRT2 * q[1]; - q2= M_SQRT2 * q[2]; - q3= M_SQRT2 * q[3]; + q0= M_SQRT2 * (double)q[0]; + q1= M_SQRT2 * (double)q[1]; + q2= M_SQRT2 * (double)q[2]; + q3= M_SQRT2 * (double)q[3]; qda= q0*q1; qdb= q0*q2; @@ -261,9 +261,9 @@ void mat3_to_quat(float *q, float wmat[][3]) copy_m3_m3(mat, wmat); normalize_m3(mat); /* this is needed AND a NormalQuat in the end */ - tr= 0.25*(1.0+mat[0][0]+mat[1][1]+mat[2][2]); + tr= 0.25* (double)(1.0f+mat[0][0]+mat[1][1]+mat[2][2]); - if(tr>FLT_EPSILON) { + if(tr>(double)FLT_EPSILON) { s= sqrt(tr); q[0]= (float)s; s= 1.0/(4.0*s); @@ -273,7 +273,7 @@ void mat3_to_quat(float *q, float wmat[][3]) } else { if(mat[0][0] > mat[1][1] && mat[0][0] > mat[2][2]) { - s= 2.0*sqrtf(1.0 + mat[0][0] - mat[1][1] - mat[2][2]); + s= 2.0*sqrtf(1.0f + mat[0][0] - mat[1][1] - mat[2][2]); q[1]= (float)(0.25*s); s= 1.0/s; @@ -282,7 +282,7 @@ void mat3_to_quat(float *q, float wmat[][3]) q[3]= (float)((mat[2][0] + mat[0][2])*s); } else if(mat[1][1] > mat[2][2]) { - s= 2.0*sqrtf(1.0 + mat[1][1] - mat[0][0] - mat[2][2]); + s= 2.0*sqrtf(1.0f + mat[1][1] - mat[0][0] - mat[2][2]); q[2]= (float)(0.25*s); s= 1.0/s; @@ -361,7 +361,7 @@ float normalize_qt(float *q) float len; len= (float)sqrt(dot_qtqt(q, q)); - if(len!=0.0) { + if(len!=0.0f) { mul_qt_fl(q, 1.0f/len); } else { @@ -428,7 +428,7 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag) q[1]=q[2]=q[3]= 0.0; len1= (float)sqrt(x2*x2+y2*y2+z2*z2); - if(len1 == 0.0) return; + if(len1 == 0.0f) return; /* nasty! I need a good routine for this... * problem is a rotation of an Y axis to the negative Y-axis for example. @@ -631,7 +631,7 @@ void tri_to_quat(float quat[4], const float v1[3], const float v2[3], const floa q2[1]= 0.0f; q2[2]= 0.0f; q2[3]= si; - + mul_qt_qtqt(quat, q1, q2); } @@ -667,7 +667,7 @@ void quat_to_axis_angle(float axis[3], float *angle, const float q[4]) float ha, si; #ifdef DEBUG - if(!((ha=dot_qtqt(q, q))==0.0 || (fabs(ha-1.0) < QUAT_EPSILON))) { + if(!((ha=dot_qtqt(q, q))==0.0f || (fabsf(ha-1.0f) < (float)QUAT_EPSILON))) { fprintf(stderr, "Warning! quat_to_axis_angle() called with non-normalized: size %.8f *** report a bug ***\n", ha); } #endif @@ -846,8 +846,8 @@ void vec_rot_to_quat(float *quat, const float vec[3], const float phi) unit_qt(quat); } else { - quat[0]= (float)cos(phi/2.0); - si= (float)sin(phi/2.0); + quat[0]= (float)cos((double)phi/2.0); + si= (float)sin((double)phi/2.0); quat[1] *= si; quat[2] *= si; quat[3] *= si; @@ -928,7 +928,7 @@ static void mat3_to_eul2(float tmat[][3], float eul1[3], float eul2[3]) cy = (float)sqrt(mat[0][0]*mat[0][0] + mat[0][1]*mat[0][1]); - if (cy > 16.0*FLT_EPSILON) { + if (cy > 16.0f*FLT_EPSILON) { eul1[0] = (float)atan2(mat[1][2], mat[2][2]); eul1[1] = (float)atan2(-mat[0][2], cy); @@ -1045,13 +1045,13 @@ void compatible_eul(float eul[3], const float oldrot[3]) /* is 1 of the axis rotations larger than 180 degrees and the other small? NO ELSE IF!! */ if(fabs(dx) > 3.2 && fabs(dy)<1.6 && fabs(dz)<1.6) { - if(dx > 0.0) eul[0] -= 2.0f*(float)M_PI; else eul[0]+= 2.0f*(float)M_PI; + if(dx > 0.0f) eul[0] -= 2.0f*(float)M_PI; else eul[0]+= 2.0f*(float)M_PI; } if(fabs(dy) > 3.2 && fabs(dz)<1.6 && fabs(dx)<1.6) { - if(dy > 0.0) eul[1] -= 2.0f*(float)M_PI; else eul[1]+= 2.0f*(float)M_PI; + if(dy > 0.0f) eul[1] -= 2.0f*(float)M_PI; else eul[1]+= 2.0f*(float)M_PI; } if(fabs(dz) > 3.2 && fabs(dx)<1.6 && fabs(dy)<1.6) { - if(dz > 0.0) eul[2] -= 2.0f*(float)M_PI; else eul[2]+= 2.0f*(float)M_PI; + if(dz > 0.0f) eul[2] -= 2.0f*(float)M_PI; else eul[2]+= 2.0f*(float)M_PI; } /* the method below was there from ancient days... but why! probably because the code sucks :) @@ -1222,7 +1222,7 @@ static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, short order) cy= sqrt(m[i][i]*m[i][i] + m[i][j]*m[i][j]); - if (cy > 16*FLT_EPSILON) { + if (cy > 16.0*(double)FLT_EPSILON) { e1[i] = atan2(m[j][k], m[k][k]); e1[j] = atan2(-m[i][k], cy); e1[k] = atan2(m[i][j], m[i][i]); @@ -1417,7 +1417,7 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4]) copy_v3_v3(dscale, scale); dscale[0] -= 1.0f; dscale[1] -= 1.0f; dscale[2] -= 1.0f; - if((determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4) { + if((determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4f) { /* extract R and S */ float tmp[4][4]; @@ -1668,10 +1668,10 @@ void vec_apply_track(float vec[3], short axis) /* lens/angle conversion (radians) */ float lens_to_angle(float lens) { - return 2.0f * atan(16.0f/lens); + return 2.0f * atanf(16.0f/lens); } float angle_to_lens(float angle) { - return 16.0f / tan(angle * 0.5f); + return 16.0f / tanf(angle * 0.5f); } diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 081f8781d9e..15d671e38d7 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -207,10 +207,10 @@ void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const f normalize_v3(ed2); normalize_v3(ed3); - angles[0]= M_PI - angle_normalized_v3v3(ed1, ed2); - angles[1]= M_PI - angle_normalized_v3v3(ed2, ed3); + angles[0]= (float)M_PI - angle_normalized_v3v3(ed1, ed2); + angles[1]= (float)M_PI - angle_normalized_v3v3(ed2, ed3); // face_angles[2] = M_PI - angle_normalized_v3v3(ed3, ed1); - angles[2]= M_PI - (angles[0] + angles[1]); + angles[2]= (float)M_PI - (angles[0] + angles[1]); } void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3]) @@ -227,10 +227,10 @@ void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const normalize_v3(ed3); normalize_v3(ed4); - angles[0]= M_PI - angle_normalized_v3v3(ed1, ed2); - angles[1]= M_PI - angle_normalized_v3v3(ed2, ed3); - angles[2]= M_PI - angle_normalized_v3v3(ed3, ed4); - angles[3]= M_PI - angle_normalized_v3v3(ed4, ed1); + angles[0]= (float)M_PI - angle_normalized_v3v3(ed1, ed2); + angles[1]= (float)M_PI - angle_normalized_v3v3(ed2, ed3); + angles[2]= (float)M_PI - angle_normalized_v3v3(ed3, ed4); + angles[3]= (float)M_PI - angle_normalized_v3v3(ed4, ed1); } /********************************* Geometry **********************************/ diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index 02b266ec160..d139fb1ab71 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -60,7 +60,7 @@ void project_from_camera(float target[2], float source[3], UvCameraInfo *uci) mul_m4_v4(uci->caminv, pv4); if(uci->do_pano) { - float angle= atan2f(pv4[0], -pv4[2]) / (M_PI * 2.0); /* angle around the camera */ + float angle= atan2f(pv4[0], -pv4[2]) / ((float)M_PI * 2.0f); /* angle around the camera */ if (uci->do_persp==0) { target[0]= angle; /* no correct method here, just map to 0-1 */ target[1]= pv4[1] / uci->camsize; @@ -69,7 +69,7 @@ void project_from_camera(float target[2], float source[3], UvCameraInfo *uci) float vec2d[2]; /* 2D position from the camera */ vec2d[0]= pv4[0]; vec2d[1]= pv4[2]; - target[0]= angle * (M_PI / uci->camangle); + target[0]= angle * ((float)M_PI / uci->camangle); target[1]= pv4[1] / (len_v2(vec2d) * uci->camsize); } } @@ -109,23 +109,23 @@ void project_from_view(float target[2], float source[3], float persmat[4][4], fl /* almost project_short */ mul_m4_v4(persmat, pv4); - if(fabs(pv4[3]) > 0.00001) { /* avoid division by zero */ - target[0] = winx/2.0 + (winx/2.0) * pv4[0] / pv4[3]; - target[1] = winy/2.0 + (winy/2.0) * pv4[1] / pv4[3]; + if(fabsf(pv4[3]) > 0.00001f) { /* avoid division by zero */ + target[0] = winx/2.0f + (winx/2.0f) * pv4[0] / pv4[3]; + target[1] = winy/2.0f + (winy/2.0f) * pv4[1] / pv4[3]; } else { /* scaling is lost but give a valid result */ - target[0] = winx/2.0 + (winx/2.0) * pv4[0]; - target[1] = winy/2.0 + (winy/2.0) * pv4[1]; + target[0] = winx/2.0f + (winx/2.0f) * pv4[0]; + target[1] = winy/2.0f + (winy/2.0f) * pv4[1]; } /* v3d->persmat seems to do this funky scaling */ if(winx > winy) { - y= (winx - winy)/2.0; + y= (winx - winy)/2.0f; winy = winx; } else { - x= (winy - winx)/2.0; + x= (winy - winx)/2.0f; winx = winy; } From 4237c0393a9d1f089f01dd7c4b223b1f61b15023 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 15:57:27 +0000 Subject: [PATCH 132/261] view3d / object drawing: floats were being implicitly promoted to doubles, adjust to use floats. --- .../blender/editors/space_view3d/drawobject.c | 158 +++++++++--------- .../editors/space_view3d/view3d_buttons.c | 20 +-- .../editors/space_view3d/view3d_draw.c | 45 +++-- .../editors/space_view3d/view3d_edit.c | 62 +++---- .../blender/editors/space_view3d/view3d_fly.c | 33 ++-- .../editors/space_view3d/view3d_select.c | 6 +- .../editors/space_view3d/view3d_snap.c | 34 ++-- .../editors/space_view3d/view3d_view.c | 82 ++++----- 8 files changed, 220 insertions(+), 220 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index c18ec4b617c..e656c0ebb91 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -153,16 +153,16 @@ static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, int l mul_m4_v4(rv3d->persmatob, vec4); /* clipplanes in window space */ - if( vec4[3]>BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */ + if( vec4[3] > (float)BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); if( fx>0 && fxwinx) { fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); - if(fy>0.0 && fy< (float)ar->winy) { - adr[0]= (short)floor(fx); - adr[1]= (short)floor(fy); + if(fy > 0.0f && fy < (float)ar->winy) { + adr[0]= (short)floorf(fx); + adr[1]= (short)floorf(fy); } } } @@ -181,16 +181,16 @@ static void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr) mul_m4_v4(rv3d->persmatob, vec4); - if( vec4[3]>BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */ + if( vec4[3] > (float)BL_NEAR_CLIP ) { /* is the NEAR clipping cutoff for picking */ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); if( fx>-32700 && fx<32700) { fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); - if(fy>-32700.0 && fy<32700.0) { - adr[0]= (short)floor(fx); - adr[1]= (short)floor(fy); + if(fy > -32700.0f && fy < 32700.0f) { + adr[0]= (short)floorf(fx); + adr[1]= (short)floorf(fy); } } } @@ -325,7 +325,7 @@ static float cosval[32] ={ static void draw_xyz_wire(const float c[3], float size, int axis) { float v1[3]= {0.f, 0.f, 0.f}, v2[3] = {0.f, 0.f, 0.f}; - float dim = size * 0.1; + float dim = size * 0.1f; float dx[3], dy[3], dz[3]; dx[0]=dim; dx[1]=0.f; dx[2]=0.f; @@ -444,9 +444,9 @@ void drawaxes(float size, char drawtype) /* square pyramid */ glBegin(GL_TRIANGLES); - v2[0]= size*0.035; v2[1] = size*0.035; - v3[0]= size*-0.035; v3[1] = size*0.035; - v2[2]= v3[2]= size*0.75; + v2[0]= size * 0.035f; v2[1] = size * 0.035f; + v3[0]= size * -0.035f; v3[1] = size * 0.035f; + v2[2]= v3[2]= size * 0.75f; for (axis=0; axis<4; axis++) { if (axis % 2 == 1) { @@ -492,18 +492,18 @@ void drawaxes(float size, char drawtype) glVertex3fv(v1); glVertex3fv(v2); - v1[axis]= size*0.85; - v1[arrow_axis]= -size*0.08; + v1[axis]= size*0.85f; + v1[arrow_axis]= -size*0.08f; glVertex3fv(v1); glVertex3fv(v2); - v1[arrow_axis]= size*0.08; + v1[arrow_axis]= size*0.08f; glVertex3fv(v1); glVertex3fv(v2); glEnd(); - v2[axis]+= size*0.125; + v2[axis]+= size*0.125f; draw_xyz_wire(v2, size, axis); @@ -824,7 +824,7 @@ static void spotvolume(float *lvec, float *vvec, float inp) q[3] = 0 ; normalize_v3(&q[1]); - angle = saacos(plane[2])/2.0; + angle = saacos(plane[2])/2.0f; co = cos(angle); si = sqrt(1-co*co); @@ -881,7 +881,7 @@ static void draw_spot_cone(Lamp *la, float x, float z) for(a=0; a<33; a++) { angle= a*M_PI*2/(33-1); - glVertex3f(z*cos(angle), z*sin(angle), 0); + glVertex3f(z*cosf(angle), z*sinf(angle), 0); } } @@ -1001,7 +1001,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, short axis; /* setup a 45 degree rotation matrix */ - vec_rot_to_mat3( mat,imat[2], M_PI/4.0f); + vec_rot_to_mat3(mat, imat[2], (float)M_PI/4.0f); /* vectors */ mul_v3_v3fl(v1, imat[0], circrad * 1.2f); @@ -1048,7 +1048,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, vvec[1]= x*ob->obmat[1][0] + y*ob->obmat[1][1] + z*ob->obmat[1][2]; vvec[2]= x*ob->obmat[2][0] + y*ob->obmat[2][1] + z*ob->obmat[2][2]; - y = cos( M_PI*la->spotsize/360.0 ); + y = cosf(la->spotsize*(float)(M_PI/360.0)); spotvolume(lvec, vvec, y); x = -la->dist; mul_v3_fl(lvec, x); @@ -1061,7 +1061,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glVertex3fv(lvec); glEnd(); - z = x*sqrt(1.0 - y*y); + z = x*sqrtf(1.0f - y*y); x *= y; /* draw the circle/square at the end of the cone */ @@ -1083,7 +1083,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glVertex3fv(tvec); glEnd(); } - else circ(0.0, 0.0, fabs(z)); + else circ(0.0, 0.0, fabsf(z)); /* draw the circle/square representing spotbl */ if(la->type==LA_SPOT) { @@ -1091,7 +1091,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* hide line if it is zero size or overlaps with outer border, previously it adjusted to always to show it but that seems confusing because it doesn't show the actual blend size */ - if (spotblcirc != 0 && spotblcirc != fabs(z)) + if (spotblcirc != 0 && spotblcirc != fabsf(z)) circ(0.0, 0.0, spotblcirc); } @@ -1165,9 +1165,9 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } else if(la->type==LA_AREA) { setlinestyle(3); if(la->area_shape==LA_AREA_SQUARE) - fdrawbox(-la->area_size*0.5, -la->area_size*0.5, la->area_size*0.5, la->area_size*0.5); + fdrawbox(-la->area_size*0.5f, -la->area_size*0.5f, la->area_size*0.5f, la->area_size*0.5f); else if(la->area_shape==LA_AREA_RECT) - fdrawbox(-la->area_size*0.5, -la->area_sizey*0.5, la->area_size*0.5, la->area_sizey*0.5); + fdrawbox(-la->area_size*0.5f, -la->area_sizey*0.5f, la->area_size*0.5f, la->area_sizey*0.5f); glBegin(GL_LINE_STRIP); glVertex3f(0.0,0.0,-circrad); @@ -1287,7 +1287,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob if(is_view) { /* fixed depth, variable size (avoids exceeding clipping range) */ - depth = -(cam->clipsta + 0.1); + depth = -(cam->clipsta + 0.1f); fac = depth / (cam->lens/-16.0f * scaz); } else { @@ -1342,15 +1342,15 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob else if (i==1 && (ob == v3d->camera)) glBegin(GL_TRIANGLES); else break; - vec[0][0]= shx + ((-0.7 * drawsize) * scax); - vec[0][1]= shy + ((drawsize * (caspy + 0.1)) * scay); + vec[0][0]= shx + ((-0.7f * drawsize) * scax); + vec[0][1]= shy + ((drawsize * (caspy + 0.1f)) * scay); glVertex3fv(vec[0]); /* left */ - vec[0][0]= shx + ((0.7 * drawsize) * scax); + vec[0][0]= shx + ((0.7f * drawsize) * scax); glVertex3fv(vec[0]); /* right */ vec[0][0]= shx; - vec[0][1]= shy + ((1.1 * drawsize * (caspy + 0.7)) * scay); + vec[0][1]= shy + ((1.1f * drawsize * (caspy + 0.7f)) * scay); glVertex3fv(vec[0]); /* top */ glEnd(); @@ -1939,7 +1939,7 @@ static int draw_dm_creases__setDrawOptions(void *UNUSED(userData), int index) { EditEdge *eed = EM_get_edge_for_index(index); - if (eed->h==0 && eed->crease!=0.0) { + if (eed->h==0 && eed->crease != 0.0f) { UI_ThemeColorBlend(TH_WIRE, TH_EDGE_CREASE, eed->crease); return 1; } else { @@ -1957,7 +1957,7 @@ static int draw_dm_bweights__setDrawOptions(void *UNUSED(userData), int index) { EditEdge *eed = EM_get_edge_for_index(index); - if (eed->h==0 && eed->bweight!=0.0) { + if (eed->h==0 && eed->bweight != 0.0f) { UI_ThemeColorBlend(TH_WIRE, TH_EDGE_SELECT, eed->bweight); return 1; } else { @@ -1968,7 +1968,7 @@ static void draw_dm_bweights__mapFunc(void *UNUSED(userData), int index, float * { EditVert *eve = EM_get_vert_for_index(index); - if (eve->h==0 && eve->bweight!=0.0) { + if (eve->h==0 && eve->bweight != 0.0f) { UI_ThemeColorBlend(TH_VERTEX, TH_VERTEX_SELECT, eve->bweight); bglVertex3fv(co); } @@ -2026,8 +2026,8 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, Deriv continue; } - size = (size>2.1?size/2.0:size); - fsize = (fsize>2.1?fsize/2.0:fsize); + size = (size > 2.1f ? size/2.0f:size); + fsize = (fsize > 2.1f ? fsize/2.0f:fsize); col[3] = fcol[3] = 100; } else { col[3] = fcol[3] = 255; @@ -2162,7 +2162,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E bUnit_AsString(val, sizeof(val), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); else sprintf(val, conv_float, len_v3v3(v1, v2)); - + view3d_cached_text_draw_add(vmid, val, 0, V3D_CACHE_TEXT_ASCII, col); } } @@ -2231,29 +2231,29 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E if( (e4->f & e1->f & SELECT) || (do_moving && (efa->v1->f & SELECT)) ) { /* Vec 1 */ - sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v4, v1, v2))); + sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v4, v1, v2))); interp_v3_v3v3(fvec, efa->cent, efa->v1->co, 0.8f); view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col); } if( (e1->f & e2->f & SELECT) || (do_moving && (efa->v2->f & SELECT)) ) { /* Vec 2 */ - sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v1, v2, v3))); + sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3))); interp_v3_v3v3(fvec, efa->cent, efa->v2->co, 0.8f); view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col); } if( (e2->f & e3->f & SELECT) || (do_moving && (efa->v3->f & SELECT)) ) { /* Vec 3 */ if(efa->v4) - sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v2, v3, v4))); + sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v2, v3, v4))); else - sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v2, v3, v1))); + sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v2, v3, v1))); interp_v3_v3v3(fvec, efa->cent, efa->v3->co, 0.8f); view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col); } /* Vec 4 */ if(efa->v4) { if( (e3->f & e4->f & SELECT) || (do_moving && (efa->v4->f & SELECT)) ) { - sprintf(val,"%.3g", RAD2DEG(angle_v3v3v3(v3, v4, v1))); + sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v3, v4, v1))); interp_v3_v3v3(fvec, efa->cent, efa->v4->co, 0.8f); view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col); } @@ -2455,7 +2455,7 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm) { if(v3d->transp==0) { // not when we draw the transparent pass - glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0); + glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); glDepthMask(0); /* if transparent, we cannot draw the edges for solid select... edges have no material info. @@ -3184,7 +3184,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas drawDispListsolid(lb, ob, 0); GPU_end_object_materials(); } - if(cu->editnurb && cu->bevobj==NULL && cu->taperobj==NULL && cu->ext1 == 0.0 && cu->ext2 == 0.0) { + if(cu->editnurb && cu->bevobj==NULL && cu->taperobj==NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) { cpack(0); draw_index_wire= 0; drawDispListwire(lb); @@ -3577,7 +3577,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv pixsize= view3d_pixel_size(rv3d, ob->obmat[3]); if(part->draw_size==0.0) - pixsize*=2.0; + pixsize *= 2.0f; else pixsize*=part->draw_size; @@ -3761,8 +3761,8 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv drawn = 0; if(part->draw_as == PART_DRAW_REND && part->trail_count > 1) { - float length = part->path_end * (1.0 - part->randlength * r_length); - int trail_count = part->trail_count * (1.0 - part->randlength * r_length); + float length = part->path_end * (1.0f - part->randlength * r_length); + int trail_count = part->trail_count * (1.0f - part->randlength * r_length); float ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length; float dt = length / (trail_count ? (float)trail_count : 1.0f); int i=0; @@ -4114,7 +4114,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) if(timed) { for(k=0, pcol=pathcol, pkey=path; kcol); - pcol[3] = 1.0f - fabs((float)CFRA - pkey->time)/(float)pset->fade_frames; + pcol[3] = 1.0f - fabsf((float)(CFRA) - pkey->time)/(float)pset->fade_frames; } glColorPointer(4, GL_FLOAT, 4*sizeof(float), pathcol); @@ -4163,7 +4163,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) } if(timed) - *(cd+3) = 1.0f - fabs((float)CFRA - *key->time)/(float)pset->fade_frames; + *(cd+3) = 1.0f - fabsf((float)CFRA - *key->time)/(float)pset->fade_frames; cd += (timed?4:3); } @@ -4757,7 +4757,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* direction vectors for 3d curve paths when at its lowest, dont render normals */ - if(cu->flag & CU_3D && ts->normalsize > 0.0015 && (cu->drawflag & CU_HIDE_NORMALS)==0) { + if(cu->flag & CU_3D && ts->normalsize > 0.0015f && (cu->drawflag & CU_HIDE_NORMALS)==0) { UI_ThemeColor(TH_WIRE); for (bl=cu->bev.first,nu=nurb; nu && bl; bl=bl->next,nu=nu->next) { @@ -4854,7 +4854,7 @@ static void draw_empty_cone (float size) radius = size; glTranslatef(cent,cent, cent); - glScalef(radius, 2.0*size, radius); + glScalef(radius, size * 2.0f, radius); glRotatef(-90., 1.0, 0.0, 0.0); gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1); @@ -5083,7 +5083,7 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, ml->selcol2= code; glLoadName(code++); } - drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad*atan(ml->s)/M_PI_2, imat); + drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad*atanf(ml->s)/(float)M_PI_2, imat); } ml= ml->next; @@ -5125,15 +5125,15 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) // force_val = IPO_GetFloatValue(ob->ipo, OB_PD_FSTR, scene->r.cfra); //else force_val = pd->f_strength; - force_val*= 0.1; + force_val *= 0.1f; drawcircball(GL_LINE_LOOP, vec, size, tmat); - vec[2]= 0.5*force_val; + vec[2]= 0.5f * force_val; drawcircball(GL_LINE_LOOP, vec, size, tmat); - vec[2]= 1.0*force_val; + vec[2]= 1.0f * force_val; drawcircball(GL_LINE_LOOP, vec, size, tmat); - vec[2]= 1.5*force_val; + vec[2]= 1.5f * force_val; drawcircball(GL_LINE_LOOP, vec, size, tmat); - vec[2] = 0; /* reset vec for max dist circle */ + vec[2] = 0.0f; /* reset vec for max dist circle */ } else if (pd->forcefield == PFIELD_FORCE) { @@ -5146,10 +5146,10 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) UI_ThemeColorBlend(curcol, TH_BACK, 0.5); drawcircball(GL_LINE_LOOP, vec, size, imat); - UI_ThemeColorBlend(curcol, TH_BACK, 0.9 - 0.4 / pow(1.5, (double)ffall_val)); - drawcircball(GL_LINE_LOOP, vec, size*1.5, imat); - UI_ThemeColorBlend(curcol, TH_BACK, 0.9 - 0.4 / pow(2.0, (double)ffall_val)); - drawcircball(GL_LINE_LOOP, vec, size*2.0, imat); + UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(1.5f, ffall_val)); + drawcircball(GL_LINE_LOOP, vec, size * 1.5f, imat); + UI_ThemeColorBlend(curcol, TH_BACK, 0.9f - 0.4f / powf(2.0f, ffall_val)); + drawcircball(GL_LINE_LOOP, vec, size*2.0f, imat); } else if (pd->forcefield == PFIELD_VORTEX) { float /*ffall_val,*/ force_val; @@ -5165,14 +5165,14 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) //else force_val = pd->f_strength; - UI_ThemeColorBlend(curcol, TH_BACK, 0.7); + UI_ThemeColorBlend(curcol, TH_BACK, 0.7f); if (force_val < 0) { - drawspiral(vec, size*1.0, tmat, 1); - drawspiral(vec, size*1.0, tmat, 16); + drawspiral(vec, size, tmat, 1); + drawspiral(vec, size, tmat, 16); } else { - drawspiral(vec, size*1.0, tmat, -1); - drawspiral(vec, size*1.0, tmat, -16); + drawspiral(vec, size, tmat, -1); + drawspiral(vec, size, tmat, -16); } } else if (pd->forcefield == PFIELD_GUIDE && ob->type==OB_CURVE) { @@ -5244,9 +5244,9 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) distance=(pd->flag&PFIELD_USEMAX)?pd->maxdist:0.0f; if(pd->flag & (PFIELD_USEMAX|PFIELD_USEMAXR)){ - drawcone(vec,distance*sin(radius),distance*cos(radius),tmat); + drawcone(vec, distance * sinf(radius),distance * cosf(radius), tmat); if((pd->flag & PFIELD_POSZ)==0) - drawcone(vec,distance*sin(radius),-distance*cos(radius),tmat); + drawcone(vec, distance * sinf(radius),-distance * cosf(radius),tmat); } radius=(pd->flag&PFIELD_USEMINR)?pd->minrad:1.0f; @@ -5254,9 +5254,9 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) distance=(pd->flag&PFIELD_USEMIN)?pd->mindist:0.0f; if(pd->flag & (PFIELD_USEMIN|PFIELD_USEMINR)){ - drawcone(vec,distance*sin(radius),distance*cos(radius),tmat); + drawcone(vec,distance*sinf(radius),distance*cosf(radius),tmat); if((pd->flag & PFIELD_POSZ)==0) - drawcone(vec,distance*sin(radius),-distance*cos(radius),tmat); + drawcone(vec, distance * sinf(radius), -distance * cosf(radius), tmat); } } setlinestyle(0); @@ -5306,13 +5306,13 @@ static void draw_bb_quadric(BoundBox *bb, short type) gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); - size[0]= 0.5*fabs(bb->vec[0][0] - bb->vec[4][0]); - size[1]= 0.5*fabs(bb->vec[0][1] - bb->vec[2][1]); - size[2]= 0.5*fabs(bb->vec[0][2] - bb->vec[1][2]); + size[0]= 0.5f*fabsf(bb->vec[0][0] - bb->vec[4][0]); + size[1]= 0.5f*fabsf(bb->vec[0][1] - bb->vec[2][1]); + size[2]= 0.5f*fabsf(bb->vec[0][2] - bb->vec[1][2]); - cent[0]= (bb->vec[0][0] + bb->vec[4][0])/2.0; - cent[1]= (bb->vec[0][1] + bb->vec[2][1])/2.0; - cent[2]= (bb->vec[0][2] + bb->vec[1][2])/2.0; + cent[0]= 0.5f*(bb->vec[0][0] + bb->vec[4][0]); + cent[1]= 0.5f*(bb->vec[0][1] + bb->vec[2][1]); + cent[2]= 0.5f*(bb->vec[0][2] + bb->vec[1][2]); glPushMatrix(); if(type==OB_BOUND_SPHERE) { @@ -5323,13 +5323,13 @@ static void draw_bb_quadric(BoundBox *bb, short type) else if(type==OB_BOUND_CYLINDER) { float radius = size[0] > size[1] ? size[0] : size[1]; glTranslatef(cent[0], cent[1], cent[2]-size[2]); - glScalef(radius, radius, 2.0*size[2]); + glScalef(radius, radius, 2.0f * size[2]); gluCylinder(qobj, 1.0, 1.0, 1.0, 8, 1); } else if(type==OB_BOUND_CONE) { float radius = size[0] > size[1] ? size[0] : size[1]; glTranslatef(cent[0], cent[2]-size[2], cent[1]); - glScalef(radius, 2.0*size[2], radius); + glScalef(radius, 2.0f * size[2], radius); glRotatef(-90., 1.0, 0.0, 0.0); gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1); } @@ -5838,7 +5838,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) drawDispList(scene, v3d, rv3d, base, dt); } - if (cu->linewidth != 0.0) { + if (cu->linewidth != 0.0f) { cpack(0xff44ff); UI_ThemeColor(TH_WIRE); copy_v3_v3(vec1, ob->orig); @@ -5857,7 +5857,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) setlinestyle(3); for (i=0; itotbox; i++) { - if (cu->tb[i].w != 0.0) { + if (cu->tb[i].w != 0.0f) { if (i == (cu->actbox-1)) UI_ThemeColor(TH_ACTIVE); else diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 1f123c11a8b..4277a7e85e3 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -383,7 +383,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float EditMesh *em = BKE_mesh_get_editmesh(me); /* allow for some rounding error becasue of matrix transform */ - if(len_v3(median) > 0.000001) { + if(len_v3(median) > 0.000001f) { EditVert *eve; for(eve= em->verts.first; eve; eve= eve->next) { @@ -397,7 +397,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float if(median[3] != 0.0f) { EditEdge *eed; - const float fixed_crease= (ve_median[3] <= 0.0f ? 0.0 : (ve_median[3] >= 1.0f ? 1.0 : FLT_MAX)); + const float fixed_crease= (ve_median[3] <= 0.0f ? 0.0f : (ve_median[3] >= 1.0f ? 1.0f : FLT_MAX)); if(fixed_crease != FLT_MAX) { /* simple case */ @@ -414,8 +414,8 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float float median_orig= ve_median[3] - median[3]; /* previous median value */ /* incase of floating point error */ - CLAMP(median_orig, 0.0, 1.0); - CLAMP(median_new, 0.0, 1.0); + CLAMP(median_orig, 0.0f, 1.0f); + CLAMP(median_new, 0.0f, 1.0f); if(median_new < median_orig) { /* scale down */ @@ -424,7 +424,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float for(eed= em->edges.first; eed; eed= eed->next) { if(eed->f & SELECT) { eed->crease *= sca; - CLAMP(eed->crease, 0.0, 1.0); + CLAMP(eed->crease, 0.0f, 1.0f); } } } @@ -435,7 +435,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float for(eed= em->edges.first; eed; eed= eed->next) { if(eed->f & SELECT) { eed->crease = 1.0f - ((1.0f - eed->crease) * sca); - CLAMP(eed->crease, 0.0, 1.0); + CLAMP(eed->crease, 0.0f, 1.0f); } } } @@ -1090,9 +1090,9 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event if (!pchan) return; /* make a copy to eul[3], to allow TAB on buttons to work */ - eul[0]= M_PI*tfp->ob_eul[0]/180.0; - eul[1]= M_PI*tfp->ob_eul[1]/180.0; - eul[2]= M_PI*tfp->ob_eul[2]/180.0; + eul[0]= (float)M_PI*tfp->ob_eul[0]/180.0f; + eul[1]= (float)M_PI*tfp->ob_eul[1]/180.0f; + eul[2]= (float)M_PI*tfp->ob_eul[2]/180.0f; if (pchan->rotmode == ROT_MODE_AXISANGLE) { float quat[4]; @@ -1237,7 +1237,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa) } */ - lim= 10000.0f*MAX2(1.0, v3d->grid); + lim= 10000.0f * MAX2(1.0f, v3d->grid); block= uiLayoutGetBlock(pa->layout); uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index dadc51b89fe..f5037ca24a1 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -223,7 +223,7 @@ static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, flo v1[1]= 0.0f; v2[1]= (float)ar->winy; - v1[0] = v2[0] = x-dx*floor(x/dx); + v1[0] = v2[0] = x-dx*floorf(x/dx); glBegin(GL_LINES); @@ -236,7 +236,7 @@ static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, flo v1[0]= 0.0f; v2[0]= (float)ar->winx; - v1[1]= v2[1]= y-dx*floor(y/dx); + v1[1]= v2[1]= y-dx*floorf(y/dx); while(v1[1] < ar->winy) { glVertex2fv(v1); @@ -292,7 +292,6 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** * items are less useful when dealing with units */ void *usys; int len, i; - double scalar; float dx_scalar; float blend_fac; @@ -301,7 +300,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** if(usys) { i= len; while(i--) { - scalar= bUnit_GetScaler(usys, i); + float scalar= bUnit_GetScaler(usys, i); dx_scalar = dx * scalar / unit->scale_length; if (dx_scalar < (GRID_MIN_PX*2)) @@ -447,7 +446,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) if(usys) { int i= bUnit_GetBaseUnit(usys); *grid_unit= bUnit_GetNameDisplay(usys, i); - grid_scale = (grid_scale * bUnit_GetScaler(usys, i)) / scene->unit.scale_length; + grid_scale = (grid_scale * (float)bUnit_GetScaler(usys, i)) / scene->unit.scale_length; } } @@ -600,7 +599,7 @@ static void draw_view_axis(RegionView3D *rv3d) { const float k = U.rvisize; /* axis size */ const float toll = 0.5; /* used to see when view is quasi-orthogonal */ - const float start = k + 1.0; /* axis center in screen coordinates, x=y */ + const float start = k + 1.0f;/* axis center in screen coordinates, x=y */ float ydisp = 0.0; /* vertical displacement to allow obj info text */ int bright = 25*(float)U.rvibright + 5; /* axis alpha (rvibright has range 0-10) */ @@ -626,7 +625,7 @@ static void draw_view_axis(RegionView3D *rv3d) glVertex2f(start + dx, start + dy + ydisp); glEnd(); - if (fabs(dx) > toll || fabs(dy) > toll) { + if (fabsf(dx) > toll || fabsf(dy) > toll) { BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "x", 1); } @@ -646,7 +645,7 @@ static void draw_view_axis(RegionView3D *rv3d) glVertex2f(start + dx, start + dy + ydisp); glEnd(); - if (fabs(dx) > toll || fabs(dy) > toll) { + if (fabsf(dx) > toll || fabsf(dy) > toll) { BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "y", 1); } @@ -665,7 +664,7 @@ static void draw_view_axis(RegionView3D *rv3d) glVertex2f(start + dx, start + dy + ydisp); glEnd(); - if (fabs(dx) > toll || fabs(dy) > toll) { + if (fabsf(dx) > toll || fabsf(dy) > toll) { BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "z", 1); } @@ -860,7 +859,7 @@ void view3d_viewborder_size_get(Scene *scene, ARegion *ar, float size_r[2]) float winmax= MAX2(ar->winx, ar->winy); float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp); - if(aspect>1.0) { + if(aspect > 1.0f) { size_r[0]= winmax; size_r[1]= winmax/aspect; } else { @@ -887,15 +886,15 @@ void view3d_calc_camera_border(Scene *scene, ARegion *ar, RegionView3D *rv3d, Vi * with multiple keypad presses (ton) */ - zoomfac= (M_SQRT2 + rv3d->camzoom/50.0); - zoomfac= (zoomfac*zoomfac)*0.25; + zoomfac= ((float)M_SQRT2 + rv3d->camzoom/50.0f); + zoomfac= (zoomfac*zoomfac) * 0.25f; size[0]= size[0]*zoomfac; size[1]= size[1]*zoomfac; /* center in window */ - viewborder_r->xmin= 0.5*ar->winx - 0.5*size[0]; - viewborder_r->ymin= 0.5*ar->winy - 0.5*size[1]; + viewborder_r->xmin= 0.5f * ar->winx - 0.5f * size[0]; + viewborder_r->ymin= 0.5f * ar->winy - 0.5f * size[1]; viewborder_r->xmax= viewborder_r->xmin + size[0]; viewborder_r->ymax= viewborder_r->ymin + size[1]; @@ -951,21 +950,21 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) y2i= (int)(y2 + 1.0f); /* passepartout, specified in camera edit buttons */ - if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001) { - if (ca->passepartalpha == 1.0) { + if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) { + if (ca->passepartalpha == 1.0f) { glColor3f(0, 0, 0); } else { glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable(GL_BLEND); glColor4f(0, 0, 0, ca->passepartalpha); } - if (x1i > 0.0) + if (x1i > 0.0f) glRectf(0.0, (float)ar->winy, x1i, 0.0); if (x2i < (float)ar->winx) glRectf(x2i, (float)ar->winy, (float)ar->winx, 0.0); if (y2i < (float)ar->winy) glRectf(x1i, (float)ar->winy, x2i, y2i); - if (y2i > 0.0) + if (y2i > 0.0f) glRectf(x1i, y1i, x2i, 0.0); glDisable(GL_BLEND); @@ -1288,7 +1287,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) initgrabz(rv3d, 0.0, 0.0, 0.0); window_to_3d_delta(ar, vec, 1, 0); fac= MAX3( fabs(vec[0]), fabs(vec[1]), fabs(vec[1]) ); - fac= 1.0/fac; + fac= 1.0f/fac; asp= ( (float)ibuf->y)/(float)ibuf->x; @@ -1344,7 +1343,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) ED_region_pixelspace(ar); glPixelZoom(zoomx, zoomy); - glColor4f(1.0, 1.0, 1.0, 1.0-bgpic->blend); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f-bgpic->blend); glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect); glPixelZoom(1.0, 1.0); @@ -2286,13 +2285,13 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) #endif /* is this more then half a frame behind? */ - if (fps+0.5 < FPS) { + if (fps+0.5f < (float)(FPS)) { UI_ThemeColor(TH_REDALERT); - BLI_snprintf(printable, sizeof(printable), "fps: %.2f", (float)fps); + BLI_snprintf(printable, sizeof(printable), "fps: %.2f", fps); } else { UI_ThemeColor(TH_TEXT_HI); - BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps+0.5)); + BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps+0.5f)); } BLF_draw_default(22, ar->winy-17, 0.0f, printable, sizeof(printable)-1); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 38888670dc2..ca5213e357b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -313,11 +313,11 @@ static void calctrackballvec(rcti *rect, int mx, int my, float *vec) y/= (float)((rect->ymax - rect->ymin)/2); d = sqrt(x*x + y*y); - if (d < radius*M_SQRT1_2) /* Inside sphere */ + if (d < radius * (float)M_SQRT1_2) /* Inside sphere */ z = sqrt(radius*radius - d*d); else { /* On hyperbola */ - t = radius / M_SQRT2; + t = radius / (float)M_SQRT2; z = t*t / d; } @@ -552,22 +552,22 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) sub_v3_v3v3(dvec, newvec, vod->trackvec); si= sqrt(dvec[0]*dvec[0]+ dvec[1]*dvec[1]+ dvec[2]*dvec[2]); - si/= (2.0*TRACKBALLSIZE); + si /= (float)(2.0 * TRACKBALLSIZE); cross_v3_v3v3(q1+1, vod->trackvec, newvec); normalize_v3(q1+1); /* Allow for rotation beyond the interval * [-pi, pi] */ - while (si > 1.0) - si -= 2.0; + while (si > 1.0f) + si -= 2.0f; /* This relation is used instead of * phi = asin(si) so that the angle * of rotation is linearly proportional * to the distance that the mouse is * dragged. */ - phi = si * M_PI / 2.0; + phi = si * (float)(M_PI / 2.0); q1[0]= cos(phi); mul_v3_fl(q1+1, sin(phi)); @@ -591,12 +591,12 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) float phi, q1[4]; float m[3][3]; float m_inv[3][3]; - float xvec[3] = {1,0,0}; + float xvec[3] = {1.0f, 0.0f, 0.0f}; /* Sensitivity will control how fast the viewport rotates. 0.0035 was obtained experimentally by looking at viewport rotation sensitivities on other modeling programs. */ /* Perhaps this should be a configurable user parameter. */ - const float sensitivity = 0.0035; + const float sensitivity = 0.0035f; /* Get the 3x3 matrix and its inverse from the quaternion */ quat_to_mat3( m,rv3d->viewquat); @@ -652,7 +652,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) invert_qt_qt(viewquat_inv_test, snapquats[i]); mul_qt_v3(viewquat_inv_test, zaxis_test); - if(angle_v3v3(zaxis_test, zaxis) < DEG2RAD(45/3)) { + if(angle_v3v3(zaxis_test, zaxis) < DEG2RADF(45/3)) { /* find the best roll */ float quat_roll[4], quat_final[4], quat_best[4]; float viewquat_align[4]; /* viewquat aligned to zaxis_test */ @@ -675,7 +675,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) float xaxis2[3]={1,0,0}; float quat_final_inv[4]; - axis_angle_to_quat(quat_roll, zaxis_test, j * DEG2RAD(45.0)); + axis_angle_to_quat(quat_roll, zaxis_test, (float)j * DEG2RADF(45.0f)); normalize_qt(quat_roll); mul_qt_qtqt(quat_final, snapquats[i], quat_roll); @@ -891,8 +891,8 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf) static void viewmove_apply(ViewOpsData *vod, int x, int y) { if(vod->rv3d->persp==RV3D_CAMOB) { - float zoomfac= (M_SQRT2 + vod->rv3d->camzoom/50.0); - zoomfac= (zoomfac*zoomfac)*0.5; + float zoomfac= ((float)M_SQRT2 + (float)vod->rv3d->camzoom / 50.0f); + zoomfac= (zoomfac * zoomfac) * 0.5f; vod->rv3d->camdx += (vod->oldx - x)/(vod->ar->winx * zoomfac); vod->rv3d->camdy += (vod->oldy - y)/(vod->ar->winy * zoomfac); @@ -1084,7 +1084,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom) float time_step= (float)(time - vod->timer_lastdraw); // oldstyle zoom - zfac = 1.0f + (((float)(vod->origx - x + vod->origy - y)/20.0) * time_step); + zfac = 1.0f + (((float)(vod->origx - x + vod->origy - y) / 20.0f) * time_step); vod->timer_lastdraw= time; } else if(viewzoom==USER_ZOOM_SCALE) { @@ -1113,11 +1113,11 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom) if (U.uiflag & USER_ZOOM_INVERT) SWAP(float, len1, len2); - zfac = vod->dist0 * (2.0*((len2/len1)-1.0) + 1.0) / vod->rv3d->dist; + zfac = vod->dist0 * (2.0f * ((len2/len1)-1.0f) + 1.0f) / vod->rv3d->dist; } - if(zfac != 1.0 && zfac*vod->rv3d->dist > 0.001*vod->grid && - zfac*vod->rv3d->dist < 10.0*vod->far) + if(zfac != 1.0f && zfac*vod->rv3d->dist > 0.001f * vod->grid && + zfac * vod->rv3d->dist < 10.0f * vod->far) view_zoom_mouseloc(vod->ar, zfac, vod->oldx, vod->oldy); @@ -1133,8 +1133,8 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom) add_v3_v3(vod->rv3d->ofs, upvec); } else { /* these limits were in old code too */ - if(vod->rv3d->dist<0.001*vod->grid) vod->rv3d->dist= 0.001*vod->grid; - if(vod->rv3d->dist>10.0*vod->far) vod->rv3d->dist=10.0*vod->far; + if(vod->rv3d->dist<0.001f * vod->grid) vod->rv3d->dist= 0.001f * vod->grid; + if(vod->rv3d->dist>10.0f * vod->far) vod->rv3d->dist=10.0f * vod->far; } // XXX if(vod->rv3d->persp==RV3D_ORTHO || vod->rv3d->persp==RV3D_CAMOB) preview3d_event= 0; @@ -1224,7 +1224,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) rv3d->camzoom-= 10; if(rv3d->camzoom < RV3D_CAMZOOM_MIN) rv3d->camzoom= RV3D_CAMZOOM_MIN; } - else if(rv3d->dist<10.0*v3d->far) { + else if(rv3d->dist < 10.0f * v3d->far) { view_zoom_mouseloc(ar, 1.2f, mx, my); } } @@ -1233,7 +1233,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) rv3d->camzoom+= 10; if(rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom= RV3D_CAMZOOM_MAX; } - else if(rv3d->dist> 0.001*v3d->grid) { + else if(rv3d->dist> 0.001f * v3d->grid) { view_zoom_mouseloc(ar, .83333f, mx, my); } } @@ -1373,7 +1373,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in sub_v3_v3v3(afm, max, min); size= 0.7f*MAX3(afm[0], afm[1], afm[2]); - if(size==0.0) ok= 0; + if(size == 0.0f) ok= 0; if(ok) { float new_dist; @@ -1387,7 +1387,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in // correction for window aspect ratio if(ar->winy>2 && ar->winx>2) { size= (float)ar->winx/(float)ar->winy; - if(size<1.0) size= 1.0f/size; + if(size < 1.0f) size= 1.0f/size; new_dist*= size; } @@ -1651,15 +1651,15 @@ static int render_border_exec(bContext *C, wmOperator *op) scene->r.border.ymax= ((float)rect.ymax-vb.ymin)/(vb.ymax-vb.ymin); /* actually set border */ - CLAMP(scene->r.border.xmin, 0.0, 1.0); - CLAMP(scene->r.border.ymin, 0.0, 1.0); - CLAMP(scene->r.border.xmax, 0.0, 1.0); - CLAMP(scene->r.border.ymax, 0.0, 1.0); + CLAMP(scene->r.border.xmin, 0.0f, 1.0f); + CLAMP(scene->r.border.ymin, 0.0f, 1.0f); + CLAMP(scene->r.border.xmax, 0.0f, 1.0f); + CLAMP(scene->r.border.ymax, 0.0f, 1.0f); /* drawing a border surrounding the entire camera view switches off border rendering * or the border covers no pixels */ - if ((scene->r.border.xmin <= 0.0 && scene->r.border.xmax >= 1.0 && - scene->r.border.ymin <= 0.0 && scene->r.border.ymax >= 1.0) || + if ((scene->r.border.xmin <= 0.0f && scene->r.border.xmax >= 1.0f && + scene->r.border.ymin <= 0.0f && scene->r.border.ymax >= 1.0f) || (scene->r.border.xmin == scene->r.border.xmax || scene->r.border.ymin == scene->r.border.ymax )) { @@ -1767,7 +1767,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) dvec[2] = p[2]-p_corner[2]; new_dist = len_v3(dvec); - if(new_dist <= v3d->near*1.5) new_dist= v3d->near*1.5; + if(new_dist <= v3d->near * 1.5f) new_dist= v3d->near * 1.5f; new_ofs[0] = -p[0]; new_ofs[1] = -p[1]; @@ -1802,7 +1802,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) scale = (xscale >= yscale)?xscale:yscale; /* zoom in as required, or as far as we can go */ - new_dist = ((new_dist*scale) >= 0.001*v3d->grid)? new_dist*scale:0.001*v3d->grid; + new_dist = ((new_dist*scale) >= 0.001f * v3d->grid)? new_dist*scale:0.001f * v3d->grid; } smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL); @@ -1858,7 +1858,7 @@ static void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar) view3d_viewborder_size_get(scene, ar, size); - rv3d->camzoom= (sqrt(4.0*im_width/size[0]) - M_SQRT2)*50.0; + rv3d->camzoom= (sqrtf(4.0f * (float)im_width/size[0]) - (float)M_SQRT2) * 50.0f; rv3d->camzoom= CLAMPIS(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); } diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index d6dcd67c756..4914020fc02 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -204,10 +204,10 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), struct ARegion *UNUSE mouse can move during fly mode without spinning the view */ float x1, x2, y1, y2; - x1= 0.45*(float)fly->ar->winx; - y1= 0.45*(float)fly->ar->winy; - x2= 0.55*(float)fly->ar->winx; - y2= 0.55*(float)fly->ar->winy; + x1= 0.45f * (float)fly->ar->winx; + y1= 0.45f * (float)fly->ar->winy; + x2= 0.55f * (float)fly->ar->winx; + y2= 0.55f * (float)fly->ar->winy; cpack(0); @@ -440,14 +440,14 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) fly->time_lastwheel = time_currwheel; /*printf("Wheel %f\n", time_wheel);*/ /*Mouse wheel delays range from 0.5==slow to 0.01==fast*/ - time_wheel = 1+ (10 - (20*MIN2(time_wheel, 0.5))); /* 0-0.5 -> 0-5.0 */ + time_wheel = 1.0f + (10.0f - (20.0f * MIN2(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */ if (fly->speed<0.0f) fly->speed= 0.0f; else { if (event->shift) - fly->speed+= fly->grid*time_wheel*0.1; + fly->speed += fly->grid*time_wheel * 0.1f; else - fly->speed+= fly->grid*time_wheel; + fly->speed += fly->grid*time_wheel; } break; } @@ -459,12 +459,12 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) time_currwheel= PIL_check_seconds_timer(); time_wheel = (float)(time_currwheel - fly->time_lastwheel); fly->time_lastwheel = time_currwheel; - time_wheel = 1+ (10 - (20*MIN2(time_wheel, 0.5))); /* 0-0.5 -> 0-5.0 */ + time_wheel = 1.0f + (10.0f - (20.0f * MIN2(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */ if (fly->speed>0) fly->speed=0; else { if (event->shift) - fly->speed-= fly->grid*time_wheel*0.1; + fly->speed-= fly->grid*time_wheel * 0.1f; else fly->speed-= fly->grid*time_wheel; } @@ -608,18 +608,19 @@ static int flyApply(bContext *C, FlyInfo *fly) if(moffset[0]) { moffset[0] /= ar->winx - (xmargin*2); - moffset[0] *= fabs(moffset[0]); + moffset[0] *= fabsf(moffset[0]); } if(moffset[1]) { moffset[1] /= ar->winy - (ymargin*2); - moffset[1] *= fabs(moffset[1]); + moffset[1] *= fabsf(moffset[1]); } /* Should we redraw? */ if(fly->speed != 0.0f || moffset[0] || moffset[1] || fly->zlock || fly->xlock || dvec[0] || dvec[1] || dvec[2] ) { float dvec_tmp[3]; - double time_current, time_redraw; /*time how fast it takes for us to redraw, this is so simple scenes dont fly too fast */ + double time_current; /*time how fast it takes for us to redraw, this is so simple scenes dont fly too fast */ + float time_redraw; float time_redraw_clamped; time_current= PIL_check_seconds_timer(); @@ -642,12 +643,12 @@ static int flyApply(bContext *C, FlyInfo *fly) dvec_tmp[2]= 0; if (fly->use_precision) { - dvec_tmp[0] *= 0.1; - dvec_tmp[1] *= 0.1; + dvec_tmp[0] *= 0.1f; + dvec_tmp[1] *= 0.1f; } mul_m3_v3(mat, dvec_tmp); - mul_v3_fl(dvec_tmp, time_redraw*200.0 * fly->grid); + mul_v3_fl(dvec_tmp, time_redraw * 200.0f * fly->grid); } else { float roll; /* similar to the angle between the camera's up and the Z-up, but its very rough so just roll*/ @@ -704,7 +705,7 @@ static int flyApply(bContext *C, FlyInfo *fly) mul_m3_v3(mat, upvec); /*make sure we have some z rolling*/ - if (fabs(upvec[2]) > 0.00001f) { + if (fabsf(upvec[2]) > 0.00001f) { roll= upvec[2]*5; upvec[0]=0; /*rotate the view about this axis*/ upvec[1]=0; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 9d882f09d02..bd19112f924 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -296,7 +296,7 @@ int lasso_inside(short mcords[][2], short moves, short sx, short sy) cross= (float)((p1[1]-p2[1])*(p1[0]-sx) + (p2[0]-p1[0])*(p1[1]-sy)); - if(cross<0.0) angletot-= ang; + if(cross<0.0f) angletot-= ang; else angletot+= ang; /* circulate */ @@ -1926,7 +1926,7 @@ static void mesh_circle_select(ViewContext *vc, int select, short *mval, float r int bbsel; struct {ViewContext *vc; short select, mval[2]; float radius; } data; - bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0)); + bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0f)); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ vc->em= ((Mesh *)vc->obedit->data)->edit_mesh; @@ -1974,7 +1974,7 @@ static void paint_facesel_circle_select(ViewContext *vc, int select, short *mval if (me) { em_vertoffs= me->totface+1; /* max index array */ - bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0)); + bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0f)); EM_backbuf_checkAndSelectTFaces(me, select==LEFTMOUSE); EM_free_backbuf(); } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index b803d49640e..f007b46dd95 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -252,7 +252,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) if(eve->f1) { VECCOPY(tv->oldloc, eve->co); tv->loc= eve->co; - if(eve->no[0]!=0.0 || eve->no[1]!=0.0 ||eve->no[2]!=0.0) + if(eve->no[0] != 0.0f || eve->no[1] != 0.0f ||eve->no[2] != 0.0f) tv->nor= eve->no; // note this is a hackish signal (ton) tv->flag= eve->f1 & SELECT; tv++; @@ -436,11 +436,11 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) for(a=0; aflag & SELECT) { add_v3_v3(centroid, tv->oldloc); - total+= 1.0; + total += 1.0f; DO_MINMAX(tv->oldloc, min, max); } } - if(total!=0.0) { + if(total != 0.0f) { mul_v3_fl(centroid, 1.0f/total); } @@ -478,9 +478,9 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) VECCOPY(vec, tv->loc); mul_m3_v3(bmat, vec); add_v3_v3(vec, obedit->obmat[3]); - vec[0]= gridf*floor(.5+ vec[0]/gridf); - vec[1]= gridf*floor(.5+ vec[1]/gridf); - vec[2]= gridf*floor(.5+ vec[2]/gridf); + vec[0]= gridf*floorf(0.5f+ vec[0]/gridf); + vec[1]= gridf*floorf(0.5f+ vec[1]/gridf); + vec[2]= gridf*floorf(0.5f+ vec[2]/gridf); sub_v3_v3(vec, obedit->obmat[3]); mul_m3_v3(imat, vec); @@ -508,9 +508,9 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) /* get nearest grid point to snap to */ VECCOPY(nLoc, pchan->pose_mat[3]); - vec[0]= gridf * (float)(floor(.5+ nLoc[0]/gridf)); - vec[1]= gridf * (float)(floor(.5+ nLoc[1]/gridf)); - vec[2]= gridf * (float)(floor(.5+ nLoc[2]/gridf)); + vec[0]= gridf * (float)(floor(0.5f+ nLoc[0]/gridf)); + vec[1]= gridf * (float)(floor(0.5f+ nLoc[1]/gridf)); + vec[2]= gridf * (float)(floor(0.5f+ nLoc[2]/gridf)); /* get bone-space location of grid point */ armature_loc_pose_to_bone(pchan, vec, vecN); @@ -538,9 +538,9 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) else { ob->recalc |= OB_RECALC_OB; - vec[0]= -ob->obmat[3][0]+gridf*floor(.5+ ob->obmat[3][0]/gridf); - vec[1]= -ob->obmat[3][1]+gridf*floor(.5+ ob->obmat[3][1]/gridf); - vec[2]= -ob->obmat[3][2]+gridf*floor(.5+ ob->obmat[3][2]/gridf); + vec[0]= -ob->obmat[3][0]+gridf*floorf(0.5f+ ob->obmat[3][0]/gridf); + vec[1]= -ob->obmat[3][1]+gridf*floorf(0.5f+ ob->obmat[3][1]/gridf); + vec[2]= -ob->obmat[3][2]+gridf*floorf(0.5f+ ob->obmat[3][2]/gridf); if(ob->parent) { where_is_object(scene, ob); @@ -723,9 +723,9 @@ static int snap_curs_to_grid(bContext *C, wmOperator *UNUSED(op)) gridf= rv3d->gridview; curs= give_cursor(scene, v3d); - curs[0]= gridf*floor(.5+curs[0]/gridf); - curs[1]= gridf*floor(.5+curs[1]/gridf); - curs[2]= gridf*floor(.5+curs[2]/gridf); + curs[0]= gridf*floorf(0.5f+curs[0]/gridf); + curs[1]= gridf*floorf(0.5f+curs[1]/gridf); + curs[2]= gridf*floorf(0.5f+curs[2]/gridf); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, v3d); // hrm @@ -784,7 +784,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) } if(v3d->around==V3D_CENTROID) { - mul_v3_fl(centroid, 1.0/(float)tottrans); + mul_v3_fl(centroid, 1.0f/(float)tottrans); VECCOPY(curs, centroid); } else { @@ -824,7 +824,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) } if(count) { if(v3d->around==V3D_CENTROID) { - mul_v3_fl(centroid, 1.0/(float)count); + mul_v3_fl(centroid, 1.0f/(float)count); VECCOPY(curs, centroid); } else { diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 852801dfc61..d6ed9752d03 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -113,9 +113,9 @@ static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, f Lamp *la = ob->data; if (lens) { float x1, fac; - fac= cos( M_PI*la->spotsize/360.0); + fac= cosf((float)M_PI*la->spotsize/360.0f); x1= saacos(fac); - *lens= 16.0*fac/sin(x1); + *lens= 16.0f*fac/sinf(x1); } if (clipsta) *clipsta= la->clipsta; if (clipend) *clipend= la->clipend; @@ -267,7 +267,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo mul_qt_v3(q2, vec2); /* scale the time allowed by the rotation */ - sms.time_allowed *= angle_v3v3(vec1, vec2) / M_PI; /* 180deg == 1.0 */ + sms.time_allowed *= (double)angle_v3v3(vec1, vec2) / M_PI; /* 180deg == 1.0 */ } /* ensure it shows correct */ @@ -312,14 +312,14 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); struct SmoothViewStore *sms= rv3d->sms; - double step, step_inv; + float step, step_inv; /* escape if not our timer */ if(rv3d->smooth_timer==NULL || rv3d->smooth_timer!=event->customdata) return OPERATOR_PASS_THROUGH; - if(sms->time_allowed != 0.0f) - step = (rv3d->smooth_timer->duration)/sms->time_allowed; + if(sms->time_allowed != 0.0) + step = (float)((rv3d->smooth_timer->duration)/sms->time_allowed); else step = 1.0f; @@ -356,18 +356,18 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent int i; /* ease in/out */ - if (step < 0.5) step = (float)pow(step*2, 2)/2; - else step = (float)1-(pow(2*(1-step),2)/2); + if (step < 0.5f) step = (float)pow(step*2.0f, 2.0)/2.0f; + else step = (float)1.0f-(powf(2.0f*(1.0f-step),2.0f)/2.0f); - step_inv = 1.0-step; + step_inv = 1.0f-step; for (i=0; i<3; i++) - rv3d->ofs[i] = sms->new_ofs[i]*step + sms->orig_ofs[i]*step_inv; + rv3d->ofs[i] = sms->new_ofs[i] * step + sms->orig_ofs[i]*step_inv; interp_qt_qtqt(rv3d->viewquat, sms->orig_quat, sms->new_quat, step); - rv3d->dist = sms->new_dist*step + sms->orig_dist*step_inv; - v3d->lens = sms->new_lens*step + sms->orig_lens*step_inv; + rv3d->dist = sms->new_dist * step + sms->orig_dist*step_inv; + v3d->lens = sms->new_lens * step + sms->orig_lens*step_inv; } if(rv3d->viewlock & RV3D_BOXVIEW) @@ -787,14 +787,14 @@ void project_short(ARegion *ar, float *vec, short *adr) /* clips */ vec4[3]= 1.0; mul_m4_v4(rv3d->persmat, vec4); - if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ + if( vec4[3] > (float)BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); if( fx>0 && fxwinx) { fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); - if(fy>0.0 && fy< (float)ar->winy) { + if(fy > 0.0f && fy < (float)ar->winy) { adr[0]= (short)floor(fx); adr[1]= (short)floor(fy); } @@ -813,7 +813,7 @@ void project_int(ARegion *ar, float *vec, int *adr) mul_m4_v4(rv3d->persmat, vec4); - if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ + if( vec4[3] > (float)BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); if( fx>-2140000000.0f && fx<2140000000.0f) { @@ -862,14 +862,14 @@ void project_short_noclip(ARegion *ar, float *vec, short *adr) mul_m4_v4(rv3d->persmat, vec4); - if( vec4[3]>BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ + if( vec4[3] > (float)BL_NEAR_CLIP ) { /* 0.001 is the NEAR clipping cutoff for picking */ fx= (ar->winx/2)*(1 + vec4[0]/vec4[3]); if( fx>-32700 && fx<32700) { fy= (ar->winy/2)*(1 + vec4[1]/vec4[3]); - if(fy>-32700.0 && fy<32700.0) { + if(fy > -32700.0f && fy < 32700.0f) { adr[0]= (short)floor(fx); adr[1]= (short)floor(fy); } @@ -888,9 +888,9 @@ void project_float(ARegion *ar, float *vec, float *adr) mul_m4_v4(rv3d->persmat, vec4); - if( vec4[3]>BL_NEAR_CLIP ) { - adr[0] = (float)(ar->winx/2.0)+(ar->winx/2.0)*vec4[0]/vec4[3]; - adr[1] = (float)(ar->winy/2.0)+(ar->winy/2.0)*vec4[1]/vec4[3]; + if(vec4[3] > (float)BL_NEAR_CLIP) { + adr[0] = (float)(ar->winx/2.0f)+(ar->winx/2.0f)*vec4[0]/vec4[3]; + adr[1] = (float)(ar->winy/2.0f)+(ar->winy/2.0f)*vec4[1]/vec4[3]; } } @@ -905,8 +905,8 @@ void project_float_noclip(ARegion *ar, float *vec, float *adr) mul_m4_v4(rv3d->persmat, vec4); if( fabs(vec4[3]) > BL_NEAR_CLIP ) { - adr[0] = (float)(ar->winx/2.0)+(ar->winx/2.0)*vec4[0]/vec4[3]; - adr[1] = (float)(ar->winy/2.0)+(ar->winy/2.0)*vec4[1]/vec4[3]; + adr[0] = (float)(ar->winx/2.0f)+(ar->winx/2.0f)*vec4[0]/vec4[3]; + adr[1] = (float)(ar->winy/2.0f)+(ar->winy/2.0f)*vec4[1]/vec4[3]; } else { @@ -965,7 +965,7 @@ int get_view3d_cliprange(View3D *v3d, RegionView3D *rv3d, float *clipsta, float } if(rv3d->persp==RV3D_ORTHO) { - *clipend *= 0.5; // otherwise too extreme low zbuffer quality + *clipend *= 0.5f; // otherwise too extreme low zbuffer quality *clipsta= - *clipend; orth= 1; } @@ -992,10 +992,10 @@ int get_view3d_viewplane(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi, Lamp *la; la= v3d->camera->data; - fac= cos( M_PI*la->spotsize/360.0); + fac= cosf(((float)M_PI)*la->spotsize/360.0f); x1= saacos(fac); - lens= 16.0*fac/sin(x1); + lens= 16.0f*fac/sinf(x1); *clipsta= la->clipsta; *clipend= la->clipend; @@ -1018,14 +1018,14 @@ int get_view3d_viewplane(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi, else y1= -rv3d->dist; y2= -y1; - *clipend *= 0.5; // otherwise too extreme low zbuffer quality + *clipend *= 0.5f; // otherwise too extreme low zbuffer quality *clipsta= - *clipend; orth= 1; } else { /* fac for zoom, also used for camdx */ if(rv3d->persp==RV3D_CAMOB) { - fac= (1.41421+( (float)rv3d->camzoom )/50.0); + fac= (1.41421f + ( (float)rv3d->camzoom )/50.0f); fac*= fac; } else fac= 2.0; @@ -1033,7 +1033,7 @@ int get_view3d_viewplane(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi, /* viewplane size depends... */ if(cam && cam->type==CAM_ORTHO) { /* ortho_scale == 1 means exact 1 to 1 mapping */ - float dfac= 2.0*cam->ortho_scale/fac; + float dfac= 2.0f*cam->ortho_scale/fac; if(winx>winy) x1= -dfac; else x1= -winx*dfac/winy; @@ -1047,8 +1047,8 @@ int get_view3d_viewplane(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi, else { float dfac; - if(winx>winy) dfac= 64.0/(fac*winx*lens); - else dfac= 64.0/(fac*winy*lens); + if(winx>winy) dfac= 64.0f/(fac*winx*lens); + else dfac= 64.0f/(fac*winy*lens); x1= - *clipsta * winx*dfac; x2= -x1; @@ -1058,8 +1058,8 @@ int get_view3d_viewplane(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi, } /* cam view offset */ if(cam) { - float dx= 0.5*fac*rv3d->camdx*(x2-x1); - float dy= 0.5*fac*rv3d->camdy*(y2-y1); + float dx= 0.5f*fac*rv3d->camdx*(x2-x1); + float dy= 0.5f*fac*rv3d->camdy*(y2-y1); /* shift offset */ if(cam->type==CAM_ORTHO) { @@ -1067,8 +1067,8 @@ int get_view3d_viewplane(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi, dy += cam->shifty * cam->ortho_scale; } else { - dx += cam->shiftx * (cam->clipsta / cam->lens) * 32.0; - dy += cam->shifty * (cam->clipsta / cam->lens) * 32.0; + dx += cam->shiftx * (cam->clipsta / cam->lens) * 32.0f; + dy += cam->shifty * (cam->clipsta / cam->lens) * 32.0f; } x1+= dx; @@ -1086,7 +1086,7 @@ int get_view3d_viewplane(View3D *v3d, RegionView3D *rv3d, int winxi, int winyi, *pixsize= 1.0f/viewfac; } else { - viewfac= (((winx >= winy)? winx: winy)*lens)/32.0; + viewfac= (((winx >= winy)? winx: winy)*lens)/32.0f; *pixsize= *clipsta/viewfac; } } @@ -1498,7 +1498,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) box[1]= (max[1]-min[1]); box[2]= (max[2]-min[2]); size= MAX3(box[0], box[1], box[2]); - if(size<=0.01) size= 0.01; + if(size <= 0.01f) size= 0.01f; } if(ok) { @@ -1515,19 +1515,19 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) rv3d->localvd= MEM_mallocN(sizeof(RegionView3D), "localview region"); memcpy(rv3d->localvd, rv3d, sizeof(RegionView3D)); - rv3d->ofs[0]= -(min[0]+max[0])/2.0; - rv3d->ofs[1]= -(min[1]+max[1])/2.0; - rv3d->ofs[2]= -(min[2]+max[2])/2.0; + rv3d->ofs[0]= -(min[0]+max[0])/2.0f; + rv3d->ofs[1]= -(min[1]+max[1])/2.0f; + rv3d->ofs[2]= -(min[2]+max[2])/2.0f; rv3d->dist= size; /* perspective should be a bit farther away to look nice */ if(rv3d->persp==RV3D_ORTHO) - rv3d->dist*= 0.7; + rv3d->dist*= 0.7f; // correction for window aspect ratio if(ar->winy>2 && ar->winx>2) { float asp= (float)ar->winx/(float)ar->winy; - if(asp<1.0) asp= 1.0/asp; + if(asp < 1.0f) asp= 1.0f/asp; rv3d->dist*= asp; } From 9c8f1e2ef487483bc374feaed9ff709e07638623 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 17:12:59 +0000 Subject: [PATCH 133/261] imbuf, mathutils & readfile: floats were being implicitly promoted to doubles, adjust to use floats. --- source/blender/blenloader/intern/readfile.c | 140 +++++++++--------- source/blender/imbuf/intern/divers.c | 6 +- source/blender/imbuf/intern/imageprocess.c | 16 +- source/blender/imbuf/intern/rectop.c | 12 +- source/blender/imbuf/intern/scaling.c | 76 +++++----- source/blender/imbuf/intern/tiff.c | 2 +- source/blender/python/generic/mathutils.c | 2 +- .../blender/python/generic/mathutils_Matrix.c | 6 +- .../python/generic/mathutils_Quaternion.c | 8 +- .../blender/python/generic/mathutils_Vector.c | 12 +- .../python/generic/mathutils_geometry.c | 2 +- 11 files changed, 141 insertions(+), 141 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b6c0688ee5a..e3b736bb7e8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2871,7 +2871,7 @@ static void direct_link_curve(FileData *fd, Curve *cu) cu->tb = tb; cu->tb[0].w = cu->linewidth; } - if (cu->wordspace == 0.0) cu->wordspace = 1.0; + if (cu->wordspace == 0.0f) cu->wordspace = 1.0f; } cu->bev.first=cu->bev.last= NULL; @@ -6951,9 +6951,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(main->versionfile <= 113) { Material *ma = main->mat.first; while(ma) { - if(ma->flaresize==0.0) ma->flaresize= 1.0; - ma->subsize= 1.0; - ma->flareboost= 1.0; + if(ma->flaresize==0.0f) ma->flaresize= 1.0f; + ma->subsize= 1.0f; + ma->flareboost= 1.0f; ma= ma->id.next; } } @@ -6961,13 +6961,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(main->versionfile <= 134) { Tex *tex = main->tex.first; while (tex) { - if ((tex->rfac == 0.0) && - (tex->gfac == 0.0) && - (tex->bfac == 0.0)) { - tex->rfac = 1.0; - tex->gfac = 1.0; - tex->bfac = 1.0; - tex->filtersize = 1.0; + if ((tex->rfac == 0.0f) && + (tex->gfac == 0.0f) && + (tex->bfac == 0.0f)) { + tex->rfac = 1.0f; + tex->gfac = 1.0f; + tex->bfac = 1.0f; + tex->filtersize = 1.0f; } tex = tex->id.next; } @@ -6976,13 +6976,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* r-g-b-fac in texture */ Tex *tex = main->tex.first; while (tex) { - if ((tex->rfac == 0.0) && - (tex->gfac == 0.0) && - (tex->bfac == 0.0)) { - tex->rfac = 1.0; - tex->gfac = 1.0; - tex->bfac = 1.0; - tex->filtersize = 1.0; + if ((tex->rfac == 0.0f) && + (tex->gfac == 0.0f) && + (tex->bfac == 0.0f)) { + tex->rfac = 1.0f; + tex->gfac = 1.0f; + tex->bfac = 1.0f; + tex->filtersize = 1.0f; } tex = tex->id.next; } @@ -6990,7 +6990,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(main->versionfile <= 153) { Scene *sce = main->scene.first; while(sce) { - if(sce->r.blurfac==0.0) sce->r.blurfac= 1.0; + if(sce->r.blurfac==0.0f) sce->r.blurfac= 1.0f; sce= sce->id.next; } } @@ -7111,8 +7111,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) TFace *tface= me->tface; for(a=0; atotface; a++, tface++) { for(b=0; b<4; b++) { - tface->uv[b][0]/= 32767.0; - tface->uv[b][1]/= 32767.0; + tface->uv[b][0]/= 32767.0f; + tface->uv[b][1]/= 32767.0f; } } } @@ -7249,13 +7249,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(act->type==ACT_OBJECT) { oa= act->data; - oa->forceloc[0]*= 25.0; - oa->forceloc[1]*= 25.0; - oa->forceloc[2]*= 25.0; + oa->forceloc[0]*= 25.0f; + oa->forceloc[1]*= 25.0f; + oa->forceloc[2]*= 25.0f; - oa->forcerot[0]*= 10.0; - oa->forcerot[1]*= 10.0; - oa->forcerot[2]*= 10.0; + oa->forcerot[0]*= 10.0f; + oa->forcerot[1]*= 10.0f; + oa->forcerot[2]*= 10.0f; } act= act->next; } @@ -7264,8 +7264,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) sound = main->sound.first; while (sound) { - if (sound->volume < 0.01) { - sound->volume = 1.0; + if (sound->volume < 0.01f) { + sound->volume = 1.0f; } sound = sound->id.next; } @@ -7361,18 +7361,18 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (act->type==ACT_OBJECT) { /* multiply velocity with 50 in old files */ oa= act->data; - if (fabs(oa->linearvelocity[0]) >= 0.01f) - oa->linearvelocity[0] *= 50.0; - if (fabs(oa->linearvelocity[1]) >= 0.01f) - oa->linearvelocity[1] *= 50.0; - if (fabs(oa->linearvelocity[2]) >= 0.01f) - oa->linearvelocity[2] *= 50.0; - if (fabs(oa->angularvelocity[0])>=0.01f) - oa->angularvelocity[0] *= 50.0; - if (fabs(oa->angularvelocity[1])>=0.01f) - oa->angularvelocity[1] *= 50.0; - if (fabs(oa->angularvelocity[2])>=0.01f) - oa->angularvelocity[2] *= 50.0; + if (fabsf(oa->linearvelocity[0]) >= 0.01f) + oa->linearvelocity[0] *= 50.0f; + if (fabsf(oa->linearvelocity[1]) >= 0.01f) + oa->linearvelocity[1] *= 50.0f; + if (fabsf(oa->linearvelocity[2]) >= 0.01f) + oa->linearvelocity[2] *= 50.0f; + if (fabsf(oa->angularvelocity[0])>=0.01f) + oa->angularvelocity[0] *= 50.0f; + if (fabsf(oa->angularvelocity[1])>=0.01f) + oa->angularvelocity[1] *= 50.0f; + if (fabsf(oa->angularvelocity[2])>=0.01f) + oa->angularvelocity[2] *= 50.0f; } act= act->next; } @@ -7394,7 +7394,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) sound->min_gain = 0.0; sound->distance = 1.0; - if (sound->attenuation > 0.0) + if (sound->attenuation > 0.0f) sound->flags |= SOUND_FLAGS_3D; else sound->flags &= ~SOUND_FLAGS_3D; @@ -7452,7 +7452,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ob->formfactor = 0.4f; /* patch form factor , note that inertia equiv radius * of a rotation symmetrical obj */ - if (ob->inertia != 1.0) { + if (ob->inertia != 1.0f) { ob->formfactor /= ob->inertia * ob->inertia; } ob = ob->id.next; @@ -7814,7 +7814,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) SpaceLink *sl; for (sl= sa->spacedata.first; sl; sl= sl->next) { - if(sl->blockscale==0.0) sl->blockscale= 0.7f; + if(sl->blockscale==0.0f) sl->blockscale= 0.7f; /* added: 5x better zoom in for action */ if(sl->spacetype==SPACE_ACTION) { SpaceAction *sac= (SpaceAction *)sl; @@ -7858,8 +7858,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* introduction of raytrace */ while(ma) { - if(ma->fresnel_tra_i==0.0) ma->fresnel_tra_i= 1.25; - if(ma->fresnel_mir_i==0.0) ma->fresnel_mir_i= 1.25; + if(ma->fresnel_tra_i==0.0f) ma->fresnel_tra_i= 1.25f; + if(ma->fresnel_mir_i==0.0f) ma->fresnel_mir_i= 1.25f; ma->ang= 1.0; ma->ray_depth= 2; @@ -7871,23 +7871,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } sce= main->scene.first; while(sce) { - if(sce->r.gauss==0.0) sce->r.gauss= 1.0; + if(sce->r.gauss==0.0f) sce->r.gauss= 1.0f; sce= sce->id.next; } la= main->lamp.first; while(la) { - if(la->k==0.0) la->k= 1.0; + if(la->k==0.0f) la->k= 1.0; if(la->ray_samp==0) la->ray_samp= 1; if(la->ray_sampy==0) la->ray_sampy= 1; if(la->ray_sampz==0) la->ray_sampz= 1; - if(la->area_size==0.0) la->area_size= 1.0; - if(la->area_sizey==0.0) la->area_sizey= 1.0; - if(la->area_sizez==0.0) la->area_sizez= 1.0; + if(la->area_size==0.0f) la->area_size= 1.0f; + if(la->area_sizey==0.0f) la->area_sizey= 1.0f; + if(la->area_sizez==0.0f) la->area_sizez= 1.0f; la= la->id.next; } wrld= main->world.first; while(wrld) { - if(wrld->range==0.0) { + if(wrld->range==0.0f) { wrld->range= 1.0f/wrld->exposure; } wrld= wrld->id.next; @@ -7928,7 +7928,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) tex->flag |= TEX_CHECKER_ODD; } /* copied from kernel texture.c */ - if(tex->ns_outscale==0.0) { + if(tex->ns_outscale==0.0f) { /* musgrave */ tex->mg_H = 1.0f; tex->mg_lacunarity = 2.0f; @@ -7946,12 +7946,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } while(wrld) { - if(wrld->aodist==0.0) { + if(wrld->aodist==0.0f) { wrld->aodist= 10.0f; wrld->aobias= 0.05f; } - if(wrld->aosamp==0.0) wrld->aosamp= 5; - if(wrld->aoenergy==0.0) wrld->aoenergy= 1.0; + if(wrld->aosamp==0) wrld->aosamp= 5; + if(wrld->aoenergy==0.0f) wrld->aoenergy= 1.0f; wrld= wrld->id.next; } @@ -7963,7 +7963,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) for (sa= sc->areabase.first; sa; sa= sa->next) { SpaceLink *sl; for (sl= sa->spacedata.first; sl; sl= sl->next) { - if(sl->blockscale==0.0) sl->blockscale= 0.7f; + if(sl->blockscale==0.0f) sl->blockscale= 0.7f; /* added: 5x better zoom in for nla */ if(sl->spacetype==SPACE_NLA) { @@ -7986,8 +7986,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Object *ob= main->object.first; while(ma) { - if(ma->rampfac_col==0.0) ma->rampfac_col= 1.0; - if(ma->rampfac_spec==0.0) ma->rampfac_spec= 1.0; + if(ma->rampfac_col==0.0f) ma->rampfac_col= 1.0; + if(ma->rampfac_spec==0.0f) ma->rampfac_spec= 1.0; if(ma->pr_lamp==0) ma->pr_lamp= 3; ma= ma->id.next; } @@ -8048,7 +8048,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Editing *ed; while(tex) { - if(tex->nabla==0.0) tex->nabla= 0.025f; + if(tex->nabla==0.0f) tex->nabla= 0.025f; tex= tex->id.next; } while(sce) { @@ -8071,7 +8071,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) bScreen *sc; while(cam) { - if(cam->ortho_scale==0.0) { + if(cam->ortho_scale==0.0f) { cam->ortho_scale= 256.0f/cam->lens; if(cam->type==CAM_ORTHO) printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n"); } @@ -8099,7 +8099,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } // init new shader vars for (ma= main->mat.first; ma; ma= ma->id.next) { - if(ma->darkness==0.0) { + if(ma->darkness==0.0f) { ma->rms=0.1f; ma->darkness=1.0f; } @@ -8108,8 +8108,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* softbody init new vars */ for(ob= main->object.first; ob; ob= ob->id.next) { if(ob->soft) { - if(ob->soft->defgoal==0.0) ob->soft->defgoal= 0.7f; - if(ob->soft->physics_speed==0.0) ob->soft->physics_speed= 1.0f; + if(ob->soft->defgoal==0.0f) ob->soft->defgoal= 0.7f; + if(ob->soft->physics_speed==0.0f) ob->soft->physics_speed= 1.0f; if(ob->soft->interval==0) { ob->soft->interval= 2; @@ -8221,7 +8221,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } for (lt=main->latt.first; lt; lt=lt->id.next) { - if (lt->fu==0.0 && lt->fv==0.0 && lt->fw==0.0) { + if (lt->fu==0.0f && lt->fv==0.0f && lt->fw==0.0f) { calc_lat_fudu(lt->flag, lt->pntsu, <->fu, <->du); calc_lat_fudu(lt->flag, lt->pntsv, <->fv, <->dv); calc_lat_fudu(lt->flag, lt->pntsw, <->fw, <->dw); @@ -8443,7 +8443,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ntree_version_241(sce->nodetree); /* uv calculation options moved to toolsettings */ - if (sce->toolsettings->uvcalc_radius == 0.0) { + if (sce->toolsettings->uvcalc_radius == 0.0f) { sce->toolsettings->uvcalc_radius = 1.0f; sce->toolsettings->uvcalc_cubesize = 1.0f; sce->toolsettings->uvcalc_mapdir = 1; @@ -8499,7 +8499,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } /* transmissivity defaults */ - if(ma->tx_falloff==0.0) ma->tx_falloff= 1.0; + if(ma->tx_falloff==0.0f) ma->tx_falloff= 1.0f; } /* during 2.41 images with this name were used for viewer node output, lets fix that */ @@ -9720,7 +9720,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Lamp *la; for(la=main->lamp.first; la; la= la->id.next) { - if(la->atm_turbidity == 0.0) { + if(la->atm_turbidity == 0.0f) { la->sun_effect_type = 0; la->horizon_brightness = 1.0f; la->spread = 1.0f; @@ -10192,7 +10192,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) for(sce = main->scene.first; sce; sce = sce->id.next) { ts= sce->toolsettings; - if(ts->normalsize == 0.0 || !ts->uv_selectmode || ts->vgroup_weight == 0.0) { + if(ts->normalsize == 0.0f || !ts->uv_selectmode || ts->vgroup_weight == 0.0f) { ts->normalsize= 0.1f; ts->selectmode= SCE_SELECT_VERTEX; @@ -11449,7 +11449,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) KeyBlock *kb; for (kb = key->block.first; kb; kb = kb->next) { - if (IS_EQ(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0)) + if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0)) kb->slidermax = kb->slidermin + 1.0f; } } diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index ff98ac60166..6b35d7df397 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -109,7 +109,7 @@ void IMB_rect_from_float(struct ImBuf *ibuf) /* quick method to convert floatbuf to byte */ float *tof = (float *)ibuf->rect_float; // int do_dither = ibuf->dither != 0.f; - float dither= ibuf->dither / 255.0; + float dither= ibuf->dither / 255.0f; float srgb[4]; int i, channels= ibuf->channels; short profile= ibuf->profile; @@ -141,7 +141,7 @@ void IMB_rect_from_float(struct ImBuf *ibuf) else if (channels == 4) { if (dither != 0.f) { for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=4) { - const float d = (BLI_frand()-0.5)*dither; + const float d = (BLI_frand()-0.5f)*dither; srgb[0]= d + linearrgb_to_srgb(tof[0]); srgb[1]= d + linearrgb_to_srgb(tof[1]); @@ -170,7 +170,7 @@ void IMB_rect_from_float(struct ImBuf *ibuf) else { if (dither != 0.f) { for (i = ibuf->x * ibuf->y; i > 0; i--, to+=4, tof+=4) { - const float d = (BLI_frand()-0.5)*dither; + const float d = (BLI_frand()-0.5f)*dither; float col[4]; col[0]= d + tof[0]; diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index ef787e8b799..fa5e951067d 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -274,8 +274,8 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float * if (x2>in->x-1 || y2>in->y-1) row4= empty; else row4= (float *)in->rect_float + in->x * y2 * 4 + 4*x2; - a= u-floor(u); - b= v-floor(v); + a= u-floorf(u); + b= v-floorf(v); a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b); outF[0]= ma_mb*row1[0] + a_mb*row3[0] + ma_b*row2[0]+ a_b*row4[0]; @@ -297,8 +297,8 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float * if (x2>in->x-1 || y2>in->y-1) row4I= emptyI; else row4I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x2; - a= u-floor(u); - b= v-floor(v); + a= u-floorf(u); + b= v-floorf(v); a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b); /* need to add 0.5 to avoid rounding down (causes darken with the smear brush) @@ -348,8 +348,8 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl row3= (float *)in->rect_float + in->x * y1 * 4 + 4*x2; row4= (float *)in->rect_float + in->x * y2 * 4 + 4*x2; - a= u-floor(u); - b= v-floor(v); + a= u-floorf(u); + b= v-floorf(v); a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b); outF[0]= ma_mb*row1[0] + a_mb*row3[0] + ma_b*row2[0]+ a_b*row4[0]; @@ -364,8 +364,8 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl row3I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x2; row4I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x2; - a= u-floor(u); - b= v-floor(v); + a= u-floorf(u); + b= v-floorf(v); a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b); /* need to add 0.5 to avoid rounding down (causes darken with the smear brush) diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index a6556cc3a9a..44af7ffdb3f 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -164,7 +164,7 @@ unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac, IMB_ static void blend_color_mix_float(float *cp, float *cp1, float *cp2, float fac) { - float mfac= 1.0-fac; + float mfac= 1.0f-fac; cp[0]= mfac*cp1[0] + fac*cp2[0]; cp[1]= mfac*cp1[1] + fac*cp2[1]; cp[2]= mfac*cp1[2] + fac*cp2[2]; @@ -194,7 +194,7 @@ static void blend_color_sub_float(float *cp, float *cp1, float *cp2, float fac) static void blend_color_mul_float(float *cp, float *cp1, float *cp2, float fac) { - float mfac= 1.0-fac; + float mfac= 1.0f-fac; cp[0]= mfac*cp1[0] + fac*(cp1[0]*cp2[0]); cp[1]= mfac*cp1[1] + fac*(cp1[1]*cp2[1]); @@ -488,7 +488,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float a; /* alpha */ float ai; /* alpha inverted */ float aich; /* alpha, inverted, ai/255.0 - Convert char to float at the same time */ - if ((!rect && !rectf) || (!col) || col[3]==0.0) + if ((!rect && !rectf) || (!col) || col[3]==0.0f) return; /* sanity checks for coords */ @@ -510,7 +510,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, unsigned char chr=0, chg=0, chb=0; float fr=0, fg=0, fb=0; - if (a == 1.0) { + if (a == 1.0f) { chr = FTOCHAR(col[0]); chg = FTOCHAR(col[1]); chb = FTOCHAR(col[2]); @@ -523,7 +523,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, for (i = 0; i < x2-x1; i++) { pixel = rect + 4 * (((y1 + j) * width) + (x1 + i)); if (pixel >= rect && pixel < rect+ (4 * (width * height))) { - if (a == 1.0) { + if (a == 1.0f) { pixel[0] = chr; pixel[1] = chg; pixel[2] = chb; @@ -542,7 +542,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, for (j = 0; j < y2-y1; j++) { for (i = 0; i < x2-x1; i++) { pixel = rectf + 4 * (((y1 + j) * width) + (x1 + i)); - if (a == 1.0) { + if (a == 1.0f) { pixel[0] = col[0]; pixel[1] = col[1]; pixel[2] = col[2]; diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 541f4586afb..9d6748ec1fb 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -594,8 +594,8 @@ static void enlarge_picture_float( for (y_dst = 0; y_dst < dst_height; y_dst++) { float* line1 = src + ((int) y_src) * 4 * src_width; float* line2 = line1 + 4 * src_width; - float weight1y = 1.0 - (y_src - (int) y_src); - float weight2y = 1.0 - weight1y; + const float weight1y = (float)(1.0 - (y_src - (int) y_src)); + const float weight2y = 1.0f - weight1y; if ((int) y_src == src_height - 1) { line2 = line1; @@ -603,13 +603,13 @@ static void enlarge_picture_float( x_src = 0; for (x_dst = 0; x_dst < dst_width; x_dst++) { - float weight1x = 1.0 - (x_src - (int) x_src); - float weight2x = 1.0 - weight1x; + const float weight1x = (float)(1.0 - (x_src - (int) x_src)); + const float weight2x = (float)(1.0f - weight1x); - float w11 = weight1y * weight1x; - float w21 = weight2y * weight1x; - float w12 = weight1y * weight2x; - float w22 = weight2y * weight2x; + const float w11 = weight1y * weight1x; + const float w21 = weight2y * weight1x; + const float w12 = weight1y * weight2x; + const float w22 = weight2y * weight2x; uintptr_t x = ((int) x_src) * 4; @@ -678,12 +678,12 @@ static void shrink_picture_float( y_counter = 1.0; for (y_src = 0; y_src < src_height; y_src++) { float* line = src + y_src * 4 * src_width; - uintptr_t weight1y = 1.0 - (y_dst - (int) y_dst); - uintptr_t weight2y = 1.0 - weight1y; + uintptr_t weight1y = 1.0f - (y_dst - (int) y_dst); + uintptr_t weight2y = 1.0f - weight1y; x_dst = 0; for (x_src = 0; x_src < src_width; x_src++) { - uintptr_t weight1x = 1.0 - (x_dst - (int) x_dst); - uintptr_t weight2x = 1.0 - weight1x; + uintptr_t weight1x = 1.0f - (x_dst - (int) x_dst); + uintptr_t weight2x = 1.0f - weight1x; uintptr_t x = (int) x_dst; @@ -731,10 +731,10 @@ static void shrink_picture_float( uintptr_t x; struct scale_outpix_float * temp; - y_counter += 1.0; + y_counter += 1.0f; for (x=0; x < dst_width; x++) { - float f = 1.0 / dst_line1[x].weight; + float f = 1.0f / dst_line1[x].weight; *dst++ = dst_line1[x].r * f; *dst++ = dst_line1[x].g * f; *dst++ = dst_line1[x].b * f; @@ -750,7 +750,7 @@ static void shrink_picture_float( if (dst - dst_begin < dst_width * dst_height * 4) { uintptr_t x; for (x = 0; x < dst_width; x++) { - float f = 1.0 / dst_line1[x].weight; + float f = 1.0f / dst_line1[x].weight; *dst++ = dst_line1[x].r * f; *dst++ = dst_line1[x].g * f; *dst++ = dst_line1[x].b * f; @@ -1026,8 +1026,8 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy) sample += add; - while (sample >= 1.0) { - sample -= 1.0; + while (sample >= 1.0f) { + sample -= 1.0f; if (do_rect) { nval[0] += rect[0]; @@ -1069,7 +1069,7 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy) newrectf += skipx; } - sample -= 1.0; + sample -= 1.0f; } } @@ -1142,22 +1142,22 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx) val_a = rect[0] ; nval_a = rect[4]; diff_a = nval_a - val_a ; - val_a += 0.5; + val_a += 0.5f; val_b = rect[1] ; nval_b = rect[5]; diff_b = nval_b - val_b ; - val_b += 0.5; + val_b += 0.5f; val_g = rect[2] ; nval_g = rect[6]; diff_g = nval_g - val_g ; - val_g += 0.5; + val_g += 0.5f; val_r = rect[3] ; nval_r = rect[7]; diff_r = nval_r - val_r ; - val_r += 0.5; + val_r += 0.5f; rect += 8; } @@ -1181,29 +1181,29 @@ static struct ImBuf *scaleupx(struct ImBuf *ibuf, int newx) rectf += 8; } for (x = newx ; x>0 ; x--){ - if (sample >= 1.0){ - sample -= 1.0; + if (sample >= 1.0f){ + sample -= 1.0f; if (do_rect) { val_a = nval_a ; nval_a = rect[0] ; diff_a = nval_a - val_a ; - val_a += 0.5; + val_a += 0.5f; val_b = nval_b ; nval_b = rect[1] ; diff_b = nval_b - val_b ; - val_b += 0.5; + val_b += 0.5f; val_g = nval_g ; nval_g = rect[2] ; diff_g = nval_g - val_g ; - val_g += 0.5; + val_g += 0.5f; val_r = nval_r ; nval_r = rect[3] ; diff_r = nval_r - val_r ; - val_r += 0.5; + val_r += 0.5f; rect += 4; } if (do_float) { @@ -1312,22 +1312,22 @@ static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy) val_a = rect[0] ; nval_a = rect[skipx]; diff_a = nval_a - val_a ; - val_a += 0.5; + val_a += 0.5f; val_b = rect[1] ; nval_b = rect[skipx+1]; diff_b = nval_b - val_b ; - val_b += 0.5; + val_b += 0.5f; val_g = rect[2] ; nval_g = rect[skipx+2]; diff_g = nval_g - val_g ; - val_g += 0.5; + val_g += 0.5f; val_r = rect[3] ; nval_r = rect[skipx+4]; diff_r = nval_r - val_r ; - val_r += 0.5; + val_r += 0.5f; rect += 2*skipx; } @@ -1355,29 +1355,29 @@ static struct ImBuf *scaleupy(struct ImBuf *ibuf, int newy) } for (y = newy ; y>0 ; y--){ - if (sample >= 1.0){ - sample -= 1.0; + if (sample >= 1.0f){ + sample -= 1.0f; if (do_rect) { val_a = nval_a ; nval_a = rect[0] ; diff_a = nval_a - val_a ; - val_a += 0.5; + val_a += 0.5f; val_b = nval_b ; nval_b = rect[1] ; diff_b = nval_b - val_b ; - val_b += 0.5; + val_b += 0.5f; val_g = nval_g ; nval_g = rect[2] ; diff_g = nval_g - val_g ; - val_g += 0.5; + val_g += 0.5f; val_r = nval_r ; nval_r = rect[3] ; diff_r = nval_r - val_r ; - val_r += 0.5; + val_r += 0.5f; rect += skipx; } if (do_float) { diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 0c04887e606..155696fb199 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -336,7 +336,7 @@ static void scanline_contig_32bit(float *rectf, float *fbuf, int scanline_w, int rectf[i*4 + 0] = fbuf[i*spp + 0]; rectf[i*4 + 1] = fbuf[i*spp + 1]; rectf[i*4 + 2] = fbuf[i*spp + 2]; - rectf[i*4 + 3] = (spp==4)?fbuf[i*spp + 3]:1.0; + rectf[i*4 + 3] = (spp==4)?fbuf[i*spp + 3]:1.0f; } } diff --git a/source/blender/python/generic/mathutils.c b/source/blender/python/generic/mathutils.c index 7cb1728f817..e94f7f798fc 100644 --- a/source/blender/python/generic/mathutils.c +++ b/source/blender/python/generic/mathutils.c @@ -66,7 +66,7 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max i= size; do { i--; - if(((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0) && PyErr_Occurred()) { + if(((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) { PyErr_Format(PyExc_ValueError, "%.200s: sequence index %d expected a number, found '%.200s' type, ", error_prefix, i, Py_TYPE(item)->tp_name); Py_DECREF(value_fast); return -1; diff --git a/source/blender/python/generic/mathutils_Matrix.c b/source/blender/python/generic/mathutils_Matrix.c index c048058f63c..936c761bf90 100644 --- a/source/blender/python/generic/mathutils_Matrix.c +++ b/source/blender/python/generic/mathutils_Matrix.c @@ -542,7 +542,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) if(matSize == 2) { float const factor= PyFloat_AsDouble(fac); - if(factor==-1.0 && PyErr_Occurred()) { + if(factor==-1.0f && PyErr_Occurred()) { PyErr_SetString(PyExc_AttributeError, "mathutils.Matrix.Shear(): the factor to be a float"); return NULL; } @@ -1520,12 +1520,12 @@ static PyObject *Matrix_mul(PyObject * m1, PyObject * m2) } } else if(mat2) { - if (((scalar= PyFloat_AsDouble(m1)) == -1.0 && PyErr_Occurred())==0) { /*FLOAT/INT * MATRIX */ + if (((scalar= PyFloat_AsDouble(m1)) == -1.0f && PyErr_Occurred())==0) { /*FLOAT/INT * MATRIX */ return matrix_mul_float(mat2, scalar); } } else if(mat1) { - if (((scalar= PyFloat_AsDouble(m2)) == -1.0 && PyErr_Occurred())==0) { /*FLOAT/INT * MATRIX */ + if (((scalar= PyFloat_AsDouble(m2)) == -1.0f && PyErr_Occurred())==0) { /*FLOAT/INT * MATRIX */ return matrix_mul_float(mat1, scalar); } } diff --git a/source/blender/python/generic/mathutils_Quaternion.c b/source/blender/python/generic/mathutils_Quaternion.c index 75d79d5afac..43d3cbc62b0 100644 --- a/source/blender/python/generic/mathutils_Quaternion.c +++ b/source/blender/python/generic/mathutils_Quaternion.c @@ -723,12 +723,12 @@ static PyObject *Quaternion_mul(PyObject *q1, PyObject *q2) } /* the only case this can happen (for a supported type is "FLOAT*QUAT") */ else if(quat2) { /* FLOAT*QUAT */ - if(((scalar= PyFloat_AsDouble(q1)) == -1.0 && PyErr_Occurred())==0) { + if(((scalar= PyFloat_AsDouble(q1)) == -1.0f && PyErr_Occurred())==0) { return quat_mul_float(quat2, scalar); } } else if (quat1) { /* QUAT*FLOAT */ - if((((scalar= PyFloat_AsDouble(q2)) == -1.0 && PyErr_Occurred())==0)) { + if((((scalar= PyFloat_AsDouble(q2)) == -1.0f && PyErr_Occurred())==0)) { return quat_mul_float(quat1, scalar); } } @@ -837,7 +837,7 @@ static PyObject *Quaternion_getAngle(QuaternionObject *self, void *UNUSED(closur return NULL; normalize_qt_qt(tquat, self->quat); - return PyFloat_FromDouble(2.0 * (saacos(tquat[0]))); + return PyFloat_FromDouble(2.0f * (saacos(tquat[0]))); } static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UNUSED(closure)) @@ -856,7 +856,7 @@ static int Quaternion_setAngle(QuaternionObject *self, PyObject *value, void *UN angle= PyFloat_AsDouble(value); - if(angle==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + if(angle==-1.0 && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "quaternion.angle = value: float expected"); return -1; } diff --git a/source/blender/python/generic/mathutils_Vector.c b/source/blender/python/generic/mathutils_Vector.c index 0ea380d1ee6..f1e417b154e 100644 --- a/source/blender/python/generic/mathutils_Vector.c +++ b/source/blender/python/generic/mathutils_Vector.c @@ -719,7 +719,7 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) if(BaseMath_ReadCallback(self) == -1) return NULL; - ifac= 1.0 - fac; + ifac= 1.0f - fac; for(x = 0; x < size; x++) { vec[x] = (ifac * self->vec[x]) + (fac * tvec[x]); @@ -1111,12 +1111,12 @@ static PyObject *Vector_mul(PyObject * v1, PyObject * v2) mul_qt_v3(quat2->quat, tvec); return newVectorObject(tvec, 3, Py_NEW, Py_TYPE(vec1)); } - else if (((scalar= PyFloat_AsDouble(v2)) == -1.0 && PyErr_Occurred())==0) { /* VEC*FLOAT */ + else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC*FLOAT */ return vector_mul_float(vec1, scalar); } } else if (vec2) { - if (((scalar= PyFloat_AsDouble(v1)) == -1.0 && PyErr_Occurred())==0) { /* VEC*FLOAT */ + if (((scalar= PyFloat_AsDouble(v1)) == -1.0f && PyErr_Occurred())==0) { /* VEC*FLOAT */ return vector_mul_float(vec2, scalar); } } @@ -1163,7 +1163,7 @@ static PyObject *Vector_imul(PyObject * v1, PyObject * v2) } mul_qt_v3(quat2->quat, vec->vec); } - else if (((scalar= PyFloat_AsDouble(v2)) == -1.0 && PyErr_Occurred())==0) { /* VEC*=FLOAT */ + else if (((scalar= PyFloat_AsDouble(v2)) == -1.0f && PyErr_Occurred())==0) { /* VEC*=FLOAT */ mul_vn_fl(vec->vec, vec->size, scalar); } else { @@ -1197,7 +1197,7 @@ static PyObject *Vector_div(PyObject * v1, PyObject * v2) return NULL; } - if(scalar==0.0) { + if(scalar==0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error"); return NULL; } @@ -1223,7 +1223,7 @@ static PyObject *Vector_idiv(PyObject * v1, PyObject * v2) return NULL; } - if(scalar==0.0) { + if(scalar==0.0f) { PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error"); return NULL; } diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c index a0991e00d07..fc821f2697a 100644 --- a/source/blender/python/generic/mathutils_geometry.c +++ b/source/blender/python/generic/mathutils_geometry.c @@ -114,7 +114,7 @@ static PyObject *M_Geometry_intersect_ray_tri(PyObject *UNUSED(self), PyObject* /* if determinant is near zero, ray lies in plane of triangle */ det= dot_v3v3(e1, pvec); - if (det > -0.000001 && det < 0.000001) { + if (det > -0.000001f && det < 0.000001f) { Py_RETURN_NONE; } From a73c3fe5c992777718431d5e5bb5f8a2c3b7a1bc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 27 Mar 2011 17:22:04 +0000 Subject: [PATCH 134/261] subsurf, derived mesh and other misc files: floats were being implicitly promoted to doubles, adjust to use floats. --- source/blender/blenkernel/intern/CCGSubSurf.c | 58 +++++++++---------- .../blender/blenkernel/intern/DerivedMesh.c | 14 ++--- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/anim_sys.c | 4 +- source/blender/blenkernel/intern/lattice.c | 14 ++--- source/blender/blenkernel/intern/object.c | 36 ++++++------ source/blender/editors/animation/anim_draw.c | 6 +- .../blender/editors/animation/fmodifier_ui.c | 2 +- .../editors/animation/keyframes_draw.c | 6 +- .../editors/animation/keyframes_edit.c | 6 +- .../blender/editors/armature/editarmature.c | 8 +-- source/blender/editors/gpencil/drawgpencil.c | 2 +- source/blender/editors/screen/area.c | 2 +- source/blender/editors/screen/screen_edit.c | 7 +-- source/blender/editors/sculpt_paint/sculpt.c | 16 ++--- source/blender/editors/space_file/file_draw.c | 2 +- source/blender/editors/space_file/filesel.c | 4 +- .../blender/editors/space_graph/graph_edit.c | 10 ++-- .../blender/editors/space_image/image_draw.c | 4 +- .../blender/editors/space_image/image_ops.c | 2 +- .../blender/editors/space_image/space_image.c | 2 +- source/blender/editors/space_info/info_ops.c | 4 +- source/blender/editors/space_nla/nla_draw.c | 12 ++-- .../editors/space_sequencer/sequencer_edit.c | 2 +- source/blender/editors/space_text/text_draw.c | 2 +- source/blender/editors/util/ed_util.c | 6 +- source/blender/makesrna/intern/rna_access.c | 12 ++-- .../windowmanager/intern/wm_operators.c | 6 +- .../windowmanager/intern/wm_subwindow.c | 12 ++-- 29 files changed, 129 insertions(+), 134 deletions(-) diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index c682b189ae8..2cfd17a95f3 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -229,9 +229,9 @@ static int VertDataEqual(float *a, float *b) { #define VertDataAvg4(tv, av, bv, cv, dv) \ { \ float *_t = (float*) tv, *_a = (float*) av, *_b = (float*) bv, *_c = (float*) cv, *_d = (float*) dv; \ - _t[0] = (_a[0]+_b[0]+_c[0]+_d[0])*.25; \ - _t[1] = (_a[1]+_b[1]+_c[1]+_d[1])*.25; \ - _t[2] = (_a[2]+_b[2]+_c[2]+_d[2])*.25; \ + _t[0] = (_a[0]+_b[0]+_c[0]+_d[0])*.25f; \ + _t[1] = (_a[1]+_b[1]+_c[1]+_d[1])*.25f; \ + _t[2] = (_a[2]+_b[2]+_c[2]+_d[2])*.25f; \ } #define NormZero(av) { float *_a = (float*) av; _a[0] = _a[1] = _a[2] = 0.0f; } #define NormCopy(av, bv) { float *_a = (float*) av, *_b = (float*) bv; _a[0] =_b[0]; _a[1] =_b[1]; _a[2] =_b[2]; } @@ -507,9 +507,9 @@ static float EDGE_getSharpness(CCGEdge *e, int lvl) { if (!lvl) return e->crease; else if (!e->crease) - return 0.0; - else if (e->crease - lvl < 0.0) - return 0.0; + return 0.0f; + else if (e->crease - lvl < 0.0f) + return 0.0f; else return e->crease - lvl; } @@ -1447,7 +1447,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, float sharpness = EDGE_getSharpness(e, curLvl); int x, j; - if (_edge_isBoundary(e) || sharpness>1.0) { + if (_edge_isBoundary(e) || sharpness > 1.0f) { for (x=0; x1.0) { - avgSharpness = 1.0; + if (avgSharpness > 1.0f) { + avgSharpness = 1.0f; } } @@ -1542,7 +1542,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } VertDataCopy(nCo, co); - VertDataMulN(nCo, 0.75); + VertDataMulN(nCo, 0.75f); VertDataMulN(r, 0.25f/numBoundary); VertDataAdd(nCo, r); } else { @@ -1587,7 +1587,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, if (seam) { if (_edge_isBoundary(e)) VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize)); - } else if (sharpness != 0.0) { + } else if (sharpness != 0.0f) { VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize)); } } @@ -1604,8 +1604,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, // r = co*.75 + q*.25 VertDataCopy(r, co); - VertDataMulN(r, .75); - VertDataMulN(q, .25); + VertDataMulN(r, .75f); + VertDataMulN(q, .25f); VertDataAdd(r, q); // nCo = nCo + (r-nCo)*avgSharpness @@ -1631,8 +1631,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, sharpCount = 2; avgSharpness += sharpness; - if (avgSharpness>1.0) { - avgSharpness = 1.0; + if (avgSharpness > 1.0f) { + avgSharpness = 1.0f; } } else { sharpCount = 0; @@ -1646,10 +1646,10 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, void *nCo = EDGE_getCo(e, nextLvl, fx); VertDataCopy(r, EDGE_getCo(e, curLvl, x-1)); VertDataAdd(r, EDGE_getCo(e, curLvl, x+1)); - VertDataMulN(r, 0.5); + VertDataMulN(r, 0.5f); VertDataCopy(nCo, co); - VertDataMulN(nCo, 0.75); - VertDataMulN(r, 0.25); + VertDataMulN(nCo, 0.75f); + VertDataMulN(r, 0.25f); VertDataAdd(nCo, r); } } else { @@ -1671,8 +1671,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, VertDataAdd(r, _face_getIFCoEdge(f, e, curLvl, x, 1, subdivLevels, vertDataSize)); numFaces++; } - VertDataMulN(q, 1.0/(numFaces*2.0f)); - VertDataMulN(r, 1.0/(2.0f + numFaces)); + VertDataMulN(q, 1.0f/(numFaces*2.0f)); + VertDataMulN(r, 1.0f/(2.0f + numFaces)); VertDataCopy(nCo, co); VertDataMulN(nCo, (float) numFaces); @@ -1895,7 +1895,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { void *co = EDGE_getCo(e, nextLvl, 1); float sharpness = EDGE_getSharpness(e, curLvl); - if (_edge_isBoundary(e) || sharpness>=1.0) { + if (_edge_isBoundary(e) || sharpness >= 1.0f) { VertDataCopy(co, VERT_getCo(e->v0, curLvl)); VertDataAdd(co, VERT_getCo(e->v1, curLvl)); VertDataMulN(co, 0.5f); @@ -1947,8 +1947,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { if(sharpCount) { avgSharpness /= sharpCount; - if (avgSharpness>1.0) { - avgSharpness = 1.0; + if (avgSharpness > 1.0f) { + avgSharpness = 1.0f; } } @@ -1969,7 +1969,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { } } VertDataCopy(nCo, co); - VertDataMulN(nCo, 0.75); + VertDataMulN(nCo, 0.75f); VertDataMulN(r, 0.25f/numBoundary); VertDataAdd(nCo, r); } else { @@ -2015,7 +2015,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { CCGVert *oV = _edge_getOtherVert(e, v); VertDataAdd(q, VERT_getCo(oV, curLvl)); } - } else if (sharpness != 0.0) { + } else if (sharpness != 0.0f) { CCGVert *oV = _edge_getOtherVert(e, v); VertDataAdd(q, VERT_getCo(oV, curLvl)); } @@ -2033,8 +2033,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { // r = co*.75 + q*.25 VertDataCopy(r, co); - VertDataMulN(r, .75); - VertDataMulN(q, .25); + VertDataMulN(r, 0.75f); + VertDataMulN(q, 0.25f); VertDataAdd(r, q); // nCo = nCo + (r-nCo)*avgSharpness diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 987f70e67ca..b0a1e74c30f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1123,9 +1123,7 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r) VECCOPY(vert_r->co, ev->co); - vert_r->no[0] = ev->no[0] * 32767.0; - vert_r->no[1] = ev->no[1] * 32767.0; - vert_r->no[2] = ev->no[2] * 32767.0; + normal_float_to_short_v3(vert_r->no, ev->no); /* TODO what to do with vert_r->flag? */ vert_r->bweight = (unsigned char) (ev->bweight*255.0f); @@ -1220,9 +1218,7 @@ static void emDM_copyVertArray(DerivedMesh *dm, MVert *vert_r) else copy_v3_v3(vert_r->co, ev->co); - vert_r->no[0] = ev->no[0] * 32767.0; - vert_r->no[1] = ev->no[1] * 32767.0; - vert_r->no[2] = ev->no[2] * 32767.0; + normal_float_to_short_v3(vert_r->no, ev->no); /* TODO what to do with vert_r->flag? */ vert_r->flag = 0; @@ -1425,7 +1421,7 @@ DerivedMesh *editmesh_get_derived(EditMesh *em, float (*vertexCos)[3]) float *no = emdm->vertexNos[i]; /* following Mesh convention; we use vertex coordinate itself * for normal in this case */ - if (normalize_v3(no)==0.0) { + if (normalize_v3(no) == 0.0f) { normalize_v3_v3(no, vertexCos[i]); } } @@ -1596,12 +1592,12 @@ void weight_to_rgb(float input, float *fr, float *fg, float *fb) *fg= blend; *fb= blend*(1.0f-((input-0.25f)*4.0f)); } - else if (input<=0.75){ // green->yellow + else if (input <= 0.75f){ // green->yellow *fr= blend * ((input-0.50f)*4.0f); *fg= blend; *fb= 0.0f; } - else if (input<=1.0){ // yellow->red + else if (input <= 1.0f){ // yellow->red *fr= blend; *fg= blend * (1.0f-((input-0.75f)*4.0f)); *fb= 0.0f; diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 2e1fbf2917a..e12ec559f4b 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1125,7 +1125,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa /* scale */ if(par->transflag & OB_DUPLIFACES_SCALE) { float size= v4? area_quad_v3(v1, v2, v3, v4): area_tri_v3(v1, v2, v3); - size= sqrt(size) * par->dupfacesca; + size= sqrtf(size) * par->dupfacesca; mul_m3_fl(mat, size); } diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index b4adaa0ab07..6e933ddd386 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1905,7 +1905,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */ calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1); dummy_strip.start = dummy_strip.actstart; - dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend); + dummy_strip.end = (IS_EQF(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend); dummy_strip.blendmode= adt->act_blendmode; dummy_strip.extendmode= adt->act_extendmode; @@ -2072,7 +2072,7 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re void BKE_animsys_evaluate_all_animation (Main *main, float ctime) { ID *id; - + if (G.f & G_DEBUG) printf("Evaluate all animation - %f \n", ctime); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 091c4a2fe50..f66afff0741 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -412,7 +412,7 @@ void calc_latt_deform(Object *ob, float *co, float weight) for(ww= wi-1; ww<=wi+2; ww++) { w= tw[ww-wi+1]; - if(w!=0.0) { + if(w != 0.0f) { if(ww>0) { if(wwpntsw) idx_w= ww*lt->pntsu*lt->pntsv; else idx_w= (lt->pntsw-1)*lt->pntsu*lt->pntsv; @@ -422,7 +422,7 @@ void calc_latt_deform(Object *ob, float *co, float weight) for(vv= vi-1; vv<=vi+2; vv++) { v= w*tv[vv-vi+1]; - if(v!=0.0) { + if(v != 0.0f) { if(vv>0) { if(vvpntsv) idx_v= idx_w + vv*lt->pntsu; else idx_v= idx_w + (lt->pntsv-1)*lt->pntsu; @@ -432,7 +432,7 @@ void calc_latt_deform(Object *ob, float *co, float weight) for(uu= ui-1; uu<=ui+2; uu++) { u= weight*v*tu[uu-ui+1]; - if(u!=0.0) { + if(u != 0.0f) { if(uu>0) { if(uupntsu) idx_u= idx_v + uu; else idx_u= idx_v + (lt->pntsu-1); @@ -508,7 +508,7 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, if(bl && bl->poly> -1) cycl= 1; if(cycl==0) { - ctime1= CLAMPIS(ctime, 0.0, 1.0); + ctime1= CLAMPIS(ctime, 0.0f, 1.0f); } else ctime1= ctime; @@ -519,16 +519,16 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, Path *path= cu->path; float dvec[3]; - if(ctime < 0.0) { + if(ctime < 0.0f) { sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec); mul_v3_fl(dvec, ctime*(float)path->len); add_v3_v3(vec, dvec); if(quat) copy_qt_qt(quat, path->data[0].quat); if(radius) *radius= path->data[0].radius; } - else if(ctime > 1.0) { + else if(ctime > 1.0f) { sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec); - mul_v3_fl(dvec, (ctime-1.0)*(float)path->len); + mul_v3_fl(dvec, (ctime-1.0f)*(float)path->len); add_v3_v3(vec, dvec); if(quat) copy_qt_qt(quat, path->data[path->len-1].quat); if(radius) *radius= path->data[path->len-1].radius; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0348d188a7d..ca31cd1b0b1 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1814,19 +1814,19 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) * we divide the curvetime calculated in the previous step by the length of the path, to get a time * factor, which then gets clamped to lie within 0.0 - 1.0 range */ - if (IS_EQ(cu->pathlen, 0.0f) == 0) + if (IS_EQF(cu->pathlen, 0.0f) == 0) ctime= cu->ctime / cu->pathlen; else ctime= cu->ctime; - - CLAMP(ctime, 0.0, 1.0); + + CLAMP(ctime, 0.0f, 1.0f); } else { ctime= scene->r.cfra - give_timeoffset(ob); - if (IS_EQ(cu->pathlen, 0.0f) == 0) + if (IS_EQF(cu->pathlen, 0.0f) == 0) ctime /= cu->pathlen; - CLAMP(ctime, 0.0, 1.0); + CLAMP(ctime, 0.0f, 1.0f); } /* time calculus is correct, now apply distance offset */ @@ -2332,9 +2332,9 @@ void object_get_dimensions(Object *ob, float *value) mat4_to_size( scale,ob->obmat); - value[0] = fabs(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); - value[1] = fabs(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); - value[2] = fabs(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]); + value[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); + value[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); + value[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]); } else { value[0] = value[1] = value[2] = 0.f; } @@ -2853,18 +2853,18 @@ void object_camera_matrix( } else if(camera->type==OB_LAMP) { Lamp *la= camera->data; - float fac= cos( M_PI*la->spotsize/360.0 ); + float fac= cosf((float)M_PI*la->spotsize/360.0f); float phi= acos(fac); - (*lens)= 16.0*fac/sin(phi); + (*lens)= 16.0f*fac/sinf(phi); if((*lens)==0.0f) - (*lens)= 35.0; + (*lens)= 35.0f; (*clipsta)= la->clipsta; (*clipend)= la->clipend; } else { /* envmap exception... */; if((*lens)==0.0f) - (*lens)= 16.0; + (*lens)= 16.0f; if((*clipsta)==0.0f || (*clipend)==0.0f) { (*clipsta)= 0.1f; @@ -2884,8 +2884,8 @@ void object_camera_matrix( pixsize= cam->ortho_scale/viewfac; } else { - if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx)/32.0; - else viewfac= (*ycor) * ((*lens) * winy)/32.0; + if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx)/32.0f; + else viewfac= (*ycor) * ((*lens) * winy)/32.0f; pixsize= (*clipsta) / viewfac; } @@ -2898,12 +2898,12 @@ void object_camera_matrix( if(field_second) { if(rd->mode & R_ODDFIELD) { - viewplane->ymin-= 0.5 * (*ycor); - viewplane->ymax-= 0.5 * (*ycor); + viewplane->ymin-= 0.5f * (*ycor); + viewplane->ymax-= 0.5f * (*ycor); } else { - viewplane->ymin+= 0.5 * (*ycor); - viewplane->ymax+= 0.5 * (*ycor); + viewplane->ymin+= 0.5f * (*ycor); + viewplane->ymax+= 0.5f * (*ycor); } } /* the window matrix is used for clipping, and not changed during OSA steps */ diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index d0fa540a9dd..9c923d3492b 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -100,7 +100,7 @@ void ANIM_timecode_string_from_frame (char *str, Scene *scene, int power, short * to cope with 'half' frames, etc., which should be fine in most cases */ seconds= (int)cfra; - frames= (int)floor( ((cfra - seconds) * FPS) + 0.5f ); + frames= (int)floor( (((double)cfra - (double)seconds) * FPS) + 0.5 ); } else { /* seconds (with pixel offset rounding) */ @@ -399,9 +399,9 @@ float ANIM_unit_mapping_get_factor (Scene *scene, ID *id, FCurve *fcu, short res /* if the radians flag is not set, default to using degrees which need conversions */ if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) { if (restore) - return M_PI / 180.0f; /* degrees to radians */ + return M_PI / 180.0; /* degrees to radians */ else - return 180.0f / M_PI; /* radians to degrees */ + return 180.0 / M_PI; /* radians to degrees */ } } diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index d14ebc2c7bb..85063be852d 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -301,7 +301,7 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short /* --------------- */ -#define BINARYSEARCH_FRAMEEQ_THRESH 0.0001 +#define BINARYSEARCH_FRAMEEQ_THRESH 0.0001f /* Binary search algorithm for finding where to insert Envelope Data Point. * Returns the index to insert at (data already at that index will be offset if replace is 0) diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 662f038fd6e..c4108e0ce33 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -360,9 +360,9 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree, * -> secondly, handles which control that section of the curve must be constant */ if ((!prev) || (!beztn)) return; - if (IS_EQ(beztn->vec[1][1], prev->vec[1][1])==0) return; - if (IS_EQ(beztn->vec[1][1], beztn->vec[0][1])==0) return; - if (IS_EQ(prev->vec[1][1], prev->vec[2][1])==0) return; + if (IS_EQF(beztn->vec[1][1], prev->vec[1][1])==0) return; + if (IS_EQF(beztn->vec[1][1], beztn->vec[0][1])==0) return; + if (IS_EQF(prev->vec[1][1], prev->vec[2][1])==0) return; /* if there are no blocks already, just add as root */ diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index a2b5e2b1c8d..1ce05573e85 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -537,7 +537,7 @@ static short ok_bezier_frame(KeyframeEditData *ked, BezTriple *bezt) short ok = 0; /* frame is stored in f1 property (this float accuracy check may need to be dropped?) */ - #define KEY_CHECK_OK(_index) IS_EQ(bezt->vec[_index][0], ked->f1) + #define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][0], ked->f1) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK @@ -577,7 +577,7 @@ static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt) * - this float accuracy check may need to be dropped? * - should value be stored in f2 instead so that we won't have conflicts when using f1 for frames too? */ - #define KEY_CHECK_OK(_index) IS_EQ(bezt->vec[_index][1], ked->f1) + #define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][1], ked->f1) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK @@ -697,7 +697,7 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt) static short snap_bezier_nearest(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->vec[1][0]= (float)(floor(bezt->vec[1][0]+0.5)); + bezt->vec[1][0]= (float)(floorf(bezt->vec[1][0]+0.5f)); return 0; } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 1709d8cb085..4e77cebf27d 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -2127,7 +2127,7 @@ float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const short sub_v3_v3v3(align_axis_proj, align_axis, vec); if(axis_only) { - if(angle_v3v3(align_axis_proj, mat[2]) > M_PI/2) { + if(angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI/2.0)) { negate_v3(align_axis_proj); } } @@ -4704,14 +4704,14 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); /* add the vert to the deform group if weight!=0.0 */ - if (distance!=0.0) + if (distance != 0.0f) ED_vgroup_vert_add (ob, dgroup, i, distance, WEIGHT_REPLACE); else ED_vgroup_vert_remove (ob, dgroup, i); /* do same for mirror */ if (dgroupflip && dgroupflip[j] && iflip >= 0) { - if (distance!=0.0) + if (distance != 0.0f) ED_vgroup_vert_add (ob, dgroupflip[j], iflip, distance, WEIGHT_REPLACE); else @@ -4960,7 +4960,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) pchan->rotAxis[2]= 0.0f; /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */ - if (IS_EQ(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQ(pchan->rotAxis[1], pchan->rotAxis[2])) + if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2])) pchan->rotAxis[1] = 1.0f; } else if (pchan->rotmode == ROT_MODE_QUAT) { diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 8d41ed5fec1..276f60bdf7f 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -384,7 +384,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s mt[1]= mb[1] * pthick; athick= len_v2(mt); dfac= pthick - (athick * 2); - if ( ((athick * 2.0f) < pthick) && (IS_EQ(athick, pthick)==0) ) + if ( ((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick)==0) ) { mt[0] += (mb[0] * dfac); mt[1] += (mb[1] * dfac); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index f272352c183..aca9a401321 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -107,7 +107,7 @@ void ED_region_pixelspace(ARegion *ar) int width= ar->winrct.xmax-ar->winrct.xmin+1; int height= ar->winrct.ymax-ar->winrct.ymin+1; - wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375); + wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); glLoadIdentity(); } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 41354c83cec..a40c62360c9 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -324,8 +324,7 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac) if(dir=='h' && (sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY)) return 0; // to be sure - if(fac<0.0) fac= 0.0; - if(fac>1.0) fac= 1.0; + CLAMP(fac, 0.0f, 1.0f); if(dir=='h') { y= sa->v1->vec.y+ fac*(sa->v2->vec.y- sa->v1->vec.y); @@ -654,14 +653,14 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) /* FIXME, this resizing logic is no good when resizing the window + redrawing [#24428] * need some way to store these as floats internally and re-apply from there. */ tempf= ((float)sv->vec.x)*facx; - sv->vec.x= (short)(tempf+0.5); + sv->vec.x= (short)(tempf+0.5f); sv->vec.x+= AREAGRID-1; sv->vec.x-= (sv->vec.x % AREAGRID); CLAMP(sv->vec.x, 0, winsizex); tempf= ((float)sv->vec.y)*facy; - sv->vec.y= (short)(tempf+0.5); + sv->vec.y= (short)(tempf+0.5f); sv->vec.y+= AREAGRID-1; sv->vec.y-= (sv->vec.y % AREAGRID); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 1428a9a9075..1d818818908 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -537,8 +537,8 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis, //distsq = len_squared_v3v3(mirror, cache->traced_location); distsq = len_squared_v3v3(mirror, cache->true_location); - if (distsq <= 4*(cache->radius_squared)) - return (2*(cache->radius) - sqrt(distsq)) / (2*(cache->radius)); + if (distsq <= 4.0f*(cache->radius_squared)) + return (2.0f*(cache->radius) - sqrtf(distsq)) / (2.0f*(cache->radius)); else return 0; } @@ -731,12 +731,12 @@ static float tex_strength(SculptSession *ss, Brush *br, float *point, const floa /* it is probably worth optimizing for those cases where the texture is not rotated by skipping the calls to atan2, sqrtf, sin, and cos. */ - if (rotation > 0.001 || rotation < -0.001) { - const float angle = atan2(y, x) + rotation; + if (rotation > 0.001f || rotation < -0.001f) { + const float angle = atan2f(y, x) + rotation; const float flen = sqrtf(x*x + y*y); - x = flen * cos(angle); - y = flen * sin(angle); + x = flen * cosf(angle); + y = flen * sinf(angle); } x *= br->mtex.size[0]; @@ -798,7 +798,7 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float va if(sd->flags & (SCULPT_LOCK_X << i)) continue; - if((ss->cache->flag & (CLIP_X << i)) && (fabs(co[i]) <= ss->cache->clip_tolerance[i])) + if((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i])) co[i]= 0.0f; else co[i]= val[i]; @@ -3135,7 +3135,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, st (brush->flag & BRUSH_RANDOM_ROTATION) && !(brush->flag & BRUSH_RAKE)) { - cache->special_rotation = 2*M_PI*BLI_frand(); + cache->special_rotation = 2.0f*(float)M_PI*BLI_frand(); } } diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 4f523f0ca76..22bf99053e8 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -309,7 +309,7 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in fs.align = align; BLI_strncpy(fname,string, FILE_MAXFILE); - file_shorten_string(fname, width+1.0, 0); + file_shorten_string(fname, width + 1.0f, 0); /* no text clipping needed, uiStyleFontDraw does it but is a bit too strict (for buttons it works) */ rect.xmin = sx; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 22f15b76dd3..0e61d30cccd 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -248,11 +248,11 @@ int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar) if (layout->flag & FILE_LAYOUT_HOR) { int width = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x; - numfiles = (float)width/(float)layout->tile_w+0.5; + numfiles = (float)width/(float)layout->tile_w + 0.5f; return numfiles*layout->rows; } else { int height = ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*layout->tile_border_y; - numfiles = (float)height/(float)layout->tile_h+0.5; + numfiles = (float)height/(float)layout->tile_h + 0.5f; return numfiles*layout->columns; } } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index deffc60019e..1bb6e6f6edb 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -128,8 +128,8 @@ void get_graph_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, flo } /* ensure that the extents are not too extreme that view implodes...*/ - if ((xmin && xmax) && (fabs(*xmax - *xmin) < 0.1)) *xmax += 0.1; - if ((ymin && ymax) && (fabs(*ymax - *ymin) < 0.1)) *ymax += 0.1; + if ((xmin && xmax) && (fabsf(*xmax - *xmin) < 0.1f)) *xmax += 0.1f; + if ((ymin && ymax) && (fabsf(*ymax - *ymin) < 0.1f)) *ymax += 0.1f; /* free memory */ BLI_freelistN(&anim_data); @@ -1621,17 +1621,17 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) /* > 180 degree flip? */ if (fabs(prev->vec[1][1] - bezt->vec[1][1]) >= M_PI) { /* 360 degrees to add/subtract frame value until difference is acceptably small that there's no more flip */ - const double fac = 2.0 * M_PI; + const float fac = 2.0f * (float)M_PI; if (prev->vec[1][1] > bezt->vec[1][1]) { - while (fabs(bezt->vec[1][1] - prev->vec[1][1]) >= M_PI) { + while (fabsf(bezt->vec[1][1] - prev->vec[1][1]) >= (float)M_PI) { bezt->vec[0][1] += fac; bezt->vec[1][1] += fac; bezt->vec[2][1] += fac; } } else /* if (prev->vec[1][1] < bezt->vec[1][1]) */ { - while (fabs(bezt->vec[1][1] - prev->vec[1][1]) >= M_PI) { + while (fabsf(bezt->vec[1][1] - prev->vec[1][1]) >= (float)M_PI) { bezt->vec[0][1] -= fac; bezt->vec[1][1] -= fac; bezt->vec[2][1] -= fac; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 3e028607172..4f2e68bb216 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -205,8 +205,8 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) } /* the fine resolution level */ - blendfac= 0.25*gridsize - floor(0.25f*gridsize); - CLAMP(blendfac, 0.0, 1.0); + blendfac= 0.25f*gridsize - floorf(0.25f*gridsize); + CLAMP(blendfac, 0.0f, 1.0f); UI_ThemeColorShade(TH_BACK, (int)(20.0f*(1.0f-blendfac))); fac= 0.0f; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 56b5ed10c56..c560b68c01b 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -372,7 +372,7 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar= CTX_wm_region(C); float factor; - factor= 1.0 + (event->x-event->prevx+event->y-event->prevy)/300.0f; + factor= 1.0f + (event->x-event->prevx+event->y-event->prevy)/300.0f; RNA_float_set(op->ptr, "factor", factor); sima_zoom_set(sima, ar, sima->zoom*factor); ED_region_tag_redraw(CTX_wm_region(C)); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 1d643ba1a89..451e0e6e89b 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -204,7 +204,7 @@ void ED_image_aspect(Image *ima, float *aspx, float *aspy) *aspx= *aspy= 1.0; if((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) || - (ima->aspx==0.0 || ima->aspy==0.0)) + (ima->aspx==0.0f || ima->aspy==0.0f)) return; /* x is always 1 */ diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 5d3f3314bd9..701b0fc1de7 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -362,7 +362,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm return (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH); } - if (rti->widthfac == 0.0) { + if (rti->widthfac == 0.0f) { /* initialise colors based on report type */ if(report->type & RPT_ERROR_ALL) { rti->col[0] = 1.0; @@ -396,7 +396,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm /* collapse report at end of timeout */ if (progress*timeout > timeout - COLLAPSE_TIMEOUT) { rti->widthfac = (progress*timeout - (timeout - COLLAPSE_TIMEOUT)) / COLLAPSE_TIMEOUT; - rti->widthfac = 1.0 - rti->widthfac; + rti->widthfac = 1.0f - rti->widthfac; send_note= 1; } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 8848d4be76f..e830a421a59 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -255,10 +255,10 @@ static void nla_draw_strip_curves (NlaStrip *strip, float yminc, float ymaxc) } else { /* use blend in/out values only if both aren't zero */ - if ((IS_EQ(strip->blendin, 0.0f) && IS_EQ(strip->blendout, 0.0f))==0) { + if ((IS_EQF(strip->blendin, 0.0f) && IS_EQF(strip->blendout, 0.0f))==0) { glBegin(GL_LINE_STRIP); /* start of strip - if no blendin, start straight at 1, otherwise from 0 to 1 over blendin frames */ - if (IS_EQ(strip->blendin, 0.0f) == 0) { + if (IS_EQF(strip->blendin, 0.0f) == 0) { glVertex2f(strip->start, yminc); glVertex2f(strip->start + strip->blendin, ymaxc); } @@ -266,7 +266,7 @@ static void nla_draw_strip_curves (NlaStrip *strip, float yminc, float ymaxc) glVertex2f(strip->start, ymaxc); /* end of strip */ - if (IS_EQ(strip->blendout, 0.0f) == 0) { + if (IS_EQF(strip->blendout, 0.0f) == 0) { glVertex2f(strip->end - strip->blendout, ymaxc); glVertex2f(strip->end, yminc); } @@ -321,7 +321,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *UNUSED(nlt) /* this only draws after the strip */ case NLASTRIP_EXTEND_HOLD_FORWARD: /* only need to try and draw if the next strip doesn't occur immediately after */ - if ((strip->next == NULL) || (IS_EQ(strip->next->start, strip->end)==0)) { + if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end)==0)) { /* set the drawing color to the color of the strip, but this time less faint */ glColor4f(color[0], color[1], color[2], 0.3f); @@ -378,7 +378,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *UNUSED(nlt) uiDrawBoxShade(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1); /* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */ - if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQ(strip->repeat, 1.0f)==0) { + if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f)==0) { float repeatLen = (strip->actend - strip->actstart) * strip->scale; int i; @@ -403,7 +403,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *UNUSED(nlt) /* draw start-line if not same as end of previous (and only if not the first strip) * - on upper half of strip */ - if ((cs->prev) && IS_EQ(cs->prev->end, cs->start)==0) + if ((cs->prev) && IS_EQF(cs->prev->end, cs->start)==0) fdrawline(cs->start, y, cs->start, ymaxc); /* draw end-line if not the last strip diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index a86f16ee10f..48bdcb88618 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -176,7 +176,7 @@ void boundbox_seq(Scene *scene, rctf *rect) if( min[0] > seq->startdisp-1) min[0]= seq->startdisp-1; if( max[0] < seq->enddisp+1) max[0]= seq->enddisp+1; - if( max[1] < seq->machine+2.0) max[1]= seq->machine+2.0; + if( max[1] < seq->machine+2) max[1]= seq->machine+2; seq= seq->next; } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 9539846df28..6ba047d741a 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1108,7 +1108,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) CLAMP(st->txtbar.ymax, pix_bottom_margin, ar->winy - pix_top_margin); st->pix_per_line= (pix_available > 0)? (float) ltexth/pix_available: 0; - if(st->pix_per_line<.1) st->pix_per_line=.1f; + if(st->pix_per_line < 0.1f) st->pix_per_line=0.1f; curl_off= text_get_span_wrap(st, ar, st->text->lines.first, st->text->curl); sell_off= text_get_span_wrap(st, ar, st->text->lines.first, st->text->sell); diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index a81865fc3b4..705fb83264c 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -157,13 +157,13 @@ void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, fl ctrl= !ctrl; if(ctrl && shift) { - if(fac3!= 0.0) *val= fac3*floor(*val/fac3 +.5); + if(fac3 != 0.0f) *val= fac3*floorf(*val/fac3 +0.5f); } else if(ctrl) { - if(fac2!= 0.0) *val= fac2*floor(*val/fac2 +.5); + if(fac2 != 0.0f) *val= fac2*floorf(*val/fac2 +0.5f); } else { - if(fac1!= 0.0) *val= fac1*floor(*val/fac1 +.5); + if(fac1 != 0.0f) *val= fac1*floorf(*val/fac1 +0.5f); } } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 4d2e205d1a9..4ca73f81965 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -903,10 +903,10 @@ void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin IDProperty *item; item= IDP_GetPropertyTypeFromGroup(idp_ui, "min", IDP_DOUBLE); - *hardmin= item ? IDP_Double(item) : FLT_MIN; + *hardmin= item ? (float)IDP_Double(item) : FLT_MIN; item= IDP_GetPropertyTypeFromGroup(idp_ui, "max", IDP_DOUBLE); - *hardmax= item ? IDP_Double(item) : FLT_MAX; + *hardmax= item ? (float)IDP_Double(item) : FLT_MAX; return; } @@ -934,16 +934,16 @@ void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *soft IDProperty *item; item= IDP_GetPropertyTypeFromGroup(idp_ui, "soft_min", IDP_DOUBLE); - *softmin= item ? IDP_Double(item) : FLT_MIN; + *softmin= item ? (float)IDP_Double(item) : FLT_MIN; item= IDP_GetPropertyTypeFromGroup(idp_ui, "soft_max", IDP_DOUBLE); - *softmax= item ? IDP_Double(item) : FLT_MAX; + *softmax= item ? (float)IDP_Double(item) : FLT_MAX; item= IDP_GetPropertyTypeFromGroup(idp_ui, "step", IDP_DOUBLE); - *step= item ? IDP_Double(item) : 1.0f; + *step= item ? (float)IDP_Double(item) : 1.0f; item= IDP_GetPropertyTypeFromGroup(idp_ui, "precision", IDP_DOUBLE); - *precision= item ? IDP_Double(item) : 3.0f; + *precision= item ? (float)IDP_Double(item) : 3.0f; return; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1622159efcb..a1cfe4a0390 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2665,7 +2665,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) // int hit = 0; if(rc->mode == WM_RADIALCONTROL_STRENGTH) - rc->tex_col[3]= (rc->value + 0.5); + rc->tex_col[3]= (rc->value + 0.5f); if(rc->mode == WM_RADIALCONTROL_SIZE) { r1= rc->value; @@ -2836,7 +2836,7 @@ int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) rc->max_value = 360; mouse[0]-= WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(initial_value); mouse[1]-= WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(initial_value); - initial_value *= 180.0f/M_PI; + initial_value *= 180.0f/(float)M_PI; } if(op->customdata) { @@ -2884,7 +2884,7 @@ void WM_radial_control_string(wmOperator *op, char str[], int maxlen) else if(mode == WM_RADIALCONTROL_STRENGTH) BLI_snprintf(str, maxlen, "Strength: %d", (int)v); else if(mode == WM_RADIALCONTROL_ANGLE) - BLI_snprintf(str, maxlen, "Angle: %d", (int)(v * 180.0f/M_PI)); + BLI_snprintf(str, maxlen, "Angle: %d", (int)(v * 180.0f/(float)M_PI)); } /** Important: this doesn't define an actual operator, it diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 1117d296f94..a87001fb1b4 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -143,7 +143,7 @@ void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4]) int width, height; wm_subwindow_getsize(win, swin->swinid, &width, &height); - orthographic_m4(mat, -0.375, (float)width-0.375, -0.375, (float)height-0.375, -100, 100); + orthographic_m4(mat, -0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f, -100, 100); } else glGetFloatv(GL_PROJECTION_MATRIX, (float*)mat); @@ -174,7 +174,7 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct) /* extra service */ wm_subwindow_getsize(win, swin->swinid, &width, &height); - wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375); + wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); glLoadIdentity(); return swin->swinid; @@ -229,7 +229,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) /* extra service */ wmSubWindowSet(win, swinid); wm_subwindow_getsize(win, swinid, &width, &height); - wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375); + wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); } else { printf("wm_subwindow_position: Internal error, bad winid: %d\n", swinid); @@ -268,7 +268,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct) else glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); - wmOrtho2(-0.375, (float)width-0.375, -0.375, (float)height-0.375); + wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); glLoadIdentity(); glFlush(); @@ -302,8 +302,8 @@ void wmOrtho(float x1, float x2, float y1, float y2, float n, float f) void wmOrtho2(float x1, float x2, float y1, float y2) { /* prevent opengl from generating errors */ - if(x1==x2) x2+=1.0; - if(y1==y2) y2+=1.0; + if(x1==x2) x2+=1.0f; + if(y1==y2) y2+=1.0f; wmOrtho(x1, x2, y1, y2, -100, 100); } From 45f9dd4bd9688a0b664a401d2cf8d7fb1d7d343a Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 27 Mar 2011 17:57:14 +0000 Subject: [PATCH 135/261] COLLADA lamp blender profile: add the remainder of the lamp variables to export. --- source/blender/collada/LightExporter.cpp | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index b4afaa4cc26..d267ee530fb 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -176,6 +176,31 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la) cla.addExtraTechniqueParameter("blender", "filtertype", la->filtertype); cla.addExtraTechniqueParameter("blender", "bufflag", la->bufflag); cla.addExtraTechniqueParameter("blender", "buftype", la->buftype); + cla.addExtraTechniqueParameter("blender", "ray_samp", la->ray_samp); + cla.addExtraTechniqueParameter("blender", "ray_sampy", la->ray_sampy); + cla.addExtraTechniqueParameter("blender", "ray_sampz", la->ray_sampz); + cla.addExtraTechniqueParameter("blender", "ray_samp_type", la->ray_samp_type); + cla.addExtraTechniqueParameter("blender", "area_shape", la->area_shape); + cla.addExtraTechniqueParameter("blender", "area_size", la->area_size); + cla.addExtraTechniqueParameter("blender", "area_sizey", la->area_sizey); + cla.addExtraTechniqueParameter("blender", "area_sizez", la->area_sizez); + cla.addExtraTechniqueParameter("blender", "adapt_thresh", la->adapt_thresh); + cla.addExtraTechniqueParameter("blender", "ray_samp_method", la->ray_samp_method); + cla.addExtraTechniqueParameter("blender", "shadhalostep", la->shadhalostep); + cla.addExtraTechniqueParameter("blender", "sun_effect_type", la->shadhalostep); + cla.addExtraTechniqueParameter("blender", "skyblendtype", la->skyblendtype); + cla.addExtraTechniqueParameter("blender", "horizon_brightness", la->horizon_brightness); + cla.addExtraTechniqueParameter("blender", "spread", la->spread); + cla.addExtraTechniqueParameter("blender", "sun_brightness", la->sun_brightness); + cla.addExtraTechniqueParameter("blender", "sun_size", la->sun_size); + cla.addExtraTechniqueParameter("blender", "backscattered_light", la->backscattered_light); + cla.addExtraTechniqueParameter("blender", "sun_intensity", la->sun_intensity); + cla.addExtraTechniqueParameter("blender", "atm_turbidity", la->atm_turbidity); + cla.addExtraTechniqueParameter("blender", "atm_extinction_factor", la->atm_extinction_factor); + cla.addExtraTechniqueParameter("blender", "atm_distance_factor", la->atm_distance_factor); + cla.addExtraTechniqueParameter("blender", "skyblendfac", la->skyblendfac); + cla.addExtraTechniqueParameter("blender", "sky_exposure", la->sky_exposure); + cla.addExtraTechniqueParameter("blender", "sky_colorspace", la->sky_colorspace); return true; } From 3598882f0ef630aac8c4810f04b28ab1ae64bd0d Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 27 Mar 2011 20:52:50 +0000 Subject: [PATCH 136/261] Proper traceback when addons fails AST parsing setp --- release/scripts/modules/addon_utils.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index d2001087f13..62a9f691acf 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -97,10 +97,17 @@ def modules(module_cache): break if body_info: - mod = ModuleType(mod_name) - mod.bl_info = ast.literal_eval(body.value) - mod.__file__ = mod_path - mod.__time__ = os.path.getmtime(mod_path) + try: + mod = ModuleType(mod_name) + mod.bl_info = ast.literal_eval(body.value) + mod.__file__ = mod_path + mod.__time__ = os.path.getmtime(mod_path) + except: + print("AST error in module %s" % mod_name) + import traceback + traceback.print_exc() + raise + return mod else: return None From 47f9b496b130776220f53a33c2a7fad8ea7eb960 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 27 Mar 2011 21:45:37 +0000 Subject: [PATCH 137/261] [#24658] Switching to "maya" via interaction preset breaks when switching back [#25045] User Preferences Input, not enough menu choices [#26525] Saving the Maya preset and another key configs Untangle keyconfig presets and interaction presets (maya keyconfig would set interaction setting, blender interaction would set keyconfig). Preset menu on slash screen now displays a list of available keyconfigs (as before) but will also set the correspondant interaction presets, if it exists) --- .../scripts/presets/interaction/blender.py | 3 -- release/scripts/presets/interaction/maya.py | 10 ++++++ release/scripts/presets/keyconfig/maya.py | 8 ----- release/scripts/startup/bl_operators/wm.py | 32 +++++++++++++++++++ .../scripts/startup/bl_ui/space_userpref.py | 12 ++++++- 5 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 release/scripts/presets/interaction/maya.py diff --git a/release/scripts/presets/interaction/blender.py b/release/scripts/presets/interaction/blender.py index 7ac9cd1eb0b..603158ed936 100644 --- a/release/scripts/presets/interaction/blender.py +++ b/release/scripts/presets/interaction/blender.py @@ -1,9 +1,6 @@ # Configuration Blender import bpy -wm = bpy.context.window_manager -wm.keyconfigs.active = wm.keyconfigs['Blender'] - bpy.context.user_preferences.view.use_mouse_auto_depth = False bpy.context.user_preferences.view.use_zoom_to_mouse = False bpy.context.user_preferences.view.use_rotate_around_active = False diff --git a/release/scripts/presets/interaction/maya.py b/release/scripts/presets/interaction/maya.py new file mode 100644 index 00000000000..4b4bb3c4f0a --- /dev/null +++ b/release/scripts/presets/interaction/maya.py @@ -0,0 +1,10 @@ +# Configuration Blender +import bpy + +bpy.context.user_preferences.edit.use_drag_immediately = True +bpy.context.user_preferences.edit.use_insertkey_xyz_to_rgb = False +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 diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index 4014920698d..87f4791ec51 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -376,11 +376,3 @@ kmi = km.keymap_items.new('mesh.select_all', 'SELECTMOUSE', 'CLICK') kmi.properties.action = 'DESELECT' wm.keyconfigs.active = kc - -bpy.context.user_preferences.edit.use_drag_immediately = True -bpy.context.user_preferences.edit.use_insertkey_xyz_to_rgb = False -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 diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index bb5f3a3a2a9..6ed46191099 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -859,6 +859,38 @@ 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" + + def execute(self, context): + import os + + context.window_manager.keyconfigs.active = context.window_manager.keyconfigs.default + + 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") + + return {'FINISHED'} + +class WM_OT_appconfig_activate(bpy.types.Operator): + bl_idname = "wm.appconfig_activate" + bl_label = "Activate Application Configuration" + + filepath = StringProperty(name="File Path", maxlen=1024) + + 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") + + return {'FINISHED'} class WM_OT_sysinfo(bpy.types.Operator): '''Generate System Info''' diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 67174db1d3d..59d9aef12f2 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -119,6 +119,16 @@ 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" + preset_operator = "wm.appconfig_activate" + + def draw(self, context): + props = self.layout.operator("wm.appconfig_default", text="Blender (default)") + + # now draw the presets + bpy.types.Menu.draw_preset(self, context) class USERPREF_MT_splash(bpy.types.Menu): bl_label = "Splash" @@ -134,7 +144,7 @@ class USERPREF_MT_splash(bpy.types.Menu): # text = bpy.path.display_name(context.window_manager.keyconfigs.active.name) # if not text: # text = "Blender (default)" - row.menu("USERPREF_MT_keyconfigs", text="Preset") + row.menu("USERPREF_MT_appconfigs", text="Preset") class USERPREF_PT_interface(bpy.types.Panel): From 3c67374f50ef5da6745ca78eaf3b6b20e658383a Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 27 Mar 2011 22:02:54 +0000 Subject: [PATCH 138/261] Revert r34026, which in it turn reverted r33039. Removal breaks renderers that use COLLADA as their format through render() callback. --- source/blender/makesrna/SConscript | 3 +++ source/blender/makesrna/intern/CMakeLists.txt | 4 ++++ source/blender/makesrna/intern/SConscript | 3 +++ .../blender/makesrna/intern/rna_scene_api.c | 21 +++++++++++++++++++ .../bad_level_call_stubs/stubs.c | 3 +++ 5 files changed, 34 insertions(+) diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index c116659e4d8..e89003a60c2 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -54,6 +54,9 @@ if env['BF_UNIT_TEST']: if env['WITH_BF_PYTHON']: defs.append('WITH_PYTHON') +if env['WITH_BF_COLLADA']: + defs.append('WITH_COLLADA') + if env['OURPLATFORM'] == 'linux2': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index cc8b3f20c9b..70490e48add 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -125,6 +125,10 @@ if(WITH_JACK) add_definitions(-DWITH_JACK) endif() +if(WITH_OPENCOLLADA) + add_definitions(-DWITH_COLLADA) +endif() + # Build makesrna executable blender_include_dirs( . diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index cacbaccfc0e..5a20a2257a8 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -88,6 +88,9 @@ if env['BF_UNIT_TEST']: if env['WITH_BF_PYTHON']: defs.append('WITH_PYTHON') +if env['WITH_BF_COLLADA']: + defs.append('WITH_COLLADA') + if env['OURPLATFORM'] == 'linux2': cflags='-pthread' incs += ' ../../../extern/binreloc/include' diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 61715727b7d..c2194636cd3 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -81,6 +81,17 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name BKE_makepicstring(name, rd->pic, (frame==INT_MIN) ? rd->cfra : frame, rd->imtype, rd->scemode & R_EXTENSION, TRUE); } +#ifdef WITH_COLLADA +/* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ +#include "../../collada/collada.h" + +static void rna_Scene_collada_export(Scene *scene, const char *filepath) +{ + collada_export(scene, filepath); +} + +#endif + #else void RNA_api_scene(StructRNA *srna) @@ -96,8 +107,18 @@ void RNA_api_scene(StructRNA *srna) func= RNA_def_function(srna, "update", "rna_Scene_update_tagged"); RNA_def_function_ui_description(func, "Update data tagged to be updated from previous access to data or operators."); + +#ifdef WITH_COLLADA + /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ + func= RNA_def_function(srna, "collada_export", "rna_Scene_collada_export"); + parm= RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file."); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */ + RNA_def_function_ui_description(func, "Export to collada file."); +#endif } + void RNA_api_scene_render(StructRNA *srna) { FunctionRNA *func; diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 292e9ddd1ff..4ad8d588ae4 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -388,6 +388,9 @@ char *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct struct wmKeyMapItem *WM_modalkeymap_add_item(struct wmKeyMap *km, int type, int val, int modifier, int keymodifier, int value){return (struct wmKeyMapItem *)NULL;} struct wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, char *idname, EnumPropertyItem *items){return (struct wmKeyMap *) NULL;} +/* RNA COLLADA dependency */ +int collada_export(struct Scene *sce, const char *filepath){ return 0; } + int sculpt_get_brush_size(struct Brush *brush) {return 0;} void sculpt_set_brush_size(struct Brush *brush, int size) {} int sculpt_get_lock_brush_size(struct Brush *brush){ return 0;} From 84befe2056a8ae03d38ab539b26f1638bdcbd41c Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 27 Mar 2011 22:15:37 +0000 Subject: [PATCH 139/261] [#26622] Blender crashes when calling transform operator Add cancellation checks for time* transforms that only run in specific spaces. Hide Transform Mode operator property (it shouldn't be modified after the operator is run), made default mode Translate, not the useless Dummy. --- source/blender/editors/transform/transform.c | 25 +++++++++++++++---- .../blender/editors/transform/transform_ops.c | 5 +++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 0a055358902..3ec7e6eec2c 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1650,11 +1650,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); @@ -1709,6 +1704,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")) { @@ -5515,6 +5517,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 +5670,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; @@ -5789,6 +5799,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_ops.c b/source/blender/editors/transform/transform_ops.c index c31722d97cb..9a78a05dba9 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -755,6 +755,8 @@ void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot) void TRANSFORM_OT_transform(struct wmOperatorType *ot) { + PropertyRNA *prop; + static EnumPropertyItem transform_mode_types[] = { {TFM_INIT, "INIT", 0, "Init", ""}, {TFM_DUMMY, "DUMMY", 0, "Dummy", ""}, @@ -800,7 +802,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); From 89c2357892458be0c47eef0e43b81cb81e8cf2fa Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 27 Mar 2011 23:19:32 +0000 Subject: [PATCH 140/261] Bugfix: One more place still using the old "keys" instead of "key_blocks" --- source/blender/makesrna/intern/rna_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 48cab3b13d1..a7317d18df1 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -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); } From e567feab64d85304c4c6a9b6b0ec81b32de61b88 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 02:09:10 +0000 Subject: [PATCH 141/261] uvedit: floats were being implicitly promoted to doubles, adjust to use floats. --- source/blender/editors/uvedit/uvedit_ops.c | 22 ++--- .../editors/uvedit/uvedit_parametrizer.c | 82 +++++++++---------- .../editors/uvedit/uvedit_unwrap_ops.c | 38 ++++----- 3 files changed, 71 insertions(+), 71 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 252f9c66266..462bdda5e32 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) @@ -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) @@ -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); } @@ -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; 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; } From cf40220e54e32cf52931e461b928f26571fc2f4f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 02:11:51 +0000 Subject: [PATCH 142/261] set CMake's GCC warnings for GCC4.6. -Wdouble-promotion -Wno-error=double-promotion -Wno-error=unused-but-set-variable --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81263095bf8..15a5071accc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1053,12 +1053,14 @@ 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) + 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) From ac1cb5ee055840ba3481b8ad490e3be2a6a49cf2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 02:34:55 +0000 Subject: [PATCH 143/261] - quiet new warnings with gcc 4.6 - use BLI math funcs for normal float/short conversion. - correct some un-intentional float/double promotions. --- .../blender/blenkernel/intern/DerivedMesh.c | 8 +-- .../blender/blenkernel/intern/cdderivedmesh.c | 4 +- source/blender/blenkernel/intern/exotic.c | 8 +-- source/blender/blenkernel/intern/mesh.c | 4 +- source/blender/editors/gpencil/drawgpencil.c | 7 ++- source/blender/editors/interface/interface.c | 8 +-- .../editors/interface/interface_handlers.c | 18 +++--- .../editors/interface/interface_panel.c | 2 +- .../editors/interface/interface_templates.c | 10 +-- .../editors/interface/interface_widgets.c | 8 +-- source/blender/editors/mesh/editface.c | 2 +- source/blender/editors/mesh/editmesh.c | 28 ++++----- source/blender/editors/mesh/editmesh_add.c | 8 +-- source/blender/editors/mesh/editmesh_lib.c | 36 +++++------ source/blender/editors/mesh/editmesh_mods.c | 62 +++++++++---------- source/blender/editors/mesh/editmesh_tools.c | 30 +++++---- .../editors/space_graph/graph_buttons.c | 6 +- .../editors/space_view3d/view3d_buttons.c | 5 +- .../blender/editors/space_view3d/view3d_fly.c | 8 ++- source/blender/makesrna/intern/rna_key.c | 2 +- source/blender/makesrna/intern/rna_lamp.c | 6 +- source/blender/makesrna/intern/rna_nla.c | 2 +- source/blender/makesrna/intern/rna_particle.c | 2 +- source/blender/makesrna/intern/rna_rna.c | 4 +- source/blender/makesrna/intern/rna_wm.c | 8 +-- 25 files changed, 136 insertions(+), 150 deletions(-) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index b0a1e74c30f..40365a2198f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2570,11 +2570,9 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const } else { - int i=0; - short * no = pMesh->mvert[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/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/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/mesh.c b/source/blender/blenkernel/intern/mesh.c index bc3e6b4c4dd..66e9d09fb7e 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -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; diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 276f60bdf7f..a0a815befba 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -516,7 +516,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 +542,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); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 93537928c92..afee8416239 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1913,7 +1913,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 +1967,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,8 +1989,8 @@ 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)]; 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_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_templates.c b/source/blender/editors/interface/interface_templates.c index 2f442d930de..42b6926e847 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_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/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..bd094211270 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -1099,9 +1099,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 +1226,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; ano[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'; } @@ -2367,7 +2367,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/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_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 4277a7e85e3..b404a7be27c 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1214,7 +1214,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 +1222,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_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/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index a7317d18df1..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) { 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_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_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_wm.c b/source/blender/makesrna/intern/rna_wm.c index 0d1463428bb..ea26663df44 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; From dd56ebe6076d7ffbe9dd698a5c1bc94fff6ff306 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 04:22:50 +0000 Subject: [PATCH 144/261] blenkernel: floats were being implicitly promoted to doubles, adjust to use floats. --- source/blender/blenkernel/intern/armature.c | 18 +-- source/blender/blenkernel/intern/brush.c | 20 +-- source/blender/blenkernel/intern/bvhutils.c | 20 +-- source/blender/blenkernel/intern/colortools.c | 20 +-- source/blender/blenkernel/intern/curve.c | 126 +++++++++--------- source/blender/blenkernel/intern/displist.c | 16 +-- source/blender/blenkernel/intern/fcurve.c | 28 ++-- source/blender/blenkernel/intern/image_gen.c | 4 +- source/blender/blenkernel/intern/key.c | 26 ++-- source/blender/blenkernel/intern/material.c | 12 +- source/blender/blenkernel/intern/mball.c | 52 ++++---- source/blender/blenkernel/intern/mesh.c | 8 +- source/blender/blenkernel/intern/nla.c | 43 +++--- source/blender/blenkernel/intern/texture.c | 14 +- 14 files changed, 203 insertions(+), 204 deletions(-) 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/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/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/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/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/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/material.c b/source/blender/blenkernel/intern/material.c index b5b872ebf01..3ca5cdb9bb1 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1006,9 +1006,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]); @@ -1174,10 +1174,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 66e9d09fb7e..6f528ec3ea8 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); @@ -1433,7 +1433,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/texture.c b/source/blender/blenkernel/intern/texture.c index c0261d3b5a3..e8c4a21d041 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); @@ -373,10 +373,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 { From 412eed6a2753bfdeaf158dd2f82e4ba070f2c254 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 04:55:24 +0000 Subject: [PATCH 145/261] RNA functions for adding timer (needed for demo mode, also useful for python modal operators). - timer = WindowManager.event_timer_add(time_step, window=None) - WindowManager.event_timer_remove(timer) Still TODO, is a way for python to check the timer identity. --- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_wm.c | 31 +++++++++++++++++++++ source/blender/makesrna/intern/rna_wm_api.c | 27 ++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index e67728def11..2816a8717c1 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -532,6 +532,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/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index ea26663df44..df029c9d871 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -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..ab2775b7184 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) +{ + return 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."); From fd72840587bacbb3e5d6964e19c9359e0dd293e9 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Mon, 28 Mar 2011 05:37:25 +0000 Subject: [PATCH 146/261] Add stubs for the new timer add and remove functions. --- source/blenderplayer/bad_level_call_stubs/stubs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 4ad8d588ae4..c1581e1f8f3 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -160,7 +160,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){} From 72b4bf2fda227ede4f6308f7171c4a74c22f02b8 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 28 Mar 2011 08:08:59 +0000 Subject: [PATCH 147/261] Bug fix: particles emitted from a moving emitter exploded with verlet integration * Verlet integration didn't like moving emitters, so now the first step for newborn particles with verlet is actually done with euler integration. --- source/blender/blenkernel/intern/particle_system.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 088ab78ce47..19d4ed598ee 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -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); From e5bf21898ea7fdc9d13b4f046fcbcf16064c6df4 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 28 Mar 2011 08:27:19 +0000 Subject: [PATCH 148/261] Fix for [#26617] convert hair particles to mesh crash rev:35787 * Hair to mesh conversion wasn't making sure the hairs had valid keys * Patch by Sergey Sharybin --- source/blender/editors/object/object_modifier.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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; From bd9854e7d1dee9b59ccab146c43db542e4873171 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Mon, 28 Mar 2011 09:31:44 +0000 Subject: [PATCH 149/261] Import light blender profile if it exists. --- source/blender/collada/DocumentImporter.cpp | 69 ++++++++++++++++++-- source/blender/collada/DocumentImporter.h | 6 +- source/blender/collada/ExtraHandler.cpp | 5 +- source/blender/collada/ExtraTags.cpp | 72 ++++++++++++++++++++- source/blender/collada/ExtraTags.h | 25 ++++++- 5 files changed, 164 insertions(+), 13 deletions(-) diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index b0bbe49a182..ce6f4777e9a 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; @@ -867,6 +867,12 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) 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()); @@ -954,6 +960,61 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) } break; } + + if(et) { + et->setData("type", &(lamp->type)); + et->setData("flag", &(lamp->flag)); + et->setData("mode", &(lamp->mode)); + et->setData("gamma", &(lamp->k)); + 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)); + } this->uid_lamp_map[light->getUniqueId()] = lamp; return true; @@ -1007,15 +1068,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..57305d1ae79 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -33,18 +33,84 @@ #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::addTag( std::string tag, std::string data) { - std::cout << "ready to add " << tag << ": " << data << "." << std::endl; + 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; +} + \ No newline at end of file diff --git a/source/blender/collada/ExtraTags.h b/source/blender/collada/ExtraTags.h index 09a86741481..5c31a5a95db 100644 --- a/source/blender/collada/ExtraTags.h +++ b/source/blender/collada/ExtraTags.h @@ -42,7 +42,19 @@ 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); private: /** Disable default copy constructor. */ @@ -50,5 +62,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); }; From 76ad75b1bb7099e414a4991c2ecaf54dab87ac92 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 11:01:24 +0000 Subject: [PATCH 150/261] Crouch on IRC noticed inconsistency between name COLOR_SETS & attribute bone_color_sets --- release/scripts/startup/bl_ui/space_userpref.py | 2 +- source/blender/makesrna/intern/rna_userdef.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 59d9aef12f2..69fe7c3d948 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -647,7 +647,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/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", ""}, From fee4cc34ccf7b74ccaa3eba3cc9972f5d9f41da4 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Mon, 28 Mar 2011 11:04:38 +0000 Subject: [PATCH 151/261] Add missing header for *nix machines. --- source/blender/collada/ExtraTags.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index 57305d1ae79..95edd85af42 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -27,6 +27,7 @@ */ #include +#include #include "BLI_string.h" #include From ca383667327683e99cb9ca36f6cac3b82e25d674 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 11:21:39 +0000 Subject: [PATCH 152/261] particles & vector-font: floats were being implicitly promoted to doubles, adjust to use floats. --- source/blender/blenkernel/BKE_curve.h | 2 +- source/blender/blenkernel/intern/font.c | 46 ++++++------- source/blender/blenkernel/intern/particle.c | 66 +++++++++---------- .../blenkernel/intern/particle_system.c | 54 +++++++-------- 4 files changed, 84 insertions(+), 84 deletions(-) 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/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/particle.c b/source/blender/blenkernel/intern/particle.c index f937d7265aa..5c1c8eae622 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; @@ -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); @@ -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 19d4ed598ee..649a6fa90a0 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/sqrt((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); @@ -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); } /************************************************/ @@ -2516,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; @@ -2559,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); @@ -2599,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{ @@ -3093,8 +3093,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); @@ -3141,7 +3141,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); @@ -3329,7 +3329,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); } } @@ -3582,11 +3582,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); @@ -3641,7 +3641,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; @@ -3785,7 +3785,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); @@ -4310,7 +4310,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); From 713f976918d2ed00fb088430d2e417d7d055b693 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 28 Mar 2011 12:16:20 +0000 Subject: [PATCH 153/261] Bugfix, irc report: Entering editmode crashed, missing v3d properties storage, which got accidentally removed. --- source/blender/editors/space_view3d/view3d_buttons.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index b404a7be27c..cd6f8954430 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); From 3916b0270e7aeff4bd0861aa4bb76f40633b606a Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Mon, 28 Mar 2011 13:44:56 +0000 Subject: [PATCH 154/261] Address [#26641] Texture Quick Edit kicks up error when Editor can't be found reported by Keith Boshoff (Wahooney) Instead of a confusing backtrace popup, tell the user the image editor cannot be found, and where to set the path to it. --- release/scripts/startup/bl_operators/image.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 82e631e31d2..65e0d5a52db 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'} @@ -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'} From bf1e2ce41ebf3dab1647d28588f951b5e587aa3e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 13:47:39 +0000 Subject: [PATCH 155/261] color gamma (such as theme colors), were not being wrapped by python as 'mathutils.Color' types --- source/blender/python/intern/bpy_rna.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ecf66ca4700..9a459063d42 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -640,6 +640,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 From d766111632014f346827ccd15a6741b3e898842e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 13:53:53 +0000 Subject: [PATCH 156/261] example operator that uses a timer. --- .../scripts/templates/operator_modal_timer.py | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 release/scripts/templates/operator_modal_timer.py diff --git a/release/scripts/templates/operator_modal_timer.py b/release/scripts/templates/operator_modal_timer.py new file mode 100644 index 00000000000..d8c218f67ea --- /dev/null +++ b/release/scripts/templates/operator_modal_timer.py @@ -0,0 +1,46 @@ +import bpy +from bpy.props import IntProperty, FloatProperty + + +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() From 859d22467d406d8be9269035e271bd9ad7c935b4 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Mon, 28 Mar 2011 15:01:19 +0000 Subject: [PATCH 157/261] 2.5 3D View Properties UI: Show text "Nothing selected" in "Transform" panel (edit mode) rather than only the empty panel. --- source/blender/editors/space_view3d/view3d_buttons.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index cd6f8954430..549a547b846 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -277,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; From faf07c3e2b6cb180d1580b4160ff6534b4754b76 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 17:06:15 +0000 Subject: [PATCH 158/261] transform: floats were being implicitly promoted to doubles, adjust to use floats. also use macros RAD2DEGF & DEG2RADF. --- source/blender/editors/transform/transform.c | 64 +++++++++---------- .../editors/transform/transform_constraints.c | 14 ++-- .../editors/transform/transform_conversions.c | 14 ++-- .../editors/transform/transform_input.c | 2 +- .../editors/transform/transform_manipulator.c | 26 ++++---- .../editors/transform/transform_snap.c | 18 +++--- 6 files changed, 69 insertions(+), 69 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 3ec7e6eec2c..f1f49a6d88b 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1272,7 +1272,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) glEnd(); glTranslatef(mval[0], mval[1], 0); - glRotatef(-180 / M_PI * atan2f(cent[0] - t->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); @@ -1306,8 +1306,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); @@ -1326,14 +1326,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); @@ -1921,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; } @@ -2237,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; @@ -2261,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 */ } @@ -2325,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; @@ -3180,16 +3180,16 @@ int Rotation(TransInfo *t, short UNUSED(mval[2])) 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.0f) + final -= 360.0f; - while (final <= -180.0) - final += 360.0; - - final *= (float)(M_PI / 180.0); + while (final <= -180.0f) + final += 360.0f; + + final = 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)) @@ -3289,11 +3289,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]); @@ -3382,7 +3382,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); @@ -3648,10 +3648,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++) { @@ -4639,7 +4639,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]; @@ -4923,8 +4923,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) { @@ -5047,10 +5047,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 */ @@ -5358,8 +5358,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); @@ -5781,7 +5781,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]); 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_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); } } From 9b9c4184c88c49ff96f3f23cbfbd00f6811d7301 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 28 Mar 2011 17:08:33 +0000 Subject: [PATCH 159/261] misc nodes & editors: floats were being implicitly promoted to doubles, adjust to use floats. + minor update to demo_mode --- intern/mikktspace/mikktspace.c | 2 +- .../blender/editors/armature/meshlaplacian.c | 20 ++++++------- .../blender/editors/physics/particle_edit.c | 6 ++-- .../blender/editors/render/render_internal.c | 6 ++-- source/blender/editors/screen/screen_ops.c | 2 +- source/blender/editors/space_info/info_ops.c | 16 +++++----- source/blender/editors/space_node/node_edit.c | 2 +- .../nodes/intern/SHD_nodes/SHD_hueSatVal.c | 4 +-- .../nodes/intern/SHD_nodes/SHD_invert.c | 2 +- .../nodes/intern/TEX_nodes/TEX_checker.c | 6 ++-- .../nodes/intern/TEX_nodes/TEX_hueSatVal.c | 6 ++-- .../blender/nodes/intern/TEX_nodes/TEX_math.c | 4 +-- .../nodes/intern/TEX_nodes/TEX_rotate.c | 4 +-- .../blender/python/generic/mathutils_Vector.c | 30 +++++++++---------- 14 files changed, 55 insertions(+), 55 deletions(-) diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c index 8ccb19e35e6..e997bafde25 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 || 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/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/render/render_internal.c b/source/blender/editors/render/render_internal.c index 956618eb1bb..39def19aa17 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; x1= (char *)(ibuf->rect)) { for(x1= 0; x1flag & 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) { 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_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/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_checker.c b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c index b2da0d60570..305d7094f57 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_checker.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_checker.c @@ -53,9 +53,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_hueSatVal.c b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c index 52e88cbc2d9..70c5d25e1eb 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c @@ -54,11 +54,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_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c index a84573f1d09..1652ba10e48 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c @@ -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_rotate.c b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c index c31fc25bea2..8f7793ddaaf 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_rotate.c @@ -53,8 +53,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/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 */ From b2ac8ff1e16235ceedb52a65abebf30ff15e21fc Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 28 Mar 2011 18:51:27 +0000 Subject: [PATCH 160/261] Maintenance: Gave the report-timer (in top header) an own TIMER define, to not confuse with timers in use for UI. Easier for debugging. :) Also gave better malloc names to regions in 3d window. All this for testing proper buffer drawing in Intel cards... which is still unsolved. --- source/blender/editors/space_info/space_info.c | 2 +- source/blender/editors/space_view3d/space_view3d.c | 10 +++++----- .../blender/windowmanager/intern/wm_event_system.c | 2 +- source/blender/windowmanager/wm_event_types.h | 13 ++++++++----- 4 files changed, 15 insertions(+), 12 deletions(-) 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_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/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 8dcd3fa34d1..b52e8e92f22 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; 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) From 1c88199a71d7184483a04a44210cfdb83b7ff442 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 28 Mar 2011 18:56:43 +0000 Subject: [PATCH 161/261] "Error totblock" renamed into "Error: Not freed memory blocks" --- source/blender/windowmanager/intern/wm_init_exit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 5f5ec9ec3cdff0fe7b0c3e3c2df791677ab053ec Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Mon, 28 Mar 2011 21:30:41 +0000 Subject: [PATCH 162/261] SVN maintenance. --- release/scripts/presets/interaction/maya.py | 2 +- source/blender/collada/ExtraTags.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index 95edd85af42..ce72085fe41 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -114,4 +114,4 @@ void ExtraTags::setData(std::string tag, char *data) if(ok) *data = (char)tmp; } - \ No newline at end of file + From e72c278f47d27aef76dc6ca976bfcba668dce260 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 01:47:03 +0000 Subject: [PATCH 163/261] 2 fixes for un-initialized memory uses, when running testfile: teapot_envmap.blend boxsample() expected talpha to be set beforehand, also dont set the int value as a float since its confusing. --- source/blender/nodes/intern/TEX_nodes/TEX_output.c | 2 +- source/blender/render/intern/source/envmap.c | 1 + source/blender/render/intern/source/imagetexture.c | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c index 63a3a7ae15c..30b5aee7832 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c @@ -65,7 +65,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/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..e5afc492c61 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -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; @@ -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; From 6e5ce953da2e7d6e85df7cfd8d6bffd00b740575 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 04:16:55 +0000 Subject: [PATCH 164/261] use 'is None' rather then '== None' as suggested by python docs & mis-spelling. --- intern/mikktspace/mikktspace.c | 2 +- release/scripts/modules/bpy/utils.py | 2 +- .../startup/bl_ui/properties_particle.py | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/intern/mikktspace/mikktspace.c b/intern/mikktspace/mikktspace.c index e997bafde25..c05ada84773 100644 --- a/intern/mikktspace/mikktspace.c +++ b/intern/mikktspace/mikktspace.c @@ -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/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index a8f5925f467..cb2349eab1d 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 diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 9c678bd96b2..be581d0dc31 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 @@ -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 @@ -1143,7 +1143,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) From 887a61897e722aeca0b445da3e569af3bf626f38 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 05:10:36 +0000 Subject: [PATCH 165/261] use RNA_warning() rather then printf() so we get the python line number. --- source/blender/makesrna/intern/rna_ui_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From 9fc6256c66708d0b368fb65203a89fd1c852b4a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 05:49:34 +0000 Subject: [PATCH 166/261] add rna read-only width/height for screen areas. --- source/blender/makesrna/intern/rna_screen.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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"); From 0f7f20325752d2e2ec7dd07c8545ca9d685b7e49 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 29 Mar 2011 09:28:46 +0000 Subject: [PATCH 167/261] Bugfix [#26650] Reset to Default Theme doesn't reset Bone Color Sets Bone Color Sets weren't set in the call used here. This seems to be a newish operator that didn't exist in the past, so this error didn't really show up in the past. --- source/blender/editors/interface/resources.c | 147 ++++++++++--------- 1 file changed, 81 insertions(+), 66 deletions(-) diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index d272b03fc22..ef9da932dd8 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,10 @@ void ui_theme_init_default(void) /* UI buttons */ ui_widget_color_init(&btheme->tui); - + + /* Bone Color Sets */ + ui_theme_init_boneColorSets(btheme); + /* common (new) variables */ ui_theme_init_new(btheme); @@ -1216,69 +1292,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)) { From dbd13d67b1aa03a08d02e686d0d2b542d38abb50 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 29 Mar 2011 09:37:53 +0000 Subject: [PATCH 168/261] Bugfix [#26645] Crash when duplicating an object with driver Missing null check for "improper" driver variables. ------ Also, this commit includes some WIP NLA evaluation reshuffling which should be harmless. I had originally intended this for a later commit... --- source/blender/blenkernel/intern/anim_sys.c | 55 ++++++++++++++------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 6e933ddd386..1c6221eba8b 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -282,23 +282,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; } } @@ -1839,23 +1847,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) +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')... */ @@ -1930,13 +1934,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); } @@ -2030,7 +2051,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) From 7a252d982411c0bf7055d7295a01bdb24d8a80ef Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 29 Mar 2011 10:27:31 +0000 Subject: [PATCH 169/261] Fix for [#26658] Permeable colliders stop particles * Forgot this exception from the collisions rewrite. Don't check collisions with the same face twice. --- source/blender/blenkernel/BKE_particle.h | 5 +++-- source/blender/blenkernel/intern/particle_system.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) 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/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 649a6fa90a0..2fe7f42abe3 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2989,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 { From aa2269e065b2f3fd3e6da97103843e6ccb2cf18a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 11:50:37 +0000 Subject: [PATCH 170/261] remove DEBUG flag from OpenNL with cmake, was giving too many prints in the console when unwrapping. --- build_files/cmake/macros.cmake | 14 +++++++------- intern/opennl/CMakeLists.txt | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 073147266bb..4a9c55d81cd 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) 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 From e4ef822ecdb1e642012c19fa82cf5a2f796ee0f3 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 29 Mar 2011 12:10:41 +0000 Subject: [PATCH 171/261] build target was changing into wrong directory. --- build_files/scons/tools/btools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 17ee80e6dbd..69bb42264e5 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -611,7 +611,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") From 74e044065b35e5444871f8f5836b221144588082 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 29 Mar 2011 12:50:43 +0000 Subject: [PATCH 172/261] Fix for [#26665] Force field absorption does not work * Old bug fix led to all kinds of wrong behavior with "plane" shaped effectors, now things are working properly again. --- source/blender/blenkernel/intern/effect.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 216dffc1e4a..9cca5ae4982 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -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]); From e4e78d475457ad86f5f29a0ccbd0090c2ba6b1d6 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 29 Mar 2011 13:00:03 +0000 Subject: [PATCH 173/261] Apply [#26044] Windows thumbnails and improved filetype registration submitted by Tom Edwards Fix [#25473] 64bit Windows installer for version 2.56 is not working patch submitted by Caleb (Dobz) The thumbnail patch adds a thumb handler DLL that adds .blend thumbnail support in Windows Explorer. A -r option is added to do registration in background. The patch also improves icon building and metadata for blender.exe. Caleb fixes and cleans up our installer to an acceptable state. The patch uses the new -r option to do the .blend extension and thumbnailer registration. Thanks to both Caleb and Tom for their efforts! --- SConstruct | 26 +++- release/windows/installer/00.sconsblender.nsi | 127 ++++++++++-------- source/blender/blenlib/BLI_winstuff.h | 2 +- source/blender/blenlib/intern/winstuff.c | 104 +++++++++++--- source/creator/CMakeLists.txt | 24 ++++ source/creator/creator.c | 10 +- source/icons/SConscript | 13 +- source/icons/blender.exe.manifest | 10 ++ source/icons/linuxcrossblender.rcscons | 2 - source/icons/winblender.rc | 42 +++++- source/icons/winblender.rcscons | 2 - 11 files changed, 266 insertions(+), 96 deletions(-) create mode 100644 source/icons/blender.exe.manifest delete mode 100644 source/icons/linuxcrossblender.rcscons delete mode 100644 source/icons/winblender.rcscons 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/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/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/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/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 99c7dba9305..b25cac7bf78 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -101,6 +101,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="${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 ) @@ -536,6 +547,19 @@ elseif(WIN32) ) endif() endif() + + add_custom_command(TARGET blender + POST_BUILD + MAIN_DEPENDENCY blender + COMMAND copy /Y \"${LIBDIR}\\thumbhandler\\lib\\BlendThumb64.dll\" \"${TARGETDIR}\\\" + ) + if(NOT CMAKE_CL_64) + add_custom_command(TARGET blender + POST_BUILD + MAIN_DEPENDENCY blender + COMMAND copy /Y \"${LIBDIR}\\thumbhandler\\lib\\BlendThumb.dll\" \"${TARGETDIR}\\\" + ) + endif() elseif(APPLE) set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) diff --git a/source/creator/creator.c b/source/creator/creator.c index 2480f8b544b..1db143cdd20 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -287,6 +287,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"); @@ -486,12 +487,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; } @@ -1094,7 +1095,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/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..244c2cb2e2c 100644 --- a/source/icons/winblender.rc +++ b/source/icons/winblender.rc @@ -1,2 +1,40 @@ -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 + VALUE "FileVersion", BLEN_VER_RC_STR + VALUE "ProductVersion", BLEN_VER_RC_STR + 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" From 4b96f15cb30fad958adced2cf73d7bd5b245af7e Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 29 Mar 2011 13:00:59 +0000 Subject: [PATCH 174/261] Fix for [#26664] Some particle panels disappear when pinned * Too strict poll functions for render & display panels. * Like said in the report cache & vertex groups are a part of the particle system (not particle settings) they can't be shown when the settings are pinned. --- .../startup/bl_ui/properties_particle.py | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index be581d0dc31..09915b03926 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -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!") From 0297b6c8c6102a5ef5eca03dbedfd4ff5bc04fbe Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 29 Mar 2011 13:37:16 +0000 Subject: [PATCH 175/261] Fix #26637: another problem with recent normals change, objects with negative scale did not get correct render normals. --- source/blender/render/intern/source/convertblender.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index f51ed550813..73addfb77e4 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) { From 5c79bbe2d8c530c84d6c5979d45c283e1875c4ce Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 13:48:28 +0000 Subject: [PATCH 176/261] fix [#26666] Snapping the cursor to selected in UV Image Editor when unwrapping causes an assert. --- source/blender/editors/uvedit/uvedit_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 462bdda5e32..ec12b997742 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -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; @@ -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; From 3d9c666f581bd5a9a01630ebb9e2452be524f035 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 14:07:07 +0000 Subject: [PATCH 177/261] fix [#26656] video sequence editor rendering stops at frame 9999 --- source/blender/blenlib/intern/path_util.c | 29 +++-------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 0dc09606533..e9efc63bc55 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, digits, 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, digits, sta, digits, 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; From e020c1504eb90138ba8bda74085df56a3522895e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 14:13:11 +0000 Subject: [PATCH 178/261] fix [#26657] Smart UV Project missing from Unwrap menu in 3D Viewport --- release/scripts/startup/bl_ui/space_view3d.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 22d630643c9..06ad23302a8 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -240,15 +240,25 @@ class VIEW3D_MT_uv_map(bpy.types.Menu): layout = self.layout layout.operator("uv.unwrap") + layout.operator("uv.smart_project") + layout.operator("uv.lightmap_pack") + layout.operator("uv.follow_active_quads") + + layout.separator() + 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 layout.separator() layout.operator("uv.reset") + # ********** View menus ********** From b84a6c4d7eba665975661428072eda57fa33abb7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 14:36:55 +0000 Subject: [PATCH 179/261] use less verbose string formatting for units and interface. --- source/blender/blenkernel/intern/unit.c | 4 +- source/blender/editors/interface/interface.c | 56 +++++++------------- 2 files changed, 20 insertions(+), 40 deletions(-) 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/editors/interface/interface.c b/source/blender/editors/interface/interface.c index afee8416239..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); @@ -1997,19 +1992,12 @@ void ui_check_but(uiBut *but) 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; From e124c477135cb59daedcb1cfd0243ed1810b8f95 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 29 Mar 2011 14:39:39 +0000 Subject: [PATCH 180/261] Fix #26653: changed DPI setting in user preferences is not saved as default. Clamping on load did not match RNA property min/max. --- source/blender/editors/interface/interface_style.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) { From c0ab420a73d51ff7f8fc2bb305128dfbb57ac487 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 29 Mar 2011 15:46:02 +0000 Subject: [PATCH 181/261] apply patch for body suspend/resume See also issue #26614 http://projects.blender.org/tracker/index.php?func=detail&aid=26614&group_id=9&atid=306 --- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; From f4ba9495c506f462fcad1c7db4d8fa2aae147a6f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 16:12:25 +0000 Subject: [PATCH 182/261] fix [#26667] Can't import scripts when using blenderplayer - move import override initialization to bpy_internal_import.c so the player and blender can both call. - remove ineffectual & unused sandboxing code. --- .../python/generic/bpy_internal_import.c | 21 +++ .../python/generic/bpy_internal_import.h | 2 + source/blender/python/intern/bpy_interface.c | 22 +-- source/gameengine/Ketsji/KX_PythonInit.cpp | 175 +----------------- 4 files changed, 26 insertions(+), 194 deletions(-) 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/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 8833079d742..c6b442fd930 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -272,27 +272,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/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); From 973ce364a43688c3a93653358c75ad4f533e7346 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 29 Mar 2011 16:52:26 +0000 Subject: [PATCH 183/261] fix [#26623] script/console windows: BACKSPACE does not work when SHIFT is held --- source/blender/editors/curve/curve_ops.c | 1 + source/blender/editors/space_console/space_console.c | 1 + source/blender/editors/space_text/space_text.c | 1 + 3 files changed, 3 insertions(+) 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/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_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); From 952aa9804f0edb1e96d363f6dfb3349310a88e93 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 29 Mar 2011 18:44:18 +0000 Subject: [PATCH 184/261] fixes in Bullet stuff, roll influence for raycast vehicles was broken, enable the setPhysicsTicRate for BGE Python --- .../NarrowPhaseCollision/btGjkPairDetector.cpp | 9 +++++---- .../src/BulletDynamics/Vehicle/btRaycastVehicle.cpp | 2 +- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h | 6 +++++- 3 files changed, 11 insertions(+), 6 deletions(-) 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/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;}; From 31700740111073c05dbec457d6b205fe53772aac Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 29 Mar 2011 21:00:42 +0000 Subject: [PATCH 185/261] Fix for [#26646] Hair particle density texture prevents strand render on linked assets * Linked particle textures weren't expanded during file load. --- source/blender/blenloader/intern/readfile.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e3b736bb7e8..a304084c7b2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12032,6 +12032,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); @@ -12039,6 +12041,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) From 77e3eac3897975a82e1c68468002a5eb0f00a8b5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 02:05:10 +0000 Subject: [PATCH 186/261] Fix for old bug with subsurf not initializing normals for edges that had no faces, Noted that a floating point exception caused by this r28953. With the render engine using DerivedMesh normals this came up as a memory error when rendering some files. for now zero the normals, could interpolate between vertex normals if needed. --- source/blender/blenkernel/intern/CCGSubSurf.c | 11 +++++++++++ source/blender/blenkernel/intern/subsurf_ccg.c | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) 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; xco); - /* 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); } } From 70162a4abd61df29f8ee451d94eeee6315d6155f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 02:59:32 +0000 Subject: [PATCH 187/261] fix [#26682] Accessing weight sometimes crashes blender also replace object type check from vgroup_edit_lattice() with an assert since all callers check for lattice type. --- source/blender/blenkernel/intern/lattice.c | 13 +++------- source/blender/editors/object/object_vgroup.c | 25 +++++++++++-------- 2 files changed, 19 insertions(+), 19 deletions(-) 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/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) From 91881dce85424860bb97d7e6ccbffc492ac98bd3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 04:58:45 +0000 Subject: [PATCH 188/261] - include for BGE joystick sensor - remove print from numinput and get rid of some float/double warnings. - nicer align line-number in text editor. --- source/blender/editors/space_text/text_draw.c | 2 +- source/blender/editors/util/numinput.c | 6 +++--- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) 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/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/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 From 4052ef16674bd981c9139eff373482bf0ae6abad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 05:07:12 +0000 Subject: [PATCH 189/261] quiet gcc's float/double warnings. --- .../editors/space_sequencer/sequencer_draw.c | 48 +++++++------- .../space_sequencer/sequencer_scopes.c | 62 +++++++++---------- 2 files changed, 55 insertions(+), 55 deletions(-) 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_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index d91d675042f..49ad1e2825c 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; @@ -217,13 +217,13 @@ static struct ImBuf *make_waveform_view_from_ibuf_float(struct ImBuf * ibuf) 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); @@ -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); @@ -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); From f8b42877b0fe07883d5ccb83189d638e83eee9e9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 05:08:52 +0000 Subject: [PATCH 190/261] update blender release cycle ID. --- source/blender/blenkernel/BKE_blender.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 6f8e9bbe8df..abae185a645 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -53,7 +53,7 @@ extern "C" { /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR a /* alpha/beta/rc/releases */ -#define BLENDER_VERSION_CYCLE beta +#define BLENDER_VERSION_CYCLE rc struct ListBase; struct MemFile; From 5b19ec3559bb552550b12f7f2fb3dc16a3278621 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 30 Mar 2011 05:44:01 +0000 Subject: [PATCH 191/261] Apply patch [#26660] Scons build on OSX fails to create Info.plist file fix provided by Mike Sloman from the patch report: When building on Mac OSX with SCONS the Info.plist file is zero length and thus OSX cannot identify icons and file type associations. The problems was in the execution of the "date" command to add times in the modified bundle name strings passed to sed. This failed and thus the info.plist file was overwritten with 0 length file. --- build_files/scons/tools/Blender.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 206e5b717997cdb4c9451444e1badd573b862261 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 06:27:39 +0000 Subject: [PATCH 192/261] print warning on windows/mac when bundled python is not found, suggesting to build the 'install' target. --- source/blender/python/intern/bpy_interface.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index c6b442fd930..f8214b643fe 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, "Bundled python is expected on this platform, if blender fails to load build the 'install' target\n"); +#endif return; - + } /* set the environment path */ printf("found bundled python: %s\n", py_path_bundle); From bfadd7c9aa2ec2b5194baccc9fe49ee14a04f2a5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 07:21:41 +0000 Subject: [PATCH 193/261] modify error when python is not found so as not to confuse users who don't build blender. + minor edits. --- release/scripts/startup/bl_ui/space_view3d.py | 2 +- source/blender/python/intern/bpy_interface.c | 2 +- source/blender/windowmanager/intern/wm_event_system.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 06ad23302a8..fc316779cfb 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -258,7 +258,7 @@ class VIEW3D_MT_uv_map(bpy.types.Menu): layout.separator() layout.operator("uv.reset") - + # ********** View menus ********** diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index f8214b643fe..80c4a6cf2f6 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -173,7 +173,7 @@ static void bpy_python_start_path(void) if(py_path_bundle==NULL) { /* Common enough to have bundled *nix python but complain on OSX/Win */ #if defined(__APPLE__) || defined(_WIN32) - fprintf(stderr, "Bundled python is expected on this platform, if blender fails to load build the 'install' target\n"); + 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; } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index b52e8e92f22..09ea924c0d2 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -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); From 22abd53c7ee99274ed93ba188e9f59e740443088 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 30 Mar 2011 10:29:32 +0000 Subject: [PATCH 194/261] Quick effects operators: * A couple of operators to quickly create effects that would otherwise take some time to set up. * Nice to use for demoing functionality or as a starting point for more complex effects. * "Make Fur" - Gives every selected mesh object particle fur with a desired density and length. * "Make Smoke" - Makes each selected object a smoke emitter and creates a new domain object around the emitters with the correct material to render the smoke. ** Has style options for "stream": constant smoke flow, "puff": only create smoke once from the volume of the emitter object, "fire": enable high resolution smoke and set a secondary fire color texture for the domain object. * "Make Fluid" - Makes every selected object a fluid object (normal/inflow) and has the option to start fluid baking immediately. * This should provide a nice base for extending these / adding more operators for different effects. --- .../scripts/startup/bl_operators/__init__.py | 1 + .../bl_operators/object_quick_effects.py | 310 ++++++++++++++++++ 2 files changed, 311 insertions(+) create mode 100644 release/scripts/startup/bl_operators/object_quick_effects.py 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/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py new file mode 100644 index 00000000000..332b7ebae42 --- /dev/null +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -0,0 +1,310 @@ +# ##### 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 ##### + +# + +import mathutils +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): + count = 0 + for ob in context.selected_objects: + + if(ob == None or ob.type != 'MESH'): + continue + + count += 1 + + context.scene.objects.active = ob + + bpy.ops.object.particle_system_add() + + psys = ob.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' + + if count == 0: + self.report({'ERROR'}, "Select at least one mesh object.") + return {'CANCELLED'} + + return {'FINISHED'} + +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): + count = 0 + min_co = Vector((0,0,0)) + max_co = Vector((0,0,0)) + for ob in context.selected_objects: + + if(ob == None or ob.type != 'MESH'): + continue + + context.scene.objects.active = ob + + # make each selected object a smoke flow + bpy.ops.object.modifier_add(type='SMOKE') + ob.modifiers[-1].smoke_type = 'FLOW' + + psys = ob.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 + + ob.modifiers[-2].flow_settings.initial_velocity = True + ob.modifiers[-2].flow_settings.temperature = 2 + + psys.settings.use_render_emitter = self.show_flows + + # store bounding box min/max for the domain object + for i in range(0, 8): + bb_vec = Vector((ob.bound_box[i][0], ob.bound_box[i][1], ob.bound_box[i][2])) * ob.matrix_world + + if count == 0 and i == 0: + min_co += bb_vec + max_co += bb_vec + else: + 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]) + + count += 1 + + if count == 0: + self.report({'ERROR'}, "Select at least one mesh object.") + return {'CANCELLED'} + + # add the smoke domain object + bpy.ops.mesh.primitive_cube_add() + ob = context.active_object + ob.name = "Smoke Domain" + + # give the smoke some room above the flows + ob.location[0] = (max_co[0] + min_co[0]) * 0.5 + ob.location[1] = (max_co[1] + min_co[1]) * 0.5 + ob.location[2] = max_co[2] - min_co[2] + ob.scale[0] = max_co[0] - min_co[0] + ob.scale[1] = max_co[1] - min_co[1] + ob.scale[2] = 2*(max_co[2] - min_co[2]) + + # setup smoke domain + bpy.ops.object.modifier_add(type='SMOKE') + ob.modifiers[-1].smoke_type = 'DOMAIN' + if self.style == 'FIRE': + ob.modifiers[-1].domain_settings.use_dissolve_smoke = True + ob.modifiers[-1].domain_settings.dissolve_speed = 20 + ob.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() + + mat = ob.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 = ob + 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 = ob + 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): + count = 0 + min_co = Vector((0,0,0)) + max_co = Vector((0,0,0)) + for ob in context.selected_objects: + + if(ob == None or ob.type != 'MESH'): + continue + + context.scene.objects.active = ob + + # make each selected object a fluid + bpy.ops.object.modifier_add(type='FLUID_SIMULATION') + if self.style == 'INFLOW': + ob.modifiers[-1].settings.type = 'INFLOW' + ob.modifiers[-1].settings.inflow_velocity = self.initial_velocity.copy() + else: + ob.modifiers[-1].settings.type = 'FLUID' + ob.modifiers[-1].settings.initial_velocity = self.initial_velocity.copy() + + ob.hide_render = not self.show_flows + + # store bounding box min/max for the domain object + for i in range(0, 8): + bb_vec = Vector((ob.bound_box[i][0], ob.bound_box[i][1], ob.bound_box[i][2])) * ob.matrix_world + + if count == 0 and i == 0: + min_co += bb_vec + max_co += bb_vec + else: + 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]) + + count += 1 + + if count == 0: + self.report({'ERROR'}, "Select at least one mesh object.") + return {'CANCELLED'} + + # add the fluid domain object + bpy.ops.mesh.primitive_cube_add() + ob = context.active_object + ob.name = "Fluid Domain" + + # give the smoke some room above the flows + ob.location[0] = (max_co[0] + min_co[0]) * 0.5 + ob.location[1] = (max_co[1] + min_co[1]) * 0.5 + ob.location[2] = min_co[2] - max_co[2] + ob.scale[0] = max_co[0] - min_co[0] + ob.scale[1] = max_co[1] - min_co[1] + ob.scale[2] = 2*(max_co[2] - min_co[2]) + + # setup smoke domain + bpy.ops.object.modifier_add(type='FLUID_SIMULATION') + ob.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() + + mat = ob.material_slots[0].material + mat.name = "Fluid Domain Material" + mat.specular_intensity = 1 + mat.specular_hardness = 100 + mat.use_transparency = True + mat.alpha = 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'} \ No newline at end of file From 2b79378f81d42049192fca47910a2db91e1d85a1 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 30 Mar 2011 10:51:01 +0000 Subject: [PATCH 195/261] COLLADA lights: * simplify export and import, now that we have blender profiles for lights. The vanilla import is now more in line with the specs. If a blender profile is found, skip normal import, use the profile data instead. * multiply energy into color rgb export (common profile). * recalc distance taking metrics in account --- source/blender/collada/DocumentImporter.cpp | 170 ++++++++++---------- source/blender/collada/ExtraTags.cpp | 5 + source/blender/collada/ExtraTags.h | 3 + source/blender/collada/LightExporter.cpp | 37 ++--- 4 files changed, 109 insertions(+), 106 deletions(-) diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index ce6f4777e9a..72341e1caa2 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -863,109 +863,35 @@ 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(); - } - 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; - } - 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->energy = 1.0; - 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; - } - - if(et) { + + // 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)); @@ -1015,7 +941,83 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) et->setData("sky_exposure", &(lamp->sky_exposure)); et->setData("sky_colorspace", &(lamp->sky_colorspace)); } + 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(); + } + + if(IS_EQ(linatt, 0.0f) && quadatt > 0.0f) { + att2 = quadatt; + d = (1.0f/quadatt) * 2; + } + // 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; + } + 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; } diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index ce72085fe41..653d4a377cd 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -44,6 +44,11 @@ ExtraTags::~ExtraTags() { } +bool ExtraTags::isProfile( std::string profile) +{ + return this->profile == profile; +} + bool ExtraTags::addTag( std::string tag, std::string data) { tags[tag] = data; diff --git a/source/blender/collada/ExtraTags.h b/source/blender/collada/ExtraTags.h index 5c31a5a95db..710d26e8cad 100644 --- a/source/blender/collada/ExtraTags.h +++ b/source/blender/collada/ExtraTags.h @@ -56,6 +56,9 @@ public: /** 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. */ ExtraTags( const ExtraTags& pre ); 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); From a462f7880b3927612553dbd86cdb4d73fb74a204 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 11:51:06 +0000 Subject: [PATCH 196/261] disallow rna paths resolving to upper case X/Y/Z/X / R/G/B/A, python cant resolve these. --- source/blender/makesrna/intern/rna_access.c | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) 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; } } From ce2be370262830db6f0c32b0771c5e42f9072d8a Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 30 Mar 2011 13:35:54 +0000 Subject: [PATCH 197/261] Small update to the quick effects operators: * "Make fur" now creates a basic fur material for each object (smaller strand tip width and a little bit of surface diffuse) * If fluid/smoke emitters aren't rendered the objects are also set to draw only in wire mode so that the fluid/smoke can be clearly seen. --- .../startup/bl_operators/object_quick_effects.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index 332b7ebae42..65d3854fab9 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -75,6 +75,14 @@ class MakeFur(bpy.types.Operator): 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 ob in context.selected_objects: + ob.data.materials.append(mat) + ob.particle_systems[-1].settings.material = len(ob.material_slots) + return {'FINISHED'} class MakeSmoke(bpy.types.Operator): @@ -123,6 +131,8 @@ class MakeSmoke(bpy.types.Operator): ob.modifiers[-2].flow_settings.temperature = 2 psys.settings.use_render_emitter = self.show_flows + if not self.show_flows: + ob.draw_type = 'WIRE' # store bounding box min/max for the domain object for i in range(0, 8): @@ -249,6 +259,8 @@ class MakeFluid(bpy.types.Operator): ob.modifiers[-1].settings.initial_velocity = self.initial_velocity.copy() ob.hide_render = not self.show_flows + if not self.show_flows: + ob.draw_type = 'WIRE' # store bounding box min/max for the domain object for i in range(0, 8): From 9ba57b6518077d6988ab228212db73bee8745c8c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 15:02:02 +0000 Subject: [PATCH 198/261] pass pep8 checker. --- .../bl_operators/object_quick_effects.py | 141 +++++++++--------- 1 file changed, 72 insertions(+), 69 deletions(-) diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index 65d3854fab9..fe5144d9e0c 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -23,11 +23,12 @@ 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", ""), @@ -35,61 +36,62 @@ class MakeFur(bpy.types.Operator): 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): count = 0 for ob in context.selected_objects: - + if(ob == None or ob.type != 'MESH'): continue - + count += 1 - + context.scene.objects.active = ob - + bpy.ops.object.particle_system_add() - + psys = ob.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' - + if count == 0: 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 ob in context.selected_objects: ob.data.materials.append(mat) ob.particle_systems[-1].settings.material = len(ob.material_slots) - + return {'FINISHED'} + 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", ""), @@ -97,26 +99,26 @@ class MakeSmoke(bpy.types.Operator): 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): count = 0 - min_co = Vector((0,0,0)) - max_co = Vector((0,0,0)) + min_co = Vector() + max_co = Vector() for ob in context.selected_objects: - + if(ob == None or ob.type != 'MESH'): continue - + context.scene.objects.active = ob - + # make each selected object a smoke flow bpy.ops.object.modifier_add(type='SMOKE') ob.modifiers[-1].smoke_type = 'FLOW' - + psys = ob.particle_systems[-1] if self.style == 'PUFF': psys.settings.frame_end = psys.settings.frame_start @@ -126,18 +128,18 @@ class MakeSmoke(bpy.types.Operator): psys.settings.effector_weights.gravity = -1 psys.settings.lifetime = 5 psys.settings.count = 100000 - + ob.modifiers[-2].flow_settings.initial_velocity = True ob.modifiers[-2].flow_settings.temperature = 2 - + psys.settings.use_render_emitter = self.show_flows if not self.show_flows: ob.draw_type = 'WIRE' - + # store bounding box min/max for the domain object for i in range(0, 8): bb_vec = Vector((ob.bound_box[i][0], ob.bound_box[i][1], ob.bound_box[i][2])) * ob.matrix_world - + if count == 0 and i == 0: min_co += bb_vec max_co += bb_vec @@ -148,26 +150,26 @@ class MakeSmoke(bpy.types.Operator): 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]) - + count += 1 - + if count == 0: self.report({'ERROR'}, "Select at least one mesh object.") return {'CANCELLED'} - + # add the smoke domain object bpy.ops.mesh.primitive_cube_add() ob = context.active_object ob.name = "Smoke Domain" - + # give the smoke some room above the flows ob.location[0] = (max_co[0] + min_co[0]) * 0.5 ob.location[1] = (max_co[1] + min_co[1]) * 0.5 ob.location[2] = max_co[2] - min_co[2] ob.scale[0] = max_co[0] - min_co[0] ob.scale[1] = max_co[1] - min_co[1] - ob.scale[2] = 2*(max_co[2] - min_co[2]) - + ob.scale[2] = 2.0 * (max_co[2] - min_co[2]) + # setup smoke domain bpy.ops.object.modifier_add(type='SMOKE') ob.modifiers[-1].smoke_type = 'DOMAIN' @@ -175,22 +177,22 @@ class MakeSmoke(bpy.types.Operator): ob.modifiers[-1].domain_settings.use_dissolve_smoke = True ob.modifiers[-1].domain_settings.dissolve_speed = 20 ob.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() - + mat = ob.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 = ob 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 @@ -198,57 +200,58 @@ class MakeSmoke(bpy.types.Operator): mat.texture_slots[1].texture = bpy.data.textures.new("Smoke Heat", 'VOXEL_DATA') mat.texture_slots[1].texture.voxel_data.domain_object = ob 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): count = 0 - min_co = Vector((0,0,0)) - max_co = Vector((0,0,0)) + min_co = Vector() + max_co = Vector() for ob in context.selected_objects: - + if(ob == None or ob.type != 'MESH'): continue - + context.scene.objects.active = ob - + # make each selected object a fluid bpy.ops.object.modifier_add(type='FLUID_SIMULATION') if self.style == 'INFLOW': @@ -257,15 +260,15 @@ class MakeFluid(bpy.types.Operator): else: ob.modifiers[-1].settings.type = 'FLUID' ob.modifiers[-1].settings.initial_velocity = self.initial_velocity.copy() - + ob.hide_render = not self.show_flows if not self.show_flows: ob.draw_type = 'WIRE' - + # store bounding box min/max for the domain object for i in range(0, 8): bb_vec = Vector((ob.bound_box[i][0], ob.bound_box[i][1], ob.bound_box[i][2])) * ob.matrix_world - + if count == 0 and i == 0: min_co += bb_vec max_co += bb_vec @@ -276,36 +279,36 @@ class MakeFluid(bpy.types.Operator): 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]) - + count += 1 - + if count == 0: self.report({'ERROR'}, "Select at least one mesh object.") return {'CANCELLED'} - + # add the fluid domain object bpy.ops.mesh.primitive_cube_add() ob = context.active_object ob.name = "Fluid Domain" - + # give the smoke some room above the flows ob.location[0] = (max_co[0] + min_co[0]) * 0.5 ob.location[1] = (max_co[1] + min_co[1]) * 0.5 ob.location[2] = min_co[2] - max_co[2] ob.scale[0] = max_co[0] - min_co[0] ob.scale[1] = max_co[1] - min_co[1] - ob.scale[2] = 2*(max_co[2] - min_co[2]) - + ob.scale[2] = 2.0 * (max_co[2] - min_co[2]) + # setup smoke domain bpy.ops.object.modifier_add(type='FLUID_SIMULATION') ob.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() - + mat = ob.material_slots[0].material mat.name = "Fluid Domain Material" mat.specular_intensity = 1 @@ -315,8 +318,8 @@ class MakeFluid(bpy.types.Operator): 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'} \ No newline at end of file + + return {'FINISHED'} From 4f29bc25948d7f412ccf7c3944bd3550d87bc9a5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 15:28:38 +0000 Subject: [PATCH 199/261] fix [#26685] Cannot exit from "edit mode" this does not fix the underlying problem that once in this state you cant exit editmode, only that the layer key bindings dont let the state come about. Looked into fixing properly but its not so simple since currently object mode operators all use "active_object" which is supposed not to be set when in a hidden layer. --- .../editors/space_view3d/view3d_header.c | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) 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< Date: Wed, 30 Mar 2011 16:11:16 +0000 Subject: [PATCH 200/261] quiet gcc implicit float -> double warnings & use floats in places. --- source/blender/blenkernel/intern/seqeffects.c | 128 +++++++++--------- source/blender/blenkernel/intern/sequencer.c | 38 +++--- 2 files changed, 83 insertions(+), 83 deletions(-) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index bebfcaed78f..e6360620048 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; } @@ -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..98a982824ba 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -333,7 +333,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 +962,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,9 +1014,9 @@ 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) { + if (seq->strobe > 1.0f) { nr -= fmod((double)nr, (double)seq->strobe); } @@ -1370,7 +1370,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 +1378,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 +1388,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 +1416,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 +1428,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 +1547,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 +1643,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 +1660,7 @@ static ImBuf * input_preprocess( } } - if(mul != 1.0) { + if(mul != 1.0f) { multibuf(ibuf, mul); } @@ -1765,7 +1765,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 +2144,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 +2252,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) { From bb1f20a534e1179fcc1f104c117f27676910bcc2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 16:14:54 +0000 Subject: [PATCH 201/261] includes for building with gcc 4.6 on fedora. patch from Richard Shaw --- extern/Eigen2/Eigen/src/Core/util/Memory.h | 2 ++ intern/ghost/GHOST_IEvent.h | 1 + intern/memutil/MEM_Allocator.h | 1 + source/gameengine/Converter/BL_ArmatureChannel.cpp | 1 + source/gameengine/Expressions/PyObjectPlus.h | 1 + 5 files changed, 6 insertions(+) diff --git a/extern/Eigen2/Eigen/src/Core/util/Memory.h b/extern/Eigen2/Eigen/src/Core/util/Memory.h index 0a43e7f7bf2..8ff8d87c55c 100644 --- a/extern/Eigen2/Eigen/src/Core/util/Memory.h +++ b/extern/Eigen2/Eigen/src/Core/util/Memory.h @@ -37,6 +37,8 @@ #define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 0 #endif +#include + #if defined(__APPLE__) || defined(_WIN64) || EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED #define EIGEN_MALLOC_ALREADY_ALIGNED 1 #else 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/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 From 37f3bbae90febc06a4f4b4b22749794b1392c0a3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 16:21:35 +0000 Subject: [PATCH 202/261] didnt mean to commit to Eigen2 since its externally maintained. --- extern/Eigen2/Eigen/src/Core/util/Memory.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/extern/Eigen2/Eigen/src/Core/util/Memory.h b/extern/Eigen2/Eigen/src/Core/util/Memory.h index 8ff8d87c55c..0a43e7f7bf2 100644 --- a/extern/Eigen2/Eigen/src/Core/util/Memory.h +++ b/extern/Eigen2/Eigen/src/Core/util/Memory.h @@ -37,8 +37,6 @@ #define EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED 0 #endif -#include - #if defined(__APPLE__) || defined(_WIN64) || EIGEN_FREEBSD_MALLOC_ALREADY_ALIGNED #define EIGEN_MALLOC_ALREADY_ALIGNED 1 #else From 9c01b941485d2a70d9fc54361ac41b430989a466 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 16:44:18 +0000 Subject: [PATCH 203/261] py/rna Operator.cancel method didnt have return defined. --- source/blender/makesrna/intern/rna_wm_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index ab2775b7184..92311641d98 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -249,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) From 531d3e410f23115347b4f9304eb99d32c137fe10 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 31 Mar 2011 00:45:52 +0000 Subject: [PATCH 204/261] Propagate Pose Tweaks: - Renamed "Last Keyframe" mode to "Before End". This mode still just copies the pose to all keyframes starting from the current frame until the last one encountered per F-Curve - "Last Keyframe" mode (new one) now copies the pose to the last keyframe. This is useful for making animations cyclic (i.e. go to first keyframe, edit, then Pose->Propagate->To Last Keyframe (Make Cyclic)) --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/editors/armature/poseSlide.c | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index fc316779cfb..f026a26c984 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1259,6 +1259,7 @@ class VIEW3D_MT_pose_propagate(bpy.types.Menu): layout.operator("pose.propagate") layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY' + layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY' class VIEW3D_MT_pose_library(bpy.types.Menu): diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index e47ec0029a0..31fcf0a1253 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -862,14 +862,16 @@ 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 } ePosePropagate_Termination; /* --------------------------------- */ @@ -1066,13 +1068,18 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, tPChanFCurveLink 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; + 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; + } /* 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)? @@ -1142,10 +1149,11 @@ 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"}, {0, NULL, 0, NULL, NULL}}; /* identifiers */ @@ -1163,7 +1171,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); } /* **************************************************** */ From 077f8520dae0425a481cbe82a3bcba902b93a0b0 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 31 Mar 2011 01:37:42 +0000 Subject: [PATCH 205/261] Pose Propagate - Further Tweaks: - Pose Propagate and Pose Sliding tools now work in the same way as Pose Library previewing, with regards to selections. If some bones are selected, then only those will be affected. But if no bones are selected, then the whole rig gets affected. - Added a "On Selected Markers" option, which only propagates poses to frames where there's a selected marker. Animators can combine this with a "select markers whose name contains..." operator to get an effective way to manage hand-keyed walk cycles, etc. --- release/scripts/startup/bl_ui/space_view3d.py | 7 +++ source/blender/editors/armature/poseSlide.c | 54 ++++++++++++++++--- source/blender/editors/armature/poseUtils.c | 12 ++++- .../editors/space_action/action_select.c | 2 +- .../editors/space_graph/graph_select.c | 2 +- 5 files changed, 68 insertions(+), 9 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index f026a26c984..13270a8c6fd 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1258,9 +1258,16 @@ 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): bl_label = "Pose Library" diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 31fcf0a1253..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" @@ -871,9 +872,21 @@ typedef enum ePosePropagate_Termination { /* stop after the specified frame */ POSE_PROPAGATE_BEFORE_FRAME, /* stop when we run out of keyframes */ - POSE_PROPAGATE_BEFORE_END + 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 @@ -1030,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"); @@ -1067,7 +1081,7 @@ 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) + if (bezt->vec[1][0] > modeData.end_frame) break; } else if (mode == POSE_PROPAGATE_NEXT_KEY) { @@ -1080,6 +1094,20 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, tPChanFCurveLink 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)? @@ -1102,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 */ @@ -1118,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; @@ -1127,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); @@ -1154,6 +1195,7 @@ void POSE_OT_propagate (wmOperatorType *ot) {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 */ 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/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_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 */ From 66a1259153100aeebb4319ed50f517d7266f780d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 04:43:26 +0000 Subject: [PATCH 206/261] fix for crash when running blender with define WITH_PYTHON_SAFETY & no startup.blend was found. was calling python function when python was not initialized. --- source/blender/python/intern/bpy_rna.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 9a459063d42..29f05369f44 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; From 7cb68f89ed0cef852ddd27d62d519c21a0a89b32 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 04:55:57 +0000 Subject: [PATCH 207/261] fix for using freed memory in ED_area_newspace() caused by loading webskategirl_bullet.blend and rendering which created a new image space. --- source/blender/editors/screen/area.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index aca9a401321..5a80799fc3b 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1087,6 +1087,9 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) if(sl && sl->regionbase.first==NULL) { st->free(sl); BLI_freelinkN(&sa->spacedata, sl); + if(slold == sl) { + slold= NULL; + } sl= NULL; } From e339acf3a948f279e359706ab1eae7734725f833 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 05:20:48 +0000 Subject: [PATCH 208/261] fix for a crash when loading a new blend file which had a scene with the same name as the old one, the freed backbuffer image from the previous blend file would get reused. also NULL the bakebuf just incase its accessed in future though at the moment this isnt causing any problems. --- source/blender/render/intern/source/convertblender.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 73addfb77e4..62f47dcd3b5 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -4636,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) From 278e2bc3a4a60eb2667954129dc8cbd51267209b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 08:46:41 +0000 Subject: [PATCH 209/261] use poppups for python UV unwrap operators (since they are too slow to be realtime). this change was lost when moving the menu items about. --- release/scripts/startup/bl_ui/space_view3d.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 13270a8c6fd..d5930c3d14c 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -240,12 +240,15 @@ 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") From d7dd2154a1e2359b9bf5cb66c5c97507f2d7a501 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 08:49:52 +0000 Subject: [PATCH 210/261] fix for issue #2 in report: [#26695] Two fail cases with modifiers targeting linked assets also fix for scene.objects.link() not setting library data as being directly used. --- source/blender/makesrna/intern/rna_modifier.c | 7 +++++-- source/blender/makesrna/intern/rna_scene.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) 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_scene.c b/source/blender/makesrna/intern/rna_scene.c index e00ceeafd99..92a2828495e 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -222,7 +222,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; From 75cd392a570ded2c8b1e2abf1d98383aaab706a5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 10:31:14 +0000 Subject: [PATCH 211/261] fix for own error r35877, was ignoring #'s in file path by using the digits value passed rather then the number of digits in the string. --- source/blender/blenlib/intern/path_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index e9efc63bc55..689c6398705 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -587,7 +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]; - sprintf(tmp, "%.*s%.*d%s", ch_sta, path, digits, frame, path+ch_end); + sprintf(tmp, "%.*s%.*d%s", ch_sta, path, ch_end-ch_sta, frame, path+ch_end); strcpy(path, tmp); return 1; } @@ -603,7 +603,7 @@ int BLI_path_frame_range(char *path, int sta, int end, int digits) if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */ char tmp[FILE_MAX]; - sprintf(tmp, "%.*s%.*d-%.*d%s", ch_sta, path, digits, sta, digits, end, path+ch_end); + 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); return 1; } From c7183d2622a0cba5e07653daa4a5aca9ad9ed9cc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 11:21:21 +0000 Subject: [PATCH 212/261] library linked modifiers were not having their ID linked expanded properly. was missing array cap ends, wave map object and shrinkwrap objects. use modifiers_foreachIDLink() rather then having to list all modifiers ID's in this function. also add foreachIDLink() for smoke domain. This fixes a bug where a linked object has as a modifier using an indirectly linked object for the missing cases mentioned above. --- source/blender/blenloader/intern/readfile.c | 58 ++++++--------------- source/blender/modifiers/intern/MOD_smoke.c | 13 ++++- 2 files changed, 28 insertions(+), 43 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a304084c7b2..e8fa56c4b01 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12301,50 +12301,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; @@ -12354,9 +12323,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/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, }; From e4c656c7bf96207fa0d966ea421a03b7a60d7060 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 31 Mar 2011 11:49:01 +0000 Subject: [PATCH 213/261] Fix for [#26694] Quick effects problems: Make Smoke/Fluid on a flat object creates flat domain. On a subdivided mesh create no domain. * Fluidsim has to be before any constructive modifiers. * Also a bit nicer domain size calculation + a warning message for using flat objects as fluid objects. * Some code cleanup and clarification too. --- .../bl_operators/object_quick_effects.py | 211 ++++++++---------- 1 file changed, 88 insertions(+), 123 deletions(-) diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index fe5144d9e0c..73119a6e216 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -44,19 +44,22 @@ class MakeFur(bpy.types.Operator): default=0.1, min=0.001, max=100, soft_min=0.01, soft_max=10) def execute(self, context): - count = 0 - for ob in context.selected_objects: + fake_context = bpy.context.copy() + mesh_objects = [obj for obj in context.selected_objects if obj.type == 'MESH'] - if(ob == None or ob.type != 'MESH'): - continue + if not mesh_objects: + self.report({'ERROR'}, "Select at least one mesh object.") + return {'CANCELLED'} - count += 1 + mat = bpy.data.materials.new("Fur Material") + mat.strand.tip_size = 0.25 + mat.strand.blend_distance = 0.5 - context.scene.objects.active = ob + for obj in mesh_objects: + fake_context["active_object"] = obj + bpy.ops.object.particle_system_add(fake_context) - bpy.ops.object.particle_system_add() - - psys = ob.particle_systems[-1] + psys = obj.particle_systems[-1] psys.settings.type = 'HAIR' if self.density == 'LIGHT': @@ -72,20 +75,21 @@ class MakeFur(bpy.types.Operator): psys.settings.use_hair_bspline = True psys.settings.child_type = 'INTERPOLATED' - if count == 0: - 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 ob in context.selected_objects: - ob.data.materials.append(mat) - ob.particle_systems[-1].settings.material = len(ob.material_slots) + 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" @@ -105,21 +109,20 @@ class MakeSmoke(bpy.types.Operator): default=False) def execute(self, context): - count = 0 - min_co = Vector() - max_co = Vector() - for ob in context.selected_objects: + 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(ob == None or ob.type != 'MESH'): - continue - - context.scene.objects.active = ob + 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(type='SMOKE') - ob.modifiers[-1].smoke_type = 'FLOW' + bpy.ops.object.modifier_add({"object": obj}, type='SMOKE') + obj.modifiers[-1].smoke_type = 'FLOW' - psys = ob.particle_systems[-1] + psys = obj.particle_systems[-1] if self.style == 'PUFF': psys.settings.frame_end = psys.settings.frame_start psys.settings.emit_from = 'VOLUME' @@ -129,59 +132,37 @@ class MakeSmoke(bpy.types.Operator): psys.settings.lifetime = 5 psys.settings.count = 100000 - ob.modifiers[-2].flow_settings.initial_velocity = True - ob.modifiers[-2].flow_settings.temperature = 2 + 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: - ob.draw_type = 'WIRE' + obj.draw_type = 'WIRE' # store bounding box min/max for the domain object - for i in range(0, 8): - bb_vec = Vector((ob.bound_box[i][0], ob.bound_box[i][1], ob.bound_box[i][2])) * ob.matrix_world - - if count == 0 and i == 0: - min_co += bb_vec - max_co += bb_vec - else: - 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]) - - count += 1 - - if count == 0: - self.report({'ERROR'}, "Select at least one mesh object.") - return {'CANCELLED'} + obj_bb_minmax(obj, min_co, max_co) # add the smoke domain object bpy.ops.mesh.primitive_cube_add() - ob = context.active_object - ob.name = "Smoke Domain" + obj = context.active_object + obj.name = "Smoke Domain" # give the smoke some room above the flows - ob.location[0] = (max_co[0] + min_co[0]) * 0.5 - ob.location[1] = (max_co[1] + min_co[1]) * 0.5 - ob.location[2] = max_co[2] - min_co[2] - ob.scale[0] = max_co[0] - min_co[0] - ob.scale[1] = max_co[1] - min_co[1] - ob.scale[2] = 2.0 * (max_co[2] - min_co[2]) + obj.location = 0.5 * (max_co + min_co) + Vector((0,0,1)) + obj.scale = 0.5 * (max_co - min_co) + Vector((1,1,2)) # setup smoke domain - bpy.ops.object.modifier_add(type='SMOKE') - ob.modifiers[-1].smoke_type = 'DOMAIN' + bpy.ops.object.modifier_add({"object": obj}, type='SMOKE') + obj.modifiers[-1].smoke_type = 'DOMAIN' if self.style == 'FIRE': - ob.modifiers[-1].domain_settings.use_dissolve_smoke = True - ob.modifiers[-1].domain_settings.dissolve_speed = 20 - ob.modifiers[-1].domain_settings.use_high_resolution = True + 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() + bpy.ops.object.material_slot_add({"object": obj}) - mat = ob.material_slots[0].material + mat = obj.material_slots[0].material mat.name = "Smoke Domain Material" mat.type = 'VOLUME' mat.volume.density = 0 @@ -189,7 +170,7 @@ class MakeSmoke(bpy.types.Operator): 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 = ob + 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 @@ -198,7 +179,7 @@ class MakeSmoke(bpy.types.Operator): 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 = ob + 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 @@ -242,74 +223,58 @@ class MakeFluid(bpy.types.Operator): default=False) def execute(self, context): - count = 0 - min_co = Vector() - max_co = Vector() - for ob in context.selected_objects: + 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(ob == None or ob.type != 'MESH'): - continue - - context.scene.objects.active = ob - - # make each selected object a fluid - bpy.ops.object.modifier_add(type='FLUID_SIMULATION') - if self.style == 'INFLOW': - ob.modifiers[-1].settings.type = 'INFLOW' - ob.modifiers[-1].settings.inflow_velocity = self.initial_velocity.copy() - else: - ob.modifiers[-1].settings.type = 'FLUID' - ob.modifiers[-1].settings.initial_velocity = self.initial_velocity.copy() - - ob.hide_render = not self.show_flows - if not self.show_flows: - ob.draw_type = 'WIRE' - - # store bounding box min/max for the domain object - for i in range(0, 8): - bb_vec = Vector((ob.bound_box[i][0], ob.bound_box[i][1], ob.bound_box[i][2])) * ob.matrix_world - - if count == 0 and i == 0: - min_co += bb_vec - max_co += bb_vec - else: - 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]) - - count += 1 - - if count == 0: + 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() - ob = context.active_object - ob.name = "Fluid Domain" + obj = context.active_object + obj.name = "Fluid Domain" - # give the smoke some room above the flows - ob.location[0] = (max_co[0] + min_co[0]) * 0.5 - ob.location[1] = (max_co[1] + min_co[1]) * 0.5 - ob.location[2] = min_co[2] - max_co[2] - ob.scale[0] = max_co[0] - min_co[0] - ob.scale[1] = max_co[1] - min_co[1] - ob.scale[2] = 2.0 * (max_co[2] - min_co[2]) + # 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,-1)) + v + obj.scale = 0.5 * (max_co - min_co) + Vector((1,1,2)) + Vector((abs(v[0]), abs(v[1]), abs(v[2]))) # setup smoke domain - bpy.ops.object.modifier_add(type='FLUID_SIMULATION') - ob.modifiers[-1].settings.type = '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() + bpy.ops.object.material_slot_add({"object": obj}) - mat = ob.material_slots[0].material + mat = obj.material_slots[0].material mat.name = "Fluid Domain Material" mat.specular_intensity = 1 mat.specular_hardness = 100 From 2900557568077f0164e83dbb544c664cb8b7c300 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 12:45:54 +0000 Subject: [PATCH 214/261] examples for keyframing nested paths. based on report from user der_On's report [#25746] --- .../bpy.types.bpy_struct.keyframe_insert.1.py | 31 +++++++++++++++++++ .../bpy.types.bpy_struct.keyframe_insert.py | 14 +++++++++ doc/python_api/sphinx_doc_gen.py | 6 ++-- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.1.py create mode 100644 doc/python_api/examples/bpy.types.bpy_struct.keyframe_insert.py 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 b479b19c297..3eedd658406 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 @@ -74,7 +74,7 @@ else: "mathutils.geometry", ) - 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 @@ -272,7 +272,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") From 76d7a3562c448d431def367e2e444696efb6c97e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 14:33:59 +0000 Subject: [PATCH 215/261] blender had no option to add a new scene from the UI, only to copy the existing one. added a new scene option which doesnt copy any render settings from the previous. --- source/blender/blenkernel/BKE_scene.h | 9 ++++---- source/blender/editors/screen/screen_ops.c | 26 ++++++++++++++-------- 2 files changed, 22 insertions(+), 13 deletions(-) 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/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 289296fd817..afda6c5088f 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3164,14 +3164,21 @@ static int scene_new_exec(bContext *C, wmOperator *op) Scene *newscene, *scene= CTX_data_scene(C); Main *bmain= CTX_data_main(C); int type= RNA_enum_get(op->ptr, "type"); - - 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); + + 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); + } + } WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); @@ -3181,7 +3188,8 @@ static int scene_new_exec(bContext *C, wmOperator *op) 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"}, From 6e14661ad06835a70c7457de50b87da333690f40 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 31 Mar 2011 15:26:51 +0000 Subject: [PATCH 216/261] Bugfix #26651 If greasepencil became active, making Blender area full or restore screen from full, the greasepencil handler was still running, using outdated area pointer. This crashed Blender. Now greasepencil modal() ends on the case its own stored area does not exist anymore. --- .../blender/editors/gpencil/gpencil_paint.c | 22 +++++++++++++++++-- source/blender/editors/screen/screen_edit.c | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) 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/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) { From cd9b42871c34e4d694bc508ed2bd5dd50f88c223 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 15:28:53 +0000 Subject: [PATCH 217/261] remove bpy python api from blenderplayer, it was being linked but not initialized/available. --- source/blender/python/SConscript | 2 +- source/blenderplayer/CMakeLists.txt | 1 - .../bad_level_call_stubs/stubs.c | 20 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index 30cd5a842ca..de6b859d259 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -34,4 +34,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/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 c1581e1f8f3..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 */ @@ -402,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 From 5d02ce8a7bc1bfd8010b2ad0d521886dc27fabd2 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 31 Mar 2011 17:14:31 +0000 Subject: [PATCH 218/261] Bugfix #26687 Using "New scene" operator was setting the screen->scene pointer after the undo-push, messing up redos or undos immediate after. --- source/blender/editors/screen/screen_ops.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index afda6c5088f..bff92df430c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3162,6 +3162,7 @@ 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"); @@ -3180,8 +3181,12 @@ static int scene_new_exec(bContext *C, wmOperator *op) } } + /* 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; } From 14e94d742e985488490cbbb74e6e1dc9923bc4c2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 31 Mar 2011 17:54:23 +0000 Subject: [PATCH 219/261] using wrong RNA type in sculpt update. --- source/blender/editors/sculpt_paint/sculpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From c8652b301fb59eead1f76bf34215af5413ffa4aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 02:41:15 +0000 Subject: [PATCH 220/261] pep8 checker, mostly pedantic style changes but also found an error in mesh_utils.mesh_linked_faces() --- build_files/buildbot/master_unpack.py | 8 ++++---- build_files/buildbot/slave_pack.py | 16 ++++++++-------- build_files/cmake/cmake_qtcreator_project.py | 3 +-- .../cmake/example_scripts/make_quicky.py | 6 +++--- release/scripts/modules/addon_utils.py | 4 ++-- release/scripts/modules/bpy/utils.py | 1 - release/scripts/modules/bpyml_ui.py | 4 ++-- release/scripts/modules/mesh_utils.py | 2 +- .../bl_operators/object_quick_effects.py | 13 +++++++------ .../object_randomize_transform.py | 2 +- .../scripts/startup/bl_operators/presets.py | 1 - release/scripts/startup/bl_operators/wm.py | 19 +++++++++++-------- .../startup/bl_ui/properties_animviz.py | 2 -- .../startup/bl_ui/properties_particle.py | 2 +- .../scripts/startup/bl_ui/space_userpref.py | 4 +++- .../scripts/templates/operator_modal_timer.py | 1 - source/tests/bl_run_operators.py | 5 ----- 17 files changed, 44 insertions(+), 49 deletions(-) diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index f97e53384b0..612b686b49a 100644 --- a/build_files/buildbot/master_unpack.py +++ b/build_files/buildbot/master_unpack.py @@ -94,11 +94,11 @@ if platform == '': 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 +112,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_pack.py b/build_files/buildbot/slave_pack.py index 74d00bf9249..effe7751915 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -41,12 +41,12 @@ if builder.find('scons') != -1: sys.exit(retcode) # clean release directory if it already exists -dir = 'release' +directory = 'release' -if os.path.exists(dir): - for f in os.listdir(dir): - if os.path.isfile(os.path.join(dir, f)): - os.remove(os.path.join(dir, f)) +if os.path.exists(directory): + for f in os.listdir(directory): + if os.path.isfile(os.path.join(directory, f)): + os.remove(os.path.join(directory, f)) # create release package try: @@ -56,7 +56,7 @@ except Exception, ex: sys.exit(1) # find release directory, must exist this time -if not os.path.exists(dir): +if not os.path.exists(directory): sys.stderr.write("Failed to find release directory.\n") sys.exit(1) @@ -64,8 +64,8 @@ if not os.path.exists(dir): file = None filepath = None -for f in os.listdir(dir): - rf = os.path.join(dir, f) +for f in os.listdir(directory): + rf = os.path.join(directory, f) if os.path.isfile(rf) and f.startswith('blender'): file = f filepath = rf 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/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 cb2349eab1d..b7c52a35fdf 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -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/startup/bl_operators/object_quick_effects.py b/release/scripts/startup/bl_operators/object_quick_effects.py index 73119a6e216..b50bb2dc3cc 100644 --- a/release/scripts/startup/bl_operators/object_quick_effects.py +++ b/release/scripts/startup/bl_operators/object_quick_effects.py @@ -18,7 +18,6 @@ # -import mathutils from mathutils import Vector import bpy from bpy.props import BoolProperty, EnumProperty, IntProperty, FloatProperty, FloatVectorProperty @@ -80,6 +79,7 @@ class MakeFur(bpy.types.Operator): 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 @@ -91,6 +91,7 @@ def obj_bb_minmax(obj, min_co, max_co): 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" @@ -148,8 +149,8 @@ class MakeSmoke(bpy.types.Operator): obj.name = "Smoke Domain" # give the smoke some room above the flows - obj.location = 0.5 * (max_co + min_co) + Vector((0,0,1)) - obj.scale = 0.5 * (max_co - min_co) + Vector((1,1,2)) + 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') @@ -261,8 +262,8 @@ class MakeFluid(bpy.types.Operator): # 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,-1)) + v - obj.scale = 0.5 * (max_co - min_co) + Vector((1,1,2)) + Vector((abs(v[0]), abs(v[1]), abs(v[2]))) + 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') @@ -279,7 +280,7 @@ class MakeFluid(bpy.types.Operator): mat.specular_intensity = 1 mat.specular_hardness = 100 mat.use_transparency = True - mat.alpha = 0 + mat.alpha = 0.0 mat.transparency_method = 'RAYTRACE' mat.raytrace_transparency.ior = 1.33 mat.raytrace_transparency.depth = 4 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..a77ff0ce5e3 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -859,6 +859,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 +869,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 +886,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 09915b03926..014aead3c08 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -889,7 +889,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel): split = layout.split(percentage=0.33) split.label(text="Split uv's:") split.prop(part, "billboard_uv_split", text="Number of splits") - + if psys: col = layout.column() col.active = part.billboard_uv_split > 1 diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 69fe7c3d948..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" diff --git a/release/scripts/templates/operator_modal_timer.py b/release/scripts/templates/operator_modal_timer.py index d8c218f67ea..d2267191cf5 100644 --- a/release/scripts/templates/operator_modal_timer.py +++ b/release/scripts/templates/operator_modal_timer.py @@ -1,5 +1,4 @@ import bpy -from bpy.props import IntProperty, FloatProperty class ModalTimerOperator(bpy.types.Operator): 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') From d4a9bc1c21b7949487a5855d4c6354f0bdc09f47 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 04:22:30 +0000 Subject: [PATCH 221/261] while looking into adding back brush tool keys found mixed texture/image paint rna vars, using 'image paint' internally. --- doc/python_api/sphinx_doc_gen.py | 2 +- release/scripts/startup/bl_operators/wm.py | 8 +- release/scripts/startup/bl_ui/space_image.py | 6 +- .../startup/bl_ui/space_view3d_toolbar.py | 38 ++++----- source/blender/blenkernel/intern/context.c | 2 +- .../editors/interface/interface_icons.c | 4 +- .../blender/editors/screen/screen_context.c | 4 +- .../blender/editors/sculpt_paint/paint_ops.c | 82 +++++++++---------- source/blender/makesrna/RNA_enum_types.h | 4 +- source/blender/makesrna/intern/rna_brush.c | 22 ++--- 10 files changed, 87 insertions(+), 85 deletions(-) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 3eedd658406..fde275c7190 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -461,6 +461,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), @@ -490,7 +491,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/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index a77ff0ce5e3..b0e2ba053dc 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) 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_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 795e73675eb..4636f1da722 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -455,7 +455,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 @@ -619,7 +619,7 @@ 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="") @@ -689,7 +689,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 +701,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 +787,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): @@ -796,7 +796,7 @@ 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 + # image_paint = context.image_paint_object # sculpt = context.sculpt_object col = layout.column(align=True) @@ -804,16 +804,16 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): 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 +826,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 +884,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 +910,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="") @@ -1018,7 +1018,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 +1135,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 +1184,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,7 +1211,7 @@ 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 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/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 03c50d213c1..77757cce61c 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -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/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/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index eb9fbea22f4..b2395173333 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -239,66 +239,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)) @@ -415,7 +415,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/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index d156387eaba..e1e58572c32 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[]; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 06dcaa5441e..2d5dba4b7b1 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"); @@ -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"); From d2a3005dd0dfc583e14e7097ac690adb0ef28bb7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 06:14:39 +0000 Subject: [PATCH 222/261] Add back sculpt mode brush keys. Operator for switching brushes based on type, cycling through brushes when multiple exist. This has the advantages over the old method that it doenst rely on hard coded brush names and if there are multiple brushes of the same type it cycles between them. also fix error in previous commit which broke number buttons changing brushes. --- release/scripts/startup/bl_operators/wm.py | 2 +- .../blender/editors/sculpt_paint/paint_ops.c | 162 ++++++++++++++++++ 2 files changed, 163 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index b0e2ba053dc..ea761d958d0 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -95,7 +95,7 @@ class BRUSH_OT_active_index_set(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'} diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index b2395173333..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); @@ -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"); From 9999c958c8ee6c5923330f80e19128e5f0115ec0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 06:39:19 +0000 Subject: [PATCH 223/261] fix for cmake / windows from mont29 on IRC. --- source/creator/CMakeLists.txt | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index b25cac7bf78..7e30e19a73f 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -547,19 +547,20 @@ elseif(WIN32) ) endif() endif() - - add_custom_command(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND copy /Y \"${LIBDIR}\\thumbhandler\\lib\\BlendThumb64.dll\" \"${TARGETDIR}\\\" - ) - if(NOT CMAKE_CL_64) - add_custom_command(TARGET blender - POST_BUILD - MAIN_DEPENDENCY blender - COMMAND copy /Y \"${LIBDIR}\\thumbhandler\\lib\\BlendThumb.dll\" \"${TARGETDIR}\\\" - ) - 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) From 308f813f3a1e7269e33212d07438d312bc8fcd58 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 06:56:45 +0000 Subject: [PATCH 224/261] workaround for building blender with mingw, was giving syntax error, for now just dont include blender version in the exe for mingw --- source/creator/CMakeLists.txt | 2 +- source/icons/winblender.rc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 7e30e19a73f..1678edcd6a3 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -105,7 +105,7 @@ if(WIN32 AND NOT UNIX) string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2) string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3) add_definitions( - -DBLEN_VER_RC_STR="${BLENDER_VERSION}" + -DBLEN_VER_RC_STR_M=${BLENDER_VERSION} -DBLEN_VER_RC_1=${bver1} -DBLEN_VER_RC_2=${bver2} -DBLEN_VER_RC_3=${bver3} diff --git a/source/icons/winblender.rc b/source/icons/winblender.rc index 244c2cb2e2c..ea9285dbaaf 100644 --- a/source/icons/winblender.rc +++ b/source/icons/winblender.rc @@ -23,8 +23,13 @@ BEGIN BEGIN BLOCK "04090000" BEGIN +#ifdef FREE_WINDOWS // 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)" From 6d3546069c270136856815365883c6490dbff25d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 08:51:12 +0000 Subject: [PATCH 225/261] fix [#26713] Video Sequencer: Audio mute after making meta strip copy/paste was not recursively restoring sound strips on paste. also found many duplicate functions were defining the transform mode as in int but getting as an enum, use enum for both now. --- source/blender/blenkernel/BKE_sequencer.h | 1 + source/blender/blenkernel/intern/sequencer.c | 18 +++++ source/blender/editors/curve/editcurve.c | 5 +- source/blender/editors/mesh/editmesh_add.c | 3 +- source/blender/editors/metaball/mball_edit.c | 3 +- source/blender/editors/object/object_add.c | 2 +- .../blender/editors/render/render_internal.c | 2 +- .../editors/space_action/action_edit.c | 2 +- .../blender/editors/space_graph/graph_edit.c | 2 +- source/blender/editors/space_nla/nla_edit.c | 2 +- .../editors/space_sequencer/sequencer_edit.c | 28 ++------ .../blender/editors/transform/transform_ops.c | 65 ++++++++++--------- source/blender/makesrna/RNA_enum_types.h | 2 + 13 files changed, 70 insertions(+), 65 deletions(-) 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/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 98a982824ba..67d79709c4f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2974,6 +2974,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/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/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index bd094211270..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" @@ -1768,6 +1769,6 @@ void MESH_OT_duplicate(wmOperatorType *ot) ot->poll= 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/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..c5fbc41902f 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1703,7 +1703,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/render/render_internal.c b/source/blender/editors/render/render_internal.c index 39def19aa17..857a36c3029 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -171,7 +171,7 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat float *rf= rectf; char *rc= rectc; float rgb[3]; - const float dither = ibuf->dither / 255.0; + const float dither = ibuf->dither / 255.0f; /* XXX temp. because crop offset */ if( rectc >= (char *)(ibuf->rect)) { 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_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_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_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 48bdcb88618..048581e207e 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*/ @@ -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 */ @@ -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/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 9a78a05dba9..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); @@ -757,38 +790,6 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot) { PropertyRNA *prop; - 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} - }; - /* identifiers */ ot->name = "Transform"; ot->description= "Transform selected items by mode type"; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index e1e58572c32..0bda47b4c7c 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -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[]; From 3556da255a53de6dc1ab4bf3859b5780390063a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 09:00:16 +0000 Subject: [PATCH 226/261] fix for memory leak when freeing metastrips from the clipboard. --- source/blender/blenkernel/intern/sequencer.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 67d79709c4f..8c5696c9a3f 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; } From 94ec34fb044a4f66da3cda7af9e98930e9cfc999 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 11:55:21 +0000 Subject: [PATCH 227/261] xray option for grease pencil (on by default), sometimes its nicer not to have lines draw through the mesh. --- source/blender/editors/gpencil/drawgpencil.c | 36 +++++++++++++++++-- .../blender/editors/gpencil/gpencil_buttons.c | 11 ++++-- source/blender/makesdna/DNA_gpencil_types.h | 2 ++ source/blender/makesrna/intern/rna_gpencil.c | 6 ++++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index a0a815befba..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); } @@ -556,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/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/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index c9cbe9c9e38..d6f13444247 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -235,6 +235,12 @@ 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_data(BlenderRNA *brna) From 2bd22ec559114ac4c2c55cffb207f4661f58e59c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 1 Apr 2011 12:21:41 +0000 Subject: [PATCH 228/261] Animation Editors: Name-based filtering I'm finally yielding to months of feature requesting, and adding support for filtering F-Curves by name, where the "name" here is the text which is displayed for each F-Curve in the Animation Editor channel lists. To use, just enable the magnifying-glass toggle on the DopeSheet filtering settings, and enter a snippet of text to find within the names of channels you wish to filter. This is case insensitive, and currently doesn't support any wildcard/regrex fanciness. Some examples: loc <--- location curves only x loc <--- x location curves only x eul <--- x rotation curves only rot <--- rotation curves only etc. --- .../scripts/startup/bl_ui/space_dopesheet.py | 86 ++++++++++--------- .../blender/editors/animation/anim_filter.c | 45 +++++++++- source/blender/makesdna/DNA_action_types.h | 4 +- source/blender/makesrna/intern/rna_action.c | 12 +++ 4 files changed, 102 insertions(+), 45 deletions(-) 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/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 89f3aa9d337..cca4fdbe331 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -804,7 +804,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) { @@ -876,6 +878,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) { @@ -885,7 +918,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... @@ -897,7 +930,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 */ @@ -906,6 +939,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/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 863d49a40b0..412b9bc56f6 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 */ @@ -554,6 +555,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/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 43f5a0c3ab9..418451801ca 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); From e725f1cf95763e14e052862c992ec25fa1d0cf3a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 1 Apr 2011 12:51:04 +0000 Subject: [PATCH 229/261] Bugfix #26654 A lot of UV tools only work in Image editor, but the operator polls allowed them to be used in 3d window too, causing crashes in cases. Also added a poll() check in F6 redo menu. --- source/blender/editors/uvedit/uvedit_ops.c | 22 +++++++++---------- .../windowmanager/intern/wm_operators.c | 7 +++++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index ec12b997742..e29c34b9092 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -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."); @@ -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; @@ -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; @@ -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."); @@ -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; @@ -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/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a1cfe4a0390..a2000bcedb5 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; } From 00fe87c84bf2d029e006205f078bfe5bf1e3d03e Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 1 Apr 2011 13:56:01 +0000 Subject: [PATCH 230/261] Bugfix #26672 Minor glitch: Add Camera operator showed option "view aligned", but that doesn't work for camera. Is now hidden. --- source/blender/editors/object/object_add.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index c5fbc41902f..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); + } From a4193184bf52b338df2d25fdf7fefed2be55bbb1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 14:04:26 +0000 Subject: [PATCH 231/261] - bpy.app.release so python scripts can check if the release is stable or not. - edited pose bone matrix description. --- source/blender/makesrna/intern/rna_pose.c | 2 +- source/blender/python/intern/bpy_app.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index d59d87c14b9..bfd5956dc65 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -59,6 +59,7 @@ 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 *)"release", (char *)"The release status of this build alpha/beta/rc/stable"}, {(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 +104,7 @@ 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_CYCLE)); SetStrItem(bprogname); SetObjItem(PyBool_FromLong(G.background)); From b94a5e7f02a07e13d3ad559ddef464086a447ae8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 14:14:37 +0000 Subject: [PATCH 232/261] fix problem with recent commit [#26717] X-Ray conflict (X-Ray Grease Pencil and Object X-Ray) --- .../editors/space_view3d/view3d_draw.c | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) 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); } From 339c6c4a511f6c6f9384e2b39d9f6b5396e2d4ee Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 1 Apr 2011 15:08:45 +0000 Subject: [PATCH 233/261] Bugfix #26691 "Theme default" missed a couple of new colors still. --- source/blender/editors/interface/resources.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index ef9da932dd8..1a2a2906f1a 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -561,6 +561,7 @@ 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); @@ -601,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); From 3ddbb36fa7233acaeefadadaf03fe4e0fff9e568 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Apr 2011 15:13:58 +0000 Subject: [PATCH 234/261] modification to api docs so release point to: http://www.blender.org/documentation/blender_python_api_2_57b_release Development versions point to: http://www.blender.org/documentation/blender_python_api_2_57_0 This way updates to api docs after release wont overwrite release docs. --- doc/python_api/sphinx_doc_gen.sh | 14 +++++++++++--- release/scripts/startup/bl_operators/wm.py | 5 ++++- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/python/intern/bpy_app.c | 4 +++- 4 files changed, 19 insertions(+), 6 deletions(-) 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/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index ea761d958d0..e6018c185a0 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -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 = [] diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index abae185a645..f222db71455 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -52,7 +52,7 @@ 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 */ + /* alpha/beta/rc/release, docs use this */ #define BLENDER_VERSION_CYCLE rc struct ListBase; diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index bfd5956dc65..99b20167dba 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -59,7 +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 *)"release", (char *)"The release status of this build alpha/beta/rc/stable"}, + {(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)"}, @@ -104,6 +105,7 @@ 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)); From 18fd4d3137db8756c85d4cc8593e52aac2939970 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 1 Apr 2011 16:01:29 +0000 Subject: [PATCH 235/261] Partial fix for #26673: sss + normal map wasn't compatible with previous versions. --- source/blender/render/intern/source/occlusion.c | 1 + source/blender/render/intern/source/rendercore.c | 1 + 2 files changed, 2 insertions(+) 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 From d40b0dfb758eb45027ba7b9b4fc4e9477f201480 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 1 Apr 2011 18:35:49 +0000 Subject: [PATCH 236/261] Comments for mesh normals calculation from Mortem Mikkelsen (aka sparky). We hope it'll help for further workers in this area! --- source/blender/blenkernel/intern/mesh.c | 2 ++ source/blender/editors/mesh/editmesh_lib.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 6f528ec3ea8..7302abe8968 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1301,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; diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index e63ce98c1b0..d3945a53f0d 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -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; From 367cf47dd68f210eeaf9ba6b51a1fdbcf93d209b Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 1 Apr 2011 20:36:27 +0000 Subject: [PATCH 237/261] 2.5 UI: *Brush option "size" had different naming in 3D View / Image Editor. Ported back name "Radius" to RNA (Brush and ParticleBrush) Discovered by Bart Crouch. Thanks! --- release/scripts/startup/bl_ui/space_view3d_toolbar.py | 8 ++++---- source/blender/makesrna/intern/rna_brush.c | 2 +- source/blender/makesrna/intern/rna_sculpt_paint.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 4636f1da722..a4b3b9a5f21 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -522,7 +522,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="") @@ -625,7 +625,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) @@ -650,7 +650,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 +668,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) diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 2d5dba4b7b1..09577fdf067 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -430,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); 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); From 485229b7db0888e8f6e504ee41f159bd45fd42a9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 1 Apr 2011 21:22:19 +0000 Subject: [PATCH 238/261] Initial support of linux 32/64 bit for buildbot: - Use the same config as we're using for release builds - Added stipping (maybe it should be generalized) - Not software gl packing, bot would be easy to add Note, that you should have special environment to create proper linux builts (which would work for everybody) --- .../buildbot/config/user-config-i686.py | 85 +++++++++++++++++++ .../config/user-config-player-i686.py | 65 ++++++++++++++ .../config/user-config-player-x86_64.py | 65 ++++++++++++++ .../buildbot/config/user-config-x86_64.py | 85 +++++++++++++++++++ build_files/buildbot/slave_compile.py | 66 +++++++++++++- build_files/buildbot/slave_pack.py | 52 +++++++++--- build_files/scons/tools/btools.py | 12 ++- 7 files changed, 417 insertions(+), 13 deletions(-) create mode 100644 build_files/buildbot/config/user-config-i686.py create mode 100644 build_files/buildbot/config/user-config-player-i686.py create mode 100644 build_files/buildbot/config/user-config-player-x86_64.py create mode 100644 build_files/buildbot/config/user-config-x86_64.py 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/slave_compile.py b/build_files/buildbot/slave_compile.py index 54150a93e61..ab9b9a61fbc 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -56,5 +56,67 @@ else: os.chdir(blender_dir) 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(['python', 'scons/scons.py'] + 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(['python', 'scons/scons.py'] + 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 effe7751915..28225b62b35 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -37,16 +37,48 @@ 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] + + 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) + + retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) + if retcode == 0: + blender = os.path.join(install_dir, 'blender') + blenderplayer = os.path.join(install_dir, 'blenderplayer') + + subprocess.call(['strip', '--strip-all', blender, blenderplayer]) + + sys.exit(retcode) + else: + retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) + sys.exit(retcode) # clean release directory if it already exists -directory = 'release' +dir = 'release' -if os.path.exists(directory): - for f in os.listdir(directory): - if os.path.isfile(os.path.join(directory, f)): - os.remove(os.path.join(directory, f)) +if os.path.exists(dir): + for f in os.listdir(dir): + if os.path.isfile(os.path.join(dir, f)): + os.remove(os.path.join(dir, f)) # create release package try: @@ -56,7 +88,7 @@ except Exception, ex: sys.exit(1) # find release directory, must exist this time -if not os.path.exists(directory): +if not os.path.exists(dir): sys.stderr.write("Failed to find release directory.\n") sys.exit(1) @@ -64,8 +96,8 @@ if not os.path.exists(directory): file = None filepath = None -for f in os.listdir(directory): - rf = os.path.join(directory, f) +for f in os.listdir(dir): + rf = os.path.join(dir, f) if os.path.isfile(rf) and f.startswith('blender'): file = f filepath = rf diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 69bb42264e5..2d8c9276ba1 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -545,8 +545,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) From c729c1a9970b981611015bc07e3b77cd21601c44 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 1 Apr 2011 21:37:40 +0000 Subject: [PATCH 239/261] 3D View Toolbar: * Code cleanup --- .../startup/bl_ui/space_view3d_toolbar.py | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index a4b3b9a5f21..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 **************** @@ -795,9 +789,6 @@ class VIEW3D_PT_tools_brush_tool(PaintPanel, bpy.types.Panel): settings = __class__.paint_settings(context) brush = settings.brush - ## Unused - # image_paint = context.image_paint_object - # sculpt = context.sculpt_object col = layout.column(align=True) @@ -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): @@ -1215,10 +1200,10 @@ class VIEW3D_PT_imagepaint_options(PaintPanel): 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") From 6d4f57bc3a7029479b28e97d9466bff0cc6b87a5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 1 Apr 2011 21:38:04 +0000 Subject: [PATCH 240/261] Oops, i've forgot that archive is preparing by scons, so stripping should happpen before calling scons (hope, binaries wouldn't be overwritten by it) --- build_files/buildbot/slave_pack.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py index 28225b62b35..7b62864fa98 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -60,13 +60,11 @@ if builder.find('scons') != -1: 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) - if retcode == 0: - blender = os.path.join(install_dir, 'blender') - blenderplayer = os.path.join(install_dir, 'blenderplayer') - - subprocess.call(['strip', '--strip-all', blender, blenderplayer]) - sys.exit(retcode) else: retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) From 1f7ed6a931ef3298fa70e9af53771813acc23e49 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 1 Apr 2011 22:19:03 +0000 Subject: [PATCH 241/261] 2.5 Weight Paint UI: * Added menu entry for "Set Weight" Tool. Request by venomgfx :) --- release/scripts/startup/bl_ui/space_view3d.py | 4 ++++ source/blender/editors/sculpt_paint/paint_vertex.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index d5930c3d14c..c83affef0e8 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1052,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 ********** 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 */ From 3f6158eedc5657917972ba70f1a3038104a4f066 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 1 Apr 2011 22:41:02 +0000 Subject: [PATCH 242/261] 2.5 Particle UI: * Missing colon and not worth a commit message ;-) --- release/scripts/startup/bl_ui/properties_particle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 014aead3c08..df464ed7fb0 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -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:") From fb994b3c857bdf3a7313da046580c0fb76e8b620 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Apr 2011 01:36:40 +0000 Subject: [PATCH 243/261] fix [#26727] Make Proxy ignores group offset --- source/blender/blenkernel/intern/object.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ca31cd1b0b1..56a209eca60 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1563,6 +1563,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 { @@ -2556,6 +2559,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); From 69bd72c3b6aa1fdaab0c1232a6ba1e3e4c9029fa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Apr 2011 02:08:33 +0000 Subject: [PATCH 244/261] quiet gcc float -> double promotion warnings. --- source/blender/blenkernel/intern/boids.c | 26 +++---- source/blender/blenkernel/intern/effect.c | 12 ++-- source/blender/blenkernel/intern/fmodifier.c | 6 +- source/blender/blenkernel/intern/node.c | 2 +- source/blender/blenkernel/intern/particle.c | 4 +- .../blenkernel/intern/particle_system.c | 8 +-- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/seqeffects.c | 4 +- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/sound.c | 2 +- source/blender/blenlib/intern/freetypefont.c | 58 +++++++-------- source/blender/gpu/intern/gpu_material.c | 10 +-- .../blender/render/intern/include/texture.h | 18 ++--- .../render/intern/source/imagetexture.c | 70 +++++++++---------- .../blender/windowmanager/intern/wm_gesture.c | 2 +- .../windowmanager/intern/wm_operators.c | 4 +- 16 files changed, 115 insertions(+), 115 deletions(-) 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/effect.c b/source/blender/blenkernel/intern/effect.c index 9cca5ae4982..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 */ @@ -705,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]); } @@ -931,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/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/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/particle.c b/source/blender/blenkernel/intern/particle.c index 5c1c8eae622..e96dc638a88 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -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); @@ -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); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 2fe7f42abe3..13f5d619daa 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -659,7 +659,7 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount) if(num==0) return; - rad1= (float)(1.0f/sqrt((float)num)); + rad1= (float)(1.0f/sqrtf((float)num)); rad2= (float)(1.0f/((float)num)); rad3= (float)sqrt((float)num)/((float)num); @@ -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); } @@ -2334,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; @@ -2658,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)) { 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 e6360620048..3dfef2e9d78 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -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; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 8c5696c9a3f..7a6eb1adc9f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1029,7 +1029,7 @@ static float give_stripelem_index(Sequence *seq, float cfra) if (seq->strobe < 1.0f) seq->strobe = 1.0f; if (seq->strobe > 1.0f) { - nr -= fmod((double)nr, (double)seq->strobe); + nr -= fmodf((double)nr, (double)seq->strobe); } return nr; 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/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/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/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/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index e5afc492c61..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; @@ -544,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; } @@ -559,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; } @@ -579,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; @@ -591,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; @@ -964,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; @@ -1100,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 @@ -1486,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; @@ -1552,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); } } @@ -1603,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); @@ -1694,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 { 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_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a2000bcedb5..8f10b164f8f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2766,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; } From f1b42a129f0f9299a9e67eb0495131a37464c9cc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Apr 2011 03:05:49 +0000 Subject: [PATCH 245/261] add angle wrapping functions: angle_wrap_rad(), angle_wrap_deg(). use with mathutils. --- source/blender/blenlib/BLI_math_rotation.h | 3 +++ source/blender/blenlib/intern/math_rotation.c | 16 ++++++++++++++++ source/blender/python/generic/mathutils_Matrix.c | 3 +-- .../python/generic/mathutils_Quaternion.c | 4 ++-- 4 files changed, 22 insertions(+), 4 deletions(-) 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/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/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 */ From 7690086d20c58872659da30e1ee7ebf404681f46 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 2 Apr 2011 05:53:42 +0000 Subject: [PATCH 246/261] pep8 fixes for buildbot --- build_files/buildbot/master_unpack.py | 7 +++++-- build_files/buildbot/slave_compile.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index 612b686b49a..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,7 +92,8 @@ 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 diff --git a/build_files/buildbot/slave_compile.py b/build_files/buildbot/slave_compile.py index ab9b9a61fbc..e6dd4840bd6 100644 --- a/build_files/buildbot/slave_compile.py +++ b/build_files/buildbot/slave_compile.py @@ -54,6 +54,7 @@ if builder.find('cmake') != -1: else: # scons os.chdir(blender_dir) + scons_cmd = ['python', 'scons/scons.py'] scons_options = [] if builder.startswith('linux'): @@ -79,7 +80,7 @@ else: 'BF_INSTALLDIR=' + install_dir] # Clean all directories first - retcode = subprocess.call(['python', 'scons/scons.py'] + common_options + ['clean']) + retcode = subprocess.call(scons_cmd + common_options + ['clean']) if retcode != 0: print('Error cleaning build directory') sys.exit(retcode) @@ -111,7 +112,7 @@ else: scons_options.append('BF_CONFIG=' + config_fpath) - retcode = subprocess.call(['python', 'scons/scons.py'] + scons_options) + retcode = subprocess.call(scons_cmd + scons_options) if retcode != 0: print('Error building rules wuth config ' + config) sys.exit(retcode) From 3bc59fe77130a6975c85d8be8606cb289d5b1e55 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Apr 2011 07:04:34 +0000 Subject: [PATCH 247/261] fix [#26732] Colorband bug with compositing. reported on IRC but submitted to the tracker for example file reference. --- source/blender/blenkernel/intern/texture.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index e8c4a21d041..5dbaee2a7b8 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -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 */ From d85279e58cf075beb30d74f267cba8a31a3bedcb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Apr 2011 11:06:41 +0000 Subject: [PATCH 248/261] move grese pencil layers[i].active (boolean) -> layers.active (GPencil Layer). --- source/blender/makesrna/intern/rna_gpencil.c | 94 ++++++++++++++++---- 1 file changed, 77 insertions(+), 17 deletions(-) diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index d6f13444247..c5d413b0c49 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"); @@ -243,6 +267,41 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) 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) { StructRNA *srna; @@ -265,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); @@ -284,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); From a5804c2e609c11877fa883e5178a9c9386736311 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 2 Apr 2011 12:54:17 +0000 Subject: [PATCH 249/261] [#26719] Fix AAO Tooltips by Sergej Reich (sergof). Thanks! --- release/scripts/startup/bl_operators/image.py | 2 +- source/blender/makesrna/intern/rna_world.c | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 65e0d5a52db..462db3a2c5e 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -112,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'} 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 - From 6a841ef3a1210a9a102b6bbf7ae107e0e7a38d9e Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 2 Apr 2011 13:18:33 +0000 Subject: [PATCH 250/261] Readme.html and Link to Release Log: * Ready for release! Note: JesterKing: Release notes now point to http://www.blender.org/development/release-logs/blender-257/ Would be cool, if we can use that one. --- release/scripts/startup/bl_ui/space_info.py | 2 +- release/text/readme.html | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) 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/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
From 89dea61c174e0dbb871385a2e9bf3eab5a4d4df3 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 2 Apr 2011 14:11:13 +0000 Subject: [PATCH 251/261] Bugfix #26731 Hotkey operator "Toggle full screen layout" restored previous layout wrongly when mouse in was top header. --- source/blender/editors/screen/screen_ops.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index bff92df430c..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; } From 371a7b477d0b40da8859cf25691c53371365f8e5 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sat, 2 Apr 2011 14:58:58 +0000 Subject: [PATCH 252/261] Fix register method order. Was broken when Campbell moved it to the C implementation. register has to be called AFTER the type is registered while unregister has to be called BEFORE it's unregistered. --- source/blender/python/intern/bpy_rna.c | 33 +++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 29f05369f44..add088d181a 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -6189,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(); @@ -6238,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; } @@ -6299,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(); From b85013e1ec89f4bf4ed138ebcd13076883a1abcb Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 2 Apr 2011 15:30:58 +0000 Subject: [PATCH 253/261] Bugfix #26736 Operator "New Image" cannot be redone simply, undo system keeps images around, and each redo will create new block. Removed it from being registered for redos. Also: fix up for default operator names to be complete, and not just "new" or "load". If we want contextual shortening of operator names (like in Image menu), that should be handled seprately, automatically, or anything we can sanely come up with that will suit any possible language as well. --- .../blender/editors/space_image/image_ops.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 */ From 447c73d639f9de776815634e27334cecbef397dd Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 2 Apr 2011 16:29:33 +0000 Subject: [PATCH 254/261] IRC report: Proportional editing tooltip lacked, and missed info for the menu items. --- source/blender/makesrna/intern/rna_scene.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 92a2828495e..8ebb71c33d0 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -78,9 +78,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 */ @@ -1087,7 +1087,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); From 2c3b4a91dcfcafb94eb964ab3f02d02f46d1a059 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 2 Apr 2011 16:45:17 +0000 Subject: [PATCH 255/261] Committing patch [#26740] Interface improvement for toolbar by Brecht. Thanks! This patch makes the bool properties inside the toolshelf more compact, only 1 row per item now. :) --- .../editors/interface/interface_utils.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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; From 90326c4c6e6c312ac4bf97dc443c32c8c0206ec6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 2 Apr 2011 21:11:22 +0000 Subject: [PATCH 256/261] buildbot: - Remove packed to buildbot_archive.zip archive file to keep scons install directory as clean as possible (if i understood correct, this file isn't actually needed in the future, so we could remove it just after packing rather than cleaning install directory before packing as it's done for cmake) - No need in scripts installation for linux slaves when preparing archive --- build_files/buildbot/slave_pack.py | 3 ++- build_files/scons/tools/btools.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py index 7b62864fa98..81402b3aca4 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -47,7 +47,8 @@ if builder.find('scons') != -1: scons_options += ['WITH_BF_NOBLENDER=True', 'WITH_BF_PLAYER=False', 'BF_BUILDDIR=' + build_dir, - 'BF_INSTALLDIR=' + install_dir] + 'BF_INSTALLDIR=' + install_dir, + 'WITHOUT_BF_INSTALL=True'] config = None diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index 2d8c9276ba1..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): From 21bd7fd8d5fb908674efcb8528f2d4a7064ea948 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Apr 2011 21:51:05 +0000 Subject: [PATCH 257/261] patch [#26606] Debian spec: Bump to Python 3.2 also update pacman spec. --- build_files/package_spec/debian/control | 4 ++-- build_files/package_spec/debian/rules | 5 ++++- build_files/package_spec/pacman/PKGBUILD | 8 ++++---- 3 files changed, 10 insertions(+), 7 deletions(-) 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=() From 5c8234c81caf72b4424571e958be3337a6900fc7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 3 Apr 2011 05:29:58 +0000 Subject: [PATCH 258/261] replace while loops with angle_wrap_rad() --- source/blender/editors/transform/transform.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index f1f49a6d88b..43e0af53ec6 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -3178,15 +3178,9 @@ 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.0f) - final -= 360.0f; - - while (final <= -180.0f) - final += 360.0f; - final = DEG2RADF(final); + /* Clamp between -180 and 180 */ + final= angle_wrap_rad(DEG2RADF(final)); } else { sprintf(str, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext); From 744a3b9cb26a734487264eec3e9e6dacb28daa73 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 3 Apr 2011 07:48:33 +0000 Subject: [PATCH 259/261] fix cmake for when BLENDER_VERSION_CHAR is not set. --- build_files/cmake/macros.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 4a9c55d81cd..24dc058c4b0 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -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() From 0298d223cc1156df3a32fbb3a97dccf5ddb5ad02 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 3 Apr 2011 10:04:16 +0000 Subject: [PATCH 260/261] quiet various warnings, also disable -Wdouble-promotion with cmake since it gives warnings with variable length args. --- CMakeLists.txt | 3 +- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenlib/BLI_utildefines.h | 2 +- .../editors/interface/interface_icons.c | 10 ++--- .../blender/editors/physics/physics_fluid.c | 2 +- .../blender/editors/space_action/action_ops.c | 3 +- .../blender/editors/space_graph/graph_ops.c | 1 + .../editors/space_sequencer/sequencer_edit.c | 40 +++++++++---------- .../space_sequencer/sequencer_scopes.c | 16 ++++---- .../editors/space_view3d/view3d_view.c | 2 +- source/blender/gpu/intern/gpu_draw.c | 8 ++-- .../blender/makesrna/intern/rna_constraint.c | 8 ++-- source/blender/makesrna/intern/rna_define.c | 4 +- source/blender/makesrna/intern/rna_gpencil.c | 4 +- source/blender/makesrna/intern/rna_wm_api.c | 2 +- source/blender/modifiers/intern/MOD_explode.c | 4 +- .../blender/nodes/intern/TEX_nodes/TEX_at.c | 3 +- .../nodes/intern/TEX_nodes/TEX_bricks.c | 4 +- .../nodes/intern/TEX_nodes/TEX_checker.c | 3 +- .../nodes/intern/TEX_nodes/TEX_compose.c | 3 +- .../nodes/intern/TEX_nodes/TEX_coord.c | 1 + .../nodes/intern/TEX_nodes/TEX_curves.c | 1 + .../nodes/intern/TEX_nodes/TEX_decompose.c | 3 +- .../nodes/intern/TEX_nodes/TEX_distance.c | 1 + .../nodes/intern/TEX_nodes/TEX_hueSatVal.c | 1 + .../nodes/intern/TEX_nodes/TEX_image.c | 1 + .../nodes/intern/TEX_nodes/TEX_invert.c | 1 + .../blender/nodes/intern/TEX_nodes/TEX_math.c | 2 +- .../nodes/intern/TEX_nodes/TEX_mixRgb.c | 1 + .../nodes/intern/TEX_nodes/TEX_output.c | 1 + .../blender/nodes/intern/TEX_nodes/TEX_proc.c | 2 + .../nodes/intern/TEX_nodes/TEX_rotate.c | 1 + .../nodes/intern/TEX_nodes/TEX_texture.c | 2 + .../nodes/intern/TEX_nodes/TEX_translate.c | 1 + .../nodes/intern/TEX_nodes/TEX_valToNor.c | 1 + .../nodes/intern/TEX_nodes/TEX_valToRgb.c | 1 + .../nodes/intern/TEX_nodes/TEX_viewer.c | 3 +- source/blender/python/intern/bpy_rna.h | 3 ++ source/blender/python/intern/bpy_rna_anim.c | 1 + 39 files changed, 90 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15a5071accc..b2243e6bd74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1059,7 +1059,8 @@ if(CMAKE_COMPILER_IS_GNUCC) 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) - ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion) + # 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) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 1c6221eba8b..2708239a4c3 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1851,7 +1851,7 @@ void nladata_flush_channels (ListBase *channels) * ! 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 */ -void animsys_evaluate_nla (ListBase *echannels, 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; 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/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 77757cce61c..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) 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/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_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_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 048581e207e..115d1ad7bae 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -337,7 +337,7 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, short mval[2]) } seq= seq->next; } - return 0; + return NULL; } @@ -461,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); @@ -479,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); @@ -497,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" @@ -590,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; @@ -604,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; @@ -617,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; @@ -626,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) { @@ -722,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 */ @@ -816,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 */ @@ -2013,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); diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 49ad1e2825c..b617d012237 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -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,7 +213,7 @@ 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); @@ -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; @@ -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); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index d6ed9752d03..8f8b46d07ad 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1696,7 +1696,7 @@ static void RestoreState(bContext *C, wmWindow *win) } /* was space_set_commmandline_options in 2.4x */ -void game_set_commmandline_options(GameData *gm) +static void game_set_commmandline_options(GameData *gm) { SYS_SystemHandle syshandle; int test; 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/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 c5d413b0c49..228b00e7937 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -272,8 +272,8 @@ static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; PropertyRNA *prop; - FunctionRNA *func; - PropertyRNA *parm; +// FunctionRNA *func; +// PropertyRNA *parm; RNA_def_property_srna(cprop, "GreasePencilLayers"); srna= RNA_def_struct(brna, "GreasePencilLayers", NULL); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 92311641d98..5a0708865b6 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -81,7 +81,7 @@ struct wmTimer *rna_event_timer_add(struct wmWindowManager *wm, float time_step, void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer) { - return WM_event_remove_timer(wm, timer->win, timer); + WM_event_remove_timer(wm, timer->win, timer); } #else 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/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 305d7094f57..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[]= { 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 70c5d25e1eb..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[]= { 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 1652ba10e48..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 ******************** */ 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 30b5aee7832..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[]= { 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 8f7793ddaaf..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}, 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/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 From 5932cec2c6fa39a755f684b1e6de6a8a39072de6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 3 Apr 2011 12:31:53 +0000 Subject: [PATCH 261/261] temp fix for building with msvc2010, this changes recently and gave mingw/msvc2010 troubles --- source/icons/winblender.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/icons/winblender.rc b/source/icons/winblender.rc index ea9285dbaaf..d1b67725b57 100644 --- a/source/icons/winblender.rc +++ b/source/icons/winblender.rc @@ -23,7 +23,7 @@ BEGIN BEGIN BLOCK "04090000" BEGIN -#ifdef FREE_WINDOWS // this doesnt work for mingw. +#if defined(FREE_WINDOWS) || !defined(WINDRES) // this doesnt work for mingw. VALUE "FileVersion", "Unknown" VALUE "ProductVersion", "Unknown" #else