diff --git a/CMakeLists.txt b/CMakeLists.txt index e83b5528d63..d4db5bef349 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,6 +180,10 @@ option(WITH_API_INSTALL "Copy API header files into the blender install fold # Cycles option(WITH_CYCLES "Enable Cycles Render Engine" ON) +# disable for now, but plan to support on all platforms eventually +option(WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF) +mark_as_advanced(WITH_MEM_JEMALLOC) + # Debug option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF) mark_as_advanced(WITH_CXX_GUARDEDALLOC) @@ -203,9 +207,6 @@ if(APPLE) option(WITH_LIBS10.5 "Use 10.5 libs (needed for 64bit builds)" OFF) endif() -# only for developers who want to make this functional -# option(WITH_LCMS "Enable color correction with lcms" OFF) - if(NOT WITH_GAMEENGINE AND WITH_PLAYER) message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE") endif() @@ -380,13 +381,6 @@ if(UNIX AND NOT APPLE) find_package(ZLIB REQUIRED) - if(WITH_LCMS) - set(LCMS /usr CACHE FILEPATH "LCMS directory") - set(LCMS_INCLUDE_DIR ${LCMS}/include) - set(LCMS_LIBRARY lcms) - set(LCMS_LIBPATH ${LCMS}/lib) - endif() - if(WITH_CODEC_FFMPEG) set(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory") mark_as_advanced(FFMPEG) @@ -429,6 +423,15 @@ if(UNIX AND NOT APPLE) set(EXPAT_LIB expat) endif() + if(WITH_MEM_JEMALLOC) + set(JEMALLOC /usr) + set(JEMALLOC_LIBRARY jemalloc CACHE STRING "JeMalloc library") + set(JEMALLOC_LIBPATH ${JEMALLOC}/lib CACHE FILEPATH "JeMalloc library path") + # no use for this yet. + # set(JEMALLOC_INCLUDE_DIR ${JEMALLOC}/include CACHE FILEPATH "JeMalloc include path") + unset(JEMALLOC) + endif() + find_package(X11 REQUIRED) find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH}) mark_as_advanced(X11_XF86keysym_INCLUDE_PATH) @@ -632,14 +635,7 @@ elseif(WIN32) set(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa UTF) set(PCRE_LIB pcre) endif() - - if(WITH_LCMS) - set(LCMS ${LIBDIR}/lcms) - set(LCMS_INCLUDE_DIR ${LCMS}/include) - set(LCMS_LIBPATH ${LCMS}/lib) - set(LCMS_LIB lcms) - endif() - + if(WITH_CODEC_FFMPEG) set(FFMPEG ${LIBDIR}/ffmpeg) set(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc) @@ -875,7 +871,7 @@ elseif(APPLE) set(GETTEXT_LIB intl iconv) set(GETTEXT_LIBPATH ${GETTEXT}/lib) endif() - + if(WITH_FFTW3) set(FFTW3 ${LIBDIR}/fftw3) set(FFTW3_INC ${FFTW3}/include) @@ -902,13 +898,6 @@ elseif(APPLE) set(OPENEXR_LIBPATH ${OPENEXR}/lib) endif() - if(WITH_LCMS) - set(LCMS ${LIBDIR}/lcms) - set(LCMS_INCLUDE_DIR ${LCMS}/include) - set(LCMS_LIBRARY lcms) - set(LCMS_LIBPATH ${LCMS}/lib) - endif() - if(WITH_CODEC_FFMPEG) set(FFMPEG ${LIBDIR}/ffmpeg) set(FFMPEG_INC ${FFMPEG}/include) diff --git a/SConstruct b/SConstruct index 954422e0b3d..e928970f6b8 100644 --- a/SConstruct +++ b/SConstruct @@ -568,9 +568,10 @@ pluglist.append('source/blender/blenpluginapi/plugin.DEF') plugtargetlist.append(os.path.join(env['BF_INSTALLDIR'], VERSION, 'plugins', 'include', 'plugin.def')) plugininstall = [] -for targetdir,srcfile in zip(plugtargetlist, pluglist): - td, tf = os.path.split(targetdir) - plugininstall.append(env.Install(dir=td, source=srcfile)) +# plugins in blender 2.5 don't work at the moment. +#for targetdir,srcfile in zip(plugtargetlist, pluglist): +# td, tf = os.path.split(targetdir) +# plugininstall.append(env.Install(dir=td, source=srcfile)) textlist = [] texttargetlist = [] diff --git a/build_files/buildbot/config/user-config-i686.py b/build_files/buildbot/config/user-config-i686.py index de8dd93982f..7c7e779bdb2 100644 --- a/build_files/buildbot/config/user-config-i686.py +++ b/build_files/buildbot/config/user-config-i686.py @@ -74,6 +74,12 @@ WITH_BF_BULLET = True # Blender player (would be enabled in it's own config) WITH_BF_PLAYER = False +# Use jemalloc memory manager +WITH_BF_JEMALLOC = True +WITH_BF_STATICJEMALLOC = True +BF_JEMALLOC = '/home/sources/staticlibs/jemalloc' +BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib32' + # Compilation and optimization BF_DEBUG = False REL_CFLAGS = ['-O2'] diff --git a/build_files/buildbot/config/user-config-player-i686.py b/build_files/buildbot/config/user-config-player-i686.py index 202c7df6f98..241f5a79983 100644 --- a/build_files/buildbot/config/user-config-player-i686.py +++ b/build_files/buildbot/config/user-config-player-i686.py @@ -59,6 +59,12 @@ WITH_BF_BULLET = True WITH_BF_NOBLENDER = True WITH_BF_PLAYER = True +# Use jemalloc memory manager +WITH_BF_JEMALLOC = True +WITH_BF_STATICJEMALLOC = True +BF_JEMALLOC = '/home/sources/staticlibs/jemalloc' +BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib32' + # Compilation and optimization BF_DEBUG = False REL_CFLAGS = ['-O2'] diff --git a/build_files/buildbot/config/user-config-player-x86_64.py b/build_files/buildbot/config/user-config-player-x86_64.py index 363997143e5..d51894b26cf 100644 --- a/build_files/buildbot/config/user-config-player-x86_64.py +++ b/build_files/buildbot/config/user-config-player-x86_64.py @@ -59,6 +59,12 @@ WITH_BF_BULLET = True WITH_BF_NOBLENDER = True WITH_BF_PLAYER = True +# Use jemalloc memory manager +WITH_BF_JEMALLOC = True +WITH_BF_STATICJEMALLOC = True +BF_JEMALLOC = '/home/sources/staticlibs/jemalloc' +BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib64' + # Compilation and optimization BF_DEBUG = False REL_CFLAGS = ['-O2'] diff --git a/build_files/buildbot/config/user-config-x86_64.py b/build_files/buildbot/config/user-config-x86_64.py index 7bae2d232cd..04489c7d06c 100644 --- a/build_files/buildbot/config/user-config-x86_64.py +++ b/build_files/buildbot/config/user-config-x86_64.py @@ -74,6 +74,12 @@ WITH_BF_BULLET = True # Blender player (would be enabled in it's own config) WITH_BF_PLAYER = False +# Use jemalloc memory manager +WITH_BF_JEMALLOC = True +WITH_BF_STATICJEMALLOC = True +BF_JEMALLOC = '/home/sources/staticlibs/jemalloc' +BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib64' + # Compilation and optimization BF_DEBUG = False REL_CFLAGS = ['-O2'] diff --git a/build_files/cmake/cmake_netbeans_project.py b/build_files/cmake/cmake_netbeans_project.py new file mode 100755 index 00000000000..c8bedb55148 --- /dev/null +++ b/build_files/cmake/cmake_netbeans_project.py @@ -0,0 +1,230 @@ +#!/usr/bin/env python + +# $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): Campbell Barton, M.G. Kishalmi +# +# ***** END GPL LICENSE BLOCK ***** + +# + +""" +Example linux usage + python .~/blenderSVN/blender/build_files/cmake/cmake_netbeans_project.py ~/blenderSVN/cmake + +Windows not supported so far +""" + +from project_info import * + +import os +from os.path import join, dirname, normpath, abspath, splitext, relpath, exists + + +def create_nb_project_main(): + files = list(source_list(SOURCE_DIR, filename_check=is_project_file)) + files_rel = [relpath(f, start=PROJECT_DIR) for f in files] + files_rel.sort() + + if SIMPLE_PROJECTFILE: + pass + else: + includes, defines = cmake_advanced_info() + # for some reason it doesnt give all internal includes + includes = list(set(includes) | set(dirname(f) for f in files if is_c_header(f))) + includes.sort() + + PROJECT_NAME = "Blender" + FILE_NAME = PROJECT_NAME.lower() + + # --------------- NB spesific + defines = [("%s=%s" % cdef) if cdef[1] else cdef[0] for cdef in defines] + defines += [cdef.replace("#define", "").strip() for cdef in cmake_compiler_defines()] + + def file_list_to_nested(files): + # convert paths to hierarchy + paths_nested = {} + + def ensure_path(filepath): + filepath_split = filepath.split(os.sep) + + pn = paths_nested + for subdir in filepath_split[:-1]: + pn = pn.setdefault(subdir, {}) + pn[filepath_split[-1]] = None + + for path in files: + ensure_path(path) + return paths_nested + + PROJECT_DIR_NB = join(PROJECT_DIR, "nbproject") + if not exists(PROJECT_DIR_NB): + os.mkdir(PROJECT_DIR_NB) + + SOURCE_DIR_REL = relpath(SOURCE_DIR, PROJECT_DIR) + + f = open(join(PROJECT_DIR_NB, "project.xml"), 'w') + + f.write('\n') + f.write('\n') + f.write(' org.netbeans.modules.cnd.makeproject\n') + f.write(' \n') + f.write(' \n') + f.write(' %s\n' % PROJECT_NAME) + f.write(' c,m\n') + f.write(' cpp,mm\n') + f.write(' h,hpp,inl\n') + f.write(' UTF-8\n') + f.write(' \n') + f.write(' \n') + f.write(' %s\n' % SOURCE_DIR) # base_root_rel + f.write(' \n') + f.write(' \n') + f.write(' \n') + f.write(' Default\n') + f.write(' 0\n') + f.write(' \n') + f.write(' \n') + f.write(' \n') + f.write(' \n') + f.write('\n') + + f = open(join(PROJECT_DIR_NB, "configurations.xml"), 'w') + + f.write('\n') + f.write('\n') + f.write(' \n') + f.write(' \n' % SOURCE_DIR) # base_root_rel + + # write files! + files_rel_local = [normpath(relpath(join(CMAKE_DIR, path), SOURCE_DIR)) for path in files_rel] + files_rel_hierarchy = file_list_to_nested(files_rel_local) + # print(files_rel_hierarchy) + + def write_df(hdir, ident): + dirs = [] + files = [] + for key, item in sorted(hdir.items()): + if item is None: + files.append(key) + else: + dirs.append((key, item)) + + for key, item in dirs: + f.write('%s \n' % (ident, key)) + write_df(item, ident + " ") + f.write('%s \n' % ident) + + for key in files: + f.write('%s%s\n' % (ident, key)) + + write_df(files_rel_hierarchy, ident=" ") + + f.write(' \n') + + f.write(' \n') + # f.write(' ../GNUmakefile\n') + f.write(' \n') + + f.write(' \n') + # default, but this dir is infact not in blender dir so we can ignore it + # f.write(' ^(nbproject)$\n') + f.write(' ^(nbproject|__pycache__|.*\.py|.*\.html|.*\.blend)$\n') + + f.write(' \n') + f.write(' %s\n' % SOURCE_DIR) # base_root_rel + f.write(' \n') + + f.write(' Makefile\n') + + # paths again + f.write(' \n') + f.write(' \n') + + f.write(' \n') + f.write(' LOCAL_SOURCES\n') + f.write(' default\n') + f.write(' \n') + f.write(' \n') + + f.write(' \n') + f.write(' .\n') + f.write(' ${MAKE} -f Makefile\n') + f.write(' ${MAKE} -f Makefile clean\n') + f.write(' ./bin/blender\n') + + def write_toolinfo(): + f.write(' \n') + for inc in includes: + f.write(' %s\n' % inc) + f.write(' \n') + f.write(' \n') + for cdef in defines: + f.write(' %s\n' % cdef) + f.write(' \n') + + f.write(' \n') + write_toolinfo() + f.write(' \n') + + f.write(' \n') + write_toolinfo() + f.write(' \n') + + f.write(' \n') + f.write(' \n') + # finishe makefle info + + f.write(' \n') + + for path in files_rel_local: + f.write(' \n') + f.write(' \n') + + f.write(' \n') + f.write(' \n') + f.write(' \n') + f.write(' %s\n' % os.path.join(CMAKE_DIR, "bin/blender")) + f.write(' %s\n' % SOURCE_DIR) + f.write(' false\n') + f.write(' 0\n') + f.write(' 0\n') + f.write(' \n') + f.write(' \n') + f.write(' \n') + + f.write(' \n') + f.write(' \n') + + # todo + + f.write('\n') + + +def main(): + create_nb_project_main() + + +if __name__ == "__main__": + main() diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py old mode 100644 new mode 100755 index 59b8b2a3b02..e38b2228cca --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# $Id: +# $Id$ # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or @@ -31,182 +31,16 @@ example linux usage python .~/blenderSVN/blender/build_files/cmake/cmake_qtcreator_project.py ~/blenderSVN/cmake """ -import sys +from project_info import * + import os from os.path import join, dirname, normpath, abspath, splitext, relpath, exists -base = join(os.path.dirname(__file__), "..", "..") -base = normpath(base) -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): - - # skip '.svn' - if dirpath.startswith("."): - continue - - for filename in filenames: - filepath = join(dirpath, filename) - if filename_check is None or filename_check(filepath): - yield filepath - - -# extension checking -def is_cmake(filename): - ext = splitext(filename)[1] - return (ext == ".cmake") or (filename.endswith("CMakeLists.txt")) - - -def is_c_header(filename): - ext = splitext(filename)[1] - 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")) - - -def is_c_any(filename): - return is_c(filename) or is_c_header(filename) - - -def is_svn_file(filename): - dn, fn = os.path.split(filename) - filename_svn = join(dn, ".svn", "text-base", "%s.svn-base" % fn) - return exists(filename_svn) - - -def is_project_file(filename): - return (is_c_any(filename) or is_cmake(filename) or is_glsl(filename)) # and is_svn_file(filename) - - -def cmake_advanced_info(): - """ Extracr includes and defines from cmake. - """ - - def create_eclipse_project(CMAKE_DIR): - print("CMAKE_DIR %r" % CMAKE_DIR) - if sys.platform == "win32": - cmd = 'cmake "%s" -G"Eclipse CDT4 - MinGW Makefiles"' % CMAKE_DIR - else: - cmd = 'cmake "%s" -G"Eclipse CDT4 - Unix Makefiles"' % CMAKE_DIR - - os.system(cmd) - - includes = [] - defines = [] - - create_eclipse_project(CMAKE_DIR) - - from xml.dom.minidom import parse - tree = parse(os.path.join(CMAKE_DIR, ".cproject")) - ''' - f = open(".cproject_pretty", 'w') - f.write(tree.toprettyxml(indent=" ", newl="")) - ''' - ELEMENT_NODE = tree.ELEMENT_NODE - - cproject, = tree.getElementsByTagName("cproject") - for storage in cproject.childNodes: - if storage.nodeType != ELEMENT_NODE: - continue - - if storage.attributes["moduleId"].value == "org.eclipse.cdt.core.settings": - cconfig = storage.getElementsByTagName("cconfiguration")[0] - for substorage in cconfig.childNodes: - if substorage.nodeType != ELEMENT_NODE: - continue - - moduleId = substorage.attributes["moduleId"].value - - # org.eclipse.cdt.core.settings - # org.eclipse.cdt.core.language.mapping - # org.eclipse.cdt.core.externalSettings - # org.eclipse.cdt.core.pathentry - # org.eclipse.cdt.make.core.buildtargets - - if moduleId == "org.eclipse.cdt.core.pathentry": - for path in substorage.childNodes: - if path.nodeType != ELEMENT_NODE: - continue - kind = path.attributes["kind"].value - - if kind == "mac": - # - defines.append((path.attributes["name"].value, path.attributes["value"].value)) - elif kind == "inc": - # - includes.append(path.attributes["include"].value) - else: - pass - - 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 +import sys def create_qtc_project_main(): - files = list(source_list(base, filename_check=is_project_file)) + files = list(source_list(SOURCE_DIR, filename_check=is_project_file)) files_rel = [relpath(f, start=PROJECT_DIR) for f in files] files_rel.sort() @@ -260,7 +94,7 @@ def create_qtc_project_main(): def create_qtc_project_python(): - files = list(source_list(base, filename_check=is_py)) + files = list(source_list(SOURCE_DIR, filename_check=is_py)) files_rel = [relpath(f, start=PROJECT_DIR) for f in files] files_rel.sort() diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index ca1dd79cd8e..14bed8874fa 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -88,9 +88,6 @@ macro(SETUP_LIBDIRS) if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE) link_directories(${OPENJPEG_LIBPATH}) endif() - if(WITH_LCMS) - link_directories(${LCMS_LIBPATH}) - endif() if(WITH_CODEC_QUICKTIME) link_directories(${QUICKTIME_LIBPATH}) endif() @@ -114,6 +111,9 @@ macro(SETUP_LIBDIRS) link_directories(${PCRE_LIBPATH}) link_directories(${EXPAT_LIBPATH}) endif() + if(WITH_MEM_JEMALLOC) + link_directories(${JEMALLOC_LIBPATH}) + endif() if(WIN32 AND NOT UNIX) link_directories(${PTHREADS_LIBPATH}) @@ -190,9 +190,6 @@ macro(setup_liblinks if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE) target_link_libraries(${target} ${OPENJPEG_LIB}) endif() - if(WITH_LCMS) - target_link_libraries(${target} ${LCMS_LIBRARY}) - endif() if(WITH_CODEC_FFMPEG) target_link_libraries(${target} ${FFMPEG_LIB}) endif() @@ -214,11 +211,8 @@ macro(setup_liblinks target_link_libraries(${target} ${EXPAT_LIB}) endif() endif() - if(WITH_LCMS) - if(WIN32 AND NOT UNIX) - target_link_libraries(${target} debug ${LCMS_LIB}_d) - target_link_libraries(${target} optimized ${LCMS_LIB}) - endif() + if(WITH_MEM_JEMALLOC) + target_link_libraries(${target} ${JEMALLOC_LIBRARY}) endif() if(WIN32 AND NOT UNIX) target_link_libraries(${target} ${PTHREADS_LIB}) diff --git a/build_files/cmake/packaging.cmake b/build_files/cmake/packaging.cmake index ee07857db26..6cda62b487f 100644 --- a/build_files/cmake/packaging.cmake +++ b/build_files/cmake/packaging.cmake @@ -31,17 +31,20 @@ set(BUILD_REV ${MY_WC_REVISION}) # Force Package Name -set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${BLENDER_VERSION}-r${BUILD_REV}-${CPACK_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) +set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${BLENDER_VERSION}-r${BUILD_REV}-${CMAKE_SYSTEM_PROCESSOR}) if(CMAKE_SYSTEM_NAME MATCHES "Linux") # RPM packages include(build_files/cmake/RpmBuild.cmake) if(RPMBUILD_FOUND AND NOT WIN32) set(CPACK_GENERATOR "RPM") - set(CPACK_SET_DESTDIR TRUE) + set(CPACK_RPM_PACKAGE_RELEASE "1.r${BUILD_REV}") + set(CPACK_SET_DESTDIR "true") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}") + set(CPACK_PACKAGE_RELOCATABLE "false") set(CPACK_RPM_PACKAGE_LICENSE "GPLv2") set(CPACK_RPM_PACKAGE_GROUP "Amusements/Graphics") + set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/build_files/package_spec/rpm/blender.spec.in") endif() endif() diff --git a/build_files/cmake/project_info.py b/build_files/cmake/project_info.py new file mode 100755 index 00000000000..c25fbf4128d --- /dev/null +++ b/build_files/cmake/project_info.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python + +# $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): Campbell Barton, M.G. Kishalmi +# +# ***** END GPL LICENSE BLOCK ***** + +# + +""" +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 +""" + +__all__ = ( + "SIMPLE_PROJECTFILE", + "SOURCE_DIR", + "CMAKE_DIR", + "PROJECT_DIR", + "source_list", + "is_project_file", + "is_c_header", + "is_py", + "cmake_advanced_info", + "cmake_compiler_defines", +) + +import sys +import os +from os.path import join, dirname, normpath, abspath, splitext, relpath, exists + +SOURCE_DIR = join(dirname(__file__), "..", "..") +SOURCE_DIR = normpath(SOURCE_DIR) +SOURCE_DIR = abspath(SOURCE_DIR) + +SIMPLE_PROJECTFILE = False + +# get cmake path +CMAKE_DIR = sys.argv[-1] + +if not exists(join(CMAKE_DIR, "CMakeCache.txt")): + CMAKE_DIR = os.getcwd() +if not exists(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 = SOURCE_DIR +PROJECT_DIR = CMAKE_DIR + + +def source_list(path, filename_check=None): + for dirpath, dirnames, filenames in os.walk(path): + + # skip '.svn' + if dirpath.startswith("."): + continue + + for filename in filenames: + filepath = join(dirpath, filename) + if filename_check is None or filename_check(filepath): + yield filepath + + +# extension checking +def is_cmake(filename): + ext = splitext(filename)[1] + return (ext == ".cmake") or (filename.endswith("CMakeLists.txt")) + + +def is_c_header(filename): + ext = splitext(filename)[1] + 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")) + + +def is_c_any(filename): + return is_c(filename) or is_c_header(filename) + + +def is_svn_file(filename): + dn, fn = os.path.split(filename) + filename_svn = join(dn, ".svn", "text-base", "%s.svn-base" % fn) + return exists(filename_svn) + + +def is_project_file(filename): + return (is_c_any(filename) or is_cmake(filename) or is_glsl(filename)) # and is_svn_file(filename) + + +def cmake_advanced_info(): + """ Extracr includes and defines from cmake. + """ + + def create_eclipse_project(CMAKE_DIR): + print("CMAKE_DIR %r" % CMAKE_DIR) + if sys.platform == "win32": + cmd = 'cmake "%s" -G"Eclipse CDT4 - MinGW Makefiles"' % CMAKE_DIR + else: + cmd = 'cmake "%s" -G"Eclipse CDT4 - Unix Makefiles"' % CMAKE_DIR + + os.system(cmd) + + includes = [] + defines = [] + + create_eclipse_project(CMAKE_DIR) + + from xml.dom.minidom import parse + tree = parse(join(CMAKE_DIR, ".cproject")) + ''' + f = open(".cproject_pretty", 'w') + f.write(tree.toprettyxml(indent=" ", newl="")) + ''' + ELEMENT_NODE = tree.ELEMENT_NODE + + cproject, = tree.getElementsByTagName("cproject") + for storage in cproject.childNodes: + if storage.nodeType != ELEMENT_NODE: + continue + + if storage.attributes["moduleId"].value == "org.eclipse.cdt.core.settings": + cconfig = storage.getElementsByTagName("cconfiguration")[0] + for substorage in cconfig.childNodes: + if substorage.nodeType != ELEMENT_NODE: + continue + + moduleId = substorage.attributes["moduleId"].value + + # org.eclipse.cdt.core.settings + # org.eclipse.cdt.core.language.mapping + # org.eclipse.cdt.core.externalSettings + # org.eclipse.cdt.core.pathentry + # org.eclipse.cdt.make.core.buildtargets + + if moduleId == "org.eclipse.cdt.core.pathentry": + for path in substorage.childNodes: + if path.nodeType != ELEMENT_NODE: + continue + kind = path.attributes["kind"].value + + if kind == "mac": + # + defines.append((path.attributes["name"].value, path.attributes["value"].value)) + elif kind == "inc": + # + includes.append(path.attributes["include"].value) + else: + pass + + return includes, defines + + +def cmake_cache_var(var): + cache_file = open(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 diff --git a/build_files/package_spec/rpm/blender.spec.in b/build_files/package_spec/rpm/blender.spec.in new file mode 100644 index 00000000000..502e9f36251 --- /dev/null +++ b/build_files/package_spec/rpm/blender.spec.in @@ -0,0 +1,69 @@ +# -*- rpm-spec -*- +%global __python %{__python3} + +BuildRoot: @CPACK_RPM_DIRECTORY@/@CPACK_PACKAGE_FILE_NAME@@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH@ +Summary: @CPACK_RPM_PACKAGE_SUMMARY@ +Name: @CPACK_RPM_PACKAGE_NAME@ +Version: @CPACK_RPM_PACKAGE_VERSION@ +Release: @CPACK_RPM_PACKAGE_RELEASE@%{?dist} +License: @CPACK_RPM_PACKAGE_LICENSE@ +Group: @CPACK_RPM_PACKAGE_GROUP@ +Vendor: @CPACK_RPM_PACKAGE_VENDOR@ + +%define _rpmdir @CPACK_RPM_DIRECTORY@ +%define _rpmfilename @CPACK_RPM_FILE_NAME@ +%define _unpackaged_files_terminate_build 0 +%define _topdir @CPACK_RPM_DIRECTORY@ + +%description +Blender is an integrated 3d suite for modelling, animation, rendering, +post-production, interactive creation and playback (games). Blender has its +own particular user interface, which is implemented entirely in OpenGL and +designed with speed in mind. Python bindings are available for scripting; +import/export features for popular file formats like 3D Studio and Wavefront +Obj are implemented as scripts by the community. Stills, animations, models +for games or other third party engines and interactive content in the form of +a standalone binary and/or a web plug-in are common products of Blender use. + +# This is a shortcutted spec file generated by CMake RPM generator +# we skip _install step because CPack does that for us. +# We do only save CPack installed tree in _prepr +# and then restore it in build. +%prep +mv ${RPM_BUILD_ROOT} "@CPACK_TOPLEVEL_DIRECTORY@/tmpBBroot" + +%install +if [ -e ${RPM_BUILD_ROOT} ]; +then + rm -rf ${RPM_BUILD_ROOT} +fi +mv "@CPACK_TOPLEVEL_DIRECTORY@/tmpBBroot" ${RPM_BUILD_ROOT} + +%clean +rm -rf ${RPM_BUILD_ROOT} + +%post +touch --no-create %{_datadir}/icons/hicolor +if [ -x %{_bindir}/gtk-update-icon-cache ]; then + %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor +fi +%{_bindir}/update-desktop-database %{_datadir}/applications || : + +%postun +%{_bindir}/update-desktop-database %{_datadir}/applications +touch --no-create %{_datadir}/icons/hicolor +if [ -x %{_bindir}/gtk-update-icon-cache ]; then + %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor +fi || : + +%files +%defattr(-,root,root,-) +%{_bindir}/%{name} +%{_datadir}/%{name}/@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@ +%{_datadir}/icons/hicolor/*/apps/%{name}.* +%{_datadir}/applications/%{name}.desktop +%{_datadir}/doc/blender +%{_mandir}/man1/blender.* + +%changelog +@CPACK_RPM_SPEC_CHANGELOG@ diff --git a/build_files/scons/config/linux2-config.py b/build_files/scons/config/linux2-config.py index d4e97c78c38..bc2917055fb 100644 --- a/build_files/scons/config/linux2-config.py +++ b/build_files/scons/config/linux2-config.py @@ -178,6 +178,14 @@ BF_EXPAT = '/usr' BF_EXPAT_LIB = 'expat' BF_EXPAT_LIBPATH = '/usr/lib' +WITH_BF_JEMALLOC = False +WITH_BF_STATICJEMALLOC = False +BF_JEMALLOC = '/usr' +BF_JEMALLOC_INC = '${BF_JEMALLOC}/include' +BF_JEMALLOC_LIBPATH = '${BF_JEMALLOC}/lib' +BF_JEMALLOC_LIB = 'jemalloc' +BF_JEMALLOC_LIB_STATIC = '${BF_JEMALLOC_LIBPATH}/libjemalloc.a' + WITH_BF_OPENMP = True #Ray trace optimization diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index eeb50a9ca65..65076be85ed 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -149,12 +149,6 @@ BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include' BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa UTF' BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib' -WITH_BF_LCMS = False -BF_LCMS = LIBDIR + '/lcms' -BF_LCMS_INC = '${BF_LCMS}/include' -BF_LCMS_LIB = 'lcms' -BF_LCMS_LIBPATH = '${BF_LCMS}/lib' - #Ray trace optimization WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['/arch:SSE'] diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py index 2dcbe8aeb2e..2c990941764 100644 --- a/build_files/scons/config/win64-vc-config.py +++ b/build_files/scons/config/win64-vc-config.py @@ -151,12 +151,6 @@ BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include' BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa UTF' BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib' -WITH_BF_LCMS = False -BF_LCMS = LIBDIR + '/lcms' -BF_LCMS_INC = '${BF_LCMS}/include' -BF_LCMS_LIB = 'lcms' -BF_LCMS_LIBPATH = '${BF_LCMS}/lib' - #Ray trace optimization WITH_BF_RAYOPTIMIZATION = True BF_RAYOPTIMIZATION_SSE_FLAGS = ['/arch:SSE','/arch:SSE2'] diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index ad4df1a60c1..4bfa1851acb 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -148,8 +148,6 @@ def setup_staticlibs(lenv): libincs += Split(lenv['BF_OPENEXR_LIBPATH']) if lenv['WITH_BF_STATICOPENEXR']: statlibs += Split(lenv['BF_OPENEXR_LIB_STATIC']) - if lenv['WITH_BF_LCMS']: - libincs += Split(lenv['BF_LCMS_LIBPATH']) if lenv['WITH_BF_TIFF']: libincs += Split(lenv['BF_TIFF_LIBPATH']) if lenv['WITH_BF_STATICTIFF']: @@ -203,6 +201,11 @@ def setup_staticlibs(lenv): if lenv['OURPLATFORM'] not in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'): libincs.append('/usr/lib') + if lenv['WITH_BF_JEMALLOC']: + libincs += Split(lenv['BF_JEMALLOC_LIBPATH']) + if lenv['WITH_BF_STATICJEMALLOC']: + statlibs += Split(lenv['BF_JEMALLOC_LIB_STATIC']) + return statlibs, libincs def setup_syslibs(lenv): @@ -253,8 +256,6 @@ def setup_syslibs(lenv): syslibs += Split(lenv['BF_OPENGL_LIB']) if lenv['OURPLATFORM'] in ('win32-vc', 'win32-mingw','linuxcross', 'win64-vc'): syslibs += Split(lenv['BF_PTHREADS_LIB']) - if lenv['WITH_BF_LCMS']: - syslibs.append(lenv['BF_LCMS_LIB']) if lenv['WITH_BF_COLLADA']: syslibs.append(lenv['BF_PCRE_LIB']) syslibs += Split(lenv['BF_OPENCOLLADA_LIB']) @@ -263,6 +264,9 @@ def setup_syslibs(lenv): if not lenv['WITH_BF_STATICLIBSAMPLERATE']: syslibs += Split(lenv['BF_LIBSAMPLERATE_LIB']) + if lenv['WITH_BF_JEMALLOC']: + if not lenv['WITH_BF_STATICJEMALLOC']: + syslibs += Split(lenv['BF_JEMALLOC_LIB']) syslibs += lenv['LLIBS'] diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index fcc782bd824..fe6b092598c 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -125,7 +125,6 @@ def validate_arguments(args, bc): 'BF_FANCY', 'BF_QUIET', 'BF_LINE_OVERWRITE', 'BF_X264_CONFIG', 'BF_XVIDCORE_CONFIG', - 'WITH_BF_LCMS', 'BF_LCMS', 'BF_LCMS_INC', 'BF_LCMS_LIB', 'BF_LCMS_LIBPATH', 'WITH_BF_DOCS', 'BF_NUMJOBS', 'BF_MSVS', @@ -134,7 +133,8 @@ def validate_arguments(args, bc): 'WITH_BF_RAYOPTIMIZATION', 'BF_RAYOPTIMIZATION_SSE_FLAGS', 'BF_NO_ELBEEM', - 'WITH_BF_CXX_GUARDEDALLOC' + 'WITH_BF_CXX_GUARDEDALLOC', + 'WITH_BF_JEMALLOC', 'WITH_BF_STATICJEMALLOC', 'BF_JEMALLOC', 'BF_JEMALLOC_INC', 'BF_JEMALLOC_LIBPATH', 'BF_JEMALLOC_LIB', 'BF_JEMALLOC_LIB_STATIC' ] # Have options here that scons expects to be lists @@ -333,12 +333,6 @@ def read_opts(env, cfg, args): ('BF_TIFF_LIBPATH', 'TIFF library path', ''), ('BF_TIFF_LIB_STATIC', 'TIFF static library', ''), - (BoolVariable('WITH_BF_LCMS', 'Enable color correction with lcms', False)), - ('BF_LCMS', 'LCMS base path', ''), - ('BF_LCMS_INC', 'LCMS include path', ''), - ('BF_LCMS_LIB', 'LCMS library', ''), - ('BF_LCMS_LIBPATH', 'LCMS library path', ''), - (BoolVariable('WITH_BF_ZLIB', 'Use ZLib if true', True)), (BoolVariable('WITH_BF_STATICZLIB', 'Staticly link to ZLib', False)), ('BF_ZLIB', 'ZLib base path', ''), @@ -429,6 +423,14 @@ def read_opts(env, cfg, args): ('BF_EXPAT_LIB', 'Expat library', ''), ('BF_EXPAT_LIBPATH', 'Expat library path', ''), + (BoolVariable('WITH_BF_JEMALLOC', 'Use jemalloc if true', False)), + (BoolVariable('WITH_BF_STATICJEMALLOC', 'Staticly link to jemalloc', False)), + ('BF_JEMALLOC', 'jemalloc base path', ''), + ('BF_JEMALLOC_INC', 'jemalloc include path', ''), + ('BF_JEMALLOC_LIB', 'jemalloc library', ''), + ('BF_JEMALLOC_LIBPATH', 'jemalloc library path', ''), + ('BF_JEMALLOC_LIB_STATIC', 'jemalloc static library', ''), + (BoolVariable('WITH_BF_PLAYER', 'Build blenderplayer if true', False)), (BoolVariable('WITH_BF_NOBLENDER', 'Do not build blender if true', False)), diff --git a/doc/doxygen/doxygen.source b/doc/doxygen/doxygen.source index 9cd86e23e59..375234d26a3 100644 --- a/doc/doxygen/doxygen.source +++ b/doc/doxygen/doxygen.source @@ -145,10 +145,6 @@ * merged in docs. */ -/** \defgroup blo readblenfile - * \ingroup blender data - */ - /** \defgroup quicktime quicktime * \ingroup blender @@ -342,17 +338,5 @@ /* ================================ */ -/** \defgroup kernel kernel */ - -/** \defgroup genmess gen_messaging - * \ingroup kernel - */ - -/** \defgroup gensys gen_system - * \ingroup kernel - */ - -/* ================================ */ - /** \defgroup undoc Undocumented * \brief Modules and libraries that are still undocumented, or lacking proper integration into the doxygen system, are marked in this group. */ diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 258b28a3d33..03c8fe1b4ff 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -810,7 +810,9 @@ def pyrna2sphinx(BASEPATH): # operators def write_ops(): - API_BASEURL = "https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/scripts" + API_BASEURL = "http://svn.blender.org/svnroot/bf-blender/trunk/blender/release/scripts" + API_BASEURL_ADDON = "http://svn.blender.org/svnroot/bf-extensions/trunk/py/scripts" + API_BASEURL_ADDON_CONTRIB = "http://svn.blender.org/svnroot/bf-extensions/contrib/py/scripts" op_modules = {} for op in ops.values(): @@ -849,7 +851,14 @@ def pyrna2sphinx(BASEPATH): location = op.get_location() if location != (None, None): - fw(" :file: `%s <%s/%s>`_:%d\n\n" % (location[0], API_BASEURL, location[0], location[1])) + if location[0].startswith("addons_contrib" + os.sep): + url_base = API_BASEURL_ADDON_CONTRIB + elif location[0].startswith("addons" + os.sep): + url_base = API_BASEURL_ADDON + else: + url_base = API_BASEURL + + fw(" :file: `%s <%s/%s>`_:%d\n\n" % (location[0], url_base, location[0], location[1])) file.close() diff --git a/intern/container/CMakeLists.txt b/intern/container/CMakeLists.txt index 7f15854e538..7e83acf68ce 100644 --- a/intern/container/CMakeLists.txt +++ b/intern/container/CMakeLists.txt @@ -26,11 +26,13 @@ set(INC . + ../guardedalloc ) set(SRC intern/CTR_List.cpp + CTR_HashedPtr.h CTR_List.h CTR_Map.h CTR_TaggedIndex.h diff --git a/source/kernel/gen_system/GEN_HashedPtr.h b/intern/container/CTR_HashedPtr.h similarity index 67% rename from source/kernel/gen_system/GEN_HashedPtr.h rename to intern/container/CTR_HashedPtr.h index 86a7ceb9ae7..0291535d718 100644 --- a/source/kernel/gen_system/GEN_HashedPtr.h +++ b/intern/container/CTR_HashedPtr.h @@ -28,24 +28,30 @@ * */ -/** \file kernel/gen_system/GEN_HashedPtr.h - * \ingroup gensys +/** \file container/CTR_HashedPtr.h + * \ingroup ctr */ -#ifndef __GEN_HASHEDPTR -#define __GEN_HASHEDPTR +#ifndef CTR_HASHEDPTR_H +#define CTR_HASHEDPTR_H -unsigned int GEN_Hash(void * inDWord); +#include -class GEN_HashedPtr +inline unsigned int CTR_Hash(void *inDWord) +{ + size_t key = (size_t)inDWord; + return (unsigned int)(key ^ (key>>4)); +} + +class CTR_HashedPtr { void* m_valptr; public: - GEN_HashedPtr(void* val) : m_valptr(val) {}; - unsigned int hash() const { return GEN_Hash(m_valptr);}; - inline friend bool operator ==(const GEN_HashedPtr & rhs, const GEN_HashedPtr & lhs) { return rhs.m_valptr == lhs.m_valptr;}; + CTR_HashedPtr(void* val) : m_valptr(val) {}; + unsigned int hash() const { return CTR_Hash(m_valptr);}; + inline friend bool operator ==(const CTR_HashedPtr & rhs, const CTR_HashedPtr & lhs) { return rhs.m_valptr == lhs.m_valptr;}; void *getValue() const { return m_valptr; } }; -#endif //__GEN_HASHEDPTR +#endif //CTR_HASHEDPTR_H diff --git a/intern/container/CTR_Map.h b/intern/container/CTR_Map.h index cbd67fdeaca..1991ec19e3a 100644 --- a/intern/container/CTR_Map.h +++ b/intern/container/CTR_Map.h @@ -55,6 +55,19 @@ public: m_buckets[i] = 0; } } + + CTR_Map(const CTR_Map& map) + { + m_num_buckets = map.m_num_buckets; + m_buckets = new Entry *[m_num_buckets]; + + for (int i = 0; i < m_num_buckets; ++i) { + m_buckets[i] = 0; + + for(Entry *entry = map.m_buckets[i]; entry; entry=entry->m_next) + insert(entry->m_key, entry->m_value); + } + } int size() { int count=0; @@ -87,6 +100,24 @@ public: } return 0; } + + Key* getKey(int index) { + int count=0; + for (int i=0;im_key; + } + bucket = bucket->m_next; + count++; + } + } + return 0; + } void clear() { for (int i = 0; i < m_num_buckets; ++i) { diff --git a/intern/container/SConscript b/intern/container/SConscript index 2d93e90b555..8edf86d7d4a 100644 --- a/intern/container/SConscript +++ b/intern/container/SConscript @@ -2,6 +2,6 @@ Import ('env') sources = env.Glob('intern/*.cpp') -incs = '.' +incs = '. #intern/guardedalloc' env.BlenderLib ('bf_intern_ctr', sources, Split(incs) , [], libtype='intern', priority = 10 ) diff --git a/intern/cycles/blender/addon/xml.py b/intern/cycles/blender/addon/xml.py index 4d1b43d4d95..3500d3f0aa5 100644 --- a/intern/cycles/blender/addon/xml.py +++ b/intern/cycles/blender/addon/xml.py @@ -20,7 +20,7 @@ import os import bpy -import io_utils +from bpy_extras.io_utils import ExportHelper import xml.etree.ElementTree as etree import xml.dom.minidom as dom @@ -40,7 +40,7 @@ def write(node, fname): f = open(fname, "w") f.write(s) -class ExportCyclesXML(bpy.types.Operator, io_utils.ExportHelper): +class ExportCyclesXML(bpy.types.Operator, ExportHelper): '''''' bl_idname = "export_mesh.cycles_xml" bl_label = "Export Cycles XML" diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 0d7a64ddfa9..d42be400dff 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -29,7 +29,7 @@ set(INC ../string ../../source/blender/imbuf ../../source/blender/makesdna - ${GLEW_INCLUDE_PATH} + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 2fdddda835d..143f7e97f2d 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -42,7 +42,7 @@ #include #ifdef FREE_WINDOWS -# define _WIN32_WINNT 0x0500 /* GetConsoleWindow() for MinGW */ +# define WINVER 0x0501 /* GetConsoleWindow() for MinGW */ #endif #include "GHOST_SystemWin32.h" @@ -304,7 +304,6 @@ bool GHOST_SystemWin32::processEvents(bool waitForEvent) // Process all the events waiting for us while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE) != 0) { - ::TranslateMessage(&msg); ::DispatchMessage(&msg); anyProcessed = true; } @@ -819,6 +818,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, // Keyboard events, processed //////////////////////////////////////////////////////////////////////// case WM_INPUT: + // check WM_INPUT from input sink when ghost window is not in the foreground + if (wParam == RIM_INPUTSINK) { + if (GetFocus() != hwnd) // WM_INPUT message not for this window + return 0; + } //else wPAram == RIM_INPUT event = processKeyEvent(window, wParam, lParam); if (!event) { GHOST_PRINT("GHOST_SystemWin32::wndProc: key event ") @@ -1174,25 +1178,29 @@ GHOST_TUns8* GHOST_SystemWin32::getClipboard(bool selection) const char *temp_buff; if ( IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL) ) { + size_t len = 0; HANDLE hData = GetClipboardData( CF_TEXT ); if (hData == NULL) { CloseClipboard(); return NULL; } buffer = (char*)GlobalLock( hData ); + if (!buffer) { + CloseClipboard(); + return NULL; + } - temp_buff = (char*) malloc(strlen(buffer)+1); - strcpy(temp_buff, buffer); + len = strlen(buffer); + temp_buff = (char*) malloc(len+1); + strncpy(temp_buff, buffer, len); + temp_buff[len] = '\0'; + /* Buffer mustn't be accessed after CloseClipboard + it would like accessing free-d memory */ GlobalUnlock( hData ); CloseClipboard(); - temp_buff[strlen(buffer)] = '\0'; - if (buffer) { - return (GHOST_TUns8*)temp_buff; - } else { - return NULL; - } + return (GHOST_TUns8*)temp_buff; } else { return NULL; } diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h index 2dad3a6f44d..729ad56d875 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.h +++ b/intern/ghost/intern/GHOST_SystemWin32.h @@ -52,6 +52,9 @@ #ifndef RID_INPUT #define RID_INPUT 0x10000003 #endif +#ifndef RIM_INPUTSINK +#define RIM_INPUTSINK 0x1 +#endif #ifndef RI_KEY_BREAK #define RI_KEY_BREAK 0x1 #endif @@ -127,8 +130,6 @@ DECLARE_HANDLE(HRAWINPUT); #ifdef FREE_WINDOWS #define NEED_RAW_PROC typedef BOOL (WINAPI * LPFNDLLRRID)(RAWINPUTDEVICE*,UINT, UINT); -#define RegisterRawInputDevices(pRawInputDevices, uiNumDevices, cbSize) ((pRegisterRawInputDevices)?pRegisterRawInputDevices(pRawInputDevices, uiNumDevices, cbSize):0) - typedef UINT (WINAPI * LPFNDLLGRID)(HRAWINPUT, UINT, LPVOID, PUINT, UINT); #define GetRawInputData(hRawInput, uiCommand, pData, pcbSize, cbSizeHeader) ((pGetRawInputData)?pGetRawInputData(hRawInput, uiCommand, pData, pcbSize, cbSizeHeader):(UINT)-1) diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 378bc6b90be..b44f2b18225 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -700,19 +700,24 @@ GHOST_SystemX11::processEvent(XEvent *xe) case EnterNotify: case LeaveNotify: { - // XCrossingEvents pointer leave enter window. - // also do cursor move here, MotionNotify only - // happens when motion starts & ends inside window + /* XCrossingEvents pointer leave enter window. + also do cursor move here, MotionNotify only + happens when motion starts & ends inside window. + we only do moves when the crossing mode is 'normal' + (really crossing between windows) since some windowmanagers + also send grab/ungrab crossings for mousewheel events. + */ XCrossingEvent &xce = xe->xcrossing; - - g_event = new - GHOST_EventCursor( - getMilliSeconds(), - GHOST_kEventCursorMove, - window, - xce.x_root, - xce.y_root - ); + if( xce.mode == NotifyNormal ) { + g_event = new + GHOST_EventCursor( + getMilliSeconds(), + GHOST_kEventCursorMove, + window, + xce.x_root, + xce.y_root + ); + } break; } case MapNotify: diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index a89b2608bb4..aae1509fda1 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -307,6 +307,15 @@ GHOST_WindowWin32::GHOST_WindowWin32( } } + if (parentwindowhwnd != 0) { + RAWINPUTDEVICE device = {0}; + device.usUsagePage = 0x01; /* usUsagePage & usUsage for keyboard*/ + device.usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */ + device.dwFlags |= RIDEV_INPUTSINK; // makes WM_INPUT is visible for ghost when has parent window + device.hwndTarget = m_hWnd; + RegisterRawInputDevices(&device, 1, sizeof(device)); + } + m_wintab = ::LoadLibrary("Wintab32.dll"); if (m_wintab) { GHOST_WIN32_WTInfo fpWTInfo = ( GHOST_WIN32_WTInfo ) ::GetProcAddress( m_wintab, "WTInfoA" ); diff --git a/intern/iksolver/intern/IK_QSegment.cpp b/intern/iksolver/intern/IK_QSegment.cpp index 4f05e750e78..237edfd4594 100644 --- a/intern/iksolver/intern/IK_QSegment.cpp +++ b/intern/iksolver/intern/IK_QSegment.cpp @@ -370,7 +370,7 @@ MT_Vector3 IK_QSphericalSegment::Axis(int dof) const void IK_QSphericalSegment::SetLimit(int axis, MT_Scalar lmin, MT_Scalar lmax) { - if (lmin >= lmax) + if (lmin > lmax) return; if (axis == 1) { @@ -613,7 +613,7 @@ void IK_QRevoluteSegment::UpdateAngleApply() void IK_QRevoluteSegment::SetLimit(int axis, MT_Scalar lmin, MT_Scalar lmax) { - if (lmin >= lmax || m_axis != axis) + if (lmin > lmax || m_axis != axis) return; // clamp and convert to axis angle parameters @@ -752,7 +752,7 @@ void IK_QSwingSegment::UpdateAngleApply() void IK_QSwingSegment::SetLimit(int axis, MT_Scalar lmin, MT_Scalar lmax) { - if (lmin >= lmax) + if (lmin > lmax) return; // clamp and convert to axis angle parameters @@ -898,7 +898,7 @@ void IK_QElbowSegment::UpdateAngleApply() void IK_QElbowSegment::SetLimit(int axis, MT_Scalar lmin, MT_Scalar lmax) { - if (lmin >= lmax) + if (lmin > lmax) return; // clamp and convert to axis angle parameters diff --git a/intern/smoke/intern/Makefile.FFT b/intern/smoke/intern/Makefile.FFT index e45af1df29b..7e9d089cec2 100644 --- a/intern/smoke/intern/Makefile.FFT +++ b/intern/smoke/intern/Makefile.FFT @@ -1,22 +1,22 @@ -# common stuff -LDFLAGS_COMMON = -lfftw3 #-lglut -lglu32 -lopengl32 -lz -lpng -CFLAGS_COMMON = -c -Wall -I./ #-I/cygdrive/c/lib/glvu/include -D_WIN32 - -CC = g++ -CFLAGS = ${CFLAGS_COMMON} -O3 -Wno-unused -LDFLAGS = ${LDFLAGS_COMMON} -EXECUTABLE = noiseFFT - -SOURCES = noiseFFT.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -all: $(SOURCES) $(EXECUTABLE) - -$(EXECUTABLE): $(OBJECTS) - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ - -.cpp.o: - $(CC) $(CFLAGS) $< -o $@ - -clean: - rm -f *.o $(EXECUTABLE_LOADER) $(EXECUTABLE) +# common stuff +LDFLAGS_COMMON = -lfftw3 #-lglut -lglu32 -lopengl32 -lz -lpng +CFLAGS_COMMON = -c -Wall -I./ #-I/cygdrive/c/lib/glvu/include -D_WIN32 + +CC = g++ +CFLAGS = ${CFLAGS_COMMON} -O3 -Wno-unused +LDFLAGS = ${LDFLAGS_COMMON} +EXECUTABLE = noiseFFT + +SOURCES = noiseFFT.cpp +OBJECTS = $(SOURCES:.cpp=.o) + +all: $(SOURCES) $(EXECUTABLE) + +$(EXECUTABLE): $(OBJECTS) + $(CC) $(OBJECTS) $(LDFLAGS) -o $@ + +.cpp.o: + $(CC) $(CFLAGS) $< -o $@ + +clean: + rm -f *.o $(EXECUTABLE_LOADER) $(EXECUTABLE) diff --git a/intern/smoke/intern/Makefile.cygwin b/intern/smoke/intern/Makefile.cygwin index c93753a67fe..2a747219554 100644 --- a/intern/smoke/intern/Makefile.cygwin +++ b/intern/smoke/intern/Makefile.cygwin @@ -1,23 +1,23 @@ -CC = g++ -LDFLAGS = -lz -lpng -CFLAGS = -O3 -Wno-unused -c -Wall -I./ -D_WIN32 -EXECUTABLE = FLUID_3D - -SOURCES = main.cpp FLUID_3D.cpp FLUID_3D_SOLVERS.cpp FLUID_3D_STATIC.cpp SPHERE.cpp WTURBULENCE.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -all: $(SOURCES) $(EXECUTABLE) - -$(EXECUTABLE): $(OBJECTS) - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ - -.cpp.o: - $(CC) $(CFLAGS) $< -o $@ - -SPHERE.o: SPHERE.h -FLUID_3D.o: FLUID_3D.h FLUID_3D.cpp -FLUID_3D_SOLVERS.o: FLUID_3D.h FLUID_3D_SOLVERS.cpp -main.o: FLUID_3D.h FLUID_3D.cpp FLUID_3D_SOLVERS.cpp - -clean: - rm -f *.o $(EXECUTABLE_LOADER) $(EXECUTABLE) +CC = g++ +LDFLAGS = -lz -lpng +CFLAGS = -O3 -Wno-unused -c -Wall -I./ -D_WIN32 +EXECUTABLE = FLUID_3D + +SOURCES = main.cpp FLUID_3D.cpp FLUID_3D_SOLVERS.cpp FLUID_3D_STATIC.cpp SPHERE.cpp WTURBULENCE.cpp +OBJECTS = $(SOURCES:.cpp=.o) + +all: $(SOURCES) $(EXECUTABLE) + +$(EXECUTABLE): $(OBJECTS) + $(CC) $(OBJECTS) $(LDFLAGS) -o $@ + +.cpp.o: + $(CC) $(CFLAGS) $< -o $@ + +SPHERE.o: SPHERE.h +FLUID_3D.o: FLUID_3D.h FLUID_3D.cpp +FLUID_3D_SOLVERS.o: FLUID_3D.h FLUID_3D_SOLVERS.cpp +main.o: FLUID_3D.h FLUID_3D.cpp FLUID_3D_SOLVERS.cpp + +clean: + rm -f *.o $(EXECUTABLE_LOADER) $(EXECUTABLE) diff --git a/intern/smoke/intern/Makefile.linux b/intern/smoke/intern/Makefile.linux index 8e71af465dd..5fbb6e6c3e3 100644 --- a/intern/smoke/intern/Makefile.linux +++ b/intern/smoke/intern/Makefile.linux @@ -1,23 +1,23 @@ -CC = g++ -LDFLAGS = -lz -lpng -fopenmp -lgomp -CFLAGS = -c -Wall -I./ -fopenmp -DPARALLEL=1 -O3 -Wno-unused -EXECUTABLE = FLUID_3D - -SOURCES = main.cpp FLUID_3D.cpp FLUID_3D_SOLVERS.cpp FLUID_3D_STATIC.cpp SPHERE.cpp WTURBULENCE.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -all: $(SOURCES) $(EXECUTABLE) - -$(EXECUTABLE): $(OBJECTS) - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ - -.cpp.o: - $(CC) $(CFLAGS) $< -o $@ - -SPHERE.o: SPHERE.h -FLUID_3D.o: FLUID_3D.h FLUID_3D.cpp -FLUID_3D_SOLVERS.o: FLUID_3D.h FLUID_3D_SOLVERS.cpp -main.o: FLUID_3D.h FLUID_3D.cpp FLUID_3D_SOLVERS.cpp - -clean: - rm -f *.o $(EXECUTABLE_LOADER) $(EXECUTABLE) +CC = g++ +LDFLAGS = -lz -lpng -fopenmp -lgomp +CFLAGS = -c -Wall -I./ -fopenmp -DPARALLEL=1 -O3 -Wno-unused +EXECUTABLE = FLUID_3D + +SOURCES = main.cpp FLUID_3D.cpp FLUID_3D_SOLVERS.cpp FLUID_3D_STATIC.cpp SPHERE.cpp WTURBULENCE.cpp +OBJECTS = $(SOURCES:.cpp=.o) + +all: $(SOURCES) $(EXECUTABLE) + +$(EXECUTABLE): $(OBJECTS) + $(CC) $(OBJECTS) $(LDFLAGS) -o $@ + +.cpp.o: + $(CC) $(CFLAGS) $< -o $@ + +SPHERE.o: SPHERE.h +FLUID_3D.o: FLUID_3D.h FLUID_3D.cpp +FLUID_3D_SOLVERS.o: FLUID_3D.h FLUID_3D_SOLVERS.cpp +main.o: FLUID_3D.h FLUID_3D.cpp FLUID_3D_SOLVERS.cpp + +clean: + rm -f *.o $(EXECUTABLE_LOADER) $(EXECUTABLE) diff --git a/intern/smoke/intern/Makefile.mac b/intern/smoke/intern/Makefile.mac index 227aaa10a16..d0b7bd38c85 100644 --- a/intern/smoke/intern/Makefile.mac +++ b/intern/smoke/intern/Makefile.mac @@ -1,35 +1,35 @@ -CC = g++ - -# uncomment the other two OPENMP_... lines, if your gcc supports OpenMP -#OPENMP_FLAGS = -fopenmp -DPARALLEL=1 -I/opt/gcc-4.3/usr/local/include -#OPENMPLD_FLAGS = -fopenmp -lgomp -I/opt/gcc-4.3/usr/local/lib -OPENMP_FLAGS = -OPENMPLD_FLAGS = - -# assumes MacPorts libpng installation -PNG_INCLUDE = -I/opt/local/include -PNG_LIBS = -I/opt/local/lib - -LDFLAGS = $(PNG_LIBS)-lz -lpng $(OPENMPLD_FLAGS) -CFLAGS = -c -Wall -I./ $(PNG_INCLUDE) $(OPENMP_FLAGS) -O3 -Wno-unused -EXECUTABLE = FLUID_3D - -SOURCES = main.cpp FLUID_3D.cpp FLUID_3D_SOLVERS.cpp FLUID_3D_STATIC.cpp SPHERE.cpp WTURBULENCE.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -all: $(SOURCES) $(EXECUTABLE) - -$(EXECUTABLE): $(OBJECTS) - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ - -.cpp.o: - $(CC) $(CFLAGS) $< -o $@ - -SPHERE.o: SPHERE.h -FLUID_3D.o: FLUID_3D.h FLUID_3D.cpp -FLUID_3D_SOLVERS.o: FLUID_3D.h FLUID_3D_SOLVERS.cpp -main.o: FLUID_3D.h FLUID_3D.cpp FLUID_3D_SOLVERS.cpp - -clean: - rm -f *.o $(EXECUTABLE_LOADER) $(EXECUTABLE) - +CC = g++ + +# uncomment the other two OPENMP_... lines, if your gcc supports OpenMP +#OPENMP_FLAGS = -fopenmp -DPARALLEL=1 -I/opt/gcc-4.3/usr/local/include +#OPENMPLD_FLAGS = -fopenmp -lgomp -I/opt/gcc-4.3/usr/local/lib +OPENMP_FLAGS = +OPENMPLD_FLAGS = + +# assumes MacPorts libpng installation +PNG_INCLUDE = -I/opt/local/include +PNG_LIBS = -I/opt/local/lib + +LDFLAGS = $(PNG_LIBS)-lz -lpng $(OPENMPLD_FLAGS) +CFLAGS = -c -Wall -I./ $(PNG_INCLUDE) $(OPENMP_FLAGS) -O3 -Wno-unused +EXECUTABLE = FLUID_3D + +SOURCES = main.cpp FLUID_3D.cpp FLUID_3D_SOLVERS.cpp FLUID_3D_STATIC.cpp SPHERE.cpp WTURBULENCE.cpp +OBJECTS = $(SOURCES:.cpp=.o) + +all: $(SOURCES) $(EXECUTABLE) + +$(EXECUTABLE): $(OBJECTS) + $(CC) $(OBJECTS) $(LDFLAGS) -o $@ + +.cpp.o: + $(CC) $(CFLAGS) $< -o $@ + +SPHERE.o: SPHERE.h +FLUID_3D.o: FLUID_3D.h FLUID_3D.cpp +FLUID_3D_SOLVERS.o: FLUID_3D.h FLUID_3D_SOLVERS.cpp +main.o: FLUID_3D.h FLUID_3D.cpp FLUID_3D_SOLVERS.cpp + +clean: + rm -f *.o $(EXECUTABLE_LOADER) $(EXECUTABLE) + diff --git a/release/environment-mswindows b/release/environment-mswindows index f8890f89af8..41308533e0b 100644 --- a/release/environment-mswindows +++ b/release/environment-mswindows @@ -1,18 +1,18 @@ -# This is a Blender Environment Variable config file. -# -# Comment lines start with "#", other lines will be split at the "=" -# and the part before will be used as env var name and the part after -# as env var value. The value can make reference to previous or -# prelaunch variables with "%%" and the content will be replaced. -# Once set, values of variables will not be overwritten. -# -# BLENDER_SHARE should be COMMON_APPDATA\\Blender Foundation\\Blender for typical installs. -# BLENDER_VERSION will be set by the program before processing this file. -BLENDER_USER_BASE=%USERPROFILE%\\Blender Foundation\\Blender\\%BLENDER_VERSION% -BLENDER_SYSTEM_BASE=%BLENDER_SHARE%\\%BLENDER_VERSION% -BLENDER_USER_DATAFILES=%USERPROFILE%\\Blender Foundation\\%BLENDER_VERSION%\\datafiles -BLENDER_SYSTEM_DATAFILES=%BLENDER_SHARE%\\%BLENDER_VERSION%\\datafiles -BLENDER_USER_PY=%USERPROFILE%\\Blender Foundation\\%BLENDER_VERSION%\\py -BLENDER_SYSTEM_PY=%BLENDER_SHARE%\\%BLENDER_VERSION%\\py -BLENDER_USER_PLUGINS=%USERPROFILE%\\Blender Foundation\\%BLENDER_VERSION%\\plugins -BLENDER_SYSTEM_PLUGINS=%BLENDER_SHARE%\\%BLENDER_VERSION%\\plugins +# This is a Blender Environment Variable config file. +# +# Comment lines start with "#", other lines will be split at the "=" +# and the part before will be used as env var name and the part after +# as env var value. The value can make reference to previous or +# prelaunch variables with "%%" and the content will be replaced. +# Once set, values of variables will not be overwritten. +# +# BLENDER_SHARE should be COMMON_APPDATA\\Blender Foundation\\Blender for typical installs. +# BLENDER_VERSION will be set by the program before processing this file. +BLENDER_USER_BASE=%USERPROFILE%\\Blender Foundation\\Blender\\%BLENDER_VERSION% +BLENDER_SYSTEM_BASE=%BLENDER_SHARE%\\%BLENDER_VERSION% +BLENDER_USER_DATAFILES=%USERPROFILE%\\Blender Foundation\\%BLENDER_VERSION%\\datafiles +BLENDER_SYSTEM_DATAFILES=%BLENDER_SHARE%\\%BLENDER_VERSION%\\datafiles +BLENDER_USER_PY=%USERPROFILE%\\Blender Foundation\\%BLENDER_VERSION%\\py +BLENDER_SYSTEM_PY=%BLENDER_SHARE%\\%BLENDER_VERSION%\\py +BLENDER_USER_PLUGINS=%USERPROFILE%\\Blender Foundation\\%BLENDER_VERSION%\\plugins +BLENDER_SYSTEM_PLUGINS=%BLENDER_SHARE%\\%BLENDER_VERSION%\\plugins diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index 9a29b713882..f7e5b988cc8 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -144,6 +144,9 @@ def resolve_ncase(path): dirpath = os.path.dirname(dirpath) if not os.path.exists(dirpath): + if dirpath == path: + return path, False + dirpath, found = _ncase_path_found(dirpath) if not found: diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 27ac1d6ea79..a2d7b9e502f 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -35,6 +35,7 @@ import addon_utils as _addon_utils _script_module_dirs = "startup", "modules" + def _test_import(module_name, loaded_modules): use_time = _bpy.app.debug diff --git a/release/scripts/modules/bpy_extras/__init__.py b/release/scripts/modules/bpy_extras/__init__.py new file mode 100644 index 00000000000..e124d3c5b3d --- /dev/null +++ b/release/scripts/modules/bpy_extras/__init__.py @@ -0,0 +1,31 @@ +# ##### 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 ##### + +# + +""" +Utility modules assosiated with the bpy module. +""" + +__all__ = ( + "object_utils", + "io_utils", + "image_utils", + "mesh_utils", + "view3d_utils", +) \ No newline at end of file diff --git a/release/scripts/modules/image_utils.py b/release/scripts/modules/bpy_extras/image_utils.py similarity index 100% rename from release/scripts/modules/image_utils.py rename to release/scripts/modules/bpy_extras/image_utils.py diff --git a/release/scripts/modules/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py similarity index 54% rename from release/scripts/modules/io_utils.py rename to release/scripts/modules/bpy_extras/io_utils.py index 4fcfcfbd0a9..820d7cfa39d 100644 --- a/release/scripts/modules/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -67,6 +67,86 @@ class ImportHelper: return {'RUNNING_MODAL'} +# Axis conversion function, not pretty LUT +# use lookup tabes to convert between any axis +_axis_convert_matrix = ( + ((-1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, 1.0)), + ((-1.0, 0.0, 0.0), (0.0, 0.0, -1.0), (0.0, -1.0, 0.0)), + ((-1.0, 0.0, 0.0), (0.0, 0.0, 1.0), (0.0, 1.0, 0.0)), + ((-1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, -1.0)), + ((0.0, -1.0, 0.0), (-1.0, 0.0, 0.0), (0.0, 0.0, -1.0)), + ((0.0, -1.0, 0.0), (0.0, 0.0, -1.0), (1.0, 0.0, 0.0)), + ((0.0, -1.0, 0.0), (0.0, 0.0, 1.0), (-1.0, 0.0, 0.0)), + ((0.0, -1.0, 0.0), (1.0, 0.0, 0.0), (0.0, 0.0, 1.0)), + ((0.0, 0.0, -1.0), (-1.0, 0.0, 0.0), (0.0, 1.0, 0.0)), + ((0.0, 0.0, -1.0), (0.0, -1.0, 0.0), (-1.0, 0.0, 0.0)), + ((0.0, 0.0, -1.0), (0.0, 1.0, 0.0), (1.0, 0.0, 0.0)), + ((0.0, 0.0, -1.0), (1.0, 0.0, 0.0), (0.0, -1.0, 0.0)), + ((0.0, 0.0, 1.0), (-1.0, 0.0, 0.0), (0.0, -1.0, 0.0)), + ((0.0, 0.0, 1.0), (0.0, -1.0, 0.0), (1.0, 0.0, 0.0)), + ((0.0, 0.0, 1.0), (0.0, 1.0, 0.0), (-1.0, 0.0, 0.0)), + ((0.0, 0.0, 1.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0)), + ((0.0, 1.0, 0.0), (-1.0, 0.0, 0.0), (0.0, 0.0, 1.0)), + ((0.0, 1.0, 0.0), (0.0, 0.0, -1.0), (-1.0, 0.0, 0.0)), + ((0.0, 1.0, 0.0), (0.0, 0.0, 1.0), (1.0, 0.0, 0.0)), + ((0.0, 1.0, 0.0), (1.0, 0.0, 0.0), (0.0, 0.0, -1.0)), + ((1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, -1.0)), + ((1.0, 0.0, 0.0), (0.0, 0.0, -1.0), (0.0, 1.0, 0.0)), + ((1.0, 0.0, 0.0), (0.0, 0.0, 1.0), (0.0, -1.0, 0.0)), + ) + +# store args as a single int +# (X Y Z -X -Y -Z) --> (0, 1, 2, 3, 4, 5) +# each value is ((src_forward, src_up), (dst_forward, dst_up)) +# where all 4 values are or'd into a single value... +# (i1<<0 | i1<<3 | i1<<6 | i1<<9) +_axis_convert_lut = ( + {0x5c, 0x9a, 0x119, 0x15d, 0x20b, 0x2a2, 0x2c8, 0x365, 0x413, 0x46c, 0x4d0, 0x529, 0x644, 0x682, 0x701, 0x745, 0x823, 0x88a, 0x8e0, 0x94d, 0xa2b, 0xa54, 0xae8, 0xb11}, + {0x9c, 0xac, 0x159, 0x169, 0x22b, 0x2e8, 0x40b, 0x465, 0x4c8, 0x522, 0x684, 0x694, 0x741, 0x751, 0x813, 0x8d0, 0xa23, 0xa4d, 0xae0, 0xb0a}, + {0x99, 0xa9, 0x15c, 0x16c, 0x213, 0x2d0, 0x423, 0x44a, 0x4e0, 0x50d, 0x681, 0x691, 0x744, 0x754, 0x82b, 0x8e8, 0xa0b, 0xa62, 0xac8, 0xb25}, + {0x59, 0x85, 0x11c, 0x142, 0x223, 0x28d, 0x2e0, 0x34a, 0x42b, 0x469, 0x4e8, 0x52c, 0x641, 0x69d, 0x704, 0x75a, 0x80b, 0x8a5, 0x8c8, 0x962, 0xa13, 0xa51, 0xad0, 0xb14}, + {0xa5, 0x162, 0x21c, 0x285, 0x2d9, 0x342, 0x463, 0x46b, 0x520, 0x528, 0x68d, 0x74a, 0x804, 0x89d, 0x8c1, 0x95a, 0xa4b, 0xa53, 0xb08, 0xb10}, + {0x4b, 0x53, 0x108, 0x110, 0x29c, 0x2ac, 0x359, 0x369, 0x41a, 0x422, 0x4dd, 0x4e5, 0x663, 0x66b, 0x720, 0x728, 0x884, 0x894, 0x941, 0x951, 0xa02, 0xa0a, 0xac5, 0xacd}, + {0x63, 0x6b, 0x120, 0x128, 0x299, 0x2a9, 0x35c, 0x36c, 0x405, 0x40d, 0x4c2, 0x4ca, 0x64b, 0x653, 0x708, 0x710, 0x881, 0x891, 0x944, 0x954, 0xa1d, 0xa25, 0xada, 0xae2}, + {0x8a, 0x14d, 0x219, 0x29a, 0x2dc, 0x35d, 0x44b, 0x453, 0x508, 0x510, 0x6a2, 0x765, 0x801, 0x882, 0x8c4, 0x945, 0xa63, 0xa6b, 0xb20, 0xb28}, + {0x5a, 0x62, 0x8b, 0x11d, 0x125, 0x148, 0x22c, 0x28b, 0x293, 0x2e9, 0x348, 0x350, 0x41c, 0x42c, 0x45a, 0x4d9, 0x4e9, 0x51d, 0x642, 0x64a, 0x6a3, 0x705, 0x70d, 0x760, 0x814, 0x8a3, 0x8ab, 0x8d1, 0x960, 0x968, 0xa04, 0xa14, 0xa42, 0xac1, 0xad1, 0xb05}, + {0x54, 0xab, 0x111, 0x168, 0x21d, 0x225, 0x2da, 0x2e2, 0x45c, 0x519, 0x66c, 0x693, 0x729, 0x750, 0x805, 0x80d, 0x8c2, 0x8ca, 0xa44, 0xb01}, + {0x51, 0x93, 0x114, 0x150, 0x202, 0x20a, 0x2c5, 0x2cd, 0x459, 0x51c, 0x669, 0x6ab, 0x72c, 0x768, 0x81a, 0x822, 0x8dd, 0x8e5, 0xa41, 0xb04}, + {0x45, 0x4d, 0xa3, 0x102, 0x10a, 0x160, 0x229, 0x2a3, 0x2ab, 0x2ec, 0x360, 0x368, 0x419, 0x429, 0x445, 0x4dc, 0x4ec, 0x502, 0x65d, 0x665, 0x68b, 0x71a, 0x722, 0x748, 0x811, 0x88b, 0x893, 0x8d4, 0x948, 0x950, 0xa01, 0xa11, 0xa5d, 0xac4, 0xad4, 0xb1a}, + {0x5d, 0x65, 0xa0, 0x11a, 0x122, 0x163, 0x214, 0x2a0, 0x2a8, 0x2d1, 0x363, 0x36b, 0x404, 0x414, 0x45d, 0x4c1, 0x4d1, 0x51a, 0x645, 0x64d, 0x688, 0x702, 0x70a, 0x74b, 0x82c, 0x888, 0x890, 0x8e9, 0x94b, 0x953, 0xa1c, 0xa2c, 0xa45, 0xad9, 0xae9, 0xb02}, + {0x6c, 0x90, 0x129, 0x153, 0x21a, 0x222, 0x2dd, 0x2e5, 0x444, 0x501, 0x654, 0x6a8, 0x711, 0x76b, 0x802, 0x80a, 0x8c5, 0x8cd, 0xa5c, 0xb19}, + {0x69, 0xa8, 0x12c, 0x16b, 0x205, 0x20d, 0x2c2, 0x2ca, 0x441, 0x504, 0x651, 0x690, 0x714, 0x753, 0x81d, 0x825, 0x8da, 0x8e2, 0xa59, 0xb1c}, + {0x42, 0x4a, 0x88, 0x105, 0x10d, 0x14b, 0x211, 0x288, 0x290, 0x2d4, 0x34b, 0x353, 0x401, 0x411, 0x442, 0x4c4, 0x4d4, 0x505, 0x65a, 0x662, 0x6a0, 0x71d, 0x725, 0x763, 0x829, 0x8a0, 0x8a8, 0x8ec, 0x963, 0x96b, 0xa19, 0xa29, 0xa5a, 0xadc, 0xaec, 0xb1d}, + {0xa2, 0x165, 0x204, 0x282, 0x2c1, 0x345, 0x448, 0x450, 0x50b, 0x513, 0x68a, 0x74d, 0x81c, 0x89a, 0x8d9, 0x95d, 0xa60, 0xa68, 0xb23, 0xb2b}, + {0x60, 0x68, 0x123, 0x12b, 0x284, 0x294, 0x341, 0x351, 0x41d, 0x425, 0x4da, 0x4e2, 0x648, 0x650, 0x70b, 0x713, 0x89c, 0x8ac, 0x959, 0x969, 0xa05, 0xa0d, 0xac2, 0xaca}, + {0x48, 0x50, 0x10b, 0x113, 0x281, 0x291, 0x344, 0x354, 0x402, 0x40a, 0x4c5, 0x4cd, 0x660, 0x668, 0x723, 0x72b, 0x899, 0x8a9, 0x95c, 0x96c, 0xa1a, 0xa22, 0xadd, 0xae5}, + {0x8d, 0x14a, 0x201, 0x29d, 0x2c4, 0x35a, 0x460, 0x468, 0x523, 0x52b, 0x6a5, 0x762, 0x819, 0x885, 0x8dc, 0x942, 0xa48, 0xa50, 0xb0b, 0xb13}, + {0x44, 0x9d, 0x101, 0x15a, 0x220, 0x2a5, 0x2e3, 0x362, 0x428, 0x454, 0x4eb, 0x511, 0x65c, 0x685, 0x719, 0x742, 0x808, 0x88d, 0x8cb, 0x94a, 0xa10, 0xa6c, 0xad3, 0xb29}, + {0x84, 0x94, 0x141, 0x151, 0x210, 0x2d3, 0x420, 0x462, 0x4e3, 0x525, 0x69c, 0x6ac, 0x759, 0x769, 0x828, 0x8eb, 0xa08, 0xa4a, 0xacb, 0xb0d}, + {0x81, 0x91, 0x144, 0x154, 0x228, 0x2eb, 0x408, 0x44d, 0x4cb, 0x50a, 0x699, 0x6a9, 0x75c, 0x76c, 0x810, 0x8d3, 0xa20, 0xa65, 0xae3, 0xb22}, + ) + +_axis_convert_num = {'X': 0, 'Y': 1, 'Z': 2, '-X': 3, '-Y': 4, '-Z': 5} + + +def axis_conversion(from_forward='Y', from_up='Z', to_forward='Y', to_up='Z'): + """ + Each argument us an axis in ['X', 'Y', 'Z', '-X', '-Y', '-Z'] + where the first 2 are a source and the second 2 are the target. + """ + from mathutils import Matrix + from functools import reduce + + if from_forward == to_forward and from_up == to_up: + return Matrix().to_3x3() + + value = reduce(int.__or__, (_axis_convert_num[a] << (i * 3) for i, a in enumerate((from_forward, from_up, to_forward, to_up)))) + for i, axis_lut in enumerate(_axis_convert_lut): + if value in axis_lut: + return Matrix(_axis_convert_matrix[i]) + assert("internal error") + + # limited replacement for BPyImage.comprehensiveImageLoad def load_image(imagepath, dirname): import os @@ -198,7 +278,7 @@ def path_reference(filepath, base_src, base_dst, mode='AUTO', copy_subdir="", co def path_reference_copy(copy_set, report=print): """ Execute copying files of path_reference - + :arg copy_set: set of (from, to) pairs to copy. :type copy_set: set :arg report: function used for reporting warnings, takes a string argument. diff --git a/release/scripts/modules/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py similarity index 100% rename from release/scripts/modules/mesh_utils.py rename to release/scripts/modules/bpy_extras/mesh_utils.py diff --git a/release/scripts/modules/add_object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py similarity index 100% rename from release/scripts/modules/add_object_utils.py rename to release/scripts/modules/bpy_extras/object_utils.py diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py new file mode 100644 index 00000000000..15f5aaa20b7 --- /dev/null +++ b/release/scripts/modules/bpy_extras/view3d_utils.py @@ -0,0 +1,93 @@ +# ##### 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 ##### + +# + + +def region_2d_to_vector_3d(region, rv3d, coord): + """ + Return a direction vector from the viewport at the spesific 2d region + coordinate. + + :arg region: region of the 3D viewport, typically bpy.context.region. + :type region: :class:`Region` + :arg rv3d: 3D region data, typically bpy.context.space_data.region_3d. + :type rv3d: :class:`RegionView3D` + :arg coord: 2d coordinates relative to the region; + (event.mouse_region_x, event.mouse_region_y) for example. + :type coord: 2d vector + :return: normalized 3d vector. + :rtype: :class:`Vector` + """ + from mathutils import Vector + + dx = (2.0 * coord[0] / region.width) - 1.0 + dy = (2.0 * coord[1] / region.height) - 1.0 + + viewvec = rv3d.view_matrix.inverted()[2].to_3d().normalized() + perspinv_x, perspinv_y = rv3d.perspective_matrix.inverted().to_3x3()[0:2] + return ((perspinv_x * dx + perspinv_y * dy) - viewvec).normalized() + + +def region_2d_to_location_3d(region, rv3d, coord, depth_location): + """ + Return a 3d location from the region relative 2d coords, aligned with + *depth_location*. + + :arg region: region of the 3D viewport, typically bpy.context.region. + :type region: :class:`Region` + :arg rv3d: 3D region data, typically bpy.context.space_data.region_3d. + :type rv3d: :class:`RegionView3D` + :arg coord: 2d coordinates relative to the region; + (event.mouse_region_x, event.mouse_region_y) for example. + :type coord: 2d vector + :arg depth_location: the returned vectors depth is aligned with this since + there is no defined depth with a 2d region input. + :type depth_location: 3d vector + :return: normalized 3d vector. + :rtype: :class:`Vector` + """ + from mathutils.geometry import intersect_point_line + origin_start = rv3d.view_matrix.inverted()[3].to_3d() + origin_end = origin_start + region_2d_to_vector_3d(region, rv3d, coord) + return intersect_point_line(depth_location, origin_start, origin_end)[0] + + +def location_3d_to_region_2d(region, rv3d, coord): + """ + Return the *region* relative 2d location of a 3d position. + + :arg region: region of the 3D viewport, typically bpy.context.region. + :type region: :class:`Region` + :arg rv3d: 3D region data, typically bpy.context.space_data.region_3d. + :type rv3d: :class:`RegionView3D` + :arg coord: 3d worldspace location. + :type coord: 3d vector + :return: 2d location + :rtype: :class:`Vector` + """ + prj = Vector((coord[0], coord[1], coord[2], 1.0)) * rv3d.perspective_matrix + if prj.w > 0.0: + width_half = region.width / 2.0 + height_half = region.height / 2.0 + + return Vector((width_half + width_half * (prj.x / prj.w), + height_half + height_half * (prj.y / prj.w), + )) + else: + return None diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index 460330a56a1..6ab803cc469 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -132,7 +132,7 @@ class AddTorus(bpy.types.Operator): mesh.faces.foreach_set("vertices_raw", faces) mesh.update() - import add_object_utils - add_object_utils.object_data_add(context, mesh, operator=self) + from bpy_extras import object_utils + object_utils.object_data_add(context, mesh, operator=self) return {'FINISHED'} diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index 5c565fbd300..2f933fb5771 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -102,7 +102,8 @@ def register(): ('Render', "Render", ""), ('Rigging', "Rigging", ""), ('Text Editor', "Text Editor", ""), - ('System', "System", "") + ('System', "System", ""), + ('Other', "Other", ""), ], name="Category", description="Filter add-ons by category", diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index e5076fd20d5..80cd5227fca 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -127,6 +127,7 @@ class DATA_PT_camera_display(CameraButtonsPanel, bpy.types.Panel): col.prop(cam, "show_mist", text="Mist") col.prop(cam, "show_title_safe", text="Title Safe") col.prop(cam, "show_name", text="Name") + col.prop_menu_enum(cam, "show_guide") col = split.column() col.prop(cam, "draw_size", text="Size") diff --git a/release/scripts/startup/bl_ui/properties_data_empty.py b/release/scripts/startup/bl_ui/properties_data_empty.py index e46cd1270ad..80f83e7fabe 100644 --- a/release/scripts/startup/bl_ui/properties_data_empty.py +++ b/release/scripts/startup/bl_ui/properties_data_empty.py @@ -39,6 +39,17 @@ class DATA_PT_empty(DataButtonsPanel, bpy.types.Panel): ob = context.object layout.prop(ob, "empty_draw_type", text="Display") + + if ob.empty_draw_type == 'IMAGE': + # layout.template_image(ob, "data", None) + layout.template_ID(ob, "data", open="image.open", unlink="image.unlink") + + row = layout.row(align = True) + row.prop(ob, "color", text="Transparency", index=3, slider=True) + row = layout.row(align = True) + row.prop(ob, "empty_image_offset", text="Offset X", index=0) + row.prop(ob, "empty_image_offset", text="Offset Y", index=1) + layout.prop(ob, "empty_draw_size", text="Size") if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index b1d1789fadd..7097988d25b 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -46,6 +46,8 @@ class MESH_MT_shape_key_specials(bpy.types.Menu): layout.operator("object.shape_key_transfer", icon='COPY_ID') # icon is not ideal layout.operator("object.join_shapes", icon='COPY_ID') # icon is not ideal layout.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT') + op = layout.operator("object.shape_key_add", icon='ZOOMIN', text="New Shape From Mix") + op.from_mix = True class MeshButtonsPanel(): @@ -193,7 +195,8 @@ class DATA_PT_shape_keys(MeshButtonsPanel, bpy.types.Panel): col = row.column() sub = col.column(align=True) - sub.operator("object.shape_key_add", icon='ZOOMIN', text="") + op = sub.operator("object.shape_key_add", icon='ZOOMIN', text="") + op.from_mix = False sub.operator("object.shape_key_remove", icon='ZOOMOUT', text="") sub.menu("MESH_MT_shape_key_specials", icon='DOWNARROW_HLT', text="") diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 1fa79a88f43..75069993521 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -219,7 +219,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel): col.label(text="Texture Coordinates:") col.prop(md, "texture_coords", text="") if md.texture_coords == 'OBJECT': - layout.prop(md, "texture_coordinate_object", text="Object") + layout.prop(md, "texture_coords_object", text="Object") elif md.texture_coords == 'UV' and ob.type == 'MESH': layout.prop_search(md, "uv_layer", ob.data, "uv_textures") @@ -673,9 +673,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, bpy.types.Panel): col.prop(md, "texture_coords", text="") if md.texture_coords == 'OBJECT': - layout.prop(md, "texture_coordinate_object", text="Object") + layout.prop(md, "texture_coords_object", text="Object") elif md.texture_coords == 'UV' and ob.type == 'MESH': - layout.prop_object(md, "uv_layer", ob.data, "uv_textures") + layout.prop_search(md, "uv_layer", ob.data, "uv_textures") def WAVE(self, layout, ob, md): split = layout.split() diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 77583b80824..44a1c814e28 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -436,7 +436,8 @@ class IMAGE_PT_game_properties(bpy.types.Panel): def poll(cls, context): rd = context.scene.render sima = context.space_data - return (sima and sima.image) and (rd.engine == 'BLENDER_GAME') + # display even when not in game mode because these settings effect the 3d view + return (sima and sima.image) # and (rd.engine == 'BLENDER_GAME') def draw(self, context): layout = self.layout diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 2079aef6402..858c619d3c1 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -213,6 +213,7 @@ class SEQUENCER_MT_add_effect(bpy.types.Menu): layout.operator("sequencer.effect_strip_add", text="Color").type = 'COLOR' layout.operator("sequencer.effect_strip_add", text="Speed Control").type = 'SPEED' layout.operator("sequencer.effect_strip_add", text="Multicam Selector").type = 'MULTICAM' + layout.operator("sequencer.effect_strip_add", text="Adjustment Layer").type = 'ADJUSTMENT' class SEQUENCER_MT_strip(bpy.types.Menu): @@ -391,7 +392,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, bpy.types.Panel): 'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'PLUGIN', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED', - 'MULTICAM'} + 'MULTICAM', 'ADJUSTMENT'} def draw(self, context): layout = self.layout @@ -530,7 +531,7 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, bpy.types.Panel): 'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'PLUGIN', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', - 'MULTICAM', 'SPEED'} + 'MULTICAM', 'SPEED', 'ADJUSTMENT'} def draw(self, context): layout = self.layout @@ -680,7 +681,7 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, bpy.types.Panel): 'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'PLUGIN', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', - 'MULTICAM', 'SPEED'} + 'MULTICAM', 'SPEED', 'ADJUSTMENT'} def draw(self, context): layout = self.layout diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index 3d3fc8499af..5b07e8dc37f 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -129,6 +129,7 @@ class TEXT_PT_find(bpy.types.Panel): layout.operator("text.mark_all") # settings + layout.prop(st, "use_match_case") row = layout.row() row.prop(st, "use_find_wrap", text="Wrap") row.prop(st, "use_find_all", text="All") diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 7d31bc39b0a..e6ce1d4c179 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2024,6 +2024,9 @@ class VIEW3D_PT_view3d_properties(bpy.types.Panel): elif not view.lock_object: col.prop(view, "lock_cursor", text="Lock to Cursor") + col = layout.column() + col.prop(view, "lock_camera") + col = layout.column(align=True) col.label(text="Clip:") col.prop(view, "clip_start", text="Start") diff --git a/release/scripts/templates/operator_export.py b/release/scripts/templates/operator_export.py index 1b1c90c8a21..4cf943a53b7 100644 --- a/release/scripts/templates/operator_export.py +++ b/release/scripts/templates/operator_export.py @@ -12,7 +12,7 @@ def write_some_data(context, filepath, use_some_setting): # ExportHelper is a helper class, defines filename and # invoke() function which calls the file selector. -from io_utils import ExportHelper +from bpy_extras.io_utils import ExportHelper from bpy.props import StringProperty, BoolProperty, EnumProperty diff --git a/release/scripts/templates/operator_mesh_add.py b/release/scripts/templates/operator_mesh_add.py index 65b08eebb4e..10d23a6712d 100644 --- a/release/scripts/templates/operator_mesh_add.py +++ b/release/scripts/templates/operator_mesh_add.py @@ -80,8 +80,8 @@ class AddBox(bpy.types.Operator): mesh.update() # add the mesh as an object into the scene with this utility module - import add_object_utils - add_object_utils.object_data_add(context, mesh, operator=self) + from bpy_extras import object_utils + object_utils.object_data_add(context, mesh, operator=self) return {'FINISHED'} diff --git a/release/windows/installer/00.sconsblender.nsi b/release/windows/installer/00.sconsblender.nsi index 2a37f7f6ba6..03f62f0df48 100644 --- a/release/windows/installer/00.sconsblender.nsi +++ b/release/windows/installer/00.sconsblender.nsi @@ -1,261 +1,261 @@ -; -; $Id$ -; -; Blender Self-Installer for Windows (NSIS - http://nsis.sourceforge.net) -; - -SetCompressor /SOLID lzma - -Name "Blender [VERSION]" - -RequestExecutionLevel admin - -!include "MUI.nsh" -!include "WinVer.nsh" -!include "FileFunc.nsh" -!include "WordFunc.nsh" -!include "nsDialogs.nsh" -!include "x64.nsh" - -!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." -!define MUI_WELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp" -!define MUI_HEADERIMAGE -!define MUI_HEADERIMAGE_BITMAP "[RELDIR]\00.header.bmp" -!define MUI_COMPONENTSPAGE_SMALLDESC -!define MUI_FINISHPAGE_RUN "$INSTDIR\blender.exe" -!define MUI_CHECKBITMAP "[RELDIR]\00.checked.bmp" -!define MUI_UNWELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp" - -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "[DISTDIR]\Copyright.txt" -!insertmacro MUI_PAGE_COMPONENTS - -!insertmacro MUI_PAGE_DIRECTORY -Page custom DataLocation DataLocationOnLeave -!insertmacro MUI_PAGE_INSTFILES -!insertmacro MUI_PAGE_FINISH - -!insertmacro MUI_UNPAGE_WELCOME -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES -!insertmacro MUI_UNPAGE_FINISH - -!insertmacro Locate -!insertmacro VersionCompare - - -Icon "[RELDIR]\00.installer.ico" -UninstallIcon "[RELDIR]\00.installer.ico" - -;-------------------------------- -;Languages - - !insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -;Language Strings - - ;Description - 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 $INSTDIR ; $INSTDIR is set inside .onInit -BrandingText "Blender Foundation | http://www.blender.org" -ComponentText "This will install Blender [VERSION] on your computer." - -DirText "Use the field below to specify the folder where you want Blender to be copied to. To specify a different folder, type a new name or use the Browse button to select an existing folder." - -SilentUnInstall normal - -Var BLENDERHOME -Var SHORTVERSION ; This is blender_version_decimal() from path_util.c - -; Custom controls -Var HWND - -Var HWND_APPDATA -Var HWND_INSTDIR -Var HWND_HOMEDIR - -Function .onInit - ClearErrors - 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 -FunctionEnd - -Function DataLocation - nsDialogs::Create /NOUNLOAD 1018 - Pop $HWND - - ${If} $HWND == error - Abort - ${EndIf} - - ${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 80 100% 12u "Use installation directory" - Pop $HWND_INSTDIR - ${NSD_CreateRadioButton} 0 110 100% 12u "I have defined a %HOME% variable, please install files there" - Pop $HWND_HOMEDIR - - ${If} ${AtMostWinME} - GetDlgItem $0 $HWND $HWND_APPDATA - EnableWindow $0 0 - SendMessage $HWND_INSTDIR ${BM_SETCHECK} 1 0 - ${Else} - SendMessage $HWND_APPDATA ${BM_SETCHECK} 1 0 - ${EndIf} - - nsDialogs::Show - -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" - StrCpy $BLENDERHOME $INSTDIR - ${Else} - ${NSD_GetState} $HWND_HOMEDIR $R0 - ${If} $R0 == "1" - ReadEnvStr $BLENDERHOME "HOME" - ${EndIf} - ${EndIf} - ${EndIf} -FunctionEnd - -Section "Blender [VERSION] (required)" InstallFiles - SectionIn RO - - ; Set output path to the installation directory. - SetOutPath $INSTDIR - ; The contents of Blender installation root dir - [ROOTDIRCONTS] - - ; All datafiles (python, scripts, config) - [DODATAFILES] - - SetOutPath $INSTDIR - ${If} ${RunningX64} - SetRegView 64 - ${EndIf} - ; Write the installation path into the registry - WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" "$INSTDIR" - 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" - 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" StartMenu - SetShellVarContext all - CreateDirectory "$SMPROGRAMS\Blender Foundation\Blender\" - CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 - CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Blender.lnk" "$INSTDIR\Blender.exe" "" "$INSTDIR\blender.exe" 0 - 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 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" 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 'Uninstall' to continue." - -Section "Uninstall" - ; 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\BlenderFoundation" - DeleteRegKey HKCR ".blend" - DeleteRegKey HKCR "blendfile" - DeleteRegKey HKCR "CLSID\{D45F043D-F17F-4e8a-8435-70971D9FA46D}" - SetShellVarContext all - - ; Remove files - [DELROOTDIRCONTS] - - 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 - RMDir /r "$BLENDERHOME\$SHORTVERSION\scripts" -NextNoScriptRemove: - MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\config? NOTE: This includes your startup.blend, bookmarks and any other file and directory you may have created in that directory" IDNO NextNoConfigRemove - RMDir /r "$BLENDERHOME\$SHORTVERSION\config" -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 - RMDir "$BLENDERHOME\$SHORTVERSION\plugins" - RMDir "$BLENDERHOME\$SHORTVERSION\config" - RMDir "$BLENDERHOME\$SHORTVERSION\scripts" - RMDir "$BLENDERHOME\$SHORTVERSION" - RMDir "$BLENDERHOME" - ; Remove shortcuts - Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*" - Delete "$DESKTOP\Blender.lnk" - ; Remove all link related directories and files - RMDir /r "$SMPROGRAMS\Blender Foundation" - ; Clear out installation dir - 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 ${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 - +; +; $Id$ +; +; Blender Self-Installer for Windows (NSIS - http://nsis.sourceforge.net) +; + +SetCompressor /SOLID lzma + +Name "Blender [VERSION]" + +RequestExecutionLevel admin + +!include "MUI.nsh" +!include "WinVer.nsh" +!include "FileFunc.nsh" +!include "WordFunc.nsh" +!include "nsDialogs.nsh" +!include "x64.nsh" + +!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." +!define MUI_WELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp" +!define MUI_HEADERIMAGE +!define MUI_HEADERIMAGE_BITMAP "[RELDIR]\00.header.bmp" +!define MUI_COMPONENTSPAGE_SMALLDESC +!define MUI_FINISHPAGE_RUN "$INSTDIR\blender.exe" +!define MUI_CHECKBITMAP "[RELDIR]\00.checked.bmp" +!define MUI_UNWELCOMEFINISHPAGE_BITMAP "[RELDIR]\01.installer.bmp" + +!insertmacro MUI_PAGE_WELCOME +!insertmacro MUI_PAGE_LICENSE "[DISTDIR]\Copyright.txt" +!insertmacro MUI_PAGE_COMPONENTS + +!insertmacro MUI_PAGE_DIRECTORY +Page custom DataLocation DataLocationOnLeave +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH + +!insertmacro MUI_UNPAGE_WELCOME +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES +!insertmacro MUI_UNPAGE_FINISH + +!insertmacro Locate +!insertmacro VersionCompare + + +Icon "[RELDIR]\00.installer.ico" +UninstallIcon "[RELDIR]\00.installer.ico" + +;-------------------------------- +;Languages + + !insertmacro MUI_LANGUAGE "English" + +;-------------------------------- +;Language Strings + + ;Description + 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 $INSTDIR ; $INSTDIR is set inside .onInit +BrandingText "Blender Foundation | http://www.blender.org" +ComponentText "This will install Blender [VERSION] on your computer." + +DirText "Use the field below to specify the folder where you want Blender to be copied to. To specify a different folder, type a new name or use the Browse button to select an existing folder." + +SilentUnInstall normal + +Var BLENDERHOME +Var SHORTVERSION ; This is blender_version_decimal() from path_util.c + +; Custom controls +Var HWND + +Var HWND_APPDATA +Var HWND_INSTDIR +Var HWND_HOMEDIR + +Function .onInit + ClearErrors + 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 +FunctionEnd + +Function DataLocation + nsDialogs::Create /NOUNLOAD 1018 + Pop $HWND + + ${If} $HWND == error + Abort + ${EndIf} + + ${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 80 100% 12u "Use installation directory" + Pop $HWND_INSTDIR + ${NSD_CreateRadioButton} 0 110 100% 12u "I have defined a %HOME% variable, please install files there" + Pop $HWND_HOMEDIR + + ${If} ${AtMostWinME} + GetDlgItem $0 $HWND $HWND_APPDATA + EnableWindow $0 0 + SendMessage $HWND_INSTDIR ${BM_SETCHECK} 1 0 + ${Else} + SendMessage $HWND_APPDATA ${BM_SETCHECK} 1 0 + ${EndIf} + + nsDialogs::Show + +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" + StrCpy $BLENDERHOME $INSTDIR + ${Else} + ${NSD_GetState} $HWND_HOMEDIR $R0 + ${If} $R0 == "1" + ReadEnvStr $BLENDERHOME "HOME" + ${EndIf} + ${EndIf} + ${EndIf} +FunctionEnd + +Section "Blender [VERSION] (required)" InstallFiles + SectionIn RO + + ; Set output path to the installation directory. + SetOutPath $INSTDIR + ; The contents of Blender installation root dir + [ROOTDIRCONTS] + + ; All datafiles (python, scripts, config) + [DODATAFILES] + + SetOutPath $INSTDIR + ${If} ${RunningX64} + SetRegView 64 + ${EndIf} + ; Write the installation path into the registry + WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" "$INSTDIR" + 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" + 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" StartMenu + SetShellVarContext all + CreateDirectory "$SMPROGRAMS\Blender Foundation\Blender\" + CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 + CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Blender.lnk" "$INSTDIR\Blender.exe" "" "$INSTDIR\blender.exe" 0 + 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 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" 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 'Uninstall' to continue." + +Section "Uninstall" + ; 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\BlenderFoundation" + DeleteRegKey HKCR ".blend" + DeleteRegKey HKCR "blendfile" + DeleteRegKey HKCR "CLSID\{D45F043D-F17F-4e8a-8435-70971D9FA46D}" + SetShellVarContext all + + ; Remove files + [DELROOTDIRCONTS] + + 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 + RMDir /r "$BLENDERHOME\$SHORTVERSION\scripts" +NextNoScriptRemove: + MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\config? NOTE: This includes your startup.blend, bookmarks and any other file and directory you may have created in that directory" IDNO NextNoConfigRemove + RMDir /r "$BLENDERHOME\$SHORTVERSION\config" +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 + RMDir "$BLENDERHOME\$SHORTVERSION\plugins" + RMDir "$BLENDERHOME\$SHORTVERSION\config" + RMDir "$BLENDERHOME\$SHORTVERSION\scripts" + RMDir "$BLENDERHOME\$SHORTVERSION" + RMDir "$BLENDERHOME" + ; Remove shortcuts + Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*" + Delete "$DESKTOP\Blender.lnk" + ; Remove all link related directories and files + RMDir /r "$SMPROGRAMS\Blender Foundation" + ; Clear out installation dir + 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 ${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/CMakeLists.txt b/source/CMakeLists.txt index 1929f19f38f..5d0354ccd72 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -27,7 +27,6 @@ add_subdirectory(blender) if(WITH_GAMEENGINE) - add_subdirectory(kernel) add_subdirectory(gameengine) endif() diff --git a/source/SConscript b/source/SConscript index 8d08d9cca08..0002cb4cf0b 100644 --- a/source/SConscript +++ b/source/SConscript @@ -4,7 +4,7 @@ Import ('env') SConscript(['blender/SConscript', 'creator/SConscript']) if env['WITH_BF_GAMEENGINE']: - SConscript (['kernel/SConscript', 'gameengine/SConscript']) + SConscript (['gameengine/SConscript']) if env['WITH_BF_PLAYER']: SConscript (['blenderplayer/bad_level_call_stubs/SConscript']) diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index 263d81fab0a..a073f5083e5 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -91,7 +91,6 @@ add_subdirectory(blenlib) add_subdirectory(render) add_subdirectory(blenfont) add_subdirectory(blenloader) -add_subdirectory(readblenfile) add_subdirectory(blenpluginapi) add_subdirectory(ikplugin) add_subdirectory(gpu) @@ -123,6 +122,5 @@ if(WITH_PYTHON) endif() if(WITH_OPENCOLLADA) - add_subdirectory(collada) + add_subdirectory(collada) endif() - diff --git a/source/blender/SConscript b/source/blender/SConscript index 549725a57a0..969bd2966fc 100644 --- a/source/blender/SConscript +++ b/source/blender/SConscript @@ -12,7 +12,6 @@ SConscript(['avi/SConscript', 'imbuf/SConscript', 'makesdna/SConscript', 'makesrna/SConscript', - 'readblenfile/SConscript', 'render/SConscript', 'nodes/SConscript', 'modifiers/SConscript', diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index 15fbfaa2de2..48ee4aed033 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -29,7 +29,7 @@ set(INC ../editors/include ../blenkernel ../../../intern/guardedalloc - ${GLEW_INCLUDE_PATH} + ${GLEW_INCLUDE_PATH} ${FREETYPE_INCLUDE_DIRS} ) diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 857ead0b7cd..fd874d991ea 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -51,6 +51,7 @@ #include "BLF_api.h" #include "blf_internal_types.h" +#include "blf_internal.h" static ListBase global_font_dir= { NULL, NULL }; @@ -150,6 +151,7 @@ char *blf_dir_search(const char *file) return(s); } +#if 0 // UNUSED int blf_dir_split(const char *str, char *file, int *size) { int i, len; @@ -173,6 +175,7 @@ int blf_dir_split(const char *str, char *file, int *size) } return(0); } +#endif /* Some font have additional file with metrics information, * in general, the extension of the file is: .afm or .pfm diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 34df8d72103..9271d8d5a9e 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -44,7 +44,7 @@ int blf_utf8_next(unsigned char *buf, int *iindex); char *blf_dir_search(const char *file); char *blf_dir_metrics_search(const char *filename); -int blf_dir_split(const char *str, char *file, int *size); +// int blf_dir_split(const char *str, char *file, int *size); // UNUSED int blf_font_init(void); void blf_font_exit(void); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 6c415010953..7e9f531162b 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 b /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE release +#define BLENDER_VERSION_CYCLE beta struct ListBase; struct MemFile; diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index a9d379e6c69..ad736cd07bf 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -90,8 +90,7 @@ void brush_painter_free(BrushPainter *painter); unsigned int *brush_gen_texture_cache(struct Brush *br, int half_side); /* radial control */ -void brush_radial_control_invoke(struct wmOperator *op, struct Brush *br, float size_weight); -int brush_radial_control_exec(struct wmOperator *op, struct Brush *br, float size_weight); +struct ImBuf *brush_gen_radial_control_imbuf(struct Brush *br); /* unified strength and size */ diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index b3709853a8c..744ed9dba9c 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -78,7 +78,6 @@ void curvemapping_premultiply(struct CurveMapping *cumap, int restore); int curvemapping_RGBA_does_something(struct CurveMapping *cumap); void curvemapping_initialize(struct CurveMapping *cumap); void curvemapping_table_RGBA(struct CurveMapping *cumap, float **array, int *size); -void colorcorrection_do_ibuf(struct ImBuf *ibuf, const char *profile); void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management); void scopes_free(struct Scopes *scopes); diff --git a/source/blender/blenkernel/BKE_exotic.h b/source/blender/blenkernel/BKE_exotic.h deleted file mode 100644 index 870dd7cb4d5..00000000000 --- a/source/blender/blenkernel/BKE_exotic.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef BKE_EXOTIC_H -#define BKE_EXOTIC_H - -/** \file BKE_exotic.h - * \ingroup bke - * \brief dxf/vrml/stl external file io function prototypes. - * \attention is this used still? Candidate for removal? - */ -struct Mesh; -struct Scene; - -/** - * Reads all 3D fileformats other than Blender fileformat - * @retval 0 The file could not be read. - * @retval 1 The file was read succesfully. - * @attention Used in filesel.c - */ -int BKE_read_exotic(struct Scene *scene, const char *name); - -/* return codes */ -#define BKE_READ_EXOTIC_FAIL_PATH -3 /* file format is not supported */ -#define BKE_READ_EXOTIC_FAIL_FORMAT -2 /* file format is not supported */ -#define BKE_READ_EXOTIC_FAIL_OPEN -1 /* Can't open the file */ -#define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */ -#define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */ - -void write_dxf(struct Scene *scene, char *str); -void write_stl(struct Scene *scene, char *str); - -#endif - diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 57829e957f7..94c474c668f 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -268,6 +268,10 @@ 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); +struct Sequence *seq_metastrip( + ListBase * seqbase /* = ed->seqbase */, + struct Sequence * meta /* = NULL */, struct Sequence *seq); + void seq_offset_animdata(struct Scene *scene, struct Sequence *seq, int ofs); void seq_dupe_animdata(struct Scene *scene, char *name_from, char *name_to); int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test, struct Scene *evil_scene); diff --git a/source/blender/blenkernel/BKE_sketch.h b/source/blender/blenkernel/BKE_sketch.h index 360a95bfb24..087cabc5c3d 100644 --- a/source/blender/blenkernel/BKE_sketch.h +++ b/source/blender/blenkernel/BKE_sketch.h @@ -73,8 +73,8 @@ typedef struct SK_Overdraw typedef struct SK_DrawData { - short mval[2]; - short previous_mval[2]; + int mval[2]; + int previous_mval[2]; SK_PType type; } SK_DrawData; @@ -152,7 +152,7 @@ void sk_endContinuousStroke(SK_Stroke *stk); void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk); -void sk_initDrawData(SK_DrawData *dd, const short mval[2]); +void sk_initDrawData(SK_DrawData *dd, const int mval[2]); void sk_deleteSelectedStrokes(SK_Sketch *sketch); void sk_selectAllSketch(SK_Sketch *sketch, int mode); diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 136ce416037..20e5bc27146 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -58,7 +58,7 @@ void write_text(struct Text *text, const char *str); char* txt_to_buf (struct Text *text); void txt_clean_text (struct Text *text); void txt_order_cursors (struct Text *text); -int txt_find_string (struct Text *text, char *findstr, int wrap); +int txt_find_string (struct Text *text, char *findstr, int wrap, int match_case); int txt_has_sel (struct Text *text); int txt_get_span (struct TextLine *from, struct TextLine *to); void txt_move_up (struct Text *text, short sel); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index ca551e1634a..2831636361f 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -53,7 +53,7 @@ set(INC ../../../intern/opennl/extern ../../../intern/smoke/extern ../../../intern/mikktspace - ../../../source/blender/windowmanager # XXX - BAD LEVEL CALL WM_api.h + ../../../source/blender/windowmanager # XXX - BAD LEVEL CALL WM_api.h ${GLEW_INCLUDE_PATH} ${ZLIB_INCLUDE_DIRS} ) @@ -91,7 +91,6 @@ set(SRC intern/depsgraph.c intern/displist.c intern/effect.c - intern/exotic.c intern/fcurve.c intern/fluidsim.c intern/fmodifier.c @@ -176,7 +175,6 @@ set(SRC BKE_displist.h BKE_effect.h BKE_endian.h - BKE_exotic.h BKE_fcurve.h BKE_fluidsim.h BKE_font.h @@ -279,11 +277,6 @@ if(WITH_CODEC_FFMPEG) add_definitions(-DWITH_FFMPEG) endif() -if(WITH_LCMS) - list(APPEND INC ${LCMS_INCLUDE_DIR}) - add_definitions(-DWITH_LCMS) -endif() - if(WITH_PYTHON) list(APPEND INC ../python ${PYTHON_INCLUDE_DIRS}) add_definitions(-DWITH_PYTHON) @@ -316,7 +309,7 @@ if(WITH_LZMA) endif() if(MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") endif() blender_add_lib(bf_blenkernel "${SRC}" "${INC}") diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index dc327abd3ad..ea19b51c044 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -78,10 +78,6 @@ if env['OURPLATFORM'] == 'darwin': if env['BF_NO_ELBEEM']: defs.append('DISABLE_ELBEEM') -if env['WITH_BF_LCMS']: - defs.append('WITH_LCMS') - incs += ' ' + env['BF_LCMS_INC'] - if env['WITH_BF_LZO']: incs += ' #/extern/lzo/minilzo' defs.append('WITH_LZO') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 5b49d9a9841..77f56058a4f 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -831,7 +831,10 @@ void pose_remove_group (Object *ob) /* now, remove it from the pose */ BLI_freelinkN(&pose->agroups, grp); - pose->active_group= 0; + pose->active_group--; + if(pose->active_group < 0 || pose->agroups.first == NULL) { + pose->active_group= 0; + } } } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 75c6303d800..2fce1175fe1 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -191,7 +191,7 @@ static void clean_paths(Main *main) /* note, this is called on Undo so any slow conversion functions here * should be avoided or check (mode!='u') */ -static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename) +static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath) { bScreen *curscreen= NULL; Scene *curscene= NULL; @@ -295,18 +295,18 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename if(recover && bfd->filename[0] && G.relbase_valid) { /* in case of autosave or quit.blend, use original filename instead * use relbase_valid to make sure the file is saved, else we get in the filename */ - filename= bfd->filename; + filepath= bfd->filename; } #if 0 else if (!G.relbase_valid) { /* otherwise, use an empty string as filename, rather than */ - filename=""; + filepath=""; } #endif /* these are the same at times, should never copy to the same location */ - if(G.main->name != filename) - BLI_strncpy(G.main->name, filename, FILE_MAX); + if(G.main->name != filepath) + BLI_strncpy(G.main->name, filepath, FILE_MAX); /* baseflags, groups, make depsgraph, etc */ set_scene_bg(G.main, CTX_data_scene(C)); @@ -353,15 +353,15 @@ void BKE_userdef_free(void) BLI_freelistN(&U.addons); } -int BKE_read_file(bContext *C, const char *dir, ReportList *reports) +int BKE_read_file(bContext *C, const char *filepath, ReportList *reports) { BlendFileData *bfd; int retval= BKE_READ_FILE_OK; - if(strstr(dir, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */ - printf("read blend: %s\n", dir); + if(strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */ + printf("read blend: %s\n", filepath); - bfd= BLO_read_from_file(dir, reports); + bfd= BLO_read_from_file(filepath, reports); if (bfd) { if(bfd->user) retval= BKE_READ_FILE_OK_USERPREFS; @@ -372,10 +372,10 @@ int BKE_read_file(bContext *C, const char *dir, ReportList *reports) retval= BKE_READ_FILE_FAIL; } else - setup_app_data(C, bfd, dir); // frees BFD + setup_app_data(C, bfd, filepath); // frees BFD } else - BKE_reports_prependf(reports, "Loading %s failed: ", dir); + BKE_reports_prependf(reports, "Loading %s failed: ", filepath); return (bfd?retval:BKE_READ_FILE_FAIL); } @@ -521,19 +521,19 @@ void BKE_write_undo(bContext *C, const char *name) /* disk save version */ if(UNDO_DISK) { static int counter= 0; - char tstr[FILE_MAXDIR+FILE_MAXFILE]; + char filepath[FILE_MAXDIR+FILE_MAXFILE]; char numstr[32]; - /* calculate current filename */ + /* calculate current filepath */ counter++; counter= counter % U.undosteps; BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter); - BLI_make_file_string("/", tstr, btempdir, numstr); + BLI_make_file_string("/", filepath, btempdir, numstr); - success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL); + success= BLO_write_file(CTX_data_main(C), filepath, G.fileflags, NULL, NULL); - BLI_strncpy(curundo->str, tstr, sizeof(curundo->str)); + BLI_strncpy(curundo->str, filepath, sizeof(curundo->str)); } else { MemFile *prevfile=NULL; diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index fa3b756ae27..98c540f53b7 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -426,13 +426,6 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) curvemapping_changed(b->curve, 0); } -static MTex *brush_active_texture(Brush *brush) -{ - if(brush) - return &brush->mtex; - return NULL; -} - int brush_texture_set_nr(Brush *brush, int nr) { ID *idtest, *id=NULL; @@ -1185,7 +1178,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) } /**** Radial Control ****/ -static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) +struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) { ImBuf *im = MEM_callocN(sizeof(ImBuf), "radial control texture"); unsigned int *texcache; @@ -1219,50 +1212,6 @@ static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) return im; } -void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight) -{ - int mode = RNA_enum_get(op->ptr, "mode"); - float original_value= 0; - - if(mode == WM_RADIALCONTROL_SIZE) - original_value = brush_size(br) * size_weight; - else if(mode == WM_RADIALCONTROL_STRENGTH) - original_value = brush_alpha(br); - else if(mode == WM_RADIALCONTROL_ANGLE) { - MTex *mtex = brush_active_texture(br); - if(mtex) - original_value = mtex->rot; - } - - RNA_float_set(op->ptr, "initial_value", original_value); - op->customdata = brush_gen_radial_control_imbuf(br); -} - -int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight) -{ - int mode = RNA_enum_get(op->ptr, "mode"); - float new_value = RNA_float_get(op->ptr, "new_value"); - const float conv = 0.017453293; - - if(mode == WM_RADIALCONTROL_SIZE) - if (brush_use_locked_size(br)) { - float initial_value = RNA_float_get(op->ptr, "initial_value"); - const float unprojected_radius = brush_unprojected_radius(br); - brush_set_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight); - } - else - brush_set_size(br, new_value * size_weight); - else if(mode == WM_RADIALCONTROL_STRENGTH) - brush_set_alpha(br, new_value); - else if(mode == WM_RADIALCONTROL_ANGLE) { - MTex *mtex = brush_active_texture(br); - if(mtex) - mtex->rot = new_value * conv; - } - - return OPERATOR_FINISHED; -} - /* Unified Size and Strength */ static void set_unified_settings(Brush *brush, short flag, int value) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 1d7481b365a..9a6c2cc7e31 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -37,10 +37,6 @@ #include #include -#ifdef WITH_LCMS -#include -#endif - #include "MEM_guardedalloc.h" #include "DNA_color_types.h" @@ -789,60 +785,6 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float *vecout, const } -#ifdef WITH_LCMS -/* basic error handler, if we dont do this blender will exit */ -static int ErrorReportingFunction(int ErrorCode, const char *ErrorText) -{ - fprintf(stderr, "%s:%d\n", ErrorText, ErrorCode); - return 1; -} -#endif - -void colorcorrection_do_ibuf(ImBuf *ibuf, const char *profile) -{ -#ifdef WITH_LCMS - if (ibuf->crect == NULL) - { - cmsHPROFILE proofingProfile; - - /* TODO, move to initialization area of code */ - //cmsSetLogErrorHandler(ErrorReportingFunction); - cmsSetErrorHandler(ErrorReportingFunction); - - /* will return NULL if the file isn't fount */ - proofingProfile = cmsOpenProfileFromFile(profile, "r"); - - cmsErrorAction(LCMS_ERROR_SHOW); - - if(proofingProfile) { - cmsHPROFILE imageProfile; - cmsHTRANSFORM hTransform; - - ibuf->crect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(int), "imbuf crect"); - - imageProfile = cmsCreate_sRGBProfile(); - - - hTransform = cmsCreateProofingTransform(imageProfile, TYPE_RGBA_8, imageProfile, TYPE_RGBA_8, - proofingProfile, - INTENT_ABSOLUTE_COLORIMETRIC, - INTENT_ABSOLUTE_COLORIMETRIC, - cmsFLAGS_SOFTPROOFING); - - cmsDoTransform(hTransform, ibuf->rect, ibuf->crect, ibuf->x * ibuf->y); - - cmsDeleteTransform(hTransform); - cmsCloseProfile(imageProfile); - cmsCloseProfile(proofingProfile); - } - } -#else - /* unused */ - (void)ibuf; - (void)profile; -#endif -} - /* only used for image editor curves */ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index b5194ca2f89..54e4bf08ee7 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -72,6 +72,8 @@ #include "ED_curve.h" /* for BKE_curve_nurbs */ +extern Material defmaterial; /* material.c */ + static void boundbox_displist(Object *ob); void free_disp_elem(DispList *dl) @@ -552,7 +554,6 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un } for (i=0; imat_nr+1); int j, vidx[4], nverts= mf->v4?4:3; @@ -664,8 +665,6 @@ void shadeDispList(Scene *scene, Base *base) dl= ob->disp.first; while(dl) { - extern Material defmaterial; /* material.c */ - dlob= MEM_callocN(sizeof(DispList), "displistshade"); BLI_addtail(&ob->disp, dlob); dlob->type= DL_VERTCOL; @@ -734,8 +733,6 @@ void shadeDispList(Scene *scene, Base *base) if(dl->type==DL_INDEX4) { if(dl->nors) { - extern Material defmaterial; /* material.c */ - if(dl->col1) MEM_freeN(dl->col1); col1= dl->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1"); @@ -984,16 +981,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) dl= dl->next; } - if(totvert && BLI_edgefill(0)) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { - - /* count faces */ - tot= 0; - efa= fillfacebase.first; - while(efa) { - tot++; - efa= efa->next; - } - + if(totvert && (tot= BLI_edgefill(0))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { if(tot) { dlnew= MEM_callocN(sizeof(DispList), "filldisplist"); dlnew->type= DL_INDEX3; @@ -1973,8 +1961,9 @@ static void boundbox_displist(Object *ob) } if(!doit) { - min[0] = min[1] = min[2] = -1.0f; - max[0] = max[1] = max[2] = 1.0f; + /* there's no geometry in displist, use zero-sized boundbox */ + zero_v3(min); + zero_v3(max); } } diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c deleted file mode 100644 index ae773818438..00000000000 --- a/source/blender/blenkernel/intern/exotic.c +++ /dev/null @@ -1,2485 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * - * Contributor(s): - * - Martin DeMello - * Added dxf_read_arc, dxf_read_ellipse and dxf_read_lwpolyline - * Copyright (C) 2004 by Etheract Software Labs - * - * - Blender Foundation - * - * ***** END GPL LICENSE BLOCK **** - */ - -/** \file blender/blenkernel/intern/exotic.c - * \ingroup bke - */ - - -#include -#include "BLI_storage.h" - -#include -#include /* isdigit, isspace */ -#include -#include - -#include -#include -#include - -#ifndef _WIN32 -#include -#else -#include -#define open _open -#define read _read -#define close _close -#define write _write -#endif - -#include "MEM_guardedalloc.h" - -#include "DNA_object_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_material_types.h" -#include "DNA_curve_types.h" -#include "DNA_camera_types.h" -#include "DNA_scene_types.h" - -#include "BLI_blenlib.h" -#include "BLI_math.h" -#include "BLI_storage.h" -#include "BLI_utildefines.h" - - -#include "BKE_blender.h" -#include "BKE_global.h" -#include "BKE_main.h" -#include "BKE_mesh.h" -#include "BKE_library.h" -#include "BKE_object.h" -#include "BKE_material.h" -#include "BKE_report.h" -#include "BKE_exotic.h" -#include "BKE_displist.h" -#include "BKE_DerivedMesh.h" -#include "BKE_curve.h" - -#ifdef WITH_PYTHON -#include "BPY_extern.h" -#endif - -#include "zlib.h" - -static int is_dxf(const char *str); -static void dxf_read(Scene *scene, const char *filename); -static int is_stl(const char *str); - -static int is_stl_ascii(const char *str) -{ - FILE *fpSTL; - char buffer[1000]; - int numread, i; - - fpSTL = fopen(str, "rb"); - if ( (numread = fread( (void *) buffer, sizeof(char), 1000, fpSTL)) <= 0 ) - { fclose(fpSTL); return 0; } - - for (i=0; i < numread; ++i) { - /* if bit 8 is set we assume binary */ - if (buffer[i] & 0x80) - { fclose(fpSTL); return 0; } - } - - buffer[5] = '\0'; - if ( !(strstr(buffer, "solid")) && !(strstr(buffer, "SOLID")) ) - { fclose(fpSTL); return 0; } - - fclose(fpSTL); - - return 1; -} - -static int is_stl(const char *str) -{ - int i; - i = strlen(str) - 3; - if ( (str[i] !='s') && (str[i] !='S')) - return 0; - i++; - if ( (str[i] !='t') && (str[i] !='T')) - return 0; - i++; - if ( (str[i] !='l') && (str[i] !='L')) - return 0; - - return 1; -} - -#define READSTLVERT { \ - if (fread(mvert->co, sizeof(float), 3, fpSTL) != 3) { \ - char error_msg[255]; \ - MEM_freeN(vertdata); \ - MEM_freeN(facedata); \ - fclose(fpSTL); \ - sprintf(error_msg, "Problems reading face %d!", i); \ - return; \ - } \ - else { \ - if (ENDIAN_ORDER==B_ENDIAN) { \ - SWITCH_INT(mvert->co[0]); \ - SWITCH_INT(mvert->co[1]); \ - SWITCH_INT(mvert->co[2]); \ - } \ - } \ -} - -static void simple_vertex_normal_blend(short *no, short *ble) -{ - if(no[0]==0 && no[1]==0 && no[2]==0) { - VECCOPY(no, ble); - } - else { - no[0]= (2*no[0] + ble[0])/3; - no[1]= (2*no[1] + ble[1])/3; - no[2]= (2*no[2] + ble[2])/3; - } -} - -static void mesh_add_normals_flags(Mesh *me) -{ - MVert *v1, *v2, *v3, *v4; - MFace *mface; - float nor[3]; - int a; - short sno[3]; - - mface= me->mface; - for(a=0; atotface; a++, mface++) { - v1= me->mvert+mface->v1; - 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); - 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); - if(mface->v4) { - simple_vertex_normal_blend(v4->no, sno); - } - mface->edcode= ME_V1V2|ME_V2V3; - } -} - -static void read_stl_mesh_binary(Scene *scene, const char *str) -{ - FILE *fpSTL; - Object *ob; - Mesh *me; - MVert *mvert, *vertdata; - MFace *mface, *facedata; - unsigned int numfacets = 0, i, j, vertnum; - unsigned int maxmeshsize, nummesh, lastmeshsize; - unsigned int totvert, totface; - ReportList *reports= NULL; /* XXX */ - - fpSTL= fopen(str, "rb"); - if(fpSTL==NULL) { - BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno)); - return; - } - - if(fseek(fpSTL, 80, SEEK_SET) != 0) { - BKE_reportf(reports, RPT_ERROR, "Failed reading file: %s.", strerror(errno)); - fclose(fpSTL); - return; - } - - if(fread(&numfacets, 4*sizeof(char), 1, fpSTL) != 1) { - if(feof(fpSTL)) - BKE_reportf(reports, RPT_ERROR, "Failed reading file: premature end of file."); - else - BKE_reportf(reports, RPT_ERROR, "Failed reading file: %s.", strerror(errno)); - fclose(fpSTL); - return; - } - if (ENDIAN_ORDER==B_ENDIAN) { - SWITCH_INT(numfacets); - } - - maxmeshsize = MESH_MAX_VERTS/3; - - nummesh = (numfacets / maxmeshsize) + 1; - lastmeshsize = numfacets % maxmeshsize; - - if (numfacets) { - for (j=0; j < nummesh; ++j) { - /* new object */ - if (j == nummesh-1) { - totface = lastmeshsize; - } - else { - totface = maxmeshsize; - } - totvert = 3 * totface; - - vertdata = MEM_callocN(totvert*sizeof(MVert), "mverts"); - facedata = MEM_callocN(totface*sizeof(MFace), "mface"); - - vertnum = 0; - mvert= vertdata; - mface = facedata; - for (i=0; i < totface; i++) { - fseek(fpSTL, 12, SEEK_CUR); /* skip the face normal */ - READSTLVERT; - mvert++; - READSTLVERT; - mvert++; - READSTLVERT; - mvert++; - - mface->v1 = vertnum++; - mface->v2 = vertnum++; - mface->v3 = vertnum++; - mface++; - - fseek(fpSTL, 2, SEEK_CUR); - } - - ob= add_object(scene, OB_MESH); - me= ob->data; - me->totvert = totvert; - me->totface = totface; - me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, - vertdata, totvert); - me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, - facedata, totface); - - mesh_add_normals_flags(me); - make_edges(me, 0); - } - //XXX waitcursor(1); - } - fclose(fpSTL); - -} -#undef READSTLVERT - -#define STLALLOCERROR { \ - char error_msg[255]; \ - fclose(fpSTL); \ - sprintf(error_msg, "Can't allocate storage for %d faces!", \ - numtenthousand * 10000); \ - return; \ -} - -#define STLBAILOUT(message) { \ - char error_msg[255]; \ - fclose(fpSTL); \ - free(vertdata); \ - sprintf(error_msg, "Line %d: %s", linenum, message); \ - return; \ -} - -#define STLREADLINE { \ - if (!fgets(buffer, 2048, fpSTL)) STLBAILOUT("Can't read line!"); \ - linenum++; \ -} - -#define STLREADVERT { \ - STLREADLINE; \ - if ( !(cp = strstr(buffer, "vertex")) && \ - !(cp = strstr(buffer, "VERTEX")) ) STLBAILOUT("Bad vertex!"); \ - vp = vertdata + 3 * totvert; \ - if (sscanf(cp + 6, "%f %f %f", vp, vp+1, vp+2) != 3) \ - STLBAILOUT("Bad vertex!"); \ - ++totvert; \ -} -static void read_stl_mesh_ascii(Scene *scene, const char *str) -{ - FILE *fpSTL; - char buffer[2048], *cp; - Object *ob; - Mesh *me; - MVert *mvert; - MFace *mface; - float *vertdata, *vp; - unsigned int numtenthousand, linenum; - unsigned int i, vertnum; - unsigned int totvert, totface; - ReportList *reports= NULL; /* XXX */ - - /* ASCII stl sucks ... we don't really know how many faces there - are until the file is done, so lets allocate faces 10000 at a time */ - - fpSTL= fopen(str, "r"); - if(fpSTL==NULL) { - BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno)); - return; - } - - /* we'll use the standard malloc/realloc for now ... - * lets allocate enough storage to hold 10000 triangles, - * i.e. 30000 verts, i.e., 90000 floats. - */ - numtenthousand = 1; - vertdata = malloc(numtenthousand*3*30000*sizeof(float)); // uses realloc! - if (!vertdata) { STLALLOCERROR; } - - linenum = 1; - /* Get rid of the first line */ - STLREADLINE; - - totvert = 0; - totface = 0; - while(1) { - /* Read in the next line */ - STLREADLINE; - - /* lets check if this is the end of the file */ - if ( strstr(buffer, "endsolid") || strstr(buffer, "ENDSOLID") ) - break; - - /* Well, guess that wasn't the end, so lets make - * sure we have enough storage for some more faces - */ - if ( (totface) && ( (totface % 10000) == 0 ) ) { - float *vertdata_old= vertdata; - ++numtenthousand; - vertdata = realloc(vertdata, - numtenthousand*3*30000*sizeof(float)); - if (!vertdata) { - if(vertdata_old) { - free(vertdata_old); - } - STLALLOCERROR; - } - } - - /* Don't read normal, but check line for proper syntax anyway - */ - if ( !(cp = strstr(buffer, "facet")) && - !(cp = strstr(buffer, "FACET")) ) STLBAILOUT("Bad normal line!"); - if ( !(strstr(cp+5, "normal")) && - !(strstr(cp+5, "NORMAL")) ) STLBAILOUT("Bad normal line!"); - - /* Read in what should be the outer loop line - */ - STLREADLINE; - if ( !(cp = strstr(buffer, "outer")) && - !(cp = strstr(buffer, "OUTER")) ) STLBAILOUT("Bad outer loop!"); - if ( !(strstr(cp+5, "loop")) && - !(strstr(cp+5, "LOOP")) ) STLBAILOUT("Bad outer loop!"); - - /* Read in the face */ - STLREADVERT; - STLREADVERT; - STLREADVERT; - - /* Read in what should be the endloop line - */ - STLREADLINE; - if ( !strstr(buffer, "endloop") && !strstr(buffer, "ENDLOOP") ) - STLBAILOUT("Bad endloop!"); - - /* Read in what should be the endfacet line - */ - STLREADLINE; - if ( !strstr(buffer, "endfacet") && !strstr(buffer, "ENDFACET") ) - STLBAILOUT("Bad endfacet!"); - - /* Made it this far? Increment face count */ - ++totface; - } - fclose(fpSTL); - - /* OK, lets create our mesh */ - ob = add_object(scene, OB_MESH); - me = ob->data; - - me->totface = totface; - me->totvert = totvert; - me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, - NULL, totvert); - me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, - NULL, totface); - - /* Copy vert coords and create topology */ - mvert = me->mvert; - mface = me->mface; - vertnum = 0; - for (i=0; i < totface; ++i) { - memcpy(mvert->co, vertdata+3*vertnum, 3*sizeof(float) ); - mface->v1 = vertnum; - mvert++; - vertnum++; - - memcpy(mvert->co, vertdata+3*vertnum, 3*sizeof(float) ); - mface->v2 = vertnum; - mvert++; - vertnum++; - - memcpy(mvert->co, vertdata+3*vertnum, 3*sizeof(float) ); - mface->v3 = vertnum; - mvert++; - vertnum++; - - mface++; - } - free(vertdata); - - mesh_add_normals_flags(me); - make_edges(me, 0); - - //XXX waitcursor(1); -} - -#undef STLALLOCERROR -#undef STLBAILOUT -#undef STLREADLINE -#undef STLREADVERT - -/* ************************************************************ */ - -int BKE_read_exotic(Scene *scene, const char *name) -{ - int len; - gzFile gzfile; - char header[7]; - int retval; - - // make sure we're not trying to read a directory.... - - len= strlen(name); - if (ELEM(name[len-1], '/', '\\')) { - retval= BKE_READ_EXOTIC_FAIL_PATH; - } - else { - gzfile = gzopen(name,"rb"); - - if (gzfile == NULL) { - retval= BKE_READ_EXOTIC_FAIL_OPEN; - } - else { - len= gzread(gzfile, header, sizeof(header)); - gzclose(gzfile); - if (len == sizeof(header) && strncmp(header, "BLENDER", 7) == 0) { - retval= BKE_READ_EXOTIC_OK_BLEND; - } - else { - //XXX waitcursor(1); - if(is_dxf(name)) { - dxf_read(scene, name); - retval= BKE_READ_EXOTIC_OK_OTHER; - } - else if(is_stl(name)) { - if (is_stl_ascii(name)) - read_stl_mesh_ascii(scene, name); - else - read_stl_mesh_binary(scene, name); - retval= BKE_READ_EXOTIC_OK_OTHER; - } - else { - retval= BKE_READ_EXOTIC_FAIL_FORMAT; - } - //XXX waitcursor(0); - } - } - } - - return retval; -} - - -/* ************************ WRITE ************************** */ - -static void write_vert_stl(Object *ob, MVert *verts, int index, FILE *fpSTL) -{ - float vert[3]; - - VECCOPY(vert, verts[(index)].co); - mul_m4_v3(ob->obmat, vert); - - if (ENDIAN_ORDER==B_ENDIAN) { - SWITCH_INT(vert[0]); - SWITCH_INT(vert[1]); - SWITCH_INT(vert[2]); - } - - fwrite(vert, sizeof(float), 3, fpSTL); -} - -static int write_derivedmesh_stl(FILE *fpSTL, Object *ob, DerivedMesh *dm) -{ - MVert *mvert = dm->getVertArray(dm); - MFace *mface = dm->getFaceArray(dm); - int i, numfacets = 0, totface = dm->getNumFaces(dm); - float zero[3] = {0.0f, 0.0f, 0.0f}; - - for (i=0; iv1, fpSTL); - write_vert_stl(ob, mvert, mface->v2, fpSTL); - write_vert_stl(ob, mvert, mface->v3, fpSTL); - fprintf(fpSTL, " "); - numfacets++; - - if(mface->v4) { /* quad = 2 tri's */ - fwrite(zero, sizeof(float), 3, fpSTL); - write_vert_stl(ob, mvert, mface->v1, fpSTL); - write_vert_stl(ob, mvert, mface->v3, fpSTL); - write_vert_stl(ob, mvert, mface->v4, fpSTL); - fprintf(fpSTL, " "); - numfacets++; - } - } - - return numfacets; -} - -static int write_object_stl(FILE *fpSTL, Scene *scene, Object *ob) -{ - int numfacets = 0; - DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - - numfacets += write_derivedmesh_stl(fpSTL, ob, dm); - - dm->release(dm); - - return numfacets; -} - -void write_stl(Scene *scene, char *str) -{ - Object *ob; - Base *base; - FILE *fpSTL; - int numfacets = 0; - ReportList *reports= NULL; /* XXX */ - - /* XXX, operator needs to manage filename extension */ - - fpSTL= fopen(str, "wb"); - - if(fpSTL==NULL) { - BKE_reportf(reports, RPT_ERROR, "Can't open file: %s.", strerror(errno)); - return; - } - - //XXX waitcursor(1); - - /* The header part of the STL */ - /* First 80 characters are a title or whatever you want. - Lets make the first 32 of those spam and the rest the filename. - Those first 80 characters will be followed by 4 bytes - which will be overwritten later with an integer holding - how many facets are written (we set them to ' ' for now). - */ - fprintf(fpSTL, "Binary STL output from Blender: %-48.48s ", str); - - /* Write all selected mesh objects */ - base= scene->base.first; - while(base) { - if (base->flag & SELECT) { - ob = base->object; - if (ob->type == OB_MESH) { - if(ob->data) - numfacets += write_object_stl(fpSTL, scene, ob); - } - } - base= base->next; - } - - /* time to write the number of facets in the 4 bytes - starting at byte 81 - */ - fseek(fpSTL, 80, SEEK_SET); - - if (ENDIAN_ORDER==B_ENDIAN) { - SWITCH_INT(numfacets); - } - fwrite(&numfacets, 4*sizeof(char), 1, fpSTL); - - fclose(fpSTL); - - //XXX waitcursor(0); -} - - -static void replace_chars(char *str1, char *str2) -{ - int a= strlen(str2); - - str1[a]= 0; - while(a--) { - if(str2[a]=='.' || str2[a]==' ') str1[a]= '_'; - else str1[a]= str2[a]; - } -} - -/* ******************************* WRITE DXF ***************************** */ - -#define write_group(id,data) fprintf(fp, "%d\n%s\n", id, data) - -/* A completely wacky function to try and make good -indexed (AutoCAD index) values out of straight rgb -ones... crazy */ - -static int rgb_to_dxf_col (float rf, float gf, float bf) -{ - int r= (int) (rf*255.0f); - int g= (int) (gf*255.0f); - int b= (int) (bf*255.0f); - float h,s,v; - int ret; - - /* Grayscale value */ - if (((int)r/10)==((int)g/10) && ((int)g/10)==((int)b/10)) ret= 250+((int)r/51); - /* A nice chroma value */ - else { - rgb_to_hsv (rf,gf,bf,&h,&s,&v); - - ret= (int) (10.0f + (h*239.0f)); - CLAMP(ret,10,249); - - /* If its whitish make the index odd */ - if (s<.5 || v>.5) if(ret%2) ret++; - } - - return ret; -} - -/* And its completely wacky complement */ - -static void dxf_col_to_rgb (int cid, float *rf, float *gf, float *bf) -{ - float h, s, v; - - /* Grayscale values */ - if (cid>=250 && cid <= 255) { - *rf= *gf= *bf= (float) ((cid-250)*51)/255; - CLAMP(*rf, 0.0, 1.0); - CLAMP(*gf, 0.0, 1.0); - CLAMP(*bf, 0.0, 1.0); - - /* Pure values */ - } else if (cid<10) { - switch (cid) { - case 1: - *rf=1.0; - *gf=0.0; - *bf=0.0; - break; - case 2: - *rf=1.0; - *gf=1.0; - *bf=0.0; - break; - case 3: - *gf=1.0; - *rf=0.0; - *bf=0.0; - break; - case 4: - *rf=0.0; - *gf=1.0; - *bf=1.0; - break; - case 5: - *rf=0.0; - *gf=0.0; - *bf=1.0; - break; - case 6: - *rf=1.0; - *gf=0.0; - *bf=1.0; - break; - case 7: - default: - *rf= *gf= *bf= 1.0; - break; - } - } else { - /* Get chroma values */ - - h= (float) (cid-10)/239; - CLAMP(h, 0.0, 1.0); - - /* If its odd make it a bit whitish */ - if (cid%2) { s=.75; v= 0.25; - } else { s= 0.25; v= 0.75;} - - hsv_to_rgb (h, s, v, rf, gf, bf); - } -} - -static void write_mesh_dxf(FILE *fp, Mesh *me) -{ - Material *ma; - MVert *mvert; - MFace *mface; - int a; - char str[32]; - - replace_chars(str, me->id.name+2); - - write_group(0, "BLOCK"); - - write_group(2, str); /* The name */ - - write_group(8, "Meshes"); /* DXF Layer */ - write_group(70, "64"); /* DXF block flags */ - - write_group(10, "0.0"); /* X of base */ - write_group(20, "0.0"); /* Y of base */ - write_group(30, "0.0"); /* Z of base */ - - write_group(3, str); /* The name (again) */ - - write_group(0, "POLYLINE"); /* Start the mesh */ - write_group(66, "1"); /* Vertices follow flag */ - write_group(8,"Meshes"); /* DXF Layer */ - - if (me->totcol) { - ma= me->mat[0]; - if(ma) { - sprintf(str,"%d",rgb_to_dxf_col(ma->r,ma->g,ma->b)); - write_group(62, str); /* Color index */ - } - } - - write_group(70, "64"); /* Polymesh mesh flag */ - - fprintf(fp, "71\n%d\n", me->totvert); /* Total vertices */ - fprintf(fp, "72\n%d\n", me->totface); /* Total faces */ - - /* Write the vertices */ - a= me->totvert; - mvert= me->mvert; - while(a--) { - write_group(0, "VERTEX"); /* Start a new vertex */ - write_group(8, "Meshes"); /* DXF Layer */ - fprintf (fp, "10\n%f\n", mvert->co[0]); /* X cord */ - fprintf (fp, "20\n%f\n", mvert->co[1]); /* Y cord */ - fprintf (fp, "30\n%f\n", mvert->co[2]); /* Z cord */ - write_group(70, "192"); /* Polymesh vertex flag */ - - mvert++; - } - - /* Write the face entries */ - a= me->totface; - mface= me->mface; - while(a--) { - write_group(0, "VERTEX"); /* Start a new face */ - write_group(8, "Meshes"); - - /* Write a face color */ - if (me->totcol) { - ma= me->mat[(int)mface->mat_nr]; - if(ma) { - sprintf(str,"%d",rgb_to_dxf_col(ma->r,ma->g,ma->b)); - write_group(62, str); /* Color index */ - } - } - else write_group(62, "254"); /* Color Index */ - - /* Not sure what this really corresponds too */ - write_group(10, "0.0"); /* X of base */ - write_group(20, "0.0"); /* Y of base */ - write_group(30, "0.0"); /* Z of base */ - - write_group(70, "128"); /* Polymesh face flag */ - - if(mface->v4) { - fprintf (fp, "71\n%d\n", mface->v1+1); - fprintf (fp, "72\n%d\n", mface->v2+1); - fprintf (fp, "73\n%d\n", mface->v3+1); - fprintf (fp, "74\n%d\n", mface->v4+1); - } else { - fprintf (fp, "71\n%d\n", mface->v1+1); - fprintf (fp, "72\n%d\n", mface->v2+1); - fprintf (fp, "73\n%d\n", mface->v3+1); - } - mface++; - } - - write_group(0, "SEQEND"); - - write_group(0, "ENDBLK"); -} - -static void write_object_dxf(FILE *fp, Object *ob, int layer) -{ - ID *id; - char str[32]; - - id= ob->data; - - write_group(0, "INSERT"); /* Start an insert group */ - - sprintf(str, "%d", layer); - write_group(8, str); - - replace_chars(str, id->name+2); - write_group(2, str); - - fprintf (fp, "10\n%f\n", ob->loc[0]); /* X of base */ - fprintf (fp, "20\n%f\n", ob->loc[1]); /* Y of base */ - fprintf (fp, "30\n%f\n", ob->loc[2]); /* Z of base */ - - fprintf (fp, "41\n%f\n", ob->size[0]); /* X scale */ - fprintf (fp, "42\n%f\n", ob->size[1]); /* Y scale */ - fprintf (fp, "43\n%f\n", ob->size[2]); /* Z scale */ - - fprintf (fp, "50\n%f\n", (float) ob->rot[2]*180/M_PI); /* Can only write the Z rot */ -} - -void write_dxf(struct Scene *scene, char *str) -{ - Mesh *me; - Base *base; - FILE *fp; - - /* XXX, operator needs to handle overwrite & rename */ - - fp= fopen(str, "w"); - - if(fp==NULL) { - //XXX error("Can't write file"); - return; - } - - //XXX waitcursor(1); - - /* The header part of the DXF */ - - write_group(0, "SECTION"); - write_group(2, "HEADER"); - write_group(0, "ENDSEC"); - - /* The blocks part of the DXF */ - - write_group(0, "SECTION"); - write_group(2, "BLOCKS"); - - - /* only write meshes we're using in this scene */ - flag_listbase_ids(&G.main->mesh, LIB_DOIT, 0); - - for(base= scene->base.first; base; base= base->next) - if(base->object->type== OB_MESH) - ((ID *)base->object->data)->flag |= LIB_DOIT; - - /* Write all the meshes */ - me= G.main->mesh.first; - while(me) { - if(me->id.flag & LIB_DOIT) { /* is the mesh used in this scene ? */ - write_mesh_dxf(fp, me); - } - me= me->id.next; - } - - write_group(0, "ENDSEC"); - - /* The entities part of the DXF */ - - write_group(0, "SECTION"); - write_group(2, "ENTITIES"); - - /* Write all the mesh objects */ - base= scene->base.first; - while(base) { - if(base->object->type== OB_MESH) { - write_object_dxf(fp, base->object, base->lay); - } - base= base->next; - } - - write_group(0, "ENDSEC"); - - /* Thats all */ - - write_group(0, "EOF"); - fclose(fp); - - //XXX waitcursor(0); -} - - -static int dxf_line= 0; -static FILE *dxf_fp= NULL; - -/* exotic.c(2863) : note C6311: c:/Program Files/Microsoft Visual - * Studio/VC98/include\ctype.h(268) : see previous definition of - * 'iswspace' */ -#define ton_iswspace(c) (c==' '||c=='\n'||c=='\t') - -static void clean_wspace (char *str) -{ - char *from, *to; - char t; - - from= str; - to=str; - - while (*from!=0) { - t= *from; - *to= t; - - if(!ton_iswspace(*from)) to++; - from++; - } - *to=0; -} - -static int all_wspace(char *str) -{ - while(*str != 0) { - if (!ton_iswspace(*str)) return 0; - str++; - } - - return 1; -} - -static int all_digits(char *str) -{ - while(*str != 0) { - if (!isdigit(*str)) return 0; - str++; - } - - return 1; -} - -static int dxf_get_layer_col(char *UNUSED(layer)) -{ - return 1; -} - -static int dxf_get_layer_num(Scene *scene, char *layer) -{ - int ret = 0; - - if (all_digits(layer) && atoi(layer)<(1<<20)) ret= atoi(layer); - if (ret == 0) ret = scene->lay; - - return ret; -} - -static void dos_clean(char *str) -{ - while (*str) { - if (*str == 0x0d) { - *str='\n'; - *(++str)= 0; - break; - } - str++; - } -} - -static void myfgets(char *str, int len, FILE *fp) -{ - char c; - - while(len>0 && (c=getc(dxf_fp)) ) { - *str= c; - str++; - len--; - /* three types of enters, \n \r and \r\n */ - if(c == '\n') break; - if(c=='\r') { - c= getc(fp); // read the linefeed from stream - if(c != 10) ungetc(c, fp); // put back, if it's not one... - break; - } - } -} - -static int read_groupf(char *str) -{ - short c; - int ret=-1; - char tmp[256]; - - strcpy(str, " "); - - while ((c=getc(dxf_fp)) && ton_iswspace(c)); - ungetc(c, dxf_fp); - if (c==EOF) return -1; - - myfgets(tmp, 255, dxf_fp); - - dos_clean(tmp); - - if(sscanf(tmp, "%d\n", &ret)!=1) return -2; - - myfgets(tmp, 255, dxf_fp); - - dos_clean(tmp); - - if (!all_wspace(tmp)) { - if (sscanf(tmp, "%s\n", str)!=1) return -2; - } - - clean_wspace(str); - dxf_line+=2; - - return ret; -} - -//XXX error() is now printf until we have a callback error -#define id_test(id) if(id<0) {char errmsg[128];fclose(dxf_fp); if(id==-1) sprintf(errmsg, "Error inputting dxf, near line %d", dxf_line); else if(id==-2) sprintf(errmsg, "Error reading dxf, near line %d", dxf_line);printf("%s", errmsg); return;} - -#define read_group(id,str) {id= read_groupf(str); id_test(id);} - -#define group_is(idtst,str) (id==idtst&&strcmp(val,str)==0) -#define group_isnt(idtst,str) (id!=idtst||strcmp(val,str)!=0) -#define id_check(idtst,str) if(group_isnt(idtst,str)) { fclose(dxf_fp); printf("Error parsing dxf, near line %d", dxf_line); return;} - -static int id; -static char val[256]; - -static short error_exit=0; -static short hasbumped=0; - -static int is_dxf(const char *str) -{ - dxf_line=0; - - dxf_fp= fopen(str, "r"); - if (dxf_fp==NULL) return 0; - - id= read_groupf(val); - if ((id==0 && strcmp(val, "SECTION")==0)||id==999) return 1; - - fclose(dxf_fp); - - return 0; -} - -/* NOTES ON THE READER */ -/* - -- - It turns out that most DXF writers like (LOVE) to - write meshes as a long string of 3DFACE entities. - This means the natural way to read a DXF file - (every entity corresponds to an object) is completely - unusable, reading in 10,000 faces each as an - object just doesn't cut it. Thus the 3DFACE - entry reader holds state, and only finalizes to - an object when a) the layer name changes, b) the - entry type changes, c) we are done reading. - - PS... I decided to do the same thing with LINES, - apparently the same thing happens sometimes as - well. - - PPS... I decided to do the same thing with everything. - Now it is all really nasty and should be rewritten. - -- - - Added circular and elliptical arcs and lwpolylines. - These are all self-contained and have the size known - in advance, and so I haven't used the held state. -- martin -*/ - -static void dxf_add_mat (Object *ob, Mesh *me, float color[3], char *layer) -{ - Material *ma; - - if (!me) return; - - if(ob) { - ob->mat= MEM_callocN(sizeof(void *)*1, "ob->mat"); - ob->matbits= MEM_callocN(sizeof(char)*1, "ob->matbits"); - ob->actcol= 1; - } - - me->totcol= 1; - me->mat= MEM_callocN(sizeof(void *)*1, "me->mat"); - - if (color[0]<0) { - if (strlen(layer)) dxf_col_to_rgb(dxf_get_layer_col(layer), &color[0], &color[1], &color[2]); - color[0]= color[1]= color[2]= 0.8f; - } - - ma= G.main->mat.first; - while(ma) { - if(ma->mtex[0]==NULL) { - if(color[0]==ma->r && color[1]==ma->g && color[2]==ma->b) { - me->mat[0]= ma; - ma->id.us++; - break; - } - } - ma= ma->id.next; - } - if(ma==NULL) { - ma= add_material("ext"); - me->mat[0]= ma; - ma->r= color[0]; - ma->g= color[1]; - ma->b= color[2]; - automatname(ma); - } -} - - /* General DXF vars */ -static float cent[3]={0.0, 0.0, 0.0}; -static char layname[32]=""; -static char entname[32]=""; -static float color[3]={-1.0, -1.0, -1.0}; -static float *vcenter; -static float zerovec[3]= {0.0, 0.0, 0.0}; - -#define reset_vars cent[0]= cent[1]= cent[2]=0.0; strcpy(layname, ""); color[0]= color[1]= color[2]= -1.0 - - -static void dxf_get_mesh(Scene *scene, Mesh** m, Object** o, int noob) -{ - Mesh *me = NULL; - Object *ob; - - if (!noob) { - *o = add_object(scene, OB_MESH); - ob = *o; - - if (entname[0]) new_id(&G.main->object, (ID *)ob, entname); - else if (layname[0]) new_id(&G.main->object, (ID *)ob, layname); - - if (layname[0]) ob->lay= dxf_get_layer_num(scene, layname); - else ob->lay= scene->lay; - // not nice i know... but add_object() sets active base, which needs layer setting too (ton) - scene->basact->lay= ob->lay; - - *m = ob->data; - me= *m; - - vcenter= ob->loc; - } - else { - *o = NULL; - *m = add_mesh("Mesh"); - - me = *m; - ob = *o; - - ((ID *)me)->us=0; - - if (entname[0]) new_id(&G.main->mesh, (ID *)me, entname); - else if (layname[0]) new_id(&G.main->mesh, (ID *)me, layname); - - vcenter = zerovec; - } - me->totvert=0; - me->totface=0; - me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, 0); - me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0); -} - -static void dxf_read_point(Scene *scene, int noob) { - /* Blender vars */ - Object *ob; - Mesh *me; - MVert *mvert; - - reset_vars; - - read_group(id, val); - while(id!=0) { - if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); - } else if (id==10) { - cent[0]= (float) atof(val); - } else if (id==20) { - cent[1]= (float) atof(val); - } else if (id==30) { - cent[2]= (float) atof(val); - } else if (id==60) { - /* short invisible= atoi(val); */ - } else if (id==62) { - int colorid= atoi(val); - - CLAMP(colorid, 1, 255); - dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); - } - read_group(id, val); - } - - dxf_get_mesh(scene, &me, &ob, noob); - me->totvert= 1; - me->mvert= MEM_callocN(me->totvert*sizeof(MVert), "mverts"); - CustomData_set_layer(&me->vdata, CD_MVERT, me->mvert); - - dxf_add_mat (ob, me, color, layname); - - mvert= me->mvert; - mvert->co[0]= mvert->co[1]= mvert->co[2]= 0; - - if (ob) VECCOPY(ob->loc, cent); - - hasbumped=1; -} - - /* Line state vars */ -static Object *linehold=NULL; -static Mesh *linemhold=NULL; - -static char oldllay[32]; -static short lwasline=0; /* last was face 3d? */ - -static void dxf_close_line(void) -{ - linemhold=NULL; - if (linehold==NULL) return; - - linehold=NULL; -} - -static void dxf_read_line(Scene *scene, int noob) { - /* Entity specific vars */ - float epoint[3]={0.0, 0.0, 0.0}; - short vspace=0; /* Whether or not coords are relative */ - - /* Blender vars */ - Object *ob; - Mesh *me; - MVert *mvert, *vtmp; - MFace *mface, *ftmp; - - reset_vars; - - read_group(id, val); - while(id!=0) { - if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); - } else if (id==10) { - cent[0]= (float) atof(val); - } else if (id==20) { - cent[1]= (float) atof(val); - } else if (id==30) { - cent[2]= (float) atof(val); - } else if (id==11) { - epoint[0]= (float) atof(val); - } else if (id==21) { - epoint[1]= (float) atof(val); - } else if (id==31) { - epoint[2]= (float) atof(val); - } else if (id==60) { - /* short invisible= atoi(val); */ - } else if (id==62) { - int colorid= atoi(val); - - CLAMP(colorid, 1, 255); - dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); - } else if (id==67) { - vspace= atoi(val); - } - read_group(id, val); - } - - /* Check to see if we need to make a new object */ - - if(!lwasline || strcmp(layname, oldllay)!=0) - dxf_close_line(); - if(linemhold != NULL && linemhold->totvert>MESH_MAX_VERTS) - dxf_close_line(); - - if (linemhold==NULL) { - dxf_get_mesh(scene, &me, &ob, noob); - - if(ob) VECCOPY(ob->loc, cent); - - dxf_add_mat (ob, me, color, layname); - - linehold= ob; - linemhold= me; - } else { - ob= linehold; - me= linemhold; - } - - me->totvert+= 2; - me->totface++; - - vtmp= MEM_callocN(me->totvert*sizeof(MVert), "mverts"); - ftmp= MEM_callocN(me->totface*sizeof(MFace), "mface"); - - if(me->mvert) { - memcpy(vtmp, me->mvert, (me->totvert-2)*sizeof(MVert)); - MEM_freeN(me->mvert); - } - me->mvert= CustomData_set_layer(&me->vdata, CD_MVERT, vtmp); - vtmp=NULL; - - if(me->mface) { - memcpy(ftmp, me->mface, (me->totface-1)*sizeof(MFace)); - MEM_freeN(me->mface); - } - me->mface= CustomData_set_layer(&me->fdata, CD_MFACE, ftmp); - ftmp=NULL; - - mvert= &me->mvert[(me->totvert-2)]; - - sub_v3_v3v3(mvert->co, cent, vcenter); - mvert++; - if (vspace) { VECCOPY(mvert->co, epoint); - } else sub_v3_v3v3(mvert->co, epoint, vcenter); - - mface= &(((MFace*)me->mface)[me->totface-1]); - mface->v1= me->totvert-2; - mface->v2= me->totvert-1; - mface->mat_nr= 0; - - hasbumped=1; -} - - /* 2D Polyline state vars */ -static Object *p2dhold=NULL; -static Mesh *p2dmhold=NULL; -static char oldplay[32]; -static short lwasp2d=0; - -static void dxf_close_2dpoly(void) -{ - p2dmhold= NULL; - if (p2dhold==NULL) return; - - p2dhold=NULL; -} - -static void dxf_read_ellipse(Scene *scene, int noob) -{ - - /* - * The Parameter option of the ELLIPSE command uses the following equation to define an elliptical arc. - * - * p(u)=c+a*cos(u)+b*sin(u) - * - * The variables a, b, c are determined when you select the endpoints for the - * first axis and the distance for the second axis. a is the negative of 1/2 - * of the major axis length, b is the negative of 1/2 the minor axis length, - * and c is the center point (2-D) of the ellipse. - * - * Because this is actually a vector equation and the variable c is actually - * a point with X and Y values, it really should be written as: - * - * p(u)=(Cx+a*cos(u))*i+(Cy+b*sin(u))*j - * - * where - * - * Cx is the X value of the point c - * Cy is the Y value of the point c - * a is -(1/2 of the major axis length) - * b is -(1/2 of the minor axis length) - * i and j represent unit vectors in the X and Y directions - * - * http://astronomy.swin.edu.au/~pbourke/geomformats/dxf2000/ellipse_command39s_parameter_option_dxf_06.htm - * (reproduced with permission) - * - * NOTE: The start and end angles ('parameters') are in radians, whereas those for the circular arc are - * in degrees. The 'sense' of u appears to be determined by the extrusion direction (see more detailed comment - * in the code) - * - * TODO: The code is specific to ellipses in the x-y plane right now. - * - */ - - /* Entity specific vars */ - float epoint[3]={0.0, 0.0, 0.0}; - float center[3]={0.0, 0.0, 0.0}; - float extrusion[3]={0.0, 0.0, 1.0}; - float axis_endpoint[3] = {0.0, 0.0, 0.0}; /* major axis endpoint */ - short vspace=0; /* Whether or not coords are relative */ - float a, b, x, y, z; - float phid = 0.0f, phi = 0.0f, theta = 0.0f; - float start_angle = 0.0f; - float end_angle = 2*M_PI; - float axis_ratio = 1.0f; - float temp; - int v, tot; - int isArc=0; - /* Blender vars */ - Object *ob; - Mesh *me; - MVert *mvert; - MFace *mface; - - reset_vars; - read_group(id, val); - while(id!=0) { - if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); - } else if (id==10) { - center[0]= (float) atof(val); - } else if (id==20) { - center[1]= (float) atof(val); - } else if (id==30) { - center[2]= (float) atof(val); - } else if (id==11) { - axis_endpoint[0]= (float) atof(val); - } else if (id==21) { - axis_endpoint[1]= (float) atof(val); - } else if (id==31) { - axis_endpoint[2]= (float) atof(val); - } else if (id==40) { - axis_ratio = (float) atof(val); - } else if (id==41) { - printf("dxf: start = %f", atof(val) * 180/M_PI); - start_angle = -atof(val) + M_PI_2; - } else if (id==42) { - printf("dxf: end = %f", atof(val) * 180/M_PI); - end_angle = -atof(val) + M_PI_2; - } else if (id==62) { - int colorid= atoi(val); - CLAMP(colorid, 1, 255); - dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); - } else if (id==67) { - vspace= atoi(val); - } else if (id==100) { - isArc = 1; - } else if (id==210) { - extrusion[0] = atof(val); - } else if (id==220) { - extrusion[1] = atof(val); - } else if (id==230) { - extrusion[2] = atof(val); - } - read_group(id, val); - } - - if(!lwasline || strcmp(layname, oldllay)!=0) dxf_close_line(); - if(linemhold != NULL && linemhold->totvert>MESH_MAX_VERTS) - dxf_close_line(); - - /* The 'extrusion direction' seems akin to a face normal, - * insofar as it determines the direction of increasing phi. - * This is again x-y plane specific; it should be fixed at - * some point. */ - - if (extrusion[2] < 0) { - temp = start_angle; - start_angle = M_PI - end_angle; - end_angle = M_PI - temp; - } - - if(end_angle > start_angle) - end_angle -= 2 * M_PI; - - phi = start_angle; - - x = axis_endpoint[0]; - y = axis_endpoint[1]; - z = axis_endpoint[2]; - a = sqrt(x*x + y*y + z*z); - b = a * axis_ratio; - - theta = atan2(y, x); - - x = a * sin(phi); - y = b * cos(phi); - -#ifndef DEBUG_CENTER - epoint[0] = center[0] + x*cos(theta) - y*sin(theta); - epoint[1] = center[1] + x*sin(theta) + y*cos(theta); - epoint[2] = center[2]; - - - cent[0]= epoint[0]; - cent[1]= epoint[1]; - cent[2]= epoint[2]; -#else - cent[0]= center[0]; - cent[1]= center[1]; - cent[2]= center[2]; -#endif - - dxf_get_mesh(scene, &me, &ob, noob); - strcpy(oldllay, layname); - if(ob) VECCOPY(ob->loc, cent); - dxf_add_mat (ob, me, color, layname); - - tot = 32; /* # of line segments to divide the arc into */ - - phid = (end_angle - start_angle)/tot; - - me->totvert += tot+1; - me->totface += tot+1; - - me->mvert = (MVert*) MEM_callocN(me->totvert*sizeof(MVert), "mverts"); - me->mface = (MFace*) MEM_callocN(me->totface*sizeof(MVert), "mface"); - - CustomData_set_layer(&me->vdata, CD_MVERT, me->mvert); - CustomData_set_layer(&me->fdata, CD_MFACE, me->mface); - - printf("vertex and face buffers allocated\n"); - - for(v = 0; v <= tot; v++) { - - x = a * sin(phi); - y = b * cos(phi); - epoint[0] = center[0] + x*cos(theta) - y*sin(theta); - epoint[1] = center[1] + x*sin(theta) + y*cos(theta); - epoint[2] = center[2]; - - mvert= &me->mvert[v]; - - if (vspace) { - VECCOPY(mvert->co, epoint); - } else { - sub_v3_v3v3(mvert->co, epoint, vcenter); - } - - if (v > 0) { - mface= &(((MFace*)me->mface)[v-1]); - mface->v1 = v-1; - mface->v2 = v; - mface->mat_nr = 0; - } - - hasbumped = 1; - - VECCOPY(cent, epoint); - phi+=phid; - } -} - -static void dxf_read_arc(Scene *scene, int noob) -{ - /* Entity specific vars */ - float epoint[3]={0.0, 0.0, 0.0}; - float center[3]={0.0, 0.0, 0.0}; - float extrusion[3]={0.0, 0.0, 1.0}; - short vspace=0; /* Whether or not coords are relative */ - float dia = 0.0f; - float phid = 0.0f, phi = 0.0f; - float start_angle = 0.0f; - float end_angle = 2*M_PI; - float temp; - int v, tot = 32; - int isArc=0; - /* Blender vars */ - Object *ob; - Mesh *me; - MVert *mvert; - MFace *mface; - - reset_vars; - read_group(id, val); - while(id!=0) { - if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); - } else if (id==10) { - center[0]= (float) atof(val); - } else if (id==20) { - center[1]= (float) atof(val); - } else if (id==30) { - center[2]= (float) atof(val); - } else if (id==40) { - dia = (float) atof(val); - } else if (id==62) { - int colorid= atoi(val); - - CLAMP(colorid, 1, 255); - dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); - } else if (id==67) { - vspace= atoi(val); - } else if (id==100) { - isArc = 1; - } else if (id==50) { - start_angle = (90 - atoi(val)) * M_PI/180.0; - } else if (id==51) { - end_angle = (90 - atoi(val)) * M_PI/180.0; - } else if (id==210) { - extrusion[0] = atof(val); - } else if (id==220) { - extrusion[1] = atof(val); - } else if (id==230) { - extrusion[2] = atof(val); - } - read_group(id, val); - } - - if(!lwasline || strcmp(layname, oldllay)!=0) dxf_close_line(); - if(linemhold != NULL && linemhold->totvert>MESH_MAX_VERTS) - dxf_close_line(); - - /* Same xy-plane-specific extrusion direction code as in read_ellipse - * (read_arc and read_ellipse should ideally be rewritten to share code) - */ - - if (extrusion[2] < 0) { - temp = start_angle; - start_angle = M_PI - end_angle; - end_angle = M_PI - temp; - } - - phi = start_angle; - if(end_angle > start_angle) - end_angle -= 2 * M_PI; - - cent[0]= center[0]+dia*sin(phi); - cent[1]= center[1]+dia*cos(phi); - cent[2]= center[2]; - - dxf_get_mesh(scene, &me, &ob, noob); - BLI_strncpy(oldllay, layname, sizeof(oldllay)); - if(ob) VECCOPY(ob->loc, cent); - dxf_add_mat (ob, me, color, layname); - - tot = 32; /* # of line segments to divide the arc into */ - phid = (end_angle - start_angle)/tot; /* fix so that arcs have the same 'resolution' as circles? */ - - me->totvert += tot+1; - me->totface += tot+1; - - me->mvert = (MVert*) MEM_callocN(me->totvert*sizeof(MVert), "mverts"); - me->mface = (MFace*) MEM_callocN(me->totface*sizeof(MVert), "mface"); - - CustomData_set_layer(&me->vdata, CD_MVERT, me->mvert); - CustomData_set_layer(&me->fdata, CD_MFACE, me->mface); - - for(v = 0; v <= tot; v++) { - - epoint[0]= center[0]+dia*sin(phi); - epoint[1]= center[1]+dia*cos(phi); - epoint[2]= center[2]; - - mvert= &me->mvert[v]; - - if (vspace) { - VECCOPY(mvert->co, epoint); - } else { - sub_v3_v3v3(mvert->co, epoint, vcenter); - } - - if (v > 0) { - mface= &(((MFace*)me->mface)[v-1]); - mface->v1 = v-1; - mface->v2 = v; - mface->mat_nr = 0; - } - - hasbumped=1; - - VECCOPY(cent, epoint); - phi+=phid; - } -} - -static void dxf_read_polyline(Scene *scene, int noob) { - /* Entity specific vars */ - short vspace=0; /* Whether or not coords are relative */ - int flag=0; - int vflags=0; - int vids[4]; - int nverts; - - /* Blender vars */ - Object *ob; - Mesh *me; - float vert[3] = {0}; - - MVert *mvert, *vtmp; - MFace *mface, *ftmp; - - reset_vars; - - read_group(id, val); - while(id!=0) { - if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); - } else if (id==10) { - cent[0]= (float) atof(val); - } else if (id==20) { - cent[1]= (float) atof(val); - } else if (id==30) { - cent[2]= (float) atof(val); - } else if (id==60) { - /* short invisible= atoi(val); */ - } else if (id==62) { - int colorid= atoi(val); - - CLAMP(colorid, 1, 255); - dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); - } else if (id==67) { - vspace= atoi(val); - } else if (id==70) { - flag= atoi(val); - } - read_group(id, val); - } - - if (flag & 9) { // 1= closed curve, 8= 3d curve - if(!lwasp2d || strcmp(layname, oldplay)!=0) dxf_close_2dpoly(); - if(p2dmhold != NULL && p2dmhold->totvert>MESH_MAX_VERTS) - dxf_close_2dpoly(); - - if (p2dmhold==NULL) { - dxf_get_mesh(scene, &me, &ob, noob); - - strcpy(oldplay, layname); - - if(ob) VECCOPY(ob->loc, cent); - - dxf_add_mat (ob, me, color, layname); - - p2dhold= ob; - p2dmhold= me; - } - else { - ob= p2dhold; - me= p2dmhold; - } - - nverts=0; - while (group_is(0, "VERTEX")) { - read_group(id, val); - while(id!=0) { - if (id==10) { - vert[0]= (float) atof(val); - } else if (id==20) { - vert[1]= (float) atof(val); - } else if (id==30) { - vert[2]= (float) atof(val); - } - read_group(id, val); - } - nverts++; - me->totvert++; - - vtmp= MEM_callocN(me->totvert*sizeof(MVert), "mverts"); - - if (me->mvert) { - memcpy (vtmp, me->mvert, (me->totvert-1)*sizeof(MVert)); - MEM_freeN(me->mvert); - } - me->mvert= CustomData_set_layer(&me->vdata, CD_MVERT, vtmp); - vtmp= NULL; - - mvert= &me->mvert[me->totvert-1]; - - if (vspace) { VECCOPY(mvert->co, vert); - } else sub_v3_v3v3(mvert->co, vert, vcenter); - } - - /* make edges */ - if(nverts>1) { - int a, oldtotface; - - oldtotface= me->totface; - me->totface+= nverts-1; - - ftmp= MEM_callocN(me->totface*sizeof(MFace), "mface"); - - if(me->mface) { - memcpy(ftmp, me->mface, oldtotface*sizeof(MFace)); - MEM_freeN(me->mface); - } - me->mface= CustomData_set_layer(&me->fdata, CD_MFACE, ftmp); - ftmp=NULL; - - mface= me->mface; - mface+= oldtotface; - - for(a=1; av1= (me->totvert-nverts)+a-1; - mface->v2= (me->totvert-nverts)+a; - mface->mat_nr= 0; - } - } - - lwasp2d=1; - } - else if (flag&64) { - dxf_get_mesh(scene, &me, &ob, noob); - - if(ob) VECCOPY(ob->loc, cent); - - dxf_add_mat (ob, me, color, layname); - - while (group_is(0, "VERTEX")) { - vflags= 0; - vids[0]= vids[1]= vids[2]= vids[3]= 0; - - vflags=0; - read_group(id, val); - while(id!=0) { - if(id==8) { - ; /* Layer def, skip */ - } else if (id==10) { - vert[0]= (float) atof(val); - } else if (id==20) { - vert[1]= (float) atof(val); - } else if (id==30) { - vert[2]= (float) atof(val); - } else if (id==70) { - vflags= atoi(val); - } else if (id==71) { - vids[0]= abs(atoi(val)); - } else if (id==72) { - vids[1]= abs(atoi(val)); - } else if (id==73) { - vids[2]= abs(atoi(val)); - } else if (id==74) { - vids[3]= abs(atoi(val)); - } - read_group(id, val); - } - - if (vflags & 128 && vflags & 64) { - me->totvert++; - - /* If we are nearing the limit scan to the next entry */ - if(me->totvert > MESH_MAX_VERTS) - while(group_isnt(0, "SEQEND")) read_group(id, val); - - vtmp= MEM_callocN(me->totvert*sizeof(MVert), "mverts"); - - if(me->mvert) { - memcpy(vtmp, me->mvert, (me->totvert-1)*sizeof(MVert)); - MEM_freeN(me->mvert); - } - me->mvert= CustomData_set_layer(&me->vdata, CD_MVERT, vtmp); - vtmp=NULL; - - mvert= &me->mvert[(me->totvert-1)]; - - if (vspace) { VECCOPY(mvert->co, vert); - } else sub_v3_v3v3(mvert->co, vert, vcenter); - - } else if (vflags & 128) { - if(vids[2]==0) { - //XXX error("(PL) Error parsing dxf, not enough vertices near line %d", dxf_line); - - error_exit=1; - fclose(dxf_fp); - return; - } - - me->totface++; - - ftmp= MEM_callocN(me->totface*sizeof(MFace), "mfaces"); - - if(me->mface) { - memcpy(ftmp, me->mface, (me->totface-1)*sizeof(MFace)); - MEM_freeN(me->mface); - } - me->mface= CustomData_set_layer(&me->fdata, CD_MFACE, ftmp); - ftmp=NULL; - - mface= &(((MFace*)me->mface)[me->totface-1]); - mface->v1= vids[0]-1; - mface->v2= vids[1]-1; - mface->v3= vids[2]-1; - - if(vids[3] && vids[3]!=vids[0]) { - mface->v4= vids[3]-1; - test_index_face(mface, NULL, 0, 4); - } - else test_index_face(mface, NULL, 0, 3); - - mface->mat_nr= 0; - - } else { - //XXX error("Error parsing dxf, unknown polyline information near %d", dxf_line); - - error_exit=1; - fclose(dxf_fp); - return; - } - - } - } -} - -static void dxf_read_lwpolyline(Scene *scene, int noob) { - /* Entity specific vars */ - short vspace=0; /* Whether or not coords are relative */ - int flag=0; - int nverts=0; - int v; - - /* Blender vars */ - Object *ob; - Mesh *me; - float vert[3] = {0}; - - MVert *mvert; - MFace *mface; - - reset_vars; - - id = -1; - - /* block structure is - * {...} - * 90 => nverts - * 70 => flags - * nverts.times { 10 => x, 20 => y } - */ - while(id!=70) { - read_group(id, val); - if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); - } else if (id==38) { - vert[2]= (float) atof(val); - } else if (id==60) { - /* short invisible= atoi(val); */ - } else if (id==62) { - int colorid= atoi(val); - - CLAMP(colorid, 1, 255); - dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); - } else if (id==67) { - vspace= atoi(val); - } else if (id==70) { - flag= atoi(val); - } else if (id==90) { - nverts= atoi(val); - } - } - printf("nverts %d\n", nverts); - if (nverts == 0) - return; - - dxf_get_mesh(scene, &me, &ob, noob); - strcpy(oldllay, layname); - if(ob) VECCOPY(ob->loc, cent); - dxf_add_mat (ob, me, color, layname); - - me->totvert += nverts; - me->totface += nverts; - - me->mvert = (MVert*) MEM_callocN(me->totvert*sizeof(MVert), "mverts"); - me->mface = (MFace*) MEM_callocN(me->totface*sizeof(MVert), "mface"); - - CustomData_set_layer(&me->vdata, CD_MVERT, me->mvert); - CustomData_set_layer(&me->fdata, CD_MFACE, me->mface); - - for (v = 0; v < nverts; v++) { - read_group(id,val); - if (id == 10) { - vert[0]= (float) atof(val); - } else { - //XXX error("Error parsing dxf, expected (10, ) at line %d", dxf_line); - } - - read_group(id,val); - if (id == 20) { - vert[1]= (float) atof(val); - } else { - //XXX error("Error parsing dxf, expected (20, ) at line %d", dxf_line); - } - - mvert = &me->mvert[v]; - - if (vspace) { - VECCOPY(mvert->co, vert); - } else { - sub_v3_v3v3(mvert->co, vert, vcenter); - } - - if (v > 0) { - mface= &(((MFace*)me->mface)[v-1]); - mface->v1 = v-1; - mface->v2 = v; - mface->mat_nr = 0; - } - } - - /* flag & 1 -> closed polyline - * TODO: give the polyline actual 2D faces if it is closed */ - - if (flag&1) { - if(me->mface) { - mface= &(((MFace*)me->mface)[nverts - 1]); - mface->v1 = nverts-1; - mface->v2 = 0; - mface->mat_nr = 0; - } - } -} - - - /* 3D Face state vars */ -static Object *f3dhold=NULL; -static Mesh *f3dmhold=NULL; -static char oldflay[32]; -static short lwasf3d=0; /* last was face 3d? */ - -/* how can this function do anything useful (ton)? */ -static void dxf_close_3dface(void) -{ - f3dmhold= NULL; - if (f3dhold==NULL) return; - - f3dhold=NULL; -} - -static void dxf_read_3dface(Scene *scene, int noob) -{ - /* Entity specific vars */ - float vert2[3]={0.0, 0.0, 0.0}; - float vert3[3]={0.0, 0.0, 0.0}; - float vert4[3]={0.0, 0.0, 0.0}; - short vspace=0; - - int nverts=0; - - /* Blender vars */ - Object *ob; - Mesh *me; - MVert *mvert, *vtmp; - MFace *mface, *ftmp; - - reset_vars; - - read_group(id, val); - while(id!=0) { - if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); - - /* First vert/origin */ - } else if (id==10) { - cent[0]= (float) atof(val); - if (nverts<1)nverts++; - } else if (id==20) { - cent[1]= (float) atof(val); - if (nverts<1)nverts++; - } else if (id==30) { - cent[2]= (float) atof(val); - if (nverts<1)nverts++; - - /* Second vert */ - } else if (id==11) { - vert2[0]= (float) atof(val); - if (nverts<2)nverts++; - } else if (id==21) { - vert2[1]= (float) atof(val); - if (nverts<2)nverts++; - } else if (id==31) { - vert2[2]= (float) atof(val); - if (nverts<2)nverts++; - - /* Third vert */ - } else if (id==12) { - vert3[0]= (float) atof(val); - if (nverts<3)nverts++; - } else if (id==22) { - vert3[1]= (float) atof(val); - if (nverts<3)nverts++; - } else if (id==32) { - vert3[2]= (float) atof(val); - if (nverts<3)nverts++; - - /* Fourth vert */ - } else if (id==13) { - vert4[0]= (float) atof(val); - if (nverts<4)nverts++; - } else if (id==23) { - vert4[1]= (float) atof(val); - if (nverts<4)nverts++; - } else if (id==33) { - vert4[2]= (float) atof(val); - if (nverts<4)nverts++; - - /* Other */ - } else if (id==60) { - /* short invisible= atoi(val); */ - } else if (id==62) { - int colorid= atoi(val); - - CLAMP(colorid, 1, 255); - dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); - } else if (id==67) { - vspace= atoi(val); - } - read_group(id, val); - } - - /* Check to see if we need to make a new object */ - - if(!lwasf3d || strcmp(layname, oldflay)!=0) dxf_close_3dface(); - if(f3dmhold != NULL && f3dmhold->totvert>MESH_MAX_VERTS) - dxf_close_3dface(); - - if(nverts<3) { - //XXX error("(3DF) Error parsing dxf, not enough vertices near line %d", dxf_line); - - error_exit=1; - fclose(dxf_fp); - return; - } - - if (f3dmhold==NULL) { - dxf_get_mesh(scene, &me, &ob, noob); - - strcpy(oldflay, layname); - - if(ob) VECCOPY(ob->loc, cent); - - dxf_add_mat (ob, me, color, layname); - - f3dhold= ob; - f3dmhold= me; - } else { - ob= f3dhold; - me= f3dmhold; - } - - me->totvert+= nverts; - me->totface++; - - vtmp= MEM_callocN(me->totvert*sizeof(MVert), "mverts"); - ftmp= MEM_callocN(me->totface*sizeof(MFace), "mface"); - - if(me->mvert) { - memcpy(vtmp, me->mvert, (me->totvert-nverts)*sizeof(MVert)); - MEM_freeN(me->mvert); - } - me->mvert= CustomData_set_layer(&me->vdata, CD_MVERT, vtmp); - vtmp=NULL; - - if(me->mface) { - memcpy(ftmp, me->mface, (me->totface-1)*sizeof(MFace)); - MEM_freeN(me->mface); - } - me->mface= CustomData_set_layer(&me->fdata, CD_MFACE, ftmp); - ftmp=NULL; - - mvert= &me->mvert[(me->totvert-nverts)]; - sub_v3_v3v3(mvert->co, cent, vcenter); - - mvert++; - if (vspace) { VECCOPY(mvert->co, vert2); - } else sub_v3_v3v3(mvert->co, vert2, vcenter); - - mvert++; - if (vspace) { VECCOPY(mvert->co, vert3); - } else sub_v3_v3v3(mvert->co, vert3, vcenter); - - if (nverts==4) { - mvert++; - if (vspace) { VECCOPY(mvert->co, vert4); - } else sub_v3_v3v3(mvert->co, vert4, vcenter); - } - - mface= &(((MFace*)me->mface)[me->totface-1]); - mface->v1= (me->totvert-nverts)+0; - mface->v2= (me->totvert-nverts)+1; - mface->v3= (me->totvert-nverts)+2; - - if (nverts==4) - mface->v4= (me->totvert-nverts)+3; - - mface->mat_nr= 0; - - test_index_face(mface, NULL, 0, nverts); - - hasbumped=1; -} - -static void dxf_read(Scene *scene, const char *filename) -{ - Mesh *lastMe = G.main->mesh.last; - - /* clear ugly global variables, that can hang because on error the code - below returns... tsk (ton) */ - dxf_line=0; - dxf_close_3dface(); - dxf_close_2dpoly(); - dxf_close_line(); - - dxf_fp= fopen(filename, "r"); - if (dxf_fp==NULL) return; - - while (1) { - read_group(id, val); - if (group_is(0, "EOF")) break; - - if (id==999) continue; - id_check(0, "SECTION"); - - read_group(id, val); - if (group_is(2, "HEADER")) { - } else if (group_is(2, "TABLES")) { - } else if (group_is(2, "OBJECTS")) { - } else if (group_is(2, "CLASSES")) { - } else if (group_is(2, "BLOCKS")) { - while(1) { - read_group(id, val); - if (group_is(0, "BLOCK")) { - while(group_isnt(0, "ENDBLK")) { - read_group(id, val); - - if(id==2) { - BLI_strncpy(entname, val, sizeof(entname)); - } else if (id==3) { - /* Now the object def should follow */ - if(strlen(entname)==0) { - //XXX error("Error parsing dxf, no mesh name near %d", dxf_line); - fclose(dxf_fp); - return; - } - - /* Now the object def should follow */ - while(group_isnt(0, "ENDBLK")) { - read_group(id, val); - - if(group_is(0, "POLYLINE")) { - dxf_read_polyline(scene, 1); - if(error_exit) return; - lwasf3d=0; - lwasline=0; - - while(group_isnt(0, "SEQEND")) read_group(id, val); - - } else if(group_is(0, "LWPOLYLINE")) { - dxf_read_lwpolyline(scene, 1); - if(error_exit) return; - lwasf3d=0; - lwasline=0; - - while(group_isnt(0, "SEQEND")) read_group(id, val); - } else if(group_is(0, "ATTRIB")) { - while(group_isnt(0, "SEQEND")) read_group(id, val); - lwasf3d=0; - lwasp2d=0; - lwasline=0; - } else if(group_is(0, "POINT")) { - dxf_read_point(scene, 1); - if(error_exit) return; - lwasf3d=0; - lwasp2d=0; - lwasline=0; - } else if(group_is(0, "LINE")) { - dxf_read_line(scene, 1); - if(error_exit) return; - lwasline=1; - lwasp2d=0; - lwasf3d=0; - } else if(group_is(0, "3DFACE")) { - dxf_read_3dface(scene, 1); - if(error_exit) return; - lwasf3d=1; - lwasp2d=0; - lwasline=0; - } else if (group_is(0, "CIRCLE")) { - dxf_read_arc(scene, 1); - } else if (group_is(0, "ELLIPSE")) { - dxf_read_ellipse(scene, 1); - } else if (group_is(0, "ENDBLK")) { - break; - } - } - } else if (group_is(0, "ENDBLK")) { - break; - } - } - while(id!=0) read_group(id, val); - - } else if(group_is(0, "ENDSEC")) { - break; - } - } - } else if (group_is(2, "ENTITIES")) { - while(group_isnt(0, "ENDSEC")) { - char obname[32]=""; - char layname[32]=""; - float cent[3]={0.0, 0.0, 0.0}; - float obsize[3]={1.0, 1.0, 1.0}; - float obrot[3]={0.0, 0.0, 0.0}; - - if(!hasbumped) read_group(id, val); - hasbumped=0; - if (group_is(0, "INSERT")) { - Base *base; - Object *ob; - void *obdata; - - read_group(id, val); - - while(id!=0) { - if(id==2) { - BLI_strncpy(obname, val, sizeof(obname)); - } else if (id==8) { - BLI_strncpy(layname, val, sizeof(layname)); - } else if (id==10) { - cent[0]= (float) atof(val); - } else if (id==20) { - cent[1]= (float) atof(val); - } else if (id==30) { - cent[2]= (float) atof(val); - } else if (id==41) { - obsize[0]= (float) atof(val); - } else if (id==42) { - obsize[1]= (float) atof(val); - } else if (id==43) { - obsize[2]= (float) atof(val); - } else if (id==50) { - obrot[2]= (float) (atof(val)*M_PI/180.0); - } else if (id==60) { - /* short invisible= atoi(val); */ - } - - read_group(id, val); - - } - - if(strlen(obname)==0) { - //XXX error("Error parsing dxf, no object name near %d", dxf_line); - fclose(dxf_fp); - return; - } - - obdata= find_id("ME", obname); - - if (obdata) { - ob= alloc_libblock(&G.main->object, ID_OB, obname); - - ob->type= OB_MESH; - - ob->dt= OB_TEXTURE; - - ob->trackflag= OB_POSY; - ob->upflag= OB_POSZ; - - ob->ipoflag = OB_OFFS_OB+OB_OFFS_PARENT; - - ob->dupon= 1; ob->dupoff= 0; - ob->dupsta= 1; ob->dupend= 100; - ob->recalc= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; /* needed because of weird way of adding libdata directly */ - - ob->data= obdata; - ((ID*)ob->data)->us++; - - VECCOPY(ob->loc, cent); - VECCOPY(ob->size, obsize); - VECCOPY(ob->rot, obrot); - - ob->mat= MEM_callocN(sizeof(void *)*1, "ob->mat"); - ob->matbits= MEM_callocN(sizeof(char)*1, "ob->matbits"); - ob->totcol= (unsigned char) ((Mesh*)ob->data)->totcol; - ob->actcol= 1; - - /* note: materials are either linked to mesh or object, if both then - you have to increase user counts. below line is not needed. - I leave it commented out here as warning (ton) */ - //for (i=0; itotcol; i++) ob->mat[i]= ((Mesh*)ob->data)->mat[i]; - - if (layname[0]) ob->lay= dxf_get_layer_num(scene, layname); - else ob->lay= scene->lay; - - /* link to scene */ - base= MEM_callocN( sizeof(Base), "add_base"); - BLI_addhead(&scene->base, base); - - base->lay= ob->lay; - - base->object= ob; - } - - hasbumped=1; - - lwasf3d=0; - lwasp2d=0; - lwasline=0; - } else if(group_is(0, "POLYLINE")) { - dxf_read_polyline(scene, 0); - if(error_exit) return; - lwasf3d=0; - lwasline=0; - - while(group_isnt(0, "SEQEND")) read_group(id, val); - - } else if(group_is(0, "LWPOLYLINE")) { - dxf_read_lwpolyline(scene, 0); - if(error_exit) return; - lwasf3d=0; - lwasline=0; - //while(group_isnt(0, "SEQEND")) read_group(id, val); - - } else if(group_is(0, "ATTRIB")) { - while(group_isnt(0, "SEQEND")) read_group(id, val); - lwasf3d=0; - lwasp2d=0; - lwasline=0; - } else if(group_is(0, "POINT")) { - dxf_read_point(scene, 0); - if(error_exit) return; - lwasf3d=0; - lwasp2d=0; - lwasline=0; - } else if(group_is(0, "LINE")) { - dxf_read_line(scene, 0); - if(error_exit) return; - lwasline=1; - lwasp2d=0; - lwasf3d=0; - } else if(group_is(0, "3DFACE")) { - dxf_read_3dface(scene, 0); - if(error_exit) return; - lwasline=0; - lwasp2d=0; - lwasf3d=1; - } else if (group_is(0, "CIRCLE") || group_is(0, "ARC")) { - dxf_read_arc(scene, 0); - } else if (group_is(0, "ELLIPSE")) { - dxf_read_ellipse(scene, 0); - } else if(group_is(0, "ENDSEC")) { - break; - } - } - } - - while(group_isnt(0, "ENDSEC")) read_group(id, val); - } - id_check(0, "EOF"); - - fclose (dxf_fp); - - /* Close any remaining state held stuff */ - dxf_close_3dface(); - dxf_close_2dpoly(); - dxf_close_line(); - - if (lastMe) { - lastMe = lastMe->id.next; - } else { - lastMe = G.main->mesh.first; - } - for (; lastMe; lastMe=lastMe->id.next) { - mesh_add_normals_flags(lastMe); - make_edges(lastMe, 0); - } -} diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 09c189a8847..18eda831c47 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -125,7 +125,7 @@ struct PreviewImage* BKE_previewimg_create(void) prv_img = MEM_callocN(sizeof(PreviewImage), "img_prv"); - for (i=0; ichanged[i] = 1; prv_img->changed_timestamp[i] = 0; } @@ -137,7 +137,7 @@ void BKE_previewimg_free(PreviewImage **prv) if(prv && (*prv)) { int i; - for (i=0; irect[i]) { MEM_freeN((*prv)->rect[i]); (*prv)->rect[i] = NULL; @@ -155,7 +155,7 @@ struct PreviewImage* BKE_previewimg_copy(PreviewImage *prv) if (prv) { prv_img = MEM_dupallocN(prv); - for (i=0; i < PREVIEW_MIPMAPS; ++i) { + for (i=0; i < NUM_ICON_SIZES; ++i) { if (prv->rect[i]) { prv_img->rect[i] = MEM_dupallocN(prv->rect[i]); } else { @@ -237,7 +237,7 @@ void BKE_icon_changed(int id) /* all previews changed */ if (prv) { int i; - for (i=0; ichanged[i] = 1; prv->changed_timestamp[i]++; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 5eca8e11c0f..2506c931eb4 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1703,21 +1703,20 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) { float rmat[3][3], dmat[3][3]; - /* initialise the delta-rotation matrix, which will get (pre)multiplied + /* 'dmat' is the delta-rotation matrix, which will get (pre)multiplied * with the rotation matrix to yield the appropriate rotation */ - unit_m3(dmat); - + /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */ if (ob->rotmode > 0) { /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */ - eulO_to_mat3( rmat,ob->rot, ob->rotmode); - eulO_to_mat3( dmat,ob->drot, ob->rotmode); + eulO_to_mat3(rmat, ob->rot, ob->rotmode); + eulO_to_mat3(dmat, ob->drot, ob->rotmode); } else if (ob->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - not really that great for 3D-changing orientations */ - axis_angle_to_mat3( rmat,ob->rotAxis, ob->rotAngle); - axis_angle_to_mat3( dmat,ob->drotAxis, ob->drotAngle); + axis_angle_to_mat3(rmat, ob->rotAxis, ob->rotAngle); + axis_angle_to_mat3(dmat, ob->drotAxis, ob->drotAngle); } else { /* quats are normalised before use to eliminate scaling issues */ @@ -1752,9 +1751,22 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) ob->rotAngle -= ob->drotAngle; break; default: /* euler */ - if(use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, mat); - else mat3_to_eulO(ob->rot, ob->rotmode, mat); - sub_v3_v3(ob->rot, ob->drot); + { + float quat[4]; + float dquat[4]; + float tmat[3][3]; + + /* without drot we could apply 'mat' directly */ + mat3_to_quat(quat, mat); + eulO_to_quat(dquat, ob->drot, ob->rotmode); + invert_qt(dquat); + mul_qt_qtqt(quat, dquat, quat); + quat_to_mat3(tmat, quat); + /* end drot correction */ + + if(use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat); + else mat3_to_eulO(ob->rot, ob->rotmode, tmat); + } } } @@ -1946,9 +1958,10 @@ static void give_parvert(Object *par, int nr, float *vec) if(dm) { MVert *mvert= dm->getVertArray(dm); int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); - int i, count = 0, vindex, numVerts = dm->getNumVerts(dm); + int i, vindex, numVerts = dm->getNumVerts(dm); /* get the average of all verts with (original index == nr) */ + count= 0; for(i = 0; i < numVerts; i++) { vindex= (index)? index[i]: i; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 666ba31faed..6b1540d7d53 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1250,7 +1250,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D double step, pos; step= (totpart < 2) ? 0.5 : 1.0/(double)totpart; - pos= 1e-16; /* tiny offset to avoid zero weight face */ + pos= 1e-6; /* tiny offset to avoid zero weight face */ i= 0; for(p=0; pdampfac != 0.f) - mul_v3_fl(pa->state.vel, 1.f - part->dampfac * efdata.ptex.damp); + mul_v3_fl(pa->state.vel, 1.f - part->dampfac * efdata.ptex.damp * 25.f * dtime); //VECCOPY(pa->state.ave, states->ave); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index aa91cff03b9..d2f05a8ca53 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -37,7 +37,7 @@ #include #include "MEM_guardedalloc.h" -#include "PIL_dynlib.h" +#include "BLI_dynlib.h" #include "BLI_math.h" /* windows needs for M_PI */ #include "BLI_utildefines.h" @@ -138,18 +138,18 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) pis->instance_private_data = NULL; /* clear the error list */ - PIL_dynlib_get_error_as_string(NULL); + BLI_dynlib_get_error_as_string(NULL); - /* if(pis->handle) PIL_dynlib_close(pis->handle); */ + /* if(pis->handle) BLI_dynlib_close(pis->handle); */ /* pis->handle= 0; */ /* open the needed object */ - pis->handle= PIL_dynlib_open(pis->name); + pis->handle= BLI_dynlib_open(pis->name); if(test_dlerr(pis->name, pis->name)) return; if (pis->handle != NULL) { /* find the address of the version function */ - version= (int (*)(void))PIL_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); + version= (int (*)(void))BLI_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); if (test_dlerr(pis->name, "plugin_seq_getversion")) return; if (version != NULL) { @@ -158,7 +158,7 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) int (*info_func)(PluginInfo *); PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); - info_func= (int (*)(PluginInfo *))PIL_dynlib_find_symbol(pis->handle, "plugin_getinfo"); + info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pis->handle, "plugin_getinfo"); if(info_func == NULL) error("No info func"); else { @@ -176,21 +176,21 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) } MEM_freeN(info); - cp= PIL_dynlib_find_symbol(pis->handle, "seqname"); + cp= BLI_dynlib_find_symbol(pis->handle, "seqname"); if(cp) strncpy(cp, seqname, 21); } else { printf ("Plugin returned unrecognized version number\n"); return; } } - alloc_private = (void* (*)(void))PIL_dynlib_find_symbol( + alloc_private = (void* (*)(void))BLI_dynlib_find_symbol( pis->handle, "plugin_seq_alloc_private_data"); if (alloc_private) { pis->instance_private_data = alloc_private(); } pis->current_private_data = (void**) - PIL_dynlib_find_symbol( + BLI_dynlib_find_symbol( pis->handle, "plugin_private_data"); } } @@ -229,12 +229,12 @@ static void free_plugin_seq(PluginSeq *pis) { if(pis==NULL) return; - /* no PIL_dynlib_close: same plugin can be opened multiple times with 1 handle */ + /* no BLI_dynlib_close: same plugin can be opened multiple times with 1 handle */ if (pis->instance_private_data) { void (*free_private)(void *); - free_private = (void (*)(void *))PIL_dynlib_find_symbol( + free_private = (void (*)(void *))BLI_dynlib_find_symbol( pis->handle, "plugin_seq_free_private_data"); if (free_private) { free_private(pis->instance_private_data); @@ -301,7 +301,7 @@ static struct ImBuf * do_plugin_effect( if(seq->plugin->cfra) *(seq->plugin->cfra)= cfra; - cp = PIL_dynlib_find_symbol( + cp = BLI_dynlib_find_symbol( seq->plugin->handle, "seqname"); if(cp) strncpy(cp, seq->name+2, 22); @@ -2858,6 +2858,83 @@ static struct ImBuf * do_multicam( return out; } +/* ********************************************************************** + ADJUSTMENT + ********************************************************************** */ + +/* no effect inputs for adjustment, we use give_ibuf_seq */ +static int num_inputs_adjustment(void) +{ + return 0; +} + +static int early_out_adjustment(struct Sequence *UNUSED(seq), float UNUSED(facf0), float UNUSED(facf1)) +{ + return -1; +} + +static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq, + float cfra) +{ + Editing * ed; + ListBase * seqbasep; + struct ImBuf * i = 0; + + ed = context.scene->ed; + + seqbasep = seq_seqbase(&ed->seqbase, seq); + + if (seq->machine > 0) { + i = give_ibuf_seqbase(context, cfra, + seq->machine - 1, seqbasep); + } + + /* found nothing? so let's work the way up the metastrip stack, so + that it is possible to group a bunch of adjustment strips into + a metastrip and have that work on everything below the metastrip + */ + + if (!i) { + Sequence * meta; + + meta = seq_metastrip(&ed->seqbase, NULL, seq); + + if (meta) { + i = do_adjustment_impl(context, meta, cfra); + } + } + + return i; +} + +static struct ImBuf * do_adjustment( + SeqRenderData context, Sequence *seq, float cfra, + float UNUSED(facf0), float UNUSED(facf1), + struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), + struct ImBuf *UNUSED(ibuf3)) +{ + struct ImBuf * i = 0; + struct ImBuf * out; + Editing * ed; + + ed = context.scene->ed; + + if (!ed) { + return NULL; + } + + i = do_adjustment_impl(context, seq, cfra); + + if (input_have_to_preprocess(context, seq, cfra)) { + out = IMB_dupImBuf(i); + IMB_freeImBuf(i); + } else { + out = i; + } + + return out; +} + /* ********************************************************************** SPEED ********************************************************************** */ @@ -3256,6 +3333,11 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) rval.early_out = early_out_multicam; rval.execute = do_multicam; break; + case SEQ_ADJUSTMENT: + rval.num_inputs = num_inputs_adjustment; + rval.early_out = early_out_adjustment; + rval.execute = do_adjustment; + break; } return rval; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index e3639dd1c51..30abb6278a7 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -79,9 +79,15 @@ #define snprintf _snprintf #endif -/* **** XXX ******** */ -//static void waitcursor(int val) {} -//static int blender_test_break() {return 0;} + +static ImBuf* seq_render_strip_stack( + SeqRenderData context, ListBase *seqbasep, float cfra, int chanshown); + +static ImBuf * seq_render_strip( + SeqRenderData context, Sequence * seq, float cfra); + +static void seq_free_animdata(Scene *scene, Sequence *seq); + /* **** XXX ******** */ #define SELECT 1 @@ -177,8 +183,6 @@ void seq_free_strip(Strip *strip) MEM_freeN(strip); } -static void seq_free_animdata(Scene *scene, Sequence *seq); - void seq_free_sequence(Scene *scene, Sequence *seq) { if(seq->strip) seq_free_strip(seq->strip); @@ -191,6 +195,10 @@ void seq_free_sequence(Scene *scene, Sequence *seq) sh.free(seq); } + if(seq->sound) { + ((ID *)seq->sound)->us--; + } + /* clipboard has no scene and will never have a sound handle or be active */ if(scene) { Editing *ed = scene->ed; @@ -446,51 +454,6 @@ void seq_end(SeqIterator *iter) * in metastrips!) ********************************************************************** */ -#if 0 /* UNUSED */ -static void do_seq_count(ListBase *seqbase, int *totseq) -{ - Sequence *seq; - - seq= seqbase->first; - while(seq) { - (*totseq)++; - if(seq->seqbase.first) do_seq_count(&seq->seqbase, totseq); - seq= seq->next; - } -} - -static void do_build_seqar(ListBase *seqbase, Sequence ***seqar, int depth) -{ - Sequence *seq; - - seq= seqbase->first; - while(seq) { - seq->depth= depth; - if(seq->seqbase.first) do_build_seqar(&seq->seqbase, seqar, depth+1); - **seqar= seq; - (*seqar)++; - seq= seq->next; - } -} - -static void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq) -{ - Sequence **tseqar; - - *totseq= 0; - do_seq_count(seqbase, totseq); - - if(*totseq==0) { - *seqar= NULL; - return; - } - *seqar= MEM_mallocN(sizeof(void *)* *totseq, "seqar"); - tseqar= *seqar; - - do_build_seqar(seqbase, seqar, 0); - *seqar= tseqar; -} -#endif /* UNUSED */ static void do_seq_count_cb(ListBase *seqbase, int *totseq, int (*test_func)(Sequence * seq)) @@ -916,6 +879,7 @@ static const char *give_seqname_by_type(int type) case SEQ_TRANSFORM: return "Transform"; case SEQ_COLOR: return "Color"; case SEQ_MULTICAM: return "Multicam"; + case SEQ_ADJUSTMENT: return "Adjustment"; case SEQ_SPEED: return "Speed"; default: return NULL; @@ -1013,16 +977,22 @@ static float give_stripelem_index(Sequence *seq, float cfra) int sta = seq->start; int end = seq->start+seq->len-1; - if(seq->len == 0) return -1; + if (seq->type & SEQ_EFFECT) { + end = seq->enddisp; + } + + if(end < sta) { + return -1; + } if(seq->flag&SEQ_REVERSE_FRAMES) { /*reverse frame in this sequence */ - if(cfra <= sta) nr= seq->len-1; + if(cfra <= sta) nr= end - sta; else if(cfra >= end) nr= 0; else nr= end - cfra; } else { if(cfra <= sta) nr= 0; - else if(cfra >= end) nr= seq->len-1; + else if(cfra >= end) nr= end - sta; else nr= cfra - sta; } @@ -1039,7 +1009,11 @@ StripElem *give_stripelem(Sequence *seq, int cfra) { StripElem *se= seq->strip->stripdata; - if(seq->type != SEQ_MOVIE) { /* movie use the first */ + if(seq->type == SEQ_IMAGE) { /* only + IMAGE strips use the whole array, + MOVIE strips use only + the first element, all other strips + don't use this... */ int nr = (int) give_stripelem_index(seq, cfra); if (nr == -1 || se == NULL) return NULL; @@ -1093,15 +1067,12 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se } if(evaluate_seq_frame_gen(seq_arr, seqbasep, cfra)) { - if (b > 0) { - if (seq_arr[b] == NULL) { - return 0; - } - } else { - for (b = MAXSEQ; b > 0; b--) { - if (video_seq_is_rendered(seq_arr[b])) { - break; - } + if (b == 0) { + b = MAXSEQ; + } + for (; b > 0; b--) { + if (video_seq_is_rendered(seq_arr[b])) { + break; } } } @@ -2071,8 +2042,9 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr break; } case SEQ_EFFECT: - { - ibuf = seq_render_effect_strip_impl(context, seq, cfra); + { + ibuf = seq_render_effect_strip_impl( + context, seq, seq->start + nr); break; } case SEQ_IMAGE: @@ -2855,7 +2827,10 @@ void seq_tx_set_final_right(Sequence *seq, int val) since they work a bit differently to normal image seq's (during transform) */ int seq_single_check(Sequence *seq) { - return (seq->len==1 && ELEM3(seq->type, SEQ_IMAGE, SEQ_COLOR, SEQ_MULTICAM)); + return (seq->len==1 && ( + seq->type == SEQ_IMAGE + || ((seq->type & SEQ_EFFECT) && + get_sequence_effect_num_inputs(seq->type) == 0))); } /* check if the selected seq's reference unselected seq's */ @@ -3214,6 +3189,24 @@ ListBase *seq_seqbase(ListBase *seqbase, Sequence *seq) return NULL; } +Sequence *seq_metastrip(ListBase * seqbase, Sequence * meta, Sequence *seq) +{ + Sequence * iseq; + + for(iseq = seqbase->first; iseq; iseq = iseq->next) { + Sequence * rval; + + if (seq == iseq) { + return meta; + } else if(iseq->seqbase.first && + (rval = seq_metastrip(&iseq->seqbase, iseq, seq))) { + return rval; + } + } + + return NULL; +} + int seq_swap(Sequence *seq_a, Sequence *seq_b) { char name[sizeof(seq_a->name)]; @@ -3523,7 +3516,8 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->len = seq->len = ceil(info.length * FPS); strip->us= 1; - strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); + /* we only need 1 element to store the filename */ + strip->stripdata= se= MEM_callocN(sizeof(StripElem), "stripelem"); BLI_split_dirfile(seq_load->path, strip->dir, se->name); @@ -3572,7 +3566,8 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->len = seq->len = IMB_anim_get_duration( an ); strip->us= 1; - strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); + /* we only need 1 element for MOVIE strips */ + strip->stripdata= se= MEM_callocN(sizeof(StripElem), "stripelem"); BLI_split_dirfile(seq_load->path, strip->dir, se->name); diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index ec0f5d1316b..4cc5a880625 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -543,7 +543,7 @@ int sk_stroke_filtermval(SK_DrawData *dd) return retval; } -void sk_initDrawData(SK_DrawData *dd, const short mval[2]) +void sk_initDrawData(SK_DrawData *dd, const int mval[2]) { dd->mval[0] = mval[0]; dd->mval[1] = mval[1]; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index ba5d4282416..512914e2c52 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1232,7 +1232,7 @@ char *txt_to_buf (Text *text) return buf; } -int txt_find_string(Text *text, char *findstr, int wrap) +int txt_find_string(Text *text, char *findstr, int wrap, int match_case) { TextLine *tl, *startl; char *s= NULL; @@ -1246,7 +1246,8 @@ int txt_find_string(Text *text, char *findstr, int wrap) oldsl= txt_get_span(text->lines.first, text->sell); tl= startl= text->sell; - s= strstr(&tl->line[text->selc], findstr); + if(match_case) s= strstr(&tl->line[text->selc], findstr); + else s= BLI_strcasestr(&tl->line[text->selc], findstr); while (!s) { tl= tl->next; if (!tl) { @@ -1256,7 +1257,8 @@ int txt_find_string(Text *text, char *findstr, int wrap) break; } - s= strstr(tl->line, findstr); + if(match_case) s= strstr(tl->line, findstr); + else s= BLI_strcasestr(tl->line, findstr); if (tl==startl) break; } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 866874ee5c8..9cd07de31dc 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -41,9 +41,8 @@ #include "MEM_guardedalloc.h" -#include "PIL_dynlib.h" - #include "BLI_blenlib.h" +#include "BLI_dynlib.h" #include "BLI_math.h" #include "BLI_kdopbvh.h" #include "BLI_utildefines.h" @@ -82,7 +81,7 @@ int test_dlerr(const char *name, const char *symbol) { char *err; - err= PIL_dynlib_get_error_as_string(NULL); + err= BLI_dynlib_get_error_as_string(NULL); if(err) { printf("var1: %s, var2: %s, var3: %s\n", name, symbol, err); return 1; @@ -108,19 +107,19 @@ void open_plugin_tex(PluginTex *pit) pit->instance_init= NULL; /* clear the error list */ - PIL_dynlib_get_error_as_string(NULL); + BLI_dynlib_get_error_as_string(NULL); - /* no PIL_dynlib_close! multiple opened plugins... */ - /* if(pit->handle) PIL_dynlib_close(pit->handle); */ + /* no BLI_dynlib_close! multiple opened plugins... */ + /* if(pit->handle) BLI_dynlib_close(pit->handle); */ /* pit->handle= 0; */ /* open the needed object */ - pit->handle= PIL_dynlib_open(pit->name); + pit->handle= BLI_dynlib_open(pit->name); if(test_dlerr(pit->name, pit->name)) return; if (pit->handle != NULL) { /* find the address of the version function */ - version= (int (*)(void)) PIL_dynlib_find_symbol(pit->handle, "plugin_tex_getversion"); + version= (int (*)(void)) BLI_dynlib_find_symbol(pit->handle, "plugin_tex_getversion"); if (test_dlerr(pit->name, "plugin_tex_getversion")) return; if (version != NULL) { @@ -129,7 +128,7 @@ void open_plugin_tex(PluginTex *pit) int (*info_func)(PluginInfo *); PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); - info_func= (int (*)(PluginInfo *))PIL_dynlib_find_symbol(pit->handle, "plugin_getinfo"); + info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pit->handle, "plugin_getinfo"); if (!test_dlerr(pit->name, "plugin_getinfo")) { info->instance_init = NULL; @@ -200,7 +199,7 @@ void free_plugin_tex(PluginTex *pit) { if(pit==NULL) return; - /* no PIL_dynlib_close: same plugin can be opened multiple times, 1 handle */ + /* no BLI_dynlib_close: same plugin can be opened multiple times, 1 handle */ MEM_freeN(pit); } diff --git a/source/blender/blenlib/PIL_dynlib.h b/source/blender/blenlib/BLI_dynlib.h similarity index 72% rename from source/blender/blenlib/PIL_dynlib.h rename to source/blender/blenlib/BLI_dynlib.h index 5569954c116..f269bedd639 100644 --- a/source/blender/blenlib/PIL_dynlib.h +++ b/source/blender/blenlib/BLI_dynlib.h @@ -27,31 +27,19 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/blenlib/PIL_dynlib.h +/** \file blender/blenlib/BLI_dynlib.h * \ingroup bli */ -#ifndef __PIL_DYNLIB_H__ -#define __PIL_DYNLIB_H__ +#ifndef __BLI_DYNLIB_H__ +#define __BLI_DYNLIB_H__ -typedef struct PILdynlib PILdynlib; +typedef struct DynamicLibrary DynamicLibrary; - PILdynlib* -PIL_dynlib_open( - char *name); +DynamicLibrary *BLI_dynlib_open(char *name); +void *BLI_dynlib_find_symbol(DynamicLibrary* lib, const char *symname); +char *BLI_dynlib_get_error_as_string(DynamicLibrary* lib); +void BLI_dynlib_close(DynamicLibrary* lib); - void* -PIL_dynlib_find_symbol( - PILdynlib* lib, - const char *symname); - - char* -PIL_dynlib_get_error_as_string( - PILdynlib* lib); - - void -PIL_dynlib_close( - PILdynlib* lib); - -#endif /* __PIL_DYNLIB_H__ */ +#endif /* __BLI_DYNLIB_H__ */ diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 756d1501536..4a7d749842d 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -77,7 +77,7 @@ void closest_to_line_segment_v3(float r[3], const float p[3], const float l1[3], #define ISECT_LINE_LINE_CROSS 2 int isect_line_line_v2(const float a1[2], const float a2[2], const float b1[2], const float b2[2]); -int isect_line_line_v2_short(const short a1[2], const short a2[2], const short b1[2], const short b2[2]); +int isect_line_line_v2_int(const int a1[2], const int a2[2], const int b1[2], const int b2[2]); int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[2], const float v4[2], float vi[2]); /* Returns the number of point of interests diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index e2f102c20eb..c5acf7b7f70 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -53,7 +53,7 @@ extern "C" { /* scanfill.c: used in displist only... */ struct EditVert *BLI_addfillvert(float *vec); struct EditEdge *BLI_addfilledge(struct EditVert *v1, struct EditVert *v2); -int BLI_edgefill(int mat_nr); +int BLI_edgefill(short mat_nr); void BLI_end_edgefill(void); /* These callbacks are needed to make the lib finction properly */ diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index d5ed8956f7a..b7827d62851 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -88,6 +88,7 @@ set(SRC BLI_bpath.h BLI_cpu.h BLI_dlrbTree.h + BLI_dynlib.h BLI_dynstr.h BLI_edgehash.h BLI_editVert.h @@ -127,7 +128,6 @@ set(SRC BLI_vfontdata.h BLI_voxel.h BLI_winstuff.h - PIL_dynlib.h PIL_time.h intern/BLI_callbacks.h intern/dynamiclist.h diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index a56b1392b69..63a8df3f73a 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -699,7 +699,12 @@ void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports) { /* be sure there is low chance of the path being too short */ char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE]; - + + if(basedir[0] == '\0') { + printf("makeFilesRelative: basedir='', this is a bug\n"); + return; + } + BLI_bpathIterator_init(&bpi, bmain, basedir, 0); while (!BLI_bpathIterator_isDone(bpi)) { BLI_bpathIterator_getPath(bpi, filepath); @@ -750,7 +755,12 @@ void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports) /* be sure there is low chance of the path being too short */ char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE]; - + + if(basedir[0] == '\0') { + printf("makeFilesAbsolute: basedir='', this is a bug\n"); + return; + } + BLI_bpathIterator_init(&bpi, bmain, basedir, 0); while (!BLI_bpathIterator_isDone(bpi)) { BLI_bpathIterator_getPath(bpi, filepath); diff --git a/source/blender/blenlib/intern/dynlib.c b/source/blender/blenlib/intern/dynlib.c index 855fa2dfbf9..ae6589b6538 100644 --- a/source/blender/blenlib/intern/dynlib.c +++ b/source/blender/blenlib/intern/dynlib.c @@ -31,110 +31,101 @@ * \ingroup bli */ - -#include - -#include "../PIL_dynlib.h" - -#if !defined(CHAR_MAX) -#define CHAR_MAX 255 -#endif - -/* - * XXX, should use mallocN so we can see - * handle's not being released. fixme zr - */ - -#ifdef WIN32 -#include #include +#include +#include -#include +#include "MEM_guardedalloc.h" -struct PILdynlib { +#include "BLI_dynlib.h" + +struct DynamicLibrary { void *handle; }; -PILdynlib *PIL_dynlib_open(char *name) { +#ifdef WIN32 + +#include + +DynamicLibrary *BLI_dynlib_open(char *name) +{ + DynamicLibrary *lib; void *handle= LoadLibrary(name); - if (handle) { - PILdynlib *lib= malloc(sizeof(*lib)); - lib->handle= handle; - - return lib; - } else { + if(!handle) return NULL; - } + + lib= MEM_callocN(sizeof(*lib), "Dynamic Library"); + lib->handle= handle; + + return lib; } -void *PIL_dynlib_find_symbol(PILdynlib* lib, const char *symname) { +void *BLI_dynlib_find_symbol(DynamicLibrary *lib, const char *symname) +{ return GetProcAddress(lib->handle, symname); } -char *PIL_dynlib_get_error_as_string(PILdynlib* lib) { +char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib) +{ int err; /* if lib is NULL reset the last error code */ err= GetLastError(); - if (!lib) SetLastError(ERROR_SUCCESS); + if(!lib) + SetLastError(ERROR_SUCCESS); - if (err) { + if(err) { static char buf[1024]; - if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - buf, - sizeof(buf), - NULL)) + if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + buf, sizeof(buf), NULL)) return buf; } return NULL; } -void PIL_dynlib_close(PILdynlib *lib) { +void BLI_dynlib_close(DynamicLibrary *lib) +{ FreeLibrary(lib->handle); - - free(lib); + MEM_freeN(lib); } -#else /* Unix */ +#else /* Unix */ #include -struct PILdynlib { - void *handle; -}; - -PILdynlib *PIL_dynlib_open(char *name) { +DynamicLibrary *BLI_dynlib_open(char *name) +{ + DynamicLibrary *lib; void *handle= dlopen(name, RTLD_LAZY); - if (handle) { - PILdynlib *lib= malloc(sizeof(*lib)); - lib->handle= handle; - - return lib; - } else { + if(!handle) return NULL; - } + + lib= MEM_callocN(sizeof(*lib), "Dynamic Library"); + lib->handle= handle; + + return lib; } -void *PIL_dynlib_find_symbol(PILdynlib* lib, const char *symname) { +void *BLI_dynlib_find_symbol(DynamicLibrary *lib, const char *symname) +{ return dlsym(lib->handle, symname); } -char *PIL_dynlib_get_error_as_string(PILdynlib* lib) { +char *BLI_dynlib_get_error_as_string(DynamicLibrary *lib) +{ (void)lib; /* unused */ return dlerror(); } -void PIL_dynlib_close(PILdynlib *lib) { +void BLI_dynlib_close(DynamicLibrary *lib) +{ dlclose(lib->handle); - - free(lib); + MEM_freeN(lib); } #endif diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index afce5a602ed..8785415c6a1 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -239,7 +239,7 @@ float dist_to_line_segment_v3(const float v1[3], const float v2[3], const float /******************************* Intersection ********************************/ /* intersect Line-Line, shorts */ -int isect_line_line_v2_short(const short v1[2], const short v2[2], const short v3[2], const short v4[2]) +int isect_line_line_v2_int(const int v1[2], const int v2[2], const int v3[2], const int v4[2]) { float div, labda, mu; @@ -529,8 +529,9 @@ int isect_ray_tri_v3(const float p1[3], const float d[3], const float v0[3], con int isect_ray_plane_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, int clip) { float p[3], s[3], e1[3], e2[3], q[3]; - float a, f, u, v; - + float a, f; + /* float u, v; */ /*UNUSED*/ + sub_v3_v3v3(e1, v1, v0); sub_v3_v3v3(e2, v2, v0); @@ -543,11 +544,11 @@ int isect_ray_plane_v3(float p1[3], float d[3], float v0[3], float v1[3], float sub_v3_v3v3(s, p1, v0); - u = f * dot_v3v3(s, p); + /* u = f * dot_v3v3(s, p); */ /*UNUSED*/ cross_v3_v3v3(q, s, e1); - v = f * dot_v3v3(d, q); + /* v = f * dot_v3v3(d, q); */ /*UNUSED*/ *lambda = f * dot_v3v3(e2, q); if (clip && (*lambda < 0.0f)) return 0; @@ -1789,7 +1790,7 @@ void orthographic_m4(float matrix[][4], const float left, const float right, con matrix[3][2] = -(farClip + nearClip)/Zdelta; } -void perspective_m4(float mat[][4],float left, const float right, const float bottom, const float top, const float nearClip, const float farClip) +void perspective_m4(float mat[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip) { float Xdelta, Ydelta, Zdelta; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index e8e8127be0c..1f4b0ffdd5c 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1692,6 +1692,10 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name) #ifdef _WIN32 if(GetModuleFileName(0, fullname, maxlen)) { GetShortPathName(fullname, fullname, maxlen); + if(!BLI_exists(fullname)) { + printf("path can't be found: \"%.*s\"\n", maxlen, fullname); + MessageBox(NULL, "path constains invalid characters or is too long (see console)", "Error", MB_OK); + } return; } #endif diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index d889c1b9bf2..9bd540e46ea 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -58,6 +58,8 @@ typedef unsigned long long r_uint64; #define LOWSEED 0x330E +extern unsigned char hash[]; // noise.c + /***/ struct RNG { @@ -83,8 +85,6 @@ void rng_seed(RNG *rng, unsigned int seed) { } void rng_srandom(RNG *rng, unsigned int seed) { - extern unsigned char hash[]; // noise.c - rng_seed(rng, seed + hash[seed & 255]); seed= rng_getInt(rng); rng_seed(rng, seed + hash[seed & 255]); @@ -180,8 +180,6 @@ static RNG rng_tab[BLENDER_MAX_THREADS]; void BLI_thread_srandom(int thread, unsigned int seed) { - extern unsigned char hash[]; // noise.c - if(thread >= BLENDER_MAX_THREADS) thread= 0; diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 423b9b99569..47a07d86e66 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -85,7 +85,6 @@ typedef struct PolyFill { typedef struct ScFillVert { EditVert *v1; EditEdge *first,*last; - short f,f1; } ScFillVert; @@ -95,9 +94,9 @@ typedef struct ScFillVert { static ScFillVert *scdata; -ListBase fillvertbase = {0,0}; -ListBase filledgebase = {0,0}; -ListBase fillfacebase = {0,0}; +ListBase fillvertbase = {NULL, NULL}; +ListBase filledgebase = {NULL, NULL}; +ListBase fillfacebase = {NULL, NULL}; static short cox, coy; @@ -219,7 +218,7 @@ EditEdge *BLI_addfilledge(EditVert *v1, EditVert *v2) return newed; } -static void addfillface(EditVert *v1, EditVert *v2, EditVert *v3, int mat_nr) +static void addfillface(EditVert *v1, EditVert *v2, EditVert *v3, short mat_nr) { /* does not make edges */ EditFace *evl; @@ -495,7 +494,7 @@ static void splitlist(ListBase *tempve, ListBase *temped, short nr) } -static void scanfill(PolyFill *pf, int mat_nr) +static int scanfill(PolyFill *pf, short mat_nr) { ScFillVert *sc = NULL, *sc1; EditVert *eve,*v1,*v2,*v3; @@ -748,11 +747,13 @@ static void scanfill(PolyFill *pf, int mat_nr) } MEM_freeN(scdata); + + return totface; } -int BLI_edgefill(int mat_nr) +int BLI_edgefill(short mat_nr) { /* - fill works with its own lists, so create that first (no faces!) @@ -760,6 +761,7 @@ int BLI_edgefill(int mat_nr) - struct elements xs en ys are not used here: don't hide stuff in it - edge flag ->f becomes 2 when it's a new edge - mode: & 1 is check for crossings, then create edges (TO DO ) + - returns number of triangle faces added. */ ListBase tempve, temped; EditVert *eve; @@ -767,6 +769,7 @@ int BLI_edgefill(int mat_nr) PolyFill *pflist,*pf; float *minp, *maxp, *v1, *v2, norm[3], len; short a,c,poly=0,ok=0,toggle=0; + int totfaces= 0; /* total faces added */ /* reset variables */ eve= fillvertbase.first; @@ -1030,7 +1033,7 @@ int BLI_edgefill(int mat_nr) for(a=0;aedges>1) { splitlist(&tempve,&temped,pf->nr); - scanfill(pf, mat_nr); + totfaces += scanfill(pf, mat_nr); } pf++; } @@ -1040,6 +1043,6 @@ int BLI_edgefill(int mat_nr) /* FREE */ MEM_freeN(pflist); - return 1; + return totfaces; } diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 22083eda1c8..b7a1e0dc592 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -79,12 +79,12 @@ typedef struct BlendFileData { * returns NULL and sets a report in the list if * it cannot open the file. * - * @param file The path of the file to open. + * @param filepath The path of the file to open. * @param reports If the return value is NULL, errors * indicating the cause of the failure. * @return The data of the file. */ -BlendFileData* BLO_read_from_file(const char *file, struct ReportList *reports); +BlendFileData* BLO_read_from_file(const char *filepath, struct ReportList *reports); /** * Open a blender file from memory. The function @@ -209,7 +209,7 @@ int BLO_has_bfile_extension(char *str); */ int BLO_is_a_library(const char *path, char *dir, char *group); -struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, char *dir); +struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, const char *filepath); /** * Link/Append a named datablock from an external blend file. @@ -217,12 +217,12 @@ struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh * @param C The context, when NULL instancing object in the scene isnt done. * @param mainl The main database to link from (not the active one). * @param bh The blender file handle. - * @param name The name of the datablock (without the 2 char ID prefix) + * @param idname The name of the datablock (without the 2 char ID prefix) * @param idcode The kind of datablock to link. * @param flag Options for linking, used for instancing. * @return Boolean, 0 when the datablock could not be found. */ -int BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *name, int idcode, short flag); +int BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *idname, int idcode, short flag); void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag); /* deprecated */ diff --git a/source/kernel/gen_messaging/intern/messaging.c b/source/blender/blenloader/BLO_runtime.h similarity index 74% rename from source/kernel/gen_messaging/intern/messaging.c rename to source/blender/blenloader/BLO_runtime.h index 93e6deac089..920b14e92fa 100644 --- a/source/kernel/gen_messaging/intern/messaging.c +++ b/source/blender/blenloader/BLO_runtime.h @@ -25,22 +25,29 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** - * A message and error sink for c and c++ + * */ -/** \file kernel/gen_messaging/intern/messaging.c - * \ingroup genmess +#ifndef BLO_RUNTIME_H +#define BLO_RUNTIME_H + +/** \file BLO_runtime.h + * \ingroup blenloader */ +#ifdef __cplusplus +extern "C" { +#endif +struct BlendFileData; +struct ReportList; -#include "GEN_messaging.h" +int BLO_is_a_runtime(char *file); +struct BlendFileData *BLO_read_runtime(char *file, struct ReportList *reports); -FILE* GEN_errorstream = NULL; -FILE* GEN_userstream = NULL; - -void GEN_init_messaging_system(void) -{ - GEN_errorstream = stderr; - GEN_userstream = stdout; +#ifdef __cplusplus } +#endif + +#endif /* BLO_RUNTIME_H */ + diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index 651928aa6a1..5c41350a463 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -39,7 +39,7 @@ struct MemFile; struct Main; struct ReportList; -extern int BLO_write_file(struct Main *mainvar, char *dir, int write_flags, struct ReportList *reports, int *thumb); +extern int BLO_write_file(struct Main *mainvar, const char *filepath, int write_flags, struct ReportList *reports, int *thumb); extern int BLO_write_file_mem(struct Main *mainvar, struct MemFile *compare, struct MemFile *current, int write_flags); extern int BLO_write_runtime(struct Main *mainvar, const char *file, char *exename, struct ReportList *reports); diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 4d8ac9bc4b6..888cf3148e3 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -29,7 +29,6 @@ set(INC ../blenlib ../blenkernel ../makesdna - ../readblenfile ../makesrna ../render/extern/include ../../../intern/guardedalloc @@ -39,10 +38,12 @@ set(INC set(SRC intern/readblenentry.c intern/readfile.c + intern/runtime.c intern/undofile.c intern/writefile.c BLO_readfile.h + BLO_runtime.h BLO_soundfile.h BLO_sys_types.h BLO_undofile.h diff --git a/source/blender/blenloader/SConscript b/source/blender/blenloader/SConscript index 695d17f0638..be9908d84e6 100644 --- a/source/blender/blenloader/SConscript +++ b/source/blender/blenloader/SConscript @@ -4,7 +4,7 @@ Import ('env') sources = env.Glob('intern/*.c') incs = '. #/intern/guardedalloc ../blenlib ../blenkernel' -incs += ' ../makesdna ../readblenfile ../editors/include' +incs += ' ../makesdna ../editors/include' incs += ' ../render/extern/include ../makesrna' incs += ' ' + env['BF_ZLIB_INC'] diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 39fab1929da..028835ee0af 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -62,8 +62,6 @@ #include "readfile.h" -#include "BLO_readblenfile.h" - #include "BLO_sys_types.h" // needed for intptr_t #ifdef _WIN32 @@ -253,15 +251,15 @@ void BLO_blendhandle_close(BlendHandle *bh) { /**********/ -BlendFileData *BLO_read_from_file(const char *file, ReportList *reports) +BlendFileData *BLO_read_from_file(const char *filepath, ReportList *reports) { BlendFileData *bfd = NULL; FileData *fd; - fd = blo_openblenderfile(file, reports); + fd = blo_openblenderfile(filepath, reports); if (fd) { fd->reports= reports; - bfd= blo_read_file_internal(fd, file); + bfd= blo_read_file_internal(fd, filepath); blo_freefiledata(fd); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 8246dd2170e..41df08dbed5 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -137,7 +137,6 @@ //XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo #include "BLO_readfile.h" #include "BLO_undofile.h" -#include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory #include "RE_engine.h" @@ -490,13 +489,13 @@ static void read_file_version(FileData *fd, Main *main) } -static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *name, const char *relabase) +static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *filepath, const char *relabase) { Main *m; Library *lib; char name1[FILE_MAXDIR+FILE_MAXFILE]; - strncpy(name1, name, sizeof(name1)-1); + BLI_strncpy(name1, filepath, sizeof(name1)); cleanup_path(relabase, name1); // printf("blo_find_main: original in %s\n", name); // printf("blo_find_main: converted to %s\n", name1); @@ -514,14 +513,14 @@ static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *name, c BLI_addtail(mainlist, m); lib= alloc_libblock(&m->library, ID_LI, "lib"); - strncpy(lib->name, name, sizeof(lib->name)-1); + strncpy(lib->name, filepath, sizeof(lib->name)-1); BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath)); m->curlib= lib; read_file_version(fd, m); - if(G.f & G_DEBUG) printf("blo_find_main: added new lib %s\n", name); + if(G.f & G_DEBUG) printf("blo_find_main: added new lib %s\n", filepath); return m; } @@ -947,14 +946,14 @@ static FileData *blo_decode_and_check(FileData *fd, ReportList *reports) /* cannot be called with relative paths anymore! */ /* on each new library added, it now checks for the current FileData and expands relativeness */ -FileData *blo_openblenderfile(const char *name, ReportList *reports) +FileData *blo_openblenderfile(const char *filepath, ReportList *reports) { gzFile gzfile; errno= 0; - gzfile= gzopen(name, "rb"); + gzfile= gzopen(filepath, "rb"); if (gzfile == (gzFile)Z_NULL) { - BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", name, errno ? strerror(errno) : "Unknown error reading file"); + BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error reading file"); return NULL; } else { FileData *fd = filedata_new(); @@ -962,7 +961,7 @@ FileData *blo_openblenderfile(const char *name, ReportList *reports) fd->read = fd_read_gzip_from_file; /* needed for library_append and read_libraries */ - BLI_strncpy(fd->relabase, name, sizeof(fd->relabase)); + BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase)); return blo_decode_and_check(fd, reports); } @@ -1586,7 +1585,7 @@ static PreviewImage *direct_link_preview_image(FileData *fd, PreviewImage *old_p if (prv) { int i; - for (i=0; i < PREVIEW_MIPMAPS; ++i) { + for (i=0; i < NUM_ICON_SIZES; ++i) { if (prv->rect[i]) { prv->rect[i] = newdataadr(fd, prv->rect[i]); } @@ -3997,7 +3996,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) fluidmd->fss= newdataadr(fd, fluidmd->fss); fluidmd->fss->fmd= fluidmd; - fluidmd->fss->meshSurfNormals = NULL; + fluidmd->fss->meshVelocities = NULL; } else if (md->type==eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData*) md; @@ -5560,20 +5559,31 @@ static void lib_link_library(FileData *UNUSED(fd), Main *main) } } -/* Always call this once you havbe loaded new library data to set the relative paths correctly in relation to the blend file */ +/* Always call this once you have loaded new library data to set the relative paths correctly in relation to the blend file */ static void fix_relpaths_library(const char *basepath, Main *main) { Library *lib; /* BLO_read_from_memory uses a blank filename */ - if (basepath==NULL || basepath[0] == '\0') - return; - - for(lib= main->library.first; lib; lib= lib->id.next) { - /* Libraries store both relative and abs paths, recreate relative paths, - * relative to the blend file since indirectly linked libs will be relative to their direct linked library */ - if (strncmp(lib->name, "//", 2)==0) { /* if this is relative to begin with? */ - strncpy(lib->name, lib->filepath, sizeof(lib->name)); - BLI_path_rel(lib->name, basepath); + if (basepath==NULL || basepath[0] == '\0') { + for(lib= main->library.first; lib; lib= lib->id.next) { + /* when loading a linked lib into a file which has not been saved, + * there is nothing we can be relative to, so instead we need to make + * it absolute. This can happen when appending an object with a relative + * link into an unsaved blend file. See [#27405]. + * The remap relative option will make it relative again on save - campbell */ + if (strncmp(lib->name, "//", 2)==0) { + strncpy(lib->name, lib->filepath, sizeof(lib->name)); + } + } + } + else { + for(lib= main->library.first; lib; lib= lib->id.next) { + /* Libraries store both relative and abs paths, recreate relative paths, + * relative to the blend file since indirectly linked libs will be relative to their direct linked library */ + if (strncmp(lib->name, "//", 2)==0) { /* if this is relative to begin with? */ + strncpy(lib->name, lib->filepath, sizeof(lib->name)); + BLI_path_rel(lib->name, basepath); + } } } } @@ -9672,7 +9682,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) fluidmd->fss->lastgoodframe = INT_MAX; fluidmd->fss->flag = 0; - fluidmd->fss->meshSurfNormals = NULL; + fluidmd->fss->meshVelocities = NULL; } } } @@ -11788,7 +11798,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) return bhead; } -BlendFileData *blo_read_file_internal(FileData *fd, const char *filename) +BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) { BHead *bhead= blo_firstbhead(fd); BlendFileData *bfd; @@ -11800,7 +11810,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filename) bfd->main->versionfile= fd->fileversion; bfd->type= BLENFILETYPE_BLEND; - strncpy(bfd->main->name, filename, sizeof(bfd->main->name)-1); + strncpy(bfd->main->name, filepath, sizeof(bfd->main->name)-1); while(bhead) { switch(bhead->code) { @@ -12834,7 +12844,7 @@ static void give_base_to_groups(Main *mainvar, Scene *scene) /* returns true if the item was found * but it may already have already been appended/linked */ -static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const char *name, int idcode, short flag) +static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const char *idname, int idcode, short flag) { Scene *scene= CTX_data_scene(C); Object *ob; @@ -12849,9 +12859,9 @@ static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const if(bhead->code==ENDB) endloop= 1; else if(bhead->code==idcode) { - char *idname= bhead_id_name(fd, bhead); + const char *idname_test= bhead_id_name(fd, bhead); - if(strcmp(idname+2, name)==0) { + if(strcmp(idname_test + 2, idname)==0) { found= 1; id= is_yet_read(fd, mainl, bhead); if(id==NULL) { @@ -12903,10 +12913,10 @@ static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const return found; } -int BLO_library_append_named_part(const bContext *C, Main *mainl, BlendHandle** bh, const char *name, int idcode, short flag) +int BLO_library_append_named_part(const bContext *C, Main *mainl, BlendHandle** bh, const char *idname, int idcode, short flag) { FileData *fd= (FileData*)(*bh); - return append_named_part(C, mainl, fd, name, idcode, flag); + return append_named_part(C, mainl, fd, idname, idcode, flag); } static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r) @@ -12931,7 +12941,7 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **id_r) /* common routine to append/link something from a library */ -static Main* library_append_begin(const bContext *C, FileData **fd, char *dir) +static Main* library_append_begin(const bContext *C, FileData **fd, const char *filepath) { Main *mainvar= CTX_data_main(C); Main *mainl; @@ -12940,7 +12950,7 @@ static Main* library_append_begin(const bContext *C, FileData **fd, char *dir) blo_split_main(&(*fd)->mainlist, mainvar); /* which one do we need? */ - mainl = blo_find_main(*fd, &(*fd)->mainlist, dir, G.main->name); + mainl = blo_find_main(*fd, &(*fd)->mainlist, filepath, G.main->name); /* needed for do_version */ mainl->versionfile= (*fd)->fileversion; @@ -12949,10 +12959,10 @@ static Main* library_append_begin(const bContext *C, FileData **fd, char *dir) return mainl; } -Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, char *dir) +Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, const char *filepath) { FileData *fd= (FileData*)(*bh); - return library_append_begin(C, &fd, dir); + return library_append_begin(C, &fd, filepath); } static void append_do_cursor(Scene *scene, Library *curlib, short flag) @@ -13074,31 +13084,6 @@ void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** *bh= (BlendHandle*)fd; } -/* this is a version of BLO_library_append needed by the BPython API, so - * scripts can load data from .blend files -- see Blender.Library module.*/ -/* append to scene */ -/* this should probably be moved into the Python code anyway */ -/* tentatively removed, Python should be able to use the split functions too: */ -/* BLO_library_append_begin, BLO_library_append_end, BLO_library_append_named_part */ -#if 0 -void BLO_script_library_append(BlendHandle **bh, char *dir, const char *name, - int idcode, short flag, Main *mainvar, Scene *scene, ReportList *reports) -{ - FileData *fd= (FileData*)(*bh); - - /* try to append the requested object */ - fd->reports= reports; - library_append(mainvar, scene, name, dir, idcode, 0, &fd, NULL, 0, flag ); - if(fd) fd->reports= NULL; - - /* do we need to do this? */ - if(scene) - DAG_scene_sort(bmain, scene); - - *bh= (BlendHandle*)fd; -} -#endif - /* ************* READ LIBRARY ************** */ static int mainvar_count_libread_blocks(Main *mainvar) diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index b409e456fe6..d4e42ccde16 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -113,9 +113,9 @@ struct Main; void blo_join_main(ListBase *mainlist); void blo_split_main(ListBase *mainlist, struct Main *main); -BlendFileData *blo_read_file_internal(FileData *fd, const char *filename); +BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath); -FileData *blo_openblenderfile(const char *name, struct ReportList *reports); +FileData *blo_openblenderfile(const char *filepath, struct ReportList *reports); FileData *blo_openblendermemory(void *buffer, int buffersize, struct ReportList *reports); FileData *blo_openblendermemfile(struct MemFile *memfile, struct ReportList *reports); diff --git a/source/blender/readblenfile/intern/BLO_readblenfile.c b/source/blender/blenloader/intern/runtime.c similarity index 63% rename from source/blender/readblenfile/intern/BLO_readblenfile.c rename to source/blender/blenloader/intern/runtime.c index 351de4bd215..f5308b5ea5c 100644 --- a/source/blender/readblenfile/intern/BLO_readblenfile.c +++ b/source/blender/blenloader/intern/runtime.c @@ -27,11 +27,13 @@ * ***** END GPL LICENSE BLOCK ***** * */ + /** - * \file BLO_readblenfile.c - * \brief This file handles the loading if .blend files - * \ingroup blo + * \file runtime.c + * \brief This file handles the loading of .blend files embedded in runtimes + * \ingroup blenloader */ + #include #include #include @@ -46,90 +48,56 @@ #endif #include "BLO_readfile.h" -#include "BLO_readblenfile.h" +#include "BLO_runtime.h" #include "BKE_blender.h" #include "BKE_report.h" +#include "BKE_utildefines.h" #include "BLI_blenlib.h" -/** Magic number for the file header */ -const char *headerMagic = "BLENDFI"; - -/** - * \brief Set the version number into the array. - * - * version contains the integer number of the version - * i.e. 227 - * array[1] gets set to the div of the number by 100 i.e. 2 - * array[2] gets the remainder i.e. 27 - */ -void BLO_setversionnumber(char array[4], int version) -{ - memset(array, 0, sizeof(char)*4); - - array[1] = version / 100; - array[2] = version % 100; -} - -/** - * Sets version number using BLENDER_VERSION - * Function that calls the setversionnumber(char[],int) with - * the BLENDER_VERSION constant and sets the resultant array - * with the version parts. - * see BLO_setversionnumber(char[],int). - */ -void BLO_setcurrentversionnumber(char array[4]) -{ - BLO_setversionnumber(array, BLENDER_VERSION); -} - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - /* Runtime reading */ -static int handle_read_msb_int(int handle) { +static int handle_read_msb_int(int handle) +{ unsigned char buf[4]; - if (read(handle, buf, 4)!=4) + if(read(handle, buf, 4) != 4) return -1; - else - return (buf[0]<<24) + (buf[1]<<16) + (buf[2]<<8) + (buf[3]<<0); + + return (buf[0]<<24) + (buf[1]<<16) + (buf[2]<<8) + (buf[3]<<0); } -int blo_is_a_runtime(char *path) { +int BLO_is_a_runtime(char *path) +{ int res= 0, fd= open(path, O_BINARY|O_RDONLY, 0); int datastart; char buf[8]; - if (fd==-1) + if(fd==-1) goto cleanup; lseek(fd, -12, SEEK_END); datastart= handle_read_msb_int(fd); - if (datastart==-1) + + if(datastart==-1) goto cleanup; - else if (read(fd, buf, 8)!=8) + else if(read(fd, buf, 8)!=8) goto cleanup; - else if (memcmp(buf, "BRUNTIME", 8)!=0) + else if(memcmp(buf, "BRUNTIME", 8)!=0) goto cleanup; else res= 1; cleanup: - if (fd!=-1) + if(fd!=-1) close(fd); return res; } -BlendFileData * -blo_read_runtime( - char *path, - ReportList *reports) +BlendFileData *BLO_read_runtime(char *path, ReportList *reports) { BlendFileData *bfd= NULL; size_t actualsize; @@ -137,7 +105,8 @@ blo_read_runtime( char buf[8]; fd= open(path, O_BINARY|O_RDONLY, 0); - if (fd==-1) { + + if(fd==-1) { BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", path, strerror(errno)); goto cleanup; } @@ -147,16 +116,20 @@ blo_read_runtime( lseek(fd, -12, SEEK_END); datastart= handle_read_msb_int(fd); - if (datastart==-1) { + + if(datastart==-1) { BKE_reportf(reports, RPT_ERROR, "Unable to read \"%s\" (problem seeking)", path); goto cleanup; - } else if (read(fd, buf, 8)!=8) { + } + else if(read(fd, buf, 8)!=8) { BKE_reportf(reports, RPT_ERROR, "Unable to read \"%s\" (truncated header)", path); goto cleanup; - } else if (memcmp(buf, "BRUNTIME", 8)!=0) { + } + else if(memcmp(buf, "BRUNTIME", 8)!=0) { BKE_reportf(reports, RPT_ERROR, "Unable to read \"%s\" (not a blend file)", path); goto cleanup; - } else { + } + else { //printf("starting to read runtime from %s at datastart %d\n", path, datastart); lseek(fd, datastart, SEEK_SET); bfd = blo_read_blendafterruntime(fd, path, actualsize-datastart, reports); @@ -164,7 +137,7 @@ blo_read_runtime( } cleanup: - if (fd!=-1) + if(fd!=-1) close(fd); return bfd; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 783a59b7e34..b7c0a292ef3 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2533,14 +2533,14 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil } /* return: success (1) */ -int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *reports, int *thumb) +int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportList *reports, int *thumb) { char userfilename[FILE_MAXDIR+FILE_MAXFILE]; char tempname[FILE_MAXDIR+FILE_MAXFILE+1]; int file, err, write_user_block; /* open temporary file, so we preserve the original in case we crash */ - BLI_snprintf(tempname, sizeof(tempname), "%s@", dir); + BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath); file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666); if(file == -1) { @@ -2552,24 +2552,32 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report if(write_flags & G_FILE_RELATIVE_REMAP) { char dir1[FILE_MAXDIR+FILE_MAXFILE]; char dir2[FILE_MAXDIR+FILE_MAXFILE]; - BLI_split_dirfile(dir, dir1, NULL); + BLI_split_dirfile(filepath, dir1, NULL); BLI_split_dirfile(mainvar->name, dir2, NULL); /* just incase there is some subtle difference */ BLI_cleanup_dir(mainvar->name, dir1); BLI_cleanup_dir(mainvar->name, dir2); - if(strcmp(dir1, dir2)==0) + if(BLI_path_cmp(dir1, dir2)==0) { write_flags &= ~G_FILE_RELATIVE_REMAP; - else - makeFilesAbsolute(mainvar, G.main->name, NULL); + } + else { + if(G.relbase_valid) { + /* blend may not have been saved before. Tn this case + * we should not have any relative paths, but if there + * is somehow, an invalid or empty G.main->name it will + * print an error, dont try make the absolute in this case. */ + makeFilesAbsolute(mainvar, G.main->name, NULL); + } + } } BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE); - write_user_block= (BLI_path_cmp(dir, userfilename) == 0); + write_user_block= (BLI_path_cmp(filepath, userfilename) == 0); if(write_flags & G_FILE_RELATIVE_REMAP) - makeFilesRelative(mainvar, dir, NULL); /* note, making relative to something OTHER then G.main->name */ + makeFilesRelative(mainvar, filepath, NULL); /* note, making relative to something OTHER then G.main->name */ /* actual file writing */ err= write_file_handle(mainvar, file, NULL,NULL, write_user_block, write_flags, thumb); @@ -2583,12 +2591,12 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report int ret; /* first write compressed to separate @.gz */ - BLI_snprintf(gzname, sizeof(gzname), "%s@.gz", dir); + BLI_snprintf(gzname, sizeof(gzname), "%s@.gz", filepath); ret = BLI_gzip(tempname, gzname); if(0==ret) { /* now rename to real file name, and delete temp @ file too */ - if(BLI_rename(gzname, dir) != 0) { + if(BLI_rename(gzname, filepath) != 0) { BKE_report(reports, RPT_ERROR, "Can't change old file. File saved with @."); return 0; } @@ -2604,7 +2612,7 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report return 0; } } - else if(BLI_rename(tempname, dir) != 0) { + else if(BLI_rename(tempname, filepath) != 0) { BKE_report(reports, RPT_ERROR, "Can't change old file. File saved with @"); return 0; } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 71893cee89a..967002131c2 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1645,10 +1645,6 @@ static int animdata_filter_dopesheet_obdata (bAnimContext *ac, ListBase *anim_da break; } - /* special exception for drivers instead of action */ - if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) - expanded= EXPANDED_DRVD(adt); - /* include data-expand widget? */ if ((filter_mode & ANIMFILTER_CURVESONLY) == 0) { /* check if filtering by active status */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index cb93d2bf70b..1ba695209b2 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1360,6 +1360,7 @@ void ANIM_OT_keyframe_delete_v3d (wmOperatorType *ot) { /* identifiers */ ot->name= "Delete Keyframe"; + ot->description= "Remove keyframes on current frame for selected object"; ot->idname= "ANIM_OT_keyframe_delete_v3d"; /* callbacks */ diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 04565b4c236..10886615976 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -578,9 +578,8 @@ void ANIM_keyingset_info_register (KeyingSetInfo *ksi) } /* Remove the given KeyingSetInfo from the list of type infos, and also remove the builtin set if appropriate */ -void ANIM_keyingset_info_unregister (const bContext *C, KeyingSetInfo *ksi) +void ANIM_keyingset_info_unregister (Main *bmain, KeyingSetInfo *ksi) { - Main *bmain= CTX_data_main(C); KeyingSet *ks, *ksn; /* find relevant builtin KeyingSets which use this, and remove them */ diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 86dc2182e03..82decf8d1cf 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -206,7 +206,7 @@ void POSE_OT_propagate(struct wmOperatorType *ot); /* editarmature.c */ EditBone *make_boneList(struct ListBase *edbo, struct ListBase *bones, struct EditBone *parent, struct Bone *actBone); -void BIF_sk_selectStroke(struct bContext *C, const short mval[2], short extend); +void BIF_sk_selectStroke(struct bContext *C, const int mval[2], short extend); /* duplicate method */ void preEditBoneDuplicate(struct ListBase *editbones); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index f4e9c7c5d3e..7d741d31afe 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1698,7 +1698,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) /* does bones and points */ /* note that BONE ROOT only gets drawn for root bones (or without IK) */ -static EditBone *get_nearest_editbonepoint (ViewContext *vc, const short mval[2], ListBase *edbo, int findunsel, int *selmask) +static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask) { EditBone *ebone; rcti rect; @@ -1958,7 +1958,7 @@ static int ebone_select_flag(EditBone *ebone) } /* context: editmode armature in view3d */ -int mouse_armature(bContext *C, const short mval[2], int extend) +int mouse_armature(bContext *C, const int mval[2], int extend) { Object *obedit= CTX_data_edit_object(C); bArmature *arm= obedit->data; @@ -2499,7 +2499,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e View3D *v3d; RegionView3D *rv3d; float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3]; - short mx, my, mval[2]; + int mx, my, mval[2]; int retv; scene= CTX_data_scene(C); @@ -2513,7 +2513,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e mx= event->x - ar->winrct.xmin; my= event->y - ar->winrct.ymin; - project_short_noclip(ar, fp, mval); + project_int_noclip(ar, fp, mval); initgrabz(rv3d, fp[0], fp[1], fp[2]); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 158c0d23ddc..1fa6a88c9f3 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -702,7 +702,7 @@ static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk) } } -static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, short mval[2], int *dist, int *index, int all_pts) +static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], int *dist, int *index, int all_pts) { ARegion *ar = CTX_wm_region(C); SK_Point *pt = NULL; @@ -736,7 +736,7 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, short mval[2], } #if 0 /* UNUSED 2.5 */ -static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, short mval[2], int *dist) +static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, int mval[2], int *dist) { ARegion *ar = CTX_wm_region(C); SK_Point *pt = NULL; @@ -2157,7 +2157,7 @@ static void sk_applyGesture(bContext *C, SK_Sketch *sketch) /********************************************/ -static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const short mval[2], int extend) +static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], int extend) { ViewContext vc; rcti rect; @@ -2473,7 +2473,7 @@ static int sketch_delete(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(ev return OPERATOR_FINISHED; } -void BIF_sk_selectStroke(bContext *C, const short mval[2], short extend) +void BIF_sk_selectStroke(bContext *C, const int mval[2], short extend) { ToolSettings *ts = CTX_data_tool_settings(C); SK_Sketch *sketch = contextSketch(C, 0); diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 5897da97f85..9e0e9374d5d 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -527,7 +527,7 @@ static int poselib_remove_exec (bContext *C, wmOperator *op) } /* get index (and pointer) of pose to remove */ - marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); + marker= BLI_findlink(&act->markers, RNA_enum_get(op->ptr, "pose")); if (marker == NULL) { BKE_reportf(op->reports, RPT_ERROR, "Invalid Pose specified %d", RNA_int_get(op->ptr, "pose")); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index cb73f20fe7b..1bfd910523e 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4169,7 +4169,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot) /***************** pick select from 3d view **********************/ -int mouse_nurb(bContext *C, const short mval[2], int extend) +int mouse_nurb(bContext *C, const int mval[2], int extend) { Object *obedit= CTX_data_edit_object(C); Curve *cu= obedit->data; @@ -4666,7 +4666,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) Curve *cu; ViewContext vc; float location[3]; - short mval[2]; + int mval[2]; Nurb *nu; BezTriple *bezt; @@ -6118,6 +6118,7 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) mul_m4_v3(cmat, bezt->vec[2]); bezt++; } + calchandlesNurb(newnu); } if( (bp= newnu->bp) ) { a= newnu->pntsu*nu->pntsv; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 2baefc2de8e..c552657df96 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -378,7 +378,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi else { float *fp= give_cursor(scene, v3d); float dvec[3]; - short mval[2]; + int mval[2]; int mx, my; /* get screen coordinate */ @@ -390,13 +390,13 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi mx= (int)(pt->x / 100 * ar->winx); my= (int)(pt->y / 100 * ar->winy); } - mval[0]= (short)mx; - mval[1]= (short)my; + mval[0]= mx; + mval[1]= my; /* convert screen coordinate to 3d coordinates * - method taken from editview.c - mouse_cursor() */ - project_short_noclip(ar, fp, mval); + project_int_noclip(ar, fp, mval); window_to_3d(ar, dvec, mval[0]-mx, mval[1]-my); sub_v3_v3v3(p3d, fp, dvec); } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 5763fcde705..7db18eaedf4 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -239,7 +239,7 @@ static short gp_stroke_filtermval (tGPsdata *p, int mval[2], int pmval[2]) /* convert screen-coordinates to buffer-coordinates */ // XXX this method needs a total overhaul! -static void gp_stroke_convertcoords (tGPsdata *p, short mval[2], float out[3], float *depth) +static void gp_stroke_convertcoords (tGPsdata *p, int mval[2], float out[3], float *depth) { bGPdata *gpd= p->gpd; @@ -251,7 +251,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[2], float out[3], f */ } else { - const short mx=mval[0], my=mval[1]; + const int mx=mval[0], my=mval[1]; float rvec[3], dvec[3]; /* Current method just converts each point in screen-coordinates to @@ -266,7 +266,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[2], float out[3], f gp_get_3d_reference(p, rvec); /* method taken from editview.c - mouse_cursor() */ - project_short_noclip(p->ar, rvec, mval); + project_int_noclip(p->ar, rvec, mval); window_to_3d_delta(p->ar, dvec, mval[0]-mx, mval[1]-my); sub_v3_v3v3(out, rvec, dvec); } @@ -387,8 +387,8 @@ static short gp_stroke_addpoint (tGPsdata *p, int mval[2], float pressure) /* temp struct for gp_stroke_smooth() */ typedef struct tGpSmoothCo { - short x; - short y; + int x; + int y; } tGpSmoothCo; /* smooth a stroke (in buffer) before storing it */ @@ -417,8 +417,8 @@ static void gp_stroke_smooth (tGPsdata *p) const tGPspoint *pd= (i+1 < cmx)?(pc+1):(pc); const tGPspoint *pe= (i+2 < cmx)?(pc+2):(pd); - spc->x= (short)(0.1*pa->x + 0.2*pb->x + 0.4*pc->x + 0.2*pd->x + 0.1*pe->x); - spc->y= (short)(0.1*pa->y + 0.2*pb->y + 0.4*pc->y + 0.2*pd->y + 0.1*pe->y); + spc->x= (int)(0.1*pa->x + 0.2*pb->x + 0.4*pc->x + 0.2*pd->x + 0.1*pe->x); + spc->y= (int)(0.1*pa->y + 0.2*pb->y + 0.4*pc->y + 0.2*pd->y + 0.1*pe->y); } /* second pass: apply smoothed coordinates */ @@ -574,7 +574,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) /* get an array of depths, far depths are blended */ if (gpencil_project_check(p)) { - short mval[2], mval_prev[2]= {0}; + int mval[2], mval_prev[2]= {0}; int interp_depth = 0; int found_depth = 0; @@ -738,7 +738,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho { bGPDspoint *pt1, *pt2; int x0=0, y0=0, x1=0, y1=0; - short xyval[2]; + int xyval[2]; int i; if (gps->totpoints == 0) { @@ -750,7 +750,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho else if (gps->totpoints == 1) { /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { - project_short(p->ar, &gps->points->x, xyval); + project_int(p->ar, &gps->points->x, xyval); x0= xyval[0]; y0= xyval[1]; } @@ -804,11 +804,11 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { - project_short(p->ar, &pt1->x, xyval); + project_int(p->ar, &pt1->x, xyval); x0= xyval[0]; y0= xyval[1]; - project_short(p->ar, &pt2->x, xyval); + project_int(p->ar, &pt2->x, xyval); x1= xyval[0]; y1= xyval[1]; } @@ -1501,8 +1501,8 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) /* get relevant data for this point from stroke */ RNA_float_get_array(&itemptr, "mouse", mousef); - p->mval[0] = (short)mousef[0]; - p->mval[1] = (short)mousef[1]; + p->mval[0] = (int)mousef[0]; + p->mval[1] = (int)mousef[1]; p->pressure= RNA_float_get(&itemptr, "pressure"); if (RNA_boolean_get(&itemptr, "is_start")) { diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 36923736068..a029c5c1f12 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -117,7 +117,7 @@ void ED_armature_deselect_all_visible(struct Object *obedit); int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int *buffer, short hits, short extend); -int mouse_armature(struct bContext *C, const short mval[2], int extend); +int mouse_armature(struct bContext *C, const int mval[2], int extend); int join_armature_exec(struct bContext *C, struct wmOperator *op); struct Bone *get_indexed_bone (struct Object *ob, int index); float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index cfafd38ed15..6a92ee2e056 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -66,7 +66,7 @@ void free_editNurb (struct Object *obedit); void free_curve_editNurb (struct Curve *cu); -int mouse_nurb (struct bContext *C, const short mval[2], int extend); +int mouse_nurb (struct bContext *C, const int mval[2], int extend); struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newob); diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index d06b0d6c4ee..e5715316a31 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -56,7 +56,7 @@ struct wmKeyConfig; * Used as part of the 'stroke cache' used during drawing of new strokes */ typedef struct tGPspoint { - short x, y; /* x and y coordinates of cursor (in relative to area) */ + int x, y; /* x and y coordinates of cursor (in relative to area) */ float pressure; /* pressure of tablet at this point */ } tGPspoint; diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index 2c866495503..cfe9ea53d9a 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -68,8 +68,5 @@ int ED_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit) /* UI level image (texture) updating... render calls own stuff (too) */ void ED_image_update_frame(const struct Main *mainp, int cfra); -/* image_render.c, export for screen_ops.c, render operator */ -void ED_space_image_output(struct bContext *C); - #endif /* ED_IMAGE_H */ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 7bab563641a..6523a897713 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -36,6 +36,7 @@ extern "C" { #endif +struct Main; struct ListBase; struct ID; struct Scene; @@ -190,7 +191,7 @@ KeyingSetInfo *ANIM_keyingset_info_find_named(const char name[]); /* for RNA type registrations... */ void ANIM_keyingset_info_register(KeyingSetInfo *ksi); -void ANIM_keyingset_info_unregister(const struct bContext *C, KeyingSetInfo *ksi); +void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi); /* cleanup on exit */ void ANIM_keyingset_infos_exit(void); diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index a742be7337c..2afc3155398 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -42,7 +42,7 @@ void ED_keymap_metaball(struct wmKeyConfig *keyconf); struct MetaElem *add_metaball_primitive(struct bContext *C, float mat[4][4], int type, int newname); -int mouse_mball(struct bContext *C, const short mval[2], int extend); +int mouse_mball(struct bContext *C, const int mval[2], int extend); void free_editMball(struct Object *obedit); void make_editMball(struct Object *obedit); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index c3c843154e5..5c4dfc6ba3d 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -169,9 +169,9 @@ void EM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct Object extern unsigned int em_vertoffs, em_solidoffs, em_wireoffs; void EM_cache_x_mirror_vert(struct Object *ob, struct EditMesh *em); -int mouse_mesh(struct bContext *C, const short mval[2], short extend); +int mouse_mesh(struct bContext *C, const int mval[2], short extend); int EM_check_backbuf(unsigned int index); -int EM_mask_init_backbuf_border(struct ViewContext *vc, short mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax); +int EM_mask_init_backbuf_border(struct ViewContext *vc, int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax); void EM_free_backbuf(void); int EM_init_backbuf_border(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); int EM_init_backbuf_circle(struct ViewContext *vc, short xs, short ys, short rads); @@ -187,10 +187,10 @@ void EM_automerge(struct Scene *scene, struct Object *obedit, int update); /* editface.c */ void paintface_flush_flags(struct Object *ob); struct MTFace *EM_get_active_mtface(struct EditMesh *em, struct EditFace **act_efa, struct MCol **mcol, int sloppy); -int paintface_mouse_select(struct bContext *C, struct Object *ob, const short mval[2], int extend); +int paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], int extend); int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int select, int extend); void paintface_deselect_all_visible(struct Object *ob, int action, short flush_flags); -void paintface_select_linked(struct bContext *C, struct Object *ob, short mval[2], int mode); +void paintface_select_linked(struct bContext *C, struct Object *ob, int mval[2], int mode); int paintface_minmax(struct Object *ob, float *min, float *max); void paintface_hide(struct Object *ob, const int unselected); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 3b27fb45f5d..28d0a9520b2 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -126,7 +126,7 @@ void ED_object_constraint_update(struct Object *ob); void ED_object_constraint_dependency_update(struct Main *bmain, struct Scene *scene, struct Object *ob); /* object_lattice.c */ -int mouse_lattice(struct bContext *C, const short mval[2], int extend); +int mouse_lattice(struct bContext *C, const int mval[2], int extend); void undo_push_lattice(struct bContext *C, const char *name); /* object_lattice.c */ diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index f29284fe64d..23997e06aef 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -60,10 +60,10 @@ void PE_hide_keys_time(struct Scene *scene, struct PTCacheEdit *edit, float cfra void PE_update_object(struct Scene *scene, struct Object *ob, int useflag); /* selection tools */ -int PE_mouse_particles(struct bContext *C, const short mval[2], int extend); +int PE_mouse_particles(struct bContext *C, const int mval[2], int extend); int PE_border_select(struct bContext *C, struct rcti *rect, int select, int extend); -int PE_circle_select(struct bContext *C, int selecting, const short mval[2], float rad); -int PE_lasso_select(struct bContext *C, short mcords[][2], short moves, short extend, short select); +int PE_circle_select(struct bContext *C, int selecting, const int mval[2], float rad); +int PE_lasso_select(struct bContext *C, int mcords[][2], short moves, short extend, short select); void PE_deselect_all_visible(struct PTCacheEdit *edit); /* undo */ diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h index 77b754519fb..50dd2308b6b 100644 --- a/source/blender/editors/include/ED_util.h +++ b/source/blender/editors/include/ED_util.h @@ -86,7 +86,6 @@ void undo_editmode_step (struct bContext *C, int step); float *crazyspace_get_mapped_editverts(struct Scene *scene, struct Object *obedit); void crazyspace_set_quats_editmesh(struct EditMesh *em, float *origcos, float *mappedcos, float *quats); void crazyspace_set_quats_mesh(struct Mesh *me, float *origcos, float *mappedcos, float *quats); -int editmesh_get_first_deform_matrices(struct Scene *scene, struct Object *ob, struct EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]); int sculpt_get_first_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]); void crazyspace_build_sculpt(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 297bd234edd..ee188f9afd4 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -64,7 +64,7 @@ typedef struct ViewContext { struct View3D *v3d; struct RegionView3D *rv3d; struct EditMesh *em; - short mval[2]; + int mval[2]; } ViewContext; typedef struct ViewDepths { @@ -80,9 +80,9 @@ typedef struct ViewDepths { float *give_cursor(struct Scene *scene, struct View3D *v3d); int initgrabz(struct RegionView3D *rv3d, float x, float y, float z); -void window_to_3d(struct ARegion *ar, float out[3], short mx, short my); -void window_to_3d_delta(struct ARegion *ar, float out[3], short mx, short my); -void window_to_3d_vector(struct ARegion *ar, float out[3], short mx, short my); +void window_to_3d(struct ARegion *ar, float out[3], const int mx, const int my); +void window_to_3d_delta(struct ARegion *ar, float out[3], const int mx, const int my); +void window_to_3d_vector(struct ARegion *ar, float out[3], const int mx, const int my); void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z); /* Depth buffer */ @@ -109,6 +109,7 @@ void viewvector(struct RegionView3D *rv3d, float coord[3], float vec[3]); void viewline(struct ARegion *ar, struct View3D *v3d, float mval[2], float ray_start[3], float ray_end[3]); void viewray(struct ARegion *ar, struct View3D *v3d, float mval[2], float ray_start[3], float ray_normal[3]); +void get_object_clip_range(struct Object *ob, float *lens, float *clipsta, float *clipend); int get_view3d_cliprange(struct View3D *v3d, struct RegionView3D *rv3d, float *clipsta, float *clipend); int get_view3d_viewplane(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend, float *pixsize); int get_view3d_ortho(struct View3D *v3d, struct RegionView3D *rv3d); @@ -133,18 +134,18 @@ void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]); /* backbuffer select and draw support */ void view3d_validate_backbuf(struct ViewContext *vc); struct ImBuf *view3d_read_backbuf(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); -unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, +unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const int mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, void *handle, unsigned int (*indextest)(void *handle, unsigned int index)); unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y); /* draws and does a 4x4 sample */ -int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const short mval[2], float mouse_worldloc[3]); +int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const int mval[2], float mouse_worldloc[3]); /* only draw so view_autodist_simple can be called many times after */ int view_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode); -int view_autodist_simple(struct ARegion *ar, const short mval[2], float mouse_worldloc[3], int margin, float *force_depth); -int view_autodist_depth(struct ARegion *ar, const short mval[2], int margin, float *depth); -int view_autodist_depth_segment(struct ARegion *ar, const short mval_sta[2], const short mval_end[2], int margin, float *depth); +int view_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth); +int view_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth); +int view_autodist_depth_segment(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth); /* select */ #define MAXPICKBUF 10000 @@ -153,13 +154,13 @@ short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigne void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc); void view3d_operator_needs_opengl(const struct bContext *C); void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar); -int view3d_get_view_aligned_coordinate(struct ViewContext *vc, float fp[3], const short mval[2], const short do_fallback); +int view3d_get_view_aligned_coordinate(struct ViewContext *vc, float fp[3], const int mval[2], const short do_fallback); void view3d_get_transformation(struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats); /* XXX should move to BLI_math */ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2); -int lasso_inside(short mcords[][2], short moves, short sx, short sy); -int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1); +int lasso_inside(int mcords[][2], short moves, int sx, int sy); +int lasso_inside_edge(int mcords[][2], short moves, int x0, int y0, int x1, int y1); /* get 3d region from context, also if mouse is in header or toolbar */ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); @@ -178,7 +179,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, char err_out[256]); -Base *ED_view3d_give_base_under_cursor(struct bContext *C, const short mval[2]); +Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, short do_clip); int ED_view3d_lock(struct RegionView3D *rv3d); @@ -187,9 +188,19 @@ unsigned int ED_viewedit_datamask(struct bScreen *screen); /* assigning view matrix */ -void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist); -void view3d_apply_ob(struct Object *ob, float *ofs, float *quat, float *dist, float *lens); +void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist); + +void ED_view3d_from_object(struct Object *ob, float ofs[3], float quat[4], float *dist, float *lens); +void ED_view3d_to_object(struct Object *ob, const float ofs[3], const float quat[4], const float dist); + +/* camera lock functions */ +/* copy the camera to the view before starting a view transformation */ +void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d); +/* copy the view to the camera */ +void ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); + int view3d_is_ortho(struct View3D *v3d, struct RegionView3D *rv3d); + #endif /* ED_VIEW3D_H */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index c2836710e17..fddb5b6d12e 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -164,6 +164,10 @@ typedef struct uiLayout uiLayout; #define UI_PANEL_WIDTH 340 #define UI_COMPACT_PANEL_WIDTH 160 +/* scale fixed button widths by this to account for DPI + * 8.4852 == sqrtf(72.0f)) */ +#define UI_DPI_FAC (sqrtf((float)U.dpi) / 8.48528137423857f) + /* Button types, bits stored in 1 value... and a short even! - bits 0-4: bitnr (0-31) - bits 5-7: pointer type diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 6c6f57461a0..5f8f3d05346 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -262,14 +262,12 @@ static int ui_is_a_warp_but(uiBut *but) static int ui_is_utf8_but(uiBut *but) { if (but->rnaprop) { - int subtype= RNA_property_subtype(but->rnaprop); - - if(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) { - return TRUE; - } + const int subtype= RNA_property_subtype(but->rnaprop); + return !(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)); + } + else { + return !(but->flag & UI_BUT_NO_UTF8); } - - return !(but->flag & UI_BUT_NO_UTF8); } /* ********************** button apply/revert ************************/ @@ -1681,7 +1679,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) { if(but) { - if(!ui_is_utf8_but(but)) { + if(ui_is_utf8_but(but)) { int strip= BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr)); /* not a file?, strip non utf-8 chars */ if(strip) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 1b7bf0fcb6d..37de4ba5888 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -798,36 +798,39 @@ void UI_icons_init(int first_dyn_id) init_brush_icons(); } -/* Render size for preview images at level miplevel */ -static int preview_render_size(int miplevel) +/* Render size for preview images and icons + */ +static int preview_render_size(enum eIconSizes size) { - switch (miplevel) { - case 0: return 32; - case 1: return PREVIEW_DEFAULT_HEIGHT; + switch (size) { + case ICON_SIZE_ICON: return 32; + case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT; } return 0; } -static void icon_create_mipmap(struct PreviewImage* prv_img, int miplevel) +/* Create rect for the icon + */ +static void icon_create_rect(struct PreviewImage* prv_img, enum eIconSizes size) { - unsigned int size = preview_render_size(miplevel); + unsigned int render_size = preview_render_size(size); if (!prv_img) { if (G.f & G_DEBUG) printf("Error: requested preview image does not exist"); } - if (!prv_img->rect[miplevel]) { - prv_img->w[miplevel] = size; - prv_img->h[miplevel] = size; - prv_img->changed[miplevel] = 1; - prv_img->changed_timestamp[miplevel] = 0; - prv_img->rect[miplevel] = MEM_callocN(size*size*sizeof(unsigned int), "prv_rect"); + if (!prv_img->rect[size]) { + prv_img->w[size] = render_size; + prv_img->h[size] = render_size; + prv_img->changed[size] = 1; + prv_img->changed_timestamp[size] = 0; + prv_img->rect[size] = MEM_callocN(render_size*render_size*sizeof(unsigned int), "prv_rect"); } } /* only called when icon has changed */ /* only call with valid pointer from UI_icon_draw */ -static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, int miplevel) +static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, enum eIconSizes size) { if (!prv_img) { if (G.f & G_DEBUG) @@ -835,11 +838,10 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, int miple return; } - /* create the preview rect */ - icon_create_mipmap(prv_img, miplevel); + icon_create_rect(prv_img, size); - ED_preview_icon_job(C, prv_img, id, prv_img->rect[miplevel], - prv_img->w[miplevel], prv_img->h[miplevel]); + ED_preview_icon_job(C, prv_img, id, prv_img->rect[size], + prv_img->w[size], prv_img->h[size]); } static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, unsigned int *rect, float alpha, float *rgb, short is_preview) @@ -928,17 +930,17 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy glDisable(GL_TEXTURE_2D); } -/* Drawing size for preview images at level miplevel */ -static int preview_size(int miplevel) +/* Drawing size for preview images */ +static int get_draw_size(enum eIconSizes size) { - switch (miplevel) { - case 0: return ICON_DEFAULT_HEIGHT; - case 1: return PREVIEW_DEFAULT_HEIGHT; + switch (size) { + case ICON_SIZE_ICON: return ICON_DEFAULT_HEIGHT; + case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT; } return 0; } -static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, int miplevel, int draw_size, int UNUSED(nocreate), int is_preview) +static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), int is_preview) { Icon *icon = NULL; DrawInfo *di = NULL; @@ -989,11 +991,11 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al if(pi) { /* no create icon on this level in code */ - if(!pi->rect[miplevel]) return; /* something has gone wrong! */ + if(!pi->rect[size]) return; /* something has gone wrong! */ /* preview images use premul alpha ... */ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - icon_draw_rect(x, y, w, h, aspect, pi->w[miplevel], pi->h[miplevel], pi->rect[miplevel], 1.0f, NULL, is_preview); + icon_draw_rect(x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], 1.0f, NULL, is_preview); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } } @@ -1025,7 +1027,7 @@ static void ui_id_brush_render(bContext *C, ID *id) if(!pi) return; - for(i = 0; i < PREVIEW_MIPMAPS; i++) { + for(i = 0; i < NUM_ICON_SIZES; i++) { /* check if rect needs to be created; changed only set by dynamic icons */ if((pi->changed[i] || !pi->rect[i])) { @@ -1114,21 +1116,21 @@ int ui_id_icon_get(bContext *C, ID *id, int big) return iconid; } -static void icon_draw_mipmap(float x, float y, int icon_id, float aspect, float alpha, int miplevel, int nocreate) +static void icon_draw_at_size(float x, float y, int icon_id, float aspect, float alpha, enum eIconSizes size, int nocreate) { - int draw_size = preview_size(miplevel); - icon_draw_size(x, y, icon_id, aspect, alpha, NULL, miplevel, draw_size, nocreate, FALSE); + int draw_size = get_draw_size(size); + icon_draw_size(x, y, icon_id, aspect, alpha, NULL, size, draw_size, nocreate, FALSE); } void UI_icon_draw_aspect(float x, float y, int icon_id, float aspect, float alpha) { - icon_draw_mipmap(x, y, icon_id, aspect, alpha, PREVIEW_MIPMAP_ZERO, 0); + icon_draw_at_size(x, y, icon_id, aspect, alpha, ICON_SIZE_ICON, 0); } void UI_icon_draw_aspect_color(float x, float y, int icon_id, float aspect, float *rgb) { - int draw_size = preview_size(PREVIEW_MIPMAP_ZERO); - icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, PREVIEW_MIPMAP_ZERO, draw_size, FALSE, FALSE); + int draw_size = get_draw_size(ICON_SIZE_ICON); + icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, ICON_SIZE_ICON, draw_size, FALSE, FALSE); } void UI_icon_draw(float x, float y, int icon_id) @@ -1138,21 +1140,21 @@ void UI_icon_draw(float x, float y, int icon_id) void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha) { - icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, PREVIEW_MIPMAP_ZERO, size, TRUE, FALSE); + icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, ICON_SIZE_ICON, size, TRUE, FALSE); } void UI_icon_draw_preview(float x, float y, int icon_id) { - icon_draw_mipmap(x, y, icon_id, 1.0f, 1.0f, PREVIEW_MIPMAP_LARGE, 0); + icon_draw_at_size(x, y, icon_id, 1.0f, 1.0f, ICON_SIZE_PREVIEW, 0); } void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect) { - icon_draw_mipmap(x, y, icon_id, aspect, 1.0f, PREVIEW_MIPMAP_LARGE, 0); + icon_draw_at_size(x, y, icon_id, aspect, 1.0f, ICON_SIZE_PREVIEW, 0); } void UI_icon_draw_preview_aspect_size(float x, float y, int icon_id, float aspect, int size) { - icon_draw_size(x, y, icon_id, aspect, 1.0f, NULL, PREVIEW_MIPMAP_LARGE, size, FALSE, TRUE); + icon_draw_size(x, y, icon_id, aspect, 1.0f, NULL, ICON_SIZE_PREVIEW, size, FALSE, TRUE); } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 41f7997491d..18b2c6a0a71 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1496,8 +1496,10 @@ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc typedef struct MenuItemLevel { int opcontext; - const char *opname; - const char *propname; + /* dont use pointers to the strings because python can dynamically + * allocate strings and free before the menu draws, see [#27304] */ + char opname[OP_MAX_TYPENAME]; + char propname[MAX_IDPROP_NAME]; PointerRNA rnapoin; } MenuItemLevel; @@ -1514,9 +1516,14 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, wmOperatorType *ot= WM_operatortype_find(opname, 1); MenuItemLevel *lvl; - if(!ot || !ot->srna) { + if(!ot) { ui_item_disabled(layout, opname); - RNA_warning("uiItemMenuEnumO: %s '%s'\n", ot ? "unknown operator" : "operator missing srna", name); + RNA_warning("uiItemMenuEnumO: unknown operator '%s'\n", opname); + return; + } + if(!ot->srna) { + ui_item_disabled(layout, opname); + RNA_warning("uiItemMenuEnumO: operator missing srna '%s'\n", opname); return; } @@ -1526,8 +1533,8 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, icon= ICON_BLANK1; lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel"); - lvl->opname= opname; - lvl->propname= propname; + BLI_strncpy(lvl->opname, opname, sizeof(lvl->opname)); + BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname)); lvl->opcontext= layout->root->opcontext; ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl); @@ -1560,7 +1567,7 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel"); lvl->rnapoin= *ptr; - lvl->propname= propname; + BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname)); lvl->opcontext= layout->root->opcontext; ui_item_menu(layout, name, icon, menu_item_enum_rna_menu, NULL, lvl); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 12506d28593..e9fad382beb 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -97,7 +97,7 @@ static int eyedropper_cancel(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -static void eyedropper_sample(bContext *C, Eyedropper *eye, short mx, short my) +static void eyedropper_sample(bContext *C, Eyedropper *eye, int mx, int my) { if(RNA_property_type(eye->prop) == PROP_FLOAT) { const int color_manage = CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index a4c2dbb9943..624f06db3c1 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1625,7 +1625,7 @@ void ui_block_func_ICONTEXTROW(bContext *UNUSED(C), uiLayout *layout, void *arg_ } #if 0 -static void ui_warp_pointer(short x, short y) +static void ui_warp_pointer(int x, int y) { /* XXX 2.50 which function to use for this? */ /* OSX has very poor mousewarp support, it sends events; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index e2664c39756..0dee76d438f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -461,7 +461,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiButSetNFunc(but, NULL, MEM_dupallocN(template), NULL); } else { - but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Unlink datablock. Shift + Click to set users to zero, data gets not saved"); + but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Unlink datablock. Shift + Click to set users to zero, data will then not be saved"); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE)); if(RNA_property_flag(template->prop) & PROP_NEVER_NULL) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 771b42f5e64..fc8770ccc37 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -888,7 +888,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) /* textbut exception, clip right when... */ if(but->editstr && but->pos >= 0) { float width; - char buf[256]; + char buf[UI_MAX_DRAW_STR]; /* copy draw string */ BLI_strncpy(buf, but->drawstr, sizeof(buf)); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 50f8d2d518f..ad95e6ea9d9 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -2029,7 +2029,7 @@ typedef struct View2DString { unsigned char ub[4]; int pack; } col; - short mval[2]; + int mval[2]; rcti rect; } View2DString; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 62b191c2c6e..4cb67994704 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -86,6 +86,7 @@ typedef struct v2dViewPanData { /* options for version 1 */ int startx, starty; /* mouse x/y values in window when operator was initiated */ int lastx, lasty; /* previous x/y values of mouse in window */ + int invoke_event; /* event starting pan, for modal exit */ short in_scroller; /* for MMB in scrollers (old feature in past, but now not that useful) */ } v2dViewPanData; @@ -202,7 +203,8 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) /* set initial settings */ vpd->startx= vpd->lastx= event->x; vpd->starty= vpd->lasty= event->y; - + vpd->invoke_event= event->type; + if (event->type == MOUSEPAN) { RNA_int_set(op->ptr, "deltax", event->prevx - event->x); RNA_int_set(op->ptr, "deltay", event->prevy - event->y); @@ -261,17 +263,19 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) WM_operator_name_call(C, "VIEW2D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL); return OPERATOR_FINISHED; } - case MIDDLEMOUSE: - case ESCKEY: - if (event->val==KM_RELEASE) { - /* calculate overall delta mouse-movement for redo */ - RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx)); - RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty)); - - view_pan_exit(op); - WM_cursor_restore(CTX_wm_window(C)); - - return OPERATOR_FINISHED; + + default: + if (event->type == vpd->invoke_event || event->type==ESCKEY) { + if (event->val==KM_RELEASE) { + /* calculate overall delta mouse-movement for redo */ + RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx)); + RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty)); + + view_pan_exit(op); + WM_cursor_restore(CTX_wm_window(C)); + + return OPERATOR_FINISHED; + } } break; } @@ -519,6 +523,7 @@ typedef struct v2dViewZoomData { double timer_lastdraw; int lastx, lasty; /* previous x/y values of mouse in window */ + int invoke_event; /* event type that invoked, for modal exits */ float dx, dy; /* running tally of previous delta values (for obtaining final zoom) */ float mx_2d, my_2d; /* initial mouse location in v2d coords */ } v2dViewZoomData; @@ -923,6 +928,9 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_float_set(op->ptr, "deltax", 0); RNA_float_set(op->ptr, "deltay", 0); + /* for modal exit test */ + vzd->invoke_event= event->type; + if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { ARegion *ar= CTX_wm_region(C); @@ -1021,8 +1029,9 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* apply zooming */ view_zoomdrag_apply(C, op); } - else if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE)) { /* XXX needs modal keymap */ - if (event->val==KM_RELEASE) { + else if (event->type == vzd->invoke_event || event->type==ESCKEY) { + if (event->val == KM_RELEASE) { + /* for redo, store the overall deltas - need to respect zoom-locks here... */ if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) RNA_float_set(op->ptr, "deltax", vzd->dx); diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 9cec034af28..ab62c88deaa 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -98,7 +98,7 @@ void paintface_flush_flags(Object *ob) } /* returns 0 if not found, otherwise 1 */ -static int facesel_face_pick(struct bContext *C, Mesh *me, const short mval[2], unsigned int *index, short rect) +static int facesel_face_pick(struct bContext *C, Mesh *me, const int mval[2], unsigned int *index, short rect) { ViewContext vc; view3d_set_viewcontext(C, &vc); @@ -327,7 +327,7 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind MEM_freeN(linkflag); } -void paintface_select_linked(bContext *UNUSED(C), Object *ob, short UNUSED(mval[2]), int mode) +void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2]), int mode) { Mesh *me; unsigned int index=0; @@ -716,7 +716,7 @@ void seam_mark_clear_tface(Scene *scene, short mode) } #endif -int paintface_mouse_select(struct bContext *C, Object *ob, const short mval[2], int extend) +int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], int extend) { Mesh *me; MFace *mface, *msel; diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index 72e9e3b6d9e..d7e59e0a68f 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -199,7 +199,7 @@ static void CutEdgeloop(Object *obedit, wmOperator *op, EditMesh *em, int numcut EditEdge *nearest=NULL, *eed; float fac; int keys = 0, holdnum=0, selectmode, dist; - short mvalo[2] = {0, 0}, mval[2] = {0, 0}; + int mvalo[2] = {0, 0}, mval[2] = {0, 0}; short event=0, val, choosing=1, cancel=0, cuthalf = 0, smooth=0; short hasHidden = 0; char msg[128]; diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 8cdbe6707a3..bd49fab1de1 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -162,7 +162,7 @@ unsigned int em_solidoffs=0, em_wireoffs=0, em_vertoffs=0; /* set in drawobject. static char *selbuf= NULL; /* opengl doesn't support concave... */ -static void draw_triangulated(short mcords[][2], short tot) +static void draw_triangulated(int mcords[][2], short tot) { ListBase lb={NULL, NULL}; DispList *dl; @@ -256,7 +256,7 @@ void EM_free_backbuf(void) - grab again and compare returns 'OK' */ -int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) +int EM_mask_init_backbuf_border(ViewContext *vc, int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) { unsigned int *dr, *drm; struct ImBuf *buf, *bufmask; @@ -290,7 +290,7 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s draw_triangulated(mcords, tot); glBegin(GL_LINE_LOOP); /* for zero sized masks, lines */ - for(a=0; apass==0) { if (index<=data->lastIndex) @@ -426,7 +426,7 @@ EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short strict) } else { - struct { short mval[2], pass, select, strict; int dist, lastIndex, closestIndex; EditVert *closest; } data; + struct { int mval[2]; short pass, select, strict; int dist, lastIndex, closestIndex; EditVert *closest; } data; static int lastSelectedIndex=0; static EditVert *lastSelected=NULL; @@ -549,7 +549,7 @@ EditEdge *findnearestedge(ViewContext *vc, int *dist) static void findnearestface__getDistance(void *userData, EditFace *efa, int x, int y, int UNUSED(index)) { - struct { short mval[2]; int dist; EditFace *toFace; } *data = userData; + struct { int mval[2]; int dist; EditFace *toFace; } *data = userData; if (efa==data->toFace) { int temp = abs(data->mval[0]-x) + abs(data->mval[1]-y); @@ -560,7 +560,7 @@ static void findnearestface__getDistance(void *userData, EditFace *efa, int x, i } static void findnearestface__doClosest(void *userData, EditFace *efa, int x, int y, int index) { - struct { short mval[2], pass; int dist, lastIndex, closestIndex; EditFace *closest; } *data = userData; + struct { int mval[2]; short pass; int dist, lastIndex, closestIndex; EditFace *closest; } *data = userData; if (data->pass==0) { if (index<=data->lastIndex) @@ -588,7 +588,7 @@ static EditFace *findnearestface(ViewContext *vc, int *dist) EditFace *efa = BLI_findlink(&vc->em->faces, index-1); if (efa) { - struct { short mval[2]; int dist; EditFace *toFace; } data; + struct { int mval[2]; int dist; EditFace *toFace; } data; data.mval[0] = vc->mval[0]; data.mval[1] = vc->mval[1]; @@ -607,7 +607,7 @@ static EditFace *findnearestface(ViewContext *vc, int *dist) return NULL; } else { - struct { short mval[2], pass; int dist, lastIndex, closestIndex; EditFace *closest; } data; + struct { int mval[2]; short pass; int dist, lastIndex, closestIndex; EditFace *closest; } data; static int lastSelectedIndex=0; static EditFace *lastSelected=NULL; @@ -2061,7 +2061,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) /* ***************** loop select (non modal) ************** */ -static void mouse_mesh_loop(bContext *C, const short mval[2], short extend, short ring) +static void mouse_mesh_loop(bContext *C, const int mval[2], short extend, short ring) { ViewContext vc; EditMesh *em; @@ -2149,7 +2149,7 @@ void MESH_OT_loop_select(wmOperatorType *ot) /* ******************* mesh shortest path select, uses prev-selected edge ****************** */ /* since you want to create paths with multiple selects, it doesn't have extend option */ -static void mouse_mesh_shortest_path(bContext *C, const short mval[2]) +static void mouse_mesh_shortest_path(bContext *C, const int mval[2]) { ViewContext vc; EditMesh *em; @@ -2282,7 +2282,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) /* here actual select happens */ /* gets called via generic mouse select operator */ -int mouse_mesh(bContext *C, const short mval[2], short extend) +int mouse_mesh(bContext *C, const int mval[2], short extend) { ViewContext vc; EditVert *eve; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index a78029da079..11e7d64c667 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4011,7 +4011,7 @@ useless: LinkNode *fuv_link; short event, draw=1; - short mval[2], mvalo[2]; + int mval[2], mvalo[2]; char str[128]; float labda = 0.0f; @@ -4416,7 +4416,7 @@ useless: percp = -1; while(draw) { /* For the % calculation */ - short mval[2]; + int mval[2]; float rc[2]; float v2[2], v3[2]; EditVert *centerVert, *upVert, *downVert; @@ -4867,7 +4867,7 @@ void mesh_set_face_flags(EditMesh *em, short mode) /********************** Rip Operator *************************/ /* helper to find edge for edge_rip */ -static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *co2, const short mval[2]) +static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *co2, const int mval[2]) { float vec1[3], vec2[3], mvalf[2]; @@ -4910,7 +4910,8 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) EditEdge *eed, *seed= NULL; EditFace *efa, *sefa= NULL; float projectMat[4][4], vec[3], dist, mindist; - short doit= 1, *mval= event->mval; + short doit= 1; + int *mval= event->mval; /* select flush... vertices are important */ EM_selectmode_set(em); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index b67f9d6de29..b007e30422d 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -455,7 +455,7 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot) /* Select MetaElement with mouse click (user can select radius circle or * stiffness circle) */ -int mouse_mball(bContext *C, const short mval[2], int extend) +int mouse_mball(bContext *C, const int mval[2], int extend) { static MetaElem *startelem=NULL; Object *obedit= CTX_data_edit_object(C); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index eb04a2743e3..91980ddf228 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -607,7 +607,7 @@ static void spot_interactive(Object *ob, int mode) Lamp *la= ob->data; float transfac, dx, dy, ratio, origval; int keep_running= 1, center2d[2]; - short mval[2], mvalo[2]; + int mval[2], mvalo[2]; // getmouseco_areawin(mval); // getmouseco_areawin(mvalo); @@ -1689,6 +1689,7 @@ void OBJECT_OT_shade_flat(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Flat"; + ot->description= "Display faces 'smooth' (using vertext normals)"; ot->idname= "OBJECT_OT_shade_flat"; /* api callbacks */ @@ -1703,6 +1704,7 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot) { /* identifiers */ ot->name= "Shade Smooth"; + ot->description= "Display faces 'flat'"; ot->idname= "OBJECT_OT_shade_smooth"; /* api callbacks */ @@ -2053,6 +2055,7 @@ void OBJECT_OT_game_property_new(wmOperatorType *ot) { /* identifiers */ ot->name= "New Game Property"; + ot->description= "Create a new property available to the game engine"; ot->idname= "OBJECT_OT_game_property_new"; /* api callbacks */ @@ -2090,6 +2093,7 @@ void OBJECT_OT_game_property_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Game Property"; + ot->description= "Remove game property"; ot->idname= "OBJECT_OT_game_property_remove"; /* api callbacks */ diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 198c8cab7fa..14ce223db5e 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -305,7 +305,7 @@ void LATTICE_OT_make_regular(wmOperatorType *ot) static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, int y) { - struct { BPoint *bp; short dist, select, mval[2]; } *data = userData; + struct { BPoint *bp; short dist, select; int mval[2]; } *data = userData; float temp = abs(data->mval[0]-x) + abs(data->mval[1]-y); if((bp->f1 & SELECT)==data->select) @@ -318,12 +318,12 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, in } } -static BPoint *findnearestLattvert(ViewContext *vc, const short mval[2], int sel) +static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel) { /* sel==1: selected gets a disadvantage */ /* in nurb and bezt or bp the nearest is written */ /* return 0 1 2: handlepunt */ - struct { BPoint *bp; short dist, select, mval[2]; } data = {NULL}; + struct { BPoint *bp; short dist, select; int mval[2]; } data = {NULL}; data.dist = 100; data.select = sel; @@ -336,7 +336,7 @@ static BPoint *findnearestLattvert(ViewContext *vc, const short mval[2], int sel return data.bp; } -int mouse_lattice(bContext *C, const short mval[2], int extend) +int mouse_lattice(bContext *C, const int mval[2], int extend) { ViewContext vc; BPoint *bp= NULL; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index ff1b693d0e1..d5bf894ac8c 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -204,17 +204,28 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob ob->dt = OB_TEXTURE; } else if(md->type == eModifierType_Multires) { + int ok= 1; Mesh *me= ob->data; + ModifierData *tmpmd; - if(me->edit_mesh) { - EditMesh *em= me->edit_mesh; - /* CustomData_external_remove is used here only to mark layer as non-external - for further free-ing, so zero element count looks safer than em->totface */ - CustomData_external_remove(&em->fdata, &me->id, CD_MDISPS, 0); - EM_free_data_layer(em, &em->fdata, CD_MDISPS); - } else { - CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); - CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); + /* ensure MDISPS CustomData layer is't used by another multires modifiers */ + for(tmpmd= ob->modifiers.first; tmpmd; tmpmd= tmpmd->next) + if(tmpmd!=md && tmpmd->type == eModifierType_Multires) { + ok= 0; + break; + } + + if(ok) { + if(me->edit_mesh) { + EditMesh *em= me->edit_mesh; + /* CustomData_external_remove is used here only to mark layer as non-external + for further free-ing, so zero element count looks safer than em->totface */ + CustomData_external_remove(&em->fdata, &me->id, CD_MDISPS, 0); + EM_free_data_layer(em, &em->fdata, CD_MDISPS); + } else { + CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); + CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); + } } } @@ -971,6 +982,7 @@ static int multires_higher_levels_delete_invoke(bContext *C, wmOperator *op, wmE void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) { ot->name= "Delete Higher Levels"; + ot->description= "Deletes the higher resolution mesh, potential loss of detail"; ot->idname= "OBJECT_OT_multires_higher_levels_delete"; ot->poll= multires_poll; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 52486677e87..a3bd399a60c 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -894,7 +894,7 @@ static int object_select_name_exec(bContext *C, wmOperator *op) if(!extend) { CTX_DATA_BEGIN(C, Base*, base, selectable_bases) { - if((base->flag & SELECT) == 0) { + if(base->flag & SELECT) { ED_base_object_select(base, BA_DESELECT); changed= 1; } diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index bce16ceeed2..f7c6ff99bde 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -515,6 +515,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo mul_m4_v3(mat, bezt->vec[2]); bezt->radius *= scale; } + calchandlesNurb(nu); } else { a= nu->pntsu*nu->pntsv; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 1c9f9e60e14..f4f66c17459 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -338,7 +338,7 @@ typedef struct PEData { DerivedMesh *dm; PTCacheEdit *edit; - const short *mval; + const int *mval; rcti *rect; float rad; float dist; @@ -439,9 +439,9 @@ static int key_test_depth(PEData *data, float co[3]) static int key_inside_circle(PEData *data, float rad, float co[3], float *distance) { float dx, dy, dist; - short sco[2]; + int sco[2]; - project_short(data->vc.ar, co, sco); + project_int(data->vc.ar, co, sco); if(sco[0] == IS_CLIPPED) return 0; @@ -465,9 +465,9 @@ static int key_inside_circle(PEData *data, float rad, float co[3], float *distan static int key_inside_rect(PEData *data, float co[3]) { - short sco[2]; + int sco[2]; - project_short(data->vc.ar, co,sco); + project_int(data->vc.ar, co,sco); if(sco[0] == IS_CLIPPED) return 0; @@ -1369,7 +1369,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) /************************ pick select operator ************************/ -int PE_mouse_particles(bContext *C, const short mval[2], int extend) +int PE_mouse_particles(bContext *C, const int mval[2], int extend) { PEData data; Scene *scene= CTX_data_scene(C); @@ -1484,7 +1484,7 @@ void PARTICLE_OT_select_tips(wmOperatorType *ot) static int select_linked_exec(bContext *C, wmOperator *op) { PEData data; - short mval[2]; + int mval[2]; int location[2]; RNA_int_get_array(op->ptr, "location", location); @@ -1574,7 +1574,7 @@ int PE_border_select(bContext *C, rcti *rect, int select, int extend) /************************ circle select operator ************************/ -int PE_circle_select(bContext *C, int selecting, const short mval[2], float rad) +int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -1599,7 +1599,7 @@ int PE_circle_select(bContext *C, int selecting, const short mval[2], float rad) /************************ lasso select operator ************************/ -int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, short select) +int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, short select) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -1610,7 +1610,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); POINT_P; KEY_K; float co[3], mat[4][4]= MAT4_UNITY; - short vertco[2]; + int vertco[2]; PEData data; @@ -1631,7 +1631,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s LOOP_KEYS { VECCOPY(co, key->co); mul_m4_v3(mat, co); - project_short(ar, co, vertco); + project_int(ar, co, vertco); if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { if(select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; @@ -1649,7 +1649,7 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, s VECCOPY(co, key->co); mul_m4_v3(mat, co); - project_short(ar, co,vertco); + project_int(ar, co,vertco); if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { if(select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; @@ -2521,80 +2521,6 @@ static void toggle_particle_cursor(bContext *C, int enable) pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_view3d, brush_drawcursor, NULL); } -/********************* radial control operator *********************/ - -static int brush_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); - ParticleBrushData *brush; - int mode = RNA_enum_get(op->ptr, "mode"); - float original_value=1.0f; - - if(pset->brushtype < 0) - return OPERATOR_CANCELLED; - - brush= &pset->brush[pset->brushtype]; - - toggle_particle_cursor(C, 0); - - if(mode == WM_RADIALCONTROL_SIZE) - original_value = brush->size; - else if(mode == WM_RADIALCONTROL_STRENGTH) - original_value = brush->strength; - - RNA_float_set(op->ptr, "initial_value", original_value); - - return WM_radial_control_invoke(C, op, event); -} - -static int brush_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - - if(ret != OPERATOR_RUNNING_MODAL) - toggle_particle_cursor(C, 1); - - return ret; -} - -static int brush_radial_control_exec(bContext *C, wmOperator *op) -{ - ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); - ParticleBrushData *brush; - int mode = RNA_enum_get(op->ptr, "mode"); - float new_value = RNA_float_get(op->ptr, "new_value"); - - if(pset->brushtype < 0) - return OPERATOR_CANCELLED; - - brush= &pset->brush[pset->brushtype]; - - if(mode == WM_RADIALCONTROL_SIZE) - brush->size= new_value; - else if(mode == WM_RADIALCONTROL_STRENGTH) - brush->strength= new_value; - - WM_event_add_notifier(C, NC_WINDOW, NULL); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_brush_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Brush Radial Control"; - ot->idname= "PARTICLE_OT_brush_radial_control"; - - ot->invoke= brush_radial_control_invoke; - ot->modal= brush_radial_control_modal; - ot->exec= brush_radial_control_exec; - ot->poll= PE_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /*************************** delete operator **************************/ enum { DEL_PARTICLE, DEL_KEY }; @@ -2845,7 +2771,7 @@ static void brush_cut(PEData *data, int pa_index) float rad2, cut_time= 1.0; float x0, x1, v0, v1, o0, o1, xo0, xo1, d, dv; int k, cut, keys= (int)pow(2.0, (double)pset->draw_step); - short vertco[2]; + int vertco[2]; /* blunt scissors */ if(BLI_frand() > data->cutfac) return; @@ -2858,7 +2784,7 @@ static void brush_cut(PEData *data, int pa_index) cut=0; - project_short_noclip(ar, key->co, vertco); + project_int_noclip(ar, key->co, vertco); x0= (float)vertco[0]; x1= (float)vertco[1]; @@ -2876,7 +2802,7 @@ static void brush_cut(PEData *data, int pa_index) else { /* calculate path time closest to root that was inside the circle */ for(k=1, key++; k<=keys; k++, key++) { - project_short_noclip(ar, key->co, vertco); + project_int_noclip(ar, key->co, vertco); if(key_test_depth(data, key->co) == 0) { x0= (float)vertco[0]; @@ -3540,7 +3466,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) ParticleBrushData *brush= &pset->brush[pset->brushtype]; ARegion *ar= CTX_wm_region(C); float vec[3], mousef[2]; - short mval[2], mvalo[2]; + int mval[2], mvalo[2]; int flip, mouse[2], dx, dy, removed= 0, added=0, selected= 0; int lock_root = pset->flag & PE_LOCK_FIRST; diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index d447da3f8c4..71f1128baf0 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -60,7 +60,6 @@ void PARTICLE_OT_delete(struct wmOperatorType *ot); void PARTICLE_OT_mirror(struct wmOperatorType *ot); void PARTICLE_OT_brush_edit(struct wmOperatorType *ot); -void PARTICLE_OT_brush_radial_control(struct wmOperatorType *ot); void PARTICLE_OT_particle_edit_toggle(struct wmOperatorType *ot); void PARTICLE_OT_edited_clear(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 02b2fad7a00..56bd8b97532 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -66,7 +66,6 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_mirror); WM_operatortype_append(PARTICLE_OT_brush_edit); - WM_operatortype_append(PARTICLE_OT_brush_radial_control); WM_operatortype_append(PARTICLE_OT_particle_edit_toggle); WM_operatortype_append(PARTICLE_OT_edited_clear); @@ -91,6 +90,7 @@ static void operatortypes_particle(void) static void keymap_particle(wmKeyConfig *keyconf) { + wmKeyMapItem *kmi; wmKeyMap *keymap; keymap= WM_keymap_find(keyconf, "Particle", 0, 0); @@ -110,10 +110,19 @@ static void keymap_particle(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1); + kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0); + RNA_boolean_set(kmi->ptr, "release_confirm", 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); - RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PARTICLE_OT_brush_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); + + /* size radial control */ + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.size"); + + /* size radial control */ + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); + RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.strength"); WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index df6cdb577a2..797ead3cd90 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -156,6 +156,7 @@ void PTCACHE_OT_bake_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Bake All Physics"; + ot->description= "Bake all physics"; ot->idname= "PTCACHE_OT_bake_all"; /* api callbacks */ @@ -171,6 +172,7 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) { /* identifiers */ ot->name= "Free All Physics Bakes"; + ot->name= "Free all physics bakes"; ot->idname= "PTCACHE_OT_free_bake_all"; /* api callbacks */ @@ -268,6 +270,7 @@ void PTCACHE_OT_bake(wmOperatorType *ot) { /* identifiers */ ot->name= "Bake Physics"; + ot->description= "Bake physics"; ot->idname= "PTCACHE_OT_bake"; /* api callbacks */ @@ -283,6 +286,7 @@ void PTCACHE_OT_free_bake(wmOperatorType *ot) { /* identifiers */ ot->name= "Free Physics Bake"; + ot->description= "Free physics bake"; ot->idname= "PTCACHE_OT_free_bake"; /* api callbacks */ @@ -296,6 +300,7 @@ void PTCACHE_OT_bake_from_cache(wmOperatorType *ot) { /* identifiers */ ot->name= "Bake From Cache"; + ot->description= "Bake from cache"; ot->idname= "PTCACHE_OT_bake_from_cache"; /* api callbacks */ @@ -364,7 +369,8 @@ static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) void PTCACHE_OT_add(wmOperatorType *ot) { /* identifiers */ - ot->name= "Add new cache"; + ot->name= "Add New Cache"; + ot->description= "Add new cache"; ot->idname= "PTCACHE_OT_add"; /* api callbacks */ @@ -377,7 +383,8 @@ void PTCACHE_OT_add(wmOperatorType *ot) void PTCACHE_OT_remove(wmOperatorType *ot) { /* identifiers */ - ot->name= "Delete current cache"; + ot->name= "Delete Current Cache"; + ot->description= "Delete current cache"; ot->idname= "PTCACHE_OT_remove"; /* api callbacks */ diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 1dc5612f48b..d04c75a2b48 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -32,7 +32,7 @@ set(INC ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc - ${GLEW_INCLUDE_PATH} + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 178a15354fb..5463eefe866 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -28,7 +28,6 @@ * \ingroup edrend */ - #include #include diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e2d7147d21f..02fae52219b 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -110,7 +110,7 @@ int ED_operator_screenactive(bContext *C) } /* XXX added this to prevent anim state to change during renders */ -int ED_operator_screenactive_norender(bContext *C) +static int ED_operator_screenactive_norender(bContext *C) { if(G.rendering) return 0; if(CTX_wm_window(C)==NULL) return 0; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 29bcb191b46..db575907b49 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -440,6 +440,8 @@ static void image_undo_restore(bContext *C, ListBase *lb) GPU_free_image(ima); /* force OpenGL reload */ if(ibuf->rect_float) ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ + if(ibuf->mipmap[0]) + ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */ } @@ -5066,56 +5068,6 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings) } } -/* ************ image paint radial control *************/ -static int paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - float zoom; - ToolSettings *ts = CTX_data_scene(C)->toolsettings; - get_imapaint_zoom(C, &zoom, &zoom); - toggle_paint_cursor(C, 0); - brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), zoom); - return WM_radial_control_invoke(C, op, event); -} - -static int paint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - toggle_paint_cursor(C, 1); - return ret; -} - -static int paint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint); - float zoom; - int ret; - char str[64]; - get_imapaint_zoom(C, &zoom, &zoom); - ret = brush_radial_control_exec(op, brush, 1.0f / zoom); - WM_radial_control_string(op, str, sizeof(str)); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -void PAINT_OT_image_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Image Paint Radial Control"; - ot->idname= "PAINT_OT_image_paint_radial_control"; - - ot->invoke= paint_radial_control_invoke; - ot->modal= paint_radial_control_modal; - ot->exec= paint_radial_control_exec; - ot->poll= image_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /************************ grab clone operator ************************/ typedef struct GrabClone { @@ -5332,7 +5284,7 @@ static int set_clone_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event) View3D *v3d= CTX_wm_view3d(C); ARegion *ar= CTX_wm_region(C); float location[3]; - short mval[2]; + int mval[2]; mval[0]= event->x - ar->winrct.xmin; mval[1]= event->y - ar->winrct.ymin; @@ -5443,28 +5395,6 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/************* texture paint radial control *************/ - -static int texture_paint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - ToolSettings *ts = CTX_data_scene(C)->toolsettings; - toggle_paint_cursor(C, !ts->imapaint.paintcursor); - brush_radial_control_invoke(op, paint_brush(&ts->imapaint.paint), 1); - return WM_radial_control_invoke(C, op, event); -} - -static int texture_paint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->imapaint.paint); - int ret = brush_radial_control_exec(op, brush, 1); - char str[64]; - WM_radial_control_string(op, str, sizeof(str)); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - static int texture_paint_poll(bContext *C) { if(texture_paint_toggle_poll(C)) @@ -5479,23 +5409,6 @@ int image_texture_paint_poll(bContext *C) return (texture_paint_poll(C) || image_paint_poll(C)); } -void PAINT_OT_texture_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Texture Paint Radial Control"; - ot->idname= "PAINT_OT_texture_paint_radial_control"; - - ot->invoke= texture_paint_radial_control_invoke; - ot->modal= paint_radial_control_modal; - ot->exec= texture_paint_radial_control_exec; - ot->poll= texture_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - - int facemask_paint_poll(bContext *C) { return paint_facesel_test(CTX_data_active_object(C)); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 48fca04ac87..ba7235a3161 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -81,12 +81,10 @@ void vpaint_fill(struct Object *ob, unsigned int paintcol); void wpaint_fill(struct VPaint *wp, struct Object *ob, float paintweight); void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot); -void PAINT_OT_weight_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_weight_paint(struct wmOperatorType *ot); void PAINT_OT_weight_set(struct wmOperatorType *ot); void PAINT_OT_weight_from_bones(struct wmOperatorType *ot); -void PAINT_OT_vertex_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_vertex_paint_toggle(struct wmOperatorType *ot); void PAINT_OT_vertex_paint(struct wmOperatorType *ot); @@ -96,12 +94,10 @@ unsigned int vpaint_get_current_col(struct VPaint *vp); int image_texture_paint_poll(struct bContext *C); void PAINT_OT_image_paint(struct wmOperatorType *ot); -void PAINT_OT_image_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_grab_clone(struct wmOperatorType *ot); void PAINT_OT_sample_color(struct wmOperatorType *ot); void PAINT_OT_clone_cursor_set(struct wmOperatorType *ot); void PAINT_OT_texture_paint_toggle(struct wmOperatorType *ot); -void PAINT_OT_texture_paint_radial_control(struct wmOperatorType *ot); void PAINT_OT_project_image(struct wmOperatorType *ot); void PAINT_OT_image_from_view(struct wmOperatorType *ot); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 9a1de939067..e4a21b1f1a7 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -23,7 +23,10 @@ * \ingroup edsculpt */ +#include "MEM_guardedalloc.h" +#include +#include "BLI_string.h" #include "BLI_utildefines.h" #include "DNA_object_types.h" @@ -355,9 +358,7 @@ void ED_operatortypes_paint(void) /* image */ WM_operatortype_append(PAINT_OT_texture_paint_toggle); - WM_operatortype_append(PAINT_OT_texture_paint_radial_control); WM_operatortype_append(PAINT_OT_image_paint); - WM_operatortype_append(PAINT_OT_image_paint_radial_control); WM_operatortype_append(PAINT_OT_sample_color); WM_operatortype_append(PAINT_OT_grab_clone); WM_operatortype_append(PAINT_OT_clone_cursor_set); @@ -366,13 +367,11 @@ void ED_operatortypes_paint(void) /* weight */ WM_operatortype_append(PAINT_OT_weight_paint_toggle); - WM_operatortype_append(PAINT_OT_weight_paint_radial_control); WM_operatortype_append(PAINT_OT_weight_paint); WM_operatortype_append(PAINT_OT_weight_set); WM_operatortype_append(PAINT_OT_weight_from_bones); /* vertex */ - WM_operatortype_append(PAINT_OT_vertex_paint_radial_control); WM_operatortype_append(PAINT_OT_vertex_paint_toggle); WM_operatortype_append(PAINT_OT_vertex_paint); WM_operatortype_append(PAINT_OT_vertex_color_set); @@ -464,6 +463,59 @@ static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path RNA_float_set(kmi->ptr, "scalar", 10.0/9.0); // 1.1111.... } +typedef enum { + RC_COLOR = 1, + RC_ROTATION = 2, + RC_ZOOM = 4, +} RCFlags; + +static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path, + const char *output_name, const char *input_name) +{ + char *path; + + path = BLI_sprintfN("%s.%s", brush_path, input_name); + RNA_string_set(ptr, output_name, path); + MEM_freeN(path); +} + +static void set_brush_rc_props(PointerRNA *ptr, const char *paint, + const char *prop, RCFlags flags) +{ + char *brush_path; + + brush_path = BLI_sprintfN("tool_settings.%s.brush", paint); + + set_brush_rc_path(ptr, brush_path, "data_path", prop); + set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add"); + set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle"); + RNA_string_set(ptr, "image_id", brush_path); + + if(flags & RC_COLOR) + set_brush_rc_path(ptr, brush_path, "fill_color_path", "color"); + if(flags & RC_ZOOM) + RNA_string_set(ptr, "zoom_path", "space_data.zoom"); + + MEM_freeN(brush_path); +} + +static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint, + RCFlags flags) +{ + wmKeyMapItem *kmi; + + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0); + set_brush_rc_props(kmi->ptr, paint, "size", flags); + + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); + set_brush_rc_props(kmi->ptr, paint, "strength", flags); + + if(flags & RC_ROTATION) { + kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0); + set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", flags); + } +} + void ED_keymap_paint(wmKeyConfig *keyconf) { wmKeyMap *keymap; @@ -474,10 +526,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0); keymap->poll= sculpt_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", WM_RADIALCONTROL_ANGLE); - RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT); RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH); @@ -496,6 +544,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "sculpt"); ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION); 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); @@ -521,8 +570,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0); keymap->poll= vertex_paint_mode_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_vertex_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); @@ -531,6 +578,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "vertex_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "data_path", "vertex_paint_object.data.use_paint_mask"); @@ -539,9 +587,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0); keymap->poll= weight_paint_mode_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, @@ -549,6 +594,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "weight_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "weight_paint", 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "data_path", "weight_paint_object.data.use_paint_mask"); @@ -559,12 +605,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0); keymap->poll= image_texture_paint_poll; - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_image_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, 0, 0)->ptr, "mode", WM_RADIALCONTROL_SIZE); - RNA_enum_set(WM_keymap_add_item(keymap, "PAINT_OT_texture_paint_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", WM_RADIALCONTROL_STRENGTH); - WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0); @@ -572,6 +612,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) ed_keymap_paint_brush_switch(keymap, "image_paint"); ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size"); + ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR|RC_ZOOM); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */ RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask"); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 19c726616da..f4fc004f413 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -736,10 +736,10 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, float vpimat[][3], fl Brush *brush = paint_brush(&vp->paint); float fac, fac_2, size, dx, dy; float alpha; - short vertco[2]; + int vertco[2]; const int radius= brush_size(brush); - project_short_noclip(vc->ar, vert_nor, vertco); + project_int_noclip(vc->ar, vert_nor, vertco); dx= mval[0]-vertco[0]; dy= mval[1]-vertco[1]; @@ -868,7 +868,7 @@ static void sample_wpaint(Scene *scene, ARegion *ar, View3D *UNUSED(v3d), int mo Object *ob= OBACT; Mesh *me= get_mesh(ob); int index; - short mval[2] = {0, 0}, sco[2]; + int mval[2] = {0, 0}, sco[2]; int vgroup= ob->actdef-1; if (!me) return; @@ -953,20 +953,20 @@ static void sample_wpaint(Scene *scene, ARegion *ar, View3D *UNUSED(v3d), int mo else { /* calc 3 or 4 corner weights */ dm->getVertCo(dm, mface->v1, co); - project_short_noclip(ar, co, sco); + project_int_noclip(ar, co, sco); w1= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1])); dm->getVertCo(dm, mface->v2, co); - project_short_noclip(ar, co, sco); + project_int_noclip(ar, co, sco); w2= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1])); dm->getVertCo(dm, mface->v3, co); - project_short_noclip(ar, co, sco); + project_int_noclip(ar, co, sco); w3= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1])); if(mface->v4) { dm->getVertCo(dm, mface->v4, co); - project_short_noclip(ar, co, sco); + project_int_noclip(ar, co, sco); w4= ((mval[0]-sco[0])*(mval[0]-sco[0]) + (mval[1]-sco[1])*(mval[1]-sco[1])); } else w4= 1.0e10; @@ -1147,110 +1147,6 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) } -/* ************ paint radial controls *************/ - -static int vpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Paint *p = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(p); - float col[4]; - - WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); - p->paint_cursor = NULL; - brush_radial_control_invoke(op, brush, 1); - - copy_v3_v3(col, brush->add_col); - col[3]= 0.5f; - RNA_float_set_array(op->ptr, "color", col); - - return WM_radial_control_invoke(C, op, event); -} - -static int vpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - paint_cursor_start(C, vertex_paint_poll); - return ret; -} - -static int vpaint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->vpaint->paint); - int ret = brush_radial_control_exec(op, brush, 1); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -static int wpaint_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Paint *p = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(p); - float col[4]; - - WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); - p->paint_cursor = NULL; - brush_radial_control_invoke(op, brush, 1); - - copy_v3_v3(col, brush->add_col); - col[3]= 0.5f; - RNA_float_set_array(op->ptr, "color", col); - - return WM_radial_control_invoke(C, op, event); -} - -static int wpaint_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - paint_cursor_start(C, weight_paint_poll); - return ret; -} - -static int wpaint_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_scene(C)->toolsettings->wpaint->paint); - int ret = brush_radial_control_exec(op, brush, 1); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -void PAINT_OT_weight_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Weight Paint Radial Control"; - ot->idname= "PAINT_OT_weight_paint_radial_control"; - - ot->invoke= wpaint_radial_control_invoke; - ot->modal= wpaint_radial_control_modal; - ot->exec= wpaint_radial_control_exec; - ot->poll= weight_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - -void PAINT_OT_vertex_paint_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Vertex Paint Radial Control"; - ot->idname= "PAINT_OT_vertex_paint_radial_control"; - - ot->invoke= vpaint_radial_control_invoke; - ot->modal= vpaint_radial_control_modal; - ot->exec= vpaint_radial_control_exec; - ot->poll= vertex_paint_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /* ************ weight paint operator ********** */ struct WPaintData { diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7156b49c026..09e46119dbe 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2816,65 +2816,6 @@ static const char *sculpt_tool_name(Sculpt *sd) } } -/**** Radial control ****/ -static int sculpt_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - Paint *p = paint_get_active(CTX_data_scene(C)); - Brush *brush = paint_brush(p); - float col[4], tex_col[4]; - - WM_paint_cursor_end(CTX_wm_manager(C), p->paint_cursor); - p->paint_cursor = NULL; - brush_radial_control_invoke(op, brush, 1); - - if((brush->flag & BRUSH_DIR_IN) && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH)) - copy_v3_v3(col, brush->sub_col); - else - copy_v3_v3(col, brush->add_col); - col[3]= 0.5f; - - copy_v3_v3(tex_col, U.sculpt_paint_overlay_col); - tex_col[3]= (brush->texture_overlay_alpha / 100.0f); - - RNA_float_set_array(op->ptr, "color", col); - RNA_float_set_array(op->ptr, "texture_color", tex_col); - - return WM_radial_control_invoke(C, op, event); -} - -static int sculpt_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - int ret = WM_radial_control_modal(C, op, event); - if(ret != OPERATOR_RUNNING_MODAL) - paint_cursor_start(C, sculpt_poll); - return ret; -} - -static int sculpt_radial_control_exec(bContext *C, wmOperator *op) -{ - Brush *brush = paint_brush(&CTX_data_tool_settings(C)->sculpt->paint); - int ret = brush_radial_control_exec(op, brush, 1); - - WM_event_add_notifier(C, NC_BRUSH|NA_EDITED, brush); - - return ret; -} - -static void SCULPT_OT_radial_control(wmOperatorType *ot) -{ - WM_OT_radial_control_partial(ot); - - ot->name= "Sculpt Radial Control"; - ot->idname= "SCULPT_OT_radial_control"; - - ot->invoke= sculpt_radial_control_invoke; - ot->modal= sculpt_radial_control_modal; - ot->exec= sculpt_radial_control_exec; - ot->poll= sculpt_poll; - - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; -} - /**** Operator for applying a stroke (various attributes including mouse path) using the current brush. ****/ @@ -3346,18 +3287,23 @@ static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss) sculpt_update_tex(sd, ss); } -static int sculpt_brush_stroke_init(bContext *C, ReportList *UNUSED(reports)) +static int sculpt_brush_stroke_init(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; SculptSession *ss = CTX_data_active_object(C)->sculpt; Brush *brush = paint_brush(&sd->paint); + int mode= RNA_enum_get(op->ptr, "mode"); + int is_smooth= 0; view3d_operator_needs_opengl(C); sculpt_brush_init_tex(sd, ss); - sculpt_update_mesh_elements(scene, sd, ob, brush->sculpt_tool == SCULPT_TOOL_SMOOTH); + is_smooth|= mode == BRUSH_STROKE_SMOOTH; + is_smooth|= brush->sculpt_tool == SCULPT_TOOL_SMOOTH; + + sculpt_update_mesh_elements(scene, sd, ob, is_smooth); return 1; } @@ -3573,7 +3519,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even struct PaintStroke *stroke; int ignore_background_click; - if(!sculpt_brush_stroke_init(C, op->reports)) + if(!sculpt_brush_stroke_init(C, op)) return OPERATOR_CANCELLED; stroke = paint_stroke_new(C, sculpt_stroke_get_location, @@ -3602,7 +3548,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) { - if(!sculpt_brush_stroke_init(C, op->reports)) + if(!sculpt_brush_stroke_init(C, op)) return OPERATOR_CANCELLED; op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, @@ -3758,7 +3704,6 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) void ED_operatortypes_sculpt(void) { - WM_operatortype_append(SCULPT_OT_radial_control); WM_operatortype_append(SCULPT_OT_brush_stroke); WM_operatortype_append(SCULPT_OT_sculptmode_toggle); WM_operatortype_append(SCULPT_OT_set_persistent_base); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index bee872dbe60..6637e7004d5 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -858,9 +858,9 @@ static int actkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent /* determine which side of the current frame mouse is on */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, NULL); if (x < CFRA) - RNA_int_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT); + RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT); else - RNA_int_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT); + RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT); } /* perform selection */ diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index b097ad0f55e..4daaea4513c 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -433,7 +433,7 @@ void folderlist_pushdir(ListBase* folderlist, const char *dir) // check if already exists if(previous_folder && previous_folder->foldername){ - if(! strcmp(previous_folder->foldername, dir)){ + if(BLI_path_cmp(previous_folder->foldername, dir)==0){ return; } } @@ -1070,9 +1070,9 @@ void filelist_from_library(struct FileList* filelist) PreviewImage *img= l->link; if (img) { - unsigned int w = img->w[PREVIEW_MIPMAP_LARGE]; - unsigned int h = img->h[PREVIEW_MIPMAP_LARGE]; - unsigned int *rect = img->rect[PREVIEW_MIPMAP_LARGE]; + unsigned int w = img->w[ICON_SIZE_PREVIEW]; + unsigned int h = img->h[ICON_SIZE_PREVIEW]; + unsigned int *rect = img->rect[ICON_SIZE_PREVIEW]; /* first allocate imbuf for copying preview into it */ if (w > 0 && h > 0 && rect) { diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 6c713d6e469..47b3a71a9ea 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -818,7 +818,7 @@ static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEve ARegion *ar= ac.ar; View2D *v2d= &ar->v2d; - short mval[2]; + int mval[2]; float x; /* get mouse coordinates (in region coordinates) */ diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index b23ab624faa..286f1f3178b 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -38,7 +38,6 @@ set(SRC image_buttons.c image_draw.c image_ops.c - image_render.c space_image.c image_intern.h @@ -60,9 +59,4 @@ if(WITH_IMAGE_CINEON) add_definitions(-DWITH_CINEON) endif() -if(WITH_LCMS) - set(INC ${INC} ${LCMS_INCLUDE_DIR}) - add_definitions(-DWITH_LCMS) -endif() - blender_add_lib(bf_editor_space_image "${SRC}" "${INC}") diff --git a/source/blender/editors/space_image/SConscript b/source/blender/editors/space_image/SConscript index e84afcdaab1..27696e35701 100644 --- a/source/blender/editors/space_image/SConscript +++ b/source/blender/editors/space_image/SConscript @@ -9,9 +9,6 @@ incs += ' ../../render/extern/include ../../makesrna ../../blenloader' defs = [] -if env['WITH_BF_LCMS']: - defs.append('WITH_LCMS') - incs += ' ' + env['BF_LCMS_INC'] if env['WITH_BF_OPENEXR']: defs.append('WITH_OPENEXR') if env['WITH_BF_OPENJPEG']: diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 0fd7ac3e754..7e881e7e62f 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -98,19 +98,6 @@ /* proto */ -static void do_image_panel_events(bContext *C, void *UNUSED(arg), int event) -{ - SpaceImage *sima= CTX_wm_space_image(C); - - switch(event) { - case B_REDR: - break; - } - - /* all events now */ - WM_event_add_notifier(C, NC_IMAGE, sima->image); -} - static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, char *str) { int ofs= 0; @@ -281,7 +268,7 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block) rcti *disprect= &G.scene->r.disprect; int winx= (G.scene->r.size*G.scene->r.xsch)/100; int winy= (G.scene->r.size*G.scene->r.ysch)/100; - short mval[2]; + int mval[2]; if(G.scene->r.mode & R_BORDER) { winx*= (G.scene->r.border.xmax - G.scene->r.border.xmin); @@ -593,6 +580,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, uiBlock *block= uiLayoutGetBlock(layout); uiLayout *row; uiBut *but; + const float dpi_fac= UI_DPI_FAC; row= uiLayoutRow(layout, 1); @@ -609,7 +597,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, but= uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0,0,18,20, NULL, 0, 0, 0, 0, "Next Layer"); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); - uiblock_layer_pass_buttons(row, rr, iuser, 230, render_slot); + uiblock_layer_pass_buttons(row, rr, iuser, 230 * dpi_fac, render_slot); /* decrease, increase arrows */ but= uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0,0,17,20, NULL, 0, 0, 0, 0, "Previous Pass"); @@ -841,8 +829,9 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser /* render layers and passes */ if(ima && iuser) { + const float dpi_fac= UI_DPI_FAC; rr= BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_buttons(layout, rr, iuser, 160, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL); + uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL); BKE_image_release_renderresult(scene, ima); } } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 0f361b43de6..112359726ea 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -58,10 +58,6 @@ #include "BKE_image.h" #include "BKE_paint.h" -#ifdef WITH_LCMS -#include "BKE_colortools.h" -#endif - #include "BIF_gl.h" #include "BIF_glutil.h" @@ -452,20 +448,6 @@ static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, fl // glColorMask(1, 1, 1, 1); } -#ifdef WITH_LCMS -static int sima_draw_colorcorrected_pixels(float x1, float y1, ImBuf *ibuf) -{ - colorcorrection_do_ibuf(ibuf, "MONOSCNR.ICM"); /* path is hardcoded here, find some place better */ - - if(ibuf->crect) { - glaDrawPixelsSafe(x1, y1, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->crect); - return 1; - } - - return 0; -} -#endif - static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int *recti) { /* zbuffer values are signed, so we need to shift color range */ @@ -544,17 +526,6 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image else if(ibuf->channels==1) sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float); } -#ifdef WITH_LCMS - else if(sima->flag & SI_COLOR_CORRECTION) { - image_verify_buffer_float(ima, ibuf, color_manage); - - if(sima_draw_colorcorrected_pixels(x, y, ibuf)==0) { - unsigned char col1[3]= {100, 0, 100}, col2[3]= {160, 0, 160}; /* pink says 'warning' in blender land */ - sima_draw_alpha_backdrop(x, y, ibuf->x, ibuf->y, zoomx, zoomy, col1, col2); - } - - } -#endif else { if(sima->flag & SI_USE_ALPHA) { unsigned char col1[3]= {100, 100, 100}, col2[3]= {160, 160, 160}; @@ -702,7 +673,7 @@ static void draw_image_view_tool(Scene *scene) { ToolSettings *settings= scene->toolsettings; Brush *brush= settings->imapaint.brush; - short mval[2]; + int mval[2]; float radius; int draw= 0; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 7d4aaf0c70e..c4d52e3b836 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -645,6 +645,9 @@ static const EnumPropertyItem image_file_type_items[] = { {R_TARGA, "TARGA", 0, "Targa", ""}, {R_RAWTGA, "TARGA RAW", 0, "Targa Raw", ""}, {R_PNG, "PNG", 0, "PNG", ""}, +#ifdef WITH_DDS + {R_DDS, "DDS", 0, "DirectDraw Surface", ""}, +#endif {R_BMP, "BMP", 0, "BMP", ""}, {R_JPEG90, "JPEG", 0, "Jpeg", ""}, #ifdef WITH_OPENJPEG @@ -799,6 +802,7 @@ void IMAGE_OT_open(wmOperatorType *ot) { /* identifiers */ ot->name= "Open Image"; + ot->description= "Open image"; ot->idname= "IMAGE_OT_open"; /* api callbacks */ @@ -1342,6 +1346,7 @@ void IMAGE_OT_new(wmOperatorType *ot) /* identifiers */ ot->name= "New Image"; + ot->description= "Create a new image"; ot->idname= "IMAGE_OT_new"; /* api callbacks */ @@ -1420,6 +1425,9 @@ static int image_invert_exec(bContext *C, wmOperator *op) } ibuf->userflags |= IB_BITMAPDIRTY; + if(ibuf->mipmap[0]) + ibuf->userflags |= IB_MIPMAP_INVALID; + WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_image/image_render.c b/source/blender/editors/space_image/image_render.c deleted file mode 100644 index 04b65af618e..00000000000 --- a/source/blender/editors/space_image/image_render.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * Contributor(s): Blender Foundation, 2002-2009 - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/editors/space_image/image_render.c - * \ingroup spimage - */ - - -#include -#include - -#include "BLI_utildefines.h" - -#include "DNA_screen_types.h" -#include "DNA_space_types.h" - -#include "BKE_context.h" -#include "BKE_image.h" - -#include "BIF_gl.h" -#include "BIF_glutil.h" - - -#include "RE_pipeline.h" - - -#define HEADER_HEIGHT 18 - -/* *********************** render callbacks ***************** */ - -/* set on initialize render, only one render output to imagewindow can exist, so the global isnt dangerous yet :) */ -static ScrArea *image_area= NULL; - -/* can get as well the full picture, as the parts while rendering */ -/* XXX will be obsolete, here for reference now */ -static void imagewindow_progress(SpaceImage *sima, RenderResult *rr, volatile rcti *renrect) -{ - float x1, y1, *rectf= NULL; - unsigned int *rect32= NULL; - int ymin, ymax, xmin, xmax; - - /* if renrect argument, we only display scanlines */ - if(renrect) { - /* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */ - if(rr->renlay==NULL || renrect->ymax>=rr->recty) - return; - - /* xmin here is first subrect x coord, xmax defines subrect width */ - xmin = renrect->xmin; - xmax = renrect->xmax - xmin; - if (xmax<2) return; - - ymin= renrect->ymin; - ymax= renrect->ymax - ymin; - if(ymax<2) - return; - renrect->ymin= renrect->ymax; - } - else { - xmin = ymin = 0; - xmax = rr->rectx - 2*rr->crop; - ymax = rr->recty - 2*rr->crop; - } - - /* image window cruft */ - - /* find current float rect for display, first case is after composit... still weak */ - if(rr->rectf) - rectf= rr->rectf; - else { - if(rr->rect32) - rect32= (unsigned int *)rr->rect32; - else { - if(rr->renlay==NULL || rr->renlay->rectf==NULL) return; - rectf= rr->renlay->rectf; - } - } - if(rectf) { - /* if scanline updates... */ - rectf+= 4*(rr->rectx*ymin + xmin); - - /* when rendering more pixels than needed, we crop away cruft */ - if(rr->crop) - rectf+= 4*(rr->crop*rr->rectx + rr->crop); - } - - /* tilerect defines drawing offset from (0,0) */ - /* however, tilerect (xmin, ymin) is first pixel */ - x1 = sima->centx + (rr->tilerect.xmin + rr->crop + xmin)*sima->zoom; - y1 = sima->centy + (rr->tilerect.ymin + rr->crop + ymin)*sima->zoom; - - /* needed for gla draw */ - // XXX { rcti rct= ar->winrct; rct.ymax-= HEADER_HEIGHT; glaDefine2DArea(&rct);} - - glPixelZoom(sima->zoom, sima->zoom); - - if(rect32) - glaDrawPixelsSafe(x1, y1, xmax, ymax, rr->rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect32); - else - glaDrawPixelsSafe_to32(x1, y1, xmax, ymax, rr->rectx, rectf, 0); - - glPixelZoom(1.0, 1.0); - -} - - -/* coming from BIF_toggle_render_display() */ -static void imagewindow_toggle_render(bContext *C) -{ - bScreen *sc= CTX_wm_screen(C); - ScrArea *sa; - - /* check if any imagewindow is showing temporal render output */ - for(sa=sc->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_IMAGE) { - SpaceImage *sima= sa->spacedata.first; - - if(sima->image && sima->image->type==IMA_TYPE_R_RESULT) - if(sima->flag & (SI_PREVSPACE|SI_FULLWINDOW)) - break; - } - } - - if(sa) { - // XXX addqueue(sa->win, ESCKEY, 1); /* also returns from fullscreen */ - } - else { -// sa= imagewindow_set_render_display(C); - // XXX scrarea_queue_headredraw(sa); - // XXX scrarea_queue_winredraw(sa); - } -} - -/* NOTE: called while render, so no malloc allowed! */ -static void imagewindow_renderinfo_cb(void *UNUSED(handle), RenderStats *UNUSED(rs)) -{ - if(image_area) { - // XXX BIF_make_render_text(rs); - - // XXX sima_draw_render_info(sima, ar); - - /* no screen_swapbuffers, prevent any other window to draw */ - // XXX myswapbuffers(); - } -} - -static void ED_space_image_render_callbacks(bContext *C, Render *re) -{ - -// RE_display_init_cb(re, C, imagewindow_init_display_cb); -// RE_display_draw_cb(re, C, imagewindow_progress_display_cb); -// RE_display_clear_cb(re, C, imagewindow_clear_display_cb); - RE_stats_draw_cb(re, C, imagewindow_renderinfo_cb); -} - diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 67f02ce4f8e..937b683e880 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -230,7 +230,7 @@ static int borderselect_exec(bContext *C, wmOperator *op) rcti rect; //rctf rectf, rq; short selecting= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); - //short mval[2]; + //int mval[2]; rect.xmin= RNA_int_get(op->ptr, "xmin"); rect.ymin= RNA_int_get(op->ptr, "ymin"); diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index d75c1aa7dd3..188042ad1d1 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -612,7 +612,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even bAnimContext ac; Scene *scene; ARegion *ar; - View2D *v2d; + // View2D *v2d; /*UNUSED*/ short selectmode; int mval[2]; @@ -623,7 +623,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even /* get useful pointers from animation context data */ scene= ac.scene; ar= ac.ar; - v2d= &ar->v2d; + // v2d= &ar->v2d; /* get mouse coordinates (in region coordinates) */ mval[0]= (event->x - ar->winrct.xmin); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 97a006ad1e3..e1085a5ca71 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1050,7 +1050,7 @@ static bNode *visible_node(SpaceNode *snode, rctf *rct) /* **************************** */ typedef struct NodeViewMove { - short mvalo[2]; + int mvalo[2]; int xmin, ymin, xmax, ymax; } NodeViewMove; @@ -1655,7 +1655,7 @@ static int node_mouse_groupheader(SpaceNode *snode) { bNode *gnode; float mx=0, my=0; -// XXX short mval[2]; +// XXX int mval[2]; gnode= node_tree_get_editgroup(snode->nodetree); if(gnode==NULL) return 0; diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 78368d91378..6bda47e5c8f 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -70,7 +70,7 @@ static bNode *node_under_mouse(bNodeTree *ntree, int mx, int my) /* ****** Click Select ****** */ -static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const short mval[2], short extend) +static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const int mval[2], short extend) { bNode *node; float mx, my; @@ -102,7 +102,7 @@ static int node_select_exec(bContext *C, wmOperator *op) { SpaceNode *snode= CTX_wm_space_node(C); ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; short extend; bNode *node= NULL; @@ -125,7 +125,7 @@ static int node_select_exec(bContext *C, wmOperator *op) static int node_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; mval[0]= event->x - ar->winrct.xmin; mval[1]= event->y - ar->winrct.ymin; @@ -199,7 +199,7 @@ static int node_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event /* this allows border select on empty space, but drag-translate on nodes */ SpaceNode *snode= CTX_wm_space_node(C); ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; float mx, my; mval[0]= event->x - ar->winrct.xmin; diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c index 1ae36b077af..9665a152970 100644 --- a/source/blender/editors/space_node/node_state.c +++ b/source/blender/editors/space_node/node_state.c @@ -158,7 +158,7 @@ static int do_header_hidden_node(bNode *node, float mx, float my) return 0; } -static int node_toggle_visibility(SpaceNode *snode, ARegion *ar, const short mval[2]) +static int node_toggle_visibility(SpaceNode *snode, ARegion *ar, const int mval[2]) { bNode *node; float mx, my; @@ -189,7 +189,7 @@ static int node_toggle_visibility_exec(bContext *C, wmOperator *op) { SpaceNode *snode= CTX_wm_space_node(C); ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; mval[0] = RNA_int_get(op->ptr, "mouse_x"); mval[1] = RNA_int_get(op->ptr, "mouse_y"); @@ -202,7 +202,7 @@ static int node_toggle_visibility_exec(bContext *C, wmOperator *op) static int node_toggle_visibility_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - short mval[2]; + int mval[2]; mval[0]= event->x - ar->winrct.xmin; mval[1]= event->y - ar->winrct.ymin; diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 0e574ca5ffb..32e6424f709 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -5640,10 +5640,11 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo xstart+= butw3+5; /* rna property */ - if(kmi->ptr && kmi->ptr->data) + if(kmi->ptr && kmi->ptr->data) { uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys+1, butw2, OL_H-1, &kmi->oskey, 0, 0, 0, 0, ""); xstart+= butw2; - - + } + + (void)xstart; } } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 2ef8fb12965..ad0d0048388 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -120,7 +120,7 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, w ARegion *ar= CTX_wm_region(C); View2D *v2d= UI_view2d_fromcontext(C); - short mval[2]; + int mval[2]; float mval_v2d[2]; @@ -633,12 +633,13 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_ERROR, "Sequencer plugin \"%s\" could not load.", path); return OPERATOR_CANCELLED; } - } - else if (seq->type==SEQ_COLOR) { + } else if (seq->type == SEQ_COLOR) { SolidColorVars *colvars= (SolidColorVars *)seq->effectdata; RNA_float_get_array(op->ptr, "color", colvars->col); seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */ + } else if (seq->type == SEQ_ADJUSTMENT) { + seq->blend_mode= SEQ_CROSS; } // XXX, this conflicts with giving a channel with invoke, perhaps we should have an active channel diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 2f95e8fa64c..f351d52db07 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -126,6 +126,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[ case SEQ_OVERDROP: case SEQ_GLOW: case SEQ_MULTICAM: + case SEQ_ADJUSTMENT: UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col); /* slightly offset hue to distinguish different effects */ @@ -137,6 +138,8 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[ if (seq->type == SEQ_OVERDROP) rgb_byte_set_hue_float_offset(col,0.24); if (seq->type == SEQ_GLOW) rgb_byte_set_hue_float_offset(col,0.28); if (seq->type == SEQ_TRANSFORM) rgb_byte_set_hue_float_offset(col,0.36); + if (seq->type == SEQ_MULTICAM) rgb_byte_set_hue_float_offset(col,0.32); + if (seq->type == SEQ_ADJUSTMENT) rgb_byte_set_hue_float_offset(col,0.40); break; case SEQ_COLOR: @@ -476,7 +479,7 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float if(name[0]=='\0') name= give_seqname(seq); - if(seq->type == SEQ_META) { + if(seq->type == SEQ_META || seq->type == SEQ_ADJUSTMENT) { sprintf(str, "%d | %s", seq->len, name); } else if(seq->type == SEQ_SCENE) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 92fae3d4820..880f285c3e3 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -100,6 +100,7 @@ EnumPropertyItem sequencer_prop_effect_types[] = { {SEQ_COLOR, "COLOR", 0, "Color", "Color effect strip type"}, {SEQ_SPEED, "SPEED", 0, "Speed", "Color effect strip type"}, {SEQ_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""}, + {SEQ_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""}, {0, NULL, 0, NULL, NULL} }; @@ -191,7 +192,7 @@ void boundbox_seq(Scene *scene, rctf *rect) static int mouse_frame_side(View2D *v2d, short mouse_x, int frame ) { - short mval[2]; + int mval[2]; float mouseloc[2]; mval[0]= mouse_x; @@ -284,7 +285,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i } -Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const short mval[2]) +Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2]) { Sequence *seq; Editing *ed= seq_give_editing(scene, FALSE); @@ -406,6 +407,7 @@ int event_to_efftype(int event) if(event==15) return SEQ_TRANSFORM; if(event==16) return SEQ_COLOR; if(event==17) return SEQ_SPEED; + if(event==18) return SEQ_ADJUSTMENT; return 0; } @@ -517,7 +519,8 @@ static void change_sequence(Scene *scene) "|Glow%x14" "|Transform%x15" "|Color Generator%x16" - "|Speed Control%x17"); + "|Speed Control%x17" + "|Adjustment Layer%x18"); if(event > 0) { if(event==1) { SWAP(Sequence *,last_seq->seq1,last_seq->seq2); @@ -703,15 +706,9 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de while(seq) { seqn= seq->next; if((seq->flag & flag) || deleteall) { - if(seq->type==SEQ_SOUND && seq->sound) { - ((ID *)seq->sound)->us--; /* TODO, could be moved into seq_free_sequence() */ - } - BLI_remlink(lb, seq); if(seq==last_seq) seq_active_set(scene, NULL); if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); - /* if(seq->ipo) seq->ipo->id.us--; */ - /* XXX, remove fcurve */ seq_free_sequence(scene, seq); } seq= seqn; @@ -1084,7 +1081,7 @@ static int seq_get_snaplimit(View2D *v2d) /* fake mouse coords to get the snap value a bit lazy but its only done once pre transform */ float xmouse, ymouse, x; - short mval[2] = {24, 0}; /* 24 screen px snap */ + int mval[2] = {24, 0}; /* 24 screen px snap */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse); x = xmouse; @@ -1706,11 +1703,6 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) if (nothingSelected) return OPERATOR_FINISHED; - /* free imbufs of all dependent strips */ - for(seq=ed->seqbasep->first; seq; seq=seq->next) - if(seq->flag & SELECT) - update_changed_seq_and_deps(scene, seq, 1, 0); - /* for effects, try to find a replacement input */ for(seq=ed->seqbasep->first; seq; seq=seq->next) if((seq->type & SEQ_EFFECT) && !(seq->flag & SELECT)) diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 9a4796ced5e..209b39662aa 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -61,7 +61,7 @@ void seq_reset_imageofs(struct SpaceSeq *sseq); struct View2D; void seq_rectf(struct Sequence *seq, struct rctf *rectf); void boundbox_seq(struct Scene *scene, struct rctf *rect); -struct Sequence *find_nearest_seq(struct Scene *scene, struct View2D *v2d, int *hand, const short mval[2]); +struct Sequence *find_nearest_seq(struct Scene *scene, struct View2D *v2d, int *hand, const int mval[2]); struct Sequence *find_neighboring_sequence(struct Scene *scene, struct Sequence *test, int lr, int sel); void deselect_all_seq(struct Scene *scene); void recurs_sel_seq(struct Sequence *seqm); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index b2d6ab6f8ca..2cae2d17a33 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -307,7 +307,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) short left_right= RNA_boolean_get(op->ptr, "left_right"); short linked_time= RNA_boolean_get(op->ptr, "linked_time"); - short mval[2]; + int mval[2]; Sequence *seq,*neighbor, *act_orig; int hand,sel_side; @@ -489,7 +489,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) /* marker transform */ #if 0 // XXX probably need to redo this differently for 2.5 if (marker) { - short mval[2], xo, yo; + int mval[2], xo, yo; // getmouseco_areawin(mval); xo= mval[0]; yo= mval[1]; @@ -656,7 +656,7 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEv View2D *v2d= UI_view2d_fromcontext(C); short extend= RNA_boolean_get(op->ptr, "extend"); - short mval[2]; + int mval[2]; Sequence *mouse_seq; int selected, hand; @@ -837,7 +837,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) rcti rect; rctf rectf, rq; short selecting = (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); - short mval[2]; + int mval[2]; if(ed==NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 2601d1ffdf3..625e5561389 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1495,6 +1495,8 @@ static void draw_cursor(SpaceText *st, ARegion *ar) glRecti(x-4, y, ar->winx, y-st->lheight), y-=st->lheight; glRecti(x-4, y, x+toc*st->cwidth, y-st->lheight); y-=st->lheight; + + (void)y; } } else { diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index c0c928dcb24..635e922cd65 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2109,7 +2109,7 @@ static void scroll_apply(bContext *C, wmOperator *op, wmEvent *event) SpaceText *st= CTX_wm_space_text(C); ARegion *ar= CTX_wm_region(C); TextScroll *tsc= op->customdata; - short mval[2]= {event->x, event->y}; + int mval[2]= {event->x, event->y}; short txtdelta[2] = {0, 0}; text_update_character_width(st); @@ -2283,7 +2283,7 @@ static int scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event) SpaceText *st= CTX_wm_space_text(C); ARegion *ar= CTX_wm_region(C); TextScroll *tsc; - const short *mval= event->mval; + const int *mval= event->mval; int zone= -1; if(RNA_property_is_set(op->ptr, "lines")) @@ -2694,7 +2694,7 @@ static int line_number_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *even SpaceText *st= CTX_wm_space_text(C); Text *text= CTX_data_edit_text(C); ARegion *ar= CTX_wm_region(C); - const short *mval= event->mval; + const int *mval= event->mval; double time; static int jump_to= 0; static double last_jump= 0; @@ -2841,8 +2841,14 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) flags ^= ST_FIND_WRAP; do { - if(first) + int proceed= 0; + + if(first) { + if(text->markers.first) + WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + txt_clear_markers(text, TMARK_GRP_FINDALL, 0); + } first= 0; @@ -2850,7 +2856,10 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) if(mode!=TEXT_FIND && txt_has_sel(text)) { tmp= txt_sel_to_buf(text); - if(strcmp(st->findstr, tmp)==0) { + if(flags & ST_MATCH_CASE) proceed= strcmp(st->findstr, tmp)==0; + else proceed= BLI_strcasecmp(st->findstr, tmp)==0; + + if(proceed) { if(mode==TEXT_REPLACE) { txt_insert_buf(text, st->replacestr); if(text->curl && text->curl->format) { @@ -2880,7 +2889,7 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) } /* Find next */ - if(txt_find_string(text, st->findstr, flags & ST_FIND_WRAP)) { + if(txt_find_string(text, st->findstr, flags & ST_FIND_WRAP, flags & ST_MATCH_CASE)) { text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); } @@ -2897,7 +2906,7 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode) first= 1; } else { - if(!found) BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr); + if(!found && !proceed) BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr); break; } found = 1; diff --git a/source/blender/editors/space_text/text_python.c b/source/blender/editors/space_text/text_python.c index bd8710ec120..6e6f131655b 100644 --- a/source/blender/editors/space_text/text_python.c +++ b/source/blender/editors/space_text/text_python.c @@ -54,7 +54,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar) TextLine *tmp; int l, x, y, w, h, i; int tgti, *top; - short mval[2] = {0, 0}; + int mval[2] = {0, 0}; if(!st || !st->text) return 0; if(!texttool_text_is_active(st->text)) return 0; diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt index 9744887ed9f..f923c578769 100644 --- a/source/blender/editors/space_view3d/CMakeLists.txt +++ b/source/blender/editors/space_view3d/CMakeLists.txt @@ -58,7 +58,7 @@ set(SRC ) if(WITH_GAMEENGINE) - list(APPEND INC ../../../kernel/gen_system) + list(APPEND INC ../../../../source/gameengine/BlenderRoutines) add_definitions(-DWITH_GAMEENGINE) endif() diff --git a/source/blender/editors/space_view3d/SConscript b/source/blender/editors/space_view3d/SConscript index 3df59d485d5..84ba8d1fe86 100644 --- a/source/blender/editors/space_view3d/SConscript +++ b/source/blender/editors/space_view3d/SConscript @@ -9,7 +9,7 @@ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../render/extern/include ../../blenloader' incs += ' ../../gpu ../../makesrna ../../blenfont' incs += ' #/intern/smoke/extern' -incs += ' #source/kernel/gen_system' +incs += ' #source/gameengine/BlenderRoutines' if env['WITH_BF_GAMEENGINE']: defs.append('WITH_GAMEENGINE') diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 374384a2a97..5e80b03dd5f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -46,6 +46,7 @@ #include "DNA_scene_types.h" #include "DNA_smoke_types.h" #include "DNA_world_types.h" +#include "DNA_armature_types.h" #include "BLI_blenlib.h" #include "BLI_math.h" @@ -76,6 +77,9 @@ #include "smoke_API.h" +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + #include "BIF_gl.h" #include "BIF_glutil.h" @@ -515,6 +519,96 @@ void drawaxes(float size, char drawtype) } } + +/* Function to draw an Image on a empty Object */ +static void draw_empty_image(Object *ob) +{ + Image *ima = (Image*)ob->data; + ImBuf *ibuf = ima ? BKE_image_get_ibuf(ima, NULL) : NULL; + + float scale, ofs_x, ofs_y, sca_x, sca_y; + int ima_x, ima_y; + + if(ibuf && (ibuf->rect == NULL) && (ibuf->rect_float != NULL)) { + IMB_rect_from_float(ibuf); + } + + /* Get the buffer dimensions so we can fallback to fake ones */ + if(ibuf && ibuf->rect) { + ima_x= ibuf->x; + ima_y= ibuf->y; + } + else { + ima_x= 1; + ima_y= 1; + } + + /* Get the image aspect even if the buffer is invalid */ + if(ima) { + if(ima->aspx > ima->aspy) { + sca_x= 1.0f; + sca_y= ima->aspy / ima->aspx; + } + else if(ima->aspx < ima->aspy) { + sca_x= ima->aspx / ima->aspy; + sca_y= 1.0f; + } + else { + sca_x= 1.0f; + sca_y= 1.0f; + } + } + else { + sca_x= 1.0f; + sca_y= 1.0f; + } + + /* Calculate the scale center based on objects origin */ + ofs_x= ob->ima_ofs[0] * ima_x; + ofs_y= ob->ima_ofs[1] * ima_y; + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + + /* Make sure we are drawing at the origin */ + glTranslatef(0.0f, 0.0f, 0.0f); + + /* Calculate Image scale */ + scale= (ob->empty_drawsize / (float)MAX2(ima_x * sca_x, ima_y * sca_y)); + + /* Set the object scale */ + glScalef(scale * sca_x, scale * sca_y, 1.0f); + + if(ibuf && ibuf->rect) { + /* Setup GL params */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + /* Use the object color and alpha */ + glColor4fv(ob->col); + + /* Draw the Image on the screen */ + glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_UNSIGNED_BYTE, ibuf->rect); + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + + glDisable(GL_BLEND); + } + + UI_ThemeColor((ob->flag & SELECT) ? TH_SELECT : TH_WIRE); + + /* Calculate the outline vertex positions */ + glBegin(GL_LINE_LOOP); + glVertex2f(ofs_x, ofs_y); + glVertex2f(ofs_x + ima_x, ofs_y); + glVertex2f(ofs_x + ima_x, ofs_y + ima_y); + glVertex2f(ofs_x, ofs_y + ima_y); + glEnd(); + + /* Reset GL settings */ + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); +} + void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]) { float vec[3], vx[3], vy[3]; @@ -572,7 +666,7 @@ typedef struct ViewCachedString { unsigned char ub[4]; int pack; } col; - short mval[2]; + short sco[2]; short xoffs; short flag; int str_len, pad; @@ -614,8 +708,8 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa for(vos= strings->first; vos; vos= vos->next) { if(mat && !(vos->flag & V3D_CACHE_TEXT_WORLDSPACE)) mul_m4_v3(mat, vos->vec); - view3d_project_short_clip(ar, vos->vec, vos->mval, 0); - if(vos->mval[0]!=IS_CLIPPED) + view3d_project_short_clip(ar, vos->vec, vos->sco, 0); + if(vos->sco[0]!=IS_CLIPPED) tot++; } @@ -655,7 +749,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa continue; } #endif - if(vos->mval[0]!=IS_CLIPPED) { + if(vos->sco[0]!=IS_CLIPPED) { const char *str= (char *)(vos+1); if(col_pack_prev != vos->col.pack) { @@ -663,10 +757,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa col_pack_prev= vos->col.pack; } if(vos->flag & V3D_CACHE_TEXT_ASCII) { - BLF_draw_default_ascii((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len); + BLF_draw_default_ascii((float)vos->sco[0]+vos->xoffs, (float)vos->sco[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len); } else { - BLF_draw_default((float)vos->mval[0]+vos->xoffs, (float)vos->mval[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len); + BLF_draw_default((float)vos->sco[0]+vos->xoffs, (float)vos->sco[1], (depth_write)? 0.0f: 2.0f, str, vos->str_len); } } } @@ -5956,8 +6050,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) break; } case OB_EMPTY: - if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) - drawaxes(ob->empty_drawsize, ob->empty_drawtype); + if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if (ob->empty_drawtype == OB_EMPTY_IMAGE) { + draw_empty_image(ob); + } + else { + drawaxes(ob->empty_drawsize, ob->empty_drawtype); + } + } break; case OB_LAMP: if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { @@ -6566,7 +6666,12 @@ void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object draw_object_mesh_instance(scene, v3d, rv3d, ob, dt, outline); break; case OB_EMPTY: - drawaxes(ob->empty_drawsize, ob->empty_drawtype); + if (ob->empty_drawtype == OB_EMPTY_IMAGE) { + draw_empty_image(ob); + } + else { + drawaxes(ob->empty_drawsize, ob->empty_drawtype); + } break; } } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 9a88b4b4493..f67ddab21e0 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -565,13 +565,13 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d) { - short mx,my,co[2]; + int mx, my, co[2]; int flag; /* we dont want the clipping for cursor */ flag= v3d->flag; v3d->flag= 0; - project_short(ar, give_cursor(scene, v3d), co); + project_int(ar, give_cursor(scene, v3d), co); v3d->flag= flag; mx = co[0]; @@ -764,7 +764,7 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d) /* draw info beside axes in bottom left-corner: * framenum, object name, bone name (if available), marker name (if available) */ -static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) +static void draw_selected_name(Scene *scene, Object *ob) { char info[256], *markern; short offset=30; @@ -833,7 +833,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) } /* color depends on whether there is a keyframe */ - if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/(float)(CFRA), v3d->keyflags)) + if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/(float)(CFRA), ANIMFILTER_KEYS_LOCAL)) UI_ThemeColor(TH_VERTEX_SELECT); else UI_ThemeColor(TH_TEXT_HI); @@ -922,6 +922,77 @@ void view3d_calc_camera_border(Scene *scene, ARegion *ar, RegionView3D *rv3d, Vi } } +static void drawviewborder_grid3(float x1, float x2, float y1, float y2, float fac) +{ + float x3, y3, x4, y4; + + x3= x1 + fac * (x2-x1); + y3= y1 + fac * (y2-y1); + x4= x1 + (1.0f - fac) * (x2-x1); + y4= y1 + (1.0f - fac) * (y2-y1); + + glBegin(GL_LINES); + glVertex2f(x1, y3); + glVertex2f(x2, y3); + + glVertex2f(x1, y4); + glVertex2f(x2, y4); + + glVertex2f(x3, y1); + glVertex2f(x3, y2); + + glVertex2f(x4, y1); + glVertex2f(x4, y2); + glEnd(); +} + +/* harmonious triangle */ +static void drawviewborder_triangle(float x1, float x2, float y1, float y2, const char golden, const char dir) +{ + float ofs; + float w= x2 - x1; + float h= y2 - y1; + + glBegin(GL_LINES); + if(w > h) { + if(golden) { + ofs = w * (1.0f-(1.0f/1.61803399)); + } + else { + ofs = h * (h / w); + } + if(dir == 'B') SWAP(float, y1, y2); + + glVertex2f(x1, y1); + glVertex2f(x2, y2); + + glVertex2f(x2, y1); + glVertex2f(x1 + (w - ofs), y2); + + glVertex2f(x1, y2); + glVertex2f(x1 + ofs, y1); + } + else { + if(golden) { + ofs = h * (1.0f-(1.0f/1.61803399)); + } + else { + ofs = w * (w / h); + } + if(dir == 'B') SWAP(float, x1, x2); + + glVertex2f(x1, y1); + glVertex2f(x2, y2); + + glVertex2f(x2, y1); + glVertex2f(x1, y1 + ofs); + + glVertex2f(x1, y2); + glVertex2f(x2, y1 + (h - ofs)); + } + glEnd(); +} + static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) { float fac, a; @@ -945,10 +1016,14 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) y2= viewborder.ymax; /* apply offsets so the real 3D camera shows through */ - x1i= (int)(x1 - 1.0f); - y1i= (int)(y1 - 1.0f); - x2i= (int)(x2 + 1.0f); - y2i= (int)(y2 + 1.0f); + + /* note: quite un-scientific but without this bit extra + * 0.0001 on the lower left the 2D border sometimes + * obscures the 3D camera border */ + x1i= (int)(x1 - 1.0001f); + y1i= (int)(y1 - 1.0001f); + x2i= (int)(x2 + (1.0f-0.0001f)); + y2i= (int)(y2 + (1.0f-0.0001f)); /* passepartout, specified in camera edit buttons */ if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) { @@ -996,21 +1071,80 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) } /* safety border */ - if (ca && (ca->flag & CAM_SHOWTITLESAFE)) { - fac= 0.1; - - a= fac*(x2-x1); - x1+= a; - x2-= a; - - a= fac*(y2-y1); - y1+= a; - y2-= a; - - UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - - uiSetRoundBox(15); - uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + if(ca) { + if (ca->dtx & CAM_DTX_CENTER) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + + x3= x1+ 0.5f*(x2-x1); + y3= y1+ 0.5f*(y2-y1); + + glBegin(GL_LINES); + glVertex2f(x1, y3); + glVertex2f(x2, y3); + + glVertex2f(x3, y1); + glVertex2f(x3, y2); + glEnd(); + } + + if (ca->dtx & CAM_DTX_CENTER_DIAG) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + + glBegin(GL_LINES); + glVertex2f(x1, y1); + glVertex2f(x2, y2); + + glVertex2f(x1, y2); + glVertex2f(x2, y1); + glEnd(); + } + + if (ca->dtx & CAM_DTX_THIRDS) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f/3.0f); + } + + if (ca->dtx & CAM_DTX_GOLDEN) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_grid3(x1, x2, y1, y2, 1.0f-(1.0f/1.61803399)); + } + + if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 0, 'A'); + } + + if (ca->dtx & CAM_DTX_GOLDEN_TRI_B) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 0, 'B'); + } + + if (ca->dtx & CAM_DTX_HARMONY_TRI_A) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 1, 'A'); + } + + if (ca->dtx & CAM_DTX_HARMONY_TRI_B) { + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + drawviewborder_triangle(x1, x2, y1, y2, 1, 'B'); + } + + if (ca->flag & CAM_SHOWTITLESAFE) { + fac= 0.1; + + a= fac*(x2-x1); + x1+= a; + x2-= a; + + a= fac*(y2-y1); + y1+= a; + y2-= a; + + UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); + + uiSetRoundBox(15); + uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + } } setlinestyle(0); @@ -1173,7 +1307,7 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, } /* smart function to sample a rect spiralling outside, nice for backbuf selection */ -unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const short mval[2], int size, +unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, void *handle, unsigned int (*indextest)(void *handle, unsigned int index)) { @@ -1318,7 +1452,11 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) float tzoom= MIN2(zoomx, zoomy); int mip= 0; - if(ibuf->mipmap[0]==NULL) + if((ibuf->userflags&IB_MIPMAP_INVALID) != 0) { + IMB_remakemipmap(ibuf, 0); + ibuf->userflags&= ~IB_MIPMAP_INVALID; + } + else if(ibuf->mipmap[0]==NULL) IMB_makemipmap(ibuf, 0); while(tzoom < 1.0f && mip<8 && ibuf->mipmap[mip]) { @@ -2393,7 +2531,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) // needs to be done always, gridview is adjusted in drawgrid() now rv3d->gridview= v3d->grid; - if(rv3d->view==0 || rv3d->persp != RV3D_ORTHO) { + if((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) { if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { drawfloor(scene, v3d, &grid_unit); } @@ -2567,7 +2705,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) ob= OBACT; if(U.uiflag & USER_DRAWVIEWINFO) - draw_selected_name(scene, ob, v3d); + draw_selected_name(scene, ob); /* XXX here was the blockhandlers for floating panels */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 2509ae75744..ee73ed3a0fd 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -40,6 +40,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_camera_types.h" +#include "DNA_lamp_types.h" #include "MEM_guardedalloc.h" @@ -55,6 +56,7 @@ #include "BKE_paint.h" #include "BKE_report.h" #include "BKE_scene.h" +#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */ #include "BIF_gl.h" @@ -79,6 +81,23 @@ /* ********************** view3d_edit: view manipulations ********************* */ +void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) +{ + if(v3d->camera && (v3d->flag2 & V3D_LOCK_CAMERA) && (rv3d->persp==RV3D_CAMOB)) { + ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); + } +} + +void ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) +{ + if(v3d->camera && (v3d->flag2 & V3D_LOCK_CAMERA) && (rv3d->persp==RV3D_CAMOB)) { + ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); + DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); + WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera); + } +} + + /* ********************* box view support ***************** */ static void view3d_boxview_clip(ScrArea *sa) @@ -277,6 +296,7 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, short do_clip) typedef struct ViewOpsData { ScrArea *sa; ARegion *ar; + View3D *v3d; RegionView3D *rv3d; /* needed for continuous zoom */ @@ -331,7 +351,6 @@ static void calctrackballvec(rcti *rect, int mx, int my, float *vec) static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) { static float lastofs[3] = {0,0,0}; - View3D *v3d; RegionView3D *rv3d; ViewOpsData *vod= MEM_callocN(sizeof(ViewOpsData), "viewops data"); @@ -339,8 +358,13 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) op->customdata= vod; vod->sa= CTX_wm_area(C); vod->ar= CTX_wm_region(C); - v3d= vod->sa->spacedata.first; + vod->v3d= vod->sa->spacedata.first; vod->rv3d= rv3d= vod->ar->regiondata; + + /* set the view from the camera, if view locking is enabled. + * we may want to make this optional but for now its needed always */ + ED_view3d_camera_lock_init(vod->v3d, vod->rv3d); + vod->dist0= rv3d->dist; copy_qt_qt(vod->oldquat, rv3d->viewquat); vod->origx= vod->oldx= event->x; @@ -358,8 +382,8 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) view3d_operator_needs_opengl(C); /* needed for zbuf drawing */ - if((vod->use_dyn_ofs=view_autodist(CTX_data_scene(C), vod->ar, v3d, event->mval, vod->dyn_ofs))) { - if (rv3d->persp==RV3D_PERSP) { + if((vod->use_dyn_ofs=view_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs))) { + if (rv3d->persp==RV3D_PERSP || (rv3d->persp==RV3D_CAMOB && (vod->v3d->flag2 & V3D_LOCK_CAMERA))) { float my_origin[3]; /* original G.vd->ofs */ float my_pivot[3]; /* view */ float dvec[3]; @@ -390,17 +414,15 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) } negate_v3(vod->dyn_ofs); copy_v3_v3(vod->ofs, rv3d->ofs); - } else { - vod->ofs[0] = vod->ofs[1] = vod->ofs[2] = 0.0f; } } /* for dolly */ - window_to_3d_vector(vod->ar, vod->mousevec, (vod->oldx - vod->ar->winrct.xmin)-(vod->ar->winx)/2, (vod->oldy - vod->ar->winrct.ymin)-(vod->ar->winy)/2); + window_to_3d_vector(vod->ar, vod->mousevec, vod->oldx - vod->ar->winrct.xmin, vod->oldy - vod->ar->winrct.ymin); /* lookup, we dont pass on v3d to prevent confusement */ - vod->grid= v3d->grid; - vod->far= v3d->far; + vod->grid= vod->v3d->grid; + vod->far= vod->v3d->far; calctrackballvec(&vod->ar->winrct, event->x, event->y, vod->trackvec); @@ -546,7 +568,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) { RegionView3D *rv3d= vod->rv3d; - rv3d->view= 0; /* need to reset everytime because of view snapping */ + rv3d->view= RV3D_VIEW_USER; /* need to reset everytime because of view snapping */ if (U.flag & USER_TRACKBALL) { float phi, si, q1[4], dvec[3], newvec[3]; @@ -711,6 +733,8 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) /* avoid precision loss over time */ normalize_qt(rv3d->viewquat); + ED_view3d_camera_lock_sync(vod->v3d, rv3d); + ED_region_tag_redraw(vod->ar); } @@ -782,18 +806,18 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) if(rv3d->persp != RV3D_PERSP) { if (U.uiflag & USER_AUTOPERSP) { - rv3d->persp= RV3D_PERSP; + if(!((rv3d->persp==RV3D_CAMOB) && (vod->v3d->flag2 & V3D_LOCK_CAMERA))) { + rv3d->persp= RV3D_PERSP; + } } else if(rv3d->persp==RV3D_CAMOB) { /* changed since 2.4x, use the camera view */ - View3D *v3d = vod->sa->spacedata.first; - - if(v3d->camera) { - view3d_apply_ob(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); + if(vod->v3d->camera) { + ED_view3d_from_object(vod->v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); } - if(rv3d->persp==RV3D_CAMOB) { + if(!(vod->v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->persp= rv3d->lpersp; } } @@ -894,7 +918,7 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf) static void viewmove_apply(ViewOpsData *vod, int x, int y) { - if(vod->rv3d->persp==RV3D_CAMOB) { + if((vod->rv3d->persp==RV3D_CAMOB) && !(vod->v3d->flag2 & V3D_LOCK_CAMERA)) { float zoomfac= ((float)M_SQRT2 + (float)vod->rv3d->camzoom / 50.0f); zoomfac= (zoomfac * zoomfac) * 0.5f; @@ -917,6 +941,8 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) vod->oldx= x; vod->oldy= y; + ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d); + ED_region_tag_redraw(vod->ar); } @@ -966,11 +992,13 @@ static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ViewOpsData *vod; + /* makes op->customdata */ viewops_data_create(C, op, event); + vod= op->customdata; if (event->type == MOUSEPAN) { - ViewOpsData *vod= op->customdata; viewmove_apply(vod, event->prevx, event->prevy); request_depth_update(vod->rv3d); @@ -1159,6 +1187,8 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, if(vod->rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_sync(vod->sa, vod->ar); + ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d); + ED_region_tag_redraw(vod->ar); } @@ -1237,7 +1267,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) if(delta < 0) { /* this min and max is also in viewmove() */ - if(rv3d->persp==RV3D_CAMOB) { + if((rv3d->persp==RV3D_CAMOB) && !(v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->camzoom-= 10; if(rv3d->camzoom < RV3D_CAMZOOM_MIN) rv3d->camzoom= RV3D_CAMZOOM_MIN; } @@ -1246,7 +1276,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) } } else { - if(rv3d->persp==RV3D_CAMOB) { + if((rv3d->persp==RV3D_CAMOB) && !(v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->camzoom+= 10; if(rv3d->camzoom > RV3D_CAMZOOM_MAX) rv3d->camzoom= RV3D_CAMZOOM_MAX; } @@ -1259,6 +1289,9 @@ static int viewzoom_exec(bContext *C, wmOperator *op) view3d_boxview_sync(sa, ar); request_depth_update(rv3d); + + ED_view3d_camera_lock_sync(v3d, rv3d); + ED_region_tag_redraw(ar); viewops_data_free(C, op); @@ -1269,6 +1302,12 @@ static int viewzoom_exec(bContext *C, wmOperator *op) /* viewdolly_invoke() copied this function, changes here may apply there */ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) { + ViewOpsData *vod; + + /* makes op->customdata */ + viewops_data_create(C, op, event); + vod= op->customdata; + /* if one or the other zoom position aren't set, set from event */ if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) { @@ -1277,18 +1316,9 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) } if(RNA_property_is_set(op->ptr, "delta")) { - /* makes op->customdata */ - viewops_data_create(C, op, event); viewzoom_exec(C, op); } else { - ViewOpsData *vod; - - /* makes op->customdata */ - viewops_data_create(C, op, event); - - vod= op->customdata; - if (event->type == MOUSEZOOM) { /* Bypass Zoom invert flag for track pads (pass FALSE always) */ @@ -1349,7 +1379,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot) static void view_dolly_mouseloc(ARegion *ar, float orig_ofs[3], float dvec[3], float dfac) { RegionView3D *rv3d= ar->regiondata; - madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, 1.0 - dfac); + madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, -(1.0 - dfac)); } static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_invert) @@ -1379,6 +1409,8 @@ static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_inv if(vod->rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_sync(vod->sa, vod->ar); + ED_view3d_camera_lock_sync(vod->v3d, vod->rv3d); + ED_region_tag_redraw(vod->ar); } @@ -1426,14 +1458,13 @@ static int viewdolly_modal(bContext *C, wmOperator *op, wmEvent *event) static int viewdolly_exec(bContext *C, wmOperator *op) { - View3D *v3d; + /* View3D *v3d; */ RegionView3D *rv3d; ScrArea *sa; ARegion *ar; float mousevec[3]; int delta= RNA_int_get(op->ptr, "delta"); - int mx, my; if(op->customdata) { ViewOpsData *vod= op->customdata; @@ -1445,10 +1476,11 @@ static int viewdolly_exec(bContext *C, wmOperator *op) else { sa= CTX_wm_area(C); ar= CTX_wm_region(C); - normalize_v3_v3(mousevec, ((RegionView3D *)ar->regiondata)->viewinv[2]); + negate_v3_v3(mousevec, ((RegionView3D *)ar->regiondata)->viewinv[2]); + normalize_v3(mousevec); } - v3d= sa->spacedata.first; + /* v3d= sa->spacedata.first; */ /* UNUSED */ rv3d= ar->regiondata; /* overwrite the mouse vector with the view direction (zoom into the center) */ @@ -1456,11 +1488,6 @@ static int viewdolly_exec(bContext *C, wmOperator *op) normalize_v3_v3(mousevec, rv3d->viewinv[2]); } - mx= RNA_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") : ar->winx / 2; - my= RNA_property_is_set(op->ptr, "my") ? RNA_int_get(op->ptr, "my") : ar->winy / 2; - - - if(delta < 0) { view_dolly_mouseloc(ar, rv3d->ofs, mousevec, 1.2f); } @@ -1481,7 +1508,13 @@ static int viewdolly_exec(bContext *C, wmOperator *op) /* copied from viewzoom_invoke(), changes here may apply there */ static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ +{ + ViewOpsData *vod; + + /* makes op->customdata */ + viewops_data_create(C, op, event); + vod= op->customdata; + /* if one or the other zoom position aren't set, set from event */ if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) { @@ -1490,21 +1523,13 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event) } if(RNA_property_is_set(op->ptr, "delta")) { - /* makes op->customdata */ - viewops_data_create(C, op, event); viewdolly_exec(C, op); } else { - ViewOpsData *vod; - - /* makes op->customdata */ - viewops_data_create(C, op, event); - - vod= op->customdata; - /* overwrite the mouse vector with the view direction (zoom into the center) */ if((U.uiflag & USER_ZOOM_TO_MOUSEPOS) == 0) { - normalize_v3_v3(vod->mousevec, vod->rv3d->viewinv[2]); + negate_v3_v3(vod->mousevec, vod->rv3d->viewinv[2]); + normalize_v3(vod->mousevec); } if (event->type == MOUSEZOOM) { @@ -1540,10 +1565,17 @@ static int viewdolly_poll(bContext *C) { RegionView3D *rv3d= CTX_wm_region_view3d(C); - if (rv3d && rv3d->persp == RV3D_PERSP) { - return 1; + if(rv3d) { + if (rv3d->persp == RV3D_PERSP) { + return 1; + } + else { + View3D *v3d= CTX_wm_view3d(C); + if ((rv3d->persp == RV3D_CAMOB) && (v3d->flag2 & V3D_LOCK_CAMERA)) { + return 1; + } + } } - return 0; } @@ -1578,6 +1610,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in Scene *scene= CTX_data_scene(C); Base *base; float *curs; + const short skip_camera= ((rv3d->persp==RV3D_CAMOB) && (v3d->flag2 & V3D_LOCK_CAMERA)); int center= RNA_boolean_get(op->ptr, "center"); @@ -1598,6 +1631,11 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in for(base= scene->base.first; base; base= base->next) { if(BASE_VISIBLE(v3d, base)) { onedone= 1; + + if(skip_camera && base->object == v3d->camera) { + continue; + } + minmax_object(base->object, min, max); } } @@ -1633,7 +1671,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in new_dist*= size; } - if (rv3d->persp==RV3D_CAMOB) { + if ((rv3d->persp==RV3D_CAMOB) && !(v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->persp= RV3D_PERSP; smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } @@ -1677,6 +1715,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca Object *obedit= CTX_data_edit_object(C); float size, min[3], max[3], afm[3]; int ok=0, ok_dist=1; + const short skip_camera= ((rv3d->persp==RV3D_CAMOB) && (v3d->flag2 & V3D_LOCK_CAMERA)); /* SMOOTHVIEW */ float new_ofs[3]; @@ -1730,17 +1769,20 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca ok= PE_minmax(scene, min, max); } else { - Base *base= FIRSTBASE; - while(base) { + Base *base; + for(base= FIRSTBASE; base; base = base->next) { if(TESTBASE(v3d, base)) { + if(skip_camera && base->object == v3d->camera) { + continue; + } + /* account for duplis */ if (minmax_object_duplis(scene, base->object, min, max)==0) minmax_object(base->object, min, max); /* use if duplis not found */ ok= 1; } - base= base->next; } } @@ -1776,7 +1818,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca new_dist*= size; } - if (rv3d->persp==RV3D_CAMOB) { + if (rv3d->persp==RV3D_CAMOB && !(v3d->flag2 & V3D_LOCK_CAMERA)) { rv3d->persp= RV3D_PERSP; smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } @@ -1844,10 +1886,23 @@ void VIEW3D_OT_view_center_cursor(wmOperatorType *ot) static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was view3d_home() in 2.4x */ { + ARegion *ar= CTX_wm_region(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); + Scene *scene= CTX_data_scene(C); + float xfac, yfac; + float size[2]; rv3d->camdx= rv3d->camdy= 0.0f; + view3d_viewborder_size_get(scene, ar, size); + + /* 4px is just a little room from the edge of the area */ + xfac= (float)ar->winx / (float)(size[0] + 4); + yfac= (float)ar->winy / (float)(size[1] + 4); + + rv3d->camzoom= (sqrtf(4.0f * MIN2(xfac, yfac)) - (float)M_SQRT2) * 50.0f; + rv3d->camzoom= CLAMPIS(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; @@ -2059,10 +2114,11 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) static int view3d_zoom_border_invoke(bContext *C, wmOperator *op, wmEvent *event) { + View3D *v3d= CTX_wm_view3d(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); /* if in camera view do not exec the operator so we do not conflict with set render border*/ - if (rv3d->persp != RV3D_CAMOB) + if ((rv3d->persp != RV3D_CAMOB) || (v3d->flag2 & V3D_LOCK_CAMERA)) return WM_border_select_invoke(C, op, event); else return OPERATOR_PASS_THROUGH; @@ -2175,7 +2231,7 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, float q1, float invert_qt(obact_quat); mul_qt_qtqt(new_quat, new_quat, obact_quat); - rv3d->view= view= 0; + rv3d->view= view= RV3D_VIEW_USER; } } @@ -2367,6 +2423,7 @@ static EnumPropertyItem prop_view_orbit_items[] = { static int vieworbit_exec(bContext *C, wmOperator *op) { + View3D *v3d= CTX_wm_view3d(C); ARegion *ar= ED_view3d_context_region_unlock(C); RegionView3D *rv3d= ar->regiondata; /* no NULL check is needed, poll checks */ float phi, q1[4], new_quat[4]; @@ -2375,8 +2432,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) orbitdir = RNA_enum_get(op->ptr, "type"); if(rv3d->viewlock==0) { - - if(rv3d->persp != RV3D_CAMOB) { + if((rv3d->persp != RV3D_CAMOB) || (v3d->flag2 & V3D_LOCK_CAMERA)) { if(orbitdir == V3D_VIEW_STEPLEFT || orbitdir == V3D_VIEW_STEPRIGHT) { float si; /* z-axis */ @@ -2387,7 +2443,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) q1[1]= q1[2]= 0.0; q1[3]= si; mul_qt_qtqt(new_quat, rv3d->viewquat, q1); - rv3d->view= 0; + rv3d->view= RV3D_VIEW_USER; } else if(orbitdir == V3D_VIEW_STEPDOWN || orbitdir == V3D_VIEW_STEPUP) { /* horizontal axis */ @@ -2399,7 +2455,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) q1[0]= (float)cos(phi); mul_v3_fl(q1+1, sin(phi)); mul_qt_qtqt(new_quat, rv3d->viewquat, q1); - rv3d->view= 0; + rv3d->view= RV3D_VIEW_USER; } smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL, NULL, new_quat, NULL, NULL); @@ -2739,7 +2795,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d= CTX_wm_region_view3d(C); float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3]; - short mx, my, mval[2]; + int mx, my, mval[2]; // short ctrl= 0; // XXX int flip; fp= give_cursor(scene, v3d); @@ -2750,7 +2806,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve mx= event->x - ar->winrct.xmin; my= event->y - ar->winrct.ymin; - project_short_noclip(ar, fp, mval); + project_int_noclip(ar, fp, mval); flip= initgrabz(rv3d, fp[0], fp[1], fp[2]); /* reset the depth based on the view offset */ @@ -2758,7 +2814,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve negate_v3_v3(fp, rv3d->ofs); /* re initialize */ - project_short_noclip(ar, fp, mval); + project_int_noclip(ar, fp, mval); flip= initgrabz(rv3d, fp[0], fp[1], fp[2]); } @@ -2766,7 +2822,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve short depth_used = 0; if (U.uiflag & USER_ORBIT_ZBUF) { /* maybe this should be accessed some other way */ - short mval_depth[2]; + int mval_depth[2]; mval_depth[0]= mx; mval_depth[1]= my; view3d_operator_needs_opengl(C); @@ -2897,7 +2953,7 @@ void VIEW3D_OT_enable_manipulator(wmOperatorType *ot) /* ************************* below the line! *********************** */ -static float view_autodist_depth_margin(ARegion *ar, const short mval[2], int margin) +static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int margin) { ViewDepths depth_temp= {0}; rcti rect; @@ -2925,7 +2981,7 @@ static float view_autodist_depth_margin(ARegion *ar, const short mval[2], int ma } /* XXX todo Zooms in on a border drawn by the user */ -int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, const short mval[2], float mouse_worldloc[3] ) //, float *autodist ) +int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3] ) //, float *autodist ) { bglMats mats; /* ZBuffer depth vars */ float depth_close= FLT_MAX; @@ -2968,7 +3024,7 @@ int view_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, flo } // no 4x4 sampling, run view_autodist_init first -int view_autodist_simple(ARegion *ar, const short mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist ) +int view_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist ) { bglMats mats; /* ZBuffer depth vars, could cache? */ float depth; @@ -2996,7 +3052,7 @@ int view_autodist_simple(ARegion *ar, const short mval[2], float mouse_worldloc[ return 1; } -int view_autodist_depth(struct ARegion *ar, const short mval[2], int margin, float *depth) +int view_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth) { *depth= view_autodist_depth_margin(ar, mval, margin); @@ -3006,11 +3062,11 @@ int view_autodist_depth(struct ARegion *ar, const short mval[2], int margin, flo static int depth_segment_cb(int x, int y, void *userData) { struct { struct ARegion *ar; int margin; float depth; } *data = userData; - short mval[2]; + int mval[2]; float depth; - mval[0]= (short)x; - mval[1]= (short)y; + mval[0]= x; + mval[1]= y; depth= view_autodist_depth_margin(data->ar, mval, data->margin); @@ -3023,7 +3079,7 @@ static int depth_segment_cb(int x, int y, void *userData) } } -int view_autodist_depth_segment(struct ARegion *ar, const short mval_sta[2], const short mval_end[2], int margin, float *depth) +int view_autodist_depth_segment(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth) { struct { struct ARegion *ar; int margin; float depth; } data = {NULL}; int p1[2]; @@ -3452,3 +3508,62 @@ void view3d_persp_mat4(RegionView3D *rv3d, float mat[][4]) mul_v3_v3fl(dvec, mat[2], -rv3d->dist); sub_v3_v3v3(mat[3], dvec, rv3d->ofs); } + + +/* Gets the view trasnformation from a camera +* currently dosnt take camzoom into account +* +* The dist is not modified for this function, if NULL its assimed zero +* */ +void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist) +{ + /* Offset */ + if (ofs) + negate_v3_v3(ofs, mat[3]); + + /* Quat */ + if (quat) { + float imat[4][4]; + invert_m4_m4(imat, mat); + mat4_to_quat(quat, imat); + } + + if (dist) { + float nmat[3][3]; + float vec[3]; + + vec[0]= 0.0f; + vec[1]= 0.0f; + vec[2]= -(*dist); + + copy_m3_m4(nmat, mat); + normalize_m3(nmat); + + mul_m3_v3(nmat, vec);; + sub_v3_v3(ofs, vec); + } +} + + +/* object -> view */ +void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, float *lens) +{ + ED_view3d_from_m4(ob->obmat, ofs, quat, dist); + + if (lens) { + get_object_clip_range(ob, lens, NULL, NULL); + } +} + +/* view -> object */ +void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], const float dist) +{ + float mat4[4][4]; + float dvec[3]= {0.0f, 0.0f, dist}; + float iviewquat[4]= {-quat[0], quat[1], quat[2], quat[3]}; + + quat_to_mat4(mat4, iviewquat); + mul_mat3_m4_v3(mat4, dvec); + sub_v3_v3v3(mat4[3], dvec, ofs); + object_apply_mat4(ob, mat4, TRUE, TRUE); +} diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 32deee50fb2..e37361fbc54 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -158,7 +158,7 @@ typedef struct FlyInfo { short state; short use_precision; short redraw; - short mval[2]; + int mval[2]; /* fly state state */ float speed; /* the speed the view is moving per redraw */ diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 63c3c6901c3..fce23df3810 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -272,7 +272,7 @@ void VIEW3D_OT_layers(wmOperatorType *ot) static char *view3d_modeselect_pup(Scene *scene) { Object *ob= OBACT; - static char string[1024]; + static char string[256]; static char formatstr[] = "|%s %%x%d %%i%d"; char *str = string; @@ -465,6 +465,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) Object *obedit = CTX_data_edit_object(C); uiBlock *block; uiLayout *row; + const float dpi_fac= UI_DPI_FAC; RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr); RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr); @@ -484,7 +485,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiBlockBeginAlign(block); uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , - 0,0,126,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode"); + 0,0,126 * dpi_fac,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode"); uiBlockEndAlign(block); /* Draw type */ @@ -521,9 +522,9 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) block= uiLayoutGetBlock(row); if(v3d->twflag & V3D_USE_MANIPULATOR) { - uiDefIconButBitS(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Translate manipulator mode"); - uiDefIconButBitS(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Rotate manipulator mode"); - uiDefIconButBitS(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Scale manipulator mode"); + uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Translate manipulator mode"); + uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Rotate manipulator mode"); + uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,XIC,YIC, &v3d->twtype, 1.0, 0.0, 0, 0, "Scale manipulator mode"); } if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) { @@ -531,7 +532,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } str_menu = BIF_menustringTransformOrientation(C, "Orientation"); - uiDefButS(block, MENU, B_MAN_MODE, str_menu,0,0,70,YIC, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation"); + uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, YIC, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation"); MEM_freeN((void *)str_menu); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f51a780787e..c4999b961f0 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -93,15 +93,15 @@ void view3d_set_viewcontext(bContext *C, ViewContext *vc) vc->obedit= CTX_data_edit_object(C); } -int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const short mval[2], const short do_fallback) +int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int mval[2], const short do_fallback) { float dvec[3]; - short mval_cpy[2]; + int mval_cpy[2]; mval_cpy[0]= mval[0]; mval_cpy[1]= mval[1]; - project_short_noclip(vc->ar, fp, mval_cpy); + project_int_noclip(vc->ar, fp, mval_cpy); initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); @@ -274,12 +274,12 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) #define MOVES_GESTURE 50 #define MOVES_LASSO 500 -int lasso_inside(short mcords[][2], short moves, short sx, short sy) +int lasso_inside(int mcords[][2], short moves, int sx, int sy) { /* we do the angle rule, define that all added angles should be about zero or 2*PI */ float angletot=0.0, len, dot, ang, cross, fp1[2], fp2[2]; int a; - short *p1, *p2; + int *p1, *p2; if(sx==IS_CLIPPED) return 0; @@ -322,9 +322,9 @@ int lasso_inside(short mcords[][2], short moves, short sx, short sy) } /* edge version for lasso select. we assume boundbox check was done */ -int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1) +int lasso_inside_edge(int mcords[][2], short moves, int x0, int y0, int x1, int y1) { - short v1[2], v2[2]; + int v1[2], v2[2]; int a; if(x0==IS_CLIPPED || x1==IS_CLIPPED) @@ -339,9 +339,9 @@ int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, in /* no points in lasso, so we have to intersect with lasso edge */ - if( isect_line_line_v2_short(mcords[0], mcords[moves-1], v1, v2) > 0) return 1; + if( isect_line_line_v2_int(mcords[0], mcords[moves-1], v1, v2) > 0) return 1; for(a=0; a 0) return 1; + if( isect_line_line_v2_int(mcords[a], mcords[a+1], v1, v2) > 0) return 1; } return 0; @@ -351,11 +351,11 @@ int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, in /* warning; lasso select with backbuffer-check draws in backbuf with persp(PERSP_WIN) and returns with persp(PERSP_VIEW). After lasso select backbuf is not OK */ -static void do_lasso_select_pose(ViewContext *vc, Object *ob, short mcords[][2], short moves, short select) +static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], short moves, short select) { bPoseChannel *pchan; float vec[3]; - short sco1[2], sco2[2]; + int sco1[2], sco2[2]; bArmature *arm= ob->data; if(ob->type!=OB_ARMATURE || ob->pose==NULL) return; @@ -363,9 +363,9 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, short mcords[][2], for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) { mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); - project_short(vc->ar, vec, sco1); + project_int(vc->ar, vec, sco1); mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); - project_short(vc->ar, vec, sco2); + project_int(vc->ar, vec, sco2); if(lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { if(select) pchan->bone->flag |= BONE_SELECTED; @@ -386,7 +386,7 @@ static void object_deselect_all_visible(Scene *scene, View3D *v3d) } } -static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { Base *base; @@ -409,7 +409,7 @@ static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short mo } } -static void lasso_select_boundbox(rcti *rect, short mcords[][2], short moves) +static void lasso_select_boundbox(rcti *rect, int mcords[][2], short moves) { short a; @@ -426,7 +426,7 @@ static void lasso_select_boundbox(rcti *rect, short mcords[][2], short moves) static void do_lasso_select_mesh__doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } *data = userData; + struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { eve->f = data->select?(eve->f|1):(eve->f&~1); @@ -434,7 +434,7 @@ static void do_lasso_select_mesh__doSelectVert(void *userData, EditVert *eve, in } static void do_lasso_select_mesh__doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index) { - struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } *data = userData; + struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; if (EM_check_backbuf(em_solidoffs+index)) { if (data->pass==0) { @@ -453,16 +453,16 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, EditEdge *eed, in } static void do_lasso_select_mesh__doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } *data = userData; + struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { EM_select_face_fgon(data->vc.em, efa, data->select); } } -static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } data; + struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } data; ToolSettings *ts= vc->scene->toolsettings; rcti rect; int bbsel; @@ -528,7 +528,7 @@ static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves #if 0 /* this is an exception in that its the only lasso that dosnt use the 3d view (uses space image view) */ -static void do_lasso_select_mesh_uv(short mcords[][2], short moves, short select) +static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) { EditFace *efa; MTFace *tf; @@ -585,7 +585,7 @@ static void do_lasso_select_mesh_uv(short mcords[][2], short moves, short select static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct { ViewContext *vc; short (*mcords)[2]; short moves; short select; } *data = userData; + struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } *data = userData; Object *obedit= data->vc->obedit; Curve *cu= (Curve*)obedit->data; @@ -612,9 +612,9 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP } } -static void do_lasso_select_curve(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_curve(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { ViewContext *vc; short (*mcords)[2]; short moves; short select; } data; + struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } data; /* set vc->editnurb */ data.vc = vc; @@ -631,15 +631,15 @@ static void do_lasso_select_curve(ViewContext *vc, short mcords[][2], short move static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, int y) { - struct { short (*mcords)[2]; short moves; short select; } *data = userData; + struct { int (*mcords)[2]; short moves; short select; } *data = userData; if (lasso_inside(data->mcords, data->moves, x, y)) { bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); } } -static void do_lasso_select_lattice(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_lattice(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { short (*mcords)[2]; short moves; short select; } data; + struct { int (*mcords)[2]; short moves; short select; } data; /* set editdata in vc */ data.mcords = mcords; @@ -653,7 +653,7 @@ static void do_lasso_select_lattice(ViewContext *vc, short mcords[][2], short mo lattice_foreachScreenVert(vc, do_lasso_select_lattice__doSelect, &data); } -static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { bArmature *arm= vc->obedit->data; EditBone *ebone; @@ -705,7 +705,7 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m -static void do_lasso_select_meta(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { MetaBall *mb = (MetaBall*)vc->obedit->data; MetaElem *ml; @@ -730,7 +730,7 @@ static void do_lasso_select_meta(ViewContext *vc, short mcords[][2], short moves } } -static void do_lasso_select_paintface(ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void do_lasso_select_paintface(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { Object *ob= vc->obact; Mesh *me= ob?ob->data:NULL; @@ -755,7 +755,7 @@ static void do_lasso_select_paintface(ViewContext *vc, short mcords[][2], short } #if 0 -static void do_lasso_select_node(short mcords[][2], short moves, short select) +static void do_lasso_select_node(int mcords[][2], short moves, short select) { SpaceNode *snode = sa->spacedata.first; @@ -785,7 +785,7 @@ static void do_lasso_select_node(short mcords[][2], short moves, short select) } #endif -static void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short moves, short extend, short select) +static void view3d_lasso_select(bContext *C, ViewContext *vc, int mcords[][2], short moves, short extend, short select) { Object *ob = CTX_data_active_object(C); @@ -834,14 +834,14 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op) { ViewContext vc; int i= 0; - short mcords[1024][2]; + int mcords[1024][2]; RNA_BEGIN(op->ptr, itemptr, "path") { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); - mcords[i][0]= (short)loc[0]; - mcords[i][1]= (short)loc[1]; + mcords[i][0]= (int)loc[0]; + mcords[i][1]= (int)loc[1]; i++; if(i>=1024) break; } @@ -953,7 +953,7 @@ static void deselectall_except(Scene *scene, Base *b) /* deselect all except b } } -static Base *mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffer, int hits, const short mval[2], short extend) +static Base *mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffer, int hits, const int mval[2], short extend) { short baseCount = 0; short ok; @@ -1039,7 +1039,7 @@ static Base *mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffe /* we want a select buffer with bones, if there are... */ /* so check three selection levels and compare */ -static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buffer, const short mval[2]) +static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buffer, const int mval[2]) { rcti rect; int offs; @@ -1096,12 +1096,12 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff } /* returns basact */ -static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, const short mval[2], Base *startbase, int has_bones) +static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, const int mval[2], Base *startbase, int has_bones) { Scene *scene= vc->scene; View3D *v3d= vc->v3d; Base *base, *basact= NULL; - static short lastmval[2]={-100, -100}; + static int lastmval[2]={-100, -100}; int a, donearest= 0; /* define if we use solid nearest select or not */ @@ -1189,7 +1189,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int } /* mval comes from event->mval, only use within region handlers */ -Base *ED_view3d_give_base_under_cursor(bContext *C, const short mval[2]) +Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2]) { ViewContext vc; Base *basact= NULL; @@ -1214,7 +1214,7 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const short mval[2]) } /* mval is region coords */ -static int mouse_select(bContext *C, const short mval[2], short extend, short obcenter, short enumerate) +static int mouse_select(bContext *C, const int mval[2], short extend, short obcenter, short enumerate) { ViewContext vc; ARegion *ar= CTX_wm_region(C); @@ -1905,7 +1905,7 @@ void VIEW3D_OT_select(wmOperatorType *ot) static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index)) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -1915,7 +1915,7 @@ static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y } static void mesh_circle_doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int UNUSED(index)) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; if (edge_inside_circle(data->mval[0], data->mval[1], (short) data->radius, x0, y0, x1, y1)) { EM_select_edge(eed, data->select); @@ -1923,7 +1923,7 @@ static void mesh_circle_doSelectEdge(void *userData, EditEdge *eed, int x0, int } static void mesh_circle_doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index)) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -1932,11 +1932,11 @@ static void mesh_circle_doSelectFace(void *userData, EditFace *efa, int x, int y } } -static void mesh_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { ToolSettings *ts= vc->scene->toolsettings; int bbsel; - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + struct {ViewContext *vc; short select; int mval[2]; float radius; } data; 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 */ @@ -1977,7 +1977,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const short mval[2], EM_selectmode_flush(vc->em); } -static void paint_facesel_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void paint_facesel_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { Object *ob= vc->obact; Mesh *me = ob?ob->data:NULL; @@ -1995,7 +1995,7 @@ static void paint_facesel_circle_select(ViewContext *vc, int select, const short static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); Object *obedit= data->vc->obedit; @@ -2024,9 +2024,9 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint } } } -static void nurbscurve_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + struct {ViewContext *vc; short select; int mval[2]; float radius; } data; /* set vc-> edit data */ @@ -2043,7 +2043,7 @@ static void nurbscurve_circle_select(ViewContext *vc, int select, const short mv static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int y) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2051,9 +2051,9 @@ static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); } } -static void lattice_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void lattice_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + struct {ViewContext *vc; short select; int mval[2]; float radius; } data; /* set vc-> edit data */ @@ -2070,7 +2070,7 @@ static void lattice_circle_select(ViewContext *vc, int select, const short mval[ // NOTE: pose-bone case is copied from editbone case... static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int x, int y) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2083,9 +2083,9 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int } return 0; } -static void pose_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void pose_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + struct {ViewContext *vc; short select; int mval[2]; float radius; } data; bPose *pose = vc->obact->pose; bPoseChannel *pchan; int change= FALSE; @@ -2130,7 +2130,7 @@ static void pose_circle_select(ViewContext *vc, int select, const short mval[2], static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int x, int y, short head) { - struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; + struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2151,7 +2151,7 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int } return 0; } -static void armature_circle_select(ViewContext *vc, int select, const short mval[2], float rad) +static void armature_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { struct {ViewContext *vc; short select, mval[2]; float radius; } data; bArmature *arm= vc->obedit->data; @@ -2210,7 +2210,7 @@ static void armature_circle_select(ViewContext *vc, int select, const short mval /** Callbacks for circle selection in Editmode */ -static void obedit_circle_select(ViewContext *vc, short select, const short mval[2], float rad) +static void obedit_circle_select(ViewContext *vc, short select, const int mval[2], float rad) { switch(vc->obedit->type) { case OB_MESH: @@ -2251,7 +2251,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT|OB_MODE_POSE))) ) { ViewContext vc; - short mval[2]; + int mval[2]; view3d_operator_needs_opengl(C); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index a3d42aa5579..b4d2fc22143 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -70,6 +70,7 @@ #include "view3d_intern.h" +extern float originmat[3][3]; /* XXX object.c */ /* ************************************************** */ /* ********************* old transform stuff ******** */ @@ -451,7 +452,6 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode) static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) { - extern float originmat[3][3]; /* XXX object.c */ Main *bmain= CTX_data_main(C); Object *obedit= CTX_data_edit_object(C); Scene *scene= CTX_data_scene(C); @@ -588,7 +588,6 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) { - extern float originmat[3][3]; /* XXX object.c */ Main *bmain= CTX_data_main(C); Object *obedit= CTX_data_edit_object(C); Scene *scene= CTX_data_scene(C); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 8a975eec40f..2f8d90dd49b 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -32,9 +32,9 @@ #include "DNA_camera_types.h" -#include "DNA_lamp_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "DNA_lamp_types.h" #include "MEM_guardedalloc.h" @@ -65,7 +65,7 @@ #include "ED_armature.h" #ifdef WITH_GAMEENGINE -#include "SYS_System.h" +#include "BL_System.h" #endif #include "view3d_intern.h" // own include @@ -105,7 +105,7 @@ float *give_cursor(Scene *scene, View3D *v3d) /* Gets the lens and clipping values from a camera of lamp type object */ -static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, float *clipend) +void get_object_clip_range(Object *ob, float *lens, float *clipsta, float *clipend) { if(ob->type==OB_LAMP ) { Lamp *la = ob->data; @@ -129,51 +129,6 @@ static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, f } } - -/* Gets the view trasnformation from a camera -* currently dosnt take camzoom into account -* -* The dist is not modified for this function, if NULL its assimed zero -* */ -void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist) -{ - /* Offset */ - if (ofs) - negate_v3_v3(ofs, mat[3]); - - /* Quat */ - if (quat) { - float imat[4][4]; - invert_m4_m4(imat, mat); - mat4_to_quat(quat, imat); - } - - if (dist) { - float nmat[3][3]; - float vec[3]; - - vec[0]= 0.0f; - vec[1]= 0.0f; - vec[2]= -(*dist); - - copy_m3_m4(nmat, mat); - normalize_m3(nmat); - - mul_m3_v3(nmat, vec);; - sub_v3_v3(ofs, vec); - } -} - -void view3d_apply_ob(Object *ob, float *ofs, float *quat, float *dist, float *lens) -{ - view3d_apply_mat4(ob->obmat, ofs, quat, dist); - - if (lens) { - object_lens_clip_settings(ob, lens, NULL, NULL); - } -} - - /* ****************** smooth view operator ****************** */ /* This operator is one of the 'timer refresh' ones like animation playback */ @@ -206,7 +161,19 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec sms.new_dist= rv3d->dist; sms.new_lens= v3d->lens; sms.to_camera= 0; - + + /* note on camera locking, this is a little confusing but works ok. + * we may be changing the view 'as if' there is no active camera, but infact + * there is an active camera which is locked to the view. + * + * In the case where smooth view is moving _to_ a camera we dont want that + * camera to be moved or changed, so only when the camera is not being set should + * we allow camera option locking to initialize the view settings from the camera. + */ + if(camera == NULL && oldcamera == NULL) { + ED_view3d_camera_lock_init(v3d, rv3d); + } + /* store the options we want to end with */ if(ofs) copy_v3_v3(sms.new_ofs, ofs); if(quat) copy_qt_qt(sms.new_quat, quat); @@ -214,7 +181,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec if(lens) sms.new_lens= *lens; if (camera) { - view3d_apply_ob(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); + ED_view3d_from_object(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); sms.to_camera= 1; /* restore view3d values in end */ } @@ -239,7 +206,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec /* original values */ if (oldcamera) { sms.orig_dist= rv3d->dist; // below function does weird stuff with it... - view3d_apply_ob(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); + ED_view3d_from_object(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); } else { copy_v3_v3(sms.orig_ofs, rv3d->ofs); @@ -251,7 +218,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec if((rv3d->viewlock & RV3D_LOCKED)==0) { /* use existing if exists, means multiple calls to smooth view wont loose the original 'view' setting */ sms.orig_view= rv3d->sms ? rv3d->sms->orig_view : rv3d->view; - rv3d->view= 0; + rv3d->view= RV3D_VIEW_USER; } sms.time_allowed= (double)U.smooth_viewtx / 1000.0; @@ -341,6 +308,8 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent copy_qt_qt(rv3d->viewquat, sms->new_quat); rv3d->dist = sms->new_dist; v3d->lens = sms->new_lens; + + ED_view3d_camera_lock_sync(v3d, rv3d); } if((rv3d->viewlock & RV3D_LOCKED)==0) { @@ -370,6 +339,8 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent rv3d->dist = sms->new_dist * step + sms->orig_dist*step_inv; v3d->lens = sms->new_lens * step + sms->orig_lens*step_inv; + + ED_view3d_camera_lock_sync(v3d, rv3d); } if(rv3d->viewlock & RV3D_BOXVIEW) @@ -396,25 +367,6 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot) /* ****************** change view operators ****************** */ -static void setcameratoview3d(RegionView3D *rv3d, Object *ob) -{ - float dvec[3]; - float mat3[3][3]; - - mul_v3_v3fl(dvec, rv3d->viewinv[2], rv3d->dist); - sub_v3_v3v3(ob->loc, dvec, rv3d->ofs); - rv3d->viewquat[0]= -rv3d->viewquat[0]; - - // quat_to_eul( ob->rot,rv3d->viewquat); // in 2.4x for xyz eulers only - quat_to_mat3(mat3, rv3d->viewquat); - object_mat3_to_rot(ob, mat3, 0); - - rv3d->viewquat[0]= -rv3d->viewquat[0]; - - ob->recalc= OB_RECALC_OB; -} - - static int view3d_setcameratoview_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); @@ -426,7 +378,7 @@ static int view3d_setcameratoview_exec(bContext *C, wmOperator *UNUSED(op)) rv3d->lpersp= rv3d->persp; } - setcameratoview3d(rv3d, v3d->camera); + ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); rv3d->persp = RV3D_CAMOB; @@ -647,7 +599,7 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z) } /* always call initgrabz */ -void window_to_3d(ARegion *ar, float out[3], short mx, short my) +void window_to_3d(ARegion *ar, float out[3], const int mx, const int my) { RegionView3D *rv3d= ar->regiondata; @@ -665,7 +617,7 @@ void window_to_3d(ARegion *ar, float out[3], short mx, short my) /* always call initgrabz */ /* only to detect delta motion */ -void window_to_3d_delta(ARegion *ar, float out[3], short mx, short my) +void window_to_3d_delta(ARegion *ar, float out[3], const int mx, const int my) { RegionView3D *rv3d= ar->regiondata; float dx, dy; @@ -681,21 +633,21 @@ void window_to_3d_delta(ARegion *ar, float out[3], short mx, short my) /* doesn't rely on initgrabz */ /* for perspective view, get the vector direction to * the mouse cursor as a normalized vector */ -void window_to_3d_vector(ARegion *ar, float out[3], short mx, short my) +void window_to_3d_vector(ARegion *ar, float out[3], const int mx, const int my) { RegionView3D *rv3d= ar->regiondata; float dx, dy; float viewvec[3]; - dx= 2.0f*mx/ar->winx; - dy= 2.0f*my/ar->winy; + dx= (2.0f * mx / ar->winx) - 1.0f; + dy= (2.0f * my / ar->winy) - 1.0f; /* normalize here so vecs are proportional to eachother */ normalize_v3_v3(viewvec, rv3d->viewinv[2]); - out[0]= viewvec[0] - (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy); - out[1]= viewvec[1] - (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy); - out[2]= viewvec[2] - (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy); + out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy) - viewvec[0]; + out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy) - viewvec[1]; + out[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy) - viewvec[2]; normalize_v3(out); } @@ -1164,7 +1116,7 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short float bmat[4][4]; float tmat[3][3]; - rv3d->view= 0; /* dont show the grid */ + rv3d->view= RV3D_VIEW_USER; /* dont show the grid */ copy_m4_m4(bmat, ob->obmat); normalize_m4(bmat); @@ -1188,7 +1140,7 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->persp=RV3D_PERSP; rv3d->dist= 0.0; - view3d_apply_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); + ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX rv3d->persp=RV3D_CAMOB; /* just to be polite, not needed */ @@ -1764,9 +1716,6 @@ static void game_set_commmandline_options(GameData *gm) } } -/* maybe we need this defined somewhere else */ -extern void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *cam_frame, int always_use_expand_framing); - #endif // WITH_GAMEENGINE static int game_engine_poll(bContext *C) @@ -1920,7 +1869,7 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f cross_v3_v3v3(axis, alignaxis, norm); axis_angle_to_quat( new_quat,axis, -angle); - rv3d->view= 0; + rv3d->view= RV3D_VIEW_USER; if (rv3d->persp==RV3D_CAMOB && v3d->camera) { /* switch out of camera view */ @@ -1931,7 +1880,7 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f copy_v3_v3(orig_ofs, rv3d->ofs); rv3d->persp= RV3D_PERSP; rv3d->dist= 0.0; - view3d_apply_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); + ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX } else { if (rv3d->persp==RV3D_CAMOB) rv3d->persp= RV3D_PERSP; /* switch out of camera mode */ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 614b048e0b8..4ea1e8742f5 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -120,7 +120,7 @@ void setTransformViewMatrices(TransInfo *t) calculateCenter2D(t); } -void convertViewVec(TransInfo *t, float *vec, short dx, short dy) +void convertViewVec(TransInfo *t, float *vec, int dx, int dy) { if (t->spacetype==SPACE_VIEW3D) { if (t->ar->regiontype == RGN_TYPE_WINDOW) @@ -783,7 +783,7 @@ int transformEvent(TransInfo *t, wmEvent *event) case SPACEKEY: if ((t->spacetype==SPACE_VIEW3D) && event->alt) { #if 0 // TRANSFORM_FIX_ME - short mval[2]; + int mval[2]; getmouseco_sc(mval); BIF_selectOrientation(); @@ -1270,7 +1270,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) setlinestyle(3); glBegin(GL_LINE_STRIP); - glVertex2sv(t->mval); + glVertex2iv(t->mval); glVertex2fv(cent); glEnd(); @@ -1315,7 +1315,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) setlinestyle(3); glBegin(GL_LINE_STRIP); - glVertex2sv(t->mval); + glVertex2iv(t->mval); glVertex2fv(cent); glEnd(); @@ -2286,7 +2286,7 @@ int handleEventWarp(TransInfo *t, wmEvent *event) return status; } -int Warp(TransInfo *t, const short UNUSED(mval[2])) +int Warp(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3], gcursor[3]; @@ -2434,7 +2434,7 @@ int handleEventShear(TransInfo *t, wmEvent *event) } -int Shear(TransInfo *t, const short UNUSED(mval[2])) +int Shear(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float vec[3]; @@ -2700,7 +2700,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { constraintTransLim(t, td); } -int Resize(TransInfo *t, const short mval[2]) +int Resize(TransInfo *t, const int mval[2]) { TransData *td; float size[3], mat[3][3]; @@ -2805,7 +2805,7 @@ void initToSphere(TransInfo *t) t->val /= (float)t->total; } -int ToSphere(TransInfo *t, const short UNUSED(mval[2])) +int ToSphere(TransInfo *t, const int UNUSED(mval[2])) { float vec[3]; float ratio, radius; @@ -3152,7 +3152,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) } } -int Rotation(TransInfo *t, const short UNUSED(mval[2])) +int Rotation(TransInfo *t, const int UNUSED(mval[2])) { char str[128], *spos= str; @@ -3260,7 +3260,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a } } -int Trackball(TransInfo *t, const short UNUSED(mval[2])) +int Trackball(TransInfo *t, const int UNUSED(mval[2])) { char str[128], *spos= str; float axis1[3], axis2[3]; @@ -3490,7 +3490,7 @@ static void applyTranslation(TransInfo *t, float vec[3]) { } /* uses t->vec to store actual translation in */ -int Translation(TransInfo *t, const short UNUSED(mval[2])) +int Translation(TransInfo *t, const int UNUSED(mval[2])) { char str[250]; @@ -3557,7 +3557,7 @@ void initShrinkFatten(TransInfo *t) -int ShrinkFatten(TransInfo *t, const short UNUSED(mval[2])) +int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { float vec[3]; float distance; @@ -3632,7 +3632,7 @@ void initTilt(TransInfo *t) -int Tilt(TransInfo *t, const short UNUSED(mval[2])) +int Tilt(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; int i; @@ -3704,7 +3704,7 @@ void initCurveShrinkFatten(TransInfo *t) t->flag |= T_NO_CONSTRAINT; } -int CurveShrinkFatten(TransInfo *t, const short UNUSED(mval[2])) +int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float ratio; @@ -3772,7 +3772,7 @@ void initPushPull(TransInfo *t) } -int PushPull(TransInfo *t, const short UNUSED(mval[2])) +int PushPull(TransInfo *t, const int UNUSED(mval[2])) { float vec[3], axis[3]; float distance; @@ -3905,7 +3905,7 @@ int handleEventBevel(TransInfo *t, wmEvent *event) return 0; } -int Bevel(TransInfo *t, const short UNUSED(mval[2])) +int Bevel(TransInfo *t, const int UNUSED(mval[2])) { float distance,d; int i; @@ -3973,7 +3973,7 @@ void initBevelWeight(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int BevelWeight(TransInfo *t, const short UNUSED(mval[2])) +int BevelWeight(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float weight; @@ -4046,7 +4046,7 @@ void initCrease(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int Crease(TransInfo *t, const short UNUSED(mval[2])) +int Crease(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float crease; @@ -4165,7 +4165,7 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3]) td->loc[1]= oldy; } -int BoneSize(TransInfo *t, const short mval[2]) +int BoneSize(TransInfo *t, const int mval[2]) { TransData *td = t->data; float size[3], mat[3][3]; @@ -4241,7 +4241,7 @@ void initBoneEnvelope(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int BoneEnvelope(TransInfo *t, const short UNUSED(mval[2])) +int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float ratio; @@ -4672,10 +4672,10 @@ static int createSlideVerts(TransInfo *t) #undef EDGE_SLIDE_MIN - sld->start[0] = (short) start[0]; - sld->start[1] = (short) start[1]; - sld->end[0] = (short) end[0]; - sld->end[1] = (short) end[1]; + sld->start[0] = (int) start[0]; + sld->start[1] = (int) start[1]; + sld->end[0] = (int) end[0]; + sld->end[1] = (int) end[1]; if (uvlay_tot) { // XXX && (scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)) { int maxnum = 0; @@ -4975,7 +4975,7 @@ int doEdgeSlide(TransInfo *t, float perc) return 1; } -int EdgeSlide(TransInfo *t, const short UNUSED(mval[2])) +int EdgeSlide(TransInfo *t, const int UNUSED(mval[2])) { char str[50]; float final; @@ -5034,7 +5034,7 @@ void initBoneRoll(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int BoneRoll(TransInfo *t, const short UNUSED(mval[2])) +int BoneRoll(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; int i; @@ -5095,7 +5095,7 @@ void initBakeTime(TransInfo *t) t->num.increment = t->snap[1]; } -int BakeTime(TransInfo *t, const short mval[2]) +int BakeTime(TransInfo *t, const int mval[2]) { TransData *td = t->data; float time; @@ -5170,7 +5170,7 @@ void initMirror(TransInfo *t) } } -int Mirror(TransInfo *t, const short UNUSED(mval[2])) +int Mirror(TransInfo *t, const int UNUSED(mval[2])) { TransData *td; float size[3], mat[3][3]; @@ -5247,7 +5247,7 @@ void initAlign(TransInfo *t) initMouseInputMode(t, &t->mouse, INPUT_NONE); } -int Align(TransInfo *t, const short UNUSED(mval[2])) +int Align(TransInfo *t, const int UNUSED(mval[2])) { TransData *td = t->data; float center[3]; @@ -5350,7 +5350,7 @@ static void applySeqSlide(TransInfo *t, float val[2]) { } } -int SeqSlide(TransInfo *t, const short UNUSED(mval[2])) +int SeqSlide(TransInfo *t, const int UNUSED(mval[2])) { char str[200]; @@ -5640,7 +5640,7 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval)) } } -int TimeTranslate(TransInfo *t, const short mval[2]) +int TimeTranslate(TransInfo *t, const int mval[2]) { View2D *v2d = (View2D *)t->view; float cval[2], sval[2]; @@ -5770,7 +5770,7 @@ static void applyTimeSlide(TransInfo *t, float sval) } } -int TimeSlide(TransInfo *t, const short mval[2]) +int TimeSlide(TransInfo *t, const int mval[2]) { View2D *v2d = (View2D *)t->view; float cval[2], sval[2]; @@ -5895,7 +5895,7 @@ static void applyTimeScale(TransInfo *t) { } } -int TimeScale(TransInfo *t, const short UNUSED(mval[2])) +int TimeScale(TransInfo *t, const int UNUSED(mval[2])) { char str[200]; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b94f2cc525a..b55435fd0cf 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -119,7 +119,7 @@ typedef struct TransCon { float pmtx[3][3]; /* Projection Constraint Matrix (same as imtx with some axis == 0) */ float center[3]; /* transformation center to define where to draw the view widget ALWAYS in global space. Unlike the transformation center */ - short imval[2]; /* initial mouse value for visual calculation */ + int imval[2]; /* initial mouse value for visual calculation */ /* the one in TransInfo is not garanty to stay the same (Rotates change it) */ int mode; /* Mode flags of the Constraint */ void (*drawExtra)(struct TransInfo *); @@ -217,7 +217,7 @@ typedef struct SlideData { struct GHash *vhash, **uvhash; struct EditVert *nearest; struct LinkNode *edgelist, *vertlist; - short start[2], end[2]; + int start[2], end[2]; } SlideData; typedef struct TransData { @@ -242,12 +242,12 @@ typedef struct TransData { } TransData; typedef struct MouseInput { - void (*apply)(struct TransInfo *, struct MouseInput *, const short [2], float [3]); + void (*apply)(struct TransInfo *, struct MouseInput *, const int [2], float [3]); void (*post)(struct TransInfo *, float [3]); - short imval[2]; /* initial mouse position */ + int imval[2]; /* initial mouse position */ char precision; - short precision_mval[2]; /* mouse position when precision key was pressed */ + int precision_mval[2]; /* mouse position when precision key was pressed */ int center[2]; float factor; void *data; /* additional data, if needed by the particular function */ @@ -261,7 +261,7 @@ typedef struct TransInfo { int options; /* current context/options for transform */ float val; /* init value for some transformations (and rotation angle) */ float fac; /* factor for distance based transform */ - int (*transform)(struct TransInfo *, const short *); + int (*transform)(struct TransInfo *, const int *); /* transform function pointer */ int (*handleEvent)(struct TransInfo *, struct wmEvent *); /* event handler function pointer RETURN 1 if redraw is needed */ @@ -279,7 +279,7 @@ typedef struct TransInfo { char proptext[20]; /* proportional falloff text */ float center[3]; /* center of transformation */ int center2d[2]; /* center in screen coordinates */ - short imval[2]; /* initial mouse position */ + int imval[2]; /* initial mouse position */ short event_type; /* event->type used to invoke transform */ short idx_max; /* maximum index on the input vector */ float snap[3]; /* Snapping Gears */ @@ -328,7 +328,7 @@ typedef struct TransInfo { struct Scene *scene; struct ToolSettings *settings; struct wmTimer *animtimer; - short mval[2]; /* current mouse position */ + int mval[2]; /* current mouse position */ struct Object *obedit; void *draw_handle_apply; void *draw_handle_view; @@ -458,7 +458,7 @@ void transformApply(struct bContext *C, TransInfo *t); int transformEnd(struct bContext *C, TransInfo *t); void setTransformViewMatrices(TransInfo *t); -void convertViewVec(TransInfo *t, float *vec, short dx, short dy); +void convertViewVec(TransInfo *t, float *vec, int dx, int dy); void projectIntView(TransInfo *t, float *vec, int *adr); void projectFloatView(TransInfo *t, float *vec, float *adr); @@ -467,81 +467,81 @@ void removeAspectRatio(TransInfo *t, float *vec); void initWarp(TransInfo *t); int handleEventWarp(TransInfo *t, struct wmEvent *event); -int Warp(TransInfo *t, const short mval[2]); +int Warp(TransInfo *t, const int mval[2]); void initShear(TransInfo *t); int handleEventShear(TransInfo *t, struct wmEvent *event); -int Shear(TransInfo *t, const short mval[2]); +int Shear(TransInfo *t, const int mval[2]); void initResize(TransInfo *t); -int Resize(TransInfo *t, const short mval[2]); +int Resize(TransInfo *t, const int mval[2]); void initTranslation(TransInfo *t); -int Translation(TransInfo *t, const short mval[2]); +int Translation(TransInfo *t, const int mval[2]); void initToSphere(TransInfo *t); -int ToSphere(TransInfo *t, const short mval[2]); +int ToSphere(TransInfo *t, const int mval[2]); void initRotation(TransInfo *t); -int Rotation(TransInfo *t, const short mval[2]); +int Rotation(TransInfo *t, const int mval[2]); void initShrinkFatten(TransInfo *t); -int ShrinkFatten(TransInfo *t, const short mval[2]); +int ShrinkFatten(TransInfo *t, const int mval[2]); void initTilt(TransInfo *t); -int Tilt(TransInfo *t, const short mval[2]); +int Tilt(TransInfo *t, const int mval[2]); void initCurveShrinkFatten(TransInfo *t); -int CurveShrinkFatten(TransInfo *t, const short mval[2]); +int CurveShrinkFatten(TransInfo *t, const int mval[2]); void initTrackball(TransInfo *t); -int Trackball(TransInfo *t, const short mval[2]); +int Trackball(TransInfo *t, const int mval[2]); void initPushPull(TransInfo *t); -int PushPull(TransInfo *t, const short mval[2]); +int PushPull(TransInfo *t, const int mval[2]); void initBevel(TransInfo *t); int handleEventBevel(TransInfo *t, struct wmEvent *event); -int Bevel(TransInfo *t, const short mval[2]); +int Bevel(TransInfo *t, const int mval[2]); void initBevelWeight(TransInfo *t); -int BevelWeight(TransInfo *t, const short mval[2]); +int BevelWeight(TransInfo *t, const int mval[2]); void initCrease(TransInfo *t); -int Crease(TransInfo *t, const short mval[2]); +int Crease(TransInfo *t, const int mval[2]); void initBoneSize(TransInfo *t); -int BoneSize(TransInfo *t, const short mval[2]); +int BoneSize(TransInfo *t, const int mval[2]); void initBoneEnvelope(TransInfo *t); -int BoneEnvelope(TransInfo *t, const short mval[2]); +int BoneEnvelope(TransInfo *t, const int mval[2]); void initBoneRoll(TransInfo *t); -int BoneRoll(TransInfo *t, const short mval[2]); +int BoneRoll(TransInfo *t, const int mval[2]); void initEdgeSlide(TransInfo *t); -int EdgeSlide(TransInfo *t, const short mval[2]); +int EdgeSlide(TransInfo *t, const int mval[2]); void initTimeTranslate(TransInfo *t); -int TimeTranslate(TransInfo *t, const short mval[2]); +int TimeTranslate(TransInfo *t, const int mval[2]); void initTimeSlide(TransInfo *t); -int TimeSlide(TransInfo *t, const short mval[2]); +int TimeSlide(TransInfo *t, const int mval[2]); void initTimeScale(TransInfo *t); -int TimeScale(TransInfo *t, const short mval[2]); +int TimeScale(TransInfo *t, const int mval[2]); void initBakeTime(TransInfo *t); -int BakeTime(TransInfo *t, const short mval[2]); +int BakeTime(TransInfo *t, const int mval[2]); void initMirror(TransInfo *t); -int Mirror(TransInfo *t, const short mval[2]); +int Mirror(TransInfo *t, const int mval[2]); void initAlign(TransInfo *t); -int Align(TransInfo *t, const short mval[2]); +int Align(TransInfo *t, const int mval[2]); void initSeqSlide(TransInfo *t); -int SeqSlide(TransInfo *t, const short mval[2]); +int SeqSlide(TransInfo *t, const int mval[2]); void drawPropCircle(const struct bContext *C, TransInfo *t); @@ -645,12 +645,12 @@ typedef enum { INPUT_CUSTOM_RATIO } MouseInputMode; -void initMouseInput(TransInfo *t, MouseInput *mi, int center[2], short mval[2]); +void initMouseInput(TransInfo *t, MouseInput *mi, int center[2], int mval[2]); void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode); int handleMouseInput(struct TransInfo *t, struct MouseInput *mi, struct wmEvent *event); -void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, short mval[2], float output[3]); +void applyMouseInput(struct TransInfo *t, struct MouseInput *mi, int mval[2], float output[3]); -void setCustomPoints(TransInfo *t, MouseInput *mi, short start[2], short end[2]); +void setCustomPoints(TransInfo *t, MouseInput *mi, int start[2], int end[2]); void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3])); /*********************** Generics ********************************/ diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 16a943baabe..0ca0812f050 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -665,7 +665,7 @@ void drawConstraint(TransInfo *t) char col2[3] = {255,255,255}; int depth_test_enabled; - convertViewVec(t, vec, (short)(t->mval[0] - t->con.imval[0]), (short)(t->mval[1] - t->con.imval[1])); + convertViewVec(t, vec, (t->mval[0] - t->con.imval[0]), (t->mval[1] - t->con.imval[1])); add_v3_v3(vec, tc->center); drawLine(t, tc->center, tc->mtx[0], 'X', 0); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 6be095fa98b..8d37b7aeabb 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4927,13 +4927,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } else if ((t->flag & T_POSE) && (t->poseobj)) { bArmature *arm; - bPose *pose; bPoseChannel *pchan; short targetless_ik= 0; ob= t->poseobj; arm= ob->data; - pose= ob->pose; if((t->flag & T_AUTOIK) && (t->options & CTX_AUTOCONFIRM)) { /* when running transform non-interactively (operator exec), @@ -5325,7 +5323,7 @@ void createTransData(bContext *C, TransInfo *t) sort_trans_data_dist(t); } - if (t->ar->regiontype == RGN_TYPE_WINDOW) + if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) { View3D *v3d = t->view; RegionView3D *rv3d = CTX_wm_region_view3d(C); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 8c7a39e5dff..67e04bbd34e 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1039,9 +1039,14 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) } else { - // XXX for now, get View2D from the active region - t->view = &ar->v2d; - // XXX for now, the center point is the midpoint of the data + if(ar) { + // XXX for now, get View2D from the active region + t->view = &ar->v2d; + // XXX for now, the center point is the midpoint of the data + } + else { + t->view= NULL; + } t->around = V3D_CENTER; } diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index b6c4deffe0a..7a16e25302c 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -43,25 +43,25 @@ /* ************************** INPUT FROM MOUSE *************************** */ -static void InputVector(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) +static void InputVector(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float vec[3], dvec[3]; if(mi->precision) { /* calculate the main translation and the precise one separate */ - convertViewVec(t, dvec, (short)(mval[0] - mi->precision_mval[0]), (short)(mval[1] - mi->precision_mval[1])); + convertViewVec(t, dvec, (mval[0] - mi->precision_mval[0]), (mval[1] - mi->precision_mval[1])); mul_v3_fl(dvec, 0.1f); - convertViewVec(t, vec, (short)(mi->precision_mval[0] - t->imval[0]), (short)(mi->precision_mval[1] - t->imval[1])); + convertViewVec(t, vec, (mi->precision_mval[0] - t->imval[0]), (mi->precision_mval[1] - t->imval[1])); add_v3_v3v3(output, vec, dvec); } else { - convertViewVec(t, output, (short)(mval[0] - t->imval[0]), (short)(mval[1] - t->imval[1])); + convertViewVec(t, output, (mval[0] - t->imval[0]), (mval[1] - t->imval[1])); } } -static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) +static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { float ratio, precise_ratio, dx, dy; if(mi->precision) @@ -87,7 +87,7 @@ static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2 output[0] = ratio; } -static void InputSpringFlip(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) +static void InputSpringFlip(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { InputSpring(t, mi, mval, output); @@ -100,7 +100,7 @@ static void InputSpringFlip(TransInfo *t, MouseInput *mi, const short mval[2], f } } -static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) +static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { if(mi->precision) @@ -118,7 +118,7 @@ static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const short mva output[1] *= mi->factor; } -static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { +static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float x, pad; pad = t->ar->winx / 10; @@ -135,7 +135,7 @@ static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const short mval[ output[0] = (x - pad) / (t->ar->winx - 2 * pad); } -static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { +static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float vec[3]; InputVector(t, mi, mval, vec); @@ -144,7 +144,7 @@ static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const short mv output[0] = dot_v3v3(t->viewinv[0], vec) * 2.0f; } -static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { +static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float y, pad; pad = t->ar->winy / 10; @@ -160,7 +160,7 @@ static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const short mval[2] output[0] = (y - pad) / (t->ar->winy - 2 * pad); } -static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { +static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) { float vec[3]; InputVector(t, mi, mval, vec); @@ -169,12 +169,12 @@ static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const short mval output[0] = dot_v3v3(t->viewinv[1], vec) * 2.0f; } -void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, short start[2], short end[2]) +void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, int start[2], int end[2]) { - short *data; + int *data; if (mi->data == NULL) { - mi->data = MEM_callocN(sizeof(short) * 4, "custom points"); + mi->data = MEM_callocN(sizeof(int) * 4, "custom points"); } data = mi->data; @@ -185,12 +185,12 @@ void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, short start[2], short data[3] = end[1]; } -static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) +static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { float length; float distance; - short *data = mi->data; - short dx, dy; + int *data = mi->data; + int dx, dy; if (data) { dx = data[2] - data[0]; @@ -200,14 +200,14 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const short m if (mi->precision) { /* deal with Shift key by adding motion / 10 to motion before shift press */ - short mdx, mdy; + int mdx, mdy; mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2]; mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3]; distance = (length != 0.0f)? (mdx*dx + mdy*dy) / length: 0.0f; } else { - short mdx, mdy; + int mdx, mdy; mdx = mval[0] - data[2]; mdy = mval[1] - data[3]; @@ -218,7 +218,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const short m } } -static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) +static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float output[3]) { double dx2 = mval[0] - mi->center[0]; double dy2 = mval[1] - mi->center[1]; @@ -279,7 +279,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2] output[0] = *angle; } -void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, int center[2], short mval[2]) +void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, int center[2], int mval[2]) { mi->factor = 0; mi->precision = 0; @@ -372,7 +372,7 @@ void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3]) mi->post = post; } -void applyMouseInput(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) +void applyMouseInput(TransInfo *t, MouseInput *mi, int mval[2], float output[3]) { if (mi->apply != NULL) { diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 2fa094c6b8b..1933b11b308 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1487,7 +1487,7 @@ void BIF_draw_manipulator(const bContext *C) } } -static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const short mval[2], float hotspot) +static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], float hotspot) { View3D *v3d= sa->spacedata.first; RegionView3D *rv3d= ar->regiondata; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 4edaabb9508..7bdf6c909d9 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -514,7 +514,7 @@ void TRANSFORM_OT_translate(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); @@ -534,7 +534,7 @@ void TRANSFORM_OT_resize(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX); @@ -555,7 +555,7 @@ void TRANSFORM_OT_trackball(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_vector(ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "angle", "", -FLT_MAX, FLT_MAX); @@ -575,7 +575,7 @@ void TRANSFORM_OT_rotate(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2); @@ -618,7 +618,7 @@ void TRANSFORM_OT_warp(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", 0, 1); @@ -639,7 +639,7 @@ void TRANSFORM_OT_shear(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX); @@ -660,7 +660,7 @@ void TRANSFORM_OT_push_pull(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX); @@ -701,7 +701,7 @@ void TRANSFORM_OT_tosphere(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1); @@ -721,7 +721,7 @@ void TRANSFORM_OT_mirror(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; Transform_Properties(ot, P_CONSTRAINT|P_PROPORTIONAL); } @@ -801,7 +801,7 @@ void TRANSFORM_OT_transform(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_areaactive; + ot->poll = ED_operator_screenactive; 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/util/undo.c b/source/blender/editors/util/undo.c index 60f551afa6e..9ac44f482a1 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -260,7 +260,7 @@ int ED_undo_valid(const bContext *C, const char *undoname) static int ed_undo_exec(bContext *C, wmOperator *UNUSED(op)) { /* "last operator" should disappear, later we can tie ths with undo stack nicer */ - WM_operator_stack_clear(C); + WM_operator_stack_clear(CTX_wm_manager(C)); return ed_undo_step(C, 1, NULL); } diff --git a/source/blender/editors/util/util_intern.h b/source/blender/editors/util/util_intern.h index 9ecfb07d535..1a82668236d 100644 --- a/source/blender/editors/util/util_intern.h +++ b/source/blender/editors/util/util_intern.h @@ -37,7 +37,6 @@ /* internal exports only */ /* editmode_undo.c */ -void undo_editmode_clear(void); void undo_editmode_name(bContext *C, const char *undoname); int undo_editmode_valid(const char *undoname); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index eee7a3d7f69..20d7ea21d5c 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -419,7 +419,7 @@ int ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float *min, float return sel; } -int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3]) +static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3]) { EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data); EditFace *efa; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index e1eab55b434..1b8acb013ea 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -893,6 +893,7 @@ void UV_OT_unwrap(wmOperatorType *ot) /* identifiers */ ot->name= "Unwrap"; + ot->description= "Unwrap the mesh of the object being edited"; ot->idname= "UV_OT_unwrap"; ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index fc7e3408683..d6e2b56c065 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -34,7 +34,7 @@ set(INC ../makesrna ../../../intern/guardedalloc ../../../intern/smoke/extern - ${GLEW_INCLUDE_PATH} + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 25be2e2aeb4..0e7df43bd34 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -76,6 +76,8 @@ #include "smoke_API.h" +extern Material defmaterial; /* from material.c */ + /* These are some obscure rendering functions shared between the * game engine and the blender, in this module to avoid duplicaten * and abstract them away from the rest a bit */ @@ -951,7 +953,6 @@ static Material *gpu_active_node_material(Material *ma) void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, Object *ob, int glsl, int *do_alpha_pass) { - extern Material defmaterial; /* from material.c */ Material *ma; GPUMaterial *gpumat; GPUBlendMode blendmode; @@ -1042,7 +1043,6 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O int GPU_enable_material(int nr, void *attribs) { - extern Material defmaterial; /* from material.c */ GPUVertexAttribs *gattribs = attribs; GPUMaterial *gpumat; GPUBlendMode blendmode; diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 81512adf065..f5e2bf71468 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -84,11 +84,13 @@ typedef struct ImBuf { /* pixels */ unsigned int *rect; /* pixel values stored here */ - unsigned int *crect; /* color corrected pixel values stored here */ float *rect_float; /* floating point Rect equivalent Linear RGB color space - may need gamma correction to sRGB when generating 8bit representations */ - + + /* resolution - pixels per meter */ + double ppm[2]; + /* tiled pixel storage */ int tilex, tiley; int xtiles, ytiles; @@ -101,7 +103,6 @@ typedef struct ImBuf { /* parameters used by conversion between byte and float */ float dither; /* random dither value, for conversion from float -> byte rect */ short profile; /* color space/profile preset that the byte rect buffer represents */ - char profile_filename[256]; /* to be implemented properly, specific filename for custom profiles */ /* mipmapping */ struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /* MipMap levels, a series of halved images */ diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index a8b9e21331d..59772771f3b 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -84,17 +84,13 @@ void imb_freerectfloatImBuf(ImBuf *ibuf) void imb_freerectImBuf(ImBuf *ibuf) { if(ibuf==NULL) return; - - if(ibuf->crect) - MEM_freeN(ibuf->crect); if(ibuf->rect && (ibuf->mall & IB_rect)) MEM_freeN(ibuf->rect); + ibuf->rect= NULL; imb_freemipmapImBuf(ibuf); - - ibuf->rect= NULL; - ibuf->crect= NULL; + ibuf->mall &= ~IB_rect; } @@ -346,6 +342,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar d, unsigned int flag ibuf->depth= d; ibuf->ftype= TGA; ibuf->channels= 4; /* float option, is set to other values when buffers get assigned */ + ibuf->ppm[0]= ibuf->ppm[1]= 150.0 / 0.0254; /* 150dpi -> pixels-per-meter */ if(flags & IB_rect) { if(imb_addrectImBuf(ibuf)==FALSE) { diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 504817b263f..8df2a9f6985 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -44,6 +44,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_filetype.h" #include "BKE_global.h" @@ -192,7 +193,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon return 1; } -short imb_savecineon(struct ImBuf *buf, const char *myfile, int flags) +int imb_savecineon(struct ImBuf *buf, const char *myfile, int flags) { return imb_save_dpx_cineon(buf, myfile, 1, flags); } @@ -203,14 +204,14 @@ int imb_is_cineon(unsigned char *buf) return cineonIsMemFileCineon(buf); } -ImBuf *imb_loadcineon(unsigned char *mem, int size, int flags) +ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags) { if(imb_is_cineon(mem)) return imb_load_dpx_cineon(mem, 1, size, flags); return NULL; } -short imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags) +int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags) { return imb_save_dpx_cineon(buf, myfile, 0, flags); } @@ -220,7 +221,7 @@ int imb_is_dpx(unsigned char *buf) return dpxIsMemFileCineon(buf); } -ImBuf *imb_loaddpx(unsigned char *mem, int size, int flags) +ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags) { if(imb_is_dpx(mem)) return imb_load_dpx_cineon(mem, 0, size, flags); diff --git a/source/blender/imbuf/intern/cineon/cineonfile.h b/source/blender/imbuf/intern/cineon/cineonfile.h index 31aa56f560c..896e0af65b3 100644 --- a/source/blender/imbuf/intern/cineon/cineonfile.h +++ b/source/blender/imbuf/intern/cineon/cineonfile.h @@ -126,19 +126,6 @@ typedef struct { ASCII reserved[740]; } CineonMPISpecificInformation; -#if 0 -/* create CineonFile from data in header */ -/* return 0 for OK */ -int readCineonGenericHeader(CineonFile* cineon, CineonGenericHeader* header); - -/* create header from data in CineonFile */ -int initCineonGenericHeader( - CineonFile* cineon, CineonGenericHeader* header, const char* imagename); - -/* Note: dump routine assumes network byte order */ -void dumpCineonGenericHeader(CineonGenericHeader* header); -#endif - #ifdef __cplusplus } #endif diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c index fdcd3491af1..922cfcf9629 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.c @@ -276,7 +276,7 @@ dumpCineonOriginationInfo(CineonOriginationInformation* originInfo) { d_printf("Input device gamma %f\n", ntohf(originInfo->input_device_gamma)); } -int +static int initCineonGenericHeader(CineonFile* cineon, CineonGenericHeader* header, const char* imagename) { fillCineonFileInfo(cineon, &header->fileInfo, imagename); @@ -287,7 +287,7 @@ initCineonGenericHeader(CineonFile* cineon, CineonGenericHeader* header, const c return 0; } -void +static void dumpCineonGenericHeader(CineonGenericHeader* header) { dumpCineonFileInfo(&header->fileInfo); dumpCineonImageInfo(&header->imageInfo); diff --git a/source/blender/imbuf/intern/cineon/logmemfile.c b/source/blender/imbuf/intern/cineon/logmemfile.c index 6347eb5fdf9..d3a32774efd 100644 --- a/source/blender/imbuf/intern/cineon/logmemfile.c +++ b/source/blender/imbuf/intern/cineon/logmemfile.c @@ -27,6 +27,8 @@ #include "logImageCore.h" +#include "logmemfile.h" /* own include */ + int logimage_fseek(void* logfile, intptr_t offsett, int origin) { struct _Log_Image_File_t_ *file = (struct _Log_Image_File_t_*) logfile; diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp index 2989361efe6..0d17f16532b 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.cpp +++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -123,6 +123,53 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const } } + +uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const +{ + // Does bit expansion before interpolation. + color_array[0].b = (3 * col0.b * 22) / 8; + color_array[0].g = (col0.g << 2) | (col0.g >> 4); + color_array[0].r = (3 * col0.r * 22) / 8; + color_array[0].a = 0xFF; + + color_array[1].r = (3 * col1.r * 22) / 8; + color_array[1].g = (col1.g << 2) | (col1.g >> 4); + color_array[1].b = (3 * col1.b * 22) / 8; + color_array[1].a = 0xFF; + + int gdiff = color_array[1].g - color_array[0].g; + + if( col0.u > col1.u ) { + // Four-color block: derive the other two colors. + color_array[2].r = ((2 * col0.r + col1.r) * 22) / 8; + color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 80) / 256; + color_array[2].b = ((2 * col0.b + col1.b) * 22) / 8; + color_array[2].a = 0xFF; + + color_array[3].r = ((2 * col1.r + col0.r) * 22) / 8; + color_array[3].g = (256 * color_array[1].g - gdiff / 4 + 128 - gdiff * 80) / 256; + color_array[3].b = ((2 * col1.b + col0.b) * 22) / 8; + color_array[3].a = 0xFF; + + return 4; + } + else { + // Three-color block: derive the other color. + color_array[2].r = ((col0.r + col1.r) * 33) / 8; + color_array[2].g = (256 * color_array[0].g + gdiff / 4 + 128 + gdiff * 128) / 256; + color_array[2].b = ((col0.b + col1.b) * 33) / 8; + color_array[2].a = 0xFF; + + // Set all components to 0 to match DXT specs. + color_array[3].r = 0x00; // color_array[2].r; + color_array[3].g = 0x00; // color_array[2].g; + color_array[3].b = 0x00; // color_array[2].b; + color_array[3].a = 0x00; + + return 3; + } +} + // Evaluate palette assuming 3 color block. void BlockDXT1::evaluatePalette3(Color32 color_array[4]) const { @@ -174,6 +221,7 @@ void BlockDXT1::evaluatePalette4(Color32 color_array[4]) const color_array[3].a = 0xFF; } + void BlockDXT1::decodeBlock(ColorBlock * block) const { // Decode color block. @@ -189,6 +237,21 @@ void BlockDXT1::decodeBlock(ColorBlock * block) const } } +void BlockDXT1::decodeBlockNV5x(ColorBlock * block) const +{ + // Decode color block. + Color32 color_array[4]; + evaluatePaletteNV5x(color_array); + + // Write color block. + for( uint j = 0; j < 4; j++ ) { + for( uint i = 0; i < 4; i++ ) { + uint idx = (row[j] >> (2 * i)) & 3; + block->color(i, j) = color_array[idx]; + } + } +} + void BlockDXT1::setIndices(int * idx) { indices = 0; @@ -225,6 +288,12 @@ void BlockDXT3::decodeBlock(ColorBlock * block) const alpha.decodeBlock(block); } +void BlockDXT3::decodeBlockNV5x(ColorBlock * block) const +{ + color.decodeBlockNV5x(block); + alpha.decodeBlock(block); +} + void AlphaBlockDXT3::decodeBlock(ColorBlock * block) const { block->color(0x0).a = (alpha0 << 4) | alpha0; @@ -394,7 +463,15 @@ void BlockDXT5::decodeBlock(ColorBlock * block) const // Decode alpha. alpha.decodeBlock(block); +} +void BlockDXT5::decodeBlockNV5x(ColorBlock * block) const +{ + // Decode color. + color.decodeBlockNV5x(block); + + // Decode alpha. + alpha.decodeBlock(block); } /// Flip DXT5 block vertically. diff --git a/source/blender/imbuf/intern/dds/BlockDXT.h b/source/blender/imbuf/intern/dds/BlockDXT.h index 7c5b9acffd2..aa0c1c509ca 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.h +++ b/source/blender/imbuf/intern/dds/BlockDXT.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -78,11 +78,13 @@ struct BlockDXT1 bool isFourColorMode() const; uint evaluatePalette(Color32 color_array[4]) const; - uint evaluatePaletteFast(Color32 color_array[4]) const; + uint evaluatePaletteNV5x(Color32 color_array[4]) const; + void evaluatePalette3(Color32 color_array[4]) const; void evaluatePalette4(Color32 color_array[4]) const; void decodeBlock(ColorBlock * block) const; + void decodeBlockNV5x(ColorBlock * block) const; void setIndices(int * idx); @@ -136,6 +138,7 @@ struct BlockDXT3 BlockDXT1 color; void decodeBlock(ColorBlock * block) const; + void decodeBlockNV5x(ColorBlock * block) const; void flip4(); void flip2(); @@ -213,6 +216,7 @@ struct BlockDXT5 BlockDXT1 color; void decodeBlock(ColorBlock * block) const; + void decodeBlockNV5x(ColorBlock * block) const; void flip4(); void flip2(); diff --git a/source/blender/imbuf/intern/dds/Color.h b/source/blender/imbuf/intern/dds/Color.h index 5efc259b795..42ed34daf76 100644 --- a/source/blender/imbuf/intern/dds/Color.h +++ b/source/blender/imbuf/intern/dds/Color.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 711d1b54cfa..edb69934231 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -83,65 +83,90 @@ ColorBlock::ColorBlock(const Image * img, uint x, uint y) void ColorBlock::init(const Image * img, uint x, uint y) { - const uint bw = min(img->width() - x, 4U); - const uint bh = min(img->height() - y, 4U); + init(img->width(), img->height(), (const uint *)img->pixels(), x, y); +} - static int remainder[] = { - 0, 0, 0, 0, - 0, 1, 0, 1, - 0, 1, 2, 0, - 0, 1, 2, 3, - }; +void ColorBlock::init(uint w, uint h, const uint * data, uint x, uint y) +{ + const uint bw = min(w - x, 4U); + const uint bh = min(h - y, 4U); + + // Blocks that are smaller than 4x4 are handled by repeating the pixels. + // @@ Thats only correct when block size is 1, 2 or 4, but not with 3. :( + // @@ Ideally we should zero the weights of the pixels out of range. + + for (uint i = 0; i < 4; i++) + { + const int by = i % bh; + + for (uint e = 0; e < 4; e++) + { + const int bx = e % bw; + const uint idx = (y + by) * w + x + bx; + + color(e, i).u = data[idx]; + } + } +} + +void ColorBlock::init(uint w, uint h, const float * data, uint x, uint y) +{ + const uint bw = min(w - x, 4U); + const uint bh = min(h - y, 4U); // Blocks that are smaller than 4x4 are handled by repeating the pixels. // @@ Thats only correct when block size is 1, 2 or 4, but not with 3. :( + // @@ Ideally we should zero the weights of the pixels out of range. - for(uint i = 0; i < 4; i++) { - //const int by = i % bh; - const int by = remainder[(bh - 1) * 4 + i]; - for(uint e = 0; e < 4; e++) { - //const int bx = e % bw; - const int bx = remainder[(bw - 1) * 4 + e]; - color(e, i) = img->pixel(x + bx, y + by); + uint srcPlane = w * h; + + for (uint i = 0; i < 4; i++) + { + const uint by = i % bh; + + for (uint e = 0; e < 4; e++) + { + const uint bx = e % bw; + const uint idx = ((y + by) * w + x + bx); + + Color32 & c = color(e, i); + c.r = uint8(255 * clamp(data[idx + 0 * srcPlane], 0.0f, 1.0f)); // @@ Is this the right way to quantize floats to bytes? + c.g = uint8(255 * clamp(data[idx + 1 * srcPlane], 0.0f, 1.0f)); + c.b = uint8(255 * clamp(data[idx + 2 * srcPlane], 0.0f, 1.0f)); + c.a = uint8(255 * clamp(data[idx + 3 * srcPlane], 0.0f, 1.0f)); } } } - -void ColorBlock::swizzleDXT5n() +static inline uint8 component(Color32 c, uint i) { - for(int i = 0; i < 16; i++) + if (i == 0) return c.r; + if (i == 1) return c.g; + if (i == 2) return c.b; + if (i == 3) return c.a; + if (i == 4) return 0xFF; + return 0; +} + +void ColorBlock::swizzle(uint x, uint y, uint z, uint w) +{ + for (int i = 0; i < 16; i++) { Color32 c = m_color[i]; - m_color[i] = Color32(0xFF, c.g, 0, c.r); + m_color[i].r = component(c, x); + m_color[i].g = component(c, y); + m_color[i].b = component(c, z); + m_color[i].a = component(c, w); } } -void ColorBlock::splatX() -{ - for(int i = 0; i < 16; i++) - { - uint8 x = m_color[i].r; - m_color[i] = Color32(x, x, x, x); - } -} - -void ColorBlock::splatY() -{ - for(int i = 0; i < 16; i++) - { - uint8 y = m_color[i].g; - m_color[i] = Color32(y, y, y, y); - } -} /// Returns true if the block has a single color. -bool ColorBlock::isSingleColor() const +bool ColorBlock::isSingleColor(Color32 mask/*= Color32(0xFF, 0xFF, 0xFF, 0x00)*/) const { - Color32 mask(0xFF, 0xFF, 0xFF, 0x00); uint u = m_color[0].u & mask.u; - for(int i = 1; i < 16; i++) + for (int i = 1; i < 16; i++) { if (u != (m_color[i].u & mask.u)) { @@ -152,6 +177,7 @@ bool ColorBlock::isSingleColor() const return true; } +/* /// Returns true if the block has a single color, ignoring transparent pixels. bool ColorBlock::isSingleColorNoAlpha() const { @@ -159,7 +185,7 @@ bool ColorBlock::isSingleColorNoAlpha() const int i; for(i = 0; i < 16; i++) { - if (m_color[i].a != 0) c = m_color[i]; + if (m_color[i].a != 0) c = m_color[i]; } Color32 mask(0xFF, 0xFF, 0xFF, 0x00); @@ -175,9 +201,10 @@ bool ColorBlock::isSingleColorNoAlpha() const return true; } +*/ /// Count number of unique colors in this color block. -uint ColorBlock::countUniqueColors() const +/*uint ColorBlock::countUniqueColors() const { uint count = 0; @@ -197,9 +224,9 @@ uint ColorBlock::countUniqueColors() const } return count; -} +}*/ -/// Get average color of the block. +/*/// Get average color of the block. Color32 ColorBlock::averageColor() const { uint r, g, b, a; @@ -213,7 +240,7 @@ Color32 ColorBlock::averageColor() const } return Color32(uint8(r / 16), uint8(g / 16), uint8(b / 16), uint8(a / 16)); -} +}*/ /// Return true if the block is not fully opaque. bool ColorBlock::hasAlpha() const @@ -225,6 +252,7 @@ bool ColorBlock::hasAlpha() const return false; } +#if 0 /// Get diameter color range. void ColorBlock::diameterRange(Color32 * start, Color32 * end) const @@ -345,8 +373,9 @@ void ColorBlock::boundsRangeAlpha(Color32 * start, Color32 * end) const *start = minColor; *end = maxColor; } +#endif -/// Sort colors by abosolute value in their 16 bit representation. +/*/// Sort colors by abosolute value in their 16 bit representation. void ColorBlock::sortColorsByAbsoluteValue() { // Dummy selection sort. @@ -364,4 +393,75 @@ void ColorBlock::sortColorsByAbsoluteValue() } swap( m_color[a], m_color[max] ); } +}*/ + + +/*/// Find extreme colors in the given axis. +void ColorBlock::computeRange(Vector3::Arg axis, Color32 * start, Color32 * end) const +{ + + int mini, maxi; + mini = maxi = 0; + + float min, max; + min = max = dot(Vector3(m_color[0].r, m_color[0].g, m_color[0].b), axis); + + for(uint i = 1; i < 16; i++) + { + const Vector3 vec(m_color[i].r, m_color[i].g, m_color[i].b); + + float val = dot(vec, axis); + if( val < min ) { + mini = i; + min = val; + } + else if( val > max ) { + maxi = i; + max = val; + } + } + + *start = m_color[mini]; + *end = m_color[maxi]; +}*/ + + +/*/// Sort colors in the given axis. +void ColorBlock::sortColors(const Vector3 & axis) +{ + float luma_array[16]; + + for(uint i = 0; i < 16; i++) { + const Vector3 vec(m_color[i].r, m_color[i].g, m_color[i].b); + luma_array[i] = dot(vec, axis); + } + + // Dummy selection sort. + for( uint a = 0; a < 16; a++ ) { + uint min = a; + for( uint b = a+1; b < 16; b++ ) { + if( luma_array[b] < luma_array[min] ) { + min = b; + } + } + swap( luma_array[a], luma_array[min] ); + swap( m_color[a], m_color[min] ); + } +}*/ + + +/*/// Get the volume of the color block. +float ColorBlock::volume() const +{ + Box bounds; + bounds.clearBounds(); + + for(int i = 0; i < 16; i++) { + const Vector3 point(m_color[i].r, m_color[i].g, m_color[i].b); + bounds.addPointToBounds(point); + } + + return bounds.volume(); } +*/ + diff --git a/source/blender/imbuf/intern/dds/ColorBlock.h b/source/blender/imbuf/intern/dds/ColorBlock.h index dd40d21e8b3..d4e4e8a809f 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.h +++ b/source/blender/imbuf/intern/dds/ColorBlock.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -51,26 +51,15 @@ struct ColorBlock ColorBlock(const Image * img, uint x, uint y); void init(const Image * img, uint x, uint y); + void init(uint w, uint h, const uint * data, uint x, uint y); + void init(uint w, uint h, const float * data, uint x, uint y); - void swizzleDXT5n(); - void splatX(); - void splatY(); + void swizzle(uint x, uint y, uint z, uint w); // 0=r, 1=g, 2=b, 3=a, 4=0xFF, 5=0 - bool isSingleColor() const; - bool isSingleColorNoAlpha() const; - uint countUniqueColors() const; - Color32 averageColor() const; + bool isSingleColor(Color32 mask = Color32(0xFF, 0xFF, 0xFF, 0x00)) const; bool hasAlpha() const; - void diameterRange(Color32 * start, Color32 * end) const; - void luminanceRange(Color32 * start, Color32 * end) const; - void boundsRange(Color32 * start, Color32 * end) const; - void boundsRangeAlpha(Color32 * start, Color32 * end) const; - void sortColorsByAbsoluteValue(); - - float volume() const; - // Accessors const Color32 * colors() const; diff --git a/source/blender/imbuf/intern/dds/Common.h b/source/blender/imbuf/intern/dds/Common.h index 25b743311d2..a6dcf69febf 100644 --- a/source/blender/imbuf/intern/dds/Common.h +++ b/source/blender/imbuf/intern/dds/Common.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -55,4 +55,10 @@ typedef unsigned int uint; typedef unsigned int uint32; typedef unsigned long long uint64; +// copied from nvtt src/nvimage/nvimage.h +inline uint computePitch(uint w, uint bitsize, uint alignment) +{ + return ((w * bitsize + 8 * alignment - 1) / (8 * alignment)) * alignment; +} + #endif diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index ede82896554..971658ff482 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -69,12 +69,11 @@ #if !defined(MAKEFOURCC) # define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((uint)((unsigned char)(ch0)) | \ - ((uint)((unsigned char)(ch1)) << 8) | \ - ((uint)((unsigned char)(ch2)) << 16) | \ - ((uint)((unsigned char)(ch3)) << 24 )) + (uint(uint8(ch0)) | (uint(uint8(ch1)) << 8) | \ + (uint(uint8(ch2)) << 16) | (uint(uint8(ch3)) << 24 )) #endif +static const uint FOURCC_NVTT = MAKEFOURCC('N', 'V', 'T', 'T'); static const uint FOURCC_DDS = MAKEFOURCC('D', 'D', 'S', ' '); static const uint FOURCC_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'); static const uint FOURCC_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'); @@ -89,6 +88,8 @@ static const uint FOURCC_A2XY = MAKEFOURCC('A', '2', 'X', 'Y'); static const uint FOURCC_DX10 = MAKEFOURCC('D', 'X', '1', '0'); +static const uint FOURCC_UVER = MAKEFOURCC('U', 'V', 'E', 'R'); + // 32 bit RGB formats. static const uint D3DFMT_R8G8B8 = 20; static const uint D3DFMT_A8R8G8B8 = 21; @@ -160,7 +161,10 @@ static const uint DDPF_PALETTEINDEXED4 = 0x00000008U; static const uint DDPF_PALETTEINDEXED8 = 0x00000020U; static const uint DDPF_LUMINANCE = 0x00020000U; static const uint DDPF_ALPHAPREMULT = 0x00008000U; -static const uint DDPF_NORMAL = 0x80000000U; // @@ Custom nv flag. + +// Custom NVTT flags. +static const uint DDPF_NORMAL = 0x80000000U; +static const uint DDPF_SRGB = 0x40000000U; // DX10 formats. enum DXGI_FORMAT @@ -277,6 +281,20 @@ static const uint DDPF_NORMAL = 0x80000000U; // @@ Custom nv flag. DXGI_FORMAT_B5G5R5A1_UNORM = 86, DXGI_FORMAT_B8G8R8A8_UNORM = 87, DXGI_FORMAT_B8G8R8X8_UNORM = 88, + + DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89, + DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, + DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, + DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, + DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, + + DXGI_FORMAT_BC6H_TYPELESS = 94, + DXGI_FORMAT_BC6H_UF16 = 95, + DXGI_FORMAT_BC6H_SF16 = 96, + + DXGI_FORMAT_BC7_TYPELESS = 97, + DXGI_FORMAT_BC7_UNORM = 98, + DXGI_FORMAT_BC7_UNORM_SRGB = 99, }; enum D3D10_RESOURCE_DIMENSION @@ -478,6 +496,63 @@ void mem_read(Stream & mem, DDSHeader & header) } } +namespace +{ + struct FormatDescriptor + { + uint format; + uint bitcount; + uint rmask; + uint gmask; + uint bmask; + uint amask; + }; + + static const FormatDescriptor s_d3dFormats[] = + { + { D3DFMT_R8G8B8, 24, 0xFF0000, 0xFF00, 0xFF, 0 }, + { D3DFMT_A8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000 }, // DXGI_FORMAT_B8G8R8A8_UNORM + { D3DFMT_X8R8G8B8, 32, 0xFF0000, 0xFF00, 0xFF, 0 }, // DXGI_FORMAT_B8G8R8X8_UNORM + { D3DFMT_R5G6B5, 16, 0xF800, 0x7E0, 0x1F, 0 }, // DXGI_FORMAT_B5G6R5_UNORM + { D3DFMT_X1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0 }, + { D3DFMT_A1R5G5B5, 16, 0x7C00, 0x3E0, 0x1F, 0x8000 }, // DXGI_FORMAT_B5G5R5A1_UNORM + { D3DFMT_A4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0xF000 }, + { D3DFMT_R3G3B2, 8, 0xE0, 0x1C, 0x3, 0 }, + { D3DFMT_A8, 8, 0, 0, 0, 8 }, // DXGI_FORMAT_A8_UNORM + { D3DFMT_A8R3G3B2, 16, 0xE0, 0x1C, 0x3, 0xFF00 }, + { D3DFMT_X4R4G4B4, 16, 0xF00, 0xF0, 0xF, 0 }, + { D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 }, // DXGI_FORMAT_R10G10B10A2 + { D3DFMT_A8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000 }, // DXGI_FORMAT_R8G8B8A8_UNORM + { D3DFMT_X8B8G8R8, 32, 0xFF, 0xFF00, 0xFF0000, 0 }, + { D3DFMT_G16R16, 32, 0xFFFF, 0xFFFF0000, 0, 0 }, // DXGI_FORMAT_R16G16_UNORM + { D3DFMT_A2R10G10B10, 32, 0x3FF00000, 0xFFC00, 0x3FF, 0xC0000000 }, + { D3DFMT_A2B10G10R10, 32, 0x3FF, 0xFFC00, 0x3FF00000, 0xC0000000 }, + + { D3DFMT_L8, 8, 8, 0, 0, 0 }, // DXGI_FORMAT_R8_UNORM + { D3DFMT_L16, 16, 16, 0, 0, 0 }, // DXGI_FORMAT_R16_UNORM + }; + + static const uint s_d3dFormatCount = sizeof(s_d3dFormats) / sizeof(s_d3dFormats[0]); + +} // namespace + +uint findD3D9Format(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) +{ + for (int i = 0; i < s_d3dFormatCount; i++) + { + if (s_d3dFormats[i].bitcount == bitcount && + s_d3dFormats[i].rmask == rmask && + s_d3dFormats[i].gmask == gmask && + s_d3dFormats[i].bmask == bmask && + s_d3dFormats[i].amask == amask) + { + return s_d3dFormats[i].format; + } + } + + return 0; + } + DDSHeader::DDSHeader() @@ -493,8 +568,8 @@ DDSHeader::DDSHeader() for (uint i = 0; i < 11; i++) this->reserved[i] = 0; // Store version information on the reserved header attributes. - this->reserved[9] = MAKEFOURCC('N', 'V', 'T', 'T'); - this->reserved[10] = (0 << 16) | (9 << 8) | (5); // major.minor.revision + this->reserved[9] = FOURCC_NVTT; + this->reserved[10] = (2 << 16) | (1 << 8) | (0); // major.minor.revision this->pf.size = 32; this->pf.flags = 0; @@ -532,7 +607,7 @@ void DDSHeader::setHeight(uint h) void DDSHeader::setDepth(uint d) { this->flags |= DDSD_DEPTH; - this->height = d; + this->depth = d; } void DDSHeader::setMipmapCount(uint count) @@ -540,7 +615,7 @@ void DDSHeader::setMipmapCount(uint count) if (count == 0 || count == 1) { this->flags &= ~DDSD_MIPMAPCOUNT; - this->mipmapcount = 0; + this->mipmapcount = 1; if (this->caps.caps2 == 0) { this->caps.caps1 = DDSCAPS_TEXTURE; @@ -561,6 +636,7 @@ void DDSHeader::setMipmapCount(uint count) void DDSHeader::setTexture2D() { this->header10.resourceDimension = D3D10_RESOURCE_DIMENSION_TEXTURE2D; + this->header10.arraySize = 1; } void DDSHeader::setTexture3D() @@ -568,6 +644,7 @@ void DDSHeader::setTexture3D() this->caps.caps2 = DDSCAPS2_VOLUME; this->header10.resourceDimension = D3D10_RESOURCE_DIMENSION_TEXTURE3D; + this->header10.arraySize = 1; } void DDSHeader::setTextureCube() @@ -599,21 +676,32 @@ void DDSHeader::setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3) this->pf.flags = DDPF_FOURCC; this->pf.fourcc = MAKEFOURCC(c0, c1, c2, c3); - if (this->pf.fourcc == FOURCC_ATI2) - { - this->pf.bitcount = FOURCC_A2XY; - } - else - { - this->pf.bitcount = 0; - } - + this->pf.bitcount = 0; this->pf.rmask = 0; this->pf.gmask = 0; this->pf.bmask = 0; this->pf.amask = 0; } +void DDSHeader::setFormatCode(uint32 code) +{ + // set fourcc pixel format. + this->pf.flags = DDPF_FOURCC; + this->pf.fourcc = code; + + this->pf.bitcount = 0; + this->pf.rmask = 0; + this->pf.gmask = 0; + this->pf.bmask = 0; + this->pf.amask = 0; +} + +void DDSHeader::setSwizzleCode(uint8 c0, uint8 c1, uint8 c2, uint8 c3) +{ + this->pf.bitcount = MAKEFOURCC(c0, c1, c2, c3); +} + + void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask) { // Make sure the masks are correct. @@ -627,10 +715,24 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask return; } - this->pf.flags = DDPF_RGB; + if (rmask != 0 || gmask != 0 || bmask != 0) + { + if (gmask == 0 && bmask == 0) + { + this->pf.flags = DDPF_LUMINANCE; + } + else + { + this->pf.flags = DDPF_RGB; + } - if (amask != 0) { - this->pf.flags |= DDPF_ALPHAPIXELS; + if (amask != 0) { + this->pf.flags |= DDPF_ALPHAPIXELS; + } + } + else if (amask != 0) + { + this->pf.flags |= DDPF_ALPHA; } if (bitcount == 0) @@ -643,18 +745,16 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask } } + // D3DX functions do not like this: + this->pf.fourcc = 0; //findD3D9Format(bitcount, rmask, gmask, bmask, amask); + /*if (this->pf.fourcc) { + this->pf.flags |= DDPF_FOURCC; + }*/ + if (!(bitcount > 0 && bitcount <= 32)) { printf("DDS: bad bit count, pixel format not set\n"); return; } - - // Align to 8. - if (bitcount <= 8) bitcount = 8; - else if (bitcount <= 16) bitcount = 16; - else if (bitcount <= 24) bitcount = 24; - else bitcount = 32; - - this->pf.fourcc = 0; //findD3D9Format(bitcount, rmask, gmask, bmask, amask); this->pf.bitcount = bitcount; this->pf.rmask = rmask; this->pf.gmask = gmask; @@ -675,10 +775,108 @@ void DDSHeader::setNormalFlag(bool b) else this->pf.flags &= ~DDPF_NORMAL; } +void DDSHeader::setSrgbFlag(bool b) +{ + if (b) this->pf.flags |= DDPF_SRGB; + else this->pf.flags &= ~DDPF_SRGB; +} + +void DDSHeader::setHasAlphaFlag(bool b) +{ + if (b) this->pf.flags |= DDPF_ALPHAPIXELS; + else this->pf.flags &= ~DDPF_ALPHAPIXELS; +} + +void DDSHeader::setUserVersion(int version) +{ + this->reserved[7] = FOURCC_UVER; + this->reserved[8] = version; +} + +/* +void DDSHeader::swapBytes() +{ + this->fourcc = POSH_LittleU32(this->fourcc); + this->size = POSH_LittleU32(this->size); + this->flags = POSH_LittleU32(this->flags); + this->height = POSH_LittleU32(this->height); + this->width = POSH_LittleU32(this->width); + this->pitch = POSH_LittleU32(this->pitch); + this->depth = POSH_LittleU32(this->depth); + this->mipmapcount = POSH_LittleU32(this->mipmapcount); + + for(int i = 0; i < 11; i++) { + this->reserved[i] = POSH_LittleU32(this->reserved[i]); + } + + this->pf.size = POSH_LittleU32(this->pf.size); + this->pf.flags = POSH_LittleU32(this->pf.flags); + this->pf.fourcc = POSH_LittleU32(this->pf.fourcc); + this->pf.bitcount = POSH_LittleU32(this->pf.bitcount); + this->pf.rmask = POSH_LittleU32(this->pf.rmask); + this->pf.gmask = POSH_LittleU32(this->pf.gmask); + this->pf.bmask = POSH_LittleU32(this->pf.bmask); + this->pf.amask = POSH_LittleU32(this->pf.amask); + this->caps.caps1 = POSH_LittleU32(this->caps.caps1); + this->caps.caps2 = POSH_LittleU32(this->caps.caps2); + this->caps.caps3 = POSH_LittleU32(this->caps.caps3); + this->caps.caps4 = POSH_LittleU32(this->caps.caps4); + this->notused = POSH_LittleU32(this->notused); + + this->header10.dxgiFormat = POSH_LittleU32(this->header10.dxgiFormat); + this->header10.resourceDimension = POSH_LittleU32(this->header10.resourceDimension); + this->header10.miscFlag = POSH_LittleU32(this->header10.miscFlag); + this->header10.arraySize = POSH_LittleU32(this->header10.arraySize); + this->header10.reserved = POSH_LittleU32(this->header10.reserved); +} +*/ + bool DDSHeader::hasDX10Header() const { - return this->pf.fourcc == FOURCC_DX10; // @@ This is according to AMD - //return this->pf.flags == 0; // @@ This is according to MS + return this->pf.fourcc == FOURCC_DX10; +} + +uint DDSHeader::signature() const +{ + return this->reserved[9]; +} + +uint DDSHeader::toolVersion() const +{ + return this->reserved[10]; +} + +uint DDSHeader::userVersion() const +{ + if (this->reserved[7] == FOURCC_UVER) { + return this->reserved[8]; + } + return 0; +} + +bool DDSHeader::isNormalMap() const +{ + return (pf.flags & DDPF_NORMAL) != 0; +} + +bool DDSHeader::isSrgb() const +{ + return (pf.flags & DDPF_SRGB) != 0; +} + +bool DDSHeader::hasAlpha() const +{ + return (pf.flags & DDPF_ALPHAPIXELS) != 0; +} + +uint DDSHeader::d3d9Format() const +{ + if (pf.flags & DDPF_FOURCC) { + return pf.fourcc; + } + else { + return findD3D9Format(pf.bitcount, pf.rmask, pf.gmask, pf.bmask, pf.amask); + } } DirectDrawSurface::DirectDrawSurface(unsigned char *mem, uint size) : stream(mem, size), header() @@ -725,6 +923,16 @@ bool DirectDrawSurface::isSupported() const { if (header.hasDX10Header()) { + if (header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM || + header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM || + header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM || + header.header10.dxgiFormat == DXGI_FORMAT_BC4_UNORM || + header.header10.dxgiFormat == DXGI_FORMAT_BC5_UNORM) + { + return true; + } + + return false; } else { @@ -743,9 +951,9 @@ bool DirectDrawSurface::isSupported() const return false; } } - else if (header.pf.flags & DDPF_RGB) - { - // All RGB formats are supported now. + else if ((header.pf.flags & DDPF_RGB) || (header.pf.flags & DDPF_LUMINANCE)) + { + // All RGB and luminance formats are supported now. } else { @@ -768,6 +976,41 @@ bool DirectDrawSurface::isSupported() const return true; } +bool DirectDrawSurface::hasAlpha() const +{ + if (header.hasDX10Header()) + { + /* TODO: Update hasAlpha to handle all DX10 formats. */ + return + header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM || + header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM || + header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM; + } + else + { + if (header.pf.flags & DDPF_RGB) + { + return header.pf.amask != 0; + } + else if (header.pf.flags & DDPF_FOURCC) + { + if (header.pf.fourcc == FOURCC_RXGB || + header.pf.fourcc == FOURCC_ATI1 || + header.pf.fourcc == FOURCC_ATI2 || + header.pf.flags & DDPF_NORMAL) + { + return false; + } + else + { + // @@ Here we could check the ALPHA_PIXELS flag, but nobody sets it. (except us?) + return true; + } + } + + return false; + } +} uint DirectDrawSurface::mipmapCount() const { @@ -794,22 +1037,6 @@ uint DirectDrawSurface::depth() const else return 1; } -bool DirectDrawSurface::hasAlpha() const -{ - if ((header.pf.flags & DDPF_RGB) && (header.pf.amask == 0)) - { - return false; - } - else if (header.pf.fourcc == FOURCC_DXT1) - { - return false; - } - else - { - return true; - } -} - bool DirectDrawSurface::isTexture1D() const { if (header.hasDX10Header()) @@ -853,6 +1080,16 @@ void DirectDrawSurface::setNormalFlag(bool b) header.setNormalFlag(b); } +void DirectDrawSurface::setHasAlphaFlag(bool b) +{ + header.setHasAlphaFlag(b); +} + +void DirectDrawSurface::setUserVersion(int version) +{ + header.setUserVersion(version); +} + void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap) { stream.seek(offset(face, mipmap)); @@ -869,14 +1106,31 @@ void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap) img->allocate(w, h); - if (header.pf.flags & DDPF_RGB) + if (hasAlpha()) { - readLinearImage(img); + img->setFormat(Image::Format_ARGB); } - else if (header.pf.flags & DDPF_FOURCC) + else { + img->setFormat(Image::Format_RGB); + } + + if (header.hasDX10Header()) + { + // So far only block formats supported. readBlockImage(img); } + else + { + if (header.pf.flags & DDPF_RGB) + { + readLinearImage(img); + } + else if (header.pf.flags & DDPF_FOURCC) + { + readBlockImage(img); + } + } } void DirectDrawSurface::readLinearImage(Image * img) @@ -906,17 +1160,6 @@ void DirectDrawSurface::readLinearImage(Image * img) return; } - // set image format: RGB or ARGB - // alpha channel exists if and only if the alpha mask is non-zero - if (header.pf.amask == 0) - { - img->setFormat(Image::Format_RGB); - } - else - { - img->setFormat(Image::Format_ARGB); - } - // Read linear RGB images. for (uint y = 0; y < h; y++) { @@ -926,10 +1169,10 @@ void DirectDrawSurface::readLinearImage(Image * img) mem_read(stream, (unsigned char *)(&c), byteCount); Color32 pixel(0, 0, 0, 0xFF); - pixel.r = PixelFormat::convert(c >> rshift, rsize, 8); - pixel.g = PixelFormat::convert(c >> gshift, gsize, 8); - pixel.b = PixelFormat::convert(c >> bshift, bsize, 8); - pixel.a = PixelFormat::convert(c >> ashift, asize, 8); + pixel.r = PixelFormat::convert((c & header.pf.rmask) >> rshift, rsize, 8); + pixel.g = PixelFormat::convert((c & header.pf.gmask) >> gshift, gsize, 8); + pixel.b = PixelFormat::convert((c & header.pf.bmask) >> bshift, bsize, 8); + pixel.a = PixelFormat::convert((c & header.pf.amask) >> ashift, asize, 8); img->pixel(x, y) = pixel; } @@ -939,19 +1182,6 @@ void DirectDrawSurface::readLinearImage(Image * img) void DirectDrawSurface::readBlockImage(Image * img) { - // set image format: RGB or ARGB - if (header.pf.fourcc == FOURCC_RXGB || - header.pf.fourcc == FOURCC_ATI1 || - header.pf.fourcc == FOURCC_ATI2 || - header.pf.flags & DDPF_NORMAL) - { - img->setFormat(Image::Format_RGB); - } - else - { - img->setFormat(Image::Format_ARGB); - } - const uint w = img->width(); const uint h = img->height(); @@ -993,20 +1223,33 @@ static Color32 buildNormal(uint8 x, uint8 y) void DirectDrawSurface::readBlock(ColorBlock * rgba) { - if (header.pf.fourcc == FOURCC_DXT1) + uint fourcc = header.pf.fourcc; + + // Map DX10 block formats to fourcc codes. + if (header.hasDX10Header()) + { + if (header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM) fourcc = FOURCC_DXT1; + if (header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM) fourcc = FOURCC_DXT3; + if (header.header10.dxgiFormat == DXGI_FORMAT_BC3_UNORM) fourcc = FOURCC_DXT5; + if (header.header10.dxgiFormat == DXGI_FORMAT_BC4_UNORM) fourcc = FOURCC_ATI1; + if (header.header10.dxgiFormat == DXGI_FORMAT_BC5_UNORM) fourcc = FOURCC_ATI2; + } + + + if (fourcc == FOURCC_DXT1) { BlockDXT1 block; mem_read(stream, block); block.decodeBlock(rgba); } - else if (header.pf.fourcc == FOURCC_DXT2 || + else if (fourcc == FOURCC_DXT2 || header.pf.fourcc == FOURCC_DXT3) { BlockDXT3 block; mem_read(stream, block); block.decodeBlock(rgba); } - else if (header.pf.fourcc == FOURCC_DXT4 || + else if (fourcc == FOURCC_DXT4 || header.pf.fourcc == FOURCC_DXT5 || header.pf.fourcc == FOURCC_RXGB) { @@ -1014,7 +1257,7 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba) mem_read(stream, block); block.decodeBlock(rgba); - if (header.pf.fourcc == FOURCC_RXGB) + if (fourcc == FOURCC_RXGB) { // Swap R & A. for (int i = 0; i < 16; i++) @@ -1026,13 +1269,13 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba) } } } - else if (header.pf.fourcc == FOURCC_ATI1) + else if (fourcc == FOURCC_ATI1) { BlockATI1 block; mem_read(stream, block); block.decodeBlock(rgba); } - else if (header.pf.fourcc == FOURCC_ATI2) + else if (fourcc == FOURCC_ATI2) { BlockATI2 block; mem_read(stream, block); @@ -1042,7 +1285,7 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba) // If normal flag set, convert to normal. if (header.pf.flags & DDPF_NORMAL) { - if (header.pf.fourcc == FOURCC_ATI2) + if (fourcc == FOURCC_ATI2) { for (int i = 0; i < 16; i++) { @@ -1050,7 +1293,7 @@ void DirectDrawSurface::readBlock(ColorBlock * rgba) c = buildNormal(c.r, c.g); } } - else if (header.pf.fourcc == FOURCC_DXT5) + else if (fourcc == FOURCC_DXT5) { for (int i = 0; i < 16; i++) { @@ -1076,6 +1319,27 @@ uint DirectDrawSurface::blockSize() const case FOURCC_RXGB: case FOURCC_ATI2: return 16; + case FOURCC_DX10: + switch(header.header10.dxgiFormat) + { + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM: + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + case DXGI_FORMAT_BC4_SNORM: + return 8; + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC2_UNORM: + case DXGI_FORMAT_BC2_UNORM_SRGB: + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC3_UNORM: + case DXGI_FORMAT_BC3_UNORM_SRGB: + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_BC5_UNORM: + case DXGI_FORMAT_BC5_SNORM: + return 16; + }; }; // Not a block image. @@ -1102,14 +1366,10 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const h = (h + 3) / 4; return blockSize() * w * h; } - else if (header.pf.flags & DDPF_RGB) + else if (header.pf.flags & DDPF_RGB || (header.pf.flags & DDPF_LUMINANCE)) { - // Align pixels to bytes. - uint byteCount = (header.pf.bitcount + 7) / 8; - - // Align pitch to 4 bytes. - uint pitch = 4 * ((w * byteCount + 3) / 4); - + uint pitch = computePitch(w, header.pf.bitcount, 8); // Asuming 8 bit alignment, which is the same D3DX expects. + return pitch * h * d; } else { @@ -1133,7 +1393,7 @@ uint DirectDrawSurface::faceSize() const uint DirectDrawSurface::offset(const uint face, const uint mipmap) { - uint size = 128; //sizeof(DDSHeader); + uint size = 128; // sizeof(DDSHeader); if (header.hasDX10Header()) { @@ -1156,7 +1416,6 @@ uint DirectDrawSurface::offset(const uint face, const uint mipmap) void DirectDrawSurface::printInfo() const { - /* printf("FOURCC: %c%c%c%c\n", ((unsigned char *)&header.fourcc)[0], ((unsigned char *)&header.fourcc)[1], ((unsigned char *)&header.fourcc)[2], ((unsigned char *)&header.fourcc)[3]); */ printf("Flags: 0x%.8X\n", header.flags); if (header.flags & DDSD_CAPS) printf("\tDDSD_CAPS\n"); if (header.flags & DDSD_PIXELFORMAT) printf("\tDDSD_PIXELFORMAT\n"); @@ -1175,9 +1434,9 @@ void DirectDrawSurface::printInfo() const printf("Mipmap count: %d\n", header.mipmapcount); printf("Pixel Format:\n"); - /* printf("\tSize: %d\n", header.pf.size); */ printf("\tFlags: 0x%.8X\n", header.pf.flags); if (header.pf.flags & DDPF_RGB) printf("\t\tDDPF_RGB\n"); + if (header.pf.flags & DDPF_LUMINANCE) printf("\t\tDDPF_LUMINANCE\n"); if (header.pf.flags & DDPF_FOURCC) printf("\t\tDDPF_FOURCC\n"); if (header.pf.flags & DDPF_ALPHAPIXELS) printf("\t\tDDPF_ALPHAPIXELS\n"); if (header.pf.flags & DDPF_ALPHA) printf("\t\tDDPF_ALPHA\n"); @@ -1188,23 +1447,30 @@ void DirectDrawSurface::printInfo() const if (header.pf.flags & DDPF_ALPHAPREMULT) printf("\t\tDDPF_ALPHAPREMULT\n"); if (header.pf.flags & DDPF_NORMAL) printf("\t\tDDPF_NORMAL\n"); - printf("\tFourCC: '%c%c%c%c'\n", - ((header.pf.fourcc >> 0) & 0xFF), - ((header.pf.fourcc >> 8) & 0xFF), - ((header.pf.fourcc >> 16) & 0xFF), - ((header.pf.fourcc >> 24) & 0xFF)); - if ((header.pf.fourcc & DDPF_FOURCC) && (header.pf.bitcount != 0)) + if (header.pf.fourcc != 0) { + // Display fourcc code even when DDPF_FOURCC flag not set. + printf("\tFourCC: '%c%c%c%c' (0x%.8X)\n", + ((header.pf.fourcc >> 0) & 0xFF), + ((header.pf.fourcc >> 8) & 0xFF), + ((header.pf.fourcc >> 16) & 0xFF), + ((header.pf.fourcc >> 24) & 0xFF), + header.pf.fourcc); + } + + if ((header.pf.flags & DDPF_FOURCC) && (header.pf.bitcount != 0)) { - printf("\tSwizzle: '%c%c%c%c'\n", + printf("\tSwizzle: '%c%c%c%c' (0x%.8X)\n", (header.pf.bitcount >> 0) & 0xFF, (header.pf.bitcount >> 8) & 0xFF, (header.pf.bitcount >> 16) & 0xFF, - (header.pf.bitcount >> 24) & 0xFF); + (header.pf.bitcount >> 24) & 0xFF, + header.pf.bitcount); } else { printf("\tBit count: %d\n", header.pf.bitcount); } + printf("\tRed mask: 0x%.8X\n", header.pf.rmask); printf("\tGreen mask: 0x%.8X\n", header.pf.gmask); printf("\tBlue mask: 0x%.8X\n", header.pf.bmask); @@ -1244,7 +1510,7 @@ void DirectDrawSurface::printInfo() const printf("\tArray size: %u\n", header.header10.arraySize); } - if (header.reserved[9] == MAKEFOURCC('N', 'V', 'T', 'T')) + if (header.reserved[9] == FOURCC_NVTT) { int major = (header.reserved[10] >> 16) & 0xFF; int minor = (header.reserved[10] >> 8) & 0xFF; @@ -1253,5 +1519,10 @@ void DirectDrawSurface::printInfo() const printf("Version:\n"); printf("\tNVIDIA Texture Tools %d.%d.%d\n", major, minor, revision); } + + if (header.reserved[7] == FOURCC_UVER) + { + printf("User Version: %d\n", header.reserved[8]); + } } diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h index cc04c50e795..5978e780991 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -126,11 +126,25 @@ struct DDSHeader void setLinearSize(uint size); void setPitch(uint pitch); void setFourCC(uint8 c0, uint8 c1, uint8 c2, uint8 c3); + void setFormatCode(uint code); + void setSwizzleCode(uint8 c0, uint8 c1, uint8 c2, uint8 c3); void setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask, uint amask); void setDX10Format(uint format); void setNormalFlag(bool b); + void setSrgbFlag(bool b); + void setHasAlphaFlag(bool b); + void setUserVersion(int version); + + /*void swapBytes();*/ bool hasDX10Header() const; + uint signature() const; + uint toolVersion() const; + uint userVersion() const; + bool isNormalMap() const; + bool isSrgb() const; + bool hasAlpha() const; + uint d3d9Format() const; }; /// DirectDraw Surface. (DDS) @@ -142,6 +156,8 @@ public: bool isValid() const; bool isSupported() const; + + bool hasAlpha() const; uint mipmapCount() const; uint width() const; @@ -153,8 +169,8 @@ public: bool isTextureCube() const; void setNormalFlag(bool b); - - bool hasAlpha() const; /* false for DXT1, true for all other DXTs */ + void setHasAlphaFlag(bool b); + void setUserVersion(int version); void mipmap(Image * img, uint f, uint m); // void mipmap(FloatImage * img, uint f, uint m); diff --git a/source/blender/imbuf/intern/dds/Image.cpp b/source/blender/imbuf/intern/dds/Image.cpp index a775a9125d2..b9ec1c0c3aa 100644 --- a/source/blender/imbuf/intern/dds/Image.cpp +++ b/source/blender/imbuf/intern/dds/Image.cpp @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -41,7 +41,7 @@ #include // printf -Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(0) +Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(NULL) { } @@ -61,7 +61,7 @@ void Image::allocate(uint w, uint h) void Image::free() { if (m_data) delete [] m_data; - m_data = 0; + m_data = NULL; } @@ -132,3 +132,4 @@ void Image::setFormat(Image::Format f) m_format = f; } + diff --git a/source/blender/imbuf/intern/dds/Image.h b/source/blender/imbuf/intern/dds/Image.h index 88051410056..96e455fc75b 100644 --- a/source/blender/imbuf/intern/dds/Image.h +++ b/source/blender/imbuf/intern/dds/Image.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h index c483c525570..35c6eacb972 100644 --- a/source/blender/imbuf/intern/dds/PixelFormat.h +++ b/source/blender/imbuf/intern/dds/PixelFormat.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -107,6 +107,38 @@ } } + inline float quantizeCeil(float f, int inbits, int outbits) + { + //uint i = f * (float(1 << inbits) - 1); + //i = convert(i, inbits, outbits); + //float result = float(i) / (float(1 << outbits) - 1); + //nvCheck(result >= f); + float result; + int offset = 0; + do { + uint i = offset + uint(f * (float(1 << inbits) - 1)); + i = convert(i, inbits, outbits); + result = float(i) / (float(1 << outbits) - 1); + offset++; + } while (result < f); + + return result; + } + + /* + inline float quantizeRound(float f, int bits) + { + float scale = float(1 << bits); + return fround(f * scale) / scale; + } + + inline float quantizeFloor(float f, int bits) + { + float scale = float(1 << bits); + return floor(f * scale) / scale; + } + */ + } // PixelFormat namespace #endif // _DDS_IMAGE_PIXELFORMAT_H diff --git a/source/blender/imbuf/intern/dds/Stream.cpp b/source/blender/imbuf/intern/dds/Stream.cpp index 88c5277e097..497109efd25 100644 --- a/source/blender/imbuf/intern/dds/Stream.cpp +++ b/source/blender/imbuf/intern/dds/Stream.cpp @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/imbuf/intern/dds/Stream.h b/source/blender/imbuf/intern/dds/Stream.h index acc2c8bb176..ca081d331fe 100644 --- a/source/blender/imbuf/intern/dds/Stream.h +++ b/source/blender/imbuf/intern/dds/Stream.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index a7b2934cafa..73ee3a2cb9c 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ @@ -106,10 +106,21 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) } /* convert DDS into ImBuf */ - // TODO use the image RGB or RGBA tag to determine the bits per pixel - if (dds.hasAlpha()) bits_per_pixel = 32; - else bits_per_pixel = 24; - ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0); + dds.mipmap(&img, 0, 0); /* load first face, first mipmap */ + pixels = img.pixels(); + numpixels = dds.width() * dds.height(); + bits_per_pixel = 24; + if (img.format() == Image::Format_ARGB) { + /* check that there is effectively an alpha channel */ + for (unsigned int i = 0; i < numpixels; i++) { + pixel = pixels[i]; + if (pixel.a != 255) { + bits_per_pixel = 32; + break; + }; + }; + }; + ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0); if (ibuf == 0) return(0); /* memory allocation failed */ ibuf->ftype = DDS; @@ -120,9 +131,6 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) if (ibuf->rect == 0) return(ibuf); rect = ibuf->rect; - dds.mipmap(&img, 0, 0); /* load first face, first mipmap */ - pixels = img.pixels(); - numpixels = dds.width() * dds.height(); cp[3] = 0xff; /* default alpha if alpha channel is not present */ for (unsigned int i = 0; i < numpixels; i++) { diff --git a/source/blender/imbuf/intern/dds/dds_api.h b/source/blender/imbuf/intern/dds/dds_api.h index cfc6910e71d..d78e4f31474 100644 --- a/source/blender/imbuf/intern/dds/dds_api.h +++ b/source/blender/imbuf/intern/dds/dds_api.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributors: Amorilia (amorilia@gamebox.net) + * Contributors: Amorilia (amorilia@users.sourceforge.net) * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 2821ba2a361..16fb1fdf4aa 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -437,7 +437,7 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter) hbuf= ibuf->mipmap[curmap]; hbuf->miplevel= curmap+1; - if(!hbuf || (hbuf->x == 1 && hbuf->y == 1)) + if(!hbuf || (hbuf->x <= 2 && hbuf->y <= 2)) break; curmap++; diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 200ff0af9af..6b6dcdb88af 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -257,6 +257,10 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) } + if(ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) { + png_set_pHYs(png_ptr, info_ptr, (unsigned int)(ibuf->ppm[0] + 0.5), (unsigned int)(ibuf->ppm[1] + 0.5), PNG_RESOLUTION_METER); + } + // write the file header information png_write_info(png_ptr, info_ptr); @@ -384,7 +388,19 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) if (ibuf) { ibuf->ftype = PNG; ibuf->profile = IB_PROFILE_SRGB; - } else { + + if (png_get_valid (png_ptr, info_ptr, PNG_INFO_pHYs)) { + int unit_type; + unsigned int xres, yres; + + if(png_get_pHYs(png_ptr, info_ptr, &xres, &yres, &unit_type)) + if(unit_type == PNG_RESOLUTION_METER) { + ibuf->ppm[0]= xres; + ibuf->ppm[1]= yres; + } + } + } + else { printf("Couldn't allocate memory for PNG image\n"); } diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 67d20d56466..36130aa0dbf 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -354,6 +354,25 @@ static void scanline_separate_32bit(float *rectf, float *fbuf, int scanline_w, i rectf[i*4 + chan] = fbuf[i]; } +static void imb_read_tiff_resolution(ImBuf *ibuf, TIFF *image) +{ + uint16 unit; + float xres; + float yres; + + TIFFGetFieldDefaulted(image, TIFFTAG_RESOLUTIONUNIT, &unit); + TIFFGetFieldDefaulted(image, TIFFTAG_XRESOLUTION, &xres); + TIFFGetFieldDefaulted(image, TIFFTAG_YRESOLUTION, &yres); + + if(unit == RESUNIT_CENTIMETER) { + ibuf->ppm[0]= (double)xres * 100.0; + ibuf->ppm[1]= (double)yres * 100.0; + } + else { + ibuf->ppm[0]= (double)xres / 0.0254; + ibuf->ppm[1]= (double)yres / 0.0254; + } +} /* * Use the libTIFF scanline API to read a TIFF image. @@ -369,10 +388,13 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) int ib_flag=0, row, chan; float *fbuf=NULL; unsigned short *sbuf=NULL; - + TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bitspersample); TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp); /* number of 'channels' */ TIFFGetField(image, TIFFTAG_PLANARCONFIG, &config); + + imb_read_tiff_resolution(ibuf, image); + scanline = TIFFScanlineSize(image); if (bitspersample == 32) { @@ -658,6 +680,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) unsigned char *from = NULL, *to = NULL; unsigned short *pixels16 = NULL, *to16 = NULL; float *fromf = NULL; + float xres, yres; int x, y, from_i, to_i, i; int extraSampleTypes[1] = { EXTRASAMPLE_ASSOCALPHA }; @@ -783,8 +806,18 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(image, TIFFTAG_XRESOLUTION, 150.0); - TIFFSetField(image, TIFFTAG_YRESOLUTION, 150.0); + + + if(ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) { + xres= (float)(ibuf->ppm[0] * 0.0254); + yres= (float)(ibuf->ppm[1] * 0.0254); + } + else { + xres= yres= 150.0f; + } + + TIFFSetField(image, TIFFTAG_XRESOLUTION, xres); + TIFFSetField(image, TIFFTAG_YRESOLUTION, yres); TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); if(TIFFWriteEncodedStrip(image, 0, (bitspersample == 16)? (unsigned char*)pixels16: pixels, diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 2cec3cf7a97..6fcb3a9d175 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -123,12 +123,14 @@ typedef struct Library { struct Library *parent; /* set for indirectly linked libs, used in the outliner and while reading */ } Library; -#define PREVIEW_MIPMAPS 2 -#define PREVIEW_MIPMAP_ZERO 0 -#define PREVIEW_MIPMAP_LARGE 1 +enum eIconSizes { + ICON_SIZE_ICON, + ICON_SIZE_PREVIEW, +}; +#define NUM_ICON_SIZES (ICON_SIZE_PREVIEW + 1) typedef struct PreviewImage { - /* All values of 2 are really PREVIEW_MIPMAPS */ + /* All values of 2 are really NUM_ICON_SIZES */ unsigned int w[2]; unsigned int h[2]; short changed[2]; diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index 4ebd7318ea8..952b4e799b5 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -47,7 +47,9 @@ typedef struct Camera { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ - short type, flag; + char type; /* CAM_PERSP or CAM_ORTHO */ + char dtx; /* draw type extra */ + short flag; float passepartalpha; float clipsta, clipend; float lens, ortho_scale, drawsize; @@ -69,6 +71,16 @@ typedef struct Camera { #define CAM_PERSP 0 #define CAM_ORTHO 1 +/* dtx */ +#define CAM_DTX_CENTER 1 +#define CAM_DTX_CENTER_DIAG 2 +#define CAM_DTX_THIRDS 4 +#define CAM_DTX_GOLDEN 8 +#define CAM_DTX_GOLDEN_TRI_A 16 +#define CAM_DTX_GOLDEN_TRI_B 32 +#define CAM_DTX_HARMONY_TRI_A 64 +#define CAM_DTX_HARMONY_TRI_B 128 + /* flag */ #define CAM_SHOWLIMITS 1 #define CAM_SHOWMIST 2 diff --git a/source/blender/makesdna/DNA_object_fluidsim.h b/source/blender/makesdna/DNA_object_fluidsim.h index e8360b99d69..6f4c16cb7f3 100644 --- a/source/blender/makesdna/DNA_object_fluidsim.h +++ b/source/blender/makesdna/DNA_object_fluidsim.h @@ -42,7 +42,10 @@ extern "C" { struct Mesh; struct Ipo; -struct MVert; + +typedef struct FluidVertexVelocity { + float vel[3]; +} FluidVertexVelocity; typedef struct FluidsimSettings { struct FluidsimModifierData *fmd; /* for fast RNA access */ @@ -82,8 +85,6 @@ typedef struct FluidsimSettings { /* store pointer to original mesh (for replacing the current one) */ struct Mesh *orgMesh; - /* pointer to the currently loaded fluidsim mesh */ - struct Mesh *meshSurface; /* a mesh to display the bounding box used for simulation */ struct Mesh *meshBB; @@ -122,8 +123,10 @@ typedef struct FluidsimSettings { /* testing vars */ float farFieldSize; - /* save fluidsurface normals in mvert.no, and surface vertex velocities (if available) in mvert.co */ - struct MVert *meshSurfNormals; + /* vertex velocities of simulated fluid mesh */ + struct FluidVertexVelocity *meshVelocities; + /* number of vertices in simulated fluid mesh */ + int totvert; /* Fluid control settings */ float cpsTimeStart; @@ -136,6 +139,8 @@ typedef struct FluidsimSettings { float velocityforceRadius; int lastgoodframe; + + int pad; } FluidsimSettings; diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 7194905f9c3..8d3330db366 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -259,6 +259,9 @@ typedef struct Object { ListBase gpulamp; /* runtime, for lamps only */ ListBase pc_ids; ListBase *duplilist; /* for temporary dupli list storage, only for use by RNA API */ + + float ima_ofs[2]; /* offset for image empties */ + char pad3[8]; } Object; /* Warning, this is not used anymore because hooks are now modifiers */ @@ -400,6 +403,7 @@ extern Object workob; #define OB_CUBE 5 #define OB_EMPTY_SPHERE 6 #define OB_EMPTY_CONE 7 +#define OB_EMPTY_IMAGE 8 /* boundtype */ #define OB_BOUND_BOX 0 diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 22f0c23ea9b..f89cc9d518a 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -310,7 +310,8 @@ typedef struct SpeedControlVars { #define SEQ_COLOR 28 #define SEQ_SPEED 29 #define SEQ_MULTICAM 30 -#define SEQ_EFFECT_MAX 30 +#define SEQ_ADJUSTMENT 31 +#define SEQ_EFFECT_MAX 31 #define STRIPELEM_FAILED 0 #define STRIPELEM_OK 1 diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 2c6cbb77bf5..debdf87f20f 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -830,6 +830,7 @@ enum { #define ST_FIND_WRAP 0x0020 #define ST_FIND_ALL 0x0040 #define ST_SHOW_MARGIN 0x0080 +#define ST_MATCH_CASE 0x0100 /* stext->findstr/replacestr */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 266121495ff..69eeda6c178 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -165,26 +165,21 @@ typedef struct View3D { * OB_SHADED or OB_TEXTURE */ short drawtype; short ob_centre_cursor; /* optional bool for 3d cursor to define center */ - short scenelock, around, pad3; + short scenelock, around; short flag, flag2; - short pivot_last; /* pivot_last is for rotating around the last edited element */ - float lens, grid; - float gridview; /* XXX deprecated, now in RegionView3D */ float near, far; float ofs[3]; /* XXX deprecated */ float cursor[3]; - short gridlines, pad4; - short gridflag; - short gridsubdiv; /* Number of subdivisions in the grid between each highlighted grid line */ short modeselect; - short keyflags; /* flags for display of keyframes */ - + short gridlines; + short gridsubdiv; /* Number of subdivisions in the grid between each highlighted grid line */ + char gridflag; + /* transform widget info */ - short twtype, twmode, twflag; - short twdrawflag; /* XXX deprecated */ + char twtype, twmode, twflag, pad2[2]; /* afterdraw, for xray & transparent */ struct ListBase afterdraw_transp; @@ -197,7 +192,7 @@ typedef struct View3D { char ndofmode; /* mode of transform for 6DOF devices -1 not found, 0 normal, 1 fly, 2 ob transform */ char ndoffilter; /* filter for 6DOF devices 0 normal, 1 dominant */ - void *properties_storage; /* Nkey panel stores stuff here, not in file */ + void *properties_storage; /* Nkey panel stores stuff here (runtime only!) */ /* XXX depricated? */ struct bGPdata *gpd; /* Grease-Pencil Data (annotation layers) */ @@ -233,10 +228,11 @@ typedef struct View3D { #define RV3D_BOXCLIP 4 /* RegionView3d->view */ -#define RV3D_VIEW_FRONT 1 +#define RV3D_VIEW_USER 0 +#define RV3D_VIEW_FRONT 1 #define RV3D_VIEW_BACK 2 #define RV3D_VIEW_LEFT 3 -#define RV3D_VIEW_RIGHT 4 +#define RV3D_VIEW_RIGHT 4 #define RV3D_VIEW_TOP 5 #define RV3D_VIEW_BOTTOM 6 #define RV3D_VIEW_PERSPORTHO 7 @@ -246,6 +242,7 @@ typedef struct View3D { #define V3D_RENDER_OVERRIDE 4 #define V3D_SOLID_TEX 8 #define V3D_DISPGP 16 +#define V3D_LOCK_CAMERA 32 /* View3D->around */ #define V3D_CENTER 0 diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 3072c2c3430..31e59f18626 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -316,10 +316,4 @@ typedef struct wmOperator { /* wmOperator flag */ #define OP_GRAB_POINTER 1 -typedef enum wmRadialControlMode { - WM_RADIALCONTROL_SIZE, - WM_RADIALCONTROL_STRENGTH, - WM_RADIALCONTROL_ANGLE -} wmRadialControlMode; - #endif /* DNA_WINDOWMANAGER_TYPES_H */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index e7c6e7d3bac..0d3101187b7 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -53,6 +53,7 @@ extern LIBEXPORT StructRNA RNA_ActionGroup; extern LIBEXPORT StructRNA RNA_Actuator; extern LIBEXPORT StructRNA RNA_ActuatorSensor; extern LIBEXPORT StructRNA RNA_Addon; +extern LIBEXPORT StructRNA RNA_AdjustmentSequence; extern LIBEXPORT StructRNA RNA_AlwaysSensor; extern LIBEXPORT StructRNA RNA_AndController; extern LIBEXPORT StructRNA RNA_AnimData; @@ -610,6 +611,7 @@ LIBEXPORT int RNA_struct_is_a(StructRNA *type, StructRNA *srna); LIBEXPORT StructRegisterFunc RNA_struct_register(StructRNA *type); LIBEXPORT StructUnregisterFunc RNA_struct_unregister(StructRNA *type); LIBEXPORT void **RNA_struct_instance(PointerRNA *ptr); +void **RNA_struct_instance(PointerRNA *ptr); LIBEXPORT void *RNA_struct_py_type_get(StructRNA *srna); LIBEXPORT void RNA_struct_py_type_set(StructRNA *srna, void *py_type); @@ -888,7 +890,7 @@ LIBEXPORT int RNA_property_is_idprop(PropertyRNA *prop); /* python compatible string representation of this property, (must be freed!) */ LIBEXPORT char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop); -LIBEXPORT char *RNA_pointer_as_string(PointerRNA *ptr); +LIBEXPORT char *RNA_pointer_as_string(struct bContext *C, PointerRNA *ptr); /* Function */ diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 229d0fdb020..2e1102ae793 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -55,6 +55,7 @@ struct StructRNA; struct BlenderRNA; struct IDProperty; struct bContext; +struct Main; struct ReportList; /** Pointer @@ -341,9 +342,9 @@ typedef enum StructFlag { typedef int (*StructValidateFunc)(struct PointerRNA *ptr, void *data, int *have_function); typedef int (*StructCallbackFunc)(struct bContext *C, struct PointerRNA *ptr, struct FunctionRNA *func, ParameterList *list); typedef void (*StructFreeFunc)(void *data); -typedef struct StructRNA *(*StructRegisterFunc)(struct bContext *C, struct ReportList *reports, void *data, +typedef struct StructRNA *(*StructRegisterFunc)(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); -typedef void (*StructUnregisterFunc)(const struct bContext *C, struct StructRNA *type); +typedef void (*StructUnregisterFunc)(struct Main *bmain, struct StructRNA *type); typedef void **(*StructInstanceFunc)(PointerRNA *ptr); typedef struct StructRNA StructRNA; diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index 86ba81aae58..b706db5e64c 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -42,10 +42,6 @@ if env['WITH_BF_QUICKTIME']: defs.append('WITH_QUICKTIME') incs += ' ../quicktime' -if env['WITH_BF_LCMS']: - defs.append('WITH_LCMS') - incs += ' ' + env['BF_LCMS_INC'] - if env['WITH_BF_GAMEENGINE']: defs.append('WITH_GAMEENGINE') diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 473e57daf93..37123ea4ec1 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -175,11 +175,6 @@ if(WITH_CODEC_FFMPEG) add_definitions(-DWITH_FFMPEG) endif() -if(WITH_LCMS) - list(APPEND INC ${LCMS_INCLUDE_DIR}) - add_definitions(-DWITH_LCMS) -endif() - if(NOT WITH_MOD_FLUID) add_definitions(-DDISABLE_ELBEEM) endif() @@ -222,7 +217,7 @@ blender_include_dirs( ../../../../intern/audaspace/intern ../../../../intern/guardedalloc ../../../../intern/memutil - ${GLEW_INCLUDE_PATH} + ${GLEW_INCLUDE_PATH} ) add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC}) diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index c48b479da16..421c3a60691 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -65,9 +65,6 @@ if env['WITH_BF_QUICKTIME']: defs.append('WITH_QUICKTIME') incs += ' ../../quicktime' -if env['WITH_BF_LCMS']: - defs.append('WITH_LCMS') - if env['WITH_BF_GAMEENGINE']: defs.append('WITH_GAMEENGINE') diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index fbf9ffa01d9..587346c4566 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -210,12 +210,12 @@ IDProperty *rna_PropertyGroup_idprops(PointerRNA *ptr, int create) return ptr->data; } -void rna_PropertyGroup_unregister(const bContext *C, StructRNA *type) +void rna_PropertyGroup_unregister(Main *bmain, StructRNA *type) { RNA_struct_free(&BLENDER_RNA, type); } -StructRNA *rna_PropertyGroup_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +StructRNA *rna_PropertyGroup_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { PointerRNA dummyptr; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index e324e59db95..399b039a2d7 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1119,21 +1119,26 @@ int RNA_property_enum_value(bContext *C, PointerRNA *ptr, PropertyRNA *prop, con { EnumPropertyItem *item, *item_array; int free, found; - + RNA_property_enum_items(C, ptr, prop, &item_array, NULL, &free); - - for(item= item_array; item->identifier; item++) { - if(item->identifier[0] && strcmp(item->identifier, identifier)==0) { - *value = item->value; - break; + + if(item_array) { + for(item= item_array; item->identifier; item++) { + if(item->identifier[0] && strcmp(item->identifier, identifier)==0) { + *value = item->value; + break; + } + } + + found= (item->identifier != NULL); /* could be alloc'd, assign before free */ + + if(free) { + MEM_freeN(item_array); } } - - found= (item->identifier != NULL); /* could be alloc'd, assign before free */ - - if(free) - MEM_freeN(item_array); - + else { + found= 0; + } return found; } @@ -4053,8 +4058,9 @@ int RNA_property_is_idprop(PropertyRNA *prop) } /* string representation of a property, python - * compatible but can be used for display too*/ -char *RNA_pointer_as_string(PointerRNA *ptr) + * compatible but can be used for display too, + * context may be NULL */ +char *RNA_pointer_as_string(bContext *C, PointerRNA *ptr) { DynStr *dynstr= BLI_dynstr_new(); char *cstring; @@ -4074,7 +4080,7 @@ char *RNA_pointer_as_string(PointerRNA *ptr) BLI_dynstr_append(dynstr, ", "); first_time= 0; - cstring = RNA_property_as_string(NULL, ptr, prop); + cstring = RNA_property_as_string(C, ptr, prop); BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring); MEM_freeN(cstring); } @@ -4192,7 +4198,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop) case PROP_POINTER: { PointerRNA tptr= RNA_property_pointer_get(ptr, prop); - cstring= RNA_pointer_as_string(&tptr); + cstring= RNA_pointer_as_string(C, &tptr); BLI_dynstr_append(dynstr, cstring); MEM_freeN(cstring); break; @@ -4211,7 +4217,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop) first_time= 0; /* now get every prop of the collection */ - cstring= RNA_pointer_as_string(&itemptr); + cstring= RNA_pointer_as_string(C, &itemptr); BLI_dynstr_append(dynstr, cstring); MEM_freeN(cstring); } diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 951d0e053ff..7f817aa5b4b 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -188,7 +188,7 @@ static StructRNA *rna_KeyingSetInfo_refine(PointerRNA *ptr) return (ksi->ext.srna)? ksi->ext.srna: &RNA_KeyingSetInfo; } -static void rna_KeyingSetInfo_unregister(const bContext *C, StructRNA *type) +static void rna_KeyingSetInfo_unregister(Main *bmain, StructRNA *type) { KeyingSetInfo *ksi= RNA_struct_blender_type_get(type); @@ -200,10 +200,10 @@ static void rna_KeyingSetInfo_unregister(const bContext *C, StructRNA *type) RNA_struct_free(&BLENDER_RNA, type); /* unlink Blender-side data */ - ANIM_keyingset_info_unregister(C, ksi); + ANIM_keyingset_info_unregister(bmain, ksi); } -static StructRNA *rna_KeyingSetInfo_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { KeyingSetInfo dummyksi = {NULL}; KeyingSetInfo *ksi; @@ -226,7 +226,7 @@ static StructRNA *rna_KeyingSetInfo_register(bContext *C, ReportList *reports, v /* check if we have registered this info before, and remove it */ ksi = ANIM_keyingset_info_find_named(dummyksi.idname); if (ksi && ksi->ext.srna) - rna_KeyingSetInfo_unregister(C, ksi->ext.srna); + rna_KeyingSetInfo_unregister(bmain, ksi->ext.srna); /* create a new KeyingSetInfo type */ ksi= MEM_callocN(sizeof(KeyingSetInfo), "python keying set info"); diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 1b07b224f87..d398bb4bb78 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -149,7 +149,20 @@ static void rna_Armature_redraw_data(Main *bmain, Scene *scene, PointerRNA *ptr) static char *rna_Bone_path(PointerRNA *ptr) { - return BLI_sprintfN("bones[\"%s\"]", ((Bone*)ptr->data)->name); + Bone *bone = (Bone*)ptr->data; + + /* special exception for trying to get the path where ID-block is Object + * - this will be assumed to be from a Pose Bone... + */ + if (ptr->id.data) { + ID *id = (ID *)ptr->id.data; + + if (GS(id->name) == ID_OB) + return BLI_sprintfN("pose.bones[\"%s\"].bone", bone->name); + } + + /* from armature... */ + return BLI_sprintfN("bones[\"%s\"]", bone->name); } static IDProperty *rna_Bone_idprops(PointerRNA *ptr, int create) diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 34b1dc85881..1705e2e5376 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -67,6 +67,16 @@ void RNA_def_camera(BlenderRNA *brna) {CAM_PERSP, "PERSP", 0, "Perspective", ""}, {CAM_ORTHO, "ORTHO", 0, "Orthographic", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem prop_draw_type_extra_items[] = { + {CAM_DTX_CENTER, "CENTER", 0, "Center", ""}, + {CAM_DTX_CENTER_DIAG, "CENTER_DIAGONAL", 0, "Center Diagonal", ""}, + {CAM_DTX_THIRDS, "THIRDS", 0, "Thirds", ""}, + {CAM_DTX_GOLDEN, "GOLDEN", 0, "Golden", ""}, + {CAM_DTX_GOLDEN_TRI_A, "GOLDEN_TRIANGLE_A", 0, "Golden Triangle A", ""}, + {CAM_DTX_GOLDEN_TRI_B, "GOLDEN_TRIANGLE_B", 0, "Golden Triangle B", ""}, + {CAM_DTX_HARMONY_TRI_A, "HARMONY_TRIANGLE_A", 0, "Harmonious Triangle A", ""}, + {CAM_DTX_HARMONY_TRI_B, "HARMONY_TRIANGLE_B", 0, "Harmonious Triangle B", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_lens_unit_items[] = { {0, "MILLIMETERS", 0, "Millimeters", ""}, {CAM_ANGLETOGGLE, "DEGREES", 0, "Degrees", ""}, @@ -81,6 +91,13 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_type_items); RNA_def_property_ui_text(prop, "Type", "Camera types"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + + prop= RNA_def_property(srna, "show_guide", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "dtx"); + RNA_def_property_enum_items(prop, prop_draw_type_extra_items); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Composition Guides", "Draw overlay"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); /* Number values */ @@ -91,7 +108,7 @@ void RNA_def_camera(BlenderRNA *brna) prop= RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "clipsta"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_range(prop, 0.001f, FLT_MAX); RNA_def_property_ui_text(prop, "Clip Start", "Camera near clipping distance"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index a8e3500f08f..9709ba7e8f6 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -435,13 +435,13 @@ static void rna_def_color_ramp_element(BlenderRNA *brna) prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Color", ""); + RNA_def_property_ui_text(prop, "Color", "Set color of selected color stop"); RNA_def_property_update(prop, 0, "rna_ColorRamp_update"); prop= RNA_def_property(srna, "position", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pos"); RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Position", ""); + RNA_def_property_ui_text(prop, "Position", "Set position of selected color stop"); RNA_def_property_update(prop, 0, "rna_ColorRamp_update"); } diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 966e679f0fe..e7604b2beb4 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -75,18 +75,25 @@ EnumPropertyItem constraint_type_items[] ={ {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT_DATA, "Shrinkwrap", ""}, {0, NULL, 0, NULL, NULL}}; -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", ""}, +static EnumPropertyItem target_space_pchan_items[] = { + {0, "WORLD", 0, "World Space", "The transformation of the target is evaluated relative to the world coordinate system"}, + {2, "POSE", 0, "Pose Space", "The transformation of the target is only evaluated in the Pose Space, the target armature object transformation is ignored"}, + {3, "LOCAL_WITH_PARENT", 0, "Local With Parent", "The transformation of the target bone is evaluated relative its local coordinate system, with the parent transformation added"}, + {1, "LOCAL", 0, "Local Space", "The transformation of the target is evaluated relative to its local coordinate system"}, + {0, NULL, 0, NULL, NULL}}; + +static EnumPropertyItem owner_space_pchan_items[] = { + {0, "WORLD", 0, "World Space", "The constraint is applied relative to the world coordinate system"}, + {2, "POSE", 0, "Pose Space", "The constraint is applied in Pose Space, the object transformation is ignored"}, + {3, "LOCAL_WITH_PARENT", 0, "The constraint is applied relative to the local coordinate system of the object, with the parent transformation added"}, + {1, "LOCAL", 0, "Local Space", "The constraint is applied relative to the local coordinate sytem of the object"}, {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME static EnumPropertyItem space_object_items[] = { - {0, "WORLD", 0, "World Space", ""}, - {1, "LOCAL", 0, "Local Space", ""}, + {0, "WORLD", 0, "World Space", "The transformation of the target is evaluated relative to the world coordinate system"}, + {1, "LOCAL", 0, "Local Space", "The transformation of the target is evaluated relative to its local coordinate system"}, {0, NULL, 0, NULL, NULL}}; #include "BKE_animsys.h" @@ -242,7 +249,7 @@ static EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *C, PointerRN bConstraint *con= (bConstraint*)ptr->data; if(BLI_findindex(&ob->constraints, con) == -1) - return space_pchan_items; + return owner_space_pchan_items; else /* object */ return space_object_items; } @@ -265,7 +272,7 @@ static EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *C, PointerR cti->flush_constraint_targets(con, &targets, 1); if(ct) - return space_pchan_items; + return target_space_pchan_items; } return space_object_items; @@ -318,9 +325,9 @@ static void rna_SplineIKConstraint_joint_bindings_set(PointerRNA *ptr, const flo #else EnumPropertyItem constraint_distance_items[] = { - {LIMITDIST_INSIDE, "LIMITDIST_INSIDE", 0, "Inside", ""}, - {LIMITDIST_OUTSIDE, "LIMITDIST_OUTSIDE", 0, "Outside", ""}, - {LIMITDIST_ONSURFACE, "LIMITDIST_ONSURFACE", 0, "On Surface", ""}, + {LIMITDIST_INSIDE, "LIMITDIST_INSIDE", 0, "Inside", "The object is constrained inside a virtual sphere around the target object, with a radius defined by the limit distance"}, + {LIMITDIST_OUTSIDE, "LIMITDIST_OUTSIDE", 0, "Outside", "The object is constrained outside a virtual sphere around the target object, with a radius defined by the limit distance"}, + {LIMITDIST_ONSURFACE, "LIMITDIST_ONSURFACE", 0, "On Surface", "The object is constrained on the surface of a virtual sphere around the target object, with a radius defined by the limit distance"}, {0, NULL, 0, NULL, NULL} }; @@ -966,7 +973,7 @@ static void rna_def_constraint_action(BlenderRNA *brna) prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act"); - RNA_def_property_ui_text(prop, "Action", ""); + RNA_def_property_ui_text(prop, "Action", "The constraining action"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); @@ -1183,10 +1190,10 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem pivot_items[] = { - {CONSTRAINT_RB_BALL, "BALL", 0, "Ball", ""}, - {CONSTRAINT_RB_HINGE, "HINGE", 0, "Hinge", ""}, - {CONSTRAINT_RB_CONETWIST, "CONE_TWIST", 0, "Cone Twist", ""}, - {CONSTRAINT_RB_GENERIC6DOF, "GENERIC_6_DOF", 0, "Generic 6 DoF", ""}, + {CONSTRAINT_RB_BALL, "BALL", 0, "Ball", "Allows rotations around all axes"}, + {CONSTRAINT_RB_HINGE, "HINGE", 0, "Hinge", "Works in one plane, allows rotations around one axis only"}, + {CONSTRAINT_RB_CONETWIST, "CONE_TWIST", 0, "Cone Twist", "Allows rotations around all axes with limits for the cone and twist axes"}, + {CONSTRAINT_RB_GENERIC6DOF, "GENERIC_6_DOF", 0, "Generic 6 DoF", "No constraints by default, limits can be set individually"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "RigidBodyJointConstraint", "Constraint"); @@ -1788,9 +1795,9 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACE", 0, "Nearest Surface Point", ""}, - {MOD_SHRINKWRAP_PROJECT, "PROJECT", 0, "Project", ""}, - {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", 0, "Nearest Vertex", ""}, + {MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACE", 0, "Nearest Surface Point", "Shrinks the location to the nearest target surface"}, + {MOD_SHRINKWRAP_PROJECT, "PROJECT", 0, "Project", "Shrinks the location to the nearest target surface along a given axis"}, + {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", 0, "Nearest Vertex", "Shrinks the location to the nearest target vertex"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ShrinkwrapConstraint", "Constraint"); @@ -1940,13 +1947,13 @@ static void rna_def_constraint_pivot(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem pivot_rotAxis_items[] = { - {PIVOTCON_AXIS_NONE, "ALWAYS_ACTIVE", 0, "Always", ""}, - {PIVOTCON_AXIS_X_NEG, "NX", 0, "-X Rot", ""}, - {PIVOTCON_AXIS_Y_NEG, "NY", 0, "-Y Rot", ""}, - {PIVOTCON_AXIS_Z_NEG, "NZ", 0, "-Z Rot", ""}, - {PIVOTCON_AXIS_X, "X", 0, "X Rot", ""}, - {PIVOTCON_AXIS_Y, "Y", 0, "Y Rot", ""}, - {PIVOTCON_AXIS_Z, "Z", 0, "Z Rot", ""}, + {PIVOTCON_AXIS_NONE, "ALWAYS_ACTIVE", 0, "Always", "Use the pivot point in every rotation"}, + {PIVOTCON_AXIS_X_NEG, "NX", 0, "-X Rot", "Use the pivot point in the negative rotation range around the X-axis"}, + {PIVOTCON_AXIS_Y_NEG, "NY", 0, "-Y Rot", "Use the pivot point in the negative rotation range around the Y-axis"}, + {PIVOTCON_AXIS_Z_NEG, "NZ", 0, "-Z Rot", "Use the pivot point in the negative rotation range around the Z-axis"}, + {PIVOTCON_AXIS_X, "X", 0, "X Rot", "Use the pivot point in the positive rotation range around the X-axis"}, + {PIVOTCON_AXIS_Y, "Y", 0, "Y Rot", "Use the pivot point in the positive rotation range around the Y-axis"}, + {PIVOTCON_AXIS_Z, "Z", 0, "Z Rot", "Use the pivot point in the positive rotation range around the Z-axis"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "PivotConstraint", "Constraint"); @@ -2019,13 +2026,13 @@ void RNA_def_constraint(BlenderRNA *brna) prop= RNA_def_property(srna, "owner_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ownspace"); - RNA_def_property_enum_items(prop, space_pchan_items); + RNA_def_property_enum_items(prop, owner_space_pchan_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf"); RNA_def_property_ui_text(prop, "Owner Space", "Space that owner is evaluated in"); prop= RNA_def_property(srna, "target_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "tarspace"); - RNA_def_property_enum_items(prop, space_pchan_items); + RNA_def_property_enum_items(prop, target_space_pchan_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_target_space_itemf"); RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in"); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index acec2ca7a24..7c93ae4168b 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -195,6 +195,18 @@ static char *rna_FluidSettings_path(PointerRNA *ptr) return BLI_sprintfN("modifiers[\"%s\"].settings", md->name); } +static void rna_FluidMeshVertex_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + FluidsimSettings *fss = (FluidsimSettings*)ptr->data; + rna_iterator_array_begin(iter, fss->meshVelocities, sizeof(float)*3, fss->totvert, 0, NULL); +} + +static int rna_FluidMeshVertex_data_length(PointerRNA *ptr) +{ + FluidsimSettings *fss = (FluidsimSettings*)ptr->data; + return fss->totvert; +} + #else static void rna_def_fluidsim_slip(StructRNA *srna) @@ -219,6 +231,24 @@ static void rna_def_fluidsim_slip(StructRNA *srna) RNA_def_property_ui_text(prop, "Partial Slip Amount", "Amount of mixing between no- and free-slip, 0 is no slip and 1 is free slip"); } +static void rna_def_fluid_mesh_vertices(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "FluidMeshVertex", NULL); + RNA_def_struct_sdna(srna, "FluidVertexVelocity"); + RNA_def_struct_ui_text(srna, "Fluid Mesh Vertex", "Vertex of a simulated fluid mesh"); + RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL); + + prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY); + RNA_def_property_array(prop, 3); + RNA_def_property_float_sdna(prop, NULL, "vel"); + RNA_def_property_ui_text(prop, "Velocity", ""); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); +} + + static void rna_def_fluidsim_domain(BlenderRNA *brna) { StructRNA *srna; @@ -367,6 +397,13 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0.0, 10.0); RNA_def_property_ui_text(prop, "Generate Particles", "Amount of particles to generate (0=off, 1=normal, >1=more)"); + + /* simulated fluid mesh data */ + prop= RNA_def_property(srna, "fluid_mesh_vertices", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "FluidMeshVertex"); + RNA_def_property_ui_text(prop, "Fluid Mesh Vertices", "Vertices of the fluid mesh generated by simulation"); + RNA_def_property_collection_funcs(prop, "rna_FluidMeshVertex_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_FluidMeshVertex_data_length", 0, 0); + rna_def_fluid_mesh_vertices(brna); } static void rna_def_fluidsim_volume(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 5872542d10a..3db90c2de0e 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -221,6 +221,39 @@ static void rna_Image_size_get(PointerRNA *ptr,int *values) BKE_image_release_ibuf(im, lock); } +static void rna_Image_resolution_get(PointerRNA *ptr, float *values) +{ + Image *im= (Image*)ptr->data; + ImBuf *ibuf; + void *lock; + + ibuf = BKE_image_acquire_ibuf(im, NULL , &lock); + if (ibuf) { + values[0]= ibuf->ppm[0]; + values[1]= ibuf->ppm[1]; + } + else { + values[0]= 0; + values[1]= 0; + } + + BKE_image_release_ibuf(im, lock); +} + +static void rna_Image_resolution_set(PointerRNA *ptr, const float *values) +{ + Image *im= (Image*)ptr->data; + ImBuf *ibuf; + void *lock; + + ibuf = BKE_image_acquire_ibuf(im, NULL , &lock); + if (ibuf) { + ibuf->ppm[0]= values[0]; + ibuf->ppm[1]= values[1]; + } + + BKE_image_release_ibuf(im, lock); +} static int rna_Image_depth_get(PointerRNA *ptr) { @@ -557,6 +590,9 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_int_funcs(prop, "rna_Image_size_get" , NULL, NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); + prop= RNA_def_float_vector(srna, "resolution" , 2 , NULL , 0, 0, "Resolution" , "X/Y pixels per meter" , 0 , 0); + RNA_def_property_float_funcs(prop, "rna_Image_resolution_get" , "rna_Image_resolution_set", NULL); + prop= RNA_def_property(srna, "pixels", PROP_FLOAT, PROP_NONE); RNA_def_property_flag(prop, PROP_DYNAMIC); RNA_def_property_multi_array(prop, 1, NULL); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 568a09dd4bd..955f9e97ffb 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -203,8 +203,8 @@ struct StructRNA *rna_ID_refine(struct PointerRNA *ptr); struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, int create); void rna_ID_fake_user_set(struct PointerRNA *ptr, int value); struct IDProperty *rna_PropertyGroup_idprops(struct PointerRNA *ptr, int create); -void rna_PropertyGroup_unregister(const struct bContext *C, struct StructRNA *type); -struct StructRNA *rna_PropertyGroup_register(struct bContext *C, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); +void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type); +struct StructRNA *rna_PropertyGroup_register(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); struct StructRNA* rna_PropertyGroup_refine(struct PointerRNA *ptr); void rna_object_vgroup_name_index_get(struct PointerRNA *ptr, char *value, int index); diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 3f0ccf99266..3e65eb8665e 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -521,7 +521,7 @@ static void rna_def_keyblock(BlenderRNA *brna) RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_ui_text(prop, "Name", "Name of Shape Key"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ShapeKey_name_set"); RNA_def_struct_name_property(srna, prop); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 81afac6caec..2cf25e216ea 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -743,7 +743,7 @@ static void rna_def_material_colors(StructRNA *srna) prop= RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Diffuse Color", ""); + RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the material"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); prop= RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR); @@ -797,25 +797,25 @@ static void rna_def_material_colors(StructRNA *srna) prop= RNA_def_property(srna, "diffuse_ramp_blend", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "rampblend_col"); RNA_def_property_enum_items(prop, ramp_blend_items); - RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", ""); + RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", "Blending method of the ramp and the diffuse color"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "specular_ramp_blend", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "rampblend_spec"); RNA_def_property_enum_items(prop, ramp_blend_items); - RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", ""); + RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", "Blending method of the ramp and the specular color"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "diffuse_ramp_input", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "rampin_col"); RNA_def_property_enum_items(prop, prop_ramp_input_items); - RNA_def_property_ui_text(prop, "Diffuse Ramp Input", ""); + RNA_def_property_ui_text(prop, "Diffuse Ramp Input", "Determines how the ramp maps on the surface"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "specular_ramp_input", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "rampin_spec"); RNA_def_property_enum_items(prop, prop_ramp_input_items); - RNA_def_property_ui_text(prop, "Specular Ramp Input", ""); + RNA_def_property_ui_text(prop, "Specular Ramp Input", "Determines how the ramp maps on the surface"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "diffuse_ramp_factor", PROP_FLOAT, PROP_FACTOR); @@ -836,11 +836,11 @@ static void rna_def_material_diffuse(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem prop_diff_shader_items[] = { - {MA_DIFF_LAMBERT, "LAMBERT", 0, "Lambert", ""}, - {MA_DIFF_ORENNAYAR, "OREN_NAYAR", 0, "Oren-Nayar", ""}, - {MA_DIFF_TOON, "TOON", 0, "Toon", ""}, - {MA_DIFF_MINNAERT, "MINNAERT", 0, "Minnaert", ""}, - {MA_DIFF_FRESNEL, "FRESNEL", 0, "Fresnel", ""}, + {MA_DIFF_LAMBERT, "LAMBERT", 0, "Lambert", "Use a Lambertian shader"}, + {MA_DIFF_ORENNAYAR, "OREN_NAYAR", 0, "Oren-Nayar", "Use an Oren-Nayar shader"}, + {MA_DIFF_TOON, "TOON", 0, "Toon", "Use a toon shader"}, + {MA_DIFF_MINNAERT, "MINNAERT", 0, "Minnaert", "Use a Minnaert shader"}, + {MA_DIFF_FRESNEL, "FRESNEL", 0, "Fresnel", "Use a Fresnel shader"}, {0, NULL, 0, NULL, NULL}}; prop= RNA_def_property(srna, "diffuse_shader", PROP_ENUM, PROP_NONE); @@ -1048,7 +1048,7 @@ static void rna_def_material_volume(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_lighting_items[] = { - {MA_VOL_SHADE_SHADELESS, "SHADELESS", 0, "Shadeless", ""}, + {MA_VOL_SHADE_SHADELESS, "SHADELESS", 0, "Shadeless", "Do not calculate lighting and shadows"}, {MA_VOL_SHADE_SHADOWED, "SHADOWED", 0, "Shadowed", ""}, {MA_VOL_SHADE_SHADED, "SHADED", 0, "Shaded", ""}, {MA_VOL_SHADE_MULTIPLE, "MULTIPLE_SCATTERING", 0, "Multiple Scattering", ""}, @@ -1168,7 +1168,7 @@ static void rna_def_material_volume(BlenderRNA *brna) prop= RNA_def_property(srna, "emission_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "emission_col"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Emission Color", ""); + RNA_def_property_ui_text(prop, "Emission Color", "Color of emitted light"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); prop= RNA_def_property(srna, "emission", PROP_FLOAT, PROP_NONE); @@ -1389,11 +1389,11 @@ static void rna_def_material_specularity(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem prop_specular_shader_items[] = { - {MA_SPEC_COOKTORR, "COOKTORR", 0, "CookTorr", ""}, - {MA_SPEC_PHONG, "PHONG", 0, "Phong", ""}, - {MA_SPEC_BLINN, "BLINN", 0, "Blinn", ""}, - {MA_SPEC_TOON, "TOON", 0, "Toon", ""}, - {MA_SPEC_WARDISO, "WARDISO", 0, "WardIso", ""}, + {MA_SPEC_COOKTORR, "COOKTORR", 0, "CookTorr", "Use a Cook-Torrance shader"}, + {MA_SPEC_PHONG, "PHONG", 0, "Phong", "Use a Phong shader"}, + {MA_SPEC_BLINN, "BLINN", 0, "Blinn", "Use a Blinn shader"}, + {MA_SPEC_TOON, "TOON", 0, "Toon", "Use a toon shader"}, + {MA_SPEC_WARDISO, "WARDISO", 0, "WardIso", "Use a Ward anisotropic shader"}, {0, NULL, 0, NULL, NULL}}; prop= RNA_def_property(srna, "specular_shader", PROP_ENUM, PROP_NONE); @@ -1405,7 +1405,7 @@ static void rna_def_material_specularity(StructRNA *srna) prop= RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "spec"); RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Specular Intensity", ""); + RNA_def_property_ui_text(prop, "Specular Intensity", "How intense (bright) the specular reflection is"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); /* NOTE: "har", "param", etc are used for multiple purposes depending on @@ -1416,13 +1416,13 @@ static void rna_def_material_specularity(StructRNA *srna) prop= RNA_def_property(srna, "specular_hardness", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "har"); RNA_def_property_range(prop, 1, 511); - RNA_def_property_ui_text(prop, "Specular Hardness", ""); + RNA_def_property_ui_text(prop, "Specular Hardness", "How hard (sharp) the specular reflection is"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); prop= RNA_def_property(srna, "specular_ior", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "refrac"); RNA_def_property_range(prop, 1, 10); - RNA_def_property_ui_text(prop, "Specular IOR", ""); + RNA_def_property_ui_text(prop, "Specular IOR", "Specular index of refraction"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop= RNA_def_property(srna, "specular_toon_size", PROP_FLOAT, PROP_NONE); @@ -1585,9 +1585,9 @@ void RNA_def_material(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_shadows_only_items[] = { - {MA_SO_OLD, "SHADOW_ONLY_OLD", 0, "Shadow and Distance", ""}, - {MA_SO_SHADOW, "SHADOW_ONLY", 0, "Shadow Only", ""}, - {MA_SO_SHADED, "SHADOW_ONLY_SHADED", 0, "Shadow and Shading", ""}, + {MA_SO_OLD, "SHADOW_ONLY_OLD", 0, "Shadow and Distance", "Old shadow only method"}, + {MA_SO_SHADOW, "SHADOW_ONLY", 0, "Shadow Only", "Improved shadow only method"}, + {MA_SO_SHADED, "SHADOW_ONLY_SHADED", 0, "Shadow and Shading", "Improved shadow only method which also renders lightless areas as shadows"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Material", "ID"); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 03c79af1907..9e5a2e9f65a 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1346,7 +1346,7 @@ static void rna_def_mtface(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_struct_name_property(srna, prop); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshTextureFaceLayer_name_set"); - RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_ui_text(prop, "Name", "Name of UV unwrapping layer"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); @@ -1530,7 +1530,7 @@ static void rna_def_mcol(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_struct_name_property(srna, prop); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshColorLayer_name_set"); - RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_ui_text(prop, "Name", "Name of Vertex color layer"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index c1289374681..87bbea334db 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -65,7 +65,7 @@ void RNA_api_mesh(StructRNA *srna) func= RNA_def_function(srna, "validate", "BKE_mesh_validate"); RNA_def_function_ui_description(func, "validate geometry, return True when the mesh has had invalid geometry corrected/removed."); - parm= RNA_def_boolean(func, "verbose", 0, "Verbose", "Output information about the errors found"); + RNA_def_boolean(func, "verbose", 0, "Verbose", "Output information about the errors found"); parm= RNA_def_boolean(func, "result", 0, "Result", ""); RNA_def_function_return(func, parm); } diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 18a93b9defb..333451e1d31 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -79,7 +79,7 @@ EnumPropertyItem modifier_type_items[] ={ {eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""}, {eModifierType_SimpleDeform, "SIMPLE_DEFORM", ICON_MOD_SIMPLEDEFORM, "Simple Deform", ""}, {eModifierType_Smooth, "SMOOTH", ICON_MOD_SMOOTH, "Smooth", ""}, - {eModifierType_Warp, "WARP", ICON_MOD_SUBSURF, "Warp", ""}, + {eModifierType_Warp, "WARP", ICON_MOD_SUBSURF, "Warp", ""}, {eModifierType_Wave, "WAVE", ICON_MOD_WAVE, "Wave", ""}, {0, "", 0, "Simulate", ""}, {eModifierType_Cloth, "CLOTH", ICON_MOD_CLOTH, "Cloth", ""}, @@ -631,10 +631,10 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna) static void rna_def_modifier_generic_map_info(StructRNA *srna) { static EnumPropertyItem prop_texture_coordinates_items[] = { - {MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Map", ""}, - {MOD_DISP_MAP_GLOBAL, "GLOBAL", 0, "Global", ""}, - {MOD_DISP_MAP_OBJECT, "OBJECT", 0, "Object", ""}, - {MOD_DISP_MAP_UV, "UV", 0, "UV", ""}, + {MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Map", "Uses the local coordinate system for the texture coordinates"}, + {MOD_DISP_MAP_GLOBAL, "GLOBAL", 0, "Global", "Uses the global coordinate system for the texture coordinates"}, + {MOD_DISP_MAP_OBJECT, "OBJECT", 0, "Object", "Uses the linked object's local coordinate system for the texture coordinates"}, + {MOD_DISP_MAP_UV, "UV", 0, "UV", "Uses UV coordinates for the texture coordinates"}, {0, NULL, 0, NULL, NULL}}; PropertyRNA *prop; @@ -656,9 +656,9 @@ static void rna_def_modifier_generic_map_info(StructRNA *srna) RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MappingInfo_uvlayer_set"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - prop= RNA_def_property(srna, "texture_coordinate_object", PROP_POINTER, PROP_NONE); + prop= RNA_def_property(srna, "texture_coords_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "map_object"); - RNA_def_property_ui_text(prop, "Texture Coordinate Object", ""); + RNA_def_property_ui_text(prop, "Texture Coordinate Object", "Object to set the texture coordinates"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); } @@ -754,7 +754,7 @@ static void rna_def_modifier_multires(BlenderRNA *brna) prop= RNA_def_property(srna, "render_levels", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "renderlvl"); - RNA_def_property_ui_text(prop, "Render Levels", ""); + RNA_def_property_ui_text(prop, "Render Levels", "The subdivision level visible at render time"); RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MultiresModifier_level_range"); prop= RNA_def_property(srna, "total_levels", PROP_INT, PROP_UNSIGNED); @@ -1020,39 +1020,39 @@ static void rna_def_modifier_wave(BlenderRNA *brna) prop= RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "lifetime"); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); - RNA_def_property_ui_text(prop, "Lifetime", ""); + RNA_def_property_ui_text(prop, "Lifetime", "Lifetime of the wave in frames, zero means infinite"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "damping_time", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "damp"); RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF); - RNA_def_property_ui_text(prop, "Damping Time", ""); + RNA_def_property_ui_text(prop, "Damping Time", "Number of frames in which the waves damps out after it dies"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "falloff"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 100, 100, 2); - RNA_def_property_ui_text(prop, "Falloff Radius", ""); + RNA_def_property_ui_text(prop, "Falloff Radius", "Distance after which it fades out"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "start_position_x", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "startx"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 100, 2); - RNA_def_property_ui_text(prop, "Start Position X", ""); + RNA_def_property_ui_text(prop, "Start Position X", "X coordinate of the start position"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "start_position_y", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "starty"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 100, 2); - RNA_def_property_ui_text(prop, "Start Position Y", ""); + RNA_def_property_ui_text(prop, "Start Position Y", "Z coordinate of the start position"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "start_position_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "objectcenter"); - RNA_def_property_ui_text(prop, "Start Position Object", ""); + RNA_def_property_ui_text(prop, "Start Position Object", "Object which defines the wave center"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); @@ -1088,26 +1088,26 @@ static void rna_def_modifier_wave(BlenderRNA *brna) prop= RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -1, 1, 10, 2); - RNA_def_property_ui_text(prop, "Speed", ""); + RNA_def_property_ui_text(prop, "Speed", "Speed of the wave, towards the starting point when negative"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -2, 2, 10, 2); - RNA_def_property_ui_text(prop, "Height", ""); + RNA_def_property_ui_text(prop, "Height", "Height of the wave"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "width", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 5, 10, 2); - RNA_def_property_ui_text(prop, "Width", ""); + RNA_def_property_ui_text(prop, "Width", "Distance between the waves"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "narrowness", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "narrow"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 10, 10, 2); - RNA_def_property_ui_text(prop, "Narrowness", ""); + RNA_def_property_ui_text(prop, "Narrowness", "Distance between the top and the base of a wave, the higher the value, the more narrow the wave"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); } @@ -1129,12 +1129,12 @@ static void rna_def_modifier_armature(BlenderRNA *brna) prop= RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE); - RNA_def_property_ui_text(prop, "Use Bone Envelopes", ""); + RNA_def_property_ui_text(prop, "Use Bone Envelopes", "Binds Bone envelope to armature modifier"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "use_vertex_groups", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP); - RNA_def_property_ui_text(prop, "Use Vertex Groups", ""); + RNA_def_property_ui_text(prop, "Use Vertex Groups", "Binds vertex group to armature modifier"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE); @@ -1226,9 +1226,9 @@ static void rna_def_modifier_boolean(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_operation_items[] = { - {eBooleanModifierOp_Intersect, "INTERSECT", 0, "Intersect", ""}, - {eBooleanModifierOp_Union, "UNION", 0, "Union", ""}, - {eBooleanModifierOp_Difference, "DIFFERENCE", 0, "Difference", ""}, + {eBooleanModifierOp_Intersect, "INTERSECT", 0, "Intersect", "Keeps the part of the mesh that intersects with the other selected object"}, + {eBooleanModifierOp_Union, "UNION", 0, "Union", "Combines two meshes in an additive way"}, + {eBooleanModifierOp_Difference, "DIFFERENCE", 0, "Difference", "Combines two meshes in a subtractive way"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "BooleanModifier", "Modifier"); @@ -1254,9 +1254,9 @@ static void rna_def_modifier_array(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_fit_type_items[] = { - {MOD_ARR_FIXEDCOUNT, "FIXED_COUNT", 0, "Fixed Count", ""}, - {MOD_ARR_FITLENGTH, "FIT_LENGTH", 0, "Fit Length", ""}, - {MOD_ARR_FITCURVE, "FIT_CURVE", 0, "Fit Curve", ""}, + {MOD_ARR_FIXEDCOUNT, "FIXED_COUNT", 0, "Fixed Count", "Duplicate the object a certain number of times"}, + {MOD_ARR_FITLENGTH, "FIT_LENGTH", 0, "Fit Length", "Duplicate the object as many times as fits in a certain length"}, + {MOD_ARR_FITCURVE, "FIT_CURVE", 0, "Fit Curve", "Fit the duplicated objects to a curve"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ArrayModifier", "Modifier"); @@ -1298,7 +1298,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) prop= RNA_def_property(srna, "constant_offset_displace", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "offset"); - RNA_def_property_ui_text(prop, "Constant Offset Displacement", ""); + RNA_def_property_ui_text(prop, "Constant Offset Displacement", "Value for the distance between arrayed items"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "use_relative_offset", PROP_BOOLEAN, PROP_NONE); @@ -1308,7 +1308,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) prop= RNA_def_property(srna, "relative_offset_displace", PROP_FLOAT, PROP_NONE); /* PROP_TRANSLATION causes units to be used which we dont want */ RNA_def_property_float_sdna(prop, NULL, "scale"); - RNA_def_property_ui_text(prop, "Relative Offset Displacement", ""); + RNA_def_property_ui_text(prop, "Relative Offset Displacement", "The size of the geometry will determine the distance between arrayed items"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); /* Vertex merging parameters */ @@ -1337,7 +1337,7 @@ static void rna_def_modifier_array(BlenderRNA *brna) prop= RNA_def_property(srna, "offset_object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "offset_ob"); - RNA_def_property_ui_text(prop, "Object Offset", ""); + RNA_def_property_ui_text(prop, "Object Offset", "Uses the location and rotation of another object to determine the distance and rotational change between arrayed items"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); @@ -1389,11 +1389,11 @@ static void rna_def_modifier_displace(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_direction_items[] = { - {MOD_DISP_DIR_X, "X", 0, "X", ""}, - {MOD_DISP_DIR_Y, "Y", 0, "Y", ""}, - {MOD_DISP_DIR_Z, "Z", 0, "Z", ""}, - {MOD_DISP_DIR_NOR, "NORMAL", 0, "Normal", ""}, - {MOD_DISP_DIR_RGB_XYZ, "RGB_TO_XYZ", 0, "RGB to XYZ", ""}, + {MOD_DISP_DIR_X, "X", 0, "X", "Uses the texture's intensity value to displace in the X direction"}, + {MOD_DISP_DIR_Y, "Y", 0, "Y", "Uses the texture's intensity value to displace in the Y direction"}, + {MOD_DISP_DIR_Z, "Z", 0, "Z", "Uses the texture's intensity value to displace in the Z direction"}, + {MOD_DISP_DIR_NOR, "NORMAL", 0, "Normal", "Uses the texture's intensity value to displace in the normal direction"}, + {MOD_DISP_DIR_RGB_XYZ, "RGB_TO_XYZ", 0, "RGB to XYZ", "Uses the texture's RGB values to displace the mesh in the XYZ direction"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "DisplaceModifier", "Modifier"); @@ -1409,7 +1409,7 @@ static void rna_def_modifier_displace(BlenderRNA *brna) prop= RNA_def_property(srna, "mid_level", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "midlevel"); - RNA_def_property_range(prop, 0, 1); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Midlevel", "Material value that gives no displacement"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); @@ -1417,7 +1417,7 @@ static void rna_def_modifier_displace(BlenderRNA *brna) prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 10, 3); - RNA_def_property_ui_text(prop, "Strength", ""); + RNA_def_property_ui_text(prop, "Strength", "Amount to displace geometry"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); @@ -1517,24 +1517,24 @@ static void rna_def_modifier_smooth(BlenderRNA *brna) prop= RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SMOOTH_X); - RNA_def_property_ui_text(prop, "X", ""); + RNA_def_property_ui_text(prop, "X", "Smooth object along X axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SMOOTH_Y); - RNA_def_property_ui_text(prop, "Y", ""); + RNA_def_property_ui_text(prop, "Y", "Smooth object along Y axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SMOOTH_Z); - RNA_def_property_ui_text(prop, "Z", ""); + RNA_def_property_ui_text(prop, "Z", "Smooth object along Z axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fac"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -10, 10, 1, 3); - RNA_def_property_ui_text(prop, "Factor", ""); + RNA_def_property_ui_text(prop, "Factor", "Strength of modifier effect"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); @@ -1569,7 +1569,7 @@ static void rna_def_modifier_cast(BlenderRNA *brna) prop= RNA_def_property(srna, "cast_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); RNA_def_property_enum_items(prop, prop_cast_type_items); - RNA_def_property_ui_text(prop, "Cast Type", ""); + RNA_def_property_ui_text(prop, "Cast Type", "Target object shape"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); @@ -1979,9 +1979,9 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem shrink_type_items[] = { - {MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACEPOINT", 0, "Nearest Surface Point", ""}, - {MOD_SHRINKWRAP_PROJECT, "PROJECT", 0, "Project", ""}, - {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", 0, "Nearest Vertex", ""}, + {MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACEPOINT", 0, "Nearest Surface Point", "Shrinks the mesh to the nearest target surface"}, + {MOD_SHRINKWRAP_PROJECT, "PROJECT", 0, "Project", "Shrinks the mesh to the nearest target surface along a given axis"}, + {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", 0, "Nearest Vertex", "Shrinks the mesh to the nearest target vertex"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem shrink_face_cull_items[] = { @@ -2133,10 +2133,10 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem simple_deform_mode_items[] = { - {MOD_SIMPLEDEFORM_MODE_TWIST, "TWIST", 0, "Twist", ""}, - {MOD_SIMPLEDEFORM_MODE_BEND, "BEND", 0, "Bend", ""}, - {MOD_SIMPLEDEFORM_MODE_TAPER, "TAPER", 0, "Taper", ""}, - {MOD_SIMPLEDEFORM_MODE_STRETCH, "STRETCH", 0, "Stretch", ""}, + {MOD_SIMPLEDEFORM_MODE_TWIST, "TWIST", 0, "Twist", "Rotates around the Z axis of the modifier space"}, + {MOD_SIMPLEDEFORM_MODE_BEND, "BEND", 0, "Bend", "Bends the mesh over the Z axis of the modifier space"}, + {MOD_SIMPLEDEFORM_MODE_TAPER, "TAPER", 0, "Taper", "Linearly scales along Z axis of the modifier space"}, + {MOD_SIMPLEDEFORM_MODE_STRETCH, "STRETCH", 0, "Stretch", "Stretches the object along the Z axis of the modifier space"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SimpleDeformModifier", "Modifier"); @@ -2169,7 +2169,7 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna) prop= RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -10, 10, 1, 3); - RNA_def_property_ui_text(prop, "Factor", ""); + RNA_def_property_ui_text(prop, "Factor", "Amount to deform object"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "limits", PROP_FLOAT, PROP_NONE); @@ -2182,12 +2182,12 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna) prop= RNA_def_property(srna, "lock_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "axis", MOD_SIMPLEDEFORM_LOCK_AXIS_X); - RNA_def_property_ui_text(prop, "Lock X Axis", ""); + RNA_def_property_ui_text(prop, "Lock X Axis", "Do not allow tapering along the X axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop= RNA_def_property(srna, "lock_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "axis", MOD_SIMPLEDEFORM_LOCK_AXIS_Y); - RNA_def_property_ui_text(prop, "Lock Y Axis", ""); + RNA_def_property_ui_text(prop, "Lock Y Axis", "Do not allow tapering along the Y axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 63241c339f6..c67830a01ae 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1692,6 +1692,9 @@ static void def_cmp_output_file(StructRNA *srna) {R_TARGA, "TARGA", 0, "Targa", ""}, {R_RAWTGA, "RAW_TARGA", 0, "Targa Raw", ""}, {R_PNG, "PNG", 0, "PNG", ""}, +#ifdef WITH_DDS + {R_DDS, "DDS", 0, "DirectDraw Surface", ""}, +#endif {R_BMP, "BMP", 0, "BMP", ""}, {R_JPEG90, "JPEG", 0, "JPEG", ""}, {R_IRIS, "IRIS", 0, "IRIS", ""}, diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 11e7dd81cb6..4407ca8ad4e 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -68,14 +68,14 @@ EnumPropertyItem object_mode_items[] = { {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem parent_type_items[] = { - {PAROBJECT, "OBJECT", 0, "Object", ""}, - {PARCURVE, "CURVE", 0, "Curve", ""}, + {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"}, + {PARCURVE, "CURVE", 0, "Curve", "The object is parented to a curve"}, {PARKEY, "KEY", 0, "Key", ""}, {PARSKEL, "ARMATURE", 0, "Armature", ""}, - {PARSKEL, "LATTICE", 0, "Lattice", ""}, // PARSKEL reuse will give issues - {PARVERT1, "VERTEX", 0, "Vertex", ""}, + {PARSKEL, "LATTICE", 0, "Lattice", "The object is parented to a lattice"}, // PARSKEL reuse will give issues + {PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"}, {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""}, - {PARBONE, "BONE", 0, "Bone", ""}, + {PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem collision_bounds_items[] = { @@ -307,22 +307,26 @@ static void rna_Base_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) WM_main_add_notifier(NC_SCENE|ND_LAYER_CONTENT, scene); } -static int rna_Object_data_editable(PointerRNA *ptr) -{ - Object *ob= (Object*)ptr->data; - - return (ob->type == OB_EMPTY)? 0: PROP_EDITABLE; -} - static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) { Object *ob= (Object*)ptr->data; ID *id= value.data; - if(ob->type == OB_EMPTY || id == NULL || ob->mode & OB_MODE_EDIT) + if (id == NULL || ob->mode & OB_MODE_EDIT) return; - - if(ob->type == OB_MESH) { + + if (ob->type == OB_EMPTY) { + if(ob->data) { + id_us_min((ID*)ob->data); + ob->data = NULL; + } + + if (id && GS(id->name) == ID_IM) { + id_us_plus(id); + ob->data = id; + } + } + else if(ob->type == OB_MESH) { set_mesh(ob, (Mesh*)id); } else { @@ -346,6 +350,7 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr) Object *ob= (Object*)ptr->data; switch(ob->type) { + case OB_EMPTY: return &RNA_Image; case OB_MESH: return &RNA_Mesh; case OB_CURVE: return &RNA_Curve; case OB_SURF: return &RNA_Curve; @@ -1691,6 +1696,7 @@ static void rna_def_object(BlenderRNA *brna) {OB_CUBE, "CUBE", 0, "Cube", ""}, {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""}, {OB_EMPTY_CONE, "CONE", 0, "Cone", ""}, + {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem track_items[] = { @@ -1709,20 +1715,20 @@ static void rna_def_object(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem drawtype_items[] = { - {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", ""}, - {OB_WIRE, "WIRE", 0, "Wire", ""}, - {OB_SOLID, "SOLID", 0, "Solid", ""}, + {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Draw the bounding box of the object"}, + {OB_WIRE, "WIRE", 0, "Wire", "Draw the object as a wireframe"}, + {OB_SOLID, "SOLID", 0, "Solid", "Draw the object as a solid (If solid drawing is enabled in the viewport)"}, // disabled {OB_SHADED, "SHADED", 0, "Shaded", ""}, - {OB_TEXTURE, "TEXTURED", 0, "Textured", ""}, + {OB_TEXTURE, "TEXTURED", 0, "Textured", "Draw the object with textures (If textures are enabled in the viewport)"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem boundtype_items[] = { - {OB_BOUND_BOX, "BOX", 0, "Box", ""}, - {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""}, - {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""}, - {OB_BOUND_CONE, "CONE", 0, "Cone", ""}, - {OB_BOUND_POLYH, "POLYHEDRON", 0, "Polyhedron", ""}, - {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", ""}, + {OB_BOUND_BOX, "BOX", 0, "Box", "Draw bounds as box"}, + {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Draw bounds as sphere"}, + {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Draw bounds as cylinder"}, + {OB_BOUND_CONE, "CONE", 0, "Cone", "Draw bounds as cone"}, + {OB_BOUND_POLYH, "POLYHEDRON", 0, "Polyhedron", "Draw bounds as polyhedron"}, + {OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Draw bounds as capsule"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dupli_items[] = { @@ -1758,7 +1764,6 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", NULL); - RNA_def_property_editable_func(prop, "rna_Object_data_editable"); RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Data", "Object data"); RNA_def_property_update(prop, 0, "rna_Object_internal_update_data"); @@ -2043,6 +2048,12 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Empty Display Size", "Size of display for empties in the viewport"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + prop= RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_sdna(prop, NULL, "ima_ofs"); + RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance"); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + /* render */ prop= RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "index"); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index a4fbd7c160e..6955c7f8fa8 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -1055,18 +1055,18 @@ static void rna_def_field(BlenderRNA *brna) static EnumPropertyItem field_type_items[] = { {0, "NONE", 0, "None", ""}, - {PFIELD_FORCE, "FORCE", ICON_FORCE_FORCE, "Force", ""}, - {PFIELD_WIND, "WIND", ICON_FORCE_WIND, "Wind", ""}, - {PFIELD_VORTEX, "VORTEX", ICON_FORCE_VORTEX, "Vortex", ""}, - {PFIELD_MAGNET, "MAGNET", ICON_FORCE_MAGNETIC, "Magnetic", ""}, - {PFIELD_HARMONIC, "HARMONIC", ICON_FORCE_HARMONIC, "Harmonic", ""}, - {PFIELD_CHARGE, "CHARGE", ICON_FORCE_CHARGE, "Charge", ""}, - {PFIELD_LENNARDJ, "LENNARDJ", ICON_FORCE_LENNARDJONES, "Lennard-Jones", ""}, - {PFIELD_TEXTURE, "TEXTURE", ICON_FORCE_TEXTURE, "Texture", ""}, - {PFIELD_GUIDE, "GUIDE", ICON_FORCE_CURVE, "Curve Guide", ""}, + {PFIELD_FORCE, "FORCE", ICON_FORCE_FORCE, "Force", "Gives a radial field toward the center of object"}, + {PFIELD_WIND, "WIND", ICON_FORCE_WIND, "Wind", "Gives a constant force along the force object’s local Z axis"}, + {PFIELD_VORTEX, "VORTEX", ICON_FORCE_VORTEX, "Vortex", "Gives a spiraling force that twists the force object’s local Z axis"}, + {PFIELD_MAGNET, "MAGNET", ICON_FORCE_MAGNETIC, "Magnetic", "Forcefield depends on the speed of the particles"}, + {PFIELD_HARMONIC, "HARMONIC", ICON_FORCE_HARMONIC, "Harmonic", "The source of this force field is the zero point of a harmonic oscillator"}, + {PFIELD_CHARGE, "CHARGE", ICON_FORCE_CHARGE, "Charge", "Spherical forcefield based on the charge of particles, only influences other charge force fields"}, + {PFIELD_LENNARDJ, "LENNARDJ", ICON_FORCE_LENNARDJONES, "Lennard-Jones", "Forcefield based on the Lennard-Jones potential"}, + {PFIELD_TEXTURE, "TEXTURE", ICON_FORCE_TEXTURE, "Texture", "Forcefield based on a texture"}, + {PFIELD_GUIDE, "GUIDE", ICON_FORCE_CURVE, "Curve Guide", "Creates a force along a curve object"}, {PFIELD_BOID, "BOID", ICON_FORCE_BOID, "Boid", ""}, - {PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""}, - {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""}, + {PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", "Creates turbulence with a noise field"}, + {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", "Creates a force that dampens motion"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem falloff_items[] = { @@ -1126,7 +1126,7 @@ static void rna_def_field(BlenderRNA *brna) prop= RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "falloff"); RNA_def_property_enum_items(prop, falloff_items); - RNA_def_property_ui_text(prop, "Fall-Off", "Fall-off shape"); + RNA_def_property_ui_text(prop, "Fall-Off", ""); RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop= RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 9fd5fafc712..fa69fad253f 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -1682,7 +1682,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, type_items); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Type", ""); + RNA_def_property_ui_text(prop, "Type", "Particle Type"); RNA_def_property_update(prop, 0, "rna_Particle_change_type"); prop= RNA_def_property(srna, "emit_from", PROP_ENUM, PROP_NONE); @@ -1840,15 +1840,15 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); prop= RNA_def_property(srna, "draw_step", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 0, 7); - RNA_def_property_ui_range(prop, 0, 10, 1, 0); + RNA_def_property_range(prop, 0, 10); + RNA_def_property_ui_range(prop, 0, 7, 1, 0); RNA_def_property_ui_text(prop, "Steps", "How many steps paths are drawn with (power of 2)"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); prop= RNA_def_property(srna, "render_step", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "ren_step"); - RNA_def_property_range(prop, 0, 9); - RNA_def_property_ui_range(prop, 0, 20, 1, 0); + RNA_def_property_range(prop, 0, 20); + RNA_def_property_ui_range(prop, 0, 9, 1, 0); RNA_def_property_ui_text(prop, "Render", "How many steps paths are rendered with (power of 2)"); prop= RNA_def_property(srna, "hair_step", PROP_INT, PROP_NONE); @@ -1896,7 +1896,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "integrator", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, integrator_type_items); - RNA_def_property_ui_text(prop, "Integration", "Select physics integrator type"); + RNA_def_property_ui_text(prop, "Integration", "Algorithm used to calculate physics. Fastest to most stable/accurate: Midpoint, Euler, Verlet, RK4 (Old)"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); prop= RNA_def_property(srna, "kink", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c index 08a3f174c15..9fd5610a577 100644 --- a/source/blender/makesrna/intern/rna_property.c +++ b/source/blender/makesrna/intern/rna_property.c @@ -101,11 +101,11 @@ void RNA_def_gameproperty(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem gameproperty_type_items[] ={ - {GPROP_BOOL, "BOOL", 0, "Boolean", ""}, - {GPROP_INT, "INT", 0, "Integer", ""}, - {GPROP_FLOAT, "FLOAT", 0, "Float", ""}, - {GPROP_STRING, "STRING", 0, "String", ""}, - {GPROP_TIME, "TIMER", 0, "Timer", ""}, + {GPROP_BOOL, "BOOL", 0, "Boolean", "Boolean Property"}, + {GPROP_INT, "INT", 0, "Integer", "Integer Property"}, + {GPROP_FLOAT, "FLOAT", 0, "Float", "Floating-Point Property"}, + {GPROP_STRING, "STRING", 0, "String", "String Property"}, + {GPROP_TIME, "TIMER", 0, "Timer", "Timer Property"}, {0, NULL, 0, NULL, NULL}}; /* Base Struct for GameProperty */ diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 9c41f458de8..fc5fb021d8e 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -160,7 +160,7 @@ static void engine_view_draw(RenderEngine *engine, const struct bContext *contex /* RenderEngine registration */ -static void rna_RenderEngine_unregister(const struct bContext *C, StructRNA *type) +static void rna_RenderEngine_unregister(Main *bmain, StructRNA *type) { RenderEngineType *et= RNA_struct_blender_type_get(type); @@ -172,7 +172,7 @@ static void rna_RenderEngine_unregister(const struct bContext *C, StructRNA *typ RNA_struct_free(&BLENDER_RNA, type); } -static StructRNA *rna_RenderEngine_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { RenderEngineType *et, dummyet = {NULL}; RenderEngine dummyengine= {NULL}; @@ -196,7 +196,7 @@ static StructRNA *rna_RenderEngine_register(bContext *C, ReportList *reports, vo for(et=R_engines.first; et; et=et->next) { if(strcmp(et->idname, dummyet.idname) == 0) { if(et->ext.srna) - rna_RenderEngine_unregister(C, et->ext.srna); + rna_RenderEngine_unregister(bmain, et->ext.srna); break; } } @@ -452,8 +452,8 @@ static void rna_def_render_layer(BlenderRNA *brna) RNA_def_function_flag(func, FUNC_USE_REPORTS); prop= RNA_def_string(func, "filename", "", 0, "Filename", "Filename to load into this render tile, must be no smaller than the renderlayer"); RNA_def_property_flag(prop, PROP_REQUIRED); - prop= RNA_def_int(func, "x", 0, 0, INT_MAX, "Offset X", "Offset the position to copy from if the image is larger than the render layer", 0, INT_MAX); - prop= RNA_def_int(func, "y", 0, 0, INT_MAX, "Offset Y", "Offset the position to copy from if the image is larger than the render layer", 0, INT_MAX); + RNA_def_int(func, "x", 0, 0, INT_MAX, "Offset X", "Offset the position to copy from if the image is larger than the render layer", 0, INT_MAX); + RNA_def_int(func, "y", 0, 0, INT_MAX, "Offset Y", "Offset the position to copy from if the image is larger than the render layer", 0, INT_MAX); RNA_define_verify_sdna(0); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 194c18cd458..1991312babc 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -70,13 +70,13 @@ EnumPropertyItem snap_target_items[] = { {0, NULL, 0, NULL, NULL}}; EnumPropertyItem proportional_falloff_items[] ={ - {PROP_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""}, - {PROP_SPHERE, "SPHERE", ICON_SPHERECURVE, "Sphere", ""}, - {PROP_ROOT, "ROOT", ICON_ROOTCURVE, "Root", ""}, - {PROP_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", ""}, - {PROP_LIN, "LINEAR", ICON_LINCURVE, "Linear", ""}, - {PROP_CONST, "CONSTANT", ICON_NOCURVE, "Constant", ""}, - {PROP_RANDOM, "RANDOM", ICON_RNDCURVE, "Random", ""}, + {PROP_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", "Smooth falloff"}, + {PROP_SPHERE, "SPHERE", ICON_SPHERECURVE, "Sphere", "Spherical falloff"}, + {PROP_ROOT, "ROOT", ICON_ROOTCURVE, "Root", "Root falloff"}, + {PROP_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", "Sharp falloff"}, + {PROP_LIN, "LINEAR", ICON_LINCURVE, "Linear", "Linear falloff"}, + {PROP_CONST, "CONSTANT", ICON_NOCURVE, "Constant", "Consant falloff"}, + {PROP_RANDOM, "RANDOM", ICON_RNDCURVE, "Random", "Random falloff"}, {0, NULL, 0, NULL, NULL}}; @@ -103,52 +103,54 @@ EnumPropertyItem snap_element_items[] = { EnumPropertyItem image_type_items[] = { {0, "", 0, "Image", NULL}, - {R_BMP, "BMP", ICON_FILE_IMAGE, "BMP", ""}, - //{R_DDS, "DDS", ICON_FILE_IMAGE, "DDS", ""}, // XXX not yet implemented - {R_IRIS, "IRIS", ICON_FILE_IMAGE, "Iris", ""}, - {R_PNG, "PNG", ICON_FILE_IMAGE, "PNG", ""}, - {R_JPEG90, "JPEG", ICON_FILE_IMAGE, "JPEG", ""}, -#ifdef WITH_OPENJPEG - {R_JP2, "JPEG2000", ICON_FILE_IMAGE, "JPEG 2000", ""}, + {R_BMP, "BMP", ICON_FILE_IMAGE, "BMP", "Output image in bitmap format"}, +#ifdef WITH_DDS + {R_DDS, "DDS", ICON_FILE_IMAGE, "DDS", "Output image in DDS format"}, #endif - {R_TARGA, "TARGA", ICON_FILE_IMAGE, "Targa", ""}, - {R_RAWTGA, "TARGA_RAW", ICON_FILE_IMAGE, "Targa Raw", ""}, + {R_IRIS, "IRIS", ICON_FILE_IMAGE, "Iris", "Output image in (old!) SGI IRIS format"}, + {R_PNG, "PNG", ICON_FILE_IMAGE, "PNG", "Output image in PNG format"}, + {R_JPEG90, "JPEG", ICON_FILE_IMAGE, "JPEG", "Output image in JPEG format"}, +#ifdef WITH_OPENJPEG + {R_JP2, "JPEG2000", ICON_FILE_IMAGE, "JPEG 2000", "Output image in JPEG 2000 format"}, +#endif + {R_TARGA, "TARGA", ICON_FILE_IMAGE, "Targa", "Output image in Targa format"}, + {R_RAWTGA, "TARGA_RAW", ICON_FILE_IMAGE, "Targa Raw", "Output image in uncompressed Targa format"}, {0, "", 0, " ", NULL}, #ifdef WITH_CINEON - {R_CINEON, "CINEON", ICON_FILE_IMAGE, "Cineon", ""}, - {R_DPX, "DPX",ICON_FILE_IMAGE, "DPX", ""}, + {R_CINEON, "CINEON", ICON_FILE_IMAGE, "Cineon", "Output image in Cineon format"}, + {R_DPX, "DPX",ICON_FILE_IMAGE, "DPX", "Output image in DPX format"}, #endif #ifdef WITH_OPENEXR - {R_MULTILAYER, "MULTILAYER", ICON_FILE_IMAGE, "MultiLayer", ""}, - {R_OPENEXR, "OPEN_EXR", ICON_FILE_IMAGE, "OpenEXR", ""}, + {R_MULTILAYER, "MULTILAYER", ICON_FILE_IMAGE, "MultiLayer", "Output image in multilayer OpenEXR format"}, + {R_OPENEXR, "OPEN_EXR", ICON_FILE_IMAGE, "OpenEXR", "Output image in OpenEXR format"}, #endif #ifdef WITH_HDR - {R_RADHDR, "HDR", ICON_FILE_IMAGE, "Radiance HDR", ""}, + {R_RADHDR, "HDR", ICON_FILE_IMAGE, "Radiance HDR", "Output image in Radiance HDR format"}, #endif #ifdef WITH_TIFF - {R_TIFF, "TIFF", ICON_FILE_IMAGE, "TIFF", ""}, + {R_TIFF, "TIFF", ICON_FILE_IMAGE, "TIFF", "Output image in TIFF format"}, #endif {0, "", 0, "Movie", NULL}, #ifdef _WIN32 - {R_AVICODEC, "AVICODEC", ICON_FILE_MOVIE, "AVI Codec", ""}, // XXX Missing codec menu + {R_AVICODEC, "AVICODEC", ICON_FILE_MOVIE, "AVI Codec", "Output video in AVI format"}, // XXX Missing codec menu #endif - {R_AVIJPEG, "AVI_JPEG", ICON_FILE_MOVIE, "AVI JPEG", ""}, - {R_AVIRAW, "AVI_RAW", ICON_FILE_MOVIE, "AVI Raw", ""}, - {R_FRAMESERVER, "FRAMESERVER", ICON_FILE_SCRIPT, "Frame Server", ""}, + {R_AVIJPEG, "AVI_JPEG", ICON_FILE_MOVIE, "AVI JPEG", "Output video in AVI JPEG format"}, + {R_AVIRAW, "AVI_RAW", ICON_FILE_MOVIE, "AVI Raw", "Output video in AVI Raw format"}, + {R_FRAMESERVER, "FRAMESERVER", ICON_FILE_SCRIPT, "Frame Server", "Output image to a frameserver"}, #ifdef WITH_FFMPEG - {R_H264, "H264", ICON_FILE_MOVIE, "H.264", ""}, - {R_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "MPEG", ""}, - {R_THEORA, "THEORA", ICON_FILE_MOVIE, "Ogg Theora", ""}, + {R_H264, "H264", ICON_FILE_MOVIE, "H.264", "Output video in H.264 format"}, + {R_FFMPEG, "FFMPEG", ICON_FILE_MOVIE, "MPEG", "Output video in MPEG format"}, + {R_THEORA, "THEORA", ICON_FILE_MOVIE, "Ogg Theora", "Output video in Ogg format"}, #endif #ifdef WITH_QUICKTIME # ifdef USE_QTKIT - {R_QUICKTIME, "QUICKTIME_QTKIT", ICON_FILE_MOVIE, "QuickTime", ""}, + {R_QUICKTIME, "QUICKTIME_QTKIT", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, # else - {R_QUICKTIME, "QUICKTIME_CARBON", ICON_FILE_MOVIE, "QuickTime", ""}, + {R_QUICKTIME, "QUICKTIME_CARBON", ICON_FILE_MOVIE, "QuickTime", "Output video in Quicktime format"}, # endif #endif #ifdef WITH_FFMPEG - {R_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", ""}, + {R_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", "Output video in Xvid format"}, #endif {0, NULL, 0, NULL, NULL}}; @@ -1334,7 +1336,7 @@ static void rna_def_unit_settings(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem rotation_units[] = { - {0, "DEGREES", 0, "Degrees", ""}, + {0, "DEGREES", 0, "Degrees", "Use degrees for measuring rotation"}, {USER_UNIT_ROT_RADIANS, "RADIANS", 0, "Radians", ""}, {0, NULL, 0, NULL, NULL}}; @@ -1665,12 +1667,12 @@ static void rna_def_scene_game_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem physics_engine_items[] = { - {WOPHY_NONE, "NONE", 0, "None", ""}, + {WOPHY_NONE, "NONE", 0, "None", "Don't use a physics engine"}, //{WOPHY_ENJI, "ENJI", 0, "Enji", ""}, //{WOPHY_SUMO, "SUMO", 0, "Sumo (Deprecated)", ""}, //{WOPHY_DYNAMO, "DYNAMO", 0, "Dynamo", ""}, //{WOPHY_ODE, "ODE", 0, "ODE", ""}, - {WOPHY_BULLET, "BULLET", 0, "Bullet", ""}, + {WOPHY_BULLET, "BULLET", 0, "Bullet", "Use the Bullet physics engine"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem material_items[] ={ @@ -1794,7 +1796,8 @@ static void rna_def_scene_game_data(BlenderRNA *brna) prop= RNA_def_property(srna, "physics_gravity", PROP_FLOAT, PROP_ACCELERATION); RNA_def_property_float_sdna(prop, NULL, "gravity"); - RNA_def_property_range(prop, 0.0, 25.0); + RNA_def_property_ui_range(prop, 0.0, 25.0, 1, 2); + RNA_def_property_range(prop, 0.0, 10000.0); RNA_def_property_ui_text(prop, "Physics Gravity", "Gravitational constant used for physics simulation in the game engine"); RNA_def_property_update(prop, NC_SCENE, NULL); @@ -1974,13 +1977,13 @@ static void rna_def_scene_render_data(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem pixel_filter_items[] ={ - {R_FILTER_BOX, "BOX", 0, "Box", ""}, - {R_FILTER_TENT, "TENT", 0, "Tent", ""}, - {R_FILTER_QUAD, "QUADRATIC", 0, "Quadratic", ""}, - {R_FILTER_CUBIC, "CUBIC", 0, "Cubic", ""}, - {R_FILTER_CATROM, "CATMULLROM", 0, "Catmull-Rom", ""}, - {R_FILTER_GAUSS, "GAUSSIAN", 0, "Gaussian", ""}, - {R_FILTER_MITCH, "MITCHELL", 0, "Mitchell-Netravali", ""}, + {R_FILTER_BOX, "BOX", 0, "Box", "Use a box filter for anti-aliasing"}, + {R_FILTER_TENT, "TENT", 0, "Tent", "Use a tent filter for anti-aliasing"}, + {R_FILTER_QUAD, "QUADRATIC", 0, "Quadratic", "Use a quadratic filter for anti-aliasing"}, + {R_FILTER_CUBIC, "CUBIC", 0, "Cubic", "Use a cubic filter for anti-aliasing"}, + {R_FILTER_CATROM, "CATMULLROM", 0, "Catmull-Rom", "Use a Catmull-Rom filter for anti-aliasing"}, + {R_FILTER_GAUSS, "GAUSSIAN", 0, "Gaussian", "Use a Gaussian filter for anti-aliasing"}, + {R_FILTER_MITCH, "MITCHELL", 0, "Mitchell-Netravali", "Use a Mitchell-Netravali filter for anti-aliasing"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem alpha_mode_items[] ={ @@ -2004,19 +2007,25 @@ static void rna_def_scene_render_data(BlenderRNA *brna) /* Bake */ static EnumPropertyItem bake_mode_items[] ={ - {RE_BAKE_ALL, "FULL", 0, "Full Render", ""}, - {RE_BAKE_AO, "AO", 0, "Ambient Occlusion", ""}, - {RE_BAKE_SHADOW, "SHADOW", 0, "Shadow", ""}, - {RE_BAKE_NORMALS, "NORMALS", 0, "Normals", ""}, - {RE_BAKE_TEXTURE, "TEXTURE", 0, "Textures", ""}, - {RE_BAKE_DISPLACEMENT, "DISPLACEMENT", 0, "Displacement", ""}, + {RE_BAKE_ALL, "FULL", 0, "Full Render", "Bake everything"}, + {RE_BAKE_AO, "AO", 0, "Ambient Occlusion", "Bake ambient occlusion"}, + {RE_BAKE_SHADOW, "SHADOW", 0, "Shadow", "Bake shadows"}, + {RE_BAKE_NORMALS, "NORMALS", 0, "Normals", "Bake normals"}, + {RE_BAKE_TEXTURE, "TEXTURE", 0, "Textures", "Bake textures"}, + {RE_BAKE_DISPLACEMENT, "DISPLACEMENT", 0, "Displacement", "Bake displacement"}, + {RE_BAKE_EMIT, "EMIT", 0, "Emission", "Bake Emit values (glow)"}, + {RE_BAKE_ALPHA, "ALPHA", 0, "Alpha", "Bake Alpha values (transparency)"}, + {RE_BAKE_MIRROR_INTENSITY, "MIRROR_INTENSITY", 0, "Mirror Intensity", "Bake Mirror values"}, + {RE_BAKE_MIRROR_COLOR, "MIRROR_COLOR", 0, "Mirror Colors", "Bake Mirror colors"}, + {RE_BAKE_SPEC_INTENSITY, "SPEC_INTENSITY", 0, "Specular Intensity", "Bake Specular values"}, + {RE_BAKE_SPEC_COLOR, "SPEC_COLOR", 0, "Specular Colors", "Bake Specular colors"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem bake_normal_space_items[] ={ - {R_BAKE_SPACE_CAMERA, "CAMERA", 0, "Camera", ""}, - {R_BAKE_SPACE_WORLD, "WORLD", 0, "World", ""}, - {R_BAKE_SPACE_OBJECT, "OBJECT", 0, "Object", ""}, - {R_BAKE_SPACE_TANGENT, "TANGENT", 0, "Tangent", ""}, + {R_BAKE_SPACE_CAMERA, "CAMERA", 0, "Camera", "Bake the normals in camera space"}, + {R_BAKE_SPACE_WORLD, "WORLD", 0, "World", "Bake the normals in world space"}, + {R_BAKE_SPACE_OBJECT, "OBJECT", 0, "Object", "Bake the normals in object space"}, + {R_BAKE_SPACE_TANGENT, "TANGENT", 0, "Tangent", "Bake the normals in tangent space"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem bake_qyad_split_items[] ={ @@ -2033,12 +2042,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem raytrace_structure_items[] = { - {R_RAYSTRUCTURE_AUTO, "AUTO", 0, "Auto", ""}, + {R_RAYSTRUCTURE_AUTO, "AUTO", 0, "Auto", "Automatically select acceleration structure"}, {R_RAYSTRUCTURE_OCTREE, "OCTREE", 0, "Octree", "Use old Octree structure"}, {R_RAYSTRUCTURE_BLIBVH, "BLIBVH", 0, "BLI BVH", "Use BLI K-Dop BVH.c"}, - {R_RAYSTRUCTURE_VBVH, "VBVH", 0, "vBVH", ""}, - {R_RAYSTRUCTURE_SIMD_SVBVH, "SIMD_SVBVH", 0, "SIMD SVBVH", ""}, - {R_RAYSTRUCTURE_SIMD_QBVH, "SIMD_QBVH", 0, "SIMD QBVH", ""}, + {R_RAYSTRUCTURE_VBVH, "VBVH", 0, "vBVH", "Use vBVH"}, + {R_RAYSTRUCTURE_SIMD_SVBVH, "SIMD_SVBVH", 0, "SIMD SVBVH", "Use SIMD SVBVH"}, + {R_RAYSTRUCTURE_SIMD_QBVH, "SIMD_QBVH", 0, "SIMD QBVH", "Use SIMD QBVH"}, {0, NULL, 0, NULL, NULL} }; @@ -2167,7 +2176,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) #endif static EnumPropertyItem engine_items[] = { - {0, "BLENDER_RENDER", 0, "Blender Render", ""}, + {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "RenderSettings", NULL); @@ -2608,7 +2617,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "edge_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "edgeR"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Edge Color", ""); + RNA_def_property_ui_text(prop, "Edge Color", "Edge color"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); /* threads */ @@ -3227,10 +3236,15 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "r.cfra"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_current_frame_set", NULL); - RNA_def_property_ui_text(prop, "Current Frame", ""); + RNA_def_property_ui_text(prop, "Current Frame", "Current Frame"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_SCENE|ND_FRAME, "rna_Scene_frame_update"); + prop= RNA_def_property(srna, "frame_subframe", PROP_FLOAT, PROP_TIME); + RNA_def_property_float_sdna(prop, NULL, "r.subframe"); + RNA_def_property_ui_text(prop, "Current Sub-Frame", ""); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE|PROP_EDITABLE); + prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_int_sdna(prop, NULL, "r.sfra"); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index ce018fdfd6e..da536f95cba 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -481,12 +481,12 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ParticleBrushData"); RNA_def_struct_ui_text(srna, "Particle Brush", "Particle editing brush"); - prop= RNA_def_property(srna, "size", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 100, 10, 3); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); - prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR); RNA_def_property_range(prop, 0.001, 1.0); RNA_def_property_ui_text(prop, "Strength", "Brush strength"); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 34963e9507f..90ae95894b0 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -387,6 +387,8 @@ static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr) return &RNA_EffectSequence; case SEQ_MULTICAM: return &RNA_MulticamSequence; + case SEQ_ADJUSTMENT: + return &RNA_AdjustmentSequence; case SEQ_PLUGIN: return &RNA_PluginSequence; case SEQ_WIPE: @@ -844,6 +846,7 @@ static void rna_def_sequence(BlenderRNA *brna) {SEQ_COLOR, "COLOR", 0, "Color", ""}, {SEQ_SPEED, "SPEED", 0, "Speed", ""}, {SEQ_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""}, + {SEQ_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""}, {0, NULL, 0, NULL, NULL}}; static const EnumPropertyItem blend_mode_items[]= { @@ -1371,6 +1374,20 @@ static void rna_def_multicam(BlenderRNA *brna) rna_def_input(srna); } +static void rna_def_adjustment(BlenderRNA *brna) +{ + StructRNA *srna; +// PropertyRNA *prop; + + srna = RNA_def_struct(brna, "AdjustmentSequence", "Sequence"); + RNA_def_struct_ui_text(srna, "Adjustment Layer Sequence", "Sequence strip to perform filter adjustments to layers below"); + RNA_def_struct_sdna(srna, "Sequence"); + + rna_def_filter_video(srna); + rna_def_proxy(srna); + rna_def_input(srna); +} + static void rna_def_plugin(BlenderRNA *brna) { StructRNA *srna; @@ -1620,6 +1637,7 @@ void RNA_def_sequencer(BlenderRNA *brna) rna_def_sound(brna); rna_def_effect(brna); rna_def_multicam(brna); + rna_def_adjustment(brna); rna_def_plugin(brna); rna_def_wipe(brna); rna_def_glow(brna); diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 922c68f45bd..974f2fdecb8 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -212,7 +212,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "strength"); RNA_def_property_range(prop, 0.0, 10.0); RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 2); - RNA_def_property_ui_text(prop, "Strength", "Strength of wavelet noise"); + RNA_def_property_ui_text(prop, "Strength", "Strength of noise"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); prop= RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 1dcee4bf726..087a5c35e77 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -79,9 +79,6 @@ static EnumPropertyItem draw_channels_items[] = { {SI_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha", "Draw image with RGB colors and alpha transparency"}, {SI_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel"}, {SI_SHOW_ZBUF, "Z_BUFFER", ICON_IMAGE_ZDEPTH, "Z-Buffer", "Draw Z-buffer associated with image (mapped from camera clip start to end)"}, -#ifdef WITH_LCMS - {SI_COLOR_CORRECTION, "COLOR_CORRECTED", ICON_IMAGE_ALPHA, "Color Corrected", "Display color corrected image"}, -#endif {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem transform_orientation_items[] = { @@ -449,7 +446,7 @@ static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *value { RegionView3D *rv3d= (RegionView3D *)(ptr->data); negate_v3_v3(rv3d->ofs, values); - view3d_apply_mat4((float (*)[4])values, rv3d->ofs, rv3d->viewquat, &rv3d->dist); + ED_view3d_from_m4((float (*)[4])values, rv3d->ofs, rv3d->viewquat, &rv3d->dist); } /* Space Image Editor */ @@ -521,16 +518,33 @@ static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, P RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_ZBUF); } -#ifdef WITH_LCMS - RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_COLOR_CORRECTION); -#endif - RNA_enum_item_end(&item, &totitem); *free= 1; return item; } +static void rna_SpaceImageEditor_zoom_get(PointerRNA *ptr, float *values) +{ + SpaceImage *sima= (SpaceImage*)ptr->data; + ScrArea *sa; + ARegion *ar; + + values[0] = values[1] = 1; + + sa = rna_area_from_space(ptr); + if(!sa) return; + + /* find aregion */ + for(ar=sa->regionbase.first; ar; ar=ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) + break; + } + if(!ar) return; + + ED_space_image_zoom(sima, ar, &values[0], &values[1]); +} + static void rna_SpaceImageEditor_cursor_location_get(PointerRNA *ptr, float *values) { SpaceImage *sima= (SpaceImage*)ptr->data; @@ -1040,18 +1054,18 @@ static void rna_def_space_outliner(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem display_mode_items[] = { - {SO_ALL_SCENES, "ALL_SCENES", 0, "All Scenes", ""}, - {SO_CUR_SCENE, "CURRENT_SCENE", 0, "Current Scene", ""}, - {SO_VISIBLE, "VISIBLE_LAYERS", 0, "Visible Layers", ""}, - {SO_SELECTED, "SELECTED", 0, "Selected", ""}, - {SO_ACTIVE, "ACTIVE", 0, "Active", ""}, - {SO_SAME_TYPE, "SAME_TYPES", 0, "Same Types", ""}, - {SO_GROUPS, "GROUPS", 0, "Groups", ""}, - {SO_LIBRARIES, "LIBRARIES", 0, "Libraries", ""}, - {SO_SEQUENCE, "SEQUENCE", 0, "Sequence", ""}, - {SO_DATABLOCKS, "DATABLOCKS", 0, "Datablocks", ""}, - {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", ""}, - {SO_KEYMAP, "KEYMAPS", 0, "Key Maps", ""}, + {SO_ALL_SCENES, "ALL_SCENES", 0, "All Scenes", "Display datablocks in all scenes"}, + {SO_CUR_SCENE, "CURRENT_SCENE", 0, "Current Scene", "Display datablocks in current scene"}, + {SO_VISIBLE, "VISIBLE_LAYERS", 0, "Visible Layers", "Display datablocks in visible layers"}, + {SO_SELECTED, "SELECTED", 0, "Selected", "Display datablocks of selected objects"}, + {SO_ACTIVE, "ACTIVE", 0, "Active", "Display datablocks of active object"}, + {SO_SAME_TYPE, "SAME_TYPES", 0, "Same Types", "Display datablocks of all objects of same type as selected object"}, + {SO_GROUPS, "GROUPS", 0, "Groups", "Display groups and their datablocks"}, + {SO_LIBRARIES, "LIBRARIES", 0, "Libraries", "Display libraries"}, + {SO_SEQUENCE, "SEQUENCE", 0, "Sequence", "Display sequence datablocks"}, + {SO_DATABLOCKS, "DATABLOCKS", 0, "Datablocks", "Display raw datablocks"}, + {SO_USERDEF, "USER_PREFERENCES", 0, "User Preferences", "Display the user preference datablocks"}, + {SO_KEYMAP, "KEYMAPS", 0, "Key Maps", "Display keymap datablocks"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceOutliner", "Space"); @@ -1093,20 +1107,20 @@ static void rna_def_background_image(BlenderRNA *brna) /* note: combinations work but dont flip so arnt that useful */ static EnumPropertyItem bgpic_axis_items[] = { {0, "", 0, "X Axis", ""}, - {(1<paneltypes.first; pt; pt=pt->next) { if(strcmp(pt->idname, dummypt.idname) == 0) { if(pt->ext.srna) - rna_Panel_unregister(C, pt->ext.srna); + rna_Panel_unregister(bmain, pt->ext.srna); else BLI_freelinkN(&art->paneltypes, pt); break; @@ -233,8 +232,7 @@ static StructRNA *rna_Panel_register(bContext *C, ReportList *reports, void *dat BLI_addtail(&art->paneltypes, pt); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return pt->ext.srna; } @@ -263,7 +261,7 @@ static void header_draw(const bContext *C, Header *hdr) RNA_parameter_list_free(&list); } -static void rna_Header_unregister(const bContext *C, StructRNA *type) +static void rna_Header_unregister(Main *bmain, StructRNA *type) { ARegionType *art; HeaderType *ht= RNA_struct_blender_type_get(type); @@ -279,11 +277,10 @@ static void rna_Header_unregister(const bContext *C, StructRNA *type) RNA_struct_free(&BLENDER_RNA, type); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Header_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; HeaderType *ht, dummyht = {NULL}; @@ -311,7 +308,7 @@ static StructRNA *rna_Header_register(bContext *C, ReportList *reports, void *da for(ht=art->headertypes.first; ht; ht=ht->next) { if(strcmp(ht->idname, dummyht.idname) == 0) { if(ht->ext.srna) - rna_Header_unregister(C, ht->ext.srna); + rna_Header_unregister(bmain, ht->ext.srna); break; } } @@ -331,8 +328,7 @@ static StructRNA *rna_Header_register(bContext *C, ReportList *reports, void *da BLI_addtail(&art->headertypes, ht); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return ht->ext.srna; } @@ -384,7 +380,7 @@ static void menu_draw(const bContext *C, Menu *hdr) RNA_parameter_list_free(&list); } -static void rna_Menu_unregister(const bContext *C, StructRNA *type) +static void rna_Menu_unregister(Main *bmain, StructRNA *type) { MenuType *mt= RNA_struct_blender_type_get(type); @@ -398,11 +394,10 @@ static void rna_Menu_unregister(const bContext *C, StructRNA *type) RNA_struct_free(&BLENDER_RNA, type); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); } -static StructRNA *rna_Menu_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { MenuType *mt, dummymt = {NULL}; Menu dummymenu= {NULL}; @@ -425,7 +420,7 @@ static StructRNA *rna_Menu_register(bContext *C, ReportList *reports, void *data /* check if we have registered this menu type before, and remove it */ mt= WM_menutype_find(dummymt.idname, TRUE); if(mt && mt->ext.srna) - rna_Menu_unregister(C, mt->ext.srna); + rna_Menu_unregister(bmain, mt->ext.srna); /* create a new menu type */ mt= MEM_callocN(sizeof(MenuType), "python buttons menu"); @@ -444,8 +439,7 @@ static StructRNA *rna_Menu_register(bContext *C, ReportList *reports, void *data WM_menutype_add(mt); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return mt->ext.srna; } @@ -622,7 +616,7 @@ static void rna_def_panel(BlenderRNA *brna) /* poll */ func= RNA_def_function(srna, "poll", NULL); RNA_def_function_ui_description(func, "If this method returns a non-null output, then the panel can be drawn."); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); parm= RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); @@ -741,7 +735,7 @@ static void rna_def_menu(BlenderRNA *brna) /* poll */ func= RNA_def_function(srna, "poll", NULL); RNA_def_function_ui_description(func, "If this method returns a non-null output, then the menu can be drawn."); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_REGISTER|FUNC_REGISTER_OPTIONAL); + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_REGISTER_OPTIONAL); RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); parm= RNA_def_pointer(func, "context", "Context", "", ""); RNA_def_property_flag(parm, PROP_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 407e48058ab..765cee9e6d1 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -389,7 +389,7 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_flag(func, FUNC_USE_CONTEXT); api_ui_item_rna_common(func); parm= RNA_def_pointer(func, "image_user", "ImageUser", "", ""); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL); RNA_def_boolean(func, "compact", 0, "", "Use more compact layout."); func= RNA_def_function(srna, "template_list", "uiTemplateList"); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 346acc522a1..e8b127b68bb 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -669,19 +669,20 @@ static void rna_wmClipboard_set(PointerRNA *ptr, const char *value) } #ifdef WITH_PYTHON -static void rna_Operator_unregister(const bContext *C, StructRNA *type) +static void rna_Operator_unregister(struct Main *bmain, StructRNA *type) { const char *idname; wmOperatorType *ot= RNA_struct_blender_type_get(type); + wmWindowManager *wm; if(!ot) return; /* update while blender is running */ - if(C) { - WM_operator_stack_clear((bContext*)C); - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); - } + wm= bmain->wm.first; + if(wm) + WM_operator_stack_clear(wm); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); RNA_struct_free_extension(type, &ot->ext); @@ -858,7 +859,7 @@ void macro_wrapper(wmOperatorType *ot, void *userdata); static char _operator_idname[OP_MAX_TYPENAME]; static char _operator_name[OP_MAX_TYPENAME]; static char _operator_descr[1024]; -static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { wmOperatorType dummyot = {NULL}; wmOperator dummyop= {NULL}; @@ -935,7 +936,7 @@ static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void * { wmOperatorType *ot= WM_operatortype_find(dummyot.idname, TRUE); if(ot && ot->ext.srna) - rna_Operator_unregister(C, ot->ext.srna); + rna_Operator_unregister(bmain, ot->ext.srna); } /* create a new menu type */ @@ -955,8 +956,7 @@ static StructRNA *rna_Operator_register(bContext *C, ReportList *reports, void * WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return dummyot.ext.srna; } @@ -967,7 +967,7 @@ void **rna_Operator_instance(PointerRNA *ptr) return &op->py_instance; } -static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { wmOperatorType dummyot = {NULL}; wmOperator dummyop= {NULL}; @@ -1011,7 +1011,7 @@ static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, v { wmOperatorType *ot= WM_operatortype_find(dummyot.idname, TRUE); if(ot && ot->ext.srna) - rna_Operator_unregister(C, ot->ext.srna); + rna_Operator_unregister(bmain, ot->ext.srna); } /* create a new menu type */ @@ -1026,8 +1026,7 @@ static StructRNA *rna_MacroOperator_register(bContext *C, ReportList *reports, v WM_operatortype_append_macro_ptr(macro_wrapper, (void *)&dummyot); /* update while blender is running */ - if(C) - WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); + WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL); return dummyot.ext.srna; } diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index 5a0708865b6..e250cc84aa3 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -135,7 +135,7 @@ void RNA_api_wm(StructRNA *srna) 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."); + 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); diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index eb9cb5c2270..39cbea27388 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -233,7 +233,7 @@ static void rna_def_lighting(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_sample_method_items[] = { - {WO_AOSAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", ""}, + {WO_AOSAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", "Fastest and gives the most noise"}, {WO_AOSAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", "Fast in high-contrast areas"}, {WO_AOSAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", "Best quality"}, {0, NULL, 0, NULL, NULL}}; @@ -324,7 +324,7 @@ static void rna_def_lighting(BlenderRNA *brna) prop= RNA_def_property(srna, "falloff_strength", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "aodistfac"); - RNA_def_property_ui_text(prop, "Strength", "Distance attenuation factor, the higher, the less influence farther away objects have influence"); + RNA_def_property_ui_text(prop, "Strength", "Attenuation falloff strength, the higher, the less influence distant objects have"); RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "bias", PROP_FLOAT, PROP_NONE); @@ -360,7 +360,7 @@ static void rna_def_lighting(BlenderRNA *brna) prop= RNA_def_property(srna, "use_falloff", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AODIST); - RNA_def_property_ui_text(prop, "Falloff", ""); + RNA_def_property_ui_text(prop, "Falloff", "Distance will be used to attenuate shadows"); RNA_def_property_update(prop, 0, "rna_World_update"); prop= RNA_def_property(srna, "use_cache", PROP_BOOLEAN, PROP_NONE); @@ -525,7 +525,7 @@ void RNA_def_world(BlenderRNA *brna) prop= RNA_def_property(srna, "ambient_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "ambr"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Ambient Color", ""); + RNA_def_property_ui_text(prop, "Ambient Color", "Ambient color of the world"); RNA_def_property_update(prop, 0, "rna_World_update"); /* exp, range */ diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 02912e38204..61345427d1c 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -139,8 +139,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fluid_get_bb(mesh->mvert, mesh->totvert, ob->obmat, fss->bbStart, fss->bbSize); */ - // (ab)used to store velocities - fss->meshSurfNormals = NULL; + fss->meshVelocities = NULL; fss->lastgoodframe = -1; @@ -158,10 +157,10 @@ void fluidsim_free(FluidsimModifierData *fluidmd) #ifndef DISABLE_ELBEEM if(fluidmd) { - if(fluidmd->fss->meshSurfNormals) + if(fluidmd->fss->meshVelocities) { - MEM_freeN(fluidmd->fss->meshSurfNormals); - fluidmd->fss->meshSurfNormals = NULL; + MEM_freeN(fluidmd->fss->meshVelocities); + fluidmd->fss->meshVelocities = NULL; } MEM_freeN(fluidmd->fss); } @@ -394,12 +393,12 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * FluidsimSettings *fss = fluidmd->fss; int len = strlen(filename); int totvert = dm->getNumVerts(dm); - float *velarray = NULL; + FluidVertexVelocity *velarray = NULL; // mesh and vverts have to be valid from loading... - if(fss->meshSurfNormals) - MEM_freeN(fss->meshSurfNormals); + if(fss->meshVelocities) + MEM_freeN(fss->meshVelocities); if(len<7) { @@ -408,12 +407,10 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * if(fss->domainNovecgen>0) return; - // abusing pointer to hold an array of 3d-velocities - fss->meshSurfNormals = MEM_callocN(sizeof(float)*3*dm->getNumVerts(dm), "Fluidsim_velocities"); - // abusing pointer to hold an INT - fss->meshSurface = SET_INT_IN_POINTER(totvert); + fss->meshVelocities = MEM_callocN(sizeof(FluidVertexVelocity)*dm->getNumVerts(dm), "Fluidsim_velocities"); + fss->totvert = totvert; - velarray = (float *)fss->meshSurfNormals; + velarray = fss->meshVelocities; // .bobj.gz , correct filename // 87654321 @@ -424,16 +421,16 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * gzf = gzopen(filename, "rb"); if (!gzf) { - MEM_freeN(fss->meshSurfNormals); - fss->meshSurfNormals = NULL; + MEM_freeN(fss->meshVelocities); + fss->meshVelocities = NULL; return; } gzread(gzf, &wri, sizeof( wri )); if(wri != totvert) { - MEM_freeN(fss->meshSurfNormals); - fss->meshSurfNormals = NULL; + MEM_freeN(fss->meshVelocities); + fss->meshVelocities = NULL; return; } @@ -442,7 +439,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * for(j=0; j<3; j++) { gzread(gzf, &wrf, sizeof( wrf )); - velarray[3*i + j] = wrf; + velarray[i].vel[j] = wrf; } } @@ -531,10 +528,10 @@ static DerivedMesh *fluidsim_read_cache(DerivedMesh *orgdm, FluidsimModifierData } else { - if(fss->meshSurfNormals) - MEM_freeN(fss->meshSurfNormals); + if(fss->meshVelocities) + MEM_freeN(fss->meshVelocities); - fss->meshSurfNormals = NULL; + fss->meshVelocities = NULL; } return dm; diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 058a560ed63..b23ec642466 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -350,7 +350,7 @@ ModifierTypeInfo modifierType_Warp = { /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, + /* deformMatricesEM */ NULL, /* applyModifier */ 0, /* applyModifierEM */ 0, /* initData */ initData, @@ -359,7 +359,7 @@ ModifierTypeInfo modifierType_Warp = { /* isDisabled */ isDisabled, /* updateDepgraph */ updateDepgraph, /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, }; diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c b/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c index a6ce77b64f0..36b7988c4e0 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_rgb.c @@ -45,7 +45,7 @@ static void node_composit_exec_rgb(void *UNUSED(data), bNode *node, bNodeStack * { bNodeSocket *sock= node->outputs.first; - VECCOPY(out[0]->vec, sock->ns.vec); + QUATCOPY(out[0]->vec, sock->ns.vec); } void register_node_type_cmp_rgb(ListBase *lb) diff --git a/source/blender/python/generic/IDProp.c b/source/blender/python/generic/IDProp.c index ccf498f1550..8330927d920 100644 --- a/source/blender/python/generic/IDProp.c +++ b/source/blender/python/generic/IDProp.c @@ -45,12 +45,6 @@ #include "py_capi_utils.h" #endif -PyObject * PyC_UnicodeFromByte(const char *str); -const char * PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */ - -/*** Function to wrap ID properties ***/ -PyObject *BPy_Wrap_IDProperty(ID *id, IDProperty *prop, IDProperty *parent); - extern PyTypeObject IDArray_Type; extern PyTypeObject IDGroup_Iter_Type; diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index 4291fc824e9..b66b2109329 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -76,7 +76,7 @@ static void bpy_lib_dealloc(BPy_Library *self) } -PyTypeObject bpy_lib_Type= { +static PyTypeObject bpy_lib_Type= { PyVarObject_HEAD_INIT(NULL, 0) "bpy_lib", /* tp_name */ sizeof(BPy_Library), /* tp_basicsize */ diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index c230e952ca1..b8883e655f2 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -36,6 +36,7 @@ #include "RNA_types.h" +#include "BPY_extern.h" #include "bpy_operator.h" #include "bpy_operator_wrap.h" #include "bpy_rna.h" /* for setting arg props only - pyrna_py_to_prop() */ diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index e1ef8aa49c1..de29cb2aeac 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -1,4 +1,3 @@ - /* * $Id$ * diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ad2a5f3ce28..4f62c545a71 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4243,6 +4243,14 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw) PropertyRNA *pret_single= NULL; void *retdata_single= NULL; + /* enable this so all strings are copied and freed after calling. + * this exposes bugs where the pointer to the string is held and re-used */ +// #define DEBUG_STRING_FREE + +#ifdef DEBUG_STRING_FREE + PyObject *string_free_ls= PyList_New(0); +#endif + /* Should never happen but it does in rare cases */ BLI_assert(self_ptr != NULL); @@ -4331,10 +4339,20 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw) err= -1; break; } - else /* PyDict_GetItemString wont raise an error */ + else { /* PyDict_GetItemString wont raise an error */ continue; + } } +#ifdef DEBUG_STRING_FREE + if(item) { + if(PyUnicode_Check(item)) { + item= PyUnicode_FromString(_PyUnicode_AsString(item)); + PyList_Append(string_free_ls, item); + Py_DECREF(item); + } + } +#endif err= pyrna_py_to_prop(&funcptr, parm, iter.data, item, ""); if(err!=0) { @@ -4470,6 +4488,13 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw) } } + +#ifdef DEBUG_STRING_FREE + // if(PyList_Size(string_free_ls)) printf("%.200s.%.200s(): has %d strings\n", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), (int)PyList_Size(string_free_ls)); + Py_DECREF(string_free_ls); +#undef DEBUG_STRING_FREE +#endif + /* cleanup */ RNA_parameter_list_end(&iter); RNA_parameter_list_free(&parms); @@ -6394,7 +6419,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class identifier= ((PyTypeObject*)py_class)->tp_name; - srna_new= reg(C, &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free); + srna_new= reg(CTX_data_main(C), &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free); if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1) return NULL; @@ -6544,7 +6569,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla C= BPy_GetContext(); /* call unregister */ - unreg(C, srna); /* calls bpy_class_free, this decref's py_class */ + unreg(CTX_data_main(C), srna); /* calls bpy_class_free, this decref's py_class */ PyDict_DelItemString(((PyTypeObject *)py_class)->tp_dict, "bl_rna"); if(PyErr_Occurred()) diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index ba19f155842..28459677b32 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -187,12 +187,8 @@ int pyrna_write_check(void); int pyrna_struct_validity_check(BPy_StructRNA *pysrna); int pyrna_prop_validity_check(BPy_PropertyRNA *self); -void BPY_modules_update(struct bContext *C); //XXX temp solution - /* bpy.utils.(un)register_class */ 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 5e53d4101f6..30d83e196ba 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -44,6 +44,9 @@ #include "RNA_access.h" +#include "WM_api.h" +#include "WM_types.h" + #include "bpy_rna.h" #include "bpy_util.h" #include "bpy_rna_anim.h" @@ -320,6 +323,8 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args) RNA_pointer_create(id, &RNA_FCurve, fcu, &tptr); ret= pyrna_struct_CreatePyObject(&tptr); } + + WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION|ND_FCURVES_ORDER, NULL); } else { /* XXX, should be handled by reports, */ @@ -371,6 +376,8 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args) if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1) return NULL; + + WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION|ND_FCURVES_ORDER, NULL); return PyBool_FromLong(result); } diff --git a/source/blender/readblenfile/BLO_readblenfile.h b/source/blender/readblenfile/BLO_readblenfile.h deleted file mode 100644 index 9b4e15165f5..00000000000 --- a/source/blender/readblenfile/BLO_readblenfile.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -#ifndef BLO_READBLENFILE_H -#define BLO_READBLENFILE_H - -/** \file BLO_readblenfile.h - * \ingroup blo - */ - -#ifdef __cplusplus -extern "C" { -#endif - -struct ReportList; - - BlendFileData * -BLO_readblenfilename( - char *fileName, - struct ReportList *reports); - - BlendFileData * -BLO_readblenfilehandle( - int fileHandle, - struct ReportList *reports); - - BlendFileData * -BLO_readblenfilememory( - char *fromBuffer, - int fromBufferSize, - struct ReportList *reports); - - - void -BLO_setcurrentversionnumber( - char array[4]); - - void -BLO_setversionnumber( - char array[4], - int version); - - int -blo_is_a_runtime( - char *file); - - BlendFileData * -blo_read_runtime( - char *file, - struct ReportList *reports); - -#define BLO_RESERVEDSIZE 12 -extern const char *headerMagic; - -#ifdef __cplusplus -} -#endif - -#endif /* BLO_READBLENFILE_H */ - diff --git a/source/blender/readblenfile/CMakeLists.txt b/source/blender/readblenfile/CMakeLists.txt deleted file mode 100644 index 8d3633b4918..00000000000 --- a/source/blender/readblenfile/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# $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. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurain. -# -# ***** END GPL LICENSE BLOCK ***** - -set(INC - . - ../blenloader - ../blenloader/intern - ../blenkernel - ../blenlib - ../makesdna - ../../kernel/gen_messaging -) - -set(SRC - intern/BLO_readblenfile.c - - BLO_readblenfile.h -) - -blender_add_lib(bf_readblenfile "${SRC}" "${INC}") diff --git a/source/blender/readblenfile/SConscript b/source/blender/readblenfile/SConscript deleted file mode 100644 index 6d8749df1e2..00000000000 --- a/source/blender/readblenfile/SConscript +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/python -Import ('env') - -sources = env.Glob('intern/*.c') - -incs = '. ../blenloader ../blenloader/intern ../blenkernel ../blenlib ../makesdna ../../kernel/gen_messaging' - -env.BlenderLib ( 'bf_readblenfile', sources, Split(incs), [], libtype=['core','player'], priority = [0,5] ) diff --git a/source/blender/readblenfile/stub/BLO_readblenfileSTUB.c b/source/blender/readblenfile/stub/BLO_readblenfileSTUB.c deleted file mode 100644 index 4900f0c3338..00000000000 --- a/source/blender/readblenfile/stub/BLO_readblenfileSTUB.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -/** \file blender/readblenfile/stub/BLO_readblenfileSTUB.c - * \ingroup blo - */ - - -#include -#include "GEN_messaging.h" - -int BLO_readblenfilememory( char *fromBuffer, int fromBufferSize); -int BLO_readblenfilename( char *fileName); -int BLO_readblenfilehandle( int fileHandle); -int BLO_is_a_runtime( char *file); -int BLO_read_runtime( char *file); - - int -BLO_readblenfilememory( - char *fromBuffer, int fromBufferSize) -{ -#if defined(DEBUG) - fprintf(GEN_errorstream, - "Error BLO_readblenfilename is a stub\n"); -#endif - return(1); -} - - int -BLO_readblenfilename( - char *fileName) -{ -#if defined(DEBUG) - fprintf(GEN_errorstream, - "Error BLO_readblenfilename is a stub\n"); -#endif - return(1); -} - - int -BLO_readblenfilehandle( - int fileHandle) -{ -#if defined(DEBUG) - fprintf(GEN_errorstream, - "Error BLO_readblenfilehandle is a stub\n"); -#endif - return(1); -} - - int -BLO_is_a_runtime( - char *file) -{ -#if defined(DEBUG) - fprintf(GEN_errorstream, - "Error BLO_is_a_runtime is a stub\n"); -#endif - return 0; -} - - int -BLO_read_runtime( - char *file) -{ -#if defined(DEBUG) - fprintf(GEN_errorstream, - "Error BLO_read_runtime is a stub\n"); -#endif - return 0; -} diff --git a/source/blender/readblenfile/test/test.c b/source/blender/readblenfile/test/test.c deleted file mode 100644 index 647df053c38..00000000000 --- a/source/blender/readblenfile/test/test.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#include // strlen -#include "BLO_readblenfile.h" - -struct streamGlueControlStruct *Global_streamGlueControl; - - int -streamGlueWrite( - struct streamGlueControlStruct *streamGlueControl, - struct streamGlueStruct **streamGlue, - unsigned char *data, - unsigned int dataIn, - int finishUp) -{ - printf("called with %d bytes in buffer [%s]\n", dataIn, data); - return (0); -} - -main() -{ - int err; - - err = BLO_readblenfile(); -} diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index f9b629791d7..5d80f68d8e2 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -36,7 +36,6 @@ set(INC ../makesrna ../blenkernel ../imbuf - ../../kernel/gen_messaging ../../../intern/smoke/extern ../../../intern/mikktspace ../../../intern/guardedalloc diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index a1d4efbfe3c..de7f65c576e 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -248,13 +248,19 @@ float RE_filter_value(int type, float x); void RE_zbuf_accumulate_vecblur(struct NodeBlurData *nbd, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect); /* shaded view or baking options */ -#define RE_BAKE_LIGHT 0 -#define RE_BAKE_ALL 1 -#define RE_BAKE_AO 2 -#define RE_BAKE_NORMALS 3 -#define RE_BAKE_TEXTURE 4 -#define RE_BAKE_DISPLACEMENT 5 -#define RE_BAKE_SHADOW 6 +#define RE_BAKE_LIGHT 0 /* not listed in rna_scene.c -> can't be enabled! */ +#define RE_BAKE_ALL 1 +#define RE_BAKE_AO 2 +#define RE_BAKE_NORMALS 3 +#define RE_BAKE_TEXTURE 4 +#define RE_BAKE_DISPLACEMENT 5 +#define RE_BAKE_SHADOW 6 +#define RE_BAKE_SPEC_COLOR 7 +#define RE_BAKE_SPEC_INTENSITY 8 +#define RE_BAKE_MIRROR_COLOR 9 +#define RE_BAKE_MIRROR_INTENSITY 10 +#define RE_BAKE_ALPHA 11 +#define RE_BAKE_EMIT 12 void RE_Database_Baking(struct Render *re, struct Main *bmain, struct Scene *scene, unsigned int lay, int type, struct Object *actob); diff --git a/source/blender/render/intern/include/shading.h b/source/blender/render/intern/include/shading.h index 865cb056a61..07d24ea6d66 100644 --- a/source/blender/render/intern/include/shading.h +++ b/source/blender/render/intern/include/shading.h @@ -37,7 +37,7 @@ struct LampRen; struct VlakRen; struct StrandSegment; struct StrandPoint; -struct ObjectInstanceRen obi; +struct ObjectInstanceRen; struct Isect; /* shadeinput.c */ diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 74ce7957dd7..c1c2fb60abd 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -5387,7 +5387,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * float imat[4][4]; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(fsob, eModifierType_Fluidsim); FluidsimSettings *fss; - float *velarray = NULL; + FluidVertexVelocity *velarray = NULL; /* only one step needed */ if(step) return 1; @@ -5401,14 +5401,14 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * invert_m4_m4(imat, mat); /* set first vertex OK */ - if(!fss->meshSurfNormals) return 0; + if(!fss->meshVelocities) return 0; - if( obr->totvert != GET_INT_FROM_POINTER(fss->meshSurface) ) { + if( obr->totvert != fss->totvert) { //fprintf(stderr, "load_fluidsimspeedvectors - modified fluidsim mesh, not using speed vectors (%d,%d)...\n", obr->totvert, fsob->fluidsimSettings->meshSurface->totvert); // DEBUG return 0; } - velarray = (float *)fss->meshSurfNormals; + velarray = fss->meshVelocities; if(obi->flag & R_TRANSFORMED) mul_m4_m4m4(winmat, obi->mat, re->winmat); @@ -5420,7 +5420,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * so that also small drops/little water volumes return a velocity != 0. But I had no luck in fixing that function - DG */ for(a=0; atotvert; a++) { - for(j=0;j<3;j++) avgvel[j] += velarray[3*a + j]; + for(j=0;j<3;j++) avgvel[j] += velarray[a].vel[j]; } for(j=0;j<3;j++) avgvel[j] /= (float)(obr->totvert); @@ -5435,7 +5435,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * // get fluid velocity fsvec[3] = 0.; //fsvec[0] = fsvec[1] = fsvec[2] = fsvec[3] = 0.; fsvec[2] = 2.; // NT fixed test - for(j=0;j<3;j++) fsvec[j] = velarray[3*a + j]; + for(j=0;j<3;j++) fsvec[j] = velarray[a].vel[j]; /* (bad) HACK insert average velocity if none is there (see previous comment) */ if((fsvec[0] == 0.0) && (fsvec[1] == 0.0) && (fsvec[2] == 0.0)) diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index b57fe5a8c3b..e8f66cf18ef 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -96,7 +96,7 @@ static void RE_rayobject_config_control(RayObject *r, Render *re) } } -RayObject* RE_rayobject_create(Render *re, int type, int size) +static RayObject* RE_rayobject_create(Render *re, int type, int size) { RayObject * res = NULL; @@ -1679,7 +1679,7 @@ static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int /* not used, test function for ambient occlusion (yaf: pathlight) */ /* main problem; has to be called within shading loop, giving unwanted recursion */ -int ray_trace_shadow_rad(ShadeInput *ship, ShadeResult *shr) +static int ray_trace_shadow_rad(ShadeInput *ship, ShadeResult *shr) { static int counter=0, only_one= 0; extern float hashvectf[]; @@ -1729,7 +1729,7 @@ int ray_trace_shadow_rad(ShadeInput *ship, ShadeResult *shr) /* end warning! - Campbell */ shade_ray(&isec, &shi, &shr_t); - fac= isec.dist*isec.dist; + /* fac= isec.dist*isec.dist; */ fac= 1.0f; accum[0]+= fac*(shr_t.diff[0]+shr_t.spec[0]); accum[1]+= fac*(shr_t.diff[1]+shr_t.spec[1]); diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 7a34fc0af50..bc6c4795f5c 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2143,7 +2143,9 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int shade_input_set_shade_texco(shi); - if(!ELEM3(bs->type, RE_BAKE_NORMALS, RE_BAKE_TEXTURE, RE_BAKE_SHADOW)) + /* only do AO for a full bake (and obviously AO bakes) + AO for light bakes is a leftover and might not be needed */ + if( ELEM3(bs->type, RE_BAKE_ALL, RE_BAKE_AO, RE_BAKE_LIGHT)) shade_samples_do_AO(ssamp); if(shi->mat->nodetree && shi->mat->use_nodes) { @@ -2206,6 +2208,42 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int VECCOPY(shr.combined, shr.shad); shr.alpha = shi->alpha; } + else if(bs->type==RE_BAKE_SPEC_COLOR) { + shr.combined[0]= shi->specr; + shr.combined[1]= shi->specg; + shr.combined[2]= shi->specb; + shr.alpha = 1.0f; + } + else if(bs->type==RE_BAKE_SPEC_INTENSITY) { + shr.combined[0]= + shr.combined[1]= + shr.combined[2]= shi->spec; + shr.alpha = 1.0f; + } + else if(bs->type==RE_BAKE_MIRROR_COLOR) { + shr.combined[0]= shi->mirr; + shr.combined[1]= shi->mirg; + shr.combined[2]= shi->mirb; + shr.alpha = 1.0f; + } + else if(bs->type==RE_BAKE_MIRROR_INTENSITY) { + shr.combined[0]= + shr.combined[1]= + shr.combined[2]= shi->ray_mirror; + shr.alpha = 1.0f; + } + else if(bs->type==RE_BAKE_ALPHA) { + shr.combined[0]= + shr.combined[1]= + shr.combined[2]= shi->alpha; + shr.alpha = 1.0f; + } + else if(bs->type==RE_BAKE_EMIT) { + shr.combined[0]= + shr.combined[1]= + shr.combined[2]= shi->emit; + shr.alpha = 1.0f; + } } if(bs->rect_float) { diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 74c99d1a92f..afe4d5c7e35 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -782,7 +782,7 @@ void free_renderdata_vlaknodes(VlakTableNode *vlaknodes) MEM_freeN(vlaknodes); } -void free_renderdata_strandnodes(StrandTableNode *strandnodes) +static void free_renderdata_strandnodes(StrandTableNode *strandnodes) { int a; diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index 12e85af7575..9f5c2c39472 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -210,7 +210,7 @@ static void interpolate_vec4(float *v1, float *v2, float t, float negt, float *v v[3]= negt*v1[3] + t*v2[3]; } -void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float t, ShadeResult *shr, int addpassflag) +static void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float t, ShadeResult *shr, int addpassflag) { float negt= 1.0f - t; @@ -252,7 +252,7 @@ void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float t, Sha } } -void strand_apply_shaderesult_alpha(ShadeResult *shr, float alpha) +static void strand_apply_shaderesult_alpha(ShadeResult *shr, float alpha) { if(alpha < 1.0f) { shr->combined[0] *= alpha; diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index 919c06d81f7..f645c29a7a5 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -113,7 +113,7 @@ static void DirectionToThetaPhi(float *toSun, float *theta, float *phi) * PerezFunction: * compute perez function value based on input paramters * */ -float PerezFunction(struct SunSky *sunsky, const float *lam, float theta, float gamma, float lvz) +static float PerezFunction(struct SunSky *sunsky, const float *lam, float theta, float gamma, float lvz) { float den, num; @@ -313,7 +313,7 @@ void GetSkyXYZRadiancef(struct SunSky* sunsky, const float varg[3], float color_ * turbidity: is atmosphere turbidity * fTau: contains computed attenuated sun light * */ -void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3]) +static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3]) { float fBeta ; float fTauR, fTauA; diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index fc3280db771..8293143a2a6 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -74,7 +74,7 @@ extern struct Render R; /* Recursive test for intersections, from a point inside the mesh, to outside * Number of intersections (depth) determine if a point is inside or outside the mesh */ -int intersect_outside_volume(RayObject *tree, Isect *isect, float *offset, int limit, int depth) +static int intersect_outside_volume(RayObject *tree, Isect *isect, float *offset, int limit, int depth) { if (limit == 0) return depth; @@ -96,7 +96,7 @@ int intersect_outside_volume(RayObject *tree, Isect *isect, float *offset, int l } /* Uses ray tracing to check if a point is inside or outside an ObjectInstanceRen */ -int point_inside_obi(RayObject *tree, ObjectInstanceRen *UNUSED(obi), float *co) +static int point_inside_obi(RayObject *tree, ObjectInstanceRen *UNUSED(obi), float *co) { Isect isect= {{0}}; float dir[3] = {0.0f,0.0f,1.0f}; @@ -350,7 +350,7 @@ static void ms_diffuse(float *x0, float *x, float diff, int *n) //n is the unpad } } -void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Material *ma) +static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Material *ma) { const float diff = ma->vol.ms_diff * 0.001f; /* compensate for scaling for a nicer UI range */ const int simframes = (int)(ma->vol.ms_spread * (float)MAX3(vp->res[0], vp->res[1], vp->res[2])); @@ -538,7 +538,7 @@ static void *vol_precache_part(void *data) pa->done = 1; - return 0; + return NULL; } @@ -676,7 +676,7 @@ static int precache_resolution(Render *re, VolumePrecache *vp, ObjectInstanceRen * in camera space, aligned with the ObjectRen's bounding box. * Resolution is defined by the user. */ -void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *obi, Material *ma) +static void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *obi, Material *ma) { VolumePrecache *vp; VolPrecachePart *nextpa, *pa; @@ -709,9 +709,8 @@ void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *obi, Mat vp->data_r = MEM_callocN(sizeof(float)*vp->res[0]*vp->res[1]*vp->res[2], "volume light cache data red channel"); vp->data_g = MEM_callocN(sizeof(float)*vp->res[0]*vp->res[1]*vp->res[2], "volume light cache data green channel"); vp->data_b = MEM_callocN(sizeof(float)*vp->res[0]*vp->res[1]*vp->res[2], "volume light cache data blue channel"); - if (vp->data_r==0 || vp->data_g==0 || vp->data_b==0) { + if (vp->data_r==NULL || vp->data_g==NULL || vp->data_b==NULL) { MEM_freeN(vp); - vp = NULL; return; } diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index dde9dbb8485..09422af7c79 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -305,7 +305,7 @@ float vol_get_density(struct ShadeInput *shi, float *co) /* Color of light that gets scattered out by the volume */ /* Uses same physically based scattering parameter as in transmission calculations, * along with artificial reflection scale/reflection color tint */ -void vol_get_reflection_color(ShadeInput *shi, float *ref_col, float *co) +static void vol_get_reflection_color(ShadeInput *shi, float *ref_col, float *co) { float scatter = shi->mat->vol.scattering; float reflection= shi->mat->vol.reflection; @@ -325,7 +325,7 @@ void vol_get_reflection_color(ShadeInput *shi, float *ref_col, float *co) /* compute emission component, amount of radiance to add per segment * can be textured with 'emit' */ -void vol_get_emission(ShadeInput *shi, float *emission_col, float *co) +static void vol_get_emission(ShadeInput *shi, float *emission_col, float *co) { float emission = shi->mat->vol.emission; VECCOPY(emission_col, shi->mat->vol.emission_col); @@ -343,7 +343,7 @@ void vol_get_emission(ShadeInput *shi, float *emission_col, float *co) * This can possibly use a specific scattering color, * and absorption multiplier factor too, but these parameters are left out for simplicity. * It's easy enough to get a good wide range of results with just these two parameters. */ -void vol_get_sigma_t(ShadeInput *shi, float *sigma_t, float *co) +static void vol_get_sigma_t(ShadeInput *shi, float *sigma_t, float *co) { /* technically absorption, but named transmission color * since it describes the effect of the coloring *after* absorption */ @@ -361,7 +361,7 @@ void vol_get_sigma_t(ShadeInput *shi, float *sigma_t, float *co) /* phase function - determines in which directions the light * is scattered in the volume relative to incoming direction * and view direction */ -float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, float *w, float *wp) +static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, float *w, float *wp) { const float normalize = 0.25f; // = 1.f/4.f = M_PI/(4.f*M_PI) @@ -408,7 +408,7 @@ float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, float *w, float *wp) } /* Compute transmittance = e^(-attenuation) */ -void vol_get_transmittance_seg(ShadeInput *shi, float *tr, float stepsize, float *co, float density) +static void vol_get_transmittance_seg(ShadeInput *shi, float *tr, float stepsize, float *co, float density) { /* input density = density at co */ float tau[3] = {0.f, 0.f, 0.f}; @@ -464,7 +464,7 @@ static void vol_get_transmittance(ShadeInput *shi, float *tr, float *co, float * tr[2] = expf(-tau[2]); } -void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar, float *lacol) +static void vol_shade_one_lamp(struct ShadeInput *shi, float *co, LampRen *lar, float *lacol) { float visifac, lv[3], lampdist; float tr[3]={1.0,1.0,1.0}; diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 1a056b56eff..6f03928e1fc 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -37,12 +37,13 @@ set(INC ../blenloader ../editors/include ../render/extern/include - ../../kernel/gen_system ../../../intern/guardedalloc ../../../intern/memutil ../../../intern/elbeem/extern ../../../intern/ghost ../../../intern/opennl/extern + ../../../source/gameengine/BlenderRoutines + ${ZLIB_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_PATH} ) diff --git a/source/blender/windowmanager/SConscript b/source/blender/windowmanager/SConscript index cbaf74ddc10..f52ac8ba3cb 100644 --- a/source/blender/windowmanager/SConscript +++ b/source/blender/windowmanager/SConscript @@ -8,11 +8,14 @@ sources = env.Glob('intern/*.c') incs = '. ../editors/include ../python ../makesdna ../blenlib ../blenkernel' incs += ' ../nodes ../imbuf ../blenloader ../render/extern/include' -incs += ' ../radiosity/extern/include ../../kernel/gen_system' +incs += ' ../radiosity/extern/include' incs += ' ../makesrna ../gpu ../blenfont' incs += ' #/intern/guardedalloc #/intern/memutil #/intern/ghost' incs += ' #/intern/elbeem #/extern/glew/include' +incs += ' #source/gameengine/BlenderRoutines' + +incs += ' ' + env['BF_ZLIB_INC'] defs = [ 'GLEW_STATIC' ] diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1b4fff8cd13..e08e681f494 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -95,7 +95,7 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type); int WM_read_homefile_exec(struct bContext *C, struct wmOperator *op); int WM_read_homefile (struct bContext *C, struct ReportList *reports, short from_memory); int WM_write_homefile (struct bContext *C, struct wmOperator *op); -void WM_read_file (struct bContext *C, const char *name, struct ReportList *reports); +void WM_read_file (struct bContext *C, const char *filepath, struct ReportList *reports); int WM_write_file (struct bContext *C, const char *target, int fileflags, struct ReportList *reports, int copy); void WM_read_autosavefile(struct bContext *C); void WM_autosave_init (struct wmWindowManager *wm); @@ -216,7 +216,7 @@ int WM_operator_confirm_message(struct bContext *C, struct wmOperator *op, con /* operator api */ void WM_operator_free (struct wmOperator *op); -void WM_operator_stack_clear(struct bContext *C); +void WM_operator_stack_clear(struct wmWindowManager *wm); struct wmOperatorType *WM_operatortype_find(const char *idnamem, int quiet); struct wmOperatorType *WM_operatortype_first(void); @@ -293,12 +293,6 @@ struct wmGesture *WM_gesture_new(struct bContext *C, struct wmEvent *event, int void WM_gesture_end(struct bContext *C, struct wmGesture *gesture); void WM_gestures_remove(struct bContext *C); - /* radial control operator */ -int WM_radial_control_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); -int WM_radial_control_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); -void WM_OT_radial_control_partial(struct wmOperatorType *ot); -void WM_radial_control_string(struct wmOperator *op, char str[], int maxlen); - /* fileselecting support */ void WM_event_add_fileselect(struct bContext *C, struct wmOperator *op); void WM_event_fileselect_event(struct bContext *C, void *ophandle, int eventval); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 8748703ad8e..ab68c6ef4d4 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -335,8 +335,8 @@ typedef struct wmEvent { short type; /* event code itself (short, is also in keymap) */ short val; /* press, release, scrollvalue */ - short x, y; /* mouse pointer position, screen coord */ - short mval[2]; /* region mouse position, name convention pre 2.5 :) */ + int x, y; /* mouse pointer position, screen coord */ + int mval[2]; /* region mouse position, name convention pre 2.5 :) */ short unicode; /* future, ghost? */ char ascii; /* from ghost */ char pad; @@ -344,9 +344,9 @@ typedef struct wmEvent { /* previous state */ short prevtype; short prevval; - short prevx, prevy; + int prevx, prevy; double prevclicktime; - short prevclickx, prevclicky; + int prevclickx, prevclicky; /* modifier states */ short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ @@ -494,7 +494,7 @@ typedef struct wmDrag { struct ImBuf *imb; /* if no icon but imbuf should be drawn around cursor */ float scale; - short sx, sy; + int sx, sy; char opname[240]; /* FILE_MAX */ /* if set, draws operator name*/ } wmDrag; diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 424c13f089f..bcd5cf38f88 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -137,9 +137,8 @@ void wm_operator_register(bContext *C, wmOperator *op) } -void WM_operator_stack_clear(bContext *C) +void WM_operator_stack_clear(wmWindowManager *wm) { - wmWindowManager *wm= CTX_wm_manager(C); wmOperator *op; while((op= wm->operators.first)) { @@ -147,7 +146,7 @@ void WM_operator_stack_clear(bContext *C) WM_operator_free(op); } - WM_event_add_notifier(C, NC_WM|ND_HISTORY, NULL); + WM_main_add_notifier(NC_WM|ND_HISTORY, NULL); } /* ****************************************** */ diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 61b3dd1f63a..82ca2ab62ff 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -837,11 +837,3 @@ void wm_draw_region_clear(wmWindow *win, ARegion *ar) win->screen->do_draw= 1; } -static void wm_draw_region_modified(wmWindow *win, ARegion *ar) -{ - int drawmethod= wm_automatic_draw_method(win); - - if(ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP)) - ED_region_tag_redraw(ar); -} - diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 3f9aa2bcc82..ba344997d8a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2299,7 +2299,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event) /* imperfect but probably usable... draw/enable drags to other windows */ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *evt) { - short mx= evt->x, my= evt->y; + int mx= evt->x, my= evt->y; if(wm->windows.first== wm->windows.last) return NULL; @@ -2316,8 +2316,8 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi return NULL; /* to desktop space */ - mx+= win->posx; - my+= win->posy; + mx += (int)win->posx; + my += (int)win->posy; /* check other windows to see if it has mouse inside */ for(owin= wm->windows.first; owin; owin= owin->next) { @@ -2325,8 +2325,8 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi if(owin!=win) { if(mx-owin->posx >= 0 && my-owin->posy >= 0 && mx-owin->posx <= owin->sizex && my-owin->posy <= owin->sizey) { - evt->x= mx-owin->posx; - evt->y= my-owin->posy; + evt->x= mx - (int)owin->posx; + evt->y= my - (int)owin->posy; return owin; } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index fec60ac3dc8..ea77fca4712 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -37,6 +37,8 @@ #include #include +#include "zlib.h" /* wm_read_exotic() */ + #ifdef WIN32 #include /* need to include windows.h so _WIN32_IE is defined */ #ifndef _WIN32_IE @@ -69,7 +71,6 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" -#include "BKE_exotic.h" #include "BKE_font.h" #include "BKE_global.h" #include "BKE_library.h" @@ -277,7 +278,62 @@ static void wm_init_userdef(bContext *C) if(U.tempdir[0]) BLI_where_is_temp(btempdir, FILE_MAX, 1); } -void WM_read_file(bContext *C, const char *name, ReportList *reports) + + +/* return codes */ +#define BKE_READ_EXOTIC_FAIL_PATH -3 /* file format is not supported */ +#define BKE_READ_EXOTIC_FAIL_FORMAT -2 /* file format is not supported */ +#define BKE_READ_EXOTIC_FAIL_OPEN -1 /* Can't open the file */ +#define BKE_READ_EXOTIC_OK_BLEND 0 /* .blend file */ +#define BKE_READ_EXOTIC_OK_OTHER 1 /* other supported formats */ + +/* intended to check for non-blender formats but for now it only reads blends */ +static int wm_read_exotic(Scene *UNUSED(scene), const char *name) +{ + int len; + gzFile gzfile; + char header[7]; + int retval; + + // make sure we're not trying to read a directory.... + + len= strlen(name); + if (ELEM(name[len-1], '/', '\\')) { + retval= BKE_READ_EXOTIC_FAIL_PATH; + } + else { + gzfile = gzopen(name,"rb"); + + if (gzfile == NULL) { + retval= BKE_READ_EXOTIC_FAIL_OPEN; + } + else { + len= gzread(gzfile, header, sizeof(header)); + gzclose(gzfile); + if (len == sizeof(header) && strncmp(header, "BLENDER", 7) == 0) { + retval= BKE_READ_EXOTIC_OK_BLEND; + } + else { + //XXX waitcursor(1); + /* + if(is_foo_format(name)) { + read_foo(name); + retval= BKE_READ_EXOTIC_OK_OTHER; + } + else + */ + { + retval= BKE_READ_EXOTIC_FAIL_FORMAT; + } + //XXX waitcursor(0); + } + } + } + + return retval; +} + +void WM_read_file(bContext *C, const char *filepath, ReportList *reports) { int retval; @@ -289,7 +345,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) /* first try to append data from exotic file formats... */ /* it throws error box when file doesnt exist and returns -1 */ /* note; it should set some error message somewhere... (ton) */ - retval= BKE_read_exotic(CTX_data_scene(C), name); + retval= wm_read_exotic(CTX_data_scene(C), filepath); /* we didn't succeed, now try to read Blender file */ if (retval == BKE_READ_EXOTIC_OK_BLEND) { @@ -300,7 +356,7 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) /* also exit screens and editors */ wm_window_match_init(C, &wmbase); - retval= BKE_read_file(C, name, reports); + retval= BKE_read_file(C, filepath, reports); G.save_over = 1; /* this flag is initialized by the operator but overwritten on read. @@ -360,16 +416,16 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports) else if(retval == BKE_READ_EXOTIC_OK_OTHER) BKE_write_undo(C, "Import file"); else if(retval == BKE_READ_EXOTIC_FAIL_OPEN) { - BKE_reportf(reports, RPT_ERROR, "Can't read file: \"%s\", %s.", name, errno ? strerror(errno) : "Unable to open the file"); + BKE_reportf(reports, RPT_ERROR, "Can't read file: \"%s\", %s.", filepath, errno ? strerror(errno) : "Unable to open the file"); } else if(retval == BKE_READ_EXOTIC_FAIL_FORMAT) { - BKE_reportf(reports, RPT_ERROR, "File format is not supported in file: \"%s\".", name); + BKE_reportf(reports, RPT_ERROR, "File format is not supported in file: \"%s\".", filepath); } else if(retval == BKE_READ_EXOTIC_FAIL_PATH) { - BKE_reportf(reports, RPT_ERROR, "File path invalid: \"%s\".", name); + BKE_reportf(reports, RPT_ERROR, "File path invalid: \"%s\".", filepath); } else { - BKE_reportf(reports, RPT_ERROR, "Unknown error loading: \"%s\".", name); + BKE_reportf(reports, RPT_ERROR, "Unknown error loading: \"%s\".", filepath); BLI_assert(!"invalid 'retval'"); } @@ -653,7 +709,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re { Library *li; int len; - char di[FILE_MAX]; + char filepath[FILE_MAX]; int *thumb= NULL; ImBuf *ibuf_thumb= NULL; @@ -670,14 +726,14 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re return -1; } - BLI_strncpy(di, target, FILE_MAX); - BLI_replace_extension(di, FILE_MAX, ".blend"); + BLI_strncpy(filepath, target, FILE_MAX); + BLI_replace_extension(filepath, FILE_MAX, ".blend"); /* dont use 'target' anymore */ /* send the OnSave event */ for (li= G.main->library.first; li; li= li->id.next) { - if (BLI_path_cmp(li->filepath, di) == 0) { - BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.200s'", di); + if (BLI_path_cmp(li->filepath, filepath) == 0) { + BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.200s'", filepath); return -1; } } @@ -698,12 +754,12 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb); /* rename to .blend1, do this as last before write */ - do_history(di, reports); + do_history(filepath, reports); - if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) { + if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) { if(!copy) { G.relbase_valid = 1; - BLI_strncpy(G.main->name, di, sizeof(G.main->name)); /* is guaranteed current file */ + BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */ G.save_over = 1; /* disable untitled.blend convention */ } @@ -718,7 +774,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re /* run this function after because the file cant be written before the blend is */ if (ibuf_thumb) { - ibuf_thumb= IMB_thumb_create(di, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb); + ibuf_thumb= IMB_thumb_create(filepath, THB_NORMAL, THB_SOURCE_BLEND, ibuf_thumb); IMB_freeImBuf(ibuf_thumb); } @@ -742,20 +798,20 @@ int WM_write_homefile(bContext *C, wmOperator *op) { wmWindowManager *wm= CTX_wm_manager(C); wmWindow *win= CTX_wm_window(C); - char tstr[FILE_MAXDIR+FILE_MAXFILE]; + char filepath[FILE_MAXDIR+FILE_MAXFILE]; int fileflags; /* check current window and close it if temp */ if(win->screen->temp) wm_window_close(C, wm, win); - BLI_make_file_string("/", tstr, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE); - printf("trying to save homefile at %s ", tstr); + BLI_make_file_string("/", filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE); + printf("trying to save homefile at %s ", filepath); /* force save as regular blend file */ fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN); - if(BLO_write_file(CTX_data_main(C), tstr, fileflags, op->reports, NULL) == 0) { + if(BLO_write_file(CTX_data_main(C), filepath, fileflags, op->reports, NULL) == 0) { printf("fail\n"); return OPERATOR_CANCELLED; } @@ -769,7 +825,7 @@ int WM_write_homefile(bContext *C, wmOperator *op) /************************ autosave ****************************/ -void wm_autosave_location(char *filename) +void wm_autosave_location(char *filepath) { char pidstr[32]; #ifdef WIN32 @@ -789,12 +845,12 @@ void wm_autosave_location(char *filename) * If there is no C:\tmp autosave fails. */ if (!BLI_exists(U.tempdir)) { savedir = BLI_get_folder_create(BLENDER_USER_AUTOSAVE, NULL); - BLI_make_file_string("/", filename, savedir, pidstr); + BLI_make_file_string("/", filepath, savedir, pidstr); return; } #endif - BLI_make_file_string("/", filename, U.tempdir, pidstr); + BLI_make_file_string("/", filepath, U.tempdir, pidstr); } void WM_autosave_init(wmWindowManager *wm) @@ -809,7 +865,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w { wmWindow *win; wmEventHandler *handler; - char filename[FILE_MAX]; + char filepath[FILE_MAX]; int fileflags; WM_event_remove_timer(wm, NULL, wm->autosavetimer); @@ -824,13 +880,13 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w } } - wm_autosave_location(filename); + wm_autosave_location(filepath); /* force save as regular blend file */ fileflags = G.fileflags & ~(G_FILE_COMPRESS|G_FILE_AUTOPLAY |G_FILE_LOCK|G_FILE_SIGN); /* no error reporting to console */ - BLO_write_file(CTX_data_main(C), filename, fileflags, NULL, NULL); + BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL); /* do timer after file write, just in case file write takes a long time */ wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime*60.0); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index eba0e0f83eb..674af7c8f19 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -73,7 +73,7 @@ #endif #ifdef WITH_GAMEENGINE -#include "SYS_System.h" +#include "BL_System.h" #endif #include "GHOST_Path-api.h" #include "GHOST_C-api.h" diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 63a8ecc4043..745ae0ae47e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -61,6 +61,7 @@ #include "BLO_readfile.h" #include "BKE_blender.h" +#include "BKE_brush.h" #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_idprop.h" @@ -698,11 +699,16 @@ static void operator_enum_call_cb(struct bContext *C, void *arg1, void *arg2) wmOperatorType *ot= arg1; if(ot) { - PointerRNA props_ptr; - WM_operator_properties_create_ptr(&props_ptr, ot); - RNA_property_enum_set(&props_ptr, ot->prop, GET_INT_FROM_POINTER(arg2)); - WM_operator_name_call(C, ot->idname, WM_OP_EXEC_DEFAULT, &props_ptr); - WM_operator_properties_free(&props_ptr); + if(ot->prop) { + PointerRNA props_ptr; + WM_operator_properties_create_ptr(&props_ptr, ot); + RNA_property_enum_set(&props_ptr, ot->prop, GET_INT_FROM_POINTER(arg2)); + WM_operator_name_call(C, ot->idname, WM_OP_EXEC_DEFAULT, &props_ptr); + WM_operator_properties_free(&props_ptr); + } + else { + printf("operator_enum_call_cb: op->prop for '%s' is NULL\n", ot->idname); + } } } @@ -1322,10 +1328,20 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev /* op->poll */ static int wm_search_menu_poll(bContext *C) { - if(CTX_wm_window(C)==NULL) return 0; - if(CTX_wm_area(C) && CTX_wm_area(C)->spacetype==SPACE_CONSOLE) return 0; // XXX - so we can use the shortcut in the console - if(CTX_wm_area(C) && CTX_wm_area(C)->spacetype==SPACE_TEXT) return 0; // XXX - so we can use the spacebar in the text editor - if(CTX_data_edit_object(C) && CTX_data_edit_object(C)->type==OB_FONT) return 0; // XXX - so we can use the spacebar for entering text + if(CTX_wm_window(C)==NULL) { + return 0; + } + else { + ScrArea *sa= CTX_wm_area(C); + if(sa) { + if(sa->spacetype==SPACE_CONSOLE) return 0; // XXX - so we can use the shortcut in the console + if(sa->spacetype==SPACE_TEXT) return 0; // XXX - so we can use the spacebar in the text editor + } + else { + Object *editob= CTX_data_edit_object(C); + if(editob && editob->type==OB_FONT) return 0; // XXX - so we can use the spacebar for entering text + } + } return 1; } @@ -2030,6 +2046,8 @@ static void WM_OT_quit_blender(wmOperatorType *ot) /* *********************** */ +#if defined(WIN32) + static int wm_console_toggle_op(bContext *UNUSED(C), wmOperator *UNUSED(op)) { GHOST_toggleConsole(2); @@ -2046,6 +2064,8 @@ static void WM_OT_console_toggle(wmOperatorType *ot) ot->poll= WM_operator_winactive; } +#endif + /* ************ default paint cursors, draw always around cursor *********** */ /* - returns handler to free @@ -2482,7 +2502,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) } { - short x, y; + int x, y; short *lasso= gesture->customdata; lasso += (2 * gesture->points - 2); @@ -2665,272 +2685,465 @@ void WM_OT_straightline_gesture(wmOperatorType *ot) static const int WM_RADIAL_CONTROL_DISPLAY_SIZE = 200; -typedef struct wmRadialControl { - int mode; - float initial_value, value, max_value; - float col[4], tex_col[4]; +typedef struct { + PropertyType type; + PropertySubType subtype; + PointerRNA ptr, col_ptr, fill_col_ptr, rot_ptr, zoom_ptr, image_id_ptr; + PropertyRNA *prop, *col_prop, *fill_col_prop, *rot_prop, *zoom_prop; + StructRNA *image_id_srna; + float initial_value, current_value, min_value, max_value; int initial_mouse[2]; + unsigned int gltex; + ListBase orig_paintcursors; void *cursor; - GLuint tex; -} wmRadialControl; +} RadialControl; -static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) +static void radial_control_set_initial_mouse(RadialControl *rc, wmEvent *event) { - wmRadialControl *rc = (wmRadialControl*)customdata; + float d[2] = {0, 0}; + float zoom[2] = {1, 1}; + + rc->initial_mouse[0]= event->x; + rc->initial_mouse[1]= event->y; + + switch(rc->subtype) { + case PROP_DISTANCE: + d[0] = rc->initial_value; + break; + case PROP_FACTOR: + d[0] = WM_RADIAL_CONTROL_DISPLAY_SIZE * (1 - rc->initial_value); + break; + case PROP_ANGLE: + d[0] = WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(rc->initial_value); + d[1] = WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(rc->initial_value); + break; + default: + return; + } + + if(rc->zoom_prop) { + RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); + d[0] *= zoom[0]; + d[1] *= zoom[1]; + } + + rc->initial_mouse[0]-= d[0]; + rc->initial_mouse[1]-= d[1]; +} + +static void radial_control_set_tex(RadialControl *rc) +{ + ImBuf *ibuf; + + switch(RNA_type_to_ID_code(rc->image_id_ptr.type)) { + case ID_BR: + if((ibuf = brush_gen_radial_control_imbuf(rc->image_id_ptr.data))) { + glGenTextures(1, &rc->gltex); + glBindTexture(GL_TEXTURE_2D, rc->gltex); + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, ibuf->x, ibuf->y, 0, + GL_ALPHA, GL_FLOAT, ibuf->rect_float); + MEM_freeN(ibuf->rect_float); + MEM_freeN(ibuf); + } + break; + default: + break; + } +} + +static void radial_control_paint_tex(RadialControl *rc, float radius, float alpha) +{ + float col[3] = {0, 0, 0}; + float rot; + + /* set fill color */ + if(rc->fill_col_prop) + RNA_property_float_get_array(&rc->fill_col_ptr, rc->fill_col_prop, col); + glColor4f(col[0], col[1], col[2], alpha); + + if(rc->gltex) { + glBindTexture(GL_TEXTURE_2D, rc->gltex); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + /* set up rotation if available */ + if(rc->rot_prop) { + rot = RNA_property_float_get(&rc->rot_ptr, rc->rot_prop); + glPushMatrix(); + glRotatef(RAD2DEGF(rot), 0, 0, 1); + } + + /* draw textured quad */ + glEnable(GL_TEXTURE_2D); + glBegin(GL_QUADS); + glTexCoord2f(0,0); + glVertex2f(-radius, -radius); + glTexCoord2f(1,0); + glVertex2f(radius, -radius); + glTexCoord2f(1,1); + glVertex2f(radius, radius); + glTexCoord2f(0,1); + glVertex2f(-radius, radius); + glEnd(); + glDisable(GL_TEXTURE_2D); + + /* undo rotation */ + if(rc->rot_prop) + glPopMatrix(); + } + else { + /* flat color if no texture available */ + glutil_draw_filled_arc(0, M_PI * 2, radius, 40); + } +} + +static void radial_control_paint_cursor(bContext *C, int x, int y, void *customdata) +{ + RadialControl *rc = customdata; ARegion *ar = CTX_wm_region(C); - float r1=0.0f, r2=0.0f, r3=0.0f, angle=0.0f; + float r1=0.0f, r2=0.0f, tex_radius, alpha; + float zoom[2], col[3] = {1, 1, 1}; - // int hit = 0; - - if(rc->mode == WM_RADIALCONTROL_STRENGTH) - rc->tex_col[3]= (rc->value + 0.5f); - - if(rc->mode == WM_RADIALCONTROL_SIZE) { - r1= rc->value; + switch(rc->subtype) { + case PROP_DISTANCE: + r1= rc->current_value; r2= rc->initial_value; - r3= r1; - } else if(rc->mode == WM_RADIALCONTROL_STRENGTH) { - r1= (1 - rc->value) * WM_RADIAL_CONTROL_DISPLAY_SIZE; - r2= r3= (float)WM_RADIAL_CONTROL_DISPLAY_SIZE; - } else if(rc->mode == WM_RADIALCONTROL_ANGLE) { - r1= r2= r3= (float)WM_RADIAL_CONTROL_DISPLAY_SIZE; - angle = rc->value; + tex_radius= r1; + alpha = 0.75; + break; + case PROP_FACTOR: + r1= (1 - rc->current_value) * WM_RADIAL_CONTROL_DISPLAY_SIZE; + r2= tex_radius= WM_RADIAL_CONTROL_DISPLAY_SIZE; + alpha = rc->current_value / 2 + 0.5; + break; + case PROP_ANGLE: + r1= r2= tex_radius= WM_RADIAL_CONTROL_DISPLAY_SIZE; + alpha = 0.75; + break; + default: + break; } /* Keep cursor in the original place */ x = rc->initial_mouse[0] - ar->winrct.xmin; y = rc->initial_mouse[1] - ar->winrct.ymin; - glTranslatef((float)x, (float)y, 0.0f); glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); - if(rc->mode == WM_RADIALCONTROL_ANGLE) { - glRotatef(angle, 0, 0, 1); + /* apply zoom if available */ + if(rc->zoom_prop) { + RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); + glScalef(zoom[0], zoom[1], 1); } - if (rc->tex) { - glBindTexture(GL_TEXTURE_2D, rc->tex); + /* draw rotated texture */ + radial_control_paint_tex(rc, tex_radius, alpha); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + /* set line color */ + if(rc->col_prop) + RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col); + glColor4f(col[0], col[1], col[2], 0.5); - glEnable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glColor4fv(rc->tex_col); - glTexCoord2f(0,0); - glVertex2f(-r3, -r3); - glTexCoord2f(1,0); - glVertex2f(r3, -r3); - glTexCoord2f(1,1); - glVertex2f(r3, r3); - glTexCoord2f(0,1); - glVertex2f(-r3, r3); - glEnd(); - glDisable(GL_TEXTURE_2D); - } - - if(rc->mode == WM_RADIALCONTROL_ANGLE) { - glColor4fv(rc->col); - glEnable(GL_LINE_SMOOTH); - glRotatef(-angle, 0, 0, 1); + if(rc->subtype == PROP_ANGLE) { + glPushMatrix(); + /* draw original angle line */ + glRotatef(RAD2DEGF(rc->initial_value), 0, 0, 1); fdrawline(0.0f, 0.0f, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); - glRotatef(angle, 0, 0, 1); + /* draw new angle line */ + glRotatef(RAD2DEGF(rc->current_value - rc->initial_value), 0, 0, 1); fdrawline(0.0f, 0.0f, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); - glDisable(GL_LINE_SMOOTH); + glPopMatrix(); } - glColor4fv(rc->col); + /* draw circles on top */ glutil_draw_lined_arc(0.0, (float)(M_PI*2.0), r1, 40); glutil_draw_lined_arc(0.0, (float)(M_PI*2.0), r2, 40); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); } -int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) +/* attempt to retrieve the rna pointer/property from an rna path; + returns 0 for failure, 1 for success, and also 1 if property is not + set */ +static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op, + const char *name, PointerRNA *r_ptr, + PropertyRNA **r_prop, int req_float, + int req_length, int allow_missing) { - wmRadialControl *rc = (wmRadialControl*)op->customdata; - int mode, initial_mouse[2], delta[2]; - float dist; - double new_value = RNA_float_get(op->ptr, "new_value"); - int ret = OPERATOR_RUNNING_MODAL; - // float initial_value = RNA_float_get(op->ptr, "initial_value"); + PropertyRNA *unused_prop; + int len; + char *str; - mode = RNA_enum_get(op->ptr, "mode"); - RNA_int_get_array(op->ptr, "initial_mouse", initial_mouse); + /* get an rna string path from the operator's properties */ + if(!(str = RNA_string_get_alloc(op->ptr, name, NULL, 0))) + return 1; + + if(str[0] == '\0') { + MEM_freeN(str); + return 1; + } + + if(!r_prop) + r_prop = &unused_prop; + + /* get rna from path */ + if(!RNA_path_resolve(ctx_ptr, str, r_ptr, r_prop)) { + MEM_freeN(str); + if(allow_missing) + return 1; + else { + BKE_reportf(op->reports, RPT_ERROR, "Couldn't resolve path %s", name); + return 0; + } + } + + /* if property is expected to be a float, check its type */ + if(req_float) { + if(!(*r_prop) || (RNA_property_type(*r_prop) != PROP_FLOAT)) { + MEM_freeN(str); + BKE_reportf(op->reports, RPT_ERROR, + "Property from path %s is not a float", name); + return 0; + } + } + + /* check property's array length */ + if(*r_prop && (len = RNA_property_array_length(r_ptr, *r_prop)) != req_length) { + MEM_freeN(str); + BKE_reportf(op->reports, RPT_ERROR, + "Property from path %s has length %d instead of %d", + name, len, req_length); + return 0; + } + + /* success */ + MEM_freeN(str); + return 1; +} + +/* initialize the rna pointers and properties using rna paths */ +static int radial_control_get_properties(bContext *C, wmOperator *op) +{ + RadialControl *rc = op->customdata; + PointerRNA ctx_ptr; + + RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr); + + if(!radial_control_get_path(&ctx_ptr, op, "data_path", &rc->ptr, &rc->prop, 0, 0, 0)) + return 0; + + /* data path is required */ + if(!rc->prop) + return 0; + + if(!radial_control_get_path(&ctx_ptr, op, "rotation_path", &rc->rot_ptr, &rc->rot_prop, 1, 0, 0)) + return 0; + if(!radial_control_get_path(&ctx_ptr, op, "color_path", &rc->col_ptr, &rc->col_prop, 1, 3, 0)) + return 0; + if(!radial_control_get_path(&ctx_ptr, op, "fill_color_path", &rc->fill_col_ptr, &rc->fill_col_prop, 1, 3, 0)) + return 0; + + /* slightly ugly; allow this property to not resolve + correctly. needed because 3d texture paint shares the same + keymap as 2d image paint */ + if(!radial_control_get_path(&ctx_ptr, op, "zoom_path", &rc->zoom_ptr, &rc->zoom_prop, 1, 2, 1)) + return 0; + + if(!radial_control_get_path(&ctx_ptr, op, "image_id", &rc->image_id_ptr, NULL, 0, 0, 0)) + return 0; + else if(rc->image_id_ptr.data) { + /* extra check, pointer must be to an ID */ + if(!RNA_struct_is_ID(rc->image_id_ptr.type)) { + BKE_report(op->reports, RPT_ERROR, + "Pointer from path image_id is not an ID"); + return 0; + } + } + + return 1; +} + +static int radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + wmWindowManager *wm; + RadialControl *rc; + int min_value_int, max_value_int, step_int; + float step_float, precision; + + if(!(op->customdata = rc = MEM_callocN(sizeof(RadialControl), "RadialControl"))) + return OPERATOR_CANCELLED; + + if(!radial_control_get_properties(C, op)) { + MEM_freeN(rc); + return OPERATOR_CANCELLED; + } + + /* get type, initial, min, and max values of the property */ + switch((rc->type = RNA_property_type(rc->prop))) { + case PROP_INT: + rc->initial_value = RNA_property_int_get(&rc->ptr, rc->prop); + RNA_property_int_ui_range(&rc->ptr, rc->prop, &min_value_int, + &max_value_int, &step_int); + rc->min_value = min_value_int; + rc->max_value = max_value_int; + break; + case PROP_FLOAT: + rc->initial_value = RNA_property_float_get(&rc->ptr, rc->prop); + RNA_property_float_ui_range(&rc->ptr, rc->prop, &rc->min_value, + &rc->max_value, &step_float, &precision); + break; + default: + BKE_report(op->reports, RPT_ERROR, "Property must be an integer or a float"); + MEM_freeN(rc); + return OPERATOR_CANCELLED; + } + + /* get subtype of property */ + rc->subtype = RNA_property_subtype(rc->prop); + if(!ELEM3(rc->subtype, PROP_DISTANCE, PROP_FACTOR, PROP_ANGLE)) { + BKE_report(op->reports, RPT_ERROR, "Property must be a distance, a factor, or an angle"); + MEM_freeN(rc); + return OPERATOR_CANCELLED; + } + + rc->current_value = rc->initial_value; + radial_control_set_initial_mouse(rc, event); + radial_control_set_tex(rc); + + /* temporarily disable other paint cursors */ + wm = CTX_wm_manager(C); + rc->orig_paintcursors = wm->paintcursors; + wm->paintcursors.first = wm->paintcursors.last = NULL; + + /* add radial control paint cursor */ + rc->cursor = WM_paint_cursor_activate(wm, op->type->poll, + radial_control_paint_cursor, rc); + + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +static void radial_control_set_value(RadialControl *rc, float val) +{ + switch(rc->type) { + case PROP_INT: + RNA_property_int_set(&rc->ptr, rc->prop, val); + break; + case PROP_FLOAT: + RNA_property_float_set(&rc->ptr, rc->prop, val); + break; + default: + break; + } +} + +static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + RadialControl *rc = op->customdata; + wmWindowManager *wm; + float new_value, dist, zoom[2]; + float delta[2], snap, ret = OPERATOR_RUNNING_MODAL; + + /* TODO: fix hardcoded events */ + + snap = event->ctrl; switch(event->type) { case MOUSEMOVE: - delta[0]= initial_mouse[0] - event->x; - delta[1]= initial_mouse[1] - event->y; + delta[0]= rc->initial_mouse[0] - event->x; + delta[1]= rc->initial_mouse[1] - event->y; - //if (mode == WM_RADIALCONTROL_SIZE) - // delta[0]+= initial_value; - //else if(mode == WM_RADIALCONTROL_STRENGTH) - // delta[0]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * (1 - initial_value); - //else if(mode == WM_RADIALCONTROL_ANGLE) { - // delta[0]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(initial_value*M_PI/180.0f); - // delta[1]+= WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(initial_value*M_PI/180.0f); - //} - - dist= sqrtf(delta[0]*delta[0]+delta[1]*delta[1]); - - if(mode == WM_RADIALCONTROL_SIZE) - new_value = dist; - else if(mode == WM_RADIALCONTROL_STRENGTH) { - new_value = 1 - dist / WM_RADIAL_CONTROL_DISPLAY_SIZE; - } else if(mode == WM_RADIALCONTROL_ANGLE) - 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)ceilf(new_value * 10.f) * 10.0f) / 100.f; - else - new_value = ((int)new_value + 5) / 10*10; + if(rc->zoom_prop) { + RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom); + delta[0] /= zoom[0]; + delta[1] /= zoom[1]; } - + + dist= sqrt(delta[0]*delta[0]+delta[1]*delta[1]); + + /* calculate new value and apply snapping */ + switch(rc->subtype) { + case PROP_DISTANCE: + new_value = dist; + if(snap) new_value = ((int)new_value + 5) / 10*10; + break; + case PROP_FACTOR: + new_value = 1 - dist / WM_RADIAL_CONTROL_DISPLAY_SIZE; + if(snap) new_value = ((int)ceil(new_value * 10.f) * 10.0f) / 100.f; + break; + case PROP_ANGLE: + new_value = atan2(delta[1], delta[0]) + M_PI; + if(snap) new_value = DEG2RADF(((int)RAD2DEGF(new_value) + 5) / 10*10); + break; + default: + break; + } + + /* clamp and update */ + CLAMP(new_value, rc->min_value, rc->max_value); + radial_control_set_value(rc, new_value); + rc->current_value = new_value; break; + case ESCKEY: case RIGHTMOUSE: + /* cancelled; restore original value */ + radial_control_set_value(rc, rc->initial_value); ret = OPERATOR_CANCELLED; break; + case LEFTMOUSE: case PADENTER: - op->type->exec(C, op); + /* done; value already set */ ret = OPERATOR_FINISHED; break; } - /* Clamp */ - if(new_value > rc->max_value) - new_value = rc->max_value; - else if(new_value < 0) - new_value = 0; - - /* Update paint data */ - rc->value = (float)new_value; - - RNA_float_set(op->ptr, "new_value", rc->value); - - if(ret != OPERATOR_RUNNING_MODAL) { - WM_paint_cursor_end(CTX_wm_manager(C), rc->cursor); - MEM_freeN(rc); - } - ED_region_tag_redraw(CTX_wm_region(C)); - //if (ret != OPERATOR_RUNNING_MODAL) { - // wmWindow *win = CTX_wm_window(C); - // WM_cursor_restore(win); - //} + if(ret != OPERATOR_RUNNING_MODAL) { + wm = CTX_wm_manager(C); + + WM_paint_cursor_end(wm, rc->cursor); + + /* restore original paint cursors */ + wm->paintcursors = rc->orig_paintcursors; + + /* not sure if this is a good notifier to use; + intended purpose is to update the UI so that the + new value is displayed in sliders/numfields */ + WM_event_add_notifier(C, NC_WINDOW, NULL); + + glDeleteTextures(1, &rc->gltex); + + MEM_freeN(rc); + } return ret; } -/* Expects the operator customdata to be an ImBuf (or NULL) */ -int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) +static void WM_OT_radial_control(wmOperatorType *ot) { - wmRadialControl *rc = MEM_callocN(sizeof(wmRadialControl), "radial control"); - // wmWindow *win = CTX_wm_window(C); - int mode = RNA_enum_get(op->ptr, "mode"); - float initial_value = RNA_float_get(op->ptr, "initial_value"); - //float initial_size = RNA_float_get(op->ptr, "initial_size"); - int mouse[2]; + ot->name= "Radial Control"; + ot->idname= "WM_OT_radial_control"; - mouse[0]= event->x; - mouse[1]= event->y; + ot->invoke= radial_control_invoke; + ot->modal= radial_control_modal; - //if (initial_size == 0) - // initial_size = WM_RADIAL_CONTROL_DISPLAY_SIZE; + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; - if(mode == WM_RADIALCONTROL_SIZE) { - rc->max_value = 200; - mouse[0]-= (int)initial_value; - } - else if(mode == WM_RADIALCONTROL_STRENGTH) { - rc->max_value = 1; - mouse[0]-= (int)(WM_RADIAL_CONTROL_DISPLAY_SIZE * (1.0f - initial_value)); - } - else if(mode == WM_RADIALCONTROL_ANGLE) { - rc->max_value = 360; - mouse[0]-= (int)(WM_RADIAL_CONTROL_DISPLAY_SIZE * cos(initial_value)); - mouse[1]-= (int)(WM_RADIAL_CONTROL_DISPLAY_SIZE * sin(initial_value)); - initial_value *= 180.0f/(float)M_PI; - } - - if(op->customdata) { - ImBuf *im = (ImBuf*)op->customdata; - /* Build GL texture */ - glGenTextures(1, &rc->tex); - glBindTexture(GL_TEXTURE_2D, rc->tex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, im->x, im->y, 0, GL_ALPHA, GL_FLOAT, im->rect_float); - MEM_freeN(im->rect_float); - MEM_freeN(im); - } - - RNA_float_get_array(op->ptr, "color", rc->col); - RNA_float_get_array(op->ptr, "texture_color", rc->tex_col); - - RNA_int_set_array(op->ptr, "initial_mouse", mouse); - RNA_float_set(op->ptr, "new_value", initial_value); - - op->customdata = rc; - rc->mode = mode; - rc->initial_value = initial_value; - rc->initial_mouse[0] = mouse[0]; - rc->initial_mouse[1] = mouse[1]; - rc->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), op->type->poll, - wm_radial_control_paint, op->customdata); - - //WM_cursor_modal(win, CURSOR_NONE); - - /* add modal handler */ - WM_event_add_modal_handler(C, op); - - WM_radial_control_modal(C, op, event); - - return OPERATOR_RUNNING_MODAL; -} - -/* Gets a descriptive string of the operation */ -void WM_radial_control_string(wmOperator *op, char str[], int maxlen) -{ - int mode = RNA_enum_get(op->ptr, "mode"); - float v = RNA_float_get(op->ptr, "new_value"); - - if(mode == WM_RADIALCONTROL_SIZE) - BLI_snprintf(str, maxlen, "Size: %d", (int)v); - 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/(float)M_PI)); -} - -/** Important: this doesn't define an actual operator, it - just sets up the common parts of the radial control op. **/ -void WM_OT_radial_control_partial(wmOperatorType *ot) -{ - static EnumPropertyItem radial_mode_items[] = { - {WM_RADIALCONTROL_SIZE, "SIZE", 0, "Size", ""}, - {WM_RADIALCONTROL_STRENGTH, "STRENGTH", 0, "Strength", ""}, - {WM_RADIALCONTROL_ANGLE, "ANGLE", 0, "Angle", ""}, - {0, NULL, 0, NULL, NULL}}; - static float color[4] = {1.0f, 1.0f, 1.0f, 0.5f}; - static float tex_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - - /* Should be set in custom invoke() */ - RNA_def_float(ot->srna, "initial_value", 0, 0, FLT_MAX, "Initial Value", "", 0, FLT_MAX); - - /* Set internally, should be used in custom exec() to get final value */ - RNA_def_float(ot->srna, "new_value", 0, 0, FLT_MAX, "New Value", "", 0, FLT_MAX); - - /* Should be set before calling operator */ - RNA_def_enum(ot->srna, "mode", radial_mode_items, 0, "Mode", ""); - - /* Internal */ - RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "Initial Mouse", "", INT_MIN, INT_MAX); - - RNA_def_float_color(ot->srna, "color", 4, color, 0.0f, FLT_MAX, "Color", "Radial control color", 0.0f, 1.0f); - RNA_def_float_color(ot->srna, "texture_color", 4, tex_color, 0.0f, FLT_MAX, "Texture Color", "Radial control texture color", 0.0f, 1.0f); + /* all paths relative to the context */ + RNA_def_string(ot->srna, "data_path", "", 0, "Data Path", "Path of property to be set by the radial control."); + RNA_def_string(ot->srna, "rotation_path", "", 0, "Rotation Path", "Path of property used to rotate the texture display."); + RNA_def_string(ot->srna, "color_path", "", 0, "Color Path", "Path of property used to set the color of the control."); + RNA_def_string(ot->srna, "fill_color_path", "", 0, "Fill Color Path", "Path of property used to set the fill color of the control."); + RNA_def_string(ot->srna, "zoom_path", "", 0, "Zoom Path", "Path of property used to set the zoom level for the control."); + RNA_def_string(ot->srna, "image_id", "", 0, "Image ID", "Path of ID that is used to generate an image for the control."); } /* ************************** timer for testing ***************** */ @@ -3124,6 +3337,7 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_splash); WM_operatortype_append(WM_OT_search_menu); WM_operatortype_append(WM_OT_call_menu); + WM_operatortype_append(WM_OT_radial_control); #if defined(WIN32) WM_operatortype_append(WM_OT_console_toggle); #endif diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index f73652125b1..fd279c31f3c 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -78,7 +78,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt); void wm_autosave_timer_ended(wmWindowManager *wm); void wm_autosave_delete(void); void wm_autosave_read(bContext *C, struct ReportList *reports); -void wm_autosave_location(char *filename); +void wm_autosave_location(char *filepath); /* hack to store circle select size - campbell, must replace with nice operator memory */ #define GESTURE_MEMORY diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 1f796e86693..901aaea3eca 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -43,13 +43,25 @@ 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 - ) + if(MINGW) + add_definitions( + -DWINDRES + -DBLEN_VER_RC_STR_M=${BLENDER_VERSION} + -DBLEN_VER_RC_1=${bver1} + -DBLEN_VER_RC_2=${bver2} + -DBLEN_VER_RC_3=${bver3} + -DBLEN_VER_RC_4=0 + ) + else() + 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 + ) + endif() + add_executable(blenderplayer ${EXETYPE} ${CMAKE_CURRENT_BINARY_DIR}/dna.c ../icons/winblender.rc) else() add_executable(blenderplayer ${CMAKE_CURRENT_BINARY_DIR}/dna.c) @@ -98,7 +110,6 @@ endif() bf_intern_smoke bf_modifiers bf_intern_moto - bf_gen_system bf_nodes bf_gpu bf_imbuf @@ -116,7 +127,6 @@ endif() extern_openjpeg extern_redcode bf_imbuf_dds - bf_readblenfile bf_dna ge_videotex bf_blenfont diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 901ec80a654..a3bd6d91a63 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -230,6 +230,7 @@ short ANIM_add_driver(struct ID *id, const char rna_path[], int array_index, sho short ANIM_remove_driver (struct ID *id, const char rna_path[], int array_index, short flag){return 0;} void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock){} struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **lock_r){return (struct ImBuf *) NULL;} +void ED_space_image_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy) {} char *ED_info_stats_string(struct Scene *scene){return (char *) NULL;} void ED_area_tag_redraw(struct ScrArea *sa){} void ED_area_tag_refresh(struct ScrArea *sa){} @@ -243,6 +244,7 @@ void ED_node_generic_update(struct Main *bmain, struct bNodeTree *ntree, struct void ED_view3d_scene_layers_update(struct Main *bmain, struct Scene *scene){} int ED_view3d_scene_layer_set(int lay, const int *values){return 0;} void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar){} +void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist){} void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist){} int text_file_modified(struct Text *text){return 0;} void ED_node_shader_default(struct Material *ma){} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 7a22746d699..f46833d1036 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -82,10 +82,7 @@ if(WITH_PYTHON) endif() if(WITH_GAMEENGINE) - blender_include_dirs( - ../kernel/gen_messaging - ../kernel/gen_system - ) + blender_include_dirs(../gameengine/BlenderRoutines) add_definitions(-DWITH_GAMEENGINE) endif() @@ -194,10 +191,10 @@ if(WITH_PYTHON_MODULE) set_target_properties( blender PROPERTIES - PREFIX "" - OUTPUT_NAME bpy - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ # only needed on windows + PREFIX "" + OUTPUT_NAME bpy + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ # only needed on windows ) if(WIN32) @@ -205,7 +202,7 @@ if(WITH_PYTHON_MODULE) set_target_properties( blender PROPERTIES - SUFFIX ".pyd" + SUFFIX ".pyd" ) endif() @@ -590,19 +587,19 @@ elseif(WIN32) endif() endif() - if(NOT CMAKE_CL_64) + if(NOT CMAKE_CL_64) install( FILES - ${LIBDIR}/thumbhandler/lib/BlendThumb.dll - DESTINATION ${TARGETDIR}/ - ) - else() + ${LIBDIR}/thumbhandler/lib/BlendThumb.dll + DESTINATION ${TARGETDIR}/ + ) + else() install( FILES - ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll - DESTINATION ${TARGETDIR}/ - ) - endif() + ${LIBDIR}/thumbhandler/lib/BlendThumb64.dll + DESTINATION ${TARGETDIR}/ + ) + endif() elseif(APPLE) set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) @@ -787,11 +784,9 @@ endif() bf_imbuf_cineon bf_imbuf_openexr bf_imbuf_dds - bf_readblenfile bf_collada bf_intern_bsp bf_intern_bop - bf_gen_system bf_intern_decimate bf_intern_elbeem bf_intern_ik @@ -813,7 +808,6 @@ endif() ge_logic_expressions ge_scenegraph ge_logic_network - bf_gen_system bf_python # duplicate for BPY_driver_exec ge_logic_ngnetwork extern_bullet @@ -829,13 +823,13 @@ endif() bf_intern_mikktspace ) - if(WITH_MOD_CLOTH_ELTOPO) + if(WITH_MOD_CLOTH_ELTOPO) list(APPEND BLENDER_SORTED_LIBS extern_eltopo) - endif() + endif() - if(WITH_BUILTIN_GLEW) + if(WITH_BUILTIN_GLEW) list(APPEND BLENDER_SORTED_LIBS extern_glew) - endif() + endif() if(WITH_BINRELOC) list(APPEND BLENDER_SORTED_LIBS extern_binreloc) diff --git a/source/creator/SConscript b/source/creator/SConscript index 8577872c48a..79e03c8dddc 100644 --- a/source/creator/SConscript +++ b/source/creator/SConscript @@ -7,8 +7,8 @@ sources = 'creator.c' incs = '#/intern/guardedalloc ../blender/blenlib ../blender/blenkernel' incs += ' ../blender/editors/include ../blender/blenloader ../blender/imbuf' incs += ' ../blender/renderconverter ../blender/render/extern/include ../blender/windowmanager' -incs += ' ../blender/makesdna ../blender/makesrna ../kernel/gen_messaging' -incs += ' ../kernel/gen_system #/extern/glew/include ../blender/gpu' +incs += ' ../blender/makesdna ../blender/makesrna' +incs += ' ../gameengine/BlenderRoutines #/extern/glew/include ../blender/gpu' incs += ' ' + env['BF_OPENGL_INC'] defs = [] diff --git a/source/creator/creator.c b/source/creator/creator.c index 1a486313c92..f7309864ce8 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -109,8 +109,7 @@ /* for passing information between creator and gameengine */ #ifdef WITH_GAMEENGINE -#include "GEN_messaging.h" -#include "SYS_System.h" +#include "BL_System.h" #else /* dummy */ #define SYS_SystemHandle int #endif @@ -153,7 +152,7 @@ char btempdir[FILE_MAX]; #define BLEND_VERSION_STRING_FMT "Blender %d.%02d (sub %d)\n", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION -/* Initialise callbacks for the modules that need them */ +/* Initialize callbacks for the modules that need them */ static void setCallbacks(void); /* set breakpoints here when running in debug mode, useful to catch floating point errors */ @@ -340,18 +339,6 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data) double PIL_check_seconds_timer(void); -/* XXX This was here to fix a crash when running python scripts - * with -P that used the screen. - * - * static void main_init_screen( void ) -{ - setscreen(G.curscreen); - - if(G.main->scene.first==0) { - set_scene( add_scene("1") ); - } -}*/ - static int end_arguments(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { return -1; @@ -1221,7 +1208,6 @@ int main(int argc, const char **argv) #ifdef WITH_GAMEENGINE syshandle = SYS_GetSystem(); - GEN_init_messaging_system(); #else syshandle= 0; #endif diff --git a/source/darwin/blender.app/Contents/Info.plist b/source/darwin/blender.app/Contents/Info.plist index 2f5d235a619..23941d91075 100644 --- a/source/darwin/blender.app/Contents/Info.plist +++ b/source/darwin/blender.app/Contents/Info.plist @@ -1,53 +1,53 @@ - - - - - CFBundleInfoDictionaryVersion - 6.0 - - CFBundleExecutable - blender - - CFBundlePackageType - APPL - CFBundleSignature - ???? - - CFBundleIconFile - blender icon.icns - - CFBundleName - Blender - CFBundleIdentifier - org.blenderfoundation.blender - - CFBundleVersion - ${MACOSX_BUNDLE_LONG_VERSION_STRING}, Blender Foundation - CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} - CFBundleGetInfoString - ${MACOSX_BUNDLE_LONG_VERSION_STRING}, Blender Foundation - - CFBundleDocumentTypes - - - CFBundleTypeIconFile - blender file icon.icns - CFBundleTypeName - Blender File - CFBundleTypeOSTypes - - BLND - - CFBundleTypeExtensions - - blend - - CFBundleTypeRole - Editor - LSIsAppleDefaultForType - - - - - + + + + + CFBundleInfoDictionaryVersion + 6.0 + + CFBundleExecutable + blender + + CFBundlePackageType + APPL + CFBundleSignature + ???? + + CFBundleIconFile + blender icon.icns + + CFBundleName + Blender + CFBundleIdentifier + org.blenderfoundation.blender + + CFBundleVersion + ${MACOSX_BUNDLE_LONG_VERSION_STRING}, Blender Foundation + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleGetInfoString + ${MACOSX_BUNDLE_LONG_VERSION_STRING}, Blender Foundation + + CFBundleDocumentTypes + + + CFBundleTypeIconFile + blender file icon.icns + CFBundleTypeName + Blender File + CFBundleTypeOSTypes + + BLND + + CFBundleTypeExtensions + + blend + + CFBundleTypeRole + Editor + LSIsAppleDefaultForType + + + + + diff --git a/source/darwin/blenderplayer.app/Contents/Info.plist b/source/darwin/blenderplayer.app/Contents/Info.plist index f99338d6c47..54364d18866 100644 --- a/source/darwin/blenderplayer.app/Contents/Info.plist +++ b/source/darwin/blenderplayer.app/Contents/Info.plist @@ -1,53 +1,53 @@ - - - - - CFBundleInfoDictionaryVersion - 6.0 - - CFBundleExecutable - blenderplayer - - CFBundlePackageType - APPL - CFBundleSignature - ???? - - CFBundleIconFile - blender player icon.icns - - CFBundleName - BlenderPlayer - CFBundleIdentifier - org.blenderfoundation.blenderplayer - - CFBundleVersion - ${MACOSX_BUNDLE_LONG_VERSION_STRING}, Blender Foundation - CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} - CFBundleGetInfoString - ${MACOSX_BUNDLE_LONG_VERSION_STRING}, Blender Foundation - - CFBundleDocumentTypes - - - CFBundleTypeIconFile - blender file icon.icns - CFBundleTypeName - Blender File - CFBundleTypeOSTypes - - BLND - - CFBundleTypeExtensions - - blend - - CFBundleTypeRole - Viewer - LSIsAppleDefaultForType - - - - - + + + + + CFBundleInfoDictionaryVersion + 6.0 + + CFBundleExecutable + blenderplayer + + CFBundlePackageType + APPL + CFBundleSignature + ???? + + CFBundleIconFile + blender player icon.icns + + CFBundleName + BlenderPlayer + CFBundleIdentifier + org.blenderfoundation.blenderplayer + + CFBundleVersion + ${MACOSX_BUNDLE_LONG_VERSION_STRING}, Blender Foundation + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleGetInfoString + ${MACOSX_BUNDLE_LONG_VERSION_STRING}, Blender Foundation + + CFBundleDocumentTypes + + + CFBundleTypeIconFile + blender file icon.icns + CFBundleTypeName + Blender File + CFBundleTypeOSTypes + + BLND + + CFBundleTypeExtensions + + blend + + CFBundleTypeRole + Viewer + LSIsAppleDefaultForType + + + + + diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index b94d15d2fbf..4789155dced 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -64,7 +64,7 @@ #include "NG_LoopBackNetworkDeviceInterface.h" -#include "SYS_System.h" +#include "BL_System.h" #include "GPU_extensions.h" #include "Value.h" @@ -427,6 +427,13 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c { // first check if we want to exit exitrequested = ketsjiengine->GetExitCode(); + + // Clear screen to border color + // We do this here since we set the canvas to be within the frames. This means the engine + // itself is unaware of the extra space, so we clear the whole region for it. + glClearColor(scene->gm.framing.col[0], scene->gm.framing.col[1], scene->gm.framing.col[2], 1.0f); + glViewport(ar->winrct.xmin, ar->winrct.ymin, ar->winrct.xmax, ar->winrct.ymax); + glClear(GL_COLOR_BUFFER_BIT); // kick the engine bool render = ketsjiengine->NextFrame(); diff --git a/source/kernel/gen_system/SYS_System.cpp b/source/gameengine/BlenderRoutines/BL_System.cpp similarity index 60% rename from source/kernel/gen_system/SYS_System.cpp rename to source/gameengine/BlenderRoutines/BL_System.cpp index b2de797fc8d..30b8beef156 100644 --- a/source/kernel/gen_system/SYS_System.cpp +++ b/source/gameengine/BlenderRoutines/BL_System.cpp @@ -25,55 +25,80 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** - * System specific information / access. * Interface to the commandline arguments */ -/** \file kernel/gen_system/SYS_System.cpp - * \ingroup gensys +/** \file gameengine/BlenderRoutines/BL_System.cpp + * \ingroup blroutines */ -#include "SYS_System.h" -#include "SYS_SingletonSystem.h" +#include "CTR_Map.h" +#include "STR_HashedString.h" +#include "BL_System.h" + +struct SingletonSystem { + CTR_Map int_params; + CTR_Map float_params; + CTR_Map string_params; +}; + +static SingletonSystem *_system_instance = NULL; SYS_SystemHandle SYS_GetSystem() { - return (SYS_SystemHandle) SYS_SingletonSystem::Instance(); + if(!_system_instance) + _system_instance = new SingletonSystem(); + + return (SYS_SystemHandle)_system_instance; } void SYS_DeleteSystem(SYS_SystemHandle sys) { - if (sys) { - ((SYS_SingletonSystem *) sys)->Destruct(); + if(_system_instance) { + delete _system_instance; + _system_instance = NULL; } } int SYS_GetCommandLineInt(SYS_SystemHandle sys, const char *paramname, int defaultvalue) { - return ((SYS_SingletonSystem *) sys)->SYS_GetCommandLineInt(paramname, defaultvalue); + int *result = ((SingletonSystem *)sys)->int_params[paramname]; + if(result) + return *result; + + return defaultvalue; } float SYS_GetCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float defaultvalue) { - return ((SYS_SingletonSystem *) sys)->SYS_GetCommandLineFloat(paramname, defaultvalue); + float *result = ((SingletonSystem *)sys)->float_params[paramname]; + if(result) + return *result; + + return defaultvalue; } const char *SYS_GetCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *defaultvalue) { - return ((SYS_SingletonSystem *) sys)->SYS_GetCommandLineString(paramname, defaultvalue); + STR_String *result = ((SingletonSystem *)sys)->string_params[paramname]; + if(result) + return *result; + + return defaultvalue; } void SYS_WriteCommandLineInt(SYS_SystemHandle sys, const char *paramname, int value) { - ((SYS_SingletonSystem *) sys)->SYS_WriteCommandLineInt(paramname, value); + ((SingletonSystem *)sys)->int_params.insert(paramname, value); } void SYS_WriteCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float value) { - ((SYS_SingletonSystem *) sys)->SYS_WriteCommandLineFloat(paramname, value); + ((SingletonSystem *)sys)->float_params.insert(paramname, value); } void SYS_WriteCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *value) { - ((SYS_SingletonSystem *) sys)->SYS_WriteCommandLineString(paramname, value); + ((SingletonSystem *)sys)->string_params.insert(paramname, value); } + diff --git a/source/kernel/gen_system/SYS_System.h b/source/gameengine/BlenderRoutines/BL_System.h similarity index 75% rename from source/kernel/gen_system/SYS_System.h rename to source/gameengine/BlenderRoutines/BL_System.h index 34fed4a81a2..d743ef5532a 100644 --- a/source/kernel/gen_system/SYS_System.h +++ b/source/gameengine/BlenderRoutines/BL_System.h @@ -29,31 +29,21 @@ * Interface to the commandline arguments */ -/** \file kernel/gen_system/SYS_System.h - * \ingroup gensys +/** \file gameengine/BlenderRoutines/BL_System.h + * \ingroup blroutines */ - -#ifndef __SYSTEM_INCLUDE -#define __SYSTEM_INCLUDE - -#define SYS_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name - -SYS_DECLARE_HANDLE(SYS_SystemHandle); - -/** - System specific information / access. - For now, only used for commandline parameters. - One of the available implementations must be linked to the application - that uses this system routines. - Please note that this protocol/interface is just for testing, - it needs discussion in the development group for a more final version. -*/ +#ifndef BL_SYSTEM_H +#define BL_SYSTEM_H #ifdef __cplusplus extern "C" { #endif +/* Game Engine command line parameters */ + +typedef void* SYS_SystemHandle; + extern SYS_SystemHandle SYS_GetSystem(void); extern void SYS_DeleteSystem(SYS_SystemHandle sys); @@ -65,9 +55,18 @@ extern void SYS_WriteCommandLineInt(SYS_SystemHandle sys, const char *paramname, extern void SYS_WriteCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float value); extern void SYS_WriteCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *value); +/* Start game engine */ + +struct bContext; +struct ARegion; +struct rcti; + +extern void StartKetsjiShell(struct bContext *C, struct ARegion *ar, + struct rcti *cam_frame, int always_use_expand_framing); + #ifdef __cplusplus } #endif -#endif //__SYSTEM_INCLUDE +#endif /* BL_SYSTEM_H */ diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index f5103034316..6a17017f261 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -1,8 +1,8 @@ set(INC . - ../../../source/kernel/gen_system ../../../intern/string + ../../../intern/container ../../../intern/guardedalloc ../../../intern/audaspace/intern ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer @@ -34,6 +34,7 @@ set(INC set(SRC BL_KetsjiEmbedStart.cpp + BL_System.cpp KX_BlenderCanvas.cpp KX_BlenderGL.cpp KX_BlenderInputDevice.cpp @@ -42,6 +43,7 @@ set(SRC KX_BlenderRenderTools.cpp KX_BlenderSystem.cpp + BL_System.h KX_BlenderCanvas.h KX_BlenderGL.h KX_BlenderInputDevice.h diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript index ff70ad3bf7b..8f59ec0bf04 100644 --- a/source/gameengine/BlenderRoutines/SConscript +++ b/source/gameengine/BlenderRoutines/SConscript @@ -4,10 +4,10 @@ Import ('env') sources = env.Glob('*.cpp') defs = [ 'GLEW_STATIC' ] -incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc' +incs = '. #intern/string #intern/guardedalloc' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' incs += ' #source/gameengine/Converter #source/blender/imbuf' -incs += ' #intern/ghost/include' +incs += ' #intern/ghost/include #intern/container' incs += ' #intern/audaspace/intern' incs += ' #intern/moto/include #source/gameengine/Ketsji #source/blender/blenlib' incs += ' #source/blender/blenkernel #source/blender' diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index c6e661f1549..ff4ca785a96 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -34,7 +34,7 @@ #ifndef BL_ACTIONACTUATOR #define BL_ACTIONACTUATOR -#include "GEN_HashedPtr.h" +#include "CTR_HashedPtr.h" #include "SCA_IActuator.h" #include "DNA_actuator_types.h" #include "MT_Point3.h" diff --git a/source/gameengine/Converter/BL_ArmatureActuator.cpp b/source/gameengine/Converter/BL_ArmatureActuator.cpp index efd1a73a448..a56fab31a26 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.cpp +++ b/source/gameengine/Converter/BL_ArmatureActuator.cpp @@ -115,7 +115,7 @@ bool BL_ArmatureActuator::UnlinkObject(SCA_IObject* clientobj) return res; } -void BL_ArmatureActuator::Relink(GEN_Map *obj_map) +void BL_ArmatureActuator::Relink(CTR_Map *obj_map) { void **h_obj = (*obj_map)[m_gametarget]; if (h_obj) { diff --git a/source/gameengine/Converter/BL_ArmatureActuator.h b/source/gameengine/Converter/BL_ArmatureActuator.h index 4615fb06714..70aa526d4d3 100644 --- a/source/gameengine/Converter/BL_ArmatureActuator.h +++ b/source/gameengine/Converter/BL_ArmatureActuator.h @@ -67,7 +67,7 @@ public: }; virtual void ProcessReplica(); virtual bool UnlinkObject(SCA_IObject* clientobj); - virtual void Relink(GEN_Map *obj_map); + virtual void Relink(CTR_Map *obj_map); virtual bool Update(double curtime, bool frame); virtual void ReParent(SCA_IObject* parent); diff --git a/source/gameengine/Converter/BL_ArmatureChannel.h b/source/gameengine/Converter/BL_ArmatureChannel.h index 0c2c27a7fab..0a66d0038a2 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.h +++ b/source/gameengine/Converter/BL_ArmatureChannel.h @@ -35,8 +35,8 @@ #define __BL_ARMATURECHANNEL #include "DNA_action_types.h" -#include "GEN_HashedPtr.h" -#include "GEN_Map.h" +#include "CTR_HashedPtr.h" +#include "CTR_Map.h" #include "PyObjectPlus.h" class SCA_IObject; diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.cpp b/source/gameengine/Converter/BL_ArmatureConstraint.cpp index c07fe6b3b41..3f1a111517c 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.cpp +++ b/source/gameengine/Converter/BL_ArmatureConstraint.cpp @@ -147,7 +147,7 @@ void BL_ArmatureConstraint::ReParent(BL_ArmatureObject* armature) } } -void BL_ArmatureConstraint::Relink(GEN_Map *obj_map) +void BL_ArmatureConstraint::Relink(CTR_Map *obj_map) { void **h_obj = (*obj_map)[m_target]; if (h_obj) { diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.h b/source/gameengine/Converter/BL_ArmatureConstraint.h index 1dd685b8cba..8e6ba1bc2d3 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.h +++ b/source/gameengine/Converter/BL_ArmatureConstraint.h @@ -35,8 +35,8 @@ #define __BL_ARMATURECONSTRAINT #include "DNA_constraint_types.h" -#include "GEN_HashedPtr.h" -#include "GEN_Map.h" +#include "CTR_HashedPtr.h" +#include "CTR_Map.h" #include "PyObjectPlus.h" class SCA_IObject; @@ -80,7 +80,7 @@ public: BL_ArmatureConstraint* GetReplica() const; void ReParent(BL_ArmatureObject* armature); - void Relink(GEN_Map *map); + void Relink(CTR_Map *map); bool UnlinkObject(SCA_IObject* clientobj); void UpdateTarget(); diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 952af4db8bb..c6c20a96482 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -45,8 +45,8 @@ #include "BKE_armature.h" #include "BKE_constraint.h" -#include "GEN_Map.h" -#include "GEN_HashedPtr.h" +#include "CTR_Map.h" +#include "CTR_HashedPtr.h" #include "MEM_guardedalloc.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" @@ -439,7 +439,7 @@ void BL_ArmatureObject::ReParentLogic() KX_GameObject::ReParentLogic(); } -void BL_ArmatureObject::Relink(GEN_Map *obj_map) +void BL_ArmatureObject::Relink(CTR_Map *obj_map) { SG_DList::iterator cit(m_controlledConstraints); for (cit.begin(); !cit.end(); ++cit) { diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index 8490bfadac2..2c3ca7404b3 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -60,7 +60,7 @@ public: short GetActivePriority(); virtual void ProcessReplica(); virtual void ReParentLogic(); - virtual void Relink(GEN_Map *obj_map); + virtual void Relink(CTR_Map *obj_map); virtual bool UnlinkObject(SCA_IObject* clientobj); class BL_ActionActuator * GetActiveAction(); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 34b417238ae..1fb30925446 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -143,9 +143,11 @@ extern "C" { #include "BKE_customdata.h" #include "BKE_cdderivedmesh.h" #include "BKE_DerivedMesh.h" +#include "BKE_material.h" /* give_current_material */ + +extern Material defmaterial; /* material.c */ } -#include "BKE_material.h" /* give_current_material */ /* end of blender include block */ #include "KX_BlenderInputDevice.h" @@ -156,7 +158,7 @@ extern "C" { #include "KX_ScalarInterpolator.h" #include "KX_IpoConvert.h" -#include "SYS_System.h" +#include "BL_System.h" #include "SG_Node.h" #include "SG_BBox.h" @@ -460,7 +462,9 @@ bool ConvertMaterial( } } } - material->flag[i] |= (mat->ipo!=0)?HASIPO:0; +#if 0 /* this flag isnt used anymore */ + material->flag[i] |= (BKE_animdata_from_id(mat->id) != NULL) ? HASIPO : 0; +#endif /// -------------------------------- // mapping methods material->mapping[i].mapping |= ( mttmp->texco & TEXCO_REFL )?USEREFL:0; @@ -835,6 +839,11 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, else ma = mesh->mat ? mesh->mat[mface->mat_nr]:NULL; + /* ckeck for texface since texface _only_ is used as a fallback */ + if(ma == NULL && tface == NULL) { + ma= &defmaterial; + } + { bool visible = true; bool twoside = false; @@ -1831,6 +1840,7 @@ static KX_GameObject *gameobject_from_blenderobject( { gameobj->SetLayer(ob->lay); gameobj->SetBlenderObject(ob); + gameobj->SetObjectColor(ob->col); /* set the visibility state based on the objects render option in the outliner */ if(ob->restrictflag & OB_RESTRICT_RENDER) gameobj->SetVisible(0, 0); } diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.h b/source/gameengine/Converter/BL_BlenderDataConversion.h index cea9f7f2a8b..0e8ea17fc38 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.h +++ b/source/gameengine/Converter/BL_BlenderDataConversion.h @@ -34,7 +34,7 @@ #ifndef __BLENDER_CONVERT #define __BLENDER_CONVERT -#include "GEN_HashedPtr.h" +#include "CTR_HashedPtr.h" #include "STR_String.h" #include "KX_Python.h" #include "KX_PhysicsEngineEnums.h" diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index 6bcdaff10e3..615bb84ac2b 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -60,7 +60,7 @@ public: { return m_blendobj; } - virtual void Relink(GEN_Map*map) + virtual void Relink(CTR_Map*map) { if (m_pDeformer) m_pDeformer->Relink (map); diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index 2a54ea7d9ae..63db9167273 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -46,7 +46,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "GEN_Map.h" +#include "CTR_Map.h" #include "STR_HashedString.h" #include "BLI_math.h" @@ -101,7 +101,7 @@ void BL_MeshDeformer::ProcessReplica() m_lastDeformUpdate = -1; } -void BL_MeshDeformer::Relink(GEN_Map*map) +void BL_MeshDeformer::Relink(CTR_Map*map) { void **h_obj = (*map)[m_gameobj]; diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index b62958c7fd1..90466e930fb 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -51,7 +51,7 @@ class BL_MeshDeformer : public RAS_Deformer public: void VerifyStorage(); void RecalcNormals(); - virtual void Relink(GEN_Map*map); + virtual void Relink(CTR_Map*map); BL_MeshDeformer(BL_DeformableGameObject *gameobj, struct Object* obj, class RAS_MeshObject *meshobj ): diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index 95f362a2879..e504fa7e49d 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -38,7 +38,7 @@ #include "MEM_guardedalloc.h" #include "BL_ModifierDeformer.h" -#include "GEN_Map.h" +#include "CTR_Map.h" #include "STR_HashedString.h" #include "RAS_IPolygonMaterial.h" #include "RAS_MeshObject.h" diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index 229c59a34a4..7a4523d4554 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -34,7 +34,7 @@ #ifndef BL_SHAPEACTIONACTUATOR #define BL_SHAPEACTIONACTUATOR -#include "GEN_HashedPtr.h" +#include "CTR_HashedPtr.h" #include "SCA_IActuator.h" #include "BL_ActionActuator.h" #include "MT_Point3.h" diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 40e7c6e1bde..8d8f149bb6c 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -38,7 +38,7 @@ #include "MEM_guardedalloc.h" #include "BL_ShapeDeformer.h" -#include "GEN_Map.h" +#include "CTR_Map.h" #include "STR_HashedString.h" #include "RAS_IPolygonMaterial.h" #include "RAS_MeshObject.h" diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 4916ce53fc5..34f9cb56c27 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -37,7 +37,7 @@ #endif //WIN32 #include "BL_SkinDeformer.h" -#include "GEN_Map.h" +#include "CTR_Map.h" #include "STR_HashedString.h" #include "RAS_IPolygonMaterial.h" #include "RAS_MeshObject.h" @@ -108,7 +108,7 @@ BL_SkinDeformer::~BL_SkinDeformer() m_armobj->Release(); } -void BL_SkinDeformer::Relink(GEN_Map*map) +void BL_SkinDeformer::Relink(CTR_Map*map) { if (m_armobj) { void **h_obj = (*map)[m_armobj]; diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index 69b8783ce22..e53e21e946f 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -38,7 +38,7 @@ #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 -#include "GEN_HashedPtr.h" +#include "CTR_HashedPtr.h" #include "BL_MeshDeformer.h" #include "BL_ArmatureObject.h" @@ -54,7 +54,7 @@ class BL_SkinDeformer : public BL_MeshDeformer { public: // void SetArmatureController (BL_ArmatureController *cont); - virtual void Relink(GEN_Map*map); + virtual void Relink(CTR_Map*map); void SetArmature (class BL_ArmatureObject *armobj); BL_SkinDeformer(BL_DeformableGameObject *gameobj, diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index 147c8b791ee..bdd0769e0a3 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -26,9 +26,9 @@ set(INC . - ../../../source/kernel/gen_system ../../../intern/string ../../../intern/guardedalloc + ../../../intern/container ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer ../../../intern/audaspace/intern ../../../source/gameengine/Converter diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index a0d58ece396..684ed0b06f9 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -50,7 +50,7 @@ #include "KX_PolygonMaterial.h" -#include "SYS_System.h" +#include "BL_System.h" #include "DummyPhysicsEnvironment.h" @@ -1126,7 +1126,7 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) /* incase the mesh might be refered to later */ { - GEN_Map &mapStringToMeshes = scene->GetLogicManager()->GetMeshMap(); + CTR_Map &mapStringToMeshes = scene->GetLogicManager()->GetMeshMap(); for(int i=0; i &mapStringToActions = scene->GetLogicManager()->GetActionMap(); + CTR_Map &mapStringToActions = scene->GetLogicManager()->GetActionMap(); for(int i=0; i #include "KX_ISceneConverter.h" @@ -61,12 +61,12 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter // Should also have a list of collision shapes. // For the time being this is held in KX_Scene::m_shapes - GEN_Map m_map_blender_to_gameobject; /* cleared after conversion */ - GEN_Map m_map_mesh_to_gamemesh; /* cleared after conversion */ - GEN_Map m_map_blender_to_gameactuator; /* cleared after conversion */ - GEN_Mapm_map_blender_to_gamecontroller; /* cleared after conversion */ + CTR_Map m_map_blender_to_gameobject; /* cleared after conversion */ + CTR_Map m_map_mesh_to_gamemesh; /* cleared after conversion */ + CTR_Map m_map_blender_to_gameactuator; /* cleared after conversion */ + CTR_Mapm_map_blender_to_gamecontroller; /* cleared after conversion */ - GEN_Map m_map_blender_to_gameAdtList; + CTR_Map m_map_blender_to_gameAdtList; Main* m_maggie; vector m_DynamicMaggie; diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp index d3d17bbe433..02c259d793b 100644 --- a/source/gameengine/Converter/KX_SoftBodyDeformer.cpp +++ b/source/gameengine/Converter/KX_SoftBodyDeformer.cpp @@ -41,8 +41,8 @@ #include "KX_ConvertPhysicsObject.h" #include "KX_SoftBodyDeformer.h" #include "RAS_MeshObject.h" -#include "GEN_Map.h" -#include "GEN_HashedPtr.h" +#include "CTR_Map.h" +#include "CTR_HashedPtr.h" #ifdef USE_BULLET @@ -53,7 +53,7 @@ #include "KX_BulletPhysicsController.h" #include "btBulletDynamicsCommon.h" -void KX_SoftBodyDeformer::Relink(GEN_Map*map) +void KX_SoftBodyDeformer::Relink(CTR_Map*map) { void **h_obj = (*map)[m_gameobj]; diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.h b/source/gameengine/Converter/KX_SoftBodyDeformer.h index aa4ff9d5e54..67eb9d7b285 100644 --- a/source/gameengine/Converter/KX_SoftBodyDeformer.h +++ b/source/gameengine/Converter/KX_SoftBodyDeformer.h @@ -60,7 +60,7 @@ public: { //printf("~KX_SoftBodyDeformer\n"); }; - virtual void Relink(GEN_Map*map); + virtual void Relink(CTR_Map*map); virtual bool Apply(class RAS_IPolyMaterial *polymat); virtual bool Update(void) { diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index 9d88018d805..9cfc3410748 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -4,7 +4,7 @@ Import ('env') sources = env.Glob('*.cpp') defs = [] -incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc' +incs = '. #intern/string #intern/guardedalloc #intern/container' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' incs += ' #intern/audaspace/intern #source/gameengine/Converter' incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf' diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt index c593c690614..8cda0e2dc77 100644 --- a/source/gameengine/Expressions/CMakeLists.txt +++ b/source/gameengine/Expressions/CMakeLists.txt @@ -26,7 +26,6 @@ set(INC . - ../../../source/kernel/gen_system ../../../intern/string ../../../intern/guardedalloc ../../../intern/moto/include diff --git a/source/gameengine/Expressions/SConscript b/source/gameengine/Expressions/SConscript index b1e34aa358b..4dc165a7696 100644 --- a/source/gameengine/Expressions/SConscript +++ b/source/gameengine/Expressions/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.cpp') -incs ='. #source/kernel/gen_system #intern/guardedalloc #intern/string #intern/moto/include #source/gameengine/SceneGraph #source/blender/blenloader' +incs ='. #intern/guardedalloc #intern/string #intern/moto/include #source/gameengine/SceneGraph #source/blender/blenloader' defs = [] diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 793b8e7eed8..2acf07584b1 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC . - ../../../source/kernel/gen_system ../../../intern/string + ../../../intern/container ../../../source/gameengine/Expressions ../../../source/gameengine/SceneGraph ../../../intern/moto/include diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index 2d0cb16b63c..596118855d2 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -78,7 +78,7 @@ void SCA_ILogicBrick::ReParent(SCA_IObject* parent) m_gameobj = parent; } -void SCA_ILogicBrick::Relink(GEN_Map *obj_map) +void SCA_ILogicBrick::Relink(CTR_Map *obj_map) { // nothing to do } diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index e74cd601b6b..4de0562339e 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -37,8 +37,8 @@ #include "Value.h" #include "SCA_IObject.h" #include "BoolValue.h" -#include "GEN_Map.h" -#include "GEN_HashedPtr.h" +#include "CTR_Map.h" +#include "CTR_HashedPtr.h" class NG_NetworkScene; class SCA_IScene; @@ -70,7 +70,7 @@ public: SCA_IObject* GetParent() { return m_gameobj; } virtual void ReParent(SCA_IObject* parent); - virtual void Relink(GEN_Map *obj_map); + virtual void Relink(CTR_Map *obj_map); virtual void Delete() { Release(); } // act as a BoolValue (with value IsPositiveTrigger) diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index 44dc12a8fd4..c4735d1c146 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -38,12 +38,12 @@ #endif #include -//#include "GEN_Map.h" +//#include "CTR_Map.h" #include #include #include -#include "GEN_Map.h" +#include "CTR_Map.h" #include "STR_HashedString.h" #include "Value.h" #include "SG_QList.h" @@ -85,12 +85,12 @@ class SCA_LogicManager // need to find better way for this // also known as FactoryManager... - GEN_Map m_mapStringToGameObjects; - GEN_Map m_mapStringToMeshes; - GEN_Map m_mapStringToActions; + CTR_Map m_mapStringToGameObjects; + CTR_Map m_mapStringToMeshes; + CTR_Map m_mapStringToActions; - GEN_Map m_map_gamemeshname_to_blendobj; - GEN_Map m_map_blendobj_to_gameobj; + CTR_Map m_map_gamemeshname_to_blendobj; + CTR_Map m_map_blendobj_to_gameobj; public: SCA_LogicManager(); virtual ~SCA_LogicManager(); @@ -129,8 +129,8 @@ public: // for the scripting... needs a FactoryManager later (if we would have time... ;) void RegisterMeshName(const STR_String& meshname,void* mesh); void UnregisterMeshName(const STR_String& meshname,void* mesh); - GEN_Map& GetMeshMap() { return m_mapStringToMeshes; }; - GEN_Map& GetActionMap() { return m_mapStringToActions; }; + CTR_Map& GetMeshMap() { return m_mapStringToMeshes; }; + CTR_Map& GetActionMap() { return m_mapStringToActions; }; void RegisterActionName(const STR_String& actname,void* action); diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 008e109384c..a4af1c35652 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -213,7 +213,7 @@ bool SCA_PropertyActuator::UnlinkObject(SCA_IObject* clientobj) return false; } -void SCA_PropertyActuator::Relink(GEN_Map *obj_map) +void SCA_PropertyActuator::Relink(CTR_Map *obj_map) { void **h_obj = (*obj_map)[m_sourceObj]; if (h_obj) { diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h index 1ca7b1c4e1e..35660710679 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.h +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h @@ -77,7 +77,7 @@ public: virtual void ProcessReplica(); virtual bool UnlinkObject(SCA_IObject* clientobj); - virtual void Relink(GEN_Map *obj_map); + virtual void Relink(CTR_Map *obj_map); virtual bool Update(); diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index a8d3ee65f4c..d6323882267 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp') -incs = '. #/source/kernel/gen_system #/intern/string' +incs = '. #/intern/string #intern/container' incs += ' #/source/gameengine/Expressions #/intern/moto/include' incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph' diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index 604dd9296a1..afbc49ea38d 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -29,11 +29,11 @@ set(INC ../../../../intern/string ../../../../intern/ghost ../../../../intern/guardedalloc + ../../../../intern/container ../../../../intern/moto/include ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../../source/kernel/gen_system - ../../../../source/kernel/gen_messaging ../../../../source/gameengine/Converter + ../../../../source/gameengine/BlenderRoutines ../../../../source/blender/imbuf ../../../../source/gameengine/Ketsji ../../../../source/blender/blenlib diff --git a/source/gameengine/GamePlayer/common/GPC_Engine.cpp b/source/gameengine/GamePlayer/common/GPC_Engine.cpp index 48ebfcaadf2..fc007d8d295 100644 --- a/source/gameengine/GamePlayer/common/GPC_Engine.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Engine.cpp @@ -50,7 +50,7 @@ // include files needed by "KX_BlenderSceneConverter.h" -#include "GEN_Map.h" +#include "CTR_Map.h" #include "SCA_IActuator.h" #include "RAS_MeshObject.h" diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index f7a423f4588..d5e1f081d21 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -19,10 +19,10 @@ incs = ['.', '#intern/ghost', '#intern/guardedalloc', '#intern/moto/include', + '#intern/container', '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - '#source/kernel/gen_system', - '#source/kernel/gen_messaging', '#source/gameengine/Converter', + '#source/gameengine/BlenderRoutines', '#source/blender/imbuf', '#source/gameengine/Ketsji', '#source/blender/blenlib', diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index a88de69b272..389300efc21 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -29,17 +29,16 @@ set(INC ../../../../intern/string ../../../../intern/ghost ../../../../intern/guardedalloc + ../../../../intern/container ../../../../intern/moto/include ../../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../../source/kernel/gen_system - ../../../../source/kernel/gen_messaging + ../../../../source/gameengine/BlenderRoutines ../../../../source/gameengine/Converter ../../../../source/blender/imbuf ../../../../source/gameengine/Ketsji ../../../../source/blender/blenfont ../../../../source/blender/blenlib ../../../../source/blender/blenkernel - ../../../../source/blender/readblenfile ../../../../source/blender ../../../../source/blender/makesdna ../../../../source/blender/makesrna diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 6ea98e0e8cc..6487d0298c7 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -69,11 +69,11 @@ extern "C" **********************************/ -#include "SYS_System.h" +#include "BL_System.h" #include "KX_KetsjiEngine.h" // include files needed by "KX_BlenderSceneConverter.h" -#include "GEN_Map.h" +#include "CTR_Map.h" #include "SCA_IActuator.h" #include "RAS_MeshObject.h" #include "RAS_OpenGLRasterizer.h" diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 0ab6da240ce..75181b6c330 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -47,7 +47,6 @@ //#include //#include #endif // __APPLE__ -#include "GEN_messaging.h" #include "KX_KetsjiEngine.h" #include "KX_PythonInit.h" @@ -68,7 +67,7 @@ extern "C" #include "DNA_scene_types.h" #include "DNA_userdef_types.h" #include "BLO_readfile.h" -#include "BLO_readblenfile.h" +#include "BLO_runtime.h" #include "IMB_imbuf.h" #include "BKE_text.h" @@ -92,7 +91,7 @@ extern char datatoc_bfont_ttf[]; * End Blender include block **********************************/ -#include "SYS_System.h" +#include "BL_System.h" #include "GPG_Application.h" #include "GHOST_ISystem.h" @@ -314,8 +313,8 @@ static BlendFileData *load_game_data(char *progname, char *filename = NULL, char BKE_reports_init(&reports, RPT_STORE); /* try to load ourself, will only work if we are a runtime */ - if (blo_is_a_runtime(progname)) { - bfd= blo_read_runtime(progname, &reports); + if (BLO_is_a_runtime(progname)) { + bfd= BLO_read_runtime(progname, &reports); if (bfd) { bfd->type= BLENFILETYPE_RUNTIME; strcpy(bfd->main->name, progname); @@ -346,7 +345,9 @@ int main(int argc, char** argv) bool fullScreen = false; bool fullScreenParFound = false; bool windowParFound = false; +#ifdef WIN32 bool closeConsole = true; +#endif RAS_IRasterizer::StereoMode stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO; bool stereoWindow = false; bool stereoParFound = false; @@ -403,8 +404,6 @@ int main(int argc, char** argv) initglobals(); - GEN_init_messaging_system(); - IMB_init(); // Setup builtin font for BLF (mostly copied from creator.c, wm_init_exit.c and interface_style.c) @@ -447,7 +446,7 @@ int main(int argc, char** argv) U.audiochannels = 2; /* if running blenderplayer the last argument can't be parsed since it has to be the filename. */ - isBlenderPlayer = !blo_is_a_runtime(argv[0]); + isBlenderPlayer = !BLO_is_a_runtime(argv[0]); if (isBlenderPlayer) validArguments = argc - 1; else @@ -573,7 +572,9 @@ int main(int argc, char** argv) break; case 'c': i++; +#ifdef WIN32 closeConsole = false; +#endif break; case 's': // stereo i++; diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index 7c8f1c6f4f0..e3ffc1a406b 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -13,16 +13,15 @@ incs = ['.', '#intern/ghost', '#intern/guardedalloc', '#intern/moto/include', + '#intern/container', '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer', - '#source/kernel/gen_system', - '#source/kernel/gen_messaging', + '#source/gameengine/BlenderRoutines', '#source/gameengine/Converter', '#source/blender/imbuf', '#source/gameengine/Ketsji', '#source/blender/blenfont', '#source/blender/blenlib', '#source/blender/blenkernel', - '#source/blender/readblenfile', '#source/blender', '#source/blender/include', '#source/blender/makesdna', diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index 126135f3d46..ef25c9218a3 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -144,7 +144,7 @@ enum BL_flag USEALPHA=4, // use actual alpha channel TEXALPHA=8, // use alpha combiner functions TEXNEG=16, // negate blending - HASIPO=32, + /*HASIPO=32,*/ // unused, commeted for now. USENEGALPHA=64 }; diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index d5ea39f5b35..0bfe1fd0266 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -26,11 +26,12 @@ set(INC . - ../../../source/kernel/gen_system ../../../intern/string ../../../intern/guardedalloc + ../../../intern/container ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer ../../../source/gameengine/Converter + ../../../source/gameengine/BlenderRoutines ../../../source/blender/imbuf ../../../intern/moto/include ../../../source/gameengine/Ketsji diff --git a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt index 5f251c832ee..17a5929420d 100644 --- a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt +++ b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC . - ../../../../source/kernel/gen_system ../../../../intern/string + ../../../../intern/container ../../../../intern/moto/include ../../../../source/gameengine/Ketsji ../../../../source/gameengine/GameLogic diff --git a/source/gameengine/Ketsji/KXNetwork/SConscript b/source/gameengine/Ketsji/KXNetwork/SConscript index 78cdc8df9af..3d696501203 100644 --- a/source/gameengine/Ketsji/KXNetwork/SConscript +++ b/source/gameengine/Ketsji/KXNetwork/SConscript @@ -3,7 +3,8 @@ Import ('env') sources = env.Glob('*.cpp') -incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Ketsji' +incs = '. #intern/string #intern/moto/include' +incs += ' #source/gameengine/Ketsji #intern/container' incs += ' #source/gameengine/GameLogic #source/gameengine/Expressions' incs += ' #source/gameengine/Network #source/gameengine/SceneGraph' diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 17dfe9474a8..d68cb453fe8 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -101,7 +101,7 @@ bool KX_CameraActuator::UnlinkObject(SCA_IObject* clientobj) } -void KX_CameraActuator::Relink(GEN_Map *obj_map) +void KX_CameraActuator::Relink(CTR_Map *obj_map) { void **h_obj = (*obj_map)[m_ob]; if (h_obj) { diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index 135a9cad9d8..d59fcff9370 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -116,7 +116,7 @@ private : virtual bool UnlinkObject(SCA_IObject* clientobj); /** Methods inherited from SCA_ILogicBrick */ - virtual void Relink(GEN_Map *obj_map); + virtual void Relink(CTR_Map *obj_map); #ifdef WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index b7cc98bd539..7bd8c445849 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -42,13 +42,13 @@ #include "BL_DeformableGameObject.h" #include "RAS_MeshObject.h" #include "KX_Scene.h" -#include "SYS_System.h" +#include "BL_System.h" #include "PHY_Pro.h" //todo cleanup #include "KX_ClientObjectInfo.h" -#include "GEN_Map.h" -#include "GEN_HashedPtr.h" +#include "CTR_Map.h" +#include "CTR_HashedPtr.h" #include "KX_PhysicsEngineEnums.h" #include "PHY_Pro.h" diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index d8bc7510c7b..47d83c16659 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1224,7 +1224,7 @@ CListValue* KX_GameObject::GetChildrenRecursive() /* --------------------------------------------------------------------- * Some stuff taken from the header * --------------------------------------------------------------------- */ -void KX_GameObject::Relink(GEN_Map *map_parameter) +void KX_GameObject::Relink(CTR_Map *map_parameter) { // we will relink the sensors and actuators that use object references // if the object is part of the replicated hierarchy, use the new diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index b54fb6b068e..50fbebe1341 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -47,8 +47,8 @@ #include "SG_Node.h" #include "MT_Transform.h" #include "MT_CmMatrix4x4.h" -#include "GEN_Map.h" -#include "GEN_HashedPtr.h" +#include "CTR_Map.h" +#include "CTR_HashedPtr.h" #include "KX_Scene.h" #include "KX_KetsjiEngine.h" /* for m_anim_framerate */ #include "KX_IPhysicsController.h" /* for suspend/resume */ @@ -142,7 +142,7 @@ public: virtual void /* This function should be virtual - derived classed override it */ Relink( - GEN_Map *map + CTR_Map *map ); /** diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 8c3e25cf3e2..7289ffc6e29 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -299,7 +299,7 @@ bool KX_ObjectActuator::UnlinkObject(SCA_IObject* clientobj) return false; } -void KX_ObjectActuator::Relink(GEN_Map *obj_map) +void KX_ObjectActuator::Relink(CTR_Map *obj_map) { void **h_obj = (*obj_map)[m_reference]; if (h_obj) { diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index e45ce899bfc..0737535b84c 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -144,7 +144,7 @@ public: CValue* GetReplica(); void ProcessReplica(); bool UnlinkObject(SCA_IObject* clientobj); - void Relink(GEN_Map *obj_map); + void Relink(CTR_Map *obj_map); void SetForceLoc(const double force[3]) { /*m_force=force;*/ } void UpdateFuzzyFlags() diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 6ff1c05b994..a73f4c38627 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -99,7 +99,7 @@ bool KX_ParentActuator::UnlinkObject(SCA_IObject* clientobj) return false; } -void KX_ParentActuator::Relink(GEN_Map *obj_map) +void KX_ParentActuator::Relink(CTR_Map *obj_map) { void **h_obj = (*obj_map)[m_ob]; if (h_obj) { diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index 8723f83920e..a850cc72eb9 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -76,7 +76,7 @@ class KX_ParentActuator : public SCA_IActuator virtual CValue* GetReplica(); virtual void ProcessReplica(); - virtual void Relink(GEN_Map *obj_map); + virtual void Relink(CTR_Map *obj_map); virtual bool UnlinkObject(SCA_IObject* clientobj); #ifdef WITH_PYTHON diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 521c0038f27..62a51fb4efc 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -151,7 +151,7 @@ bool KX_SCA_AddObjectActuator::UnlinkObject(SCA_IObject* clientobj) return false; } -void KX_SCA_AddObjectActuator::Relink(GEN_Map *obj_map) +void KX_SCA_AddObjectActuator::Relink(CTR_Map *obj_map) { void **h_obj = (*obj_map)[m_OriginalObject]; if (h_obj) { diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 11f210ad7b5..a8304667b66 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -108,7 +108,7 @@ public: UnlinkObject(SCA_IObject* clientobj); virtual void - Relink(GEN_Map *obj_map); + Relink(CTR_Map *obj_map); virtual bool Update(); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 080765c7846..28dc660037c 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -67,7 +67,7 @@ #include "SCA_IController.h" #include "SCA_IActuator.h" #include "SG_Node.h" -#include "SYS_System.h" +#include "BL_System.h" #include "SG_Controller.h" #include "SG_IObject.h" #include "SG_Tree.h" diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index af6a31e786c..367bf0b82da 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -41,8 +41,8 @@ #include #include -#include "GEN_Map.h" -#include "GEN_HashedPtr.h" +#include "CTR_Map.h" +#include "CTR_HashedPtr.h" #include "SG_IObject.h" #include "SCA_IScene.h" #include "MT_Transform.h" @@ -61,7 +61,7 @@ struct SM_MaterialProps; struct SM_ShapeProps; struct Scene; -class GEN_HashedPtr; +class CTR_HashedPtr; class CListValue; class CValue; class SCA_LogicManager; @@ -207,7 +207,7 @@ protected: * used in AddReplicaObject to map game objects to their * replicas so pointers can be updated. */ - GEN_Map m_map_gameobject_to_replica; + CTR_Map m_map_gameobject_to_replica; /** * Another temporary variable outstaying its welcome diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index 8312a14ebfb..f572f8eb36d 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -97,7 +97,7 @@ bool KX_SceneActuator::UnlinkObject(SCA_IObject* clientobj) return false; } -void KX_SceneActuator::Relink(GEN_Map *obj_map) +void KX_SceneActuator::Relink(CTR_Map *obj_map) { void **h_obj = (*obj_map)[m_camera]; if (h_obj) { diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index 563255d1560..288f4acc280 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -85,7 +85,7 @@ class KX_SceneActuator : public SCA_IActuator virtual CValue* GetReplica(); virtual void ProcessReplica(); virtual bool UnlinkObject(SCA_IObject* clientobj); - virtual void Relink(GEN_Map *obj_map); + virtual void Relink(CTR_Map *obj_map); virtual bool Update(); diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 5530fa286cf..edcba969811 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -219,7 +219,7 @@ bool KX_TrackToActuator::UnlinkObject(SCA_IObject* clientobj) return false; } -void KX_TrackToActuator::Relink(GEN_Map *obj_map) +void KX_TrackToActuator::Relink(CTR_Map *obj_map) { void **h_obj = (*obj_map)[m_object]; if (h_obj) { diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index 33780bf53e4..c5e96bd7454 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -67,7 +67,7 @@ class KX_TrackToActuator : public SCA_IActuator virtual void ProcessReplica(); virtual bool UnlinkObject(SCA_IObject* clientobj); - virtual void Relink(GEN_Map *obj_map); + virtual void Relink(CTR_Map *obj_map); virtual bool Update(double curtime, bool frame); #ifdef WITH_PYTHON diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 56e0db0cc20..08642262724 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -8,7 +8,7 @@ defs = [ 'GLEW_STATIC' ] incs = '. #source/blender/python/generic' # Only for Mathutils! and bpy_internal_import.h, be very careful -incs += ' #source/kernel/gen_system #intern/string #intern/guardedalloc' +incs += ' #intern/string #intern/guardedalloc #intern/container' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' incs += ' #intern/audaspace/intern #source/gameengine/Converter' incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf #intern/moto/include' diff --git a/source/gameengine/Network/CMakeLists.txt b/source/gameengine/Network/CMakeLists.txt index 6a2b5fe841e..7f4c7c357da 100644 --- a/source/gameengine/Network/CMakeLists.txt +++ b/source/gameengine/Network/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC . - ../../../source/kernel/gen_system ../../../intern/string + ../../../intern/container ../../../intern/moto/include ) diff --git a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt index 4cf43a1fc93..d7b88304474 100644 --- a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt +++ b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt @@ -26,8 +26,8 @@ set(INC . - ../../../../source/kernel/gen_system ../../../../intern/string + ../../../../intern/container ../../../../source/gameengine/Network ) diff --git a/source/gameengine/Network/LoopBackNetwork/SConscript b/source/gameengine/Network/LoopBackNetwork/SConscript index af76065cc94..7ca0a64f774 100644 --- a/source/gameengine/Network/LoopBackNetwork/SConscript +++ b/source/gameengine/Network/LoopBackNetwork/SConscript @@ -3,6 +3,6 @@ Import ('env') sources = 'NG_LoopBackNetworkDeviceInterface.cpp' -incs = '. #source/kernel/gen_system #intern/string #source/gameengine/Network' +incs = '. #intern/string #intern/container #source/gameengine/Network' env.BlenderLib ( 'ge_logic_loopbacknetwork', Split(sources), Split(incs), defines=[],libtype=['core','player'], priority=[400,135] ) diff --git a/source/gameengine/Network/NG_NetworkScene.h b/source/gameengine/Network/NG_NetworkScene.h index d390eabc465..ebe50d36b46 100644 --- a/source/gameengine/Network/NG_NetworkScene.h +++ b/source/gameengine/Network/NG_NetworkScene.h @@ -34,7 +34,7 @@ #ifndef __NG_NETWORKSCENE_H #define __NG_NETWORKSCENE_H -#include "GEN_Map.h" +#include "CTR_Map.h" #include "STR_HashedString.h" #include @@ -52,10 +52,10 @@ class NG_NetworkDeviceInterface; class NG_NetworkScene { class NG_NetworkDeviceInterface *m_networkdevice; - GEN_Map m_networkObjects; + CTR_Map m_networkObjects; - // GEN_Maps used as a 'Bloom' filter - typedef GEN_Map* > TMessageMap; + // CTR_Maps used as a 'Bloom' filter + typedef CTR_Map* > TMessageMap; TMessageMap m_messagesByDestinationName; TMessageMap m_messagesBySenderName; TMessageMap m_messagesBySubject; diff --git a/source/gameengine/Network/SConscript b/source/gameengine/Network/SConscript index 1b63592d0a4..bbf714383b7 100644 --- a/source/gameengine/Network/SConscript +++ b/source/gameengine/Network/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.cpp') #'NG_NetworkMessage.cpp NG_NetworkObject.cpp NG_NetworkScene.cpp' -incs = '. #source/kernel/gen_system #intern/string #intern/moto/include' +incs = '. #intern/string #intern/moto/include #intern/container' defs = [] diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt index cc469c3772a..a984d0436f0 100644 --- a/source/gameengine/Physics/Bullet/CMakeLists.txt +++ b/source/gameengine/Physics/Bullet/CMakeLists.txt @@ -33,7 +33,7 @@ set(INC ../../../../extern/bullet2/src ../../../../intern/moto/include ../../../../intern/guardedalloc - ../../../kernel/gen_system + ../../../../intern/container ../../../../intern/string ../../Rasterizer ../../Ketsji diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript index f8f0f8afaea..ba4db001533 100644 --- a/source/gameengine/Physics/Bullet/SConscript +++ b/source/gameengine/Physics/Bullet/SConscript @@ -4,7 +4,6 @@ Import ('env') sources = 'CcdPhysicsEnvironment.cpp CcdPhysicsController.cpp CcdGraphicController.cpp' incs = '. ../common' -incs += ' #source/kernel/gen_system' incs += ' #intern/string' incs += ' #intern/moto/include' incs += ' #extern/glew/include' @@ -17,6 +16,7 @@ incs += ' #source/blender/makesdna' incs += ' #source/blender/blenkernel' incs += ' #source/blender/blenlib' incs += ' #intern/guardedalloc' +incs += ' #intern/container' incs += ' ' + env['BF_BULLET_INC'] diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index 7e2fda177d7..2bfb3f8f328 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -26,11 +26,11 @@ set(INC . - ../../../source/kernel/gen_system ../../../source/blender/makesdna ../../../source/gameengine/SceneGraph ../../../source/gameengine/Ketsji ../../../intern/string + ../../../intern/container ../../../intern/moto/include ../../../intern/guardedalloc ../Expressions diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 8c9f5e9786b..6316b119588 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -36,7 +36,7 @@ #pragma warning (disable:4786) #endif -#include "GEN_Map.h" +#include "CTR_Map.h" #include "RAS_MaterialBucket.h" #include "STR_HashedString.h" #include "RAS_MeshObject.h" diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index 297782bd4fe..8a9f21d5db7 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -36,7 +36,7 @@ #include "MT_Transform.h" #include "RAS_MaterialBucket.h" -#include "GEN_Map.h" +#include "CTR_Map.h" #include diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index 8678830f6a2..c7a32b38e04 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -39,7 +39,7 @@ #endif //WIN32 #include -#include "GEN_Map.h" +#include "CTR_Map.h" #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" @@ -53,7 +53,7 @@ class RAS_Deformer public: RAS_Deformer() : m_pMesh(NULL), m_bDynamic(false) {}; virtual ~RAS_Deformer(){}; - virtual void Relink(GEN_Map*map)=0; + virtual void Relink(CTR_Map*map)=0; virtual bool Apply(class RAS_IPolyMaterial *polymat)=0; virtual bool Update(void)=0; virtual bool UpdateBuckets(void)=0; diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index c46a36768ee..51c430dd57b 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -35,7 +35,7 @@ #define __RAS_MATERIALBUCKET #include "RAS_TexVert.h" -#include "GEN_Map.h" +#include "CTR_Map.h" #include "STR_HashedString.h" #include "SG_QList.h" @@ -193,7 +193,7 @@ class RAS_MeshMaterial public: RAS_MeshSlot *m_baseslot; class RAS_MaterialBucket *m_bucket; - GEN_Map m_slots; + CTR_Map m_slots; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index 0b35b212e1d..555a290ba6f 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -47,7 +47,7 @@ #include "RAS_MaterialBucket.h" #include "MT_Transform.h" -#include "GEN_HashedPtr.h" +#include "CTR_HashedPtr.h" struct Mesh; class RAS_Deformer; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index 7c1dd8a2de8..99068aa1bb8 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -25,12 +25,13 @@ # ***** END GPL LICENSE BLOCK ***** set(INC - ../../../../source/kernel/gen_system ../../../../intern/string + ../../../../intern/container ../../../../intern/moto/include ../../../../source/gameengine/Rasterizer ../../../../source/gameengine/Ketsji ../../../../source/gameengine/SceneGraph + ../../../../source/gameengine/BlenderRoutines ../../../../source/blender/gpu ../../../../source/blender/makesdna ../../../../source/blender/blenkernel diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index 890d1efb850..5f3af7360ff 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -5,10 +5,10 @@ sources = env.Glob('*.cpp') defs = [ 'GLEW_STATIC' ] -incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines ' -incs += ' #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC'] +incs = '. #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines ' +incs += ' #intern/container #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC'] incs += ' #source/blender/gameengine/Ketsji #source/gameengine/SceneGraph #source/blender/makesdna #source/blender/blenkernel' -incs += ' #intern/guardedalloc #source/blender/blenlib' +incs += ' #intern/guardedalloc #source/blender/blenlib #source/gameengine/BlenderRoutines' if env['WITH_BF_CXX_GUARDEDALLOC']: defs.append('WITH_CXX_GUARDEDALLOC') diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index bff2a7e2084..4164271ba9b 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -4,7 +4,7 @@ Import ('env') sources = env.Glob('*.cpp') -incs = '. #intern/guardedalloc #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions #source/gameengine/SceneGraph #source/blender/blenkernel #source/blender/makesdna' +incs = '. #intern/guardedalloc #intern/string #intern/moto/include #intern/container #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions #source/gameengine/SceneGraph #source/blender/blenkernel #source/blender/makesdna' defs = [ 'GLEW_STATIC' ] diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt index aae57fce679..fb10b619f17 100644 --- a/source/gameengine/VideoTexture/CMakeLists.txt +++ b/source/gameengine/VideoTexture/CMakeLists.txt @@ -41,7 +41,7 @@ set(INC ../../../source/blender/python ../../../source/blender/python/generic ../../../source/blender/gpu - ../../../source/kernel/gen_system + ../../../intern/container ../../../intern/string ../../../intern/moto/include ../../../intern/guardedalloc diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript index 2cd143d2deb..5091082e87a 100644 --- a/source/gameengine/VideoTexture/SConscript +++ b/source/gameengine/VideoTexture/SConscript @@ -11,8 +11,8 @@ incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' incs += ' #source/gameengine/BlenderRoutines' incs += ' #source/blender/editors/include #source/blender/blenlib #source/blender/blenkernel' incs += ' #source/blender/makesdna #source/blender/imbuf #source/blender/python #source/blender/python/generic' -incs += ' #source/blender/gpu #source/kernel/gen_system #intern/string #intern/moto/include' -incs += ' #intern/guardedalloc #extern/glew/include' +incs += ' #source/blender/gpu #intern/string #intern/moto/include' +incs += ' #intern/guardedalloc #intern/container #extern/glew/include' defs = [] if env['OURPLATFORM'] in ('win32-vc', 'win64-vc','win32-mingw'): diff --git a/source/icons/blender.exe.manifest b/source/icons/blender.exe.manifest index bc13bf4c586..a43d11b21a0 100644 --- a/source/icons/blender.exe.manifest +++ b/source/icons/blender.exe.manifest @@ -1,10 +1,10 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/source/kernel/CMakeLists.txt b/source/kernel/CMakeLists.txt deleted file mode 100644 index bcf967cff12..00000000000 --- a/source/kernel/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -# $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. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurain. -# -# ***** END GPL LICENSE BLOCK ***** - -set(INC - gen_messaging - gen_system - ../../intern/string - ../../intern/moto/include - ../../source/blender/blenloader -) - -set(SRC - gen_messaging/intern/messaging.c - gen_system/GEN_HashedPtr.cpp - gen_system/SYS_SingletonSystem.cpp - gen_system/SYS_System.cpp - - gen_messaging/GEN_messaging.h - gen_system/GEN_HashedPtr.h - gen_system/GEN_Map.h - gen_system/SYS_SingletonSystem.h - gen_system/SYS_System.h -) - -blender_add_lib(bf_gen_system "${SRC}" "${INC}") diff --git a/source/kernel/SConscript b/source/kernel/SConscript deleted file mode 100644 index 8dd0fd36e8a..00000000000 --- a/source/kernel/SConscript +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/python -Import ('env') - -sources = 'gen_messaging/intern/messaging.c gen_system/GEN_HashedPtr.cpp' -sources += ' gen_system/SYS_SingletonSystem.cpp' -sources += ' gen_system/SYS_System.cpp' - -incs = 'gen_messaging gen_system #/intern/string #/intern/moto/include #/source/blender/blenloader ' - -env.BlenderLib ( 'bf_gen_system', Split(sources), Split(incs), [], libtype = ['core','player'], priority = [400,100] ) diff --git a/source/kernel/gen_messaging/GEN_messaging.h b/source/kernel/gen_messaging/GEN_messaging.h deleted file mode 100644 index 866716f3914..00000000000 --- a/source/kernel/gen_messaging/GEN_messaging.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file kernel/gen_messaging/GEN_messaging.h - * \ingroup genmess - */ - -#ifndef GEN_MESSAGING_H -#define GEN_MESSAGING_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - /** - * Stream for error messages. - */ - extern FILE* GEN_errorstream; - - /** - * Stream for notices to the user. - */ - extern FILE* GEN_userstream; - - /** - * Initialise the messaging system. If the system is not - * initialised, the streams cannot be used. */ - void GEN_init_messaging_system(void); - -#ifdef __cplusplus -} -#endif - -#endif /* GEN_MESSAGING_H */ - diff --git a/source/kernel/gen_system/GEN_HashedPtr.cpp b/source/kernel/gen_system/GEN_HashedPtr.cpp deleted file mode 100644 index f065d27bee2..00000000000 --- a/source/kernel/gen_system/GEN_HashedPtr.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -/** \file kernel/gen_system/GEN_HashedPtr.cpp - * \ingroup gensys - */ - -#include "GEN_HashedPtr.h" - -#include "BLO_sys_types.h" // for intptr_t support - -// -// Build hash index from pointer. Even though the final result -// is a 32-bit integer, use all the bits of the pointer as long -// as possible. -// -#if 1 -unsigned int GEN_Hash(void * inDWord) -{ - uintptr_t key = (uintptr_t)inDWord; -#if 0 - // this is way too complicated - key += ~(key << 16); - key ^= (key >> 5); - key += (key << 3); - key ^= (key >> 13); - key += ~(key << 9); - key ^= (key >> 17); - - return (unsigned int)(key & 0xffffffff); -#else - return (unsigned int)(key ^ (key>>4)); -#endif -} -#endif diff --git a/source/kernel/gen_system/GEN_Map.h b/source/kernel/gen_system/GEN_Map.h deleted file mode 100644 index 4ac5a10c4c6..00000000000 --- a/source/kernel/gen_system/GEN_Map.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file kernel/gen_system/GEN_Map.h - * \ingroup gensys - */ - -#ifndef GEN_MAP_H -#define GEN_MAP_H - -template -class GEN_Map { -private: - struct Entry { - Entry (Entry *next, Key key, Value value) : - m_next(next), - m_key(key), - m_value(value) {} - - Entry *m_next; - Key m_key; - Value m_value; - }; - -public: - GEN_Map(int num_buckets = 100) : m_num_buckets(num_buckets) { - m_buckets = new Entry *[num_buckets]; - for (int i = 0; i < num_buckets; ++i) { - m_buckets[i] = 0; - } - } - - GEN_Map(const GEN_Map& map) - { - m_num_buckets = map.m_num_buckets; - m_buckets = new Entry *[m_num_buckets]; - - for (int i = 0; i < m_num_buckets; ++i) { - m_buckets[i] = 0; - - for(Entry *entry = map.m_buckets[i]; entry; entry=entry->m_next) - insert(entry->m_key, entry->m_value); - } - } - - int size() { - int count=0; - for (int i=0;im_next; - count++; - } - } - return count; - } - - Value* at(int index) { - int count=0; - for (int i=0;im_value; - } - bucket = bucket->m_next; - count++; - } - } - return 0; - } - - Key* getKey(int index) { - int count=0; - for (int i=0;im_key; - } - bucket = bucket->m_next; - count++; - } - } - return 0; - } - - void clear() { - for (int i = 0; i < m_num_buckets; ++i) { - Entry *entry_ptr = m_buckets[i]; - - while (entry_ptr != 0) { - Entry *tmp_ptr = entry_ptr->m_next; - delete entry_ptr; - entry_ptr = tmp_ptr; - } - m_buckets[i] = 0; - } - } - - ~GEN_Map() { - clear(); - delete [] m_buckets; - } - - void insert(const Key& key, const Value& value) { - Entry *entry_ptr = m_buckets[key.hash() % m_num_buckets]; - while ((entry_ptr != 0) && !(key == entry_ptr->m_key)) { - entry_ptr = entry_ptr->m_next; - } - - if (entry_ptr != 0) { - entry_ptr->m_value = value; - } - else { - Entry **bucket = &m_buckets[key.hash() % m_num_buckets]; - *bucket = new Entry(*bucket, key, value); - } - } - - void remove(const Key& key) { - Entry **entry_ptr = &m_buckets[key.hash() % m_num_buckets]; - while ((*entry_ptr != 0) && !(key == (*entry_ptr)->m_key)) { - entry_ptr = &(*entry_ptr)->m_next; - } - - if (*entry_ptr != 0) { - Entry *tmp_ptr = (*entry_ptr)->m_next; - delete *entry_ptr; - *entry_ptr = tmp_ptr; - } - } - - Value *operator[](Key key) { - Entry *bucket = m_buckets[key.hash() % m_num_buckets]; - while ((bucket != 0) && !(key == bucket->m_key)) { - bucket = bucket->m_next; - } - return bucket != 0 ? &bucket->m_value : 0; - } - -private: - int m_num_buckets; - Entry **m_buckets; -}; - -#endif - - diff --git a/source/kernel/gen_system/SYS_SingletonSystem.cpp b/source/kernel/gen_system/SYS_SingletonSystem.cpp deleted file mode 100644 index 08ee186c723..00000000000 --- a/source/kernel/gen_system/SYS_SingletonSystem.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * Unique instance of system class for system specific information / access - * Used by SYS_System - */ - -/** \file kernel/gen_system/SYS_SingletonSystem.cpp - * \ingroup gensys - */ - -#include "SYS_SingletonSystem.h" -// #include "GEN_DataCache.h" - -SYS_SingletonSystem* SYS_SingletonSystem::_instance = 0; - -void SYS_SingletonSystem::Destruct() -{ - if (_instance) { - delete _instance; - _instance = NULL; - } -} - -SYS_SingletonSystem *SYS_SingletonSystem::Instance() -{ - if (!_instance) { - _instance = new SYS_SingletonSystem(); - } - return _instance; -} - -int SYS_SingletonSystem::SYS_GetCommandLineInt(const char *paramname, int defaultvalue) -{ - int *result = m_int_commandlineparms[paramname]; - if (result) - return *result; - - return defaultvalue; -} - -float SYS_SingletonSystem::SYS_GetCommandLineFloat(const char *paramname, float defaultvalue) -{ - float *result = m_float_commandlineparms[paramname]; - if (result) - return *result; - - return defaultvalue; -} - -const char *SYS_SingletonSystem::SYS_GetCommandLineString(const char *paramname, const char *defaultvalue) -{ - STR_String *result = m_string_commandlineparms[paramname]; - if (result) - return *result; - - return defaultvalue; -} - -void SYS_SingletonSystem::SYS_WriteCommandLineInt(const char *paramname, int value) -{ - m_int_commandlineparms.insert(paramname, value); -} - -void SYS_SingletonSystem::SYS_WriteCommandLineFloat(const char *paramname, float value) -{ - m_float_commandlineparms.insert(paramname, value); -} - -void SYS_SingletonSystem::SYS_WriteCommandLineString(const char *paramname, const char *value) -{ - m_string_commandlineparms.insert(paramname, value); -} - -SYS_SingletonSystem::SYS_SingletonSystem() -{ -} diff --git a/source/kernel/gen_system/SYS_SingletonSystem.h b/source/kernel/gen_system/SYS_SingletonSystem.h deleted file mode 100644 index d8628558618..00000000000 --- a/source/kernel/gen_system/SYS_SingletonSystem.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * $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. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * Unique instance of system class for system specific information / access - * Used by SYS_System - */ - -/** \file kernel/gen_system/SYS_SingletonSystem.h - * \ingroup gensys - */ - -#ifndef __SINGLETONSYSTEM_H -#define __SINGLETONSYSTEM_H - -#include "GEN_Map.h" -#include "STR_HashedString.h" - -class SYS_SingletonSystem -{ -public: - static SYS_SingletonSystem* Instance(); - static void Destruct(); - - int SYS_GetCommandLineInt(const char* paramname,int defaultvalue); - float SYS_GetCommandLineFloat(const char* paramname,float defaultvalue); - const char* SYS_GetCommandLineString(const char* paramname,const char* defaultvalue); - - void SYS_WriteCommandLineInt(const char* paramname,int value); - void SYS_WriteCommandLineFloat(const char* paramname,float value); - void SYS_WriteCommandLineString(const char* paramname,const char* value); - - SYS_SingletonSystem(); - -private: - static SYS_SingletonSystem* _instance; - GEN_Map m_int_commandlineparms; - GEN_Map m_float_commandlineparms; - GEN_Map m_string_commandlineparms; -}; - -#endif //__SINGLETONSYSTEM_H -